AccountManagementActivity.java
8.76 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package com.hjx.personalcenter.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hjx.personalcenter.R;
import com.hjx.personalcenter.adapter.AccountChildsAdapter;
import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem;
import com.hjx.personalcenter.db.Content;
import com.hjx.personalcenter.db.SaveParam;
import com.hjx.personalcenter.http.HttpCode;
import com.hjx.personalcenter.http.HttpManager;
import com.hjx.personalcenter.model.ChildsInfo;
import com.hjx.personalcenter.util.AlertUtils;
import com.hjx.personalcenter.util.GetDevicesUtil;
import java.util.ArrayList;
import java.util.List;
/**账户管理 熊巍
* Created by h on 2017/8/12.
*/
public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener {
private TextView changbangding,changpassword,usernames,
tv_username,tv_grade,tv_school,tv_adress,tv_changzhu;
private ImageView iv_useing,cancel;
private SimpleDraweeView mSimpleDraweeView;
private RecyclerView listview;
private LinearLayout add_accunt,ll_zhu_backgrangd;
private AccountChildsAdapter childsAdapter;
private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>();
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case HttpCode.CHILDS_SUCESS:
String name = null;
String grade = null;
String school = null;
String addr = null;
String phote = null;
List<ChildsInfo.DataBean> childList = new ArrayList<>() ;
List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>)msg.obj ;
for (int i = 0; i < list.size(); i++) {
int type = list.get(i).getType();
if(type == 1){
name = list.get(i).getName();
grade = list.get(i).getGrade();
school = list.get(i).getSchool();
addr = list.get(i).getRegion();
phote = list.get(i).getImage();
}else if (type == 2){
childList.add(list.get(i));
}
}
tv_username.setText(name);
tv_grade.setText(grade);
tv_school.setText(school);
tv_adress.setText(addr);
data.clear();
data.addAll(childList);
childsAdapter.notifyDataSetChanged();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_management);
initView();
initData();
initLister();
}
private void initView() {
changbangding = (TextView) findViewById(R.id.changBangding);
changpassword = (TextView) findViewById(R.id.changpassword);
usernames = (TextView) findViewById(R.id.cunt_username);
tv_username = (TextView) findViewById(R.id.tv_account_name);
tv_grade = (TextView) findViewById(R.id.tv_account_grade);
tv_school = (TextView) findViewById(R.id.tv_account_school);
tv_adress = (TextView) findViewById(R.id.tv_account_adress);
mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head);
iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong);
cancel = (ImageView) findViewById(R.id.cancel);
add_accunt = (LinearLayout) findViewById(R.id.add_account);
ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd);
tv_changzhu = (TextView) findViewById(R.id.change_zhu_account);
listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal);
}
private void initData() {
String cunt_username = SaveParam.getInstance().getLoginParam(this,"username");
String tv_usernames = SaveParam.getInstance().getLoginParam(this,SaveParam.USERNAME);
String tv_grades = SaveParam.getInstance().getLoginParam(this,SaveParam.GRADES);
String tv_schools = SaveParam.getInstance().getLoginParam(this,SaveParam.SCHOOL);
String tv_adresss = SaveParam.getInstance().getLoginParam(this,SaveParam.ADRESS);
String account = SaveParam.getInstance().getLoginParam(this,SaveParam.ACCOUNT);
usernames.setText(cunt_username);
if (account.equals("1")){
tv_changzhu.setText("使用中");
tv_changzhu.setEnabled(false);
iv_useing.setVisibility(View.VISIBLE);
ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg);
}else {
tv_changzhu.setText("切换主账户");
tv_changzhu.setEnabled(true);
iv_useing.setVisibility(View.GONE);
ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg);
}
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
listview.setLayoutManager(linearLayoutManager);
childsAdapter = new AccountChildsAdapter(data,this);
listview.addItemDecoration(new RecyclerViewSpaceItem(10));
listview.setAdapter(childsAdapter);
childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
AlertUtils.showToast(AccountManagementActivity.this,"你点击了"+data.get(position));
}
});
}
private void initLister() {
changbangding.setOnClickListener(this);
changpassword.setOnClickListener(this);
cancel.setOnClickListener(this);
add_accunt.setOnClickListener(this);
tv_changzhu.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.changBangding:
Intent changebangding = new Intent();
changebangding.setClass(AccountManagementActivity.this,ChangeBangDingActivity.class);
startActivity(changebangding);
overridePendingTransition(R.anim.rightin, R.anim.rightout);
break;
case R.id.changpassword:
Content.authcodeflag = 1;
Intent changpwd = new Intent();
changpwd.setClass(AccountManagementActivity.this,ChangePasswordActivity.class);
startActivity(changpwd);
overridePendingTransition(R.anim.rightin, R.anim.rightout);
break;
case R.id.add_account:
Content.accountflag = 2;
Intent account = new Intent();
account.setClass(AccountManagementActivity.this,RegisterInfoActivity.class);
startActivity(account);
overridePendingTransition(R.anim.rightin, R.anim.rightout);
break;
case R.id.change_zhu_account:
Content.changgeaccountflag =1;
String userID = SaveParam.getInstance().getLoginParam(this,"userId");
SaveParam.getInstance().saveLoginParam(this,SaveParam.ACCOUNT,"1");
String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
try {
long auserID = Long.parseLong(userID);
HttpManager.getInstance().Accountinfo(AccountManagementActivity.this,auserID,
devicenumber,1);
} catch (NumberFormatException e) {
e.printStackTrace();
}
break;
case R.id.cancel:
finish();
break;
}
}
@Override
protected void onResume() {
super.onResume();
String userID = SaveParam.getInstance().getLoginParam(this,"userId");
String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
try {
long auserID = Long.parseLong(userID);
HttpManager.getInstance().getchildAccountinfo(this,auserID,devicenumber,handler);
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}