AccountManagementActivity.java
5.69 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
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.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 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_delete;
private ImageView iv_account_head,cancel;
private RecyclerView listview;
private LinearLayout add_accunt;
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:
data.clear();
data.addAll( (List<ChildsInfo.DataBean>)msg.obj);
childsAdapter.notifyDataSetChanged();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_management);
String userID = SaveParam.getInstance().getLoginParam(this,"userId");
try {
long auserID = Long.parseLong(userID);
HttpManager.getInstance().getchildAccountinfo(this,auserID,handler);
} catch (NumberFormatException e) {
e.printStackTrace();
}
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);
tv_delete = (TextView) findViewById(R.id.tv_account_delete);
iv_account_head = (ImageView) findViewById(R.id.tv_account_head);
cancel = (ImageView) findViewById(R.id.cancel);
add_accunt = (LinearLayout) findViewById(R.id.add_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);
usernames.setText(cunt_username);
tv_username.setText(tv_usernames);
tv_grade.setText(tv_grades);
tv_school.setText(tv_schools);
tv_adress.setText(tv_adresss);
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);
}
private void initLister() {
changbangding.setOnClickListener(this);
changpassword.setOnClickListener(this);
tv_delete.setOnClickListener(this);
cancel.setOnClickListener(this);
add_accunt.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.cancel:
finish();
break;
}
}
}