|
|
@@ -1,5 +1,6 @@
|
|
|
package com.sheep.jiuyan.samllsheep.page;
|
|
|
|
|
|
+import android.content.Intent;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.view.View;
|
|
|
@@ -9,14 +10,14 @@ import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
|
import com.sheep.jiuyan.samllsheep.net.NetManager;
|
|
|
import com.sheep.jiuyan.samllsheep.net.SheepCallback;
|
|
|
import com.sheep.jiuyan.samllsheep.net.Url;
|
|
|
import com.sheep.jiuyan.samllsheep.page.adapter.AdpChangeUser;
|
|
|
import com.sheep.jiuyan.samllsheep.page.adapter.AdpWxDetailList;
|
|
|
-import com.sheep.jiuyan.samllsheep.page.entry.TaskPublish;
|
|
|
-import com.sheep.jiuyan.samllsheep.page.entry.User;
|
|
|
+import com.sheep.jiuyan.samllsheep.page.entry.WXAccount;
|
|
|
import com.sheep.jiuyan.samllsheep.page.entry.WxDetailList;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
@@ -26,8 +27,6 @@ import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import okhttp3.Call;
|
|
|
-
|
|
|
/**
|
|
|
* @ Created by Dlg
|
|
|
* @ <p>TiTle: WxAccountDetail</p>
|
|
|
@@ -38,6 +37,7 @@ import okhttp3.Call;
|
|
|
public class WxAccountDetail extends BaseActivity {
|
|
|
|
|
|
public final static String INTENT_WXID_STR = "INTENT_WXID_STR";
|
|
|
+ public final static String INTENT_NAME = "DATA";
|
|
|
private RecyclerView mRecyclerView;//列表
|
|
|
private TextView mTxtAccount;//当前微信号
|
|
|
private AdpWxDetailList mAdpWxDetailList;
|
|
|
@@ -71,6 +71,7 @@ public class WxAccountDetail extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private List<WXAccount> mWxlist;
|
|
|
/**
|
|
|
* 切换用户的实现
|
|
|
*/
|
|
|
@@ -78,29 +79,45 @@ public class WxAccountDetail extends BaseActivity {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
if (mPopupWindow == null) {
|
|
|
- View view1 = View.inflate(WxAccountDetail.this, R.layout.pop_change_user, null);
|
|
|
+ final View view1 = View.inflate(WxAccountDetail.this, R.layout.pop_change_user, null);
|
|
|
mPopupWindow = new PopupWindow(view1, G.WIDTH, -2);
|
|
|
View foot = View.inflate(WxAccountDetail.this, R.layout.foot_pop_change_user, null);
|
|
|
foot.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- G.showToast("点我添加");
|
|
|
+ Intent intent = new Intent(WxAccountDetail.this, WebActivity.class);
|
|
|
+ intent.putExtra(WebActivity.INTENT_URL, Url.ADD_CHILD_WX);
|
|
|
+ intent.putExtra(WebActivity.INTENT_TITLE, "添加微信号");
|
|
|
+ WxAccountDetail.this.startActivity(intent);
|
|
|
+ mPopupWindow.dismiss();
|
|
|
}
|
|
|
});
|
|
|
- ListView listView = view1.findViewById(R.id.list_pop_change_user);
|
|
|
+ final ListView listView = view1.findViewById(R.id.list_pop_change_user);
|
|
|
listView.addFooterView(foot);
|
|
|
- //测试
|
|
|
- mAdpChangeUser.add(new User());
|
|
|
- mAdpChangeUser.add(new User());
|
|
|
- mAdpChangeUser.add(new User());
|
|
|
- mAdpChangeUser.add(new User());
|
|
|
- listView.setAdapter(mAdpChangeUser);
|
|
|
mPopupWindow.setContentView(view1);
|
|
|
mPopupWindow.setOutsideTouchable(true);
|
|
|
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("wx_open_id", SpUtils.getOpenId(SheepApp.mContext));
|
|
|
+ NetManager.get(Url.WXACCOUNT, map, SheepApp.mContext, new SheepCallback<List<WXAccount>>(WxAccountDetail.this) {
|
|
|
+ @Override
|
|
|
+ public void success(List<WXAccount> wxAccounts) {
|
|
|
+ mWxlist = wxAccounts;
|
|
|
+ mAdpChangeUser.addAll(wxAccounts);
|
|
|
+ //测试
|
|
|
+ listView.setAdapter(mAdpChangeUser);
|
|
|
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
+ int id = mWxlist.get(i).getId();
|
|
|
+ refreshWx(id + "");
|
|
|
+ mPopupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- G.showToast("点第:" + i + "项");
|
|
|
+ public void failure(IOException e) {
|
|
|
+ super.failure(e);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -108,15 +125,16 @@ public class WxAccountDetail extends BaseActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public void initData() {
|
|
|
+ private void refreshWx(String id) {
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
- map.put("wx_open_id", SpUtils.getOpenId(this));
|
|
|
- map.put("wx_id", "39");
|
|
|
+ map.put("wx_open_id", SpUtils.getOpenId(SheepApp.mContext));
|
|
|
+ map.put("wx_id", id);
|
|
|
NetManager.get(Url.TASK_LIST, map, this, new SheepCallback<List<WxDetailList>>(this) {
|
|
|
@Override
|
|
|
public void success(List<WxDetailList> tasks) {
|
|
|
+ if (mAdpWxDetailList != null) {
|
|
|
+ mAdpWxDetailList.clear();
|
|
|
+ }
|
|
|
if (tasks != null && tasks.size() > 0) {
|
|
|
mAdpWxDetailList.addAll(tasks);
|
|
|
mAdpWxDetailList.notifyDataSetChanged();
|
|
|
@@ -126,4 +144,14 @@ public class WxAccountDetail extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void initData() {
|
|
|
+ Intent intent = getIntent();
|
|
|
+ String wxName = intent.getStringExtra(INTENT_NAME);
|
|
|
+ String wxID = intent.getStringExtra(INTENT_WXID_STR);
|
|
|
+ mTxtAccount.setText(wxName);
|
|
|
+ refreshWx(wxID);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|