|
|
@@ -1,16 +1,20 @@
|
|
|
package com.uas.appme.pedometer.view;
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
+import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
|
+import android.content.ServiceConnection;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.IBinder;
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.common.LogUtil;
|
|
|
@@ -23,10 +27,13 @@ import com.core.base.BaseActivity;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.helper.AvatarHelper;
|
|
|
import com.core.widget.MyListView;
|
|
|
+import com.core.xmpp.CoreService;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
+import com.uas.appcontact.model.contacts.ContactsModel;
|
|
|
+import com.uas.appcontact.ui.activity.ContactsActivity;
|
|
|
import com.uas.appme.R;
|
|
|
import com.uas.appme.pedometer.adapter.UUAttentionAdapter;
|
|
|
import com.uas.appme.pedometer.adapter.UURankingAdapter;
|
|
|
@@ -57,7 +64,6 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
private LinearLayout mAttentionLl;
|
|
|
private MyListView mAttentionPtlv;
|
|
|
private MyListView mAllPtlv;
|
|
|
- private TextView mInviteFriendsTv;
|
|
|
private String curSelDate;
|
|
|
private String myem_name;
|
|
|
private List<StepEntity> stepEntityList;
|
|
|
@@ -78,6 +84,8 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
private TextView first_ranking_tv;
|
|
|
private String first_ranking_imid = null; //第一名imid
|
|
|
private String first_ranking_name = null; //第一名名字
|
|
|
+ private String shareStepStr = "我正在使用UU运动计步功能,你也一起来吧";
|
|
|
+ private CoreService mService;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -85,12 +93,17 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
setContentView(R.layout.uu_ranking_activity);
|
|
|
StepUtils.doSaveLocalStepsToJudgeHttps();
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(updateReceiver, new IntentFilter(AppConstant.UPDATE_STEPRANKING_PRISE));
|
|
|
+ bindService(CoreService.getIntent(), mConnection, BIND_AUTO_CREATE);
|
|
|
initView();
|
|
|
initData();
|
|
|
initEvents();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ unbindService(mConnection);
|
|
|
+ }
|
|
|
private void initView() {
|
|
|
mHeaderImg = (ImageView) findViewById(R.id.header_background_im);
|
|
|
mPhotoImg = (CircleImageView) findViewById(R.id.photo_img);
|
|
|
@@ -102,7 +115,7 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
mAttentionLl = (LinearLayout) findViewById(R.id.attention_ll);
|
|
|
mAttentionPtlv = (MyListView) findViewById(R.id.attention_ptlv);
|
|
|
mAllPtlv = (MyListView) findViewById(R.id.all_ptlv);
|
|
|
- mInviteFriendsTv = (TextView) findViewById(R.id.invite_friends_tv);
|
|
|
+ findViewById(R.id.invite_friends_tv).setOnClickListener(this);
|
|
|
curSelDate = TimeUtil.getCurrentDate();
|
|
|
stepEntityList = new ArrayList<>();
|
|
|
mRankAdapter = new UURankingAdapter(this);
|
|
|
@@ -146,7 +159,8 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
.url("appStepsrank")
|
|
|
.add("userid",MyApplication.getInstance().mLoginUser.getUserId())
|
|
|
.add("token",MyApplication.getInstance().mAccessToken)
|
|
|
- .method(Method.GET)
|
|
|
+
|
|
|
+ .method(Method.POST)
|
|
|
.build(),new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
|
@@ -167,7 +181,7 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
mAttenAdapter.setModel(mStepsRankingBean);
|
|
|
mAttentionPtlv.setAdapter(mAttenAdapter);
|
|
|
mAttenAdapter.notifyDataSetChanged();
|
|
|
-// if (mStepsRankingBean.getAttrank().size()>1)
|
|
|
+ if (mStepsRankingBean.getAttrank().size()>0)
|
|
|
mAttentionLl.setVisibility(View.VISIBLE);
|
|
|
showMyInfo();
|
|
|
LogUtil.prinlnLongMsg("mStepsRankingBean", JSON.toJSONString(mStepsRankingBean)+"");
|
|
|
@@ -287,6 +301,12 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
public void onClick(View v) {
|
|
|
if (v.getId() == R.id.my_info_rl){
|
|
|
inTentToPersonal(1,0);
|
|
|
+ }else if (v.getId() == R.id.invite_friends_tv){
|
|
|
+ Intent intent = new Intent(this, ContactsActivity.class);
|
|
|
+ intent.putExtra("type", 1);
|
|
|
+ intent.putExtra("title", "分享好友");
|
|
|
+ startActivityForResult(intent, 0x03);
|
|
|
+ Toast.makeText(ct,"只能分享给UU好友",Toast.LENGTH_LONG).show();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -296,6 +316,17 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
|
|
|
if (requestCode == 0x01 && resultCode == 0x02){
|
|
|
initData();
|
|
|
+ }else if (requestCode == 0x03 ){
|
|
|
+ if (data == null){
|
|
|
+ ToastMessage("只能分享给UU好友");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ContactsModel model = data.getParcelableExtra("data");
|
|
|
+ String ownerId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
+ String ownerName = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname");
|
|
|
+ String objectId = model.getImid();
|
|
|
+ StepUtils.sendMessage(mService,ownerId,ownerName,objectId,shareStepStr);
|
|
|
+ LogUtil.d("0x01",JSON.toJSONString(model));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -314,4 +345,16 @@ public class UURanking extends BaseActivity implements View.OnClickListener {
|
|
|
progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
+ private ServiceConnection mConnection = new ServiceConnection() {
|
|
|
+ @Override
|
|
|
+ public void onServiceDisconnected(ComponentName name) {
|
|
|
+ mService = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onServiceConnected(ComponentName name, IBinder service) {
|
|
|
+ mService = ((CoreService.CoreServiceBinder) service).getService();
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|