|
@@ -3,24 +3,27 @@ package com.uas.appme.pedometer.view;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
|
+import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.common.LogUtil;
|
|
import com.common.LogUtil;
|
|
|
import com.core.app.MyApplication;
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.base.BaseActivity;
|
|
import com.core.base.BaseActivity;
|
|
|
import com.core.utils.CommonUtil;
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.helper.AvatarHelper;
|
|
import com.core.utils.helper.AvatarHelper;
|
|
|
import com.core.widget.MyListView;
|
|
import com.core.widget.MyListView;
|
|
|
-import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
|
|
import com.me.network.app.http.HttpClient;
|
|
import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
import com.uas.appme.R;
|
|
import com.uas.appme.R;
|
|
|
|
|
+import com.uas.appme.pedometer.adapter.UUAttentionAdapter;
|
|
|
import com.uas.appme.pedometer.adapter.UURankingAdapter;
|
|
import com.uas.appme.pedometer.adapter.UURankingAdapter;
|
|
|
import com.uas.appme.pedometer.bean.StepEntity;
|
|
import com.uas.appme.pedometer.bean.StepEntity;
|
|
|
|
|
+import com.uas.appme.pedometer.bean.StepsRankingBean;
|
|
|
import com.uas.appme.pedometer.constant.Constant;
|
|
import com.uas.appme.pedometer.constant.Constant;
|
|
|
import com.uas.appme.pedometer.db.StepDataDao;
|
|
import com.uas.appme.pedometer.db.StepDataDao;
|
|
|
import com.uas.appme.pedometer.utils.TimeUtil;
|
|
import com.uas.appme.pedometer.utils.TimeUtil;
|
|
@@ -42,17 +45,17 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
private TextView mStepsTv;
|
|
private TextView mStepsTv;
|
|
|
private TextView mPriseTv;
|
|
private TextView mPriseTv;
|
|
|
private ImageView mPriseIm;
|
|
private ImageView mPriseIm;
|
|
|
- private View mHideAboveAf;
|
|
|
|
|
private LinearLayout mAttentionLl;
|
|
private LinearLayout mAttentionLl;
|
|
|
- private PullToRefreshListView mAttentionPtlv;
|
|
|
|
|
|
|
+ private MyListView mAttentionPtlv;
|
|
|
private MyListView mAllPtlv;
|
|
private MyListView mAllPtlv;
|
|
|
private TextView mInviteFriendsTv;
|
|
private TextView mInviteFriendsTv;
|
|
|
- private StepDataDao stepDataDao;
|
|
|
|
|
private String curSelDate;
|
|
private String curSelDate;
|
|
|
private String myem_name;
|
|
private String myem_name;
|
|
|
private List<StepEntity> stepEntityList;
|
|
private List<StepEntity> stepEntityList;
|
|
|
private UURankingAdapter mRankAdapter;
|
|
private UURankingAdapter mRankAdapter;
|
|
|
|
|
+ private UUAttentionAdapter mAttenAdapter;
|
|
|
private ImageView mHeaderImg;
|
|
private ImageView mHeaderImg;
|
|
|
|
|
+ private StepsRankingBean mStepsRankingBean;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -60,10 +63,11 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
setContentView(R.layout.uu_ranking_activity);
|
|
setContentView(R.layout.uu_ranking_activity);
|
|
|
initView();
|
|
initView();
|
|
|
initData();
|
|
initData();
|
|
|
|
|
+ initEvents();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void initView() {
|
|
|
|
|
|
|
|
|
|
|
|
+ private void initView() {
|
|
|
mHeaderImg = (ImageView) findViewById(R.id.header_background_im);
|
|
mHeaderImg = (ImageView) findViewById(R.id.header_background_im);
|
|
|
mPhotoImg = (CircleImageView) findViewById(R.id.photo_img);
|
|
mPhotoImg = (CircleImageView) findViewById(R.id.photo_img);
|
|
|
mNameTv = (TextView) findViewById(R.id.name_tv);
|
|
mNameTv = (TextView) findViewById(R.id.name_tv);
|
|
@@ -71,25 +75,24 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
mStepsTv = (TextView) findViewById(R.id.steps_tv);
|
|
mStepsTv = (TextView) findViewById(R.id.steps_tv);
|
|
|
mPriseTv = (TextView) findViewById(R.id.prise_tv);
|
|
mPriseTv = (TextView) findViewById(R.id.prise_tv);
|
|
|
mPriseIm = (ImageView) findViewById(R.id.prise_im);
|
|
mPriseIm = (ImageView) findViewById(R.id.prise_im);
|
|
|
- mHideAboveAf = (View) findViewById(R.id.hide_above_af);
|
|
|
|
|
mAttentionLl = (LinearLayout) findViewById(R.id.attention_ll);
|
|
mAttentionLl = (LinearLayout) findViewById(R.id.attention_ll);
|
|
|
- mAttentionPtlv = (PullToRefreshListView) findViewById(R.id.attention_ptlv);
|
|
|
|
|
|
|
+ mAttentionPtlv = (MyListView) findViewById(R.id.attention_ptlv);
|
|
|
mAllPtlv = (MyListView) findViewById(R.id.all_ptlv);
|
|
mAllPtlv = (MyListView) findViewById(R.id.all_ptlv);
|
|
|
mInviteFriendsTv = (TextView) findViewById(R.id.invite_friends_tv);
|
|
mInviteFriendsTv = (TextView) findViewById(R.id.invite_friends_tv);
|
|
|
- stepDataDao = new StepDataDao(this);
|
|
|
|
|
curSelDate = TimeUtil.getCurrentDate();
|
|
curSelDate = TimeUtil.getCurrentDate();
|
|
|
stepEntityList = new ArrayList<>();
|
|
stepEntityList = new ArrayList<>();
|
|
|
mRankAdapter = new UURankingAdapter(this);
|
|
mRankAdapter = new UURankingAdapter(this);
|
|
|
- mAllPtlv.setAdapter(mRankAdapter);
|
|
|
|
|
|
|
+ mAttenAdapter = new UUAttentionAdapter(this);
|
|
|
findViewById(R.id.my_info_rl).setOnClickListener(this);
|
|
findViewById(R.id.my_info_rl).setOnClickListener(this);
|
|
|
|
|
|
|
|
mHeaderImg.requestFocus();
|
|
mHeaderImg.requestFocus();
|
|
|
- mAttentionLl.setVisibility(View.GONE);
|
|
|
|
|
|
|
+ mStepsRankingBean = new StepsRankingBean();
|
|
|
|
|
|
|
|
myem_name = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname");
|
|
myem_name = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname");
|
|
|
mNameTv.setText(myem_name+"");
|
|
mNameTv.setText(myem_name+"");
|
|
|
String loginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
String loginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
AvatarHelper.getInstance().display(loginUserId, mPhotoImg, true, false);
|
|
AvatarHelper.getInstance().display(loginUserId, mPhotoImg, true, false);
|
|
|
|
|
+ StepDataDao stepDataDao = new StepDataDao(this);
|
|
|
StepEntity stepEntity = stepDataDao.getCurDataByDate(curSelDate);
|
|
StepEntity stepEntity = stepDataDao.getCurDataByDate(curSelDate);
|
|
|
if (stepEntity != null) {
|
|
if (stepEntity != null) {
|
|
|
int steps = Integer.parseInt(stepEntity.getSteps());
|
|
int steps = Integer.parseInt(stepEntity.getSteps());
|
|
@@ -100,14 +103,15 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
mStepsTv.setText("0");
|
|
mStepsTv.setText("0");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- stepEntityList.clear();
|
|
|
|
|
- stepEntityList.addAll(stepDataDao.getAllDatas());
|
|
|
|
|
- mRankAdapter.setmList(stepEntityList);
|
|
|
|
|
- mRankAdapter.notifyDataSetChanged();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initData() {
|
|
private void initData() {
|
|
|
|
|
+ if (!CommonUtil.isNetWorkConnected(this)) {
|
|
|
|
|
+ ToastMessage(getString(R.string.common_notlinknet));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ progressDialog.show();
|
|
|
//获取所有人的当天步数数据
|
|
//获取所有人的当天步数数据
|
|
|
HttpClient httpClient = new HttpClient.Builder(Constant.BASE_STEP_URL).build();
|
|
HttpClient httpClient = new HttpClient.Builder(Constant.BASE_STEP_URL).build();
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
@@ -119,21 +123,80 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
@Override
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
public void onResponse(Object o) {
|
|
|
LogUtil.prinlnLongMsg("appStepsrank", o.toString()+"");
|
|
LogUtil.prinlnLongMsg("appStepsrank", o.toString()+"");
|
|
|
|
|
+ try {
|
|
|
|
|
+ mStepsRankingBean = JSON.parseObject(o.toString(),StepsRankingBean.class);
|
|
|
|
|
+ mRankAdapter.setModel(mStepsRankingBean);
|
|
|
|
|
+ mAllPtlv.setAdapter(mRankAdapter);
|
|
|
|
|
+ mRankAdapter.notifyDataSetChanged();
|
|
|
|
|
+
|
|
|
|
|
+ mAttenAdapter.setModel(mStepsRankingBean);
|
|
|
|
|
+ mAttentionPtlv.setAdapter(mAttenAdapter);
|
|
|
|
|
+ mAttenAdapter.notifyDataSetChanged();
|
|
|
|
|
+ if (mStepsRankingBean.getAttrank().size()>1)
|
|
|
|
|
+ mAttentionLl.setVisibility(View.VISIBLE);
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+ LogUtil.prinlnLongMsg("mStepsRankingBean", JSON.toJSONString(mStepsRankingBean)+"");
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void initEvents() {
|
|
|
|
|
+ mAttentionPtlv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
+ inTentToPersonal(2,position);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ mAllPtlv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
+ inTentToPersonal(3,position);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void inTentToPersonal(int type, int position) {
|
|
|
|
|
+ Intent intent = new Intent(this,PersonalPageActivity.class);
|
|
|
|
|
+ String title = "";
|
|
|
|
|
+ String userid = "";
|
|
|
|
|
+ String em_name = "";
|
|
|
|
|
+
|
|
|
|
|
+ switch (type){
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ title = "我";
|
|
|
|
|
+ userid = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
|
|
+ em_name = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ title = mStepsRankingBean.getAttrank().get(position).getAs_username();
|
|
|
|
|
+ userid = mStepsRankingBean.getAttrank().get(position).getAs_userid();
|
|
|
|
|
+ em_name = mStepsRankingBean.getAttrank().get(position).getAs_username();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ title = mStepsRankingBean.getToalrank().get(position).getAs_username();
|
|
|
|
|
+ userid = mStepsRankingBean.getToalrank().get(position).getAs_userid();
|
|
|
|
|
+ em_name = mStepsRankingBean.getToalrank().get(position).getAs_username();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (MyApplication.getInstance().mLoginUser.getUserId().equals(userid)) {
|
|
|
|
|
+ type = 1;
|
|
|
|
|
+ title = "我";
|
|
|
|
|
+ }
|
|
|
|
|
+ intent.putExtra("type",type);
|
|
|
|
|
+ intent.putExtra("title",title+"的主页");
|
|
|
|
|
+ intent.putExtra("userid",userid);
|
|
|
|
|
+ intent.putExtra("em_name",em_name);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
if (v.getId() == R.id.my_info_rl){
|
|
if (v.getId() == R.id.my_info_rl){
|
|
|
- Intent intent = new Intent(this,PersonalPageActivity.class);
|
|
|
|
|
- intent.putExtra("type",1);
|
|
|
|
|
- intent.putExtra("title","我的主页");
|
|
|
|
|
- intent.putExtra("userid",MyApplication.getInstance().mLoginUser.getUserId());
|
|
|
|
|
- intent.putExtra("em_name",CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname"));
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
|
|
+ inTentToPersonal(1,0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|