AccountChildsAdapter.java
5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.hjx.personalcenter.adapter;
import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hjx.personalcenter.R;
import com.hjx.personalcenter.db.Content;
import com.hjx.personalcenter.db.SaveParam;
import com.hjx.personalcenter.http.HttpManager;
import com.hjx.personalcenter.model.ChildsInfo;
import com.mylhyl.circledialog.CircleDialog;
import java.util.ArrayList;
import java.util.List;
/**
* Created by h on 2017/8/26.
*/
public class AccountChildsAdapter extends RecyclerView.Adapter<AccountChildsAdapter.AccountChildsHolder> {
private List<ChildsInfo.DataBean> specailList;
private LayoutInflater mInflater;
private Context mContext ;
public AccountChildsAdapter(ArrayList<ChildsInfo.DataBean> specailList,Context context) {
this.mContext = context;
this.specailList = specailList;
mInflater = LayoutInflater.from(context);
}
public OnItemClickListener mOnItemClickListener;
public interface OnItemClickListener {
void onItemClick(View view, int position);
}
public void setOnItemClickListener(OnItemClickListener mOnItemClickLitener) {
this.mOnItemClickListener = mOnItemClickLitener;
}
public void setList(List<ChildsInfo.DataBean> list) {
this.specailList = list;
notifyDataSetChanged();
}
@Override
public AccountChildsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.recycler_childaccunt_item_view, parent, false);
AccountChildsHolder holder = new AccountChildsHolder(view);
return holder;
}
@Override
public void onBindViewHolder(AccountChildsHolder holder, int position) {
final ChildsInfo.DataBean bean = specailList.get(position);
if (bean != null) {
holder.mSimpleDraweeView.setImageURI(bean.getImage());
holder.iv_child_name.setText(bean.getName());
holder.iv_child_grade.setText(bean.getGrade());
holder.iv_child_school.setText(bean.getSchool());
holder.iv_child_adress.setText(bean.getRegion());
holder.delete_account.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new CircleDialog.Builder((FragmentActivity)mContext)
.setCanceledOnTouchOutside(false)
.setWidth(0.4f)
.setCancelable(false)
.setText("您确定删除该子账户?")
.setNegative("取消", null)
.setPositive("确定", new View.OnClickListener() {
@Override
public void onClick(View v) {
HttpManager.getInstance().deletechildAccountinfo(mContext,bean.getSubAccountId());
}
})
.show();
}
});
holder.chang_account.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new CircleDialog.Builder((FragmentActivity)mContext)
.setCanceledOnTouchOutside(false)
.setWidth(0.4f)
.setCancelable(false)
.setText("您确定切换为该子账户?")
.setNegative("取消", null)
.setPositive("确定", new View.OnClickListener() {
@Override
public void onClick(View v) {
Content.changgeaccountflag =2;
SaveParam.getInstance().saveLoginParam(mContext,SaveParam.ACCOUNT,"2");
HttpManager.getInstance().changechildAccountinfo(mContext,bean.getSubAccountId(),bean.getParentId());
}
})
.show();
}
});
}
}
@Override
public int getItemCount() {
return specailList.size();
}
class AccountChildsHolder extends RecyclerView.ViewHolder {
SimpleDraweeView mSimpleDraweeView;
TextView iv_child_name, iv_child_grade, iv_child_school, iv_child_adress,
delete_account,chang_account;
public AccountChildsHolder(View itemView) {
super(itemView);
mSimpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.iv_child_head);
iv_child_name = (TextView) itemView.findViewById(R.id.iv_child_name);
iv_child_grade = (TextView) itemView.findViewById(R.id.iv_child_grade);
iv_child_school = (TextView) itemView.findViewById(R.id.iv_child_school);
iv_child_adress = (TextView) itemView.findViewById(R.id.iv_child_adress);
delete_account = (TextView) itemView.findViewById(R.id.delete_child_account);
chang_account = (TextView) itemView.findViewById(R.id.chang_account);
if (Content.changgeaccountflag==2){
chang_account.setText("使用中");
chang_account.setEnabled(true);
}
}
}
}