Commit 9d08c5be52ae93dd699a5515d966a7587889615a

Authored by xiongwei
1 parent 73ba0df5f6
Exists in master

修改个人中心BUG

Showing 34 changed files with 315 additions and 107 deletions   Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/AccountManagementActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.os.Handler; 5 import android.os.Handler;
6 import android.os.Message; 6 import android.os.Message;
7 import android.support.v7.app.AppCompatActivity; 7 import android.support.v7.app.AppCompatActivity;
8 import android.support.v7.widget.LinearLayoutManager; 8 import android.support.v7.widget.LinearLayoutManager;
9 import android.support.v7.widget.RecyclerView; 9 import android.support.v7.widget.RecyclerView;
10 import android.view.View; 10 import android.view.View;
11 import android.widget.ImageView; 11 import android.widget.ImageView;
12 import android.widget.LinearLayout; 12 import android.widget.LinearLayout;
13 import android.widget.TextView; 13 import android.widget.TextView;
14 14
15 import com.facebook.drawee.view.SimpleDraweeView; 15 import com.facebook.drawee.view.SimpleDraweeView;
16 import com.hjx.personalcenter.R; 16 import com.hjx.personalcenter.R;
17 import com.hjx.personalcenter.adapter.AccountChildsAdapter; 17 import com.hjx.personalcenter.adapter.AccountChildsAdapter;
18 import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; 18 import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem;
19 import com.hjx.personalcenter.db.Content; 19 import com.hjx.personalcenter.db.Content;
20 import com.hjx.personalcenter.db.SaveParam; 20 import com.hjx.personalcenter.db.SaveParam;
21 import com.hjx.personalcenter.http.HttpCode; 21 import com.hjx.personalcenter.http.HttpCode;
22 import com.hjx.personalcenter.http.HttpManager; 22 import com.hjx.personalcenter.http.HttpManager;
23 import com.hjx.personalcenter.model.ChildsInfo; 23 import com.hjx.personalcenter.model.ChildsInfo;
24 import com.hjx.personalcenter.util.AlertUtils; 24 import com.hjx.personalcenter.util.AlertUtils;
25 import com.hjx.personalcenter.util.GetDevicesUtil; 25 import com.hjx.personalcenter.util.GetDevicesUtil;
26 26
27 import java.util.ArrayList; 27 import java.util.ArrayList;
28 import java.util.List; 28 import java.util.List;
29 29
30 /** 30 /**
31 * 账户管理 熊巍 31 * 账户管理 熊巍
32 * Created by h on 2017/8/12. 32 * Created by h on 2017/8/12.
33 */ 33 */
34 34
35 public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener { 35 public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener {
36 private TextView changbangding, changpassword, usernames, 36 private TextView changbangding, changpassword, usernames,
37 tv_username, tv_grade, tv_school, tv_adress, tv_changzhu; 37 tv_username, tv_grade, tv_school, tv_adress, tv_changzhu;
38 private ImageView iv_useing, cancel; 38 private ImageView iv_useing, cancel;
39 private SimpleDraweeView mSimpleDraweeView; 39 private SimpleDraweeView mSimpleDraweeView;
40 private RecyclerView listview; 40 private RecyclerView listview;
41 private LinearLayout add_accunt, ll_zhu_backgrangd; 41 private LinearLayout add_accunt, ll_zhu_backgrangd;
42 private AccountChildsAdapter childsAdapter; 42 private AccountChildsAdapter childsAdapter;
43 private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>(); 43 private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>();
44 Handler handler = new Handler() { 44 Handler handler = new Handler() {
45 @Override 45 @Override
46 public void handleMessage(Message msg) { 46 public void handleMessage(Message msg) {
47 super.handleMessage(msg); 47 super.handleMessage(msg);
48 switch (msg.what) { 48 switch (msg.what) {
49 case HttpCode.CHILDS_SUCESS: 49 case HttpCode.CHILDS_SUCESS:
50 ChildsInfo childsInfo = new ChildsInfo(); 50 ChildsInfo childsInfo = new ChildsInfo();
51 if (childsInfo.getStatus()==1000) { 51 if (childsInfo.getStatus()==1000) {
52 String names =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.USERNAME); 52 String names =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.USERNAME);
53 String adress =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.ADRESS); 53 String adress =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.ADRESS);
54 String grades =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.GRADES); 54 String grades =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.GRADES);
55 String schools =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.SCHOOL); 55 String schools =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.SCHOOL);
56 tv_username.setText(names); 56 tv_username.setText(names);
57 tv_grade.setText(grades); 57 tv_grade.setText(grades);
58 tv_school.setText(schools); 58 tv_school.setText(schools);
59 tv_adress.setText(adress); 59 tv_adress.setText(adress);
60 tv_changzhu.setText("使用中"); 60 tv_changzhu.setText("使用中");
61 tv_changzhu.setEnabled(false); 61 tv_changzhu.setEnabled(false);
62 iv_useing.setVisibility(View.VISIBLE); 62 iv_useing.setVisibility(View.VISIBLE);
63 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); 63 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg);
64 //mSimpleDraweeView.setImageURI(phote); 64 //mSimpleDraweeView.setImageURI(phote);
65 65
66 } else { 66 } else {
67 String name = null; 67 String name = null;
68 String grade = null; 68 String grade = null;
69 String school = null; 69 String school = null;
70 String addr = null; 70 String addr = null;
71 String phote = null; 71 String phote = null;
72 String subAccountId = null; 72 String subAccountId = null;
73 List<ChildsInfo.DataBean> childList = new ArrayList<>(); 73 List<ChildsInfo.DataBean> childList = new ArrayList<>();
74 List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>) msg.obj; 74 List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>) msg.obj;
75 for (int i = 0; i < list.size(); i++) { 75 for (int i = 0; i < list.size(); i++) {
76 int type = list.get(i).getType(); 76 int type = list.get(i).getType();
77 if (type == 1) { 77 if (type == 1) {
78 name = list.get(i).getName(); 78 name = list.get(i).getName();
79 grade = list.get(i).getGrade(); 79 grade = list.get(i).getGrade();
80 school = list.get(i).getSchool(); 80 school = list.get(i).getSchool();
81 addr = list.get(i).getRegion(); 81 addr = list.get(i).getRegion();
82 phote = list.get(i).getImage(); 82 phote = list.get(i).getImage();
83 subAccountId = list.get(i).getSubAccountId(); 83 subAccountId = list.get(i).getSubAccountId();
84 } else if (type == 2) { 84 } else if (type == 2) {
85 childList.add(list.get(i)); 85 childList.add(list.get(i));
86 } 86 }
87 } 87 }
88 tv_username.setText(name); 88 tv_username.setText(name);
89 tv_grade.setText(grade); 89 tv_grade.setText(grade);
90 tv_school.setText(school); 90 tv_school.setText(school);
91 tv_adress.setText(addr); 91 tv_adress.setText(addr);
92 mSimpleDraweeView.setImageURI(phote); 92 mSimpleDraweeView.setImageURI(phote);
93 data.clear(); 93 data.clear();
94 data.addAll(childList); 94 data.addAll(childList);
95 childsAdapter.notifyDataSetChanged(); 95 childsAdapter.notifyDataSetChanged();
96 } 96 }
97 break; 97 break;
98 } 98 }
99 } 99 }
100 }; 100 };
101 101
102 @Override 102 @Override
103 protected void onCreate(Bundle savedInstanceState) { 103 protected void onCreate(Bundle savedInstanceState) {
104 super.onCreate(savedInstanceState); 104 super.onCreate(savedInstanceState);
105 setContentView(R.layout.activity_account_management); 105 setContentView(R.layout.activity_account_management);
106 SysApplication.getInstance().addActivity(this);
106 107
107 initView(); 108 initView();
108 initData(); 109 initData();
109 initLister(); 110 initLister();
110 } 111 }
111 112
112 private void initView() { 113 private void initView() {
113 changbangding = (TextView) findViewById(R.id.changBangding); 114 changbangding = (TextView) findViewById(R.id.changBangding);
114 changpassword = (TextView) findViewById(R.id.changpassword); 115 changpassword = (TextView) findViewById(R.id.changpassword);
115 usernames = (TextView) findViewById(R.id.cunt_username); 116 usernames = (TextView) findViewById(R.id.cunt_username);
116 tv_username = (TextView) findViewById(R.id.tv_account_name); 117 tv_username = (TextView) findViewById(R.id.tv_account_name);
117 tv_grade = (TextView) findViewById(R.id.tv_account_grade); 118 tv_grade = (TextView) findViewById(R.id.tv_account_grade);
118 tv_school = (TextView) findViewById(R.id.tv_account_school); 119 tv_school = (TextView) findViewById(R.id.tv_account_school);
119 tv_adress = (TextView) findViewById(R.id.tv_account_adress); 120 tv_adress = (TextView) findViewById(R.id.tv_account_adress);
120 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head); 121 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head);
121 iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong); 122 iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong);
122 cancel = (ImageView) findViewById(R.id.cancel); 123 cancel = (ImageView) findViewById(R.id.cancel);
123 add_accunt = (LinearLayout) findViewById(R.id.add_account); 124 add_accunt = (LinearLayout) findViewById(R.id.add_account);
124 ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd); 125 ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd);
125 tv_changzhu = (TextView) findViewById(R.id.change_zhu_account); 126 tv_changzhu = (TextView) findViewById(R.id.change_zhu_account);
126 listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); 127 listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal);
127 } 128 }
128 129
129 private void initData() { 130 private void initData() {
130 String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); 131 String cunt_username = SaveParam.getInstance().getLoginParam(this, "username");
131 String account = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); 132 String account = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT);
132 usernames.setText(cunt_username); 133 usernames.setText(cunt_username);
133 134
134 if (account.equals("1")) { 135 if (account.equals("1")) {
135 tv_changzhu.setText("使用中"); 136 tv_changzhu.setText("使用中");
136 tv_changzhu.setEnabled(false); 137 tv_changzhu.setEnabled(false);
137 iv_useing.setVisibility(View.VISIBLE); 138 iv_useing.setVisibility(View.VISIBLE);
138 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); 139 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg);
139 } else { 140 } else {
140 141
141 tv_changzhu.setText("切换主账户"); 142 tv_changzhu.setText("切换主账户");
142 tv_changzhu.setEnabled(true); 143 tv_changzhu.setEnabled(true);
143 iv_useing.setVisibility(View.GONE); 144 iv_useing.setVisibility(View.GONE);
144 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg); 145 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg);
145 } 146 }
146 147
147 148
148 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); 149 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
149 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); 150 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
150 listview.setLayoutManager(linearLayoutManager); 151 listview.setLayoutManager(linearLayoutManager);
151 childsAdapter = new AccountChildsAdapter(data, this); 152 childsAdapter = new AccountChildsAdapter(data, this);
152 listview.addItemDecoration(new RecyclerViewSpaceItem(10)); 153 listview.addItemDecoration(new RecyclerViewSpaceItem(10));
153 listview.setAdapter(childsAdapter); 154 listview.setAdapter(childsAdapter);
154 childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() { 155 childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() {
155 @Override 156 @Override
156 public void onItemClick(View view, int position) { 157 public void onItemClick(View view, int position) {
157 158
158 AlertUtils.showToast(AccountManagementActivity.this, "你点击了" + data.get(position)); 159 AlertUtils.showToast(AccountManagementActivity.this, "你点击了" + data.get(position));
159 } 160 }
160 }); 161 });
161 162
162 } 163 }
163 164
164 165
165 private void initLister() { 166 private void initLister() {
166 changbangding.setOnClickListener(this); 167 changbangding.setOnClickListener(this);
167 changpassword.setOnClickListener(this); 168 changpassword.setOnClickListener(this);
168 cancel.setOnClickListener(this); 169 cancel.setOnClickListener(this);
169 add_accunt.setOnClickListener(this); 170 add_accunt.setOnClickListener(this);
170 tv_changzhu.setOnClickListener(this); 171 tv_changzhu.setOnClickListener(this);
171 172
172 173
173 } 174 }
174 175
175 @Override 176 @Override
176 public void onClick(View v) { 177 public void onClick(View v) {
177 switch (v.getId()) { 178 switch (v.getId()) {
178 case R.id.changBangding: 179 case R.id.changBangding:
179 Content.authcodeflag = 1; 180 Content.authcodeflag = 1;
180 Intent changebangding = new Intent(); 181 Intent changebangding = new Intent();
181 changebangding.setClass(AccountManagementActivity.this, ElectronicCardValidationActivity.class); 182 changebangding.setClass(AccountManagementActivity.this, ElectronicCardValidationActivity.class);
182 startActivity(changebangding); 183 startActivity(changebangding);
183 overridePendingTransition(R.anim.rightin, R.anim.rightout); 184 overridePendingTransition(R.anim.rightin, R.anim.rightout);
184 break; 185 break;
185 case R.id.changpassword: 186 case R.id.changpassword:
186 Intent changpwd = new Intent(); 187 Intent changpwd = new Intent();
187 changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class); 188 changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class);
188 startActivity(changpwd); 189 startActivity(changpwd);
189 overridePendingTransition(R.anim.rightin, R.anim.rightout); 190 overridePendingTransition(R.anim.rightin, R.anim.rightout);
190 break; 191 break;
191 case R.id.add_account: 192 case R.id.add_account:
192 Content.accountflag =2; 193 Content.accountflag =2;
193 Intent account = new Intent(); 194 Intent account = new Intent();
194 account.setClass(AccountManagementActivity.this, RegisterInfoActivity.class); 195 account.setClass(AccountManagementActivity.this, RegisterInfoActivity.class);
195 startActivity(account); 196 startActivity(account);
196 overridePendingTransition(R.anim.rightin, R.anim.rightout); 197 overridePendingTransition(R.anim.rightin, R.anim.rightout);
197 198
198 break; 199 break;
199 case R.id.change_zhu_account: 200 case R.id.change_zhu_account:
200 Content.changgeaccountflag = 1; 201 Content.changgeaccountflag = 1;
201 String userID = SaveParam.getInstance().getLoginParam(this, "userId"); 202 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
202 SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ACCOUNT, "1"); 203 SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ACCOUNT, "1");
203 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); 204 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
204 try { 205 try {
205 long auserID = Long.parseLong(userID); 206 long auserID = Long.parseLong(userID);
206 HttpManager.getInstance().Accountinfo(AccountManagementActivity.this, auserID, 207 HttpManager.getInstance().Accountinfo(AccountManagementActivity.this, auserID,
207 devicenumber, 1); 208 devicenumber, 1);
208 209
209 } catch (NumberFormatException e) { 210 } catch (NumberFormatException e) {
210 e.printStackTrace(); 211 e.printStackTrace();
211 } 212 }
212 213
213 214
214 break; 215 break;
215 case R.id.cancel: 216 case R.id.cancel:
216 finish(); 217 finish();
217 break; 218 break;
218 219
219 } 220 }
220 221
221 } 222 }
222 223
223 @Override 224 @Override
224 protected void onResume() { 225 protected void onResume() {
225 super.onResume(); 226 super.onResume();
226 String userID = SaveParam.getInstance().getLoginParam(this, "userId"); 227 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
227 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); 228 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
228 String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); 229 String cunt_username = SaveParam.getInstance().getLoginParam(this, "username");
229 usernames.setText(cunt_username); 230 usernames.setText(cunt_username);
230 try { 231 try {
231 long auserID = Long.parseLong(userID); 232 long auserID = Long.parseLong(userID);
232 HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler); 233 HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler);
233 234
234 } catch (NumberFormatException e) { 235 } catch (NumberFormatException e) {
235 e.printStackTrace(); 236 e.printStackTrace();
236 } 237 }
237 } 238 }
238 } 239 }
239 240
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/BangDingCode.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent;
3 import android.graphics.Bitmap; 4 import android.graphics.Bitmap;
4 import android.os.Bundle; 5 import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity; 6 import android.support.v7.app.AppCompatActivity;
6 import android.util.DisplayMetrics; 7 import android.util.DisplayMetrics;
8 import android.view.View;
9 import android.widget.Button;
7 import android.widget.ImageView; 10 import android.widget.ImageView;
8 import android.widget.LinearLayout; 11 import android.widget.LinearLayout;
9 12
10 import com.hjx.personalcenter.R; 13 import com.hjx.personalcenter.R;
11 import com.hjx.personalcenter.util.FileUtil; 14 import com.hjx.personalcenter.util.FileUtil;
12 import com.hjx.personalcenter.util.QRCodeUtil; 15 import com.hjx.personalcenter.util.QRCodeUtil;
13 16
14 import java.io.File; 17 import java.io.File;
15 18
16 /** 19 /**
17 * Created by h on 2017/8/31. 20 * Created by h on 2017/8/31.
18 */ 21 */
19 22
20 public class BangDingCode extends AppCompatActivity { 23 public class BangDingCode extends AppCompatActivity {
21 private ImageView EQpicture; 24 private ImageView EQpicture;
25 private Button btn_next_tep;
22 File file; 26 File file;
23 @Override 27 @Override
24 protected void onCreate(Bundle savedInstanceState) { 28 protected void onCreate(Bundle savedInstanceState) {
25 super.onCreate(savedInstanceState); 29 super.onCreate(savedInstanceState);
26 setContentView(R.layout.activity_binding_code); 30 setContentView(R.layout.activity_binding_code);
31 SysApplication.getInstance().addActivity(this);
27 EQpicture = (ImageView) findViewById(R.id.EQpicture); 32 EQpicture = (ImageView) findViewById(R.id.EQpicture);
33 btn_next_tep = (Button) findViewById(R.id.btn_next_tep);
34 btn_next_tep.setOnClickListener(new View.OnClickListener() {
35 @Override
36 public void onClick(View v) {
37 Intent intent = new Intent();
38 intent.setClass(BangDingCode.this, TheStartPageActivity.class);
39 startActivity(intent);
40 overridePendingTransition(R.anim.rightin, R.anim.rightout);
41 }
42 });
28 EQPicture(); 43 EQPicture();
29 44
30 45
31 } 46 }
32 public void EQPicture() { 47 public void EQPicture() {
33 DisplayMetrics dm = new DisplayMetrics(); 48 DisplayMetrics dm = new DisplayMetrics();
34 getWindowManager().getDefaultDisplay().getMetrics(dm); 49 getWindowManager().getDefaultDisplay().getMetrics(dm);
35 int screenHeight = dm.heightPixels;//屏幕高度 50 int screenHeight = dm.heightPixels;//屏幕高度
36 //设置二维码外布局占屏幕高宽 51 //设置二维码外布局占屏幕高宽
37 LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) EQpicture.getLayoutParams(); 52 LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) EQpicture.getLayoutParams();
38 layoutParams.width = screenHeight * 17 / 30; 53 layoutParams.width = screenHeight * 15 / 30;
39 layoutParams.height = screenHeight * 19 / 30; 54 layoutParams.height = screenHeight * 17 / 30;
40 EQpicture.setLayoutParams(layoutParams); 55 EQpicture.setLayoutParams(layoutParams);
41 //生成占屏幕一定比例 的二维码存储在本地并显示 56 //生成占屏幕一定比例 的二维码存储在本地并显示
42 file = new File(FileUtil.getCachePath(this), "user-code.jpg"); 57 file = new File(FileUtil.getCachePath(this), "user-code.jpg");
43 Bitmap bitmap = QRCodeUtil.createQRImage("www.baidu.com", screenHeight * 15 / 30, screenHeight * 15 / 30, null, file.getPath()); 58 Bitmap bitmap = QRCodeUtil.createQRImage("www.baidu.com", screenHeight * 15 / 30, screenHeight * 15 / 30, null, file.getPath());
44 if (bitmap != null) { 59 if (bitmap != null) {
45 EQpicture.setImageBitmap(bitmap); 60 EQpicture.setImageBitmap(bitmap);
46 } 61 }
47 } 62 }
48 } 63 }
49 64
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeBangDingActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 5
6 import com.hjx.personalcenter.R; 6 import com.hjx.personalcenter.R;
7 7
8 /** 8 /**
9 * Created by h on 2017/8/9. 9 * Created by h on 2017/8/9.
10 */ 10 */
11 11
12 public class ChangeBangDingActivity extends Activity { 12 public class ChangeBangDingActivity extends Activity {
13 @Override 13 @Override
14 protected void onCreate(Bundle savedInstanceState) { 14 protected void onCreate(Bundle savedInstanceState) {
15 super.onCreate(savedInstanceState); 15 super.onCreate(savedInstanceState);
16 setContentView(R.layout.activity_chage_binding); 16 setContentView(R.layout.activity_chage_binding);
17 SysApplication.getInstance().addActivity(this);
17 } 18 }
18 } 19 }
19 20
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeElectronicCardAdressInfoActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.os.Bundle; 3 import android.os.Bundle;
4 import android.os.Handler; 4 import android.os.Handler;
5 import android.os.Message; 5 import android.os.Message;
6 import android.support.v7.app.AppCompatActivity; 6 import android.support.v7.app.AppCompatActivity;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.Button; 9 import android.widget.Button;
10 import android.widget.EditText; 10 import android.widget.EditText;
11 import android.widget.ImageView; 11 import android.widget.ImageView;
12 import android.widget.TextView; 12 import android.widget.TextView;
13 13
14 import com.hjx.personalcenter.R; 14 import com.hjx.personalcenter.R;
15 import com.hjx.personalcenter.customdialog.CitysListDialog; 15 import com.hjx.personalcenter.customdialog.CitysListDialog;
16 import com.hjx.personalcenter.customdialog.CountryDialog; 16 import com.hjx.personalcenter.customdialog.CountryDialog;
17 import com.hjx.personalcenter.customdialog.ProvinceListDialog; 17 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
18 import com.hjx.personalcenter.db.SaveParam; 18 import com.hjx.personalcenter.db.SaveParam;
19 import com.hjx.personalcenter.http.HttpCode; 19 import com.hjx.personalcenter.http.HttpCode;
20 import com.hjx.personalcenter.http.HttpManager; 20 import com.hjx.personalcenter.http.HttpManager;
21 import com.hjx.personalcenter.interfaces.DialogCallBack; 21 import com.hjx.personalcenter.interfaces.DialogCallBack;
22 import com.hjx.personalcenter.model.CityInfo; 22 import com.hjx.personalcenter.model.CityInfo;
23 import com.hjx.personalcenter.model.CountyInfo; 23 import com.hjx.personalcenter.model.CountyInfo;
24 import com.hjx.personalcenter.model.ProvinceInfo; 24 import com.hjx.personalcenter.model.ProvinceInfo;
25 import com.hjx.personalcenter.util.AlertUtils; 25 import com.hjx.personalcenter.util.AlertUtils;
26 import com.hjx.personalcenter.util.Judgment; 26 import com.hjx.personalcenter.util.Judgment;
27 import com.hjx.personalcenter.util.PhoneNumCheckUtils; 27 import com.hjx.personalcenter.util.PhoneNumCheckUtils;
28 28
29 import org.json.JSONObject; 29 import org.json.JSONObject;
30 30
31 import java.util.ArrayList; 31 import java.util.ArrayList;
32 import java.util.TimerTask; 32 import java.util.TimerTask;
33 33
34 /** 34 /**
35 * Created by h on 2017/8/9. 35 * Created by h on 2017/8/9.
36 */ 36 */
37 37
38 public class ChangeElectronicCardAdressInfoActivity extends AppCompatActivity implements View.OnClickListener 38 public class ChangeElectronicCardAdressInfoActivity extends AppCompatActivity implements View.OnClickListener
39 ,DialogCallBack.ProvincesCallBack 39 ,DialogCallBack.ProvincesCallBack
40 ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack{ 40 ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack{
41 private ImageView back_forgit; 41 private ImageView back_forgit;
42 private EditText forot_pwd_phone,forot_pwd_anthcode,newadress; 42 private EditText forot_pwd_phone,forot_pwd_anthcode,newadress;
43 private TextView adress; 43 private TextView adress;
44 private Button forot_pwd_sub,forot_pwd_getanthcode; 44 private Button forot_pwd_sub,forot_pwd_getanthcode;
45 private String typeStr = "register"; 45 private String typeStr = "register";
46 private int delayTime=60; 46 private int delayTime=60;
47 private java.util.Timer Delaytimer; 47 private java.util.Timer Delaytimer;
48 Handler handler = new Handler() { 48 Handler handler = new Handler() {
49 @Override 49 @Override
50 public void handleMessage(Message msg) { 50 public void handleMessage(Message msg) {
51 super.handleMessage(msg); 51 super.handleMessage(msg);
52 JSONObject jsonObject; 52 JSONObject jsonObject;
53 String status; 53 String status;
54 switch (msg.what) { 54 switch (msg.what) {
55 case HttpCode.AUTHCODE_SUCESS1: 55 case HttpCode.AUTHCODE_SUCESS1:
56 jsonObject = (JSONObject) msg.obj; 56 jsonObject = (JSONObject) msg.obj;
57 status = jsonObject.optString("status"); 57 status = jsonObject.optString("status");
58 if (status.equals("100")) { 58 if (status.equals("100")) {
59 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "验证码发送成功"); 59 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "验证码发送成功");
60 } 60 }
61 //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); 61 //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message"));
62 break; 62 break;
63 case HttpCode.AUTHCODE_FAIL1: 63 case HttpCode.AUTHCODE_FAIL1:
64 jsonObject = (JSONObject) msg.obj; 64 jsonObject = (JSONObject) msg.obj;
65 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, jsonObject.optString("验证码发送失败,请检查网络")); 65 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, jsonObject.optString("验证码发送失败,请检查网络"));
66 break; 66 break;
67 case 21: 67 case 21:
68 if(delayTime<=0){ 68 if(delayTime<=0){
69 if(Delaytimer!=null){ 69 if(Delaytimer!=null){
70 Delaytimer.cancel(); 70 Delaytimer.cancel();
71 } 71 }
72 forot_pwd_getanthcode.setEnabled(true); 72 forot_pwd_getanthcode.setEnabled(true);
73 forot_pwd_getanthcode.setClickable(true); 73 forot_pwd_getanthcode.setClickable(true);
74 forot_pwd_getanthcode.setText("获取验证码"); 74 forot_pwd_getanthcode.setText("获取验证码");
75 delayTime=60; 75 delayTime=60;
76 }else{ 76 }else{
77 forot_pwd_getanthcode.setEnabled(false); 77 forot_pwd_getanthcode.setEnabled(false);
78 forot_pwd_getanthcode.setClickable(false); 78 forot_pwd_getanthcode.setClickable(false);
79 forot_pwd_getanthcode.setText(delayTime + " s"); 79 forot_pwd_getanthcode.setText(delayTime + " s");
80 } 80 }
81 break; 81 break;
82 } 82 }
83 } 83 }
84 }; 84 };
85 @Override 85 @Override
86 protected void onCreate(Bundle savedInstanceState) { 86 protected void onCreate(Bundle savedInstanceState) {
87 super.onCreate(savedInstanceState); 87 super.onCreate(savedInstanceState);
88 setContentView(R.layout.activity_change_card_validation); 88 setContentView(R.layout.activity_change_card_validation);
89 SysApplication.getInstance().addActivity(this);
89 initView(); 90 initView();
90 setLister(); 91 setLister();
91 } 92 }
92 //获取验证码 93 //获取验证码
93 private void getauthcode() { 94 private void getauthcode() {
94 forot_pwd_anthcode.requestFocus(); 95 forot_pwd_anthcode.requestFocus();
95 String forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 96 String forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
96 HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this); 97 HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this);
97 valiDelay(); 98 valiDelay();
98 99
99 } 100 }
100 private void initView() { 101 private void initView() {
101 forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber); 102 forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber);
102 forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode); 103 forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode);
103 adress = (TextView) findViewById(R.id.et_newpassword); 104 adress = (TextView) findViewById(R.id.et_newpassword);
104 newadress = (EditText) findViewById(R.id.et_again_newpassword); 105 newadress = (EditText) findViewById(R.id.et_again_newpassword);
105 forot_pwd_sub = (Button) findViewById(R.id.btn_ok); 106 forot_pwd_sub = (Button) findViewById(R.id.btn_ok);
106 forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode); 107 forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode);
107 back_forgit= (ImageView) findViewById(R.id.cancel); 108 back_forgit= (ImageView) findViewById(R.id.cancel);
108 } 109 }
109 private void setLister() { 110 private void setLister() {
110 back_forgit.setOnClickListener(this); 111 back_forgit.setOnClickListener(this);
111 forot_pwd_sub.setOnClickListener(this); 112 forot_pwd_sub.setOnClickListener(this);
112 forot_pwd_getanthcode.setOnClickListener(this); 113 forot_pwd_getanthcode.setOnClickListener(this);
113 adress.setOnClickListener(this); 114 adress.setOnClickListener(this);
114 115
115 } 116 }
116 117
117 @Override 118 @Override
118 public void onClick(View view) { 119 public void onClick(View view) {
119 switch (view.getId()){ 120 switch (view.getId()){
120 case R.id.btn_ok: 121 case R.id.btn_ok:
121 String forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 122 String forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
122 String forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim(); 123 String forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim();
123 String forot_pwd_pwd3 = adress.getText().toString().trim(); 124 String forot_pwd_pwd3 = adress.getText().toString().trim();
124 String forot_pwd_pwd4 = newadress.getText().toString().trim(); 125 String forot_pwd_pwd4 = newadress.getText().toString().trim();
125 if (TextUtils.isEmpty(forot_pwd_phone1)|| 126 if (TextUtils.isEmpty(forot_pwd_phone1)||
126 TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)){ 127 TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)){
127 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "请将必填项填写完整"); 128 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "请将必填项填写完整");
128 return; 129 return;
129 }else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)){ 130 }else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)){
130 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "手机号码输入有误"); 131 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "手机号码输入有误");
131 132
132 } else { 133 } else {
133 //修改地址接口 134 //修改地址接口
134 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 135 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
135 long auserID = 0; 136 long auserID = 0;
136 try { 137 try {
137 auserID = Long.parseLong(userID); 138 auserID = Long.parseLong(userID);
138 HttpManager.getInstance().changecardadressinfo(this,auserID,forot_pwd_phone1,forot_pwd_anthcode1,forot_pwd_pwd3+forot_pwd_pwd4); 139 HttpManager.getInstance().changecardadressinfo(this,auserID,forot_pwd_phone1,forot_pwd_anthcode1,forot_pwd_pwd3+forot_pwd_pwd4);
139 } catch (NumberFormatException e) { 140 } catch (NumberFormatException e) {
140 e.printStackTrace(); 141 e.printStackTrace();
141 } 142 }
142 143
143 } 144 }
144 break; 145 break;
145 case R.id.btn_authcode: 146 case R.id.btn_authcode:
146 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 147 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
147 if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)){ 148 if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)){
148 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "请输入正确的手机号"); 149 AlertUtils.showToast(ChangeElectronicCardAdressInfoActivity.this, "请输入正确的手机号");
149 }else { 150 }else {
150 forot_pwd_anthcode.requestFocus(); 151 forot_pwd_anthcode.requestFocus();
151 getauthcode(); 152 getauthcode();
152 153
153 } 154 }
154 155
155 break; 156 break;
156 case R.id.et_newpassword: 157 case R.id.et_newpassword:
157 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) ChangeElectronicCardAdressInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); 158 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) ChangeElectronicCardAdressInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog");
158 break; 159 break;
159 160
160 case R.id.cancel: 161 case R.id.cancel:
161 finish(); 162 finish();
162 break; 163 break;
163 } 164 }
164 } 165 }
165 166
166 @Override 167 @Override
167 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { 168 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) {
168 String regionName = data.get(position).getRegionName(); 169 String regionName = data.get(position).getRegionName();
169 String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); 170 String provice = SaveParam.getInstance().getLoginParam(this,"sheng");
170 SaveParam.getInstance().saveLoginParam(this,"shi",regionName); 171 SaveParam.getInstance().saveLoginParam(this,"shi",regionName);
171 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); 172 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog");
172 adress.setText(""); 173 adress.setText("");
173 adress.setText(provice+regionName); 174 adress.setText(provice+regionName);
174 175
175 176
176 } 177 }
177 178
178 @Override 179 @Override
179 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { 180 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) {
180 String regionName = data.get(position).getRegionName(); 181 String regionName = data.get(position).getRegionName();
181 String provices = SaveParam.getInstance().getLoginParam(this,"sheng"); 182 String provices = SaveParam.getInstance().getLoginParam(this,"sheng");
182 String citys = SaveParam.getInstance().getLoginParam(this,"shi"); 183 String citys = SaveParam.getInstance().getLoginParam(this,"shi");
183 adress.setText(""); 184 adress.setText("");
184 adress.setText(provices+citys+regionName); 185 adress.setText(provices+citys+regionName);
185 } 186 }
186 187
187 @Override 188 @Override
188 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { 189 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) {
189 String regionName = data.get(position).getRegionName(); 190 String regionName = data.get(position).getRegionName();
190 SaveParam.getInstance().saveLoginParam(this,"sheng",regionName); 191 SaveParam.getInstance().saveLoginParam(this,"sheng",regionName);
191 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); 192 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog");
192 adress.setText(""); 193 adress.setText("");
193 adress.setText(regionName); 194 adress.setText(regionName);
194 } 195 }
195 196
196 // 线程类 定时器 197 // 线程类 定时器
197 public void valiDelay() { 198 public void valiDelay() {
198 199
199 Delaytimer = new java.util.Timer(true); 200 Delaytimer = new java.util.Timer(true);
200 201
201 202
202 TimerTask task = new TimerTask() { 203 TimerTask task = new TimerTask() {
203 public void run() { 204 public void run() {
204 //每次需要执行的代码放到这里面。 205 //每次需要执行的代码放到这里面。
205 delayTime--; 206 delayTime--;
206 handler.sendEmptyMessage(21); 207 handler.sendEmptyMessage(21);
207 208
208 209
209 210
210 } 211 }
211 }; 212 };
212 Delaytimer.schedule(task, 1000,1000); 213 Delaytimer.schedule(task, 1000,1000);
213 } 214 }
214 215
215 } 216 }
216 217
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeEletronicCardPhoneActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.os.Bundle; 3 import android.os.Bundle;
4 import android.support.v7.app.AppCompatActivity; 4 import android.support.v7.app.AppCompatActivity;
5 5
6 import com.hjx.personalcenter.R; 6 import com.hjx.personalcenter.R;
7 7
8 /** 8 /**
9 * Created by h on 2017/8/9. 9 * Created by h on 2017/8/9.
10 */ 10 */
11 11
12 public class ChangeEletronicCardPhoneActivity extends AppCompatActivity { 12 public class ChangeEletronicCardPhoneActivity extends AppCompatActivity {
13 13
14 14
15 @Override 15 @Override
16 protected void onCreate(Bundle savedInstanceState) { 16 protected void onCreate(Bundle savedInstanceState) {
17 super.onCreate(savedInstanceState); 17 super.onCreate(savedInstanceState);
18 setContentView(R.layout.activity_electronicard_phone); 18 setContentView(R.layout.activity_electronicard_phone);
19 SysApplication.getInstance().addActivity(this);
19 } 20 }
20 } 21 }
21 22
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePasswordActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.os.Bundle; 3 import android.os.Bundle;
4 import android.support.v7.app.AppCompatActivity; 4 import android.support.v7.app.AppCompatActivity;
5 import android.text.TextUtils; 5 import android.text.TextUtils;
6 import android.text.method.HideReturnsTransformationMethod; 6 import android.text.method.HideReturnsTransformationMethod;
7 import android.text.method.PasswordTransformationMethod; 7 import android.text.method.PasswordTransformationMethod;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.Button; 9 import android.widget.Button;
10 import android.widget.EditText; 10 import android.widget.EditText;
11 import android.widget.ImageView; 11 import android.widget.ImageView;
12 12
13 import com.hjx.personalcenter.R; 13 import com.hjx.personalcenter.R;
14 import com.hjx.personalcenter.db.SaveParam; 14 import com.hjx.personalcenter.db.SaveParam;
15 import com.hjx.personalcenter.http.HttpManager; 15 import com.hjx.personalcenter.http.HttpManager;
16 import com.hjx.personalcenter.util.AlertUtils; 16 import com.hjx.personalcenter.util.AlertUtils;
17 import com.hjx.personalcenter.util.PasswordCheckUtils; 17 import com.hjx.personalcenter.util.PasswordCheckUtils;
18 18
19 /**修改密码 19 /**修改密码
20 * Created by h on 2017/6/27. 20 * Created by h on 2017/6/27.
21 */ 21 */
22 22
23 public class ChangePasswordActivity extends AppCompatActivity implements View.OnClickListener { 23 public class ChangePasswordActivity extends AppCompatActivity implements View.OnClickListener {
24 private EditText old_pwd,newpassword,newpassword1; 24 private EditText old_pwd,newpassword,newpassword1;
25 private Button sub_change_pwd; 25 private Button sub_change_pwd;
26 private ImageView back_change_pwd,eyes_iv_change1; 26 private ImageView back_change_pwd,eyes_iv_change1;
27 public static Boolean showPassword = false; 27 public static Boolean showPassword = false;
28 @Override 28 @Override
29 protected void onCreate(Bundle savedInstanceState) { 29 protected void onCreate(Bundle savedInstanceState) {
30 super.onCreate(savedInstanceState); 30 super.onCreate(savedInstanceState);
31 setContentView(R.layout.activity_changepsword); 31 setContentView(R.layout.activity_changepsword);
32 SysApplication.getInstance().addActivity(this);
32 initView(); 33 initView();
33 setLister(); 34 setLister();
34 } 35 }
35 36
36 private void initView() { 37 private void initView() {
37 old_pwd = (EditText) findViewById(R.id.et_oldpassword); 38 old_pwd = (EditText) findViewById(R.id.et_oldpassword);
38 newpassword = (EditText) findViewById(R.id.et_newpassword); 39 newpassword = (EditText) findViewById(R.id.et_newpassword);
39 newpassword1 = (EditText) findViewById(R.id.et_again_newpassword); 40 newpassword1 = (EditText) findViewById(R.id.et_again_newpassword);
40 sub_change_pwd = (Button) findViewById(R.id.btn_ok); 41 sub_change_pwd = (Button) findViewById(R.id.btn_ok);
41 back_change_pwd = (ImageView) findViewById(R.id.cancel); 42 back_change_pwd = (ImageView) findViewById(R.id.cancel);
42 eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change); 43 eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change);
43 44
44 45
45 } 46 }
46 47
47 private void setLister() { 48 private void setLister() {
48 sub_change_pwd.setOnClickListener(this); 49 sub_change_pwd.setOnClickListener(this);
49 back_change_pwd.setOnClickListener(this); 50 back_change_pwd.setOnClickListener(this);
50 eyes_iv_change1.setOnClickListener(this); 51 eyes_iv_change1.setOnClickListener(this);
51 } 52 }
52 53
53 @Override 54 @Override
54 public void onClick(View v) { 55 public void onClick(View v) {
55 String old_pwd1 = old_pwd.getText().toString().trim(); 56 String old_pwd1 = old_pwd.getText().toString().trim();
56 String newpassword3 = newpassword.getText().toString().trim(); 57 String newpassword3 = newpassword.getText().toString().trim();
57 String newpassword4 = newpassword1.getText().toString().trim(); 58 String newpassword4 = newpassword1.getText().toString().trim();
58 switch (v.getId()){ 59 switch (v.getId()){
59 //确认修改 60 //确认修改
60 case R.id.btn_ok: 61 case R.id.btn_ok:
61 62
62 //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password")); 63 //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password"));
63 if (TextUtils.isEmpty(old_pwd1)|| 64 if (TextUtils.isEmpty(old_pwd1)||
64 TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){ 65 TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){
65 AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整"); 66 AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整");
66 return; 67 return;
67 }else if(newpassword3.length()<8||newpassword4.length()<8){ 68 }else if(newpassword3.length()<8||newpassword4.length()<8){
68 AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位"); 69 AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位");
69 }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ 70 }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){
70 AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成"); 71 AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成");
71 } 72 }
72 //得到原密码并且判断是否输入的一样 73 //得到原密码并且判断是否输入的一样
73 else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){ 74 else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){
74 75
75 AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误"); 76 AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误");
76 77
77 }else if (!newpassword3.equals(newpassword4)){ 78 }else if (!newpassword3.equals(newpassword4)){
78 AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致"); 79 AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致");
79 return; 80 return;
80 }else{ 81 }else{
81 //修改密码接口 82 //修改密码接口
82 String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username"); 83 String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username");
83 HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3); 84 HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3);
84 } 85 }
85 86
86 break; 87 break;
87 case R.id.iv_pwd_change: 88 case R.id.iv_pwd_change:
88 if(showPassword){//显示密码 89 if(showPassword){//显示密码
89 showPassword = !showPassword; 90 showPassword = !showPassword;
90 eyes_iv_change1.setImageResource(R.mipmap.pwd_open); 91 eyes_iv_change1.setImageResource(R.mipmap.pwd_open);
91 newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); 92 newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
92 newpassword.setSelection(newpassword.getText().toString().length()); 93 newpassword.setSelection(newpassword.getText().toString().length());
93 }else{//隐藏密码 94 }else{//隐藏密码
94 showPassword = !showPassword; 95 showPassword = !showPassword;
95 eyes_iv_change1.setImageResource(R.mipmap.pwd_hide); 96 eyes_iv_change1.setImageResource(R.mipmap.pwd_hide);
96 newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); 97 newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
97 newpassword.setSelection(newpassword.getText().toString().length()); 98 newpassword.setSelection(newpassword.getText().toString().length());
98 } 99 }
99 break; 100 break;
100 101
101 case R.id.cancel: 102 case R.id.cancel:
102 finish(); 103 finish();
103 break; 104 break;
104 } 105 }
105 106
106 } 107 }
107 } 108 }
108 109
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePresonalInfoActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.os.Bundle; 3 import android.os.Bundle;
4 import android.support.v4.app.Fragment; 4 import android.support.v4.app.Fragment;
5 import android.support.v4.view.ViewPager; 5 import android.support.v4.view.ViewPager;
6 import android.support.v7.app.AppCompatActivity; 6 import android.support.v7.app.AppCompatActivity;
7 import android.view.View; 7 import android.view.View;
8 import android.widget.ImageView; 8 import android.widget.ImageView;
9 import android.widget.TextView; 9 import android.widget.TextView;
10 10
11 import com.hjx.personalcenter.R; 11 import com.hjx.personalcenter.R;
12 import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; 12 import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter;
13 import com.hjx.personalcenter.fragment.PresonInfoFragment; 13 import com.hjx.personalcenter.fragment.PresonInfoFragment;
14 import com.hjx.personalcenter.fragment.VersionsInfoFragment; 14 import com.hjx.personalcenter.fragment.VersionsInfoFragment;
15 import com.hjx.personalcenter.thirdparty.SlidingTabLayout; 15 import com.hjx.personalcenter.thirdparty.SlidingTabLayout;
16 16
17 import java.util.ArrayList; 17 import java.util.ArrayList;
18 import java.util.Arrays; 18 import java.util.Arrays;
19 import java.util.List; 19 import java.util.List;
20 20
21 /** 21 /**
22 * Created by h on 2017/8/12. 22 * Created by h on 2017/8/12.
23 */ 23 */
24 24
25 public class ChangePresonalInfoActivity extends AppCompatActivity implements View.OnClickListener { 25 public class ChangePresonalInfoActivity extends AppCompatActivity implements View.OnClickListener {
26 private ViewPager viewPager; 26 private ViewPager viewPager;
27 private SlidingTabLayout tableLayout; 27 private SlidingTabLayout tableLayout;
28 private TextView subsave; 28 private TextView subsave;
29 private ImageView cancel; 29 private ImageView cancel;
30 private List<Fragment> presoninfo; 30 private List<Fragment> presoninfo;
31 private LoginAndRegisterAdapter presoninfodapter; 31 private LoginAndRegisterAdapter presoninfodapter;
32 private List<String> title = Arrays.asList("个人信息", "版本信息"); 32 private List<String> title = Arrays.asList("个人信息", "版本信息");
33 @Override 33 @Override
34 protected void onCreate(Bundle savedInstanceState) { 34 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState); 35 super.onCreate(savedInstanceState);
36 setContentView(R.layout.activity_change_preson_info); 36 setContentView(R.layout.activity_change_preson_info);
37 SysApplication.getInstance().addActivity(this);
37 initView(); 38 initView();
38 initData(); 39 initData();
39 setLister(); 40 setLister();
40 41
41 } 42 }
42 private void initView() { 43 private void initView() {
43 viewPager = (ViewPager) findViewById(R.id.viewpager_login); 44 viewPager = (ViewPager) findViewById(R.id.viewpager_login);
44 tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); 45 tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id);
45 cancel = (ImageView) findViewById(R.id.cancel); 46 cancel = (ImageView) findViewById(R.id.cancel);
46 subsave = (TextView) findViewById(R.id.presonal_sub); 47 subsave = (TextView) findViewById(R.id.presonal_sub);
47 } 48 }
48 49
49 private void initData() { 50 private void initData() {
50 presoninfo = new ArrayList<>(); 51 presoninfo = new ArrayList<>();
51 for (int i = 0; i < title.size(); i++) { 52 for (int i = 0; i < title.size(); i++) {
52 if (title.get(i).equals("个人信息")) { 53 if (title.get(i).equals("个人信息")) {
53 presoninfo.add(PresonInfoFragment.newInstance(i + 1)); 54 presoninfo.add(PresonInfoFragment.newInstance(i + 1));
54 } else { 55 } else {
55 presoninfo.add(VersionsInfoFragment.newInstance(i + 1)); 56 presoninfo.add(VersionsInfoFragment.newInstance(i + 1));
56 } 57 }
57 } 58 }
58 59
59 60
60 //设置Tab上的标题 61 //设置Tab上的标题
61 tableLayout.setData(title); 62 tableLayout.setData(title);
62 //设置关联的ViewPager 63 //设置关联的ViewPager
63 tableLayout.setViewPager(viewPager, 0); 64 tableLayout.setViewPager(viewPager, 0);
64 presoninfodapter = new LoginAndRegisterAdapter(presoninfo, getSupportFragmentManager()); 65 presoninfodapter = new LoginAndRegisterAdapter(presoninfo, getSupportFragmentManager());
65 //给ViewPager设置适配器 66 //给ViewPager设置适配器
66 viewPager.setAdapter(presoninfodapter); 67 viewPager.setAdapter(presoninfodapter);
67 //设置滑动时数据不丢失 68 //设置滑动时数据不丢失
68 viewPager.setOffscreenPageLimit(1); 69 viewPager.setOffscreenPageLimit(1);
69 //将TabLayout和ViewPager关联起来。 70 //将TabLayout和ViewPager关联起来。
70 } 71 }
71
72 private void setLister() { 72 private void setLister() {
73 cancel.setOnClickListener(this); 73 cancel.setOnClickListener(this);
74 subsave.setOnClickListener(this);
74 } 75 }
75 76
76 @Override 77 @Override
77 public void onClick(View v) { 78 public void onClick(View v) {
78 switch (v.getId()){ 79 switch (v.getId()){
80 case R.id.presonal_sub:
81 break;
79 case R.id.cancel: 82 case R.id.cancel:
80 finish(); 83 finish();
81 break; 84 break;
82 } 85 }
83 86
84 } 87 }
85 } 88 }
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChoiseTextBookActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.os.Handler; 5 import android.os.Handler;
6 import android.os.Message; 6 import android.os.Message;
7 import android.support.v7.app.AppCompatActivity; 7 import android.support.v7.app.AppCompatActivity;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.AdapterView; 9 import android.widget.AdapterView;
10 import android.widget.Button; 10 import android.widget.Button;
11 import android.widget.GridView; 11 import android.widget.GridView;
12 import android.widget.ImageView; 12 import android.widget.ImageView;
13 import android.widget.TextView; 13 import android.widget.TextView;
14 import android.widget.Toast; 14 import android.widget.Toast;
15 15
16 import com.facebook.drawee.view.SimpleDraweeView; 16 import com.facebook.drawee.view.SimpleDraweeView;
17 import com.hjx.personalcenter.R; 17 import com.hjx.personalcenter.R;
18 import com.hjx.personalcenter.adapter.GridAdapter; 18 import com.hjx.personalcenter.adapter.GridAdapter;
19 import com.hjx.personalcenter.customdialog.ElectronicCardDialog; 19 import com.hjx.personalcenter.customdialog.ElectronicCardDialog;
20 import com.hjx.personalcenter.customdialog.VerSionDialog; 20 import com.hjx.personalcenter.customdialog.VerSionDialog;
21 import com.hjx.personalcenter.db.SaveParam; 21 import com.hjx.personalcenter.db.SaveParam;
22 import com.hjx.personalcenter.http.HttpCode; 22 import com.hjx.personalcenter.http.HttpCode;
23 import com.hjx.personalcenter.http.HttpManager; 23 import com.hjx.personalcenter.http.HttpManager;
24 import com.hjx.personalcenter.interfaces.DialogCallBack;
24 import com.hjx.personalcenter.model.DefautPublishInfo; 25 import com.hjx.personalcenter.model.DefautPublishInfo;
26 import com.hjx.personalcenter.model.VersionInfo;
25 import com.hjx.personalcenter.util.AlertUtils; 27 import com.hjx.personalcenter.util.AlertUtils;
26 28
27 import org.json.JSONException; 29 import org.json.JSONException;
28 import org.json.JSONObject; 30 import org.json.JSONObject;
29 31
30 import java.util.ArrayList; 32 import java.util.ArrayList;
31 import java.util.List; 33 import java.util.List;
32 34
33 /** 35 /**
34 * 选择教材 36 * 选择教材
35 * Created by h on 2017/8/10. 37 * Created by h on 2017/8/10.
36 */ 38 */
37 39
38 public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener{ 40 public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener, DialogCallBack.VersionCallBack {
39 private GridView gridView; 41 private GridView gridView;
40 private Button btn_ok; 42 private Button btn_ok;
41 private ImageView cancel; 43 private ImageView cancel;
42 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); 44 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>();
43 private GridAdapter sim_adapter; 45 private GridAdapter sim_adapter;
44 46 private SimpleDraweeView simpleDraweeView;
47 private TextView publish;
45 48
46 49
47 Handler handler = new Handler() { 50 Handler handler = new Handler() {
48 @Override 51 @Override
49 public void handleMessage(Message msg) { 52 public void handleMessage(Message msg) {
50 super.handleMessage(msg); 53 super.handleMessage(msg);
51 JSONObject jsonObject; 54 JSONObject jsonObject;
52 String status; 55 String status;
53 switch (msg.what) { 56 switch (msg.what) {
54 case HttpCode.CHECKCARD: 57 case HttpCode.CHECKCARD:
55 try { 58 try {
56 jsonObject = new JSONObject((String) msg.obj); 59 jsonObject = new JSONObject((String) msg.obj);
57 status = jsonObject.optString("status"); 60 status = jsonObject.optString("status");
58 if (status.equals("1")) { 61 if (status.equals("1")) {
59 AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); 62 AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!");
60 Intent intent = new Intent(); 63 Intent intent = new Intent();
61 intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); 64 intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class);
62 ChoiseTextBookActivity.this.startActivity(intent); 65 ChoiseTextBookActivity.this.startActivity(intent);
63 overridePendingTransition(R.anim.rightin, R.anim.rightout); 66 overridePendingTransition(R.anim.rightin, R.anim.rightout);
64 } else if (status.equals("2001")) { 67 } else if (status.equals("2001")) {
65 ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); 68 ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog");
66 } 69 }
67 70
68 } catch (JSONException e) { 71 } catch (JSONException e) {
69 e.printStackTrace(); 72 e.printStackTrace();
70 } 73 }
71 74
72 break; 75 break;
73 case HttpCode.PUBLISH_SUCESS: 76 case HttpCode.PUBLISH_SUCESS:
74 defautPublishInfos.clear(); 77 defautPublishInfos.clear();
75 defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj); 78 defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj);
76 sim_adapter.notifyDataSetChanged(); 79 sim_adapter.notifyDataSetChanged();
77 break; 80 break;
78 case HttpCode.REGISTERINFO_SUCESS: 81 case HttpCode.REGISTERINFO_SUCESS:
79 try { 82 try {
80 jsonObject = new JSONObject((String) msg.obj); 83 jsonObject = new JSONObject((String) msg.obj);
81 String statusregister = jsonObject.optString("status"); 84 String statusregister = jsonObject.optString("status");
82 if (statusregister.equals("1")) { 85 if (statusregister.equals("1")) {
83 Toast.makeText(ChoiseTextBookActivity.this, "注册信息上传成功", Toast.LENGTH_LONG).show(); 86 Toast.makeText(ChoiseTextBookActivity.this, "注册信息上传成功", Toast.LENGTH_LONG).show();
84 String userID = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, "userId"); 87 String userID = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, "userId");
85 try { 88 try {
86 if (userID == null) { 89 if (userID == null) {
87 AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); 90 AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!");
88 91
89 } else { 92 } else {
90 long auserID = Long.parseLong(userID); 93 long auserID = Long.parseLong(userID);
91 //验证保卡信息 94 //验证保卡信息
92 HttpManager.getInstance().cardinfocheck(ChoiseTextBookActivity.this, auserID, handler); 95 HttpManager.getInstance().cardinfocheck(ChoiseTextBookActivity.this, auserID, handler);
93 } 96 }
94 97
95 } catch (NumberFormatException e) { 98 } catch (NumberFormatException e) {
96 e.printStackTrace(); 99 e.printStackTrace();
97 } 100 }
98 101
99 } else { 102 } else {
100 AlertUtils.showToast(ChoiseTextBookActivity.this, "您好,服务器异常,请稍后重试"); 103 AlertUtils.showToast(ChoiseTextBookActivity.this, "您好,服务器异常,请稍后重试");
101 } 104 }
102 } catch (JSONException e) { 105 } catch (JSONException e) {
103 e.printStackTrace(); 106 e.printStackTrace();
104 } 107 }
105 108
106 109
107 break; 110 break;
108 111
109 } 112 }
110 113
111 } 114 }
112 }; 115 };
113 116
114 @Override 117 @Override
115 protected void onCreate(Bundle savedInstanceState) { 118 protected void onCreate(Bundle savedInstanceState) {
116 super.onCreate(savedInstanceState); 119 super.onCreate(savedInstanceState);
117 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 120 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
118 String graderid = SaveParam.getInstance().getCustomizeParam(this,SaveParam.GRADENS); 121 String graderid = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS);
119 try { 122 try {
120 long auserID = Long.parseLong(userID); 123 long auserID = Long.parseLong(userID);
121 int graderID = Integer.parseInt(graderid); 124 int graderID = Integer.parseInt(graderid);
122 //获取版本信息 125 //获取版本信息
123 HttpManager.getInstance().getpublishinfo(this,auserID,graderID,handler); 126 HttpManager.getInstance().getpublishinfo(this, auserID, graderID, handler);
124 127
125 } catch (NumberFormatException e) { 128 } catch (NumberFormatException e) {
126 e.printStackTrace(); 129 e.printStackTrace();
127 } 130 }
128 setContentView(R.layout.activity_choisetextbook); 131 setContentView(R.layout.activity_choisetextbook);
132 SysApplication.getInstance().addActivity(this);
129 initView(); 133 initView();
130 initData(); 134 initData();
131 initLister(); 135 initLister();
132 } 136 }
133 137
134 private void initView() { 138 private void initView() {
135 gridView = (GridView) findViewById(R.id.grideview); 139 gridView = (GridView) findViewById(R.id.grideview);
136 cancel = (ImageView) findViewById(R.id.cancel); 140 cancel = (ImageView) findViewById(R.id.cancel);
137 btn_ok = (Button) findViewById(R.id.btn_ok); 141 btn_ok = (Button) findViewById(R.id.btn_ok);
138 } 142 }
139 143
140 private void initData() { 144 private void initData() {
141 sim_adapter = new GridAdapter(defautPublishInfos,this); 145 sim_adapter = new GridAdapter(defautPublishInfos, this);
142 //配置适配器 146 //配置适配器
143 gridView.setAdapter(sim_adapter); 147 gridView.setAdapter(sim_adapter);
144 148
145 } 149 }
146 150
147 private void initLister() { 151 private void initLister() {
148 btn_ok.setOnClickListener(this); 152 btn_ok.setOnClickListener(this);
149 cancel.setOnClickListener(this); 153 cancel.setOnClickListener(this);
150 gridView.setOnItemClickListener(this); 154 gridView.setOnItemClickListener(this);
151 155
152 } 156 }
153 157
154 @Override 158 @Override
155 public void onClick(View v) { 159 public void onClick(View v) {
156 switch (v.getId()) { 160 switch (v.getId()) {
157 case R.id.btn_ok: 161 case R.id.btn_ok:
158 String userID = SaveParam.getInstance().getLoginParam(this, "userId"); 162 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
159 String regionId = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.COUNTRY); 163 String regionId = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.COUNTRY);
160 String regionId1 = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.CITYS); 164 String regionId1 = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.CITYS);
161 if (regionId == null) { 165 if (regionId == null) {
162 regionId = regionId1; 166 regionId = regionId1;
163 } 167 }
164 String grade = SaveParam.getInstance().getCustomizeParam(ChoiseTextBookActivity.this, SaveParam.GRADENS); 168 String grade = SaveParam.getInstance().getCustomizeParam(ChoiseTextBookActivity.this, SaveParam.GRADENS);
165 String schoolid = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.SCHOOOlID); 169 String schoolid = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.SCHOOOlID);
166 String name = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.USERNAME); 170 String name = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.USERNAME);
167 String regeionname = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.ADRESS); 171 String regeionname = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.ADRESS);
168 String togoth ="人民教育出版社"; 172 String togoth = "人民教育出版社";
169 173
170 try { 174 try {
171 if (userID == null) { 175 if (userID == null) {
172 AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); 176 AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!");
173 177
174 } else { 178 } else {
175 Object schoolID; 179 Object schoolID;
176 long auserID = Long.parseLong(userID); 180 long auserID = Long.parseLong(userID);
177 int gradeID = Integer.parseInt(grade); 181 int gradeID = Integer.parseInt(grade);
178 long regionID = Long.parseLong(regionId); 182 long regionID = Long.parseLong(regionId);
179 if (schoolid==null){ 183 if (schoolid == null) {
180 schoolID =null; 184 schoolID = null;
181 }else { 185 } else {
182 schoolID = Long.parseLong(schoolid); 186 schoolID = Long.parseLong(schoolid);
183 } 187 }
184 188
185 //提交注册信息 189 //提交注册信息
186 HttpManager.getInstance().subregisterinfo(ChoiseTextBookActivity.this, auserID, 190 HttpManager.getInstance().subregisterinfo(ChoiseTextBookActivity.this, auserID,
187 name ,gradeID,regionID,regeionname,schoolID,togoth,togoth,togoth,togoth 191 name, gradeID, regionID, regeionname, schoolID, togoth, togoth, togoth, togoth
188 ,togoth,togoth,togoth,togoth,togoth,togoth,handler); 192 , togoth, togoth, togoth, togoth, togoth, togoth, handler);
189 } 193 }
190 194
191 } catch (NumberFormatException e) { 195 } catch (NumberFormatException e) {
192 e.printStackTrace(); 196 e.printStackTrace();
193 } 197 }
194 198
195 break; 199 break;
196 case R.id.cancel: 200 case R.id.cancel:
197 finish(); 201 finish();
198 break; 202 break;
199 } 203 }
200 204
201 } 205 }
202 206
203 @Override 207 @Override
204 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 208 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
205 SaveParam.getInstance().saveLoginParam(this,SaveParam.SUBJECT,defautPublishInfos.get(position).getSubject()); 209 SaveParam.getInstance().saveLoginParam(this, SaveParam.SUBJECT, defautPublishInfos.get(position).getSubject());
206 VerSionDialog.getInstance().show(getSupportFragmentManager(), "VerSionDialog"); 210 VerSionDialog.getInstance(this).show(getSupportFragmentManager(), "VerSionDialog");
207 211 simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.image_publish);
208 String imgurl = SaveParam.getInstance().getLoginParam(this, SaveParam.IMGURL); 212 publish = (TextView) view.findViewById(R.id.tv_publish);
209 String version = SaveParam.getInstance().getLoginParam(this, SaveParam.VERSION); 213
210 SimpleDraweeView simpleDraweeView = (SimpleDraweeView) parent.findViewById(R.id.image_publish);
211 TextView publish = (TextView) parent.findViewById(R.id.tv_publish);
212 simpleDraweeView.setImageURI(imgurl);
213 publish.setText(version);
214 } 214 }
215 215
216 @Override
217 public void versionOnItemClick(ArrayList<VersionInfo.DataBean> data, int position, int type) {
218 String imageurl = data.get(position).getPressCover();
219 String publishs = data.get(position).getPressName();
220 simpleDraweeView.setImageURI(imageurl);
221 publish.setText(publishs);
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardEditInfoActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity; 5 import android.support.v7.app.AppCompatActivity;
6 import android.text.TextUtils; 6 import android.text.TextUtils;
7 import android.view.View; 7 import android.view.View;
8 import android.widget.Button; 8 import android.widget.Button;
9 import android.widget.EditText; 9 import android.widget.EditText;
10 import android.widget.ImageView; 10 import android.widget.ImageView;
11 import android.widget.LinearLayout; 11 import android.widget.LinearLayout;
12 import android.widget.TextView; 12 import android.widget.TextView;
13 13
14 import com.bigkoo.pickerview.TimePickerView; 14 import com.bigkoo.pickerview.TimePickerView;
15 import com.hjx.personalcenter.R; 15 import com.hjx.personalcenter.R;
16 import com.hjx.personalcenter.customdialog.CitysListDialog; 16 import com.hjx.personalcenter.customdialog.CitysListDialog;
17 import com.hjx.personalcenter.customdialog.CountryDialog; 17 import com.hjx.personalcenter.customdialog.CountryDialog;
18 import com.hjx.personalcenter.customdialog.ProvinceListDialog; 18 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
19 import com.hjx.personalcenter.db.Content; 19 import com.hjx.personalcenter.db.Content;
20 import com.hjx.personalcenter.db.SaveParam; 20 import com.hjx.personalcenter.db.SaveParam;
21 import com.hjx.personalcenter.interfaces.DialogCallBack; 21 import com.hjx.personalcenter.interfaces.DialogCallBack;
22 import com.hjx.personalcenter.model.CityInfo; 22 import com.hjx.personalcenter.model.CityInfo;
23 import com.hjx.personalcenter.model.CountyInfo; 23 import com.hjx.personalcenter.model.CountyInfo;
24 import com.hjx.personalcenter.model.ProvinceInfo; 24 import com.hjx.personalcenter.model.ProvinceInfo;
25 import com.hjx.personalcenter.util.AlertUtils; 25 import com.hjx.personalcenter.util.AlertUtils;
26 import com.hjx.personalcenter.util.GetDate; 26 import com.hjx.personalcenter.util.GetDate;
27 27
28 import java.util.ArrayList; 28 import java.util.ArrayList;
29 29
30 /**填写保卡信息 熊巍 30 /**填写保卡信息 熊巍
31 * Created by h on 2017/8/11. 31 * Created by h on 2017/8/11.
32 */ 32 */
33 33
34 public class ElectronicCardEditInfoActivity extends AppCompatActivity implements View.OnClickListener 34 public class ElectronicCardEditInfoActivity extends AppCompatActivity implements View.OnClickListener
35 ,DialogCallBack.ProvincesCallBack 35 ,DialogCallBack.ProvincesCallBack
36 ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack{ 36 ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack{
37 private LinearLayout lineL_buy_time; 37 private LinearLayout lineL_buy_time;
38 private TextView tv_buy_time,adress_shop,adress_custem; 38 private TextView tv_buy_time,adress_shop,adress_custem;
39 private EditText username,store,detalAdress,telphone; 39 private EditText username,store,detalAdress,telphone;
40 private TimePickerView pvTime; 40 private TimePickerView pvTime;
41 private Button btn_change_info; 41 private Button btn_change_info;
42 private ImageView iv_card_back,shop_adress,custom_adress; 42 private ImageView iv_card_back,shop_adress,custom_adress;
43 43
44 @Override 44 @Override
45 protected void onCreate(Bundle savedInstanceState) { 45 protected void onCreate(Bundle savedInstanceState) {
46 super.onCreate(savedInstanceState); 46 super.onCreate(savedInstanceState);
47 setContentView(R.layout.activity_electroniccard_info); 47 setContentView(R.layout.activity_electroniccard_info);
48 SysApplication.getInstance().addActivity(this);
48 initView(); 49 initView();
49 initData(); 50 initData();
50 initLister(); 51 initLister();
51 } 52 }
52 53
53 private void initView() { 54 private void initView() {
54 lineL_buy_time = (LinearLayout) findViewById(R.id.lineL_buy_time); 55 lineL_buy_time = (LinearLayout) findViewById(R.id.lineL_buy_time);
55 tv_buy_time = (TextView) findViewById(R.id.tv_buy_time); 56 tv_buy_time = (TextView) findViewById(R.id.tv_buy_time);
56 adress_shop = (TextView) findViewById(R.id.tv_edit_adress_shop); 57 adress_shop = (TextView) findViewById(R.id.tv_edit_adress_shop);
57 adress_custem = (TextView) findViewById(R.id.tv_edit_adress_custem); 58 adress_custem = (TextView) findViewById(R.id.tv_edit_adress_custem);
58 username = (EditText) findViewById(R.id.et_edit_username); 59 username = (EditText) findViewById(R.id.et_edit_username);
59 store = (EditText) findViewById(R.id.et_edit_store); 60 store = (EditText) findViewById(R.id.et_edit_store);
60 detalAdress = (EditText) findViewById(R.id.et_edit_adress_detail); 61 detalAdress = (EditText) findViewById(R.id.et_edit_adress_detail);
61 telphone = (EditText) findViewById(R.id.et_edit_telphone); 62 telphone = (EditText) findViewById(R.id.et_edit_telphone);
62 btn_change_info = (Button) findViewById(R.id.btn_change_info); 63 btn_change_info = (Button) findViewById(R.id.btn_change_info);
63 iv_card_back = (ImageView) findViewById(R.id.iv_card_back); 64 iv_card_back = (ImageView) findViewById(R.id.iv_card_back);
64 shop_adress = (ImageView) findViewById(R.id.shopdizhi); 65 shop_adress = (ImageView) findViewById(R.id.shopdizhi);
65 custom_adress = (ImageView) findViewById(R.id.cunstomdizhi); 66 custom_adress = (ImageView) findViewById(R.id.cunstomdizhi);
66 } 67 }
67 68
68 private void initData() { 69 private void initData() {
69 GetDate date = new GetDate(); 70 GetDate date = new GetDate();
70 tv_buy_time.setText(date.getYMD().toString()); 71 tv_buy_time.setText(date.getYMD().toString());
71 72
72 } 73 }
73 74
74 private void initLister() { 75 private void initLister() {
75 adress_shop.setOnClickListener(this); 76 adress_shop.setOnClickListener(this);
76 adress_custem.setOnClickListener(this); 77 adress_custem.setOnClickListener(this);
77 btn_change_info.setOnClickListener(this); 78 btn_change_info.setOnClickListener(this);
78 iv_card_back.setOnClickListener(this); 79 iv_card_back.setOnClickListener(this);
79 shop_adress.setOnClickListener(this); 80 shop_adress.setOnClickListener(this);
80 custom_adress.setOnClickListener(this); 81 custom_adress.setOnClickListener(this);
81 82
82 } 83 }
83 84
84 @Override 85 @Override
85 public void onClick(View v) { 86 public void onClick(View v) {
86 switch (v.getId()){ 87 switch (v.getId()){
87 case R.id.btn_change_info: 88 case R.id.btn_change_info:
88 String info1 =username.getText().toString().trim(); 89 String info1 =username.getText().toString().trim();
89 String info2 =adress_custem.getText().toString().trim(); 90 String info2 =adress_custem.getText().toString().trim();
90 String info3 =detalAdress.getText().toString().trim(); 91 String info3 =detalAdress.getText().toString().trim();
91 String info4 =tv_buy_time.getText().toString().trim(); 92 String info4 =tv_buy_time.getText().toString().trim();
92 String info5 =adress_shop.getText().toString().trim(); 93 String info5 =adress_shop.getText().toString().trim();
93 String info6 =store.getText().toString().trim(); 94 String info6 =store.getText().toString().trim();
94 String info7 =telphone.getText().toString().trim(); 95 String info7 =telphone.getText().toString().trim();
95 96
96 if (TextUtils.isEmpty(info1) || TextUtils.isEmpty(info2)||TextUtils.isEmpty(info3) 97 if (TextUtils.isEmpty(info1) || TextUtils.isEmpty(info2)||TextUtils.isEmpty(info3)
97 ||TextUtils.isEmpty(info4)||TextUtils.isEmpty(info5)||TextUtils.isEmpty(info6) 98 ||TextUtils.isEmpty(info4)||TextUtils.isEmpty(info5)||TextUtils.isEmpty(info6)
98 ||TextUtils.isEmpty(info7)) { 99 ||TextUtils.isEmpty(info7)) {
99 AlertUtils.showToast(ElectronicCardEditInfoActivity.this, "所有内容不能为空。"); 100 AlertUtils.showToast(ElectronicCardEditInfoActivity.this, "所有内容不能为空。");
100 return; 101 return;
101 }else { 102 }else {
102 savedata(); 103 savedata();
103 Intent intent = new Intent(); 104 Intent intent = new Intent();
104 intent.setClass(ElectronicCardEditInfoActivity.this,ElectronicCardInfoOKActivity.class); 105 intent.setClass(ElectronicCardEditInfoActivity.this,ElectronicCardInfoOKActivity.class);
105 startActivity(intent); 106 startActivity(intent);
106 overridePendingTransition(R.anim.rightin, R.anim.rightout); 107 overridePendingTransition(R.anim.rightin, R.anim.rightout);
107 } 108 }
108 109
109 break; 110 break;
110 case R.id.tv_edit_adress_shop: 111 case R.id.tv_edit_adress_shop:
111 case R.id.shopdizhi: 112 case R.id.shopdizhi:
112 Content.adressflag =1; 113 Content.adressflag =1;
113 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) this).show(getSupportFragmentManager(), "ProvinceListDialog"); 114 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) this).show(getSupportFragmentManager(), "ProvinceListDialog");
114 115
115 break; 116 break;
116 case R.id.tv_edit_adress_custem: 117 case R.id.tv_edit_adress_custem:
117 case R.id.cunstomdizhi: 118 case R.id.cunstomdizhi:
118 Content.adressflag =2; 119 Content.adressflag =2;
119 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) this).show(getSupportFragmentManager(), "ProvinceListDialog"); 120 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) this).show(getSupportFragmentManager(), "ProvinceListDialog");
120 121
121 break; 122 break;
122 case R.id.iv_card_back: 123 case R.id.iv_card_back:
123 finish(); 124 finish();
124 break; 125 break;
125 126
126 } 127 }
127 128
128 129
129 } 130 }
130 //保存数据 131 //保存数据
131 private void savedata() { 132 private void savedata() {
132 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CUNSTEMNAME, username.getText().toString().trim()); 133 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CUNSTEMNAME, username.getText().toString().trim());
133 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.ADRESSCUNSTEM, adress_custem.getText().toString().trim()+detalAdress.getText().toString().trim()); 134 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.ADRESSCUNSTEM, adress_custem.getText().toString().trim()+detalAdress.getText().toString().trim());
134 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPTIME, tv_buy_time.getText().toString().trim()); 135 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPTIME, tv_buy_time.getText().toString().trim());
135 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPADRESS, adress_shop.getText().toString().trim()+store.getText().toString().trim()); 136 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPADRESS, adress_shop.getText().toString().trim()+store.getText().toString().trim());
136 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPTLEPHONE, telphone.getText().toString().trim()); 137 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPTLEPHONE, telphone.getText().toString().trim());
137 138
138 } 139 }
139 140
140 @Override 141 @Override
141 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { 142 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) {
142 String regionName = data.get(position).getRegionName(); 143 String regionName = data.get(position).getRegionName();
143 String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); 144 String provice = SaveParam.getInstance().getLoginParam(this,"sheng");
144 SaveParam.getInstance().saveLoginParam(this,"shi",regionName); 145 SaveParam.getInstance().saveLoginParam(this,"shi",regionName);
145 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); 146 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog");
146 if (Content.adressflag ==1){ 147 if (Content.adressflag ==1){
147 adress_shop.setText(""); 148 adress_shop.setText("");
148 adress_shop.setText(provice+regionName); 149 adress_shop.setText(provice+regionName);
149 }else { 150 }else {
150 adress_custem.setText(""); 151 adress_custem.setText("");
151 adress_custem.setText(provice+regionName); 152 adress_custem.setText(provice+regionName);
152 } 153 }
153 154
154 } 155 }
155 156
156 @Override 157 @Override
157 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { 158 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) {
158 String regionName = data.get(position).getRegionName(); 159 String regionName = data.get(position).getRegionName();
159 String provices = SaveParam.getInstance().getLoginParam(this,"sheng"); 160 String provices = SaveParam.getInstance().getLoginParam(this,"sheng");
160 String citys = SaveParam.getInstance().getLoginParam(this,"shi"); 161 String citys = SaveParam.getInstance().getLoginParam(this,"shi");
161 if (Content.adressflag ==1){ 162 if (Content.adressflag ==1){
162 adress_shop.setText(""); 163 adress_shop.setText("");
163 adress_shop.setText(provices+citys+regionName); 164 adress_shop.setText(provices+citys+regionName);
164 }else { 165 }else {
165 adress_custem.setText(""); 166 adress_custem.setText("");
166 adress_custem.setText(provices+citys+regionName); 167 adress_custem.setText(provices+citys+regionName);
167 } 168 }
168 169
169 170
170 171
171 } 172 }
172 173
173 @Override 174 @Override
174 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { 175 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) {
175 String regionName = data.get(position).getRegionName(); 176 String regionName = data.get(position).getRegionName();
176 SaveParam.getInstance().saveLoginParam(this,"sheng",regionName); 177 SaveParam.getInstance().saveLoginParam(this,"sheng",regionName);
177 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); 178 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog");
178 adress_custem.setText(""); 179 adress_custem.setText("");
179 adress_custem.setText(regionName); 180 adress_custem.setText(regionName);
180 181
181 } 182 }
182 } 183 }
183 184
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardInfoOKActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity; 5 import android.support.v7.app.AppCompatActivity;
6 import android.view.View; 6 import android.view.View;
7 import android.widget.Button; 7 import android.widget.Button;
8 import android.widget.ImageView; 8 import android.widget.ImageView;
9 import android.widget.TextView; 9 import android.widget.TextView;
10 10
11 import com.hjx.personalcenter.R; 11 import com.hjx.personalcenter.R;
12 import com.hjx.personalcenter.db.SaveParam; 12 import com.hjx.personalcenter.db.SaveParam;
13 import com.hjx.personalcenter.http.HttpManager; 13 import com.hjx.personalcenter.http.HttpManager;
14 import com.hjx.personalcenter.util.GetDevicesUtil; 14 import com.hjx.personalcenter.util.GetDevicesUtil;
15 15
16 /**确认保卡信息 16 /**确认保卡信息
17 * Created by h on 2017/8/11. 17 * Created by h on 2017/8/11.
18 */ 18 */
19 19
20 public class ElectronicCardInfoOKActivity extends AppCompatActivity implements View.OnClickListener { 20 public class ElectronicCardInfoOKActivity extends AppCompatActivity implements View.OnClickListener {
21 private Button btn_finish,btn_bangding; 21 private Button btn_finish,btn_bangding;
22 private ImageView iv_last_step; 22 private ImageView iv_last_step;
23 private TextView usename,deviceModel,customer_address,mac_adress,shoptime,deviceNumber,shopadress,phone,tlePhone; 23 private TextView usename,deviceModel,customer_address,mac_adress,shoptime,deviceNumber,shopadress,phone,tlePhone;
24 @Override 24 @Override
25 protected void onCreate(Bundle savedInstanceState) { 25 protected void onCreate(Bundle savedInstanceState) {
26 super.onCreate(savedInstanceState); 26 super.onCreate(savedInstanceState);
27 setContentView(R.layout.activity_ok_cardinfo); 27 setContentView(R.layout.activity_ok_cardinfo);
28 SysApplication.getInstance().addActivity(this);
28 initView(); 29 initView();
29 initData(); 30 initData();
30 initLister(); 31 initLister();
31 } 32 }
32 private void initView() { 33 private void initView() {
33 btn_finish = (Button) findViewById(R.id.btn_finish); 34 btn_finish = (Button) findViewById(R.id.btn_finish);
34 iv_last_step = (ImageView) findViewById(R.id.cancel); 35 iv_last_step = (ImageView) findViewById(R.id.cancel);
35 usename = (TextView) findViewById(R.id.iv_card_username); 36 usename = (TextView) findViewById(R.id.iv_card_username);
36 deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); 37 deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel);
37 customer_address = (TextView) findViewById(R.id.tv_card_adress); 38 customer_address = (TextView) findViewById(R.id.tv_card_adress);
38 mac_adress = (TextView) findViewById(R.id.tv_card_mac); 39 mac_adress = (TextView) findViewById(R.id.tv_card_mac);
39 shoptime = (TextView) findViewById(R.id.tv_card_time); 40 shoptime = (TextView) findViewById(R.id.tv_card_time);
40 deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber); 41 deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber);
41 shopadress = (TextView) findViewById(R.id.tv_card_shopAdress); 42 shopadress = (TextView) findViewById(R.id.tv_card_shopAdress);
42 phone = (TextView) findViewById(R.id.tv_card_phone); 43 phone = (TextView) findViewById(R.id.tv_card_phone);
43 tlePhone = (TextView) findViewById(R.id.tv_card_tleNember); 44 tlePhone = (TextView) findViewById(R.id.tv_card_tleNember);
44 btn_bangding = (Button) findViewById(R.id.btn_bangding); 45 btn_bangding = (Button) findViewById(R.id.btn_bangding);
45 } 46 }
46 47
47 private void initData() { 48 private void initData() {
48 //获取设备信息 49 //获取设备信息
49 deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel()); 50 deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel());
50 deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber()); 51 deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber());
51 mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac()); 52 mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac());
52 //获取保卡信息 53 //获取保卡信息
53 usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME)); 54 usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME));
54 customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM)); 55 customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM));
55 shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME)); 56 shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME));
56 shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS)); 57 shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS));
57 tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE)); 58 tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE));
58 phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE)); 59 phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE));
59 60
60 61
61 } 62 }
62 63
63 private void initLister() { 64 private void initLister() {
64 iv_last_step.setOnClickListener(this); 65 iv_last_step.setOnClickListener(this);
65 btn_finish.setOnClickListener(this); 66 btn_finish.setOnClickListener(this);
66 btn_bangding.setOnClickListener(this); 67 btn_bangding.setOnClickListener(this);
67 } 68 }
68 69
69 @Override 70 @Override
70 public void onClick(View v) { 71 public void onClick(View v) {
71 switch (v.getId()){ 72 switch (v.getId()){
72 case R.id.btn_finish: 73 case R.id.btn_finish:
73 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 74 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
74 long auserID = 0; 75 long auserID = 0;
75 try { 76 try {
76 auserID = Long.parseLong(userID); 77 auserID = Long.parseLong(userID);
77 } catch (NumberFormatException e) { 78 } catch (NumberFormatException e) {
78 e.printStackTrace(); 79 e.printStackTrace();
79 } 80 }
80 HttpManager.getInstance().subcardinfo(this,auserID,usename.getText().toString().trim(), 81 HttpManager.getInstance().subcardinfo(this,auserID,usename.getText().toString().trim(),
81 customer_address.getText().toString().trim(),shopadress.getText().toString().trim(), 82 customer_address.getText().toString().trim(),shopadress.getText().toString().trim(),
82 shoptime.getText().toString().trim(),tlePhone.getText().toString().trim(), 83 shoptime.getText().toString().trim(),tlePhone.getText().toString().trim(),
83 deviceModel.getText().toString().trim(),deviceNumber.getText().toString().trim(), 84 deviceModel.getText().toString().trim(),deviceNumber.getText().toString().trim(),
84 mac_adress.getText().toString().trim(),phone.getText().toString().trim()); 85 mac_adress.getText().toString().trim(),phone.getText().toString().trim());
85 break; 86 break;
86 case R.id.btn_bangding: 87 case R.id.btn_bangding:
87 Intent intent = new Intent(); 88 Intent intent = new Intent();
88 intent.setClass(ElectronicCardInfoOKActivity.this, BangDingCode.class); 89 intent.setClass(ElectronicCardInfoOKActivity.this, BangDingCode.class);
89 startActivity(intent); 90 startActivity(intent);
90 overridePendingTransition(R.anim.rightin, R.anim.rightout); 91 overridePendingTransition(R.anim.rightin, R.anim.rightout);
91 92
92 break; 93 break;
93 case R.id.cancel: 94 case R.id.cancel:
94 finish(); 95 finish();
95 break; 96 break;
96 } 97 }
97 } 98 }
98 99
99 100
100 } 101 }
101 102
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardLookInfoActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.os.Handler; 5 import android.os.Handler;
6 import android.os.Message; 6 import android.os.Message;
7 import android.support.v7.app.AppCompatActivity; 7 import android.support.v7.app.AppCompatActivity;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.ImageView; 9 import android.widget.ImageView;
10 import android.widget.TextView; 10 import android.widget.TextView;
11 11
12 import com.hjx.personalcenter.R; 12 import com.hjx.personalcenter.R;
13 import com.hjx.personalcenter.db.Content; 13 import com.hjx.personalcenter.db.Content;
14 import com.hjx.personalcenter.db.SaveParam; 14 import com.hjx.personalcenter.db.SaveParam;
15 import com.hjx.personalcenter.http.HttpCode; 15 import com.hjx.personalcenter.http.HttpCode;
16 import com.hjx.personalcenter.http.HttpManager; 16 import com.hjx.personalcenter.http.HttpManager;
17 import com.hjx.personalcenter.model.CardInfo; 17 import com.hjx.personalcenter.model.CardInfo;
18 import com.hjx.personalcenter.util.AlertUtils; 18 import com.hjx.personalcenter.util.AlertUtils;
19 19
20 import java.util.ArrayList; 20 import java.util.ArrayList;
21 21
22 /** 22 /**
23 * Created by h on 2017/8/11. 23 * Created by h on 2017/8/11.
24 */ 24 */
25 25
26 public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener { 26 public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener {
27 private ImageView iv_last_step; 27 private ImageView iv_last_step;
28 private TextView usename, deviceModel, customer_address, mac_adress, shoptime, deviceNumber, 28 private TextView usename, deviceModel, customer_address, mac_adress, shoptime, deviceNumber,
29 shopadress, phone, tlePhone, tv_card_adress_change, tv_card_phone_change; 29 shopadress, phone, tlePhone, tv_card_adress_change, tv_card_phone_change;
30 private ArrayList<CardInfo.DataBean> data = new ArrayList<>(); 30 private ArrayList<CardInfo.DataBean> data = new ArrayList<>();
31 31
32 Handler handler = new Handler() { 32 Handler handler = new Handler() {
33 @Override 33 @Override
34 public void handleMessage(Message msg) { 34 public void handleMessage(Message msg) {
35 super.handleMessage(msg); 35 super.handleMessage(msg);
36 switch (msg.what) { 36 switch (msg.what) {
37 37
38 case HttpCode.SUCHCARDINFO: 38 case HttpCode.SUCHCARDINFO:
39 CardInfo.DataBean cardinfoBean = (CardInfo.DataBean) msg.obj; 39 CardInfo.DataBean cardinfoBean = (CardInfo.DataBean) msg.obj;
40 if (cardinfoBean != null) { 40 if (cardinfoBean != null) {
41 //获取设备信息 41 //获取设备信息
42 deviceModel.setText(cardinfoBean.getProductModel()); 42 deviceModel.setText(cardinfoBean.getProductModel());
43 deviceNumber.setText(cardinfoBean.getDeviceNumber()); 43 deviceNumber.setText(cardinfoBean.getDeviceNumber());
44 mac_adress.setText(cardinfoBean.getMacAddress()); 44 mac_adress.setText(cardinfoBean.getMacAddress());
45 //获取保卡信息 45 //获取保卡信息
46 usename.setText(cardinfoBean.getCustomerName()); 46 usename.setText(cardinfoBean.getCustomerName());
47 customer_address.setText(cardinfoBean.getCustomerAddress()); 47 customer_address.setText(cardinfoBean.getCustomerAddress());
48 shoptime.setText(cardinfoBean.getBuyTime()); 48 shoptime.setText(cardinfoBean.getBuyTime());
49 shopadress.setText(cardinfoBean.getBuyAddress()); 49 shopadress.setText(cardinfoBean.getBuyAddress());
50 tlePhone.setText(cardinfoBean.getAlterSaleCall()); 50 tlePhone.setText(cardinfoBean.getAlterSaleCall());
51 phone.setText(cardinfoBean.getMobilePhone()); 51 phone.setText(cardinfoBean.getMobilePhone());
52 }else { 52 }else {
53 AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"您的机器还没有保卡信息,请重新登录"); 53 AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"您的机器还没有保卡信息,请重新登录");
54 } 54 }
55 55
56 break; 56 break;
57 57
58 } 58 }
59 59
60 } 60 }
61 }; 61 };
62 62
63 @Override 63 @Override
64 protected void onCreate(Bundle savedInstanceState) { 64 protected void onCreate(Bundle savedInstanceState) {
65 super.onCreate(savedInstanceState); 65 super.onCreate(savedInstanceState);
66 setContentView(R.layout.activity_electronic_look_cardinfo); 66 setContentView(R.layout.activity_electronic_look_cardinfo);
67 SysApplication.getInstance().addActivity(this);
67 initView(); 68 initView();
68 initData(); 69 initData();
69 initLister(); 70 initLister();
70 } 71 }
71 72
72 @Override 73 @Override
73 protected void onResume() { 74 protected void onResume() {
74 super.onResume(); 75 super.onResume();
75 String userID = SaveParam.getInstance().getLoginParam(this, "userId"); 76 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
76 try { 77 try {
77 Long a = Long.parseLong(userID); 78 Long a = Long.parseLong(userID);
78 HttpManager.getInstance().getcardinfo(this, a, handler); 79 HttpManager.getInstance().getcardinfo(this, a, handler);
79 } catch (NumberFormatException e) { 80 } catch (NumberFormatException e) {
80 e.printStackTrace(); 81 e.printStackTrace();
81 } 82 }
82 } 83 }
83 84
84 private void initView() { 85 private void initView() {
85 usename = (TextView) findViewById(R.id.iv_card_username); 86 usename = (TextView) findViewById(R.id.iv_card_username);
86 iv_last_step = (ImageView) findViewById(R.id.cancel); 87 iv_last_step = (ImageView) findViewById(R.id.cancel);
87 deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); 88 deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel);
88 customer_address = (TextView) findViewById(R.id.tv_card_adress); 89 customer_address = (TextView) findViewById(R.id.tv_card_adress);
89 mac_adress = (TextView) findViewById(R.id.tv_card_mac); 90 mac_adress = (TextView) findViewById(R.id.tv_card_mac);
90 shoptime = (TextView) findViewById(R.id.tv_card_time); 91 shoptime = (TextView) findViewById(R.id.tv_card_time);
91 deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber); 92 deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber);
92 shopadress = (TextView) findViewById(R.id.tv_card_shopAdress); 93 shopadress = (TextView) findViewById(R.id.tv_card_shopAdress);
93 phone = (TextView) findViewById(R.id.tv_card_phone); 94 phone = (TextView) findViewById(R.id.tv_card_phone);
94 tlePhone = (TextView) findViewById(R.id.tv_card_tleNember); 95 tlePhone = (TextView) findViewById(R.id.tv_card_tleNember);
95 tv_card_adress_change = (TextView) findViewById(R.id.tv_card_adress_change); 96 tv_card_adress_change = (TextView) findViewById(R.id.tv_card_adress_change);
96 tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change); 97 tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change);
97 } 98 }
98 99
99 private void initData() { 100 private void initData() {
100 101
101 // //获取设备信息 102 // //获取设备信息
102 // deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel()); 103 // deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel());
103 // deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber()); 104 // deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber());
104 // mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac()); 105 // mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac());
105 // //获取保卡信息 106 // //获取保卡信息
106 // usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME)); 107 // usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME));
107 // customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM)); 108 // customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM));
108 // shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME)); 109 // shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME));
109 // shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS)); 110 // shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS));
110 // tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE)); 111 // tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE));
111 // phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE)); 112 // phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE));
112 113
113 114
114 } 115 }
115 116
116 private void initLister() { 117 private void initLister() {
117 tv_card_adress_change.setOnClickListener(this); 118 tv_card_adress_change.setOnClickListener(this);
118 tv_card_phone_change.setOnClickListener(this); 119 tv_card_phone_change.setOnClickListener(this);
119 iv_last_step.setOnClickListener(this); 120 iv_last_step.setOnClickListener(this);
120 } 121 }
121 122
122 @Override 123 @Override
123 public void onClick(View v) { 124 public void onClick(View v) {
124 switch (v.getId()) { 125 switch (v.getId()) {
125 case R.id.tv_card_adress_change: 126 case R.id.tv_card_adress_change:
126 Intent intent = new Intent(); 127 Intent intent = new Intent();
127 intent.setClass(this, ChangeElectronicCardAdressInfoActivity.class); 128 intent.setClass(this, ChangeElectronicCardAdressInfoActivity.class);
128 startActivity(intent); 129 startActivity(intent);
129 overridePendingTransition(R.anim.rightin, R.anim.rightout); 130 overridePendingTransition(R.anim.rightin, R.anim.rightout);
130 131
131 break; 132 break;
132 case R.id.tv_card_phone_change: 133 case R.id.tv_card_phone_change:
133 Content.authcodeflag = 2; 134 Content.authcodeflag = 2;
134 Intent intent1 = new Intent(); 135 Intent intent1 = new Intent();
135 intent1.setClass(this, ElectronicCardValidationActivity.class); 136 intent1.setClass(this, ElectronicCardValidationActivity.class);
136 startActivity(intent1); 137 startActivity(intent1);
137 overridePendingTransition(R.anim.rightin, R.anim.rightout); 138 overridePendingTransition(R.anim.rightin, R.anim.rightout);
138 139
139 140
140 break; 141 break;
141 case R.id.cancel: 142 case R.id.cancel:
142 finish(); 143 finish();
143 break; 144 break;
144 } 145 }
145 } 146 }
146 147
147 } 148 }
148 149
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardValidationActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.os.Handler; 5 import android.os.Handler;
6 import android.os.Message; 6 import android.os.Message;
7 import android.support.v7.app.AppCompatActivity; 7 import android.support.v7.app.AppCompatActivity;
8 import android.text.TextUtils; 8 import android.text.TextUtils;
9 import android.view.View; 9 import android.view.View;
10 import android.widget.Button; 10 import android.widget.Button;
11 import android.widget.EditText; 11 import android.widget.EditText;
12 import android.widget.ImageView; 12 import android.widget.ImageView;
13 import android.widget.TextView; 13 import android.widget.TextView;
14 14
15 import com.hjx.personalcenter.R; 15 import com.hjx.personalcenter.R;
16 import com.hjx.personalcenter.db.Content; 16 import com.hjx.personalcenter.db.Content;
17 import com.hjx.personalcenter.db.SaveParam; 17 import com.hjx.personalcenter.db.SaveParam;
18 import com.hjx.personalcenter.http.HttpCode; 18 import com.hjx.personalcenter.http.HttpCode;
19 import com.hjx.personalcenter.http.HttpManager; 19 import com.hjx.personalcenter.http.HttpManager;
20 import com.hjx.personalcenter.util.AlertUtils; 20 import com.hjx.personalcenter.util.AlertUtils;
21 import com.hjx.personalcenter.util.PhoneNumCheckUtils; 21 import com.hjx.personalcenter.util.PhoneNumCheckUtils;
22 22
23 import org.json.JSONObject; 23 import org.json.JSONObject;
24 24
25 import java.util.TimerTask; 25 import java.util.TimerTask;
26 26
27 /** 27 /**
28 * Created by h on 2017/8/9. 28 * Created by h on 2017/8/9.
29 */ 29 */
30 30
31 public class ElectronicCardValidationActivity extends AppCompatActivity implements View.OnClickListener { 31 public class ElectronicCardValidationActivity extends AppCompatActivity implements View.OnClickListener {
32 private Button btn_card_valiyanzhen,get_authcode; 32 private Button btn_card_valiyanzhen,get_authcode;
33 private EditText phonenumber,anth_6num;//;//密码 33 private EditText phonenumber,anth_6num;//;//密码
34 private TextView menu_title; 34 private TextView menu_title;
35 private ImageView cancel; 35 private ImageView cancel;
36 private int delayTime=60; 36 private int delayTime=60;
37 private java.util.Timer Delaytimer; 37 private java.util.Timer Delaytimer;
38 private String sourceStr ="android"; 38 private String sourceStr ="android";
39 private String typeStr = "register"; 39 private String typeStr = "register";
40 String authcode = ""; 40 String authcode = "";
41 Handler handler = new Handler() { 41 Handler handler = new Handler() {
42 @Override 42 @Override
43 public void handleMessage(Message msg) { 43 public void handleMessage(Message msg) {
44 super.handleMessage(msg); 44 super.handleMessage(msg);
45 JSONObject jsonObject; 45 JSONObject jsonObject;
46 String status; 46 String status;
47 switch (msg.what) { 47 switch (msg.what) {
48 case HttpCode.AUTHCODE_SUCESS: 48 case HttpCode.AUTHCODE_SUCESS:
49 jsonObject = (JSONObject) msg.obj; 49 jsonObject = (JSONObject) msg.obj;
50 status = jsonObject.optString("status"); 50 status = jsonObject.optString("status");
51 authcode = jsonObject.optString("jsessionid"); 51 authcode = jsonObject.optString("jsessionid");
52 if (status.equals("100")) { 52 if (status.equals("100")) {
53 AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送成功"); 53 AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送成功");
54 } 54 }
55 55
56 break; 56 break;
57 case HttpCode.AUTHCODE_FAIL: 57 case HttpCode.AUTHCODE_FAIL:
58 AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送失败"); 58 AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送失败");
59 break; 59 break;
60 case 21: 60 case 21:
61 if(delayTime<=0){ 61 if(delayTime<=0){
62 if(Delaytimer!=null){ 62 if(Delaytimer!=null){
63 Delaytimer.cancel(); 63 Delaytimer.cancel();
64 } 64 }
65 get_authcode.setEnabled(true); 65 get_authcode.setEnabled(true);
66 get_authcode.setClickable(true); 66 get_authcode.setClickable(true);
67 get_authcode.setText("获取验证码"); 67 get_authcode.setText("获取验证码");
68 delayTime=60; 68 delayTime=60;
69 }else{ 69 }else{
70 get_authcode.setEnabled(false); 70 get_authcode.setEnabled(false);
71 get_authcode.setClickable(false); 71 get_authcode.setClickable(false);
72 get_authcode.setText(delayTime + " s"); 72 get_authcode.setText(delayTime + " s");
73 } 73 }
74 break; 74 break;
75 } 75 }
76 } 76 }
77 }; 77 };
78 @Override 78 @Override
79 protected void onCreate(Bundle savedInstanceState) { 79 protected void onCreate(Bundle savedInstanceState) {
80 super.onCreate(savedInstanceState); 80 super.onCreate(savedInstanceState);
81 setContentView(R.layout.activity_electroniccard_validation); 81 setContentView(R.layout.activity_electroniccard_validation);
82 SysApplication.getInstance().addActivity(this);
82 initView(); 83 initView();
83 initData(); 84 initData();
84 initLister(); 85 initLister();
85 } 86 }
86 87
87 private void initView() { 88 private void initView() {
88 btn_card_valiyanzhen = (Button) findViewById(R.id.btn_card_valiyanzhen); 89 btn_card_valiyanzhen = (Button) findViewById(R.id.btn_card_valiyanzhen);
89 get_authcode = (Button) findViewById(R.id.btn_authcode); 90 get_authcode = (Button) findViewById(R.id.btn_authcode);
90 anth_6num = (EditText) findViewById(R.id.et_authcode); 91 anth_6num = (EditText) findViewById(R.id.et_authcode);
91 phonenumber = (EditText) findViewById(R.id.et_phonenumber); 92 phonenumber = (EditText) findViewById(R.id.et_phonenumber);
92 menu_title = (TextView) findViewById(R.id.menu_title); 93 menu_title = (TextView) findViewById(R.id.menu_title);
93 cancel = (ImageView) findViewById(R.id.cancel); 94 cancel = (ImageView) findViewById(R.id.cancel);
94 } 95 }
95 96
96 private void initData() { 97 private void initData() {
97 if (Content.authcodeflag==1){ 98 if (Content.authcodeflag==1){
98 menu_title.setText("更换绑定"); 99 menu_title.setText("更换绑定");
99 btn_card_valiyanzhen.setText("确定"); 100 btn_card_valiyanzhen.setText("确定");
100 101
101 }else if (Content.authcodeflag==2){ 102 }else if (Content.authcodeflag==2){
102 menu_title.setText("修改保卡信息"); 103 menu_title.setText("修改保卡信息");
103 btn_card_valiyanzhen.setText("确定"); 104 btn_card_valiyanzhen.setText("确定");
104 105
105 }else { 106 }else {
106 menu_title.setText("填写保卡信息"); 107 menu_title.setText("填写保卡信息");
107 btn_card_valiyanzhen.setText("下一步"); 108 btn_card_valiyanzhen.setText("下一步");
108 } 109 }
109 110
110 111
111 112
112 } 113 }
113 114
114 private void initLister() { 115 private void initLister() {
115 get_authcode.setOnClickListener(this); 116 get_authcode.setOnClickListener(this);
116 btn_card_valiyanzhen.setOnClickListener(this); 117 btn_card_valiyanzhen.setOnClickListener(this);
117 cancel.setOnClickListener(this); 118 cancel.setOnClickListener(this);
118 119
119 } 120 }
120 121
121 @Override 122 @Override
122 public void onClick(View v) { 123 public void onClick(View v) {
123 switch (v.getId()){ 124 switch (v.getId()){
124 case R.id.btn_card_valiyanzhen: 125 case R.id.btn_card_valiyanzhen:
125 126
126 String usernameStr = phonenumber.getText().toString().trim(); 127 String usernameStr = phonenumber.getText().toString().trim();
127 String authcodeStr = anth_6num.getText().toString().trim(); 128 String authcodeStr = anth_6num.getText().toString().trim();
128 if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)) { 129 if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)) {
129 AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号,和验证码不能为空"); 130 AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号,和验证码不能为空");
130 return; 131 return;
131 } else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ 132 } else if (!PhoneNumCheckUtils.isPhone(usernameStr)){
132 AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号码输入错误"); 133 AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号码输入错误");
133 134
134 }else if (!authcode.equals(authcodeStr)){ 135 }else if (!authcode.equals(authcodeStr)){
135 AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确"); 136 AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确");
136 }else { 137 }else {
137 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 138 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
138 int auserID = 0; 139 int auserID = 0;
139 try { 140 try {
140 auserID = Integer.parseInt(userID); 141 auserID = Integer.parseInt(userID);
141 } catch (NumberFormatException e) { 142 } catch (NumberFormatException e) {
142 e.printStackTrace(); 143 e.printStackTrace();
143 } 144 }
144 if (Content.authcodeflag==1){ 145 if (Content.authcodeflag==1){
145 //修改账户手机号 146 //修改账户手机号
146 HttpManager.getInstance().changecardinfophone(this, 147 HttpManager.getInstance().changecardinfophone(this,
147 auserID,usernameStr,authcodeStr); 148 auserID,usernameStr,authcodeStr);
148 149
149 }else if (Content.authcodeflag==2){ 150 }else if (Content.authcodeflag==2){
150 //修改保卡手机号 151 //修改保卡手机号
151 HttpManager.getInstance().changecardinfophone(this, 152 HttpManager.getInstance().changecardinfophone(this,
152 auserID,usernameStr,authcodeStr); 153 auserID,usernameStr,authcodeStr);
153 }else { 154 }else {
154 String phone =phonenumber.getText().toString().trim(); 155 String phone =phonenumber.getText().toString().trim();
155 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phone ); 156 SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phone );
156 Intent intent = new Intent(); 157 Intent intent = new Intent();
157 intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); 158 intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class);
158 startActivity(intent); 159 startActivity(intent);
159 overridePendingTransition(R.anim.rightin, R.anim.rightout); 160 overridePendingTransition(R.anim.rightin, R.anim.rightout);
160 } 161 }
161 // SaveParam.getInstance().saveLoginParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim()); 162 // SaveParam.getInstance().saveLoginParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim());
162 // Intent intent = new Intent(); 163 // Intent intent = new Intent();
163 // intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); 164 // intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class);
164 // startActivity(intent); 165 // startActivity(intent);
165 // overridePendingTransition(R.anim.rightin, R.anim.rightout); 166 // overridePendingTransition(R.anim.rightin, R.anim.rightout);
166 } 167 }
167 break; 168 break;
168 case R.id.btn_authcode: 169 case R.id.btn_authcode:
169 String usernameStr1 = phonenumber.getText().toString().trim(); 170 String usernameStr1 = phonenumber.getText().toString().trim();
170 if (!PhoneNumCheckUtils.isPhone(usernameStr1)){ 171 if (!PhoneNumCheckUtils.isPhone(usernameStr1)){
171 AlertUtils.showToast(ElectronicCardValidationActivity.this, "请输入正确的手机号"); 172 AlertUtils.showToast(ElectronicCardValidationActivity.this, "请输入正确的手机号");
172 }else { 173 }else {
173 anth_6num.requestFocus(); 174 anth_6num.requestFocus();
174 HttpManager.getInstance().authCode(typeStr, usernameStr1, handler, ElectronicCardValidationActivity.this); 175 HttpManager.getInstance().authCode(typeStr, usernameStr1, handler, ElectronicCardValidationActivity.this);
175 valiDelay(); 176 valiDelay();
176 177
177 } 178 }
178 179
179 break; 180 break;
180 case R.id.cancel: 181 case R.id.cancel:
181 finish(); 182 finish();
182 break; 183 break;
183 } 184 }
184 } 185 }
185 // 线程类 定时器 186 // 线程类 定时器
186 public void valiDelay() { 187 public void valiDelay() {
187 188
188 Delaytimer = new java.util.Timer(true); 189 Delaytimer = new java.util.Timer(true);
189 190
190 191
191 TimerTask task = new TimerTask() { 192 TimerTask task = new TimerTask() {
192 public void run() { 193 public void run() {
193 //每次需要执行的代码放到这里面。 194 //每次需要执行的代码放到这里面。
194 delayTime--; 195 delayTime--;
195 handler.sendEmptyMessage(21); 196 handler.sendEmptyMessage(21);
196 } 197 }
197 }; 198 };
198 Delaytimer.schedule(task, 1000,1000); 199 Delaytimer.schedule(task, 1000,1000);
199 } 200 }
200 } 201 }
201 202
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.content.pm.PackageManager; 4 import android.content.pm.PackageManager;
5 import android.graphics.Color; 5 import android.graphics.Color;
6 import android.net.Uri; 6 import android.net.Uri;
7 import android.os.Build; 7 import android.os.Build;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.provider.MediaStore; 9 import android.provider.MediaStore;
10 import android.support.annotation.NonNull; 10 import android.support.annotation.NonNull;
11 import android.support.v4.content.FileProvider; 11 import android.support.v4.content.FileProvider;
12 import android.support.v7.app.AppCompatActivity; 12 import android.support.v7.app.AppCompatActivity;
13 import android.text.TextUtils; 13 import android.text.TextUtils;
14 import android.view.Gravity; 14 import android.view.Gravity;
15 import android.view.View; 15 import android.view.View;
16 import android.widget.AdapterView; 16 import android.widget.AdapterView;
17 import android.widget.EditText; 17 import android.widget.EditText;
18 import android.widget.ImageView; 18 import android.widget.ImageView;
19 import android.widget.TextView; 19 import android.widget.TextView;
20 import android.widget.Toast; 20 import android.widget.Toast;
21 21
22 import com.facebook.drawee.backends.pipeline.Fresco; 22 import com.facebook.drawee.backends.pipeline.Fresco;
23 import com.facebook.drawee.generic.GenericDraweeHierarchy; 23 import com.facebook.drawee.generic.GenericDraweeHierarchy;
24 import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; 24 import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
25 import com.facebook.drawee.generic.RoundingParams; 25 import com.facebook.drawee.generic.RoundingParams;
26 import com.facebook.drawee.interfaces.DraweeController; 26 import com.facebook.drawee.interfaces.DraweeController;
27 import com.facebook.drawee.view.SimpleDraweeView; 27 import com.facebook.drawee.view.SimpleDraweeView;
28 import com.hjx.personalcenter.R; 28 import com.hjx.personalcenter.R;
29 import com.hjx.personalcenter.db.SaveParam; 29 import com.hjx.personalcenter.db.SaveParam;
30 import com.hjx.personalcenter.http.HttpManager; 30 import com.hjx.personalcenter.http.HttpManager;
31 import com.hjx.personalcenter.util.AlertUtils; 31 import com.hjx.personalcenter.util.AlertUtils;
32 import com.hjx.personalcenter.util.CropUtils; 32 import com.hjx.personalcenter.util.CropUtils;
33 import com.hjx.personalcenter.util.DialogPermission; 33 import com.hjx.personalcenter.util.DialogPermission;
34 import com.hjx.personalcenter.util.FileUtil; 34 import com.hjx.personalcenter.util.FileUtil;
35 import com.hjx.personalcenter.util.PermissionUtil; 35 import com.hjx.personalcenter.util.PermissionUtil;
36 import com.hjx.personalcenter.util.SharedPreferenceMark; 36 import com.hjx.personalcenter.util.SharedPreferenceMark;
37 import com.mylhyl.circledialog.CircleDialog; 37 import com.mylhyl.circledialog.CircleDialog;
38 import com.mylhyl.circledialog.callback.ConfigButton; 38 import com.mylhyl.circledialog.callback.ConfigButton;
39 import com.mylhyl.circledialog.callback.ConfigDialog; 39 import com.mylhyl.circledialog.callback.ConfigDialog;
40 import com.mylhyl.circledialog.params.ButtonParams; 40 import com.mylhyl.circledialog.params.ButtonParams;
41 import com.mylhyl.circledialog.params.DialogParams; 41 import com.mylhyl.circledialog.params.DialogParams;
42 42
43 import java.io.File; 43 import java.io.File;
44 44
45 /** 45 /**
46 * Created by h on 2017/8/11. 46 * Created by h on 2017/8/11.
47 */ 47 */
48 48
49 public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener { 49 public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener {
50 private ImageView iv_cance, iv_show, iv_take; 50 private ImageView iv_cance, iv_show, iv_take;
51 private EditText content, phone; 51 private EditText content, phone;
52 private TextView tv_sub; 52 private TextView tv_sub;
53 private static final int REQUEST_CODE_TAKE_PHOTO = 1; 53 private static final int REQUEST_CODE_TAKE_PHOTO = 1;
54 private static final int REQUEST_CODE_ALBUM = 2; 54 private static final int REQUEST_CODE_ALBUM = 2;
55 private static final int REQUEST_CODE_CROUP_PHOTO = 3; 55 private static final int REQUEST_CODE_CROUP_PHOTO = 3;
56 SimpleDraweeView mSimpleDraweeView; 56 SimpleDraweeView mSimpleDraweeView;
57 String type = "个人中心"; 57 String type = "个人中心";
58 private File file; 58 private File file;
59 private Uri uri; 59 private Uri uri;
60 60
61 @Override 61 @Override
62 protected void onCreate(Bundle savedInstanceState) { 62 protected void onCreate(Bundle savedInstanceState) {
63 super.onCreate(savedInstanceState); 63 super.onCreate(savedInstanceState);
64 Fresco.initialize(this); 64 Fresco.initialize(this);
65 setContentView(R.layout.activity_feedback); 65 setContentView(R.layout.activity_feedback);
66 SysApplication.getInstance().addActivity(this);
66 initView(); 67 initView();
67 initData(); 68 initData();
68 initLister(); 69 initLister();
69 } 70 }
70 71
71 private void initView() { 72 private void initView() {
72 iv_cance = (ImageView) findViewById(R.id.cancel); 73 iv_cance = (ImageView) findViewById(R.id.cancel);
73 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv); 74 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv);
74 iv_take = (ImageView) findViewById(R.id.iv_take); 75 iv_take = (ImageView) findViewById(R.id.iv_take);
75 content = (EditText) findViewById(R.id.feedback_content); 76 content = (EditText) findViewById(R.id.feedback_content);
76 phone = (EditText) findViewById(R.id.feedback_phone); 77 phone = (EditText) findViewById(R.id.feedback_phone);
77 tv_sub = (TextView) findViewById(R.id.feedback_sub); 78 tv_sub = (TextView) findViewById(R.id.feedback_sub);
78 79
79 } 80 }
80 81
81 private void initData() { 82 private void initData() {
82 file = new File(FileUtil.getCachePath(this), "user-feedback.jpg"); 83 file = new File(FileUtil.getCachePath(this), "user-feedback.jpg");
83 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { 84 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
84 uri = Uri.fromFile(file); 85 uri = Uri.fromFile(file);
85 } else { 86 } else {
86 //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) 87 //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问)
87 uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); 88 uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file);
88 } 89 }
89 90
90 } 91 }
91 92
92 private void initLister() { 93 private void initLister() {
93 iv_cance.setOnClickListener(this); 94 iv_cance.setOnClickListener(this);
94 iv_take.setOnClickListener(this); 95 iv_take.setOnClickListener(this);
95 tv_sub.setOnClickListener(this); 96 tv_sub.setOnClickListener(this);
96 mSimpleDraweeView.setOnClickListener(this); 97 mSimpleDraweeView.setOnClickListener(this);
97 98
98 } 99 }
99 100
100 @Override 101 @Override
101 public void onClick(View v) { 102 public void onClick(View v) {
102 String contents = content.getText().toString().trim(); 103 String contents = content.getText().toString().trim();
103 String contants = phone.getText().toString().trim(); 104 String contants = phone.getText().toString().trim();
104 switch (v.getId()) { 105 switch (v.getId()) {
105 case R.id.cancel: 106 case R.id.cancel:
106 finish(); 107 finish();
107 break; 108 break;
108 case R.id.iv_take: 109 case R.id.iv_take:
109 choiceAvatar(); 110 choiceAvatar();
110 break; 111 break;
111 case R.id.feedback_sub: 112 case R.id.feedback_sub:
112 //提交用户反馈 113 //提交用户反馈
113 if (TextUtils.isEmpty(contents)) { 114 if (TextUtils.isEmpty(contents)) {
114 AlertUtils.showToast(FeedBackActivity.this, "请将必填项填写完整"); 115 AlertUtils.showToast(FeedBackActivity.this, "请将必填项填写完整");
115 return; 116 return;
116 } 117 }
117 String userID = SaveParam.getInstance().getLoginParam(this, "userId"); 118 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
118 try { 119 try {
119 HttpManager.getInstance().feedback(FeedBackActivity.this, userID, 120 HttpManager.getInstance().feedback(FeedBackActivity.this, userID,
120 contents,contants,file.getPath(),type); 121 contents,contants,file.getPath(),type);
121 } catch (Exception e) { 122 } catch (Exception e) {
122 e.printStackTrace(); 123 e.printStackTrace();
123 } 124 }
124 break; 125 break;
125 case R.id.show_iv: 126 case R.id.show_iv:
126 127
127 128
128 break; 129 break;
129 } 130 }
130 } 131 }
131 132
132 //拍摄头像 133 //拍摄头像
133 private void choiceAvatar() { 134 private void choiceAvatar() {
134 final String[] items = {"拍照", "从相册选择"}; 135 final String[] items = {"拍照", "从相册选择"};
135 new CircleDialog.Builder(this) 136 new CircleDialog.Builder(this)
136 .configDialog(new ConfigDialog() { 137 .configDialog(new ConfigDialog() {
137 @Override 138 @Override
138 public void onConfig(DialogParams params) { 139 public void onConfig(DialogParams params) {
139 //增加弹出动画 140 //增加弹出动画
140 params.gravity = Gravity.CENTER; 141 params.gravity = Gravity.CENTER;
141 } 142 }
142 }) 143 })
143 .setTitle("请选择图片来源") 144 .setTitle("请选择图片来源")
144 .setWidth(0.5f) 145 .setWidth(0.5f)
145 .setItems(items, new AdapterView.OnItemClickListener() { 146 .setItems(items, new AdapterView.OnItemClickListener() {
146 @Override 147 @Override
147 public void onItemClick(AdapterView<?> parent, View view, int 148 public void onItemClick(AdapterView<?> parent, View view, int
148 position, long id) { 149 position, long id) {
149 switch (position) { 150 switch (position) {
150 case 0: 151 case 0:
151 if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) { 152 if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) {
152 uploadAvatarFromPhotoRequest(); 153 uploadAvatarFromPhotoRequest();
153 } 154 }
154 break; 155 break;
155 case 1: 156 case 1:
156 uploadAvatarFromAlbumRequest(); 157 uploadAvatarFromAlbumRequest();
157 break; 158 break;
158 } 159 }
159 160
160 } 161 }
161 }) 162 })
162 .setNegative("取消", null) 163 .setNegative("取消", null)
163 .configNegative(new ConfigButton() { 164 .configNegative(new ConfigButton() {
164 @Override 165 @Override
165 public void onConfig(ButtonParams params) { 166 public void onConfig(ButtonParams params) {
166 //取消按钮字体颜色 167 //取消按钮字体颜色
167 params.textColor = Color.RED; 168 params.textColor = Color.RED;
168 } 169 }
169 }) 170 })
170 .show(); 171 .show();
171 172
172 173
173 } 174 }
174 175
175 //照相 176 //照相
176 private void uploadAvatarFromPhotoRequest() { 177 private void uploadAvatarFromPhotoRequest() {
177 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 178 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
178 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 179 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
179 intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); 180 intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
180 intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); 181 intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
181 startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); 182 startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO);
182 } 183 }
183 184
184 //选择图库 185 //选择图库
185 private void uploadAvatarFromAlbumRequest() { 186 private void uploadAvatarFromAlbumRequest() {
186 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); 187 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
187 photoPickerIntent.setType("image/*"); 188 photoPickerIntent.setType("image/*");
188 startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); 189 startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM);
189 } 190 }
190 191
191 //回掉 192 //回掉
192 @Override 193 @Override
193 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 194 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
194 super.onActivityResult(requestCode, resultCode, data); 195 super.onActivityResult(requestCode, resultCode, data);
195 if (resultCode != -1) { 196 if (resultCode != -1) {
196 return; 197 return;
197 } 198 }
198 if (requestCode == REQUEST_CODE_ALBUM && data != null) { 199 if (requestCode == REQUEST_CODE_ALBUM && data != null) {
199 Uri newUri; 200 Uri newUri;
200 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { 201 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
201 newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); 202 newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData()));
202 } else { 203 } else {
203 newUri = data.getData(); 204 newUri = data.getData();
204 } 205 }
205 if (newUri != null) { 206 if (newUri != null) {
206 uploadAvatarFromPhoto(); 207 uploadAvatarFromPhoto();
207 //裁剪图片 208 //裁剪图片
208 //startPhotoZoom(newUri); 209 //startPhotoZoom(newUri);
209 } else { 210 } else {
210 Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); 211 Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show();
211 } 212 }
212 } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { 213 } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) {
213 uploadAvatarFromPhoto(); 214 uploadAvatarFromPhoto();
214 } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { 215 } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) {
215 uploadAvatarFromPhoto(); 216 uploadAvatarFromPhoto();
216 } 217 }
217 } 218 }
218 219
219 private void uploadAvatarFromPhoto() { 220 private void uploadAvatarFromPhoto() {
220 compressAndUploadAvatar(file.getPath()); 221 compressAndUploadAvatar(file.getPath());
221 222
222 } 223 }
223 224
224 private void compressAndUploadAvatar(String fileSrc) { 225 private void compressAndUploadAvatar(String fileSrc) {
225 226
226 227
227 //上传到服务器 228 //上传到服务器
228 229
229 final File cover = FileUtil.getSmallBitmap(this, fileSrc); 230 final File cover = FileUtil.getSmallBitmap(this, fileSrc);
230 String mimeType = "image/*"; 231 String mimeType = "image/*";
231 //requestBody = RequestBody.create(MediaType.parse(mimeType), file); 232 //requestBody = RequestBody.create(MediaType.parse(mimeType), file);
232 //String fileName = cover.getName(); 233 //String fileName = cover.getName();
233 //HttpManager.getInstance().header(this, fileSrc); 234 //HttpManager.getInstance().header(this, fileSrc);
234 //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); 235 //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody);
235 //Fresco设置圆形头像 236 //Fresco设置圆形头像
236 GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); 237 GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
237 GenericDraweeHierarchy hierarchy = builder 238 GenericDraweeHierarchy hierarchy = builder
238 .setDesiredAspectRatio(1f) 239 .setDesiredAspectRatio(1f)
239 .setFailureImage(R.mipmap.blank) 240 .setFailureImage(R.mipmap.blank)
240 //圆形头像 241 //圆形头像
241 .setRoundingParams(RoundingParams.fromCornersRadius(0.7f)) 242 .setRoundingParams(RoundingParams.fromCornersRadius(0.7f))
242 .build(); 243 .build();
243 244
244 //加载本地图片 245 //加载本地图片
245 Uri uri = Uri.fromFile(cover); 246 Uri uri = Uri.fromFile(cover);
246 DraweeController controller = Fresco.newDraweeControllerBuilder() 247 DraweeController controller = Fresco.newDraweeControllerBuilder()
247 .setOldController(mSimpleDraweeView.getController()) 248 .setOldController(mSimpleDraweeView.getController())
248 .setUri(uri) 249 .setUri(uri)
249 .build(); 250 .build();
250 mSimpleDraweeView.setHierarchy(hierarchy); 251 mSimpleDraweeView.setHierarchy(hierarchy);
251 mSimpleDraweeView.setController(controller); 252 mSimpleDraweeView.setController(controller);
252 253
253 } 254 }
254 255
255 public void startPhotoZoom(Uri uri) { 256 public void startPhotoZoom(Uri uri) {
256 Intent intent = new Intent("com.android.camera.action.CROP"); 257 Intent intent = new Intent("com.android.camera.action.CROP");
257 intent.setDataAndType(uri, "image/*"); 258 intent.setDataAndType(uri, "image/*");
258 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 259 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
259 intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. 260 intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面.
260 intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. 261 intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例.
261 intent.putExtra("aspectY", 1);// x:y=1:1 262 intent.putExtra("aspectY", 1);// x:y=1:1
262 // intent.putExtra("outputX", 400);//图片输出大小 263 // intent.putExtra("outputX", 400);//图片输出大小
263 // intent.putExtra("outputY", 400); 264 // intent.putExtra("outputY", 400);
264 intent.putExtra("output", Uri.fromFile(file)); 265 intent.putExtra("output", Uri.fromFile(file));
265 intent.putExtra("outputFormat", "JPEG");// 返回格式 266 intent.putExtra("outputFormat", "JPEG");// 返回格式
266 startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); 267 startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO);
267 } 268 }
268 269
269 @Override 270 @Override
270 public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 271 public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
271 switch (requestCode) { 272 switch (requestCode) {
272 273
273 case PermissionUtil.REQUEST_SHOWCAMERA: 274 case PermissionUtil.REQUEST_SHOWCAMERA:
274 if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 275 if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
275 // Permission Granted 276 // Permission Granted
276 uploadAvatarFromPhotoRequest(); 277 uploadAvatarFromPhotoRequest();
277 278
278 } else { 279 } else {
279 if (!SharedPreferenceMark.getHasShowCamera()) { 280 if (!SharedPreferenceMark.getHasShowCamera()) {
280 SharedPreferenceMark.setHasShowCamera(true); 281 SharedPreferenceMark.setHasShowCamera(true);
281 new DialogPermission(this, "关闭摄像头权限影响扫描功能"); 282 new DialogPermission(this, "关闭摄像头权限影响扫描功能");
282 283
283 } else { 284 } else {
284 Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) 285 Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT)
285 .show(); 286 .show();
286 } 287 }
287 } 288 }
288 break; 289 break;
289 default: 290 default:
290 super.onRequestPermissionsResult(requestCode, permissions, grantResults); 291 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
291 } 292 }
292 } 293 }
293 } 294 }
294 295
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ForgotPasswordActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.os.Bundle; 3 import android.os.Bundle;
4 import android.os.Handler; 4 import android.os.Handler;
5 import android.os.Message; 5 import android.os.Message;
6 import android.support.v7.app.AppCompatActivity; 6 import android.support.v7.app.AppCompatActivity;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import android.text.method.HideReturnsTransformationMethod; 8 import android.text.method.HideReturnsTransformationMethod;
9 import android.text.method.PasswordTransformationMethod; 9 import android.text.method.PasswordTransformationMethod;
10 import android.view.View; 10 import android.view.View;
11 import android.widget.Button; 11 import android.widget.Button;
12 import android.widget.EditText; 12 import android.widget.EditText;
13 import android.widget.ImageView; 13 import android.widget.ImageView;
14 14
15 import com.hjx.personalcenter.R; 15 import com.hjx.personalcenter.R;
16 import com.hjx.personalcenter.http.HttpCode; 16 import com.hjx.personalcenter.http.HttpCode;
17 import com.hjx.personalcenter.http.HttpManager; 17 import com.hjx.personalcenter.http.HttpManager;
18 import com.hjx.personalcenter.util.AlertUtils; 18 import com.hjx.personalcenter.util.AlertUtils;
19 import com.hjx.personalcenter.util.Judgment; 19 import com.hjx.personalcenter.util.Judgment;
20 import com.hjx.personalcenter.util.PasswordCheckUtils; 20 import com.hjx.personalcenter.util.PasswordCheckUtils;
21 import com.hjx.personalcenter.util.PhoneNumCheckUtils; 21 import com.hjx.personalcenter.util.PhoneNumCheckUtils;
22 22
23 import org.json.JSONException; 23 import org.json.JSONException;
24 import org.json.JSONObject; 24 import org.json.JSONObject;
25 25
26 import java.util.TimerTask; 26 import java.util.TimerTask;
27 27
28 /** 28 /**
29 * 忘记密码 29 * 忘记密码
30 * Created by h on 2017/6/17. 30 * Created by h on 2017/6/17.
31 */ 31 */
32 32
33 public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener { 33 public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener {
34 private ImageView back_forgit, iv_pwd_change; 34 private ImageView back_forgit, iv_pwd_change;
35 private EditText forot_pwd_phone, forot_pwd_anthcode, forot_pwd_pwd, forot_pwd_pwd2; 35 private EditText forot_pwd_phone, forot_pwd_anthcode, forot_pwd_pwd, forot_pwd_pwd2;
36 private Button forot_pwd_sub, forot_pwd_getanthcode; 36 private Button forot_pwd_sub, forot_pwd_getanthcode;
37 private String forot_pwd_phone1; 37 private String forot_pwd_phone1;
38 private String forot_pwd_anthcode1; 38 private String forot_pwd_anthcode1;
39 private String forot_pwd_pwd3; 39 private String forot_pwd_pwd3;
40 private String forot_pwd_pwd4; 40 private String forot_pwd_pwd4;
41 private String typeStr = "login"; 41 private String typeStr = "login";
42 private int delayTime=60; 42 private int delayTime=60;
43 private java.util.Timer Delaytimer; 43 private java.util.Timer Delaytimer;
44 public static Boolean showPassword = false; 44 public static Boolean showPassword = false;
45 45
46 Handler handler = new Handler() { 46 Handler handler = new Handler() {
47 @Override 47 @Override
48 public void handleMessage(Message msg) { 48 public void handleMessage(Message msg) {
49 super.handleMessage(msg); 49 super.handleMessage(msg);
50 try { 50 try {
51 JSONObject jsonObject; 51 JSONObject jsonObject;
52 String status; 52 String status;
53 switch (msg.what) { 53 switch (msg.what) {
54 case HttpCode.PASSWORD_SUCESS: 54 case HttpCode.PASSWORD_SUCESS:
55 jsonObject = (JSONObject) msg.obj; 55 jsonObject = (JSONObject) msg.obj;
56 status = jsonObject.getString("status"); 56 status = jsonObject.getString("status");
57 // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); 57 // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message"));
58 if (status.equals("100")) { 58 if (status.equals("100")) {
59 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改成功"); 59 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改成功");
60 } 60 }
61 61
62 break; 62 break;
63 case HttpCode.PASSWORD_FAIL: 63 case HttpCode.PASSWORD_FAIL:
64 jsonObject = (JSONObject) msg.obj; 64 jsonObject = (JSONObject) msg.obj;
65 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。"); 65 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。");
66 break; 66 break;
67 case HttpCode.AUTHCODE_SUCESS1: 67 case HttpCode.AUTHCODE_SUCESS1:
68 jsonObject = (JSONObject) msg.obj; 68 jsonObject = (JSONObject) msg.obj;
69 status = jsonObject.optString("status"); 69 status = jsonObject.optString("status");
70 if (status.equals("100")) { 70 if (status.equals("100")) {
71 AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功"); 71 AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功");
72 } 72 }
73 //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); 73 //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message"));
74 break; 74 break;
75 case HttpCode.AUTHCODE_FAIL1: 75 case HttpCode.AUTHCODE_FAIL1:
76 jsonObject = (JSONObject) msg.obj; 76 jsonObject = (JSONObject) msg.obj;
77 AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络")); 77 AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络"));
78 break; 78 break;
79 case HttpCode.IS_REFISTER: 79 case HttpCode.IS_REFISTER:
80 jsonObject = (JSONObject) msg.obj; 80 jsonObject = (JSONObject) msg.obj;
81 status = jsonObject.getString("status"); 81 status = jsonObject.getString("status");
82 if (status.equals("true")) { 82 if (status.equals("true")) {
83 getauthcode(); 83 getauthcode();
84 84
85 } else { 85 } else {
86 AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册"); 86 AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册");
87 } 87 }
88 break; 88 break;
89 case 21: 89 case 21:
90 90
91 if(delayTime<=0){ 91 if(delayTime<=0){
92 if(Delaytimer!=null){ 92 if(Delaytimer!=null){
93 Delaytimer.cancel(); 93 Delaytimer.cancel();
94 } 94 }
95 forot_pwd_getanthcode.setEnabled(true); 95 forot_pwd_getanthcode.setEnabled(true);
96 forot_pwd_getanthcode.setClickable(true); 96 forot_pwd_getanthcode.setClickable(true);
97 forot_pwd_getanthcode.setText("获取验证码"); 97 forot_pwd_getanthcode.setText("获取验证码");
98 delayTime=60; 98 delayTime=60;
99 }else{ 99 }else{
100 forot_pwd_getanthcode.setEnabled(false); 100 forot_pwd_getanthcode.setEnabled(false);
101 forot_pwd_getanthcode.setClickable(false); 101 forot_pwd_getanthcode.setClickable(false);
102 forot_pwd_getanthcode.setText(delayTime + " s"); 102 forot_pwd_getanthcode.setText(delayTime + " s");
103 } 103 }
104 break; 104 break;
105 } 105 }
106 } catch (JSONException e) { 106 } catch (JSONException e) {
107 e.printStackTrace(); 107 e.printStackTrace();
108 } 108 }
109 } 109 }
110 }; 110 };
111 111
112 @Override 112 @Override
113 protected void onCreate(Bundle savedInstanceState) { 113 protected void onCreate(Bundle savedInstanceState) {
114 super.onCreate(savedInstanceState); 114 super.onCreate(savedInstanceState);
115 setContentView(R.layout.activity_forgetpsword); 115 setContentView(R.layout.activity_forgetpsword);
116 SysApplication.getInstance().addActivity(this);
116 initView(); 117 initView();
117 setLister(); 118 setLister();
118 } 119 }
119 120
120 //获取验证码 121 //获取验证码
121 private void getauthcode() { 122 private void getauthcode() {
122 forot_pwd_anthcode.requestFocus(); 123 forot_pwd_anthcode.requestFocus();
123 HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this); 124 HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this);
124 valiDelay(); 125 valiDelay();
125 126
126 } 127 }
127 128
128 private void initView() { 129 private void initView() {
129 forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber); 130 forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber);
130 forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode); 131 forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode);
131 forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword); 132 forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword);
132 forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword); 133 forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword);
133 forot_pwd_sub = (Button) findViewById(R.id.btn_ok); 134 forot_pwd_sub = (Button) findViewById(R.id.btn_ok);
134 forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode); 135 forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode);
135 iv_pwd_change = (ImageView) findViewById(R.id.iv_pwd_change); 136 iv_pwd_change = (ImageView) findViewById(R.id.iv_pwd_change);
136 back_forgit = (ImageView) findViewById(R.id.cancel); 137 back_forgit = (ImageView) findViewById(R.id.cancel);
137 } 138 }
138 139
139 private void setLister() { 140 private void setLister() {
140 iv_pwd_change.setOnClickListener(this); 141 iv_pwd_change.setOnClickListener(this);
141 back_forgit.setOnClickListener(this); 142 back_forgit.setOnClickListener(this);
142 forot_pwd_sub.setOnClickListener(this); 143 forot_pwd_sub.setOnClickListener(this);
143 forot_pwd_getanthcode.setOnClickListener(this); 144 forot_pwd_getanthcode.setOnClickListener(this);
144 145
145 } 146 }
146 147
147 148
148 @Override 149 @Override
149 public void onClick(View view) { 150 public void onClick(View view) {
150 switch (view.getId()) { 151 switch (view.getId()) {
151 case R.id.btn_ok: 152 case R.id.btn_ok:
152 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 153 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
153 forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim(); 154 forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim();
154 forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim(); 155 forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim();
155 forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim(); 156 forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim();
156 if (TextUtils.isEmpty(forot_pwd_phone1) || 157 if (TextUtils.isEmpty(forot_pwd_phone1) ||
157 TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)) { 158 TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)) {
158 AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整"); 159 AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整");
159 return; 160 return;
160 } else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)) { 161 } else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)) {
161 AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误"); 162 AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误");
162 163
163 } else if (forot_pwd_pwd3.length() < 8 || forot_pwd_pwd4.length() < 8) { 164 } else if (forot_pwd_pwd3.length() < 8 || forot_pwd_pwd4.length() < 8) {
164 AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位"); 165 AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位");
165 } else if (!forot_pwd_pwd3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER) || !forot_pwd_pwd4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)) { 166 } else if (!forot_pwd_pwd3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER) || !forot_pwd_pwd4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)) {
166 AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成"); 167 AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成");
167 } else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)) { 168 } else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)) {
168 AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致"); 169 AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致");
169 return; 170 return;
170 } else { 171 } else {
171 //忘记密码接口 172 //忘记密码接口
172 HttpManager.getInstance().forgetpassword(this, forot_pwd_phone1, forot_pwd_pwd3, forot_pwd_anthcode1, handler); 173 HttpManager.getInstance().forgetpassword(this, forot_pwd_phone1, forot_pwd_pwd3, forot_pwd_anthcode1, handler);
173 } 174 }
174 break; 175 break;
175 case R.id.btn_authcode: 176 case R.id.btn_authcode:
176 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 177 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
177 if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)) { 178 if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)) {
178 AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号"); 179 AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号");
179 } else { 180 } else {
180 forot_pwd_anthcode.requestFocus(); 181 forot_pwd_anthcode.requestFocus();
181 ifregister(); 182 ifregister();
182 183
183 } 184 }
184 185
185 break; 186 break;
186 case R.id.iv_pwd_change: 187 case R.id.iv_pwd_change:
187 if (showPassword) {//显示密码 188 if (showPassword) {//显示密码
188 showPassword = !showPassword; 189 showPassword = !showPassword;
189 iv_pwd_change.setImageResource(R.mipmap.pwd_open); 190 iv_pwd_change.setImageResource(R.mipmap.pwd_open);
190 forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); 191 forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
191 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); 192 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length());
192 } else {//隐藏密码 193 } else {//隐藏密码
193 showPassword = !showPassword; 194 showPassword = !showPassword;
194 iv_pwd_change.setImageResource(R.mipmap.pwd_hide); 195 iv_pwd_change.setImageResource(R.mipmap.pwd_hide);
195 forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); 196 forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
196 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); 197 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length());
197 } 198 }
198 break; 199 break;
199 200
200 case R.id.cancel: 201 case R.id.cancel:
201 finish(); 202 finish();
202 break; 203 break;
203 } 204 }
204 } 205 }
205 206
206 //是否注册 207 //是否注册
207 private void ifregister() { 208 private void ifregister() {
208 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 209 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
209 HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this); 210 HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this);
210 } 211 }
211 212
212 // 线程类 定时器 213 // 线程类 定时器
213 public void valiDelay() { 214 public void valiDelay() {
214 215
215 Delaytimer = new java.util.Timer(true); 216 Delaytimer = new java.util.Timer(true);
216 217
217 218
218 TimerTask task = new TimerTask() { 219 TimerTask task = new TimerTask() {
219 public void run() { 220 public void run() {
220 //每次需要执行的代码放到这里面。 221 //每次需要执行的代码放到这里面。
221 delayTime--; 222 delayTime--;
222 handler.sendEmptyMessage(21); 223 handler.sendEmptyMessage(21);
223 } 224 }
224 }; 225 };
225 Delaytimer.schedule(task, 1000,1000); 226 Delaytimer.schedule(task, 1000,1000);
226 } 227 }
227 } 228 }
228 229
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/LoginAndRegisterActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.provider.Settings; 5 import android.provider.Settings;
6 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
7 import android.support.v4.app.Fragment; 7 import android.support.v4.app.Fragment;
8 import android.support.v4.view.ViewPager; 8 import android.support.v4.view.ViewPager;
9 import android.support.v7.app.AppCompatActivity; 9 import android.support.v7.app.AppCompatActivity;
10 import android.view.Gravity; 10 import android.view.Gravity;
11 import android.view.View; 11 import android.view.View;
12 12
13 import com.hjx.personalcenter.R; 13 import com.hjx.personalcenter.R;
14 import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; 14 import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter;
15 import com.hjx.personalcenter.db.SaveParam; 15 import com.hjx.personalcenter.db.SaveParam;
16 import com.hjx.personalcenter.fragment.LoginFragment; 16 import com.hjx.personalcenter.fragment.LoginFragment;
17 import com.hjx.personalcenter.fragment.RegisterFragment; 17 import com.hjx.personalcenter.fragment.RegisterFragment;
18 import com.hjx.personalcenter.thirdparty.SlidingTabLayout; 18 import com.hjx.personalcenter.thirdparty.SlidingTabLayout;
19 import com.hjx.personalcenter.util.NetUtils; 19 import com.hjx.personalcenter.util.NetUtils;
20 import com.mylhyl.circledialog.CircleDialog; 20 import com.mylhyl.circledialog.CircleDialog;
21 import com.mylhyl.circledialog.callback.ConfigText; 21 import com.mylhyl.circledialog.callback.ConfigText;
22 import com.mylhyl.circledialog.params.TextParams; 22 import com.mylhyl.circledialog.params.TextParams;
23 23
24 import java.util.ArrayList; 24 import java.util.ArrayList;
25 import java.util.Arrays; 25 import java.util.Arrays;
26 import java.util.List; 26 import java.util.List;
27 27
28 /** 28 /**
29 * 登录和注册 熊巍 29 * 登录和注册 熊巍
30 * Created by h on 2017/8/8. 30 * Created by h on 2017/8/8.
31 */ 31 */
32 32
33 public class LoginAndRegisterActivity extends AppCompatActivity { 33 public class LoginAndRegisterActivity extends AppCompatActivity {
34 private ViewPager viewPager; 34 private ViewPager viewPager;
35 private SlidingTabLayout tableLayout; 35 private SlidingTabLayout tableLayout;
36 private List<Fragment> loginlist; 36 private List<Fragment> loginlist;
37 private LoginAndRegisterAdapter logindapter; 37 private LoginAndRegisterAdapter logindapter;
38 private List<String> title = Arrays.asList("登录", "注册"); 38 private List<String> title = Arrays.asList("登录", "注册");
39 39
40 @Override 40 @Override
41 protected void onCreate(@Nullable Bundle savedInstanceState) { 41 protected void onCreate(@Nullable Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState); 42 super.onCreate(savedInstanceState);
43 //检查网络 43 //检查网络
44 boolean isconnect = NetUtils.isNetworkConnected(this); 44 boolean isconnect = NetUtils.isNetworkConnected(this);
45 if (!isconnect){ 45 if (!isconnect){
46 new CircleDialog.Builder(this) 46 new CircleDialog.Builder(this)
47 .setCanceledOnTouchOutside(false) 47 .setCanceledOnTouchOutside(false)
48 .setCancelable(false) 48 .setCancelable(false)
49 .setWidth(0.5f) 49 .setWidth(0.5f)
50 .configText(new ConfigText() { 50 .configText(new ConfigText() {
51 @Override 51 @Override
52 public void onConfig(TextParams params) { 52 public void onConfig(TextParams params) {
53 params.gravity = Gravity.CENTER; 53 params.gravity = Gravity.CENTER;
54 params.padding = new int[]{50, 50, 50, 50}; 54 params.padding = new int[]{50, 50, 50, 50};
55 } 55 }
56 }) 56 })
57 .setText("当前无网络,请检查网络设置") 57 .setText("当前无网络,请检查网络设置")
58 .setNegative("继续使用", null) 58 .setNegative("继续使用", null)
59 .setPositive("设置网络", new View.OnClickListener() { 59 .setPositive("设置网络", new View.OnClickListener() {
60 @Override 60 @Override
61 public void onClick(View v) { 61 public void onClick(View v) {
62 Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 62 Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面
63 startActivity(intent); 63 startActivity(intent);
64 } 64 }
65 }) 65 })
66 .show(); 66 .show();
67 } 67 }
68 String islogin =SaveParam.getInstance().getLoginParam(this,"login"); 68 String islogin =SaveParam.getInstance().getLoginParam(this,"login");
69 String type =SaveParam.getInstance().getCustomizeParam(LoginAndRegisterActivity.this,SaveParam.ACCOUNT); 69 String type =SaveParam.getInstance().getCustomizeParam(LoginAndRegisterActivity.this,SaveParam.ACCOUNT);
70 if (type==null){ 70 if (type==null){
71 SaveParam.getInstance().saveCustomizeParam(LoginAndRegisterActivity.this, SaveParam.ACCOUNT,"1"); 71 SaveParam.getInstance().saveCustomizeParam(LoginAndRegisterActivity.this, SaveParam.ACCOUNT,"1");
72 } 72 }
73 if ("true".equals(islogin)){ 73 if ("true".equals(islogin)){
74 Intent intent = new Intent(); 74 Intent intent = new Intent();
75 intent.setClass(this,MainActivity.class); 75 intent.setClass(this,MainActivity.class);
76 startActivity(intent); 76 startActivity(intent);
77 overridePendingTransition(R.anim.rightin, R.anim.rightout); 77 overridePendingTransition(R.anim.rightin, R.anim.rightout);
78 finish(); 78 finish();
79 79
80 } 80 }
81 setContentView(R.layout.activity_loginandregister); 81 setContentView(R.layout.activity_loginandregister);
82 SysApplication.getInstance().addActivity(this);
82 initView(); 83 initView();
83 initData(); 84 initData();
84 setLister(); 85 setLister();
85 } 86 }
86 87
87 private void initView() { 88 private void initView() {
88 viewPager = (ViewPager) findViewById(R.id.viewpager_login); 89 viewPager = (ViewPager) findViewById(R.id.viewpager_login);
89 tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); 90 tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id);
90 } 91 }
91 92
92 private void initData() { 93 private void initData() {
93 loginlist = new ArrayList<>(); 94 loginlist = new ArrayList<>();
94 for (int i = 0; i < title.size(); i++) { 95 for (int i = 0; i < title.size(); i++) {
95 if (title.get(i).equals("登录")) { 96 if (title.get(i).equals("登录")) {
96 loginlist.add(LoginFragment.newInstance(i + 1)); 97 loginlist.add(LoginFragment.newInstance(i + 1));
97 } else { 98 } else {
98 loginlist.add(RegisterFragment.newInstance(i + 1)); 99 loginlist.add(RegisterFragment.newInstance(i + 1));
99 } 100 }
100 } 101 }
101 102
102 103
103 //设置Tab上的标题 104 //设置Tab上的标题
104 tableLayout.setData(title); 105 tableLayout.setData(title);
105 //设置关联的ViewPager 106 //设置关联的ViewPager
106 tableLayout.setViewPager(viewPager, 0); 107 tableLayout.setViewPager(viewPager, 0);
107 logindapter = new LoginAndRegisterAdapter(loginlist, getSupportFragmentManager()); 108 logindapter = new LoginAndRegisterAdapter(loginlist, getSupportFragmentManager());
108 //给ViewPager设置适配器 109 //给ViewPager设置适配器
109 viewPager.setAdapter(logindapter); 110 viewPager.setAdapter(logindapter);
110 //设置滑动时数据不丢失 111 //设置滑动时数据不丢失
111 viewPager.setOffscreenPageLimit(1); 112 viewPager.setOffscreenPageLimit(1);
112 //将TabLayout和ViewPager关联起来。 113 //将TabLayout和ViewPager关联起来。
113 } 114 }
114 115
115 private void setLister() { 116 private void setLister() {
116 117
117 } 118 }
118 119
119 120
120 } 121 }
121 122
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.content.Intent; 4 import android.content.Intent;
5 import android.content.pm.PackageManager; 5 import android.content.pm.PackageManager;
6 import android.net.Uri; 6 import android.net.Uri;
7 import android.os.Build; 7 import android.os.Build;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.Message; 10 import android.os.Message;
11 import android.provider.MediaStore; 11 import android.provider.MediaStore;
12 import android.support.annotation.NonNull; 12 import android.support.annotation.NonNull;
13 import android.support.v4.content.FileProvider; 13 import android.support.v4.content.FileProvider;
14 import android.support.v7.app.AppCompatActivity; 14 import android.support.v7.app.AppCompatActivity;
15 import android.support.v7.widget.LinearLayoutManager; 15 import android.support.v7.widget.LinearLayoutManager;
16 import android.support.v7.widget.RecyclerView; 16 import android.support.v7.widget.RecyclerView;
17 import android.view.KeyEvent; 17 import android.view.KeyEvent;
18 import android.view.View; 18 import android.view.View;
19 import android.widget.ImageView; 19 import android.widget.ImageView;
20 import android.widget.LinearLayout; 20 import android.widget.LinearLayout;
21 import android.widget.TextView; 21 import android.widget.TextView;
22 import android.widget.Toast; 22 import android.widget.Toast;
23 23
24 import com.facebook.drawee.backends.pipeline.Fresco; 24 import com.facebook.drawee.backends.pipeline.Fresco;
25 import com.facebook.drawee.generic.GenericDraweeHierarchy; 25 import com.facebook.drawee.generic.GenericDraweeHierarchy;
26 import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; 26 import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
27 import com.facebook.drawee.generic.RoundingParams; 27 import com.facebook.drawee.generic.RoundingParams;
28 import com.facebook.drawee.interfaces.DraweeController; 28 import com.facebook.drawee.interfaces.DraweeController;
29 import com.facebook.drawee.view.SimpleDraweeView; 29 import com.facebook.drawee.view.SimpleDraweeView;
30 import com.hjx.personalcenter.R; 30 import com.hjx.personalcenter.R;
31 import com.hjx.personalcenter.adapter.GalleryAdapter; 31 import com.hjx.personalcenter.adapter.GalleryAdapter;
32 import com.hjx.personalcenter.adapter.VideoAdapter; 32 import com.hjx.personalcenter.adapter.VideoAdapter;
33 import com.hjx.personalcenter.customdialog.HeadDialog; 33 import com.hjx.personalcenter.customdialog.HeadDialog;
34 import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; 34 import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem;
35 import com.hjx.personalcenter.db.SaveParam; 35 import com.hjx.personalcenter.db.SaveParam;
36 import com.hjx.personalcenter.http.HttpCode; 36 import com.hjx.personalcenter.http.HttpCode;
37 import com.hjx.personalcenter.http.HttpManager; 37 import com.hjx.personalcenter.http.HttpManager;
38 import com.hjx.personalcenter.interfaces.DialogCallBack; 38 import com.hjx.personalcenter.interfaces.DialogCallBack;
39 import com.hjx.personalcenter.model.DefautPublishInfo; 39 import com.hjx.personalcenter.model.DefautPublishInfo;
40 import com.hjx.personalcenter.model.PesonalInfo; 40 import com.hjx.personalcenter.model.PesonalInfo;
41 import com.hjx.personalcenter.model.SignInfo; 41 import com.hjx.personalcenter.model.SignInfo;
42 import com.hjx.personalcenter.model.VideoInfo; 42 import com.hjx.personalcenter.model.VideoInfo;
43 import com.hjx.personalcenter.update.UpdateChecker; 43 import com.hjx.personalcenter.update.UpdateChecker;
44 import com.hjx.personalcenter.util.AlertUtils; 44 import com.hjx.personalcenter.util.AlertUtils;
45 import com.hjx.personalcenter.util.CropUtils; 45 import com.hjx.personalcenter.util.CropUtils;
46 import com.hjx.personalcenter.util.DialogPermission; 46 import com.hjx.personalcenter.util.DialogPermission;
47 import com.hjx.personalcenter.util.FileUtil; 47 import com.hjx.personalcenter.util.FileUtil;
48 import com.hjx.personalcenter.util.PermissionUtil; 48 import com.hjx.personalcenter.util.PermissionUtil;
49 import com.hjx.personalcenter.util.SharedPreferenceMark; 49 import com.hjx.personalcenter.util.SharedPreferenceMark;
50 import com.mylhyl.circledialog.CircleDialog; 50 import com.mylhyl.circledialog.CircleDialog;
51 import com.mylhyl.circledialog.callback.ConfigInput; 51 import com.mylhyl.circledialog.callback.ConfigInput;
52 import com.mylhyl.circledialog.params.InputParams; 52 import com.mylhyl.circledialog.params.InputParams;
53 import com.mylhyl.circledialog.view.listener.OnInputClickListener; 53 import com.mylhyl.circledialog.view.listener.OnInputClickListener;
54 import com.zaaach.toprightmenu.MenuItem; 54 import com.zaaach.toprightmenu.MenuItem;
55 import com.zaaach.toprightmenu.TopRightMenu; 55 import com.zaaach.toprightmenu.TopRightMenu;
56 56
57 import java.io.File; 57 import java.io.File;
58 import java.io.UnsupportedEncodingException; 58 import java.io.UnsupportedEncodingException;
59 import java.util.ArrayList; 59 import java.util.ArrayList;
60 import java.util.List; 60 import java.util.List;
61 61
62 public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { 62 public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView {
63 private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; 63 private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex;
64 private TextView tv_edit_presoninfo, tv_sign, 64 private TextView tv_edit_presoninfo, tv_sign,
65 tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, 65 tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday,
66 tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; 66 tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender;
67 private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; 67 private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass;
68 private TopRightMenu mTopRightMenu; 68 private TopRightMenu mTopRightMenu;
69 //水平滑动 69 //水平滑动
70 private RecyclerView mRecyclerView; 70 private RecyclerView mRecyclerView;
71 private RecyclerView mRecyclerViewpublish; 71 private RecyclerView mRecyclerViewpublish;
72 private VideoAdapter RecyclerViewadapter; 72 private VideoAdapter RecyclerViewadapter;
73 private GalleryAdapter RecyclerViewadapterpublish; 73 private GalleryAdapter RecyclerViewadapterpublish;
74 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); 74 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>();
75 75
76 private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); 76 private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>();
77 private boolean showIcon = true; 77 private boolean showIcon = true;
78 private boolean dimBg = true; 78 private boolean dimBg = true;
79 private boolean needAnim = true; 79 private boolean needAnim = true;
80 private static final int REQUEST_CODE_TAKE_PHOTO = 1; 80 private static final int REQUEST_CODE_TAKE_PHOTO = 1;
81 private static final int REQUEST_CODE_ALBUM = 2; 81 private static final int REQUEST_CODE_ALBUM = 2;
82 private static final int REQUEST_CODE_CROUP_PHOTO = 3; 82 private static final int REQUEST_CODE_CROUP_PHOTO = 3;
83 SimpleDraweeView mSimpleDraweeView; 83 SimpleDraweeView mSimpleDraweeView;
84 private File file; 84 private File file;
85 private Uri uri; 85 private Uri uri;
86 Handler handler = new Handler(){ 86 Handler handler = new Handler(){
87 @Override 87 @Override
88 public void handleMessage(Message msg) { 88 public void handleMessage(Message msg) {
89 super.handleMessage(msg); 89 super.handleMessage(msg);
90 switch (msg.what){ 90 switch (msg.what){
91 case HttpCode.GETINFO: 91 case HttpCode.GETINFO:
92 PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj; 92 PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj;
93 tv_username.setText(cardinfoBean.getNickName()); 93 tv_username.setText(cardinfoBean.getNickName());
94 tv_username1.setText(cardinfoBean.getNickName()); 94 tv_username1.setText(cardinfoBean.getNickName());
95 tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); 95 tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName());
96 tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); 96 tv_useinfo_birthday.setText(cardinfoBean.getBirthday());
97 tv_useinfo_qq.setText(cardinfoBean.getQq()); 97 tv_useinfo_qq.setText(cardinfoBean.getQq());
98 tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); 98 tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName());
99 tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); 99 tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName());
100 String sex = cardinfoBean.getGender(); 100 String sex = cardinfoBean.getGender();
101 if ("0".equals(sex)){ 101 if ("0".equals(sex)){
102 tv_sex.setText("男"); 102 tv_sex.setText("男");
103 iv_sex.setImageResource(R.mipmap.men); 103 iv_sex.setImageResource(R.mipmap.men);
104 }else { 104 }else {
105 tv_sex.setText("女"); 105 tv_sex.setText("女");
106 iv_sex.setImageResource(R.mipmap.women); 106 iv_sex.setImageResource(R.mipmap.women);
107 } 107 }
108 mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); 108 mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait());
109 String graderID =cardinfoBean.getGrade().getGradeId();
110 String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId");
111 SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.GRADENS, ""+graderID);
112 try {
113 long auserID = Long.parseLong(userID);
114 int graderIDs =Integer.parseInt(graderID);
115 //获取版本信息
116 HttpManager.getInstance().getpublishinfo(MainActivity.this,auserID,graderIDs,handler);
117
118 } catch (NumberFormatException e) {
119 e.printStackTrace();
120 }
121
109 break; 122 break;
110 case HttpCode.SIGN: 123 case HttpCode.SIGN:
111 SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; 124 SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj;
112 if (dataBean.getSignature()==null){ 125 if (dataBean.getSignature()==null){
113 tv_sign.setText("你还未设置个性签名"); 126 tv_sign.setText("你还未设置个性签名");
114 }else { 127 }else {
115 tv_sign.setText(dataBean.getSignature()); 128 tv_sign.setText(dataBean.getSignature());
116 } 129 }
117 130
118 break; 131 break;
119 case HttpCode.PUBLISH_SUCESS: 132 case HttpCode.PUBLISH_SUCESS:
120 defautPublishInfos.clear(); 133 defautPublishInfos.clear();
121 defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj); 134 defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj);
122 RecyclerViewadapterpublish.notifyDataSetChanged(); 135 RecyclerViewadapterpublish.notifyDataSetChanged();
123 break; 136 break;
124 case HttpCode.GETVIDIO_SUCESS: 137 case HttpCode.GETVIDIO_SUCESS:
125 videoinfo.clear(); 138 videoinfo.clear();
126 videoinfo.addAll( (List<VideoInfo.DataBean>)msg.obj); 139 videoinfo.addAll( (List<VideoInfo.DataBean>)msg.obj);
127 RecyclerViewadapter.notifyDataSetChanged(); 140 RecyclerViewadapter.notifyDataSetChanged();
128 break; 141 break;
129 } 142 }
130 } 143 }
131 }; 144 };
132 145
133 @Override 146 @Override
134 protected void onCreate(Bundle savedInstanceState) { 147 protected void onCreate(Bundle savedInstanceState) {
135 super.onCreate(savedInstanceState); 148 super.onCreate(savedInstanceState);
136 Fresco.initialize(this); 149 Fresco.initialize(this);
137 setContentView(R.layout.activity_main); 150 setContentView(R.layout.activity_main);
151 SysApplication.getInstance().addActivity(this);
138 initView(); 152 initView();
139 initData(); 153 initData();
140 initLister(); 154 initLister();
141 updateVersion(); 155 updateVersion();
142 // String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); 156 // String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
143 // Log.e("test","......."+devicenumber); 157 // Log.e("test","......."+devicenumber);
144 } 158 }
145 //////版本更新 159 //////版本更新
146 private void updateVersion() { 160 private void updateVersion() {
147 UpdateChecker updateChecker = new UpdateChecker(this); 161 UpdateChecker updateChecker = new UpdateChecker(this);
148 updateChecker.checkForUpdates(); 162 updateChecker.checkForUpdates();
149 163
150 164
151 } 165 }
152 166
153 private void initView() { 167 private void initView() {
154 iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); 168 iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan);
155 iv_look_card = (ImageView) findViewById(R.id.iv_look_card); 169 iv_look_card = (ImageView) findViewById(R.id.iv_look_card);
156 tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); 170 tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo);
157 iv_setting = (ImageView) findViewById(R.id.iv_setting); 171 iv_setting = (ImageView) findViewById(R.id.iv_setting);
158 iv_sign = (ImageView) findViewById(R.id.iv_sign); 172 iv_sign = (ImageView) findViewById(R.id.iv_sign);
159 tv_sign = (TextView) findViewById(R.id.tv_sign); 173 tv_sign = (TextView) findViewById(R.id.tv_sign);
160 //头像 174 //头像
161 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); 175 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head);
162 //初始化个人信息 176 //初始化个人信息
163 iv_sex = (ImageView) findViewById(R.id.iv_sex); 177 iv_sex = (ImageView) findViewById(R.id.iv_sex);
164 tv_username = (TextView) findViewById(R.id.tv_username); 178 tv_username = (TextView) findViewById(R.id.tv_username);
165 tv_username1 = (TextView) findViewById(R.id.tv_username1); 179 tv_username1 = (TextView) findViewById(R.id.tv_username1);
166 tv_mygad = (TextView) findViewById(R.id.tv_mygad); 180 tv_mygad = (TextView) findViewById(R.id.tv_mygad);
167 tv_sex = (TextView) findViewById(R.id.tv_sex); 181 tv_sex = (TextView) findViewById(R.id.tv_sex);
168 tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); 182 tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress);
169 tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); 183 tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday);
170 tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); 184 tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq);
171 tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); 185 tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school);
172 tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); 186 tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender);
173 //跳转其他应用 187 //跳转其他应用
174 linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); 188 linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti);
175 linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); 189 linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote);
176 linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); 190 linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege);
177 linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); 191 linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass);
178 // 192 //
179 mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); 193 mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal);
180 mRecyclerViewpublish =(RecyclerView) findViewById(R.id.id_recyclerview_pubish); 194 mRecyclerViewpublish =(RecyclerView) findViewById(R.id.id_recyclerview_pubish);
181 195
182 } 196 }
183 197
184 198
185 private void initData() { 199 private void initData() {
186 //设置布局管理器 200 //设置布局管理器
187 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); 201 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
188 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); 202 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
189 203
190 LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); 204 LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this);
191 linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); 205 linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL);
192 206
193 mRecyclerView.setLayoutManager(linearLayoutManager); 207 mRecyclerView.setLayoutManager(linearLayoutManager);
194 mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); 208 mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10));
195 209
196 mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); 210 mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish);
197 mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); 211 mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10));
198 212
199 //设置视频适配器 213 //设置视频适配器
200 RecyclerViewadapter = new VideoAdapter(this,videoinfo); 214 RecyclerViewadapter = new VideoAdapter(this,videoinfo);
201 RecyclerViewadapterpublish= new GalleryAdapter(this,defautPublishInfos); 215 RecyclerViewadapterpublish= new GalleryAdapter(this,defautPublishInfos);
202 216
203 //版本信息适配器 217 //版本信息适配器
204 mRecyclerView.setAdapter(RecyclerViewadapter); 218 mRecyclerView.setAdapter(RecyclerViewadapter);
205 mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); 219 mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish);
206
207 //加载个人信息
208 String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION);
209 if (xiongzuo==null){
210 tv_mygad.setText("");
211 }else {
212 tv_mygad.setText(xiongzuo);
213 }
214 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 220 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
215
216 //获取个性签名 221 //获取个性签名
217 String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); 222 String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT);
218 try { 223 try {
219 long auserID = Long.parseLong(userID); 224 long auserID = Long.parseLong(userID);
220 int typeaccount1=Integer.parseInt(typeaccount); 225 int typeaccount1=Integer.parseInt(typeaccount);
221 HttpManager.getInstance().getsignatures(MainActivity.this,auserID,typeaccount1,handler); 226 HttpManager.getInstance().getsignatures(MainActivity.this,auserID,typeaccount1,handler);
222 227
223 } catch (NumberFormatException e) { 228 } catch (NumberFormatException e) {
224 e.printStackTrace(); 229 e.printStackTrace();
225 } 230 }
226 231
227
228
229 //初始化图片 232 //初始化图片
230 file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); 233 file = new File(FileUtil.getCachePath(this), "user-avatar.jpg");
231 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { 234 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
232 uri = Uri.fromFile(file); 235 uri = Uri.fromFile(file);
233 } else { 236 } else {
234 //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) 237 //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问)
235 uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); 238 uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file);
236 } 239 }
237 240
238 } 241 }
239 242
240 private void initLister() { 243 private void initLister() {
241 iv_imformatioan.setOnClickListener(this); 244 iv_imformatioan.setOnClickListener(this);
242 iv_look_card.setOnClickListener(this); 245 iv_look_card.setOnClickListener(this);
243 tv_edit_presoninfo.setOnClickListener(this); 246 tv_edit_presoninfo.setOnClickListener(this);
244 iv_setting.setOnClickListener(this); 247 iv_setting.setOnClickListener(this);
245 iv_sign.setOnClickListener(this); 248 iv_sign.setOnClickListener(this);
246 mSimpleDraweeView.setOnClickListener(this); 249 mSimpleDraweeView.setOnClickListener(this);
247 linel_mycuoti.setOnClickListener(this); 250 linel_mycuoti.setOnClickListener(this);
248 linel_mynote.setOnClickListener(this); 251 linel_mynote.setOnClickListener(this);
249 linel_mycollege.setOnClickListener(this); 252 linel_mycollege.setOnClickListener(this);
250 linel_myclass.setOnClickListener(this); 253 linel_myclass.setOnClickListener(this);
251 254
252 } 255 }
253 256
254 @Override 257 @Override
255 public void onClick(View v) { 258 public void onClick(View v) {
256 switch (v.getId()) { 259 switch (v.getId()) {
257 case R.id.iv_imformatioan: 260 case R.id.iv_imformatioan:
258 Intent intent = new Intent(); 261 Intent intent = new Intent();
259 intent.setClass(MainActivity.this, FeedBackActivity.class); 262 intent.setClass(MainActivity.this, FeedBackActivity.class);
260 startActivity(intent); 263 startActivity(intent);
261 overridePendingTransition(R.anim.rightin, R.anim.rightout); 264 overridePendingTransition(R.anim.rightin, R.anim.rightout);
262 break; 265 break;
263 case R.id.iv_look_card: 266 case R.id.iv_look_card:
264 Intent lookintent = new Intent(); 267 Intent lookintent = new Intent();
265 lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); 268 lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class);
266 startActivity(lookintent); 269 startActivity(lookintent);
267 overridePendingTransition(R.anim.rightin, R.anim.rightout); 270 overridePendingTransition(R.anim.rightin, R.anim.rightout);
268 break; 271 break;
269 case R.id.tv_edit_presoninfo: 272 case R.id.tv_edit_presoninfo:
270 Intent editintent = new Intent(); 273 Intent editintent = new Intent();
271 editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); 274 editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class);
272 startActivity(editintent); 275 startActivity(editintent);
273 overridePendingTransition(R.anim.rightin, R.anim.rightout); 276 overridePendingTransition(R.anim.rightin, R.anim.rightout);
274 break; 277 break;
275 case R.id.iv_head: 278 case R.id.iv_head:
276 HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); 279 HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog");
277 break; 280 break;
278 case R.id.iv_setting: 281 case R.id.iv_setting:
279 mTopRightMenu = new TopRightMenu(MainActivity.this); 282 mTopRightMenu = new TopRightMenu(MainActivity.this);
280 List<MenuItem> menuItems = new ArrayList<>(); 283 List<MenuItem> menuItems = new ArrayList<>();
281 menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); 284 menuItems.add(new MenuItem(R.mipmap.blank, "切换账户"));
282 menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); 285 menuItems.add(new MenuItem(R.mipmap.blank, "账户管理"));
283 mTopRightMenu 286 mTopRightMenu
284 .setHeight(150) //默认高度480 287 .setHeight(150) //默认高度480
285 .setWidth(320) //默认宽度wrap_content 288 .setWidth(320) //默认宽度wrap_content
286 .showIcon(showIcon) //显示菜单图标,默认为true 289 .showIcon(showIcon) //显示菜单图标,默认为true
287 .dimBackground(dimBg) //背景变暗,默认为true 290 .dimBackground(dimBg) //背景变暗,默认为true
288 .needAnimationStyle(needAnim) //显示动画,默认为true 291 .needAnimationStyle(needAnim) //显示动画,默认为true
289 .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE 292 .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE
290 .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { 293 .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() {
291 @Override 294 @Override
292 public void onMenuItemClick(int position) { 295 public void onMenuItemClick(int position) {
293 switch (position) { 296 switch (position) {
294 case 0: 297 case 0:
295 //清除数据 298 //清除数据
296 SaveParam.getInstance().clearData(MainActivity.this); 299 SaveParam.getInstance().clearData(MainActivity.this);
297 Intent settingintent = new Intent(); 300 Intent settingintent = new Intent();
298 settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); 301 settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class);
299 startActivity(settingintent); 302 startActivity(settingintent);
300 overridePendingTransition(R.anim.rightin, R.anim.rightout); 303 overridePendingTransition(R.anim.rightin, R.anim.rightout);
301 finish(); 304 finish();
302 break; 305 break;
303 case 1: 306 case 1:
304 Intent accontMintent = new Intent(); 307 Intent accontMintent = new Intent();
305 accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); 308 accontMintent.setClass(MainActivity.this, AccountManagementActivity.class);
306 startActivity(accontMintent); 309 startActivity(accontMintent);
307 overridePendingTransition(R.anim.rightin, R.anim.rightout); 310 overridePendingTransition(R.anim.rightin, R.anim.rightout);
308 break; 311 break;
309 } 312 }
310 } 313 }
311 }) 314 })
312 .addMenuList(menuItems) 315 .addMenuList(menuItems)
313 .showAsDropDown(iv_setting, -250, 0); 316 .showAsDropDown(iv_setting, -250, 0);
314 break; 317 break;
315 case R.id.iv_sign: 318 case R.id.iv_sign:
316 new CircleDialog.Builder(this) 319 new CircleDialog.Builder(this)
317 .setCanceledOnTouchOutside(false) 320 .setCanceledOnTouchOutside(false)
318 .setCancelable(true) 321 .setCancelable(true)
319 .setTitle("个性签名") 322 .setTitle("个性签名")
320 .setInputHint("请输入个性签名") 323 .setInputHint("请输入个性签名")
321 .setWidth(0.5f) 324 .setWidth(0.5f)
322 .configInput(new ConfigInput() { 325 .configInput(new ConfigInput() {
323 @Override 326 @Override
324 public void onConfig(InputParams params) { 327 public void onConfig(InputParams params) {
325 // params.inputBackgroundResourceId = R.drawable.bg_input; 328 // params.inputBackgroundResourceId = R.drawable.bg_input;
326 } 329 }
327 }) 330 })
328 .setNegative("取消", null) 331 .setNegative("取消", null)
329 .setPositiveInput("确定", new OnInputClickListener() { 332 .setPositiveInput("确定", new OnInputClickListener() {
330 @Override 333 @Override
331 public void onClick(String text, View v) { 334 public void onClick(String text, View v) {
332 if (text.equals("")) { 335 if (text.equals("")) {
333 AlertUtils.showToast(MainActivity.this, "请输入个性签名"); 336 AlertUtils.showToast(MainActivity.this, "请输入个性签名");
334 } else { 337 } else {
335 try { 338 try {
336 String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.ACCOUNT); 339 String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.ACCOUNT);
337 String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); 340 String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId");
338 long auserID = Long.parseLong(userID); 341 long auserID = Long.parseLong(userID);
339 int typeaccount1=Integer.parseInt(typeaccount); 342 int typeaccount1=Integer.parseInt(typeaccount);
340 HttpManager.getInstance().changsignature(MainActivity.this,auserID,typeaccount1,text); 343 HttpManager.getInstance().changsignature(MainActivity.this,auserID,typeaccount1,text);
341 } catch (NumberFormatException e) { 344 } catch (NumberFormatException e) {
342 e.printStackTrace(); 345 e.printStackTrace();
343 } 346 }
344 347
345 tv_sign.setText(text); 348 tv_sign.setText(text);
346 } 349 }
347 350
348 } 351 }
349 }) 352 })
350 .show(); 353 .show();
351 break; 354 break;
352 case R.id.linel_mycuoti: 355 case R.id.linel_mycuoti:
353 AlertUtils.showToast(this, "hhahahah "); 356 AlertUtils.showToast(this, "hhahahah ");
354 break; 357 break;
355 case R.id.linel_mynote: 358 case R.id.linel_mynote:
356 AlertUtils.showToast(this, "hhahahah "); 359 AlertUtils.showToast(this, "hhahahah ");
357 break; 360 break;
358 case R.id.linel_mycollege: 361 case R.id.linel_mycollege:
359 AlertUtils.showToast(this, "hhahahah "); 362 AlertUtils.showToast(this, "hhahahah ");
360 break; 363 break;
361 case R.id.linel_myclass: 364 case R.id.linel_myclass:
362 AlertUtils.showToast(this, "hhahahah "); 365 AlertUtils.showToast(this, "hhahahah ");
363 break; 366 break;
364 } 367 }
365 368
366 } 369 }
367 370
368 @Override 371 @Override
369 protected void onResume() { 372 protected void onResume() {
370 super.onResume(); 373 super.onResume();
371 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 374 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
372 String graderid = SaveParam.getInstance().getCustomizeParam(this,SaveParam.GRADENS);
373 //子账户年级id
374 String graderidchilds = SaveParam.getInstance().getCustomizeParam(this,SaveParam.CHILDSGRADENS);
375 //账户类型 375 //账户类型
376 String accounts = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); 376 String accounts = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT);
377 //加载个人信息
378 String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION);
379 if (xiongzuo==null){
380 tv_mygad.setText("");
381 }else {
382 tv_mygad.setText(xiongzuo);
383 }
377 try { 384 try {
378 int graderID; 385 int graderID;
379 long auserID = Long.parseLong(userID); 386 long auserID = Long.parseLong(userID);
380 int typeaccount1=Integer.parseInt(accounts); 387 int typeaccount1=Integer.parseInt(accounts);
381 if ("2".equals(accounts)){
382 graderID = Integer.parseInt(graderidchilds);
383 }else {
384 graderID = Integer.parseInt(graderid);
385 }
386 //获取个人信息
387 HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,typeaccount1,handler);
388 //获取版本信息
389 HttpManager.getInstance().getpublishinfo(this,auserID,graderID,handler);
390 //获取最近播放视频 388 //获取最近播放视频
391 HttpManager.getInstance().getstuyvidioinfo(this,auserID,handler); 389 HttpManager.getInstance().getstuyvidioinfo(this,auserID,handler);
390 //获取个人信息
391 HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,typeaccount1,handler);
392
393
392 394
393 } catch (NumberFormatException e) { 395 } catch (NumberFormatException e) {
394 e.printStackTrace(); 396 e.printStackTrace();
395 } 397 }
396 398
397 } 399 }
398 400
399 //回调头像监听 401 //回调头像监听
400 @Override 402 @Override
401 public void heard(Context context, View v,int headpitiaon) { 403 public void heard(Context context, View v,int headpitiaon) {
402 String picUrl = ""; 404 String picUrl = "";
403 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 405 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
404 String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); 406 String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT);
405 switch (v.getId()){ 407 switch (v.getId()){
406 //选择默认图片 408 //选择默认图片
407 case R.id.oktakephone: 409 case R.id.oktakephone:
408 if (headpitiaon==1){ 410 if (headpitiaon==1){
409 mSimpleDraweeView.setImageDrawable(null); 411 mSimpleDraweeView.setImageDrawable(null);
410 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); 412 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1);
411 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; 413 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png";
412 try { 414 try {
413 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); 415 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl);
414 } catch (UnsupportedEncodingException e) { 416 } catch (UnsupportedEncodingException e) {
415 e.printStackTrace(); 417 e.printStackTrace();
416 } 418 }
417 }else if (headpitiaon==2){ 419 }else if (headpitiaon==2){
418 mSimpleDraweeView.setImageDrawable(null); 420 mSimpleDraweeView.setImageDrawable(null);
419 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); 421 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2);
420 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; 422 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png";
421 try { 423 try {
422 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); 424 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl);
423 } catch (UnsupportedEncodingException e) { 425 } catch (UnsupportedEncodingException e) {
424 e.printStackTrace(); 426 e.printStackTrace();
425 } 427 }
426 }else if (headpitiaon==3){ 428 }else if (headpitiaon==3){
427 mSimpleDraweeView.setImageDrawable(null); 429 mSimpleDraweeView.setImageDrawable(null);
428 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); 430 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3);
429 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; 431 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png";
430 try { 432 try {
431 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); 433 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl);
432 } catch (UnsupportedEncodingException e) { 434 } catch (UnsupportedEncodingException e) {
433 e.printStackTrace(); 435 e.printStackTrace();
434 } 436 }
435 }else if (headpitiaon==4){ 437 }else if (headpitiaon==4){
436 mSimpleDraweeView.setImageDrawable(null); 438 mSimpleDraweeView.setImageDrawable(null);
437 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); 439 mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4);
438 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png"; 440 picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png";
439 try { 441 try {
440 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); 442 HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl);
441 } catch (UnsupportedEncodingException e) { 443 } catch (UnsupportedEncodingException e) {
442 e.printStackTrace(); 444 e.printStackTrace();
443 } 445 }
444 }else{ 446 }else{
445 mSimpleDraweeView.setImageDrawable(null); 447 mSimpleDraweeView.setImageDrawable(null);
446 mSimpleDraweeView.setImageResource(R.mipmap.header_default);; 448 mSimpleDraweeView.setImageResource(R.mipmap.header_default);;
447 } 449 }
448 450
449 break; 451 break;
450 case R.id.canceltakephone: 452 case R.id.canceltakephone:
451 453
452 break; 454 break;
453 //拍摄和相册 455 //拍摄和相册
454 case R.id.take_pic: 456 case R.id.take_pic:
455 if (PermissionUtil.hasCameraPermission(MainActivity.this)) { 457 if (PermissionUtil.hasCameraPermission(MainActivity.this)) {
456 uploadAvatarFromPhotoRequest(); 458 uploadAvatarFromPhotoRequest();
457 } 459 }
458 460
459 break; 461 break;
460 case R.id.xiangce: 462 case R.id.xiangce:
461 uploadAvatarFromAlbumRequest(); 463 uploadAvatarFromAlbumRequest();
462 break; 464 break;
463 465
464 } 466 }
465 467
466 } 468 }
467 469
468 //照相 470 //照相
469 private void uploadAvatarFromPhotoRequest() { 471 private void uploadAvatarFromPhotoRequest() {
470 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 472 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
471 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 473 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
472 intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); 474 intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
473 intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); 475 intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
474 startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); 476 startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO);
475 } 477 }
476 478
477 //选择图库 479 //选择图库
478 private void uploadAvatarFromAlbumRequest() { 480 private void uploadAvatarFromAlbumRequest() {
479 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); 481 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
480 photoPickerIntent.setType("image/*"); 482 photoPickerIntent.setType("image/*");
481 startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); 483 startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM);
482 } 484 }
483 //回掉 485 //回掉
484 @Override 486 @Override
485 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 487 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
486 super.onActivityResult(requestCode, resultCode, data); 488 super.onActivityResult(requestCode, resultCode, data);
487 if (resultCode != -1) { 489 if (resultCode != -1) {
488 return; 490 return;
489 } 491 }
490 if (requestCode == REQUEST_CODE_ALBUM && data != null) { 492 if (requestCode == REQUEST_CODE_ALBUM && data != null) {
491 Uri newUri; 493 Uri newUri;
492 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { 494 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
493 newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); 495 newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData()));
494 } else { 496 } else {
495 newUri = data.getData(); 497 newUri = data.getData();
496 } 498 }
497 if (newUri != null) { 499 if (newUri != null) {
498 startPhotoZoom(newUri); 500 startPhotoZoom(newUri);
499 } else { 501 } else {
500 Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); 502 Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show();
501 } 503 }
502 } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { 504 } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) {
503 startPhotoZoom(uri); 505 startPhotoZoom(uri);
504 } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { 506 } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) {
505 uploadAvatarFromPhoto(); 507 uploadAvatarFromPhoto();
506 } 508 }
507 } 509 }
508 510
509 private void uploadAvatarFromPhoto() { 511 private void uploadAvatarFromPhoto() {
510 compressAndUploadAvatar(file.getPath()); 512 compressAndUploadAvatar(file.getPath());
511 513
512 } 514 }
513 private void compressAndUploadAvatar(String fileSrc) { 515 private void compressAndUploadAvatar(String fileSrc) {
514 516
515 517
516 //上传到服务器 518 //上传到服务器
517 519
518 final File cover = FileUtil.getSmallBitmap(this, fileSrc); 520 final File cover = FileUtil.getSmallBitmap(this, fileSrc);
519 String mimeType = "image/*"; 521 String mimeType = "image/*";
520 //requestBody = RequestBody.create(MediaType.parse(mimeType), file); 522 //requestBody = RequestBody.create(MediaType.parse(mimeType), file);
521 //String fileName = cover.getName(); 523 //String fileName = cover.getName();
522 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 524 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
523 String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); 525 String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT);
524 526
525 //上传头像 527 //上传头像
526 528
527 try { 529 try {
528 HttpManager.getInstance().header(this, userID,typeaccount,file.getPath()); 530 HttpManager.getInstance().header(this, userID,typeaccount,file.getPath());
529 } catch (UnsupportedEncodingException e) { 531 } catch (UnsupportedEncodingException e) {
530 e.printStackTrace(); 532 e.printStackTrace();
531 } 533 }
532 534
533 //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); 535 //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody);
534 //Fresco设置圆形头像 536 //Fresco设置圆形头像
535 GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); 537 GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
536 GenericDraweeHierarchy hierarchy = builder 538 GenericDraweeHierarchy hierarchy = builder
537 .setDesiredAspectRatio(1f) 539 .setDesiredAspectRatio(1f)
538 .setFailureImage(R.mipmap.blank) 540 .setFailureImage(R.mipmap.blank)
539 //圆形头像 541 //圆形头像
540 .setRoundingParams(RoundingParams.asCircle()) 542 .setRoundingParams(RoundingParams.asCircle())
541 .build(); 543 .build();
542 544
543 //加载本地图片 545 //加载本地图片
544 Uri uri = Uri.fromFile(cover); 546 Uri uri = Uri.fromFile(cover);
545 DraweeController controller = Fresco.newDraweeControllerBuilder() 547 DraweeController controller = Fresco.newDraweeControllerBuilder()
546 .setOldController(mSimpleDraweeView.getController()) 548 .setOldController(mSimpleDraweeView.getController())
547 .setUri(uri) 549 .setUri(uri)
548 .build(); 550 .build();
549 mSimpleDraweeView.setHierarchy(hierarchy); 551 mSimpleDraweeView.setHierarchy(hierarchy);
550 mSimpleDraweeView.setController(controller); 552 mSimpleDraweeView.setController(controller);
551 553
552 } 554 }
553 555
554 public void startPhotoZoom(Uri uri) { 556 public void startPhotoZoom(Uri uri) {
555 Intent intent = new Intent("com.android.camera.action.CROP"); 557 Intent intent = new Intent("com.android.camera.action.CROP");
556 intent.setDataAndType(uri, "image/*"); 558 intent.setDataAndType(uri, "image/*");
557 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 559 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
558 intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. 560 intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面.
559 intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. 561 intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例.
560 intent.putExtra("aspectY", 1);// x:y=1:1 562 intent.putExtra("aspectY", 1);// x:y=1:1
561 // intent.putExtra("outputX", 400);//图片输出大小 563 // intent.putExtra("outputX", 400);//图片输出大小
562 // intent.putExtra("outputY", 400); 564 // intent.putExtra("outputY", 400);
563 intent.putExtra("output", Uri.fromFile(file)); 565 intent.putExtra("output", Uri.fromFile(file));
564 intent.putExtra("outputFormat", "JPEG");// 返回格式 566 intent.putExtra("outputFormat", "JPEG");// 返回格式
565 startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); 567 startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO);
566 } 568 }
567 569
568 @Override 570 @Override
569 public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 571 public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
570 switch (requestCode) { 572 switch (requestCode) {
571 573
572 case PermissionUtil.REQUEST_SHOWCAMERA: 574 case PermissionUtil.REQUEST_SHOWCAMERA:
573 if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 575 if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
574 // Permission Granted 576 // Permission Granted
575 uploadAvatarFromPhotoRequest(); 577 uploadAvatarFromPhotoRequest();
576 578
577 } else { 579 } else {
578 if (!SharedPreferenceMark.getHasShowCamera()) { 580 if (!SharedPreferenceMark.getHasShowCamera()) {
579 SharedPreferenceMark.setHasShowCamera(true); 581 SharedPreferenceMark.setHasShowCamera(true);
580 new DialogPermission(this, "关闭摄像头权限影响扫描功能"); 582 new DialogPermission(this, "关闭摄像头权限影响扫描功能");
581 583
582 } else { 584 } else {
583 Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) 585 Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT)
584 .show(); 586 .show();
585 } 587 }
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity; 5 import android.support.v7.app.AppCompatActivity;
6 import android.text.TextUtils; 6 import android.text.TextUtils;
7 import android.view.KeyEvent; 7 import android.view.KeyEvent;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.Button; 9 import android.widget.Button;
10 import android.widget.EditText; 10 import android.widget.EditText;
11 import android.widget.TextView; 11 import android.widget.TextView;
12 12
13 import com.hjx.personalcenter.R; 13 import com.hjx.personalcenter.R;
14 import com.hjx.personalcenter.customdialog.CitysListDialog; 14 import com.hjx.personalcenter.customdialog.CitysListDialog;
15 import com.hjx.personalcenter.customdialog.CountryDialog; 15 import com.hjx.personalcenter.customdialog.CountryDialog;
16 import com.hjx.personalcenter.customdialog.GradeListDialog; 16 import com.hjx.personalcenter.customdialog.GradeListDialog;
17 import com.hjx.personalcenter.customdialog.ProvinceListDialog; 17 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
18 import com.hjx.personalcenter.customdialog.SchoolListDialog; 18 import com.hjx.personalcenter.customdialog.SchoolListDialog;
19 import com.hjx.personalcenter.db.Content; 19 import com.hjx.personalcenter.db.Content;
20 import com.hjx.personalcenter.db.SaveParam; 20 import com.hjx.personalcenter.db.SaveParam;
21 import com.hjx.personalcenter.http.HttpManager; 21 import com.hjx.personalcenter.http.HttpManager;
22 import com.hjx.personalcenter.interfaces.DialogCallBack; 22 import com.hjx.personalcenter.interfaces.DialogCallBack;
23 import com.hjx.personalcenter.model.CityInfo; 23 import com.hjx.personalcenter.model.CityInfo;
24 import com.hjx.personalcenter.model.CountyInfo; 24 import com.hjx.personalcenter.model.CountyInfo;
25 import com.hjx.personalcenter.model.GradeInfo; 25 import com.hjx.personalcenter.model.GradeInfo;
26 import com.hjx.personalcenter.model.ProvinceInfo; 26 import com.hjx.personalcenter.model.ProvinceInfo;
27 import com.hjx.personalcenter.model.SchoolInfo; 27 import com.hjx.personalcenter.model.SchoolInfo;
28 import com.hjx.personalcenter.util.AlertUtils; 28 import com.hjx.personalcenter.util.AlertUtils;
29 import com.hjx.personalcenter.util.GetDevicesUtil; 29 import com.hjx.personalcenter.util.GetDevicesUtil;
30 30
31 import java.util.ArrayList; 31 import java.util.ArrayList;
32 32
33 /** 33 /**
34 * 填写注册信息 熊巍 34 * 填写注册信息 熊巍
35 * Created by h on 2017/8/9. 35 * Created by h on 2017/8/9.
36 */ 36 */
37 37
38 public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack 38 public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack
39 , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { 39 , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack {
40 private EditText et_username; 40 private EditText et_username;
41 private TextView et_region, et_grade, et_school; 41 private TextView et_region, et_grade, et_school;
42 private Button btn_ok; 42 private Button btn_ok;
43 43
44 @Override 44 @Override
45 protected void onCreate(Bundle savedInstanceState) { 45 protected void onCreate(Bundle savedInstanceState) {
46 super.onCreate(savedInstanceState); 46 super.onCreate(savedInstanceState);
47 setContentView(R.layout.activity_registerinfo); 47 setContentView(R.layout.activity_registerinfo);
48 SysApplication.getInstance().addActivity(this);
49
48 initView(); 50 initView();
49 initData(); 51 initData();
50 initLister(); 52 initLister();
51 } 53 }
52 54
53 private void initView() { 55 private void initView() {
54 et_username = (EditText) findViewById(R.id.et_username); 56 et_username = (EditText) findViewById(R.id.et_username);
55 et_region = (TextView) findViewById(R.id.et_region); 57 et_region = (TextView) findViewById(R.id.et_region);
56 et_grade = (TextView) findViewById(R.id.et_grade); 58 et_grade = (TextView) findViewById(R.id.et_grade);
57 et_school = (TextView) findViewById(R.id.et_school); 59 et_school = (TextView) findViewById(R.id.et_school);
58 btn_ok = (Button) findViewById(R.id.btn_ok); 60 btn_ok = (Button) findViewById(R.id.btn_ok);
59 61
60 62
61 } 63 }
62 64
63 private void initData() { 65 private void initData() {
64 if (Content.accountflag == 2) { 66 if (Content.accountflag == 2) {
65 btn_ok.setText("提交"); 67 btn_ok.setText("提交");
66 68
67 } 69 }
68 70
69 } 71 }
70 72
71 private void initLister() { 73 private void initLister() {
72 et_region.setOnClickListener(this); 74 et_region.setOnClickListener(this);
73 et_grade.setOnClickListener(this); 75 et_grade.setOnClickListener(this);
74 et_school.setOnClickListener(this); 76 et_school.setOnClickListener(this);
75 btn_ok.setOnClickListener(this); 77 btn_ok.setOnClickListener(this);
76 78
77 79
78 } 80 }
79 81
80 @Override 82 @Override
81 public void onClick(View v) { 83 public void onClick(View v) {
82 String register1 = et_username.getText().toString().trim(); 84 String register1 = et_username.getText().toString().trim();
83 String register2 = et_region.getText().toString().trim(); 85 String register2 = et_region.getText().toString().trim();
84 String register3 = et_grade.getText().toString().trim(); 86 String register3 = et_grade.getText().toString().trim();
85 String register4 = et_school.getText().toString().trim(); 87 String register4 = et_school.getText().toString().trim();
86 switch (v.getId()) { 88 switch (v.getId()) {
87 case R.id.et_region: 89 case R.id.et_region:
90 et_school.setText("");
88 choiseregion(); 91 choiseregion();
89 break; 92 break;
90 case R.id.et_grade: 93 case R.id.et_grade:
94 et_school.setText("");
91 choisegrade(); 95 choisegrade();
92 break; 96 break;
93 case R.id.et_school: 97 case R.id.et_school:
94 if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { 98 if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) {
95 AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); 99 AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址");
96 return; 100 return;
97 } else { 101 } else {
98 choiseschool(); 102 choiseschool();
99 } 103 }
100 104
101 break; 105 break;
102 case R.id.btn_ok: 106 case R.id.btn_ok:
103 if (TextUtils.isEmpty(register1) || 107 if (TextUtils.isEmpty(register1) ||
104 TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { 108 TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) {
105 AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); 109 AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整");
106 return; 110 return;
107 } else { 111 } else {
108 String register5 = et_username.getText().toString().trim(); 112 String register5 = et_username.getText().toString().trim();
109 String register6 = et_region.getText().toString().trim(); 113 String register6 = et_region.getText().toString().trim();
110 String register7 = et_grade.getText().toString().trim(); 114 String register7 = et_grade.getText().toString().trim();
111 String register8 = et_school.getText().toString().trim(); 115 String register8 = et_school.getText().toString().trim();
112 if (Content.accountflag == 2) { 116 if (Content.accountflag == 2) {
113 String userID = SaveParam.getInstance().getLoginParam(this, "userId"); 117 String userID = SaveParam.getInstance().getLoginParam(this, "userId");
114 String grade = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS); 118 String grade = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS);
115 String School = SaveParam.getInstance().getLoginParam(this, SaveParam.SCHOOOlID); 119 String School = SaveParam.getInstance().getLoginParam(this, SaveParam.SCHOOOlID);
116 String regionId = SaveParam.getInstance().getLoginParam(this, SaveParam.COUNTRY); 120 String regionId = SaveParam.getInstance().getLoginParam(this, SaveParam.COUNTRY);
117 String regionId1 = SaveParam.getInstance().getLoginParam(this, SaveParam.CITYS); 121 String regionId1 = SaveParam.getInstance().getLoginParam(this, SaveParam.CITYS);
118 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); 122 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
119 if (regionId == null) { 123 if (regionId == null) {
120 regionId = regionId1; 124 regionId = regionId1;
121 } 125 }
122 126
123 try { 127 try {
124 Object schoolss; 128 Object schoolss;
125 long auserID = Long.parseLong(userID); 129 long auserID = Long.parseLong(userID);
126 long grades = Long.parseLong(grade); 130 long grades = Long.parseLong(grade);
127 if (TextUtils.isEmpty(register8)) { 131 if (TextUtils.isEmpty(register8)) {
128 schoolss = null; 132 schoolss = null;
129 } else { 133 } else {
130 schoolss = Long.parseLong(School); 134 schoolss = Long.parseLong(School);
131 } 135 }
132 long regionIds = Long.parseLong(regionId); 136 long regionIds = Long.parseLong(regionId);
133 HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this, auserID, "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", 137 HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this, auserID, "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png",
134 register5, grades, schoolss, regionIds, devicenumber, register6); 138 register5, grades, schoolss, regionIds, devicenumber, register6);
135 139
136 } catch (NumberFormatException e) { 140 } catch (NumberFormatException e) {
137 e.printStackTrace(); 141 e.printStackTrace();
138 } 142 }
139 143
140 } else { 144 } else {
141 savedata(); 145 savedata();
142 Intent intent = new Intent(); 146 Intent intent = new Intent();
143 intent.setClass(RegisterInfoActivity.this, ChoiseTextBookActivity.class); 147 intent.setClass(RegisterInfoActivity.this, ChoiseTextBookActivity.class);
144 startActivity(intent); 148 startActivity(intent);
145 overridePendingTransition(R.anim.rightin, R.anim.rightout); 149 overridePendingTransition(R.anim.rightin, R.anim.rightout);
146 } 150 }
147 151
148 } 152 }
149 153
150 break; 154 break;
151 } 155 }
152 156
153 } 157 }
154 158
155 private void savedata() { 159 private void savedata() {
156 String register9 = et_username.getText().toString().trim(); 160 String register9 = et_username.getText().toString().trim();
157 String register10 = et_region.getText().toString().trim(); 161 String register10 = et_region.getText().toString().trim();
158 String register11 = et_grade.getText().toString().trim(); 162 String register11 = et_grade.getText().toString().trim();
159 String register12 = et_school.getText().toString().trim(); 163 String register12 = et_school.getText().toString().trim();
160 SaveParam.getInstance().saveLoginParam(this,SaveParam.USERNAME,register9); 164 SaveParam.getInstance().saveLoginParam(this,SaveParam.USERNAME,register9);
161 SaveParam.getInstance().saveLoginParam(this,SaveParam.ADRESS,register10); 165 SaveParam.getInstance().saveLoginParam(this,SaveParam.ADRESS,register10);
162 SaveParam.getInstance().saveLoginParam(this,SaveParam.GRADES,register11); 166 SaveParam.getInstance().saveLoginParam(this,SaveParam.GRADES,register11);
163 SaveParam.getInstance().saveLoginParam(this,SaveParam.SCHOOL,register12); 167 SaveParam.getInstance().saveLoginParam(this,SaveParam.SCHOOL,register12);
164 168
165 } 169 }
166 170
167 @Override 171 @Override
168 protected void onResume() { 172 protected void onResume() {
169 super.onResume(); 173 super.onResume();
170 } 174 }
171 175
172 176
173 //选择地区 177 //选择地区
174 private void choiseregion() { 178 private void choiseregion() {
175 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); 179 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog");
176 180
177 } 181 }
178 182
179 //选择年级 183 //选择年级
180 private void choisegrade() { 184 private void choisegrade() {
181 GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); 185 GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog");
182 186
183 } 187 }
184 188
185 //选择学校 189 //选择学校
186 private void choiseschool() { 190 private void choiseschool() {
187 SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); 191 SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog");
188 192
189 } 193 }
190 194
191 195
192 @Override 196 @Override
193 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { 197 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) {
194 String regionName = data.get(position).getRegionName(); 198 String regionName = data.get(position).getRegionName();
195 SaveParam.getInstance().saveLoginParam(this, "sheng", regionName); 199 SaveParam.getInstance().saveLoginParam(this, "sheng", regionName);
196 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); 200 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog");
197 et_region.setText(""); 201 et_region.setText("");
198 et_region.setText(regionName); 202 et_region.setText(regionName);
199 203
200 } 204 }
201 205
202 @Override 206 @Override
203 public boolean onKeyUp(int keyCode, KeyEvent event) { 207 public boolean onKeyUp(int keyCode, KeyEvent event) {
204 if (keyCode == KeyEvent.KEYCODE_BACK) { 208 if (keyCode == KeyEvent.KEYCODE_BACK) {
205 finish(); 209 finish();
206 210
207 } 211 }
208 return super.onKeyUp(keyCode, event); 212 return super.onKeyUp(keyCode, event);
209 } 213 }
210 214
211 @Override 215 @Override
212 public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { 216 public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) {
213 String regionName = data.get(position).getName(); 217 String regionName = data.get(position).getName();
214 et_grade.setText(regionName); 218 et_grade.setText(regionName);
215 219
216 } 220 }
217 221
218 @Override 222 @Override
219 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { 223 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) {
220 String regionName = data.get(position).getRegionName(); 224 String regionName = data.get(position).getRegionName();
221 String provice = SaveParam.getInstance().getLoginParam(this, "sheng"); 225 String provice = SaveParam.getInstance().getLoginParam(this, "sheng");
222 SaveParam.getInstance().saveLoginParam(this, "shi", regionName); 226 SaveParam.getInstance().saveLoginParam(this, "shi", regionName);
223 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); 227 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog");
224 et_region.setText(""); 228 et_region.setText("");
225 et_region.setText(provice + regionName); 229 et_region.setText(provice + regionName);
226 230
227 } 231 }
228 232
229 @Override 233 @Override
230 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { 234 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) {
231 String regionName = data.get(position).getRegionName(); 235 String regionName = data.get(position).getRegionName();
232 String provices = SaveParam.getInstance().getLoginParam(this, "sheng"); 236 String provices = SaveParam.getInstance().getLoginParam(this, "sheng");
233 String citys = SaveParam.getInstance().getLoginParam(this, "shi"); 237 String citys = SaveParam.getInstance().getLoginParam(this, "shi");
234 et_region.setText(""); 238 et_region.setText("");
235 et_region.setText(provices + citys + regionName); 239 et_region.setText(provices + citys + regionName);
236 240
237 } 241 }
238 242
239 @Override 243 @Override
240 public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { 244 public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) {
241 String regionName = data.get(position).getSchoolName(); 245 String regionName = data.get(position).getSchoolName();
242 et_school.setText(regionName); 246 et_school.setText(regionName);
243 247
244 } 248 }
245 } 249 }
246 250
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/SysApplication.java
File was created 1 package com.hjx.personalcenter.activity;
2
3 import android.app.Activity;
4 import android.app.Application;
5
6 import java.util.LinkedList;
7 import java.util.List;
8 public class SysApplication extends Application {
9 private List<Activity> mList = new LinkedList<Activity>();
10 private static SysApplication instance;
11 private SysApplication() {
12 }
13 public synchronized static SysApplication getInstance() {
14 if (null == instance) {
15 instance = new SysApplication();
16 }
17 return instance;
18 }
19 // add Activity
20 public void addActivity(Activity activity) {
21 mList.add(activity);
22 }
23 public void exit() {
24 try {
25 for (Activity activity : mList) {
26 if (activity != null)
27 activity.finish();
28 }
29 } catch (Exception e) {
30 e.printStackTrace();
31 } finally {
32 System.exit(0);
33 }
34 }
35 public void onLowMemory() {
36 super.onLowMemory();
37 System.gc();
38 }
39 }
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/TheStartPageActivity.java
1 package com.hjx.personalcenter.activity; 1 package com.hjx.personalcenter.activity;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity; 5 import android.support.v7.app.AppCompatActivity;
6 import android.view.View; 6 import android.view.View;
7 import android.widget.Button; 7 import android.widget.Button;
8 8
9 import com.hjx.personalcenter.R; 9 import com.hjx.personalcenter.R;
10 import com.hjx.personalcenter.db.SaveParam; 10 import com.hjx.personalcenter.db.SaveParam;
11 11
12 /** 12 /**
13 * Created by h on 2017/8/10. 13 * Created by h on 2017/8/10.
14 */ 14 */
15 15
16 public class TheStartPageActivity extends AppCompatActivity implements View.OnClickListener { 16 public class TheStartPageActivity extends AppCompatActivity implements View.OnClickListener {
17 private Button btn_start; 17 private Button btn_start;
18 @Override 18 @Override
19 protected void onCreate(Bundle savedInstanceState) { 19 protected void onCreate(Bundle savedInstanceState) {
20 super.onCreate(savedInstanceState); 20 super.onCreate(savedInstanceState);
21 setContentView(R.layout.activity_start_page); 21 setContentView(R.layout.activity_start_page);
22 SysApplication.getInstance().addActivity(this);
22 initView(); 23 initView();
23 initData(); 24 initData();
24 initLister(); 25 initLister();
25 } 26 }
26 private void initView() { 27 private void initView() {
27 btn_start = (Button) findViewById(R.id.btn_start); 28 btn_start = (Button) findViewById(R.id.btn_start);
28 } 29 }
29 30
30 private void initData() { 31 private void initData() {
31 32
32 } 33 }
33 34
34 private void initLister() { 35 private void initLister() {
35 btn_start.setOnClickListener(this); 36 btn_start.setOnClickListener(this);
36 } 37 }
37 38
38 @Override 39 @Override
39 public void onClick(View v) { 40 public void onClick(View v) {
40 switch (v.getId()){ 41 switch (v.getId()){
41 case R.id.btn_start: 42 case R.id.btn_start:
42 SaveParam.getInstance().saveLoginParam(this, "login", "true"); 43 SaveParam.getInstance().saveLoginParam(this, "login", "true");
43 Intent intent = new Intent(); 44 Intent intent = new Intent();
44 intent.setClass(TheStartPageActivity.this,MainActivity.class); 45 intent.setClass(TheStartPageActivity.this,MainActivity.class);
45 startActivity(intent); 46 startActivity(intent);
46 overridePendingTransition(R.anim.rightin, R.anim.rightout); 47 overridePendingTransition(R.anim.rightin, R.anim.rightout);
47 finish(); 48 finish();
48 break; 49 break;
49 } 50 }
50 } 51 }
51 } 52 }
52 53
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GridAdapter.java
1 package com.hjx.personalcenter.adapter; 1 package com.hjx.personalcenter.adapter;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.view.View; 4 import android.view.View;
5 import android.view.ViewGroup; 5 import android.view.ViewGroup;
6 import android.widget.BaseAdapter; 6 import android.widget.BaseAdapter;
7 import android.widget.TextView; 7 import android.widget.TextView;
8 8
9 import com.facebook.drawee.view.SimpleDraweeView; 9 import com.facebook.drawee.view.SimpleDraweeView;
10 import com.hjx.personalcenter.R; 10 import com.hjx.personalcenter.R;
11 import com.hjx.personalcenter.model.DefautPublishInfo; 11 import com.hjx.personalcenter.model.DefautPublishInfo;
12 12
13 import java.util.ArrayList; 13 import java.util.ArrayList;
14 14
15 /** 15 /**
16 * Created by h on 2017/9/12. 16 * Created by h on 2017/9/12.
17 */ 17 */
18 18
19 public class GridAdapter extends BaseAdapter { 19 public class GridAdapter extends BaseAdapter {
20 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfo; 20 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfo;
21 private Context context; 21 private Context context;
22 22
23 public GridAdapter(ArrayList<DefautPublishInfo.DataBean> defautPublishInfo, Context context) { 23 public GridAdapter(ArrayList<DefautPublishInfo.DataBean> defautPublishInfo, Context context) {
24 this.defautPublishInfo = defautPublishInfo; 24 this.defautPublishInfo = defautPublishInfo;
25 this.context = context; 25 this.context = context;
26 } 26 }
27 27
28 @Override 28 @Override
29 public int getCount() { 29 public int getCount() {
30 return defautPublishInfo.size(); 30 return defautPublishInfo.size();
31 } 31 }
32 32
33 @Override 33 @Override
34 public Object getItem(int position) { 34 public Object getItem(int position) {
35 return position; 35 return position;
36 } 36 }
37 37
38 @Override 38 @Override
39 public long getItemId(int position) { 39 public long getItemId(int position) {
40 return position; 40 return position;
41 } 41 }
42 42
43 @Override 43 @Override
44 public View getView(int position, View convertView, ViewGroup parent) { 44 public View getView(int position, View convertView, ViewGroup parent) {
45 ViewHolder viewHolder = new ViewHolder(); 45 ViewHolder viewHolder = new ViewHolder();
46 if (convertView == null) { 46 if (convertView == null) {
47 convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes3, null); 47 convertView = View.inflate(context, R.layout.fragment_changge_version_info_itmes3, null);
48 viewHolder.simpleDraweeView = (SimpleDraweeView) convertView.findViewById(R.id.image_publish); 48 viewHolder.simpleDraweeView = (SimpleDraweeView) convertView.findViewById(R.id.image_publish);
49 viewHolder.subject = (TextView) convertView.findViewById(R.id.subject); 49 viewHolder.subject = (TextView) convertView.findViewById(R.id.subject);
50 viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish); 50 viewHolder.publish = (TextView) convertView.findViewById(R.id.tv_publish);
51 convertView.setTag(viewHolder); 51 convertView.setTag(viewHolder);
52 } else { 52 } else {
53 viewHolder = (ViewHolder) convertView.getTag(); 53 viewHolder = (ViewHolder) convertView.getTag();
54 } 54 }
55 viewHolder.simpleDraweeView.setImageURI(defautPublishInfo.get(position).getCover()); 55 viewHolder.simpleDraweeView.setImageURI(defautPublishInfo.get(position).getCover());
56 viewHolder.subject.setText(defautPublishInfo.get(position).getSubject()); 56 viewHolder.subject.setText(defautPublishInfo.get(position).getSubject());
57 viewHolder.publish.setText(defautPublishInfo.get(position).getPress()); 57 viewHolder.publish.setText(defautPublishInfo.get(position).getPress());
58 return convertView; 58 return convertView;
59 } 59 }
60 60
61 static class ViewHolder { 61 static class ViewHolder {
62 SimpleDraweeView simpleDraweeView; 62 SimpleDraweeView simpleDraweeView;
63 TextView subject; 63 TextView subject;
64 TextView publish; 64 TextView publish;
65 } 65 }
66 } 66 }
67 67
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
1 package com.hjx.personalcenter.customdialog; 1 package com.hjx.personalcenter.customdialog;
2 2
3 import android.annotation.SuppressLint; 3 import android.annotation.SuppressLint;
4 import android.content.Context; 4 import android.content.Context;
5 import android.graphics.Color; 5 import android.graphics.Color;
6 import android.os.Bundle; 6 import android.os.Bundle;
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.Message; 8 import android.os.Message;
9 import android.view.Gravity; 9 import android.view.Gravity;
10 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
11 import android.view.View; 11 import android.view.View;
12 import android.view.ViewGroup; 12 import android.view.ViewGroup;
13 import android.widget.AdapterView; 13 import android.widget.AdapterView;
14 import android.widget.ImageView; 14 import android.widget.ImageView;
15 import android.widget.ListView; 15 import android.widget.ListView;
16 16
17 import com.hjx.personalcenter.R; 17 import com.hjx.personalcenter.R;
18 import com.hjx.personalcenter.adapter.GrandeAdapter; 18 import com.hjx.personalcenter.adapter.GrandeAdapter;
19 import com.hjx.personalcenter.db.Content;
19 import com.hjx.personalcenter.db.SaveParam; 20 import com.hjx.personalcenter.db.SaveParam;
20 import com.hjx.personalcenter.http.HttpCode; 21 import com.hjx.personalcenter.http.HttpCode;
21 import com.hjx.personalcenter.http.HttpManager; 22 import com.hjx.personalcenter.http.HttpManager;
22 import com.hjx.personalcenter.interfaces.DialogCallBack; 23 import com.hjx.personalcenter.interfaces.DialogCallBack;
23 import com.hjx.personalcenter.model.GradeInfo; 24 import com.hjx.personalcenter.model.GradeInfo;
24 import com.mylhyl.circledialog.BaseCircleDialog; 25 import com.mylhyl.circledialog.BaseCircleDialog;
25 import com.mylhyl.circledialog.res.values.CircleDimen; 26 import com.mylhyl.circledialog.res.values.CircleDimen;
26 27
27 import java.util.ArrayList; 28 import java.util.ArrayList;
28 import java.util.List; 29 import java.util.List;
29 30
30 /**自定义年级列表对话框 31 /**自定义年级列表对话框
31 * Created by h on 2017/8/10. 32 * Created by h on 2017/8/10.
32 */ 33 */
33 @SuppressLint("ValidFragment") 34 @SuppressLint("ValidFragment")
34 public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { 35 public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener {
35 private GrandeAdapter listadapter; 36 private GrandeAdapter listadapter;
36 private ListView listView; 37 private ListView listView;
37 private ImageView cance; 38 private ImageView cance;
38 ArrayList<GradeInfo.DataBean.ChildrenBean> data = new ArrayList<>(); 39 ArrayList<GradeInfo.DataBean.ChildrenBean> data = new ArrayList<>();
39 private DialogCallBack.GradeCallBack mCallBack; 40 private DialogCallBack.GradeCallBack mCallBack;
40 public GradeListDialog(DialogCallBack.GradeCallBack callBack) { 41 public GradeListDialog(DialogCallBack.GradeCallBack callBack) {
41 this.mCallBack = callBack; 42 this.mCallBack = callBack;
42 } 43 }
43 public static GradeListDialog getInstance(DialogCallBack.GradeCallBack callBack) { 44 public static GradeListDialog getInstance(DialogCallBack.GradeCallBack callBack) {
44 GradeListDialog dialogFragment = new GradeListDialog(callBack); 45 GradeListDialog dialogFragment = new GradeListDialog(callBack);
45 dialogFragment.setCanceledBack(true); 46 dialogFragment.setCanceledBack(true);
46 dialogFragment.setCanceledOnTouchOutside(true); 47 dialogFragment.setCanceledOnTouchOutside(true);
47 dialogFragment.setRadius(CircleDimen.RADIUS); 48 dialogFragment.setRadius(CircleDimen.RADIUS);
48 dialogFragment.setWidth(0.5f); 49 dialogFragment.setWidth(0.5f);
49 dialogFragment.setGravity(Gravity.CENTER); 50 dialogFragment.setGravity(Gravity.CENTER);
50 dialogFragment.setBackgroundColor(Color.WHITE); 51 dialogFragment.setBackgroundColor(Color.WHITE);
51 return dialogFragment; 52 return dialogFragment;
52 } 53 }
53 Handler handler = new Handler(){ 54 Handler handler = new Handler(){
54 @Override 55 @Override
55 public void handleMessage(Message msg) { 56 public void handleMessage(Message msg) {
56 super.handleMessage(msg); 57 super.handleMessage(msg);
57 switch (msg.what){ 58 switch (msg.what){
58 case HttpCode.GRADER: 59 case HttpCode.GRADER:
59 data.clear(); 60 data.clear();
60 data.addAll( (List<GradeInfo.DataBean.ChildrenBean>)msg.obj); 61 data.addAll( (List<GradeInfo.DataBean.ChildrenBean>)msg.obj);
61 listadapter.notifyDataSetChanged(); 62 listadapter.notifyDataSetChanged();
62 break; 63 break;
63 } 64 }
64 } 65 }
65 }; 66 };
66 @Override 67 @Override
67 public View createView(Context context, LayoutInflater inflater, ViewGroup container) { 68 public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
68 69
69 return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); 70 return inflater.inflate(R.layout.custom_adilog_gradelist, container, false);
70 } 71 }
71 @Override 72 @Override
72 public void onActivityCreated(Bundle savedInstanceState) { 73 public void onActivityCreated(Bundle savedInstanceState) {
73 super.onActivityCreated(savedInstanceState); 74 super.onActivityCreated(savedInstanceState);
74 listView = (ListView) getView().findViewById(R.id.listadapter); 75 listView = (ListView) getView().findViewById(R.id.listadapter);
75 cance = (ImageView) getView().findViewById(R.id.cancel); 76 cance = (ImageView) getView().findViewById(R.id.cancel);
76 listadapter = new GrandeAdapter(data,getActivity()); 77 listadapter = new GrandeAdapter(data,getActivity());
77 listView.setAdapter(listadapter); 78 listView.setAdapter(listadapter);
78 listView.setOnItemClickListener(this); 79 listView.setOnItemClickListener(this);
79 cance.setOnClickListener(new View.OnClickListener() { 80 cance.setOnClickListener(new View.OnClickListener() {
80 @Override 81 @Override
81 public void onClick(View v) { 82 public void onClick(View v) {
82 dismiss(); 83 dismiss();
83 } 84 }
84 }); 85 });
85 HttpManager.getInstance().getgrade(getActivity(),handler); 86 HttpManager.getInstance().getgrade(getActivity(),handler);
86 87
87 } 88 }
88 89
89 @Override 90 @Override
90 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 91 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
92 if (Content.accountflag ==2){
93 SaveParam.getInstance().saveCustomizeParam(getActivity(), SaveParam.CHILDSGRADENS, ""+data.get(position).getId());
94 }else {
95 SaveParam.getInstance().saveCustomizeParam(getActivity(), SaveParam.GRADENS, ""+data.get(position).getId());
96 }
91 97
92 SaveParam.getInstance().saveCustomizeParam(getActivity(), SaveParam.GRADENS, ""+data.get(position).getId());
93 mCallBack.province3OnItemClick(data,position,5); 98 mCallBack.province3OnItemClick(data,position,5);
94 dismiss(); 99 dismiss();
95 100
96 101
97 } 102 }
98 } 103 }
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/VerSionDialog.java
1 package com.hjx.personalcenter.customdialog; 1 package com.hjx.personalcenter.customdialog;
2 2
3 import android.annotation.SuppressLint; 3 import android.annotation.SuppressLint;
4 import android.content.Context; 4 import android.content.Context;
5 import android.graphics.Color; 5 import android.graphics.Color;
6 import android.os.Bundle; 6 import android.os.Bundle;
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.Message; 8 import android.os.Message;
9 import android.util.Log; 9 import android.util.Log;
10 import android.view.Gravity; 10 import android.view.Gravity;
11 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
12 import android.view.View; 12 import android.view.View;
13 import android.view.ViewGroup; 13 import android.view.ViewGroup;
14 import android.widget.AdapterView; 14 import android.widget.AdapterView;
15 import android.widget.ImageView; 15 import android.widget.ImageView;
16 import android.widget.ListView; 16 import android.widget.ListView;
17 import android.widget.TextView;
17 18
19 import com.facebook.drawee.view.SimpleDraweeView;
18 import com.hjx.personalcenter.R; 20 import com.hjx.personalcenter.R;
19 import com.hjx.personalcenter.adapter.VersionAdapter; 21 import com.hjx.personalcenter.adapter.VersionAdapter;
20 import com.hjx.personalcenter.db.SaveParam; 22 import com.hjx.personalcenter.db.SaveParam;
21 import com.hjx.personalcenter.http.HttpCode; 23 import com.hjx.personalcenter.http.HttpCode;
22 import com.hjx.personalcenter.http.HttpManager; 24 import com.hjx.personalcenter.http.HttpManager;
25 import com.hjx.personalcenter.interfaces.DialogCallBack;
23 import com.hjx.personalcenter.model.VersionInfo; 26 import com.hjx.personalcenter.model.VersionInfo;
24 import com.mylhyl.circledialog.BaseCircleDialog; 27 import com.mylhyl.circledialog.BaseCircleDialog;
25 import com.mylhyl.circledialog.res.values.CircleDimen; 28 import com.mylhyl.circledialog.res.values.CircleDimen;
26 29
27 import java.util.ArrayList; 30 import java.util.ArrayList;
28 import java.util.List; 31 import java.util.List;
29 32
30 /** 33 /**
31 * 自定义版本信息列表对话框 34 * 自定义版本信息列表对话框
32 * Created by h on 2017/8/10. 35 * Created by h on 2017/8/10.
33 */ 36 */
34 @SuppressLint("ValidFragment") 37 @SuppressLint("ValidFragment")
35 public class VerSionDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { 38 public class VerSionDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener{
36 private VersionAdapter listadapter; 39 private VersionAdapter listadapter;
37 private ImageView cance; 40 private ImageView cance;
38 private ListView listView; 41 private ListView listView;
42 private TextView publish;
43 private SimpleDraweeView simpleDraweeView;
39 private ArrayList<VersionInfo.DataBean> data = new ArrayList<>(); 44 private ArrayList<VersionInfo.DataBean> data = new ArrayList<>();
40 45 private DialogCallBack.VersionCallBack mcallback;
46 public VerSionDialog(DialogCallBack.VersionCallBack callBack) {
47 this.mcallback = callBack;
48 }
41 Handler handler = new Handler(){ 49 Handler handler = new Handler(){
42 @Override 50 @Override
43 public void handleMessage(Message msg) { 51 public void handleMessage(Message msg) {
44 super.handleMessage(msg); 52 super.handleMessage(msg);
45 switch (msg.what){ 53 switch (msg.what){
46 case HttpCode.VERSION_SUCESS: 54 case HttpCode.VERSION_SUCESS:
47 data.clear(); 55 data.clear();
48 data.addAll( (List<VersionInfo.DataBean>)msg.obj); 56 data.addAll( (List<VersionInfo.DataBean>)msg.obj);
49 listadapter.notifyDataSetChanged(); 57 listadapter.notifyDataSetChanged();
50 58
51 break; 59 break;
52 } 60 }
53 } 61 }
54 }; 62 };
55 63
56 public static VerSionDialog getInstance() { 64 public static VerSionDialog getInstance(DialogCallBack.VersionCallBack callBack) {
57 VerSionDialog dialogFragment = new VerSionDialog(); 65 VerSionDialog dialogFragment = new VerSionDialog(callBack);
58 dialogFragment.setCanceledBack(true); 66 dialogFragment.setCanceledBack(true);
59 dialogFragment.setCanceledOnTouchOutside(true); 67 dialogFragment.setCanceledOnTouchOutside(true);
60 dialogFragment.setRadius(CircleDimen.RADIUS); 68 dialogFragment.setRadius(CircleDimen.RADIUS);
61 dialogFragment.setWidth(0.5f); 69 dialogFragment.setWidth(0.5f);
62 dialogFragment.setGravity(Gravity.CENTER); 70 dialogFragment.setGravity(Gravity.CENTER);
63 dialogFragment.setBackgroundColor(Color.WHITE); 71 dialogFragment.setBackgroundColor(Color.WHITE);
64 return dialogFragment; 72 return dialogFragment;
65 } 73 }
66 74
67 @Override 75 @Override
68 public View createView(Context context, LayoutInflater inflater, ViewGroup container) { 76 public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
69 return inflater.inflate(R.layout.custom_adilog_publishlist, container, false); 77 return inflater.inflate(R.layout.custom_adilog_publishlist, container, false);
70 } 78 }
71 79
72 @Override 80 @Override
73 public void onActivityCreated(Bundle savedInstanceState) { 81 public void onActivityCreated(Bundle savedInstanceState) {
74 super.onActivityCreated(savedInstanceState); 82 super.onActivityCreated(savedInstanceState);
75 listView = (ListView) getView().findViewById(R.id.listadapter); 83 listView = (ListView) getView().findViewById(R.id.listadapter);
76 cance = (ImageView) getView().findViewById(R.id.cancel); 84 cance = (ImageView) getView().findViewById(R.id.cancel);
77 listadapter = new VersionAdapter(data,getActivity()); 85 listadapter = new VersionAdapter(data,getActivity());
78 listView.setAdapter(listadapter); 86 listView.setAdapter(listadapter);
79 listView.setOnItemClickListener(this); 87 listView.setOnItemClickListener(this);
80 cance.setOnClickListener(new View.OnClickListener() { 88 cance.setOnClickListener(new View.OnClickListener() {
81 @Override 89 @Override
82 public void onClick(View v) { 90 public void onClick(View v) {
83 dismiss(); 91 dismiss();
84 } 92 }
85 }); 93 });
86 String subjectName = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.SUBJECT); 94 String subjectName = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.SUBJECT);
87 Log.e("test","选择的科目"+subjectName); 95 Log.e("test","选择的科目"+subjectName);
88 HttpManager.getInstance().versioninfo(getActivity(),subjectName,handler); 96 HttpManager.getInstance().versioninfo(getActivity(),subjectName,handler);
89 97
90 } 98 }
91 99
92 @Override 100 @Override
93 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 101 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
94 String imageurl = data.get(position).getPressCover(); 102 mcallback.versionOnItemClick(data,position,5);
95 String publish = data.get(position).getPressName(); 103 // String imageurl = data.get(position).getPressCover();
96 Log.e("test","拿到的数据为"+imageurl+publish); 104 // String publishs = data.get(position).getPressName();
97 105 // Log.e("test","拿到的数据为"+imageurl+publish);
98 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.IMGURL,imageurl); 106 // simpleDraweeView.setImageURI(imageurl);
99 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.VERSION,publish); 107 // publish.setText(publishs);
100 108
101 dismiss(); 109 dismiss();
102 110
103 } 111 }
104 } 112 }
105 113
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
1 package com.hjx.personalcenter.db; 1 package com.hjx.personalcenter.db;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 import android.content.SharedPreferences; 5 import android.content.SharedPreferences;
6 6
7 public class SaveParam { 7 public class SaveParam {
8 8
9 private static SaveParam instance; 9 private static SaveParam instance;
10 public static SaveParam getInstance(){ 10 public static SaveParam getInstance(){
11 if (instance==null){ 11 if (instance==null){
12 instance = new SaveParam(); 12 instance = new SaveParam();
13 } 13 }
14 return instance; 14 return instance;
15 } 15 }
16 public static String CHILDSID = "childID";//子账号id 16 public static String CHILDSID = "childID";//子账号id
17 public static String CHILDSGRADENS = "childs";//子账号年级id 17 public static String CHILDSGRADENS = "childs";//子账号年级id
18 public static String GRADENS = "gradens";//年级id 18 public static String GRADENS = "gradens";//年级id
19 public static String SCHOOOlID = "schoolid";//学校id 19 public static String SCHOOOlID = "schoolid";//学校id
20 //个人信息 20 //个人信息
21 public static String USERNAME = "usernames";//昵称 21 public static String USERNAME = "usernames";//昵称
22 public static String ADRESS = "adress";//地址 22 public static String ADRESS = "adress";//地址
23 public static String GRADES = "gadens";//年级 23 public static String GRADES = "gadens";//年级
24 public static String SCHOOL = "school";//学校 24 public static String SCHOOL = "school";//学校
25 public static String CONSTELLATION = "constellations";//星座 25 public static String CONSTELLATION = "constellations";//星座
26 public static String HEADURL = "headurl";//星座 26 public static String HEADURL = "headurl";//星座
27 27
28 //电子保卡信息 28 //电子保卡信息
29 public static String CARDPHONE = "cardphone";//保卡手机号 29 public static String CARDPHONE = "cardphone";//保卡手机号
30 public static String CUNSTEMNAME = "cunstemname";//客户姓名 30 public static String CUNSTEMNAME = "cunstemname";//客户姓名
31 public static String ADRESSCUNSTEM = "adresscunstem";//客户地址 31 public static String ADRESSCUNSTEM = "adresscunstem";//客户地址
32 public static String SHOPTIME = "shoptime";//购买时间 32 public static String SHOPTIME = "shoptime";//购买时间
33 public static String SHOPADRESS = "shopadress";//购买地址 33 public static String SHOPADRESS = "shopadress";//购买地址
34 public static String SHOPTLEPHONE = "shoptlephone";//售后电话 34 public static String SHOPTLEPHONE = "shoptlephone";//售后电话
35 35
36 //省市区参数、 36 //省市区参数、
37 public static String PROVINCES = "provinces";//省 37 public static String PROVINCES = "provinces";//省
38 public static String CITYS = "citys";//市 38 public static String CITYS = "citys";//市
39 public static String COUNTRY = "country";//区 39 public static String COUNTRY = "country";//区
40 40
41 //账户管理 41 //账户管理
42 public static String ACCOUNT = "account";//账户类型 42 public static String ACCOUNT = "account";//账户类型
43 //科目信息 43 //科目信息
44 public static String SUBJECT = "subject"; 44 public static String SUBJECT = "subject";
45 //科目出版社
46 public static String CHINESE = "chinese";
47 public static String MATH = "math";
48 public static String ENGLISH = "english";
49 public static String PHYSICS = "physics";
50 public static String CHEMISTRY = "chemistry";
51 public static String HISTORY = "history";
52 public static String GEOGRAPHY = "geography";
53 public static String POLITICAL = "political";
54 public static String BIOLOGY = "biology";
55 public static String SCIENCE = "science";
45 //图片URL 56 //图片URL
46 public static String IMGURL = "imgurl"; 57 public static String IMGURL = "imgurl";
47 //版本名称 58 //版本名称
48 public static String VERSION = "version"; 59 public static String VERSION = "version";
49 60
50 61
51 public void saveLoginParam(Context context,String spname, String spstr) { 62 public void saveLoginParam(Context context,String spname, String spstr) {
52 SharedPreferences sp = context.getSharedPreferences("loginparam", 63 SharedPreferences sp = context.getSharedPreferences("loginparam",
53 Activity.MODE_PRIVATE); 64 Activity.MODE_PRIVATE);
54 65
55 sp.edit().putString(spname, spstr).commit(); 66 sp.edit().putString(spname, spstr).commit();
56 } 67 }
57 68
58 69
59 public String getLoginParam(Context context,String spname) { 70 public String getLoginParam(Context context,String spname) {
60 SharedPreferences sp = context.getSharedPreferences("loginparam", 71 SharedPreferences sp = context.getSharedPreferences("loginparam",
61 Activity.MODE_PRIVATE); 72 Activity.MODE_PRIVATE);
62 String param = sp.getString(spname, null); 73 String param = sp.getString(spname, null);
63 return param; 74 return param;
64 } 75 }
65 public void clearData(Context context) { 76 public void clearData(Context context) {
66 SharedPreferences sp = context.getSharedPreferences("loginparam", 77 SharedPreferences sp = context.getSharedPreferences("loginparam",
67 Activity.MODE_PRIVATE); 78 Activity.MODE_PRIVATE);
68 sp.edit().clear().commit(); 79 sp.edit().clear().commit();
69 } 80 }
70 81
71 public void saveCustomizeParam(Context context,String spname, String spstr) { 82 public void saveCustomizeParam(Context context,String spname, String spstr) {
72 SharedPreferences sp = context.getSharedPreferences("presoninfo", 83 SharedPreferences sp = context.getSharedPreferences("presoninfo",
73 Activity.MODE_PRIVATE); 84 Activity.MODE_PRIVATE);
74 85
75 sp.edit().putString(spname, spstr).commit(); 86 sp.edit().putString(spname, spstr).commit();
76 87
77 } 88 }
78 89
79 public String getCustomizeParam(Context context,String spname) { 90 public String getCustomizeParam(Context context,String spname) {
80 SharedPreferences sp = context.getSharedPreferences("presoninfo", 91 SharedPreferences sp = context.getSharedPreferences("presoninfo",
81 Activity.MODE_PRIVATE); 92 Activity.MODE_PRIVATE);
82 String param = sp.getString(spname, null); 93 String param = sp.getString(spname, null);
83 return param; 94 return param;
84 } 95 }
85 96
86 public void clearCustomizeParam(Context context ){ 97 public void clearCustomizeParam(Context context ){
87 SharedPreferences sp = context.getSharedPreferences("presoninfo", 98 SharedPreferences sp = context.getSharedPreferences("presoninfo",
88 Activity.MODE_PRIVATE); 99 Activity.MODE_PRIVATE);
89 sp.edit().clear().commit(); 100 sp.edit().clear().commit();
90 } 101 }
91 } 102 }
92 103
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/PresonInfoFragment.java
1 package com.hjx.personalcenter.fragment; 1 package com.hjx.personalcenter.fragment;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context;
4 import android.graphics.Color; 5 import android.graphics.Color;
5 import android.os.Bundle; 6 import android.os.Bundle;
6 import android.support.annotation.Nullable; 7 import android.support.annotation.Nullable;
7 import android.support.v4.app.Fragment; 8 import android.support.v4.app.Fragment;
8 import android.util.Log; 9 import android.util.Log;
9 import android.view.Gravity; 10 import android.view.Gravity;
10 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
11 import android.view.View; 12 import android.view.View;
12 import android.view.ViewGroup; 13 import android.view.ViewGroup;
13 import android.widget.AdapterView; 14 import android.widget.AdapterView;
14 import android.widget.EditText; 15 import android.widget.EditText;
15 import android.widget.ImageView; 16 import android.widget.ImageView;
16 import android.widget.TextView; 17 import android.widget.TextView;
17 18
18 import com.bigkoo.pickerview.TimePickerView; 19 import com.bigkoo.pickerview.TimePickerView;
19 import com.hjx.personalcenter.R; 20 import com.hjx.personalcenter.R;
20 import com.hjx.personalcenter.customdialog.CitysListDialog; 21 import com.hjx.personalcenter.customdialog.CitysListDialog;
21 import com.hjx.personalcenter.customdialog.CountryDialog; 22 import com.hjx.personalcenter.customdialog.CountryDialog;
22 import com.hjx.personalcenter.customdialog.GradeListDialog; 23 import com.hjx.personalcenter.customdialog.GradeListDialog;
23 import com.hjx.personalcenter.customdialog.ProvinceListDialog; 24 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
24 import com.hjx.personalcenter.customdialog.SchoolListDialog; 25 import com.hjx.personalcenter.customdialog.SchoolListDialog;
25 import com.hjx.personalcenter.db.Content;
26 import com.hjx.personalcenter.db.SaveParam; 26 import com.hjx.personalcenter.db.SaveParam;
27 import com.hjx.personalcenter.http.HttpManager; 27 import com.hjx.personalcenter.http.HttpManager;
28 import com.hjx.personalcenter.interfaces.DialogCallBack; 28 import com.hjx.personalcenter.interfaces.DialogCallBack;
29 import com.hjx.personalcenter.model.CityInfo; 29 import com.hjx.personalcenter.model.CityInfo;
30 import com.hjx.personalcenter.model.CountyInfo; 30 import com.hjx.personalcenter.model.CountyInfo;
31 import com.hjx.personalcenter.model.GradeInfo; 31 import com.hjx.personalcenter.model.GradeInfo;
32 import com.hjx.personalcenter.model.ProvinceInfo; 32 import com.hjx.personalcenter.model.ProvinceInfo;
33 import com.hjx.personalcenter.model.SchoolInfo; 33 import com.hjx.personalcenter.model.SchoolInfo;
34 import com.hjx.personalcenter.util.AlertUtils; 34 import com.hjx.personalcenter.util.AlertUtils;
35 import com.hjx.personalcenter.util.BrithdayStar; 35 import com.hjx.personalcenter.util.BrithdayStar;
36 import com.hjx.personalcenter.util.GetDevicesUtil; 36 import com.hjx.personalcenter.util.GetDevicesUtil;
37 import com.mylhyl.circledialog.CircleDialog; 37 import com.mylhyl.circledialog.CircleDialog;
38 import com.mylhyl.circledialog.callback.ConfigDialog; 38 import com.mylhyl.circledialog.callback.ConfigDialog;
39 import com.mylhyl.circledialog.params.DialogParams; 39 import com.mylhyl.circledialog.params.DialogParams;
40 40
41 import org.apache.http.util.TextUtils; 41 import org.apache.http.util.TextUtils;
42 42
43 import java.text.SimpleDateFormat; 43 import java.text.SimpleDateFormat;
44 import java.util.ArrayList; 44 import java.util.ArrayList;
45 import java.util.Date; 45 import java.util.Date;
46 46
47 /** 47 /**
48 * Created by h on 2017/8/12. 48 * Created by h on 2017/8/12.
49 */ 49 */
50 50
51 public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack 51 public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack
52 , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { 52 , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack {
53 private View mView; 53 private View mView;
54 private int type; 54 private int type;
55 private TimePickerView pvTime; 55 private TimePickerView pvTime;
56 private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; 56 private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq;
57 private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender; 57 private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender;
58 public static String TABLAYOUT_FRAGMENT = "presonfragment"; 58 public static String TABLAYOUT_FRAGMENT = "presonfragment";
59 private ImageView my_adress,my_sex,my_bthday,my_grade,my_school; 59 private ImageView my_adress,my_sex,my_bthday,my_grade,my_school;
60 60
61 public static PresonInfoFragment newInstance(int type) { 61 public static PresonInfoFragment newInstance(int type) {
62 PresonInfoFragment fragment = new PresonInfoFragment(); 62 PresonInfoFragment fragment = new PresonInfoFragment();
63 Bundle bundle = new Bundle(); 63 Bundle bundle = new Bundle();
64 bundle.putSerializable(TABLAYOUT_FRAGMENT, type); 64 bundle.putSerializable(TABLAYOUT_FRAGMENT, type);
65 fragment.setArguments(bundle); 65 fragment.setArguments(bundle);
66 return fragment; 66 return fragment;
67 67
68 } 68 }
69 69
70 @Override 70 @Override
71 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 71 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
72 if (mView == null) { 72 if (mView == null) {
73 mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); 73 mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false);
74 initView(mView); 74 initView(mView);
75 initData(); 75 initData();
76 setLister(); 76 setLister();
77 initTimePicker(); 77 initTimePicker();
78 78
79 79
80 } 80 }
81 return mView; 81 return mView;
82 } 82 }
83 83
84 //初始化 84 //初始化
85 private void initView(View mView) { 85 private void initView(View mView) {
86 tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); 86 tv_username1 = (EditText) mView.findViewById(R.id.tv_username1);
87 tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); 87 tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1);
88 tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); 88 tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq);
89 tv_sex = (TextView) mView.findViewById(R.id.tv_sex); 89 tv_sex = (TextView) mView.findViewById(R.id.tv_sex);
90 tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); 90 tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress);
91 tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); 91 tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday);
92 tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); 92 tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school);
93 tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); 93 tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender);
94 my_adress = (ImageView) mView.findViewById(R.id.my_adress); 94 my_adress = (ImageView) mView.findViewById(R.id.my_adress);
95 my_sex = (ImageView) mView.findViewById(R.id.my_sex); 95 my_sex = (ImageView) mView.findViewById(R.id.my_sex);
96 my_bthday = (ImageView) mView.findViewById(R.id.my_bthday); 96 my_bthday = (ImageView) mView.findViewById(R.id.my_bthday);
97 my_grade = (ImageView) mView.findViewById(R.id.my_grade); 97 my_grade = (ImageView) mView.findViewById(R.id.my_grade);
98 my_school = (ImageView) mView.findViewById(R.id.my_school); 98 my_school = (ImageView) mView.findViewById(R.id.my_school);
99 99
100 100
101 } 101 }
102 102
103 private void initData() { 103 private void initData() {
104 } 104 }
105 105
106 private void setLister() { 106 private void setLister() {
107 tv_sex.setOnClickListener(this); 107 tv_sex.setOnClickListener(this);
108 tv_useinfo_adress.setOnClickListener(this); 108 tv_useinfo_adress.setOnClickListener(this);
109 tv_useinfo_birthday.setOnClickListener(this); 109 tv_useinfo_birthday.setOnClickListener(this);
110 tv_useinfo_school.setOnClickListener(this); 110 tv_useinfo_school.setOnClickListener(this);
111 tv_useinfo_gender.setOnClickListener(this); 111 tv_useinfo_gender.setOnClickListener(this);
112 my_adress.setOnClickListener(this); 112 my_adress.setOnClickListener(this);
113 my_sex.setOnClickListener(this); 113 my_sex.setOnClickListener(this);
114 my_bthday.setOnClickListener(this); 114 my_bthday.setOnClickListener(this);
115 my_grade.setOnClickListener(this); 115 my_grade.setOnClickListener(this);
116 my_school.setOnClickListener(this); 116 my_school.setOnClickListener(this);
117 } 117 }
118 118
119 @Override 119 @Override
120 public void onClick(View v) { 120 public void onClick(View v) {
121 String presonal1 = tv_username1.getText().toString().trim(); 121 String presonal1 = tv_username1.getText().toString().trim();
122 String presonal2 = tv_useinfo_adress1.getText().toString().trim(); 122 String presonal2 = tv_useinfo_adress1.getText().toString().trim();
123 String presonal3 = tv_sex.getText().toString().trim(); 123 String presonal3 = tv_sex.getText().toString().trim();
124 String presonal4 = tv_useinfo_adress.getText().toString().trim(); 124 String presonal4 = tv_useinfo_adress.getText().toString().trim();
125 String presonal5 = tv_useinfo_birthday.getText().toString().trim(); 125 String presonal5 = tv_useinfo_birthday.getText().toString().trim();
126 String presonal6 = tv_useinfo_school.getText().toString().trim(); 126 String presonal6 = tv_useinfo_school.getText().toString().trim();
127 String presonal7 = tv_useinfo_gender.getText().toString().trim(); 127 String presonal7 = tv_useinfo_gender.getText().toString().trim();
128 String presonal8 = tv_useinfo_qq.getText().toString().trim(); 128 String presonal8 = tv_useinfo_qq.getText().toString().trim();
129 switch (v.getId()) { 129 switch (v.getId()) {
130 case R.id.tv_sex: 130 case R.id.tv_sex:
131 case R.id.my_sex: 131 case R.id.my_sex:
132 final String[] items = {"男", "女"}; 132 final String[] items = {"男", "女"};
133 new CircleDialog.Builder(getActivity()) 133 new CircleDialog.Builder(getActivity())
134 .configDialog(new ConfigDialog() { 134 .configDialog(new ConfigDialog() {
135 @Override 135 @Override
136 public void onConfig(DialogParams params) { 136 public void onConfig(DialogParams params) {
137 //增加弹出动画 137 //增加弹出动画
138 params.gravity = Gravity.CENTER; 138 params.gravity = Gravity.CENTER;
139 } 139 }
140 }) 140 })
141 .setTitle("请选择性别") 141 .setTitle("请选择性别")
142 .setWidth(0.5f) 142 .setWidth(0.5f)
143 .setItems(items, new AdapterView.OnItemClickListener() { 143 .setItems(items, new AdapterView.OnItemClickListener() {
144 @Override 144 @Override
145 public void onItemClick(AdapterView<?> parent, View view, int 145 public void onItemClick(AdapterView<?> parent, View view, int
146 position, long id) { 146 position, long id) {
147 switch (position) { 147 switch (position) {
148 case 0: 148 case 0:
149 tv_sex.setText("男"); 149 tv_sex.setText("男");
150 break; 150 break;
151 case 1: 151 case 1:
152 tv_sex.setText("女"); 152 tv_sex.setText("女");
153 break; 153 break;
154 } 154 }
155 155
156 } 156 }
157 }) 157 })
158 .show(); 158 .show();
159 break; 159 break;
160 case R.id.tv_useinfo_adress: 160 case R.id.tv_useinfo_adress:
161 case R.id.my_adress: 161 case R.id.my_adress:
162 tv_useinfo_school.setText("");
162 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); 163 ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog");
163 break; 164 break;
164 case R.id.tv_useinfo_birthday: 165 case R.id.tv_useinfo_birthday:
165 case R.id.my_bthday: 166 case R.id.my_bthday:
166 pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view 167 pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view
167 break; 168 break;
168 case R.id.tv_useinfo_school: 169 case R.id.tv_useinfo_school:
169 case R.id.my_school: 170 case R.id.my_school:
170 if (TextUtils.isEmpty(presonal4) || 171 if (TextUtils.isEmpty(presonal4) ||
171 TextUtils.isEmpty(presonal7)) { 172 TextUtils.isEmpty(presonal7)) {
172 AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); 173 AlertUtils.showToast(getActivity(), "请先选择地区和年级!");
173 return; 174 return;
174 } else { 175 } else {
175 SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); 176 SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog");
176 } 177 }
177 178
178 179
179 break; 180 break;
180 case R.id.tv_useinfo_gender: 181 case R.id.tv_useinfo_gender:
181 case R.id.my_grade: 182 case R.id.my_grade:
183 tv_useinfo_school.setText("");
182 GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); 184 GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog");
183 break; 185 break;
184 case R.id.presonal_sub: 186 case R.id.presonal_sub:
185 if (Content.changeinfoflag == 1) {
186 Log.e("test","你提交个人信息"); 187 Log.e("test","你提交个人信息");
187 if (TextUtils.isEmpty(presonal1) || 188 if (TextUtils.isEmpty(presonal1) ||
188 TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || 189 TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) ||
189 TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || 190 TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) ||
190 TextUtils.isEmpty(presonal8)) { 191 TextUtils.isEmpty(presonal8)) {
191 AlertUtils.showToast(getActivity(), "请将信息填写完整!"); 192 AlertUtils.showToast(getActivity(), "请将信息填写完整!");
192 return; 193 return;
193 } else { 194 } else {
194 195
195 int a = 0, b = 0; 196 int a = 0, b = 0;
196 int d = 1; 197 int d = 1;
197 Object schoolids; 198 Object schoolids;
198 Long f = null; 199 Long f = null;
199 //保存星座 200 //保存星座
200 BrithdayStar brithdayStar = new BrithdayStar(); 201 BrithdayStar brithdayStar = new BrithdayStar();
201 String s = brithdayStar.getConstellations(tv_useinfo_birthday.getText().toString()); 202 String s = brithdayStar.getConstellations(tv_useinfo_birthday.getText().toString());
202 SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CONSTELLATION, s); 203 SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CONSTELLATION, s);
203 204
204 String regionId = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.COUNTRY); 205 String regionId = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.COUNTRY);
205 String regionId1 = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); 206 String regionId1 = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS);
206 if (regionId == null) { 207 if (regionId == null) {
207 regionId = regionId1; 208 regionId = regionId1;
208 } 209 }
209 String grade = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.GRADENS); 210 String grade = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.GRADENS);
210 String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOOlID); 211 String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOOlID);
211 String type = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); 212 String type = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT);
212 String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); 213 String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId");
213 String devicenumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); 214 String devicenumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber();
214 String changeinfo = null; 215 String changeinfo = null;
215 if ("男".equals(presonal3)) { 216 if ("男".equals(presonal3)) {
216 changeinfo = "male"; 217 changeinfo = "male";
217 } else { 218 } else {
218 changeinfo = "female"; 219 changeinfo = "female";
219 } 220 }
220 try { 221 try {
221 a = Integer.parseInt(regionId); 222 a = Integer.parseInt(regionId);
222 b = Integer.parseInt(grade); 223 b = Integer.parseInt(grade);
223 if (TextUtils.isEmpty(presonal6)) { 224 if (TextUtils.isEmpty(presonal6)) {
224 schoolids = null; 225 schoolids = null;
225 } else { 226 } else {
226 schoolids = Long.parseLong(schoolid); 227 schoolids = Long.parseLong(schoolid);
227 } 228 }
228 d = Integer.parseInt(type); 229 d = Integer.parseInt(type);
229 f = Long.parseLong(userID); 230 f = Long.parseLong(userID);
230 //提交个人信息 231 //提交个人信息
231 HttpManager.getInstance().changepresonalinfo(getActivity(), 232 HttpManager.getInstance().changepresonalinfo(getActivity(),
232 f, d, presonal1, presonal5, b, a, schoolids, presonal8, changeinfo, presonal4 + presonal2, devicenumber); 233 f, d, presonal1, presonal5, b, a, schoolids, presonal8, changeinfo, presonal4 + presonal2, devicenumber);
233 234
234 } catch (Exception e) { 235 } catch (Exception e) {
235 e.printStackTrace(); 236 e.printStackTrace();
236 } 237 }
237 }
238 238
239 break; 239 break;
240 } 240 }
241 } 241 }
242 } 242 }
243 243
244 //自定义时间选择器 244 //自定义时间选择器
245 private void initTimePicker() { 245 private void initTimePicker() {
246 //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) 246 //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释)
247 //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 247 //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11
248 // Calendar selectedDate = Calendar.getInstance(); 248 // Calendar selectedDate = Calendar.getInstance();
249 // Calendar startDate = Calendar.getInstance(); 249 // Calendar startDate = Calendar.getInstance();
250 // startDate.set(1900, 1, 1); 250 // startDate.set(1900, 1, 1);
251 // Calendar endDate = Calendar.getInstance(); 251 // Calendar endDate = Calendar.getInstance();
252 // endDate.set(2100, 1, 1); 252 // endDate.set(2100, 1, 1);
253 //时间选择器 253 //时间选择器
254 pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { 254 pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() {
255 @Override 255 @Override
256 public void onTimeSelect(Date date, View v) {//选中事件回调 256 public void onTimeSelect(Date date, View v) {//选中事件回调
257 // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null 257 // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null
258 /*btn_Time.setText(getTime(date));*/ 258 /*btn_Time.setText(getTime(date));*/
259 TextView btn = (TextView) v; 259 TextView btn = (TextView) v;
260 btn.setText(getTime(date)); 260 btn.setText(getTime(date));
261 } 261 }
262 }) 262 })
263 //年月日时分秒 的显示与否,不设置则默认全部显示 263 //年月日时分秒 的显示与否,不设置则默认全部显示
264 .setType(new boolean[]{true, true, true, false, false, false}) 264 .setType(new boolean[]{true, true, true, false, false, false})
265 .setLabel("", "", "", "", "", "") 265 .setLabel("", "", "", "", "", "")
266 .isCenterLabel(false) 266 .isCenterLabel(false)
267 .setDividerColor(Color.DKGRAY) 267 .setDividerColor(Color.DKGRAY)
268 .setContentSize(21) 268 .setContentSize(21)
269 // .setDate(selectedDate) 269 // .setDate(selectedDate)
270 // .setRangDate(startDate, endDate) 270 // .setRangDate(startDate, endDate)
271 .setBackgroundId(0x80000000) //设置外部遮罩颜色 271 .setBackgroundId(0x80000000) //设置外部遮罩颜色
272 .setDecorView(null) 272 .setDecorView(null)
273 .setTitleText("出生日期") 273 .setTitleText("出生日期")
274 .setTitleSize(22) 274 .setTitleSize(22)
275 .setCancelColor(Color.GRAY) 275 .setCancelColor(Color.GRAY)
276 .setSubCalSize(22) 276 .setSubCalSize(22)
277 .setDividerColor(Color.GRAY) 277 .setDividerColor(Color.GRAY)
278 .setSubmitColor(Color.GRAY) 278 .setSubmitColor(Color.GRAY)
279 .build(); 279 .build();
280 } 280 }
281 281
282 private String getTime(Date date) {//可根据需要自行截取数据显示 282 private String getTime(Date date) {//可根据需要自行截取数据显示
283 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 283 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
284 return format.format(date); 284 return format.format(date);
285 } 285 }
286 286 //
287 @Override 287 @Override
288 public void onAttach(Activity activity) { 288 public void onAttach(Context context) {
289 super.onAttach(activity); 289 super.onAttach(context);
290 View rootView = activity.getWindow().getDecorView(); 290 View rootView = ((Activity)context).getWindow().getDecorView();
291 TextView sub = (TextView) rootView.findViewById(R.id.presonal_sub); 291 TextView sub = (TextView) rootView.findViewById(R.id.presonal_sub);
292 sub.setOnClickListener(this); 292 sub.setOnClickListener(this);
293 } 293 }
294 294
295 @Override 295 @Override
296 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { 296 public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) {
297 String regionName = data.get(position).getRegionName(); 297 String regionName = data.get(position).getRegionName();
298 String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); 298 String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng");
299 SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); 299 SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName);
300 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); 300 CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog");
301 tv_useinfo_adress.setText(""); 301 tv_useinfo_adress.setText("");
302 tv_useinfo_adress.setText(provice + regionName); 302 tv_useinfo_adress.setText(provice + regionName);
303 303
304 304
305 } 305 }
306 306
307 @Override 307 @Override
308 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { 308 public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) {
309 String regionName = data.get(position).getRegionName(); 309 String regionName = data.get(position).getRegionName();
310 String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); 310 String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng");
311 String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); 311 String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi");
312 tv_useinfo_adress.setText(""); 312 tv_useinfo_adress.setText("");
313 tv_useinfo_adress.setText(provices + citys + regionName); 313 tv_useinfo_adress.setText(provices + citys + regionName);
314 314
315 } 315 }
316 316
317 @Override 317 @Override
318 public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { 318 public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) {
319 String regionName = data.get(position).getName(); 319 String regionName = data.get(position).getName();
320 tv_useinfo_gender.setText(regionName); 320 tv_useinfo_gender.setText(regionName);
321 } 321 }
322 322
323 @Override 323 @Override
324 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { 324 public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) {
325 String regionName = data.get(position).getRegionName(); 325 String regionName = data.get(position).getRegionName();
326 SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); 326 SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName);
327 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); 327 CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog");
328 tv_useinfo_adress.setText(""); 328 tv_useinfo_adress.setText("");
329 tv_useinfo_adress.setText(regionName); 329 tv_useinfo_adress.setText(regionName);
330 } 330 }
331 331
332 @Override 332 @Override
333 public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { 333 public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) {
334 String regionName = data.get(position).getSchoolName(); 334 String regionName = data.get(position).getSchoolName();
335 tv_useinfo_school.setText(regionName); 335 tv_useinfo_school.setText(regionName);
336 336
337 337
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/VersionsInfoFragment.java
1 package com.hjx.personalcenter.fragment; 1 package com.hjx.personalcenter.fragment;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context;
4 import android.os.Bundle; 5 import android.os.Bundle;
5 import android.os.Handler; 6 import android.os.Handler;
6 import android.os.Message; 7 import android.os.Message;
7 import android.support.annotation.Nullable; 8 import android.support.annotation.Nullable;
8 import android.support.v4.app.Fragment; 9 import android.support.v4.app.Fragment;
9 import android.util.Log; 10 import android.util.Log;
10 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
11 import android.view.View; 12 import android.view.View;
12 import android.view.ViewGroup; 13 import android.view.ViewGroup;
13 import android.widget.AdapterView; 14 import android.widget.AdapterView;
14 import android.widget.GridView; 15 import android.widget.GridView;
15 import android.widget.TextView; 16 import android.widget.TextView;
16 17
17 import com.facebook.drawee.view.SimpleDraweeView; 18 import com.facebook.drawee.view.SimpleDraweeView;
18 import com.hjx.personalcenter.R; 19 import com.hjx.personalcenter.R;
19 import com.hjx.personalcenter.adapter.GridAdapter; 20 import com.hjx.personalcenter.adapter.GridAdapter;
20 import com.hjx.personalcenter.customdialog.VerSionDialog; 21 import com.hjx.personalcenter.customdialog.VerSionDialog;
21 import com.hjx.personalcenter.db.Content;
22 import com.hjx.personalcenter.db.SaveParam; 22 import com.hjx.personalcenter.db.SaveParam;
23 import com.hjx.personalcenter.http.HttpCode; 23 import com.hjx.personalcenter.http.HttpCode;
24 import com.hjx.personalcenter.http.HttpManager; 24 import com.hjx.personalcenter.http.HttpManager;
25 import com.hjx.personalcenter.interfaces.DialogCallBack;
25 import com.hjx.personalcenter.model.DefautPublishInfo; 26 import com.hjx.personalcenter.model.DefautPublishInfo;
27 import com.hjx.personalcenter.model.VersionInfo;
26 28
27 import java.util.ArrayList; 29 import java.util.ArrayList;
28 import java.util.List; 30 import java.util.List;
29 31
30 /** 32 /**
31 * Created by h on 2017/8/12. 33 * Created by h on 2017/8/12.
32 */ 34 */
33 35
34 public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener, View.OnClickListener { 36 public class VersionsInfoFragment extends Fragment implements AdapterView.OnItemClickListener, View.OnClickListener, DialogCallBack.VersionCallBack {
35 private GridView gridView; 37 private GridView gridView;
36 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); 38 private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>();
37 private GridAdapter sim_adapter; 39 private GridAdapter sim_adapter;
38 private View mView; 40 private View mView;
39 private int type; 41 private int type;
42 private TextView publish;
43 private SimpleDraweeView simpleDraweeView;
40 public static String TABLAYOUT_FRAGMENT = "versionfragment"; 44 public static String TABLAYOUT_FRAGMENT = "versionfragment";
41 45
42 public static VersionsInfoFragment newInstance(int type) { 46 public static VersionsInfoFragment newInstance(int type) {
43 VersionsInfoFragment fragment = new VersionsInfoFragment(); 47 VersionsInfoFragment fragment = new VersionsInfoFragment();
44 Bundle bundle = new Bundle(); 48 Bundle bundle = new Bundle();
45 bundle.putSerializable(TABLAYOUT_FRAGMENT, type); 49 bundle.putSerializable(TABLAYOUT_FRAGMENT, type);
46 fragment.setArguments(bundle); 50 fragment.setArguments(bundle);
47 return fragment; 51 return fragment;
48 52
49 } 53 }
50 Handler handler = new Handler(){ 54 Handler handler = new Handler(){
51 @Override 55 @Override
52 public void handleMessage(Message msg) { 56 public void handleMessage(Message msg) {
53 super.handleMessage(msg); 57 super.handleMessage(msg);
54 switch (msg.what){ 58 switch (msg.what){
55 case HttpCode.PUBLISH_SUCESS: 59 case HttpCode.PUBLISH_SUCESS:
56 defautPublishInfos.clear(); 60 defautPublishInfos.clear();
57 defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj); 61 defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj);
58 sim_adapter.notifyDataSetChanged(); 62 sim_adapter.notifyDataSetChanged();
59 break; 63 break;
60 } 64 }
61 } 65 }
62 }; 66 };
63 @Override 67 @Override
64 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 68 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
65 if (mView == null) { 69 if (mView == null) {
66 mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false); 70 mView = inflater.inflate(R.layout.fragment_changge_version_info, container, false);
67 String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId"); 71 String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId");
68 String graderid = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.GRADENS); 72 String graderid = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.GRADENS);
69 //子账户年级id 73 //子账户年级id
70 String graderidchilds = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.CHILDSGRADENS); 74 String graderidchilds = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSGRADENS);
71 //账户类型 75 //账户类型
72 String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.ACCOUNT); 76 String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.ACCOUNT);
73 try { 77 try {
74 int graderID; 78 int graderID;
75 long auserID = Long.parseLong(userID); 79 long auserID = Long.parseLong(userID);
76 if ("2".equals(accounts)){ 80 if ("2".equals(accounts)){
77 graderID = Integer.parseInt(graderidchilds); 81 graderID = Integer.parseInt(graderidchilds);
78 }else { 82 }else {
79 graderID = Integer.parseInt(graderid); 83 graderID = Integer.parseInt(graderid);
80 } 84 }
81 85
82 //获取版本信息 86 //获取版本信息
83 HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderID,handler); 87 HttpManager.getInstance().getpublishinfo(getActivity(),auserID,graderID,handler);
84 88
85 } catch (NumberFormatException e) { 89 } catch (NumberFormatException e) {
86 e.printStackTrace(); 90 e.printStackTrace();
87 } 91 }
88 92
89 initView(mView); 93 initView(mView);
90 initData(); 94 initData();
91 setLister(); 95 setLister();
92 96
93 97
94 } 98 }
95 return mView; 99 return mView;
96 } 100 }
97 //初始化 101 //初始化
98 private void initView(View mView) { 102 private void initView(View mView) {
99 gridView =(GridView) mView.findViewById(R.id.grideview); 103 gridView =(GridView) mView.findViewById(R.id.grideview);
100 104
101 } 105 }
102 private void initData() { 106 private void initData() {
103 sim_adapter = new GridAdapter(defautPublishInfos,getActivity()); 107 sim_adapter = new GridAdapter(defautPublishInfos,getActivity());
104 //配置适配器 108 //配置适配器
105 gridView.setAdapter(sim_adapter); 109 gridView.setAdapter(sim_adapter);
106 } 110 }
107 111
108 private void setLister() { 112 private void setLister() {
109 gridView.setOnItemClickListener(this); 113 gridView.setOnItemClickListener(this);
110 } 114 }
111 115
112 @Override 116 @Override
113 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 117 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
114 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.SUBJECT,defautPublishInfos.get(position).getSubject()); 118 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.SUBJECT,defautPublishInfos.get(position).getSubject());
115 VerSionDialog.getInstance().show(getChildFragmentManager(), "VerSionDialog"); 119 VerSionDialog.getInstance(this).show(getChildFragmentManager(), "VerSionDialog");
116 120 simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.image_publish);
117 121 publish = (TextView) view.findViewById(R.id.tv_publish);
118 String imgurl = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.IMGURL);
119 String version = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.VERSION);
120 SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.image_publish);
121 TextView publish = (TextView) view.findViewById(R.id.tv_publish);
122 simpleDraweeView.setImageURI(imgurl);
123 publish.setText(version);
124 122
125 } 123 }
126 124
127 @Override 125 @Override
128 public void onAttach(Activity activity) { 126 public void onAttach(Context context) {
129 super.onAttach(activity); 127 super.onAttach(context);
130 View rootView = activity.getWindow().getDecorView(); 128 View rootView = ((Activity)context).getWindow().getDecorView();
131 TextView sub = (TextView) rootView.findViewById(R.id.presonal_sub); 129 TextView sub = (TextView) rootView.findViewById(R.id.presonal_sub);
132 sub.setOnClickListener(this); 130 sub.setOnClickListener(this);
133 } 131 }
134 132
135 133
136 134
137 @Override 135 @Override
138 public void onResume() { 136 public void onResume() {
139 super.onResume(); 137 super.onResume();
140 138
141 } 139 }
142 140
143 @Override 141 @Override
144 public void onClick(View v) { 142 public void onClick(View v) {
145 switch (v.getId()){ 143 switch (v.getId()){
146 case R.id.presonal_sub: 144 case R.id.presonal_sub:
147 if (Content.changeinfoflag ==2){ 145 Log.e("test","你提交版本信息");
148 Log.e("test","你提交版本信息");
149 }
150
151 String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId"); 146 String userID = SaveParam.getInstance().getLoginParam(getActivity(),"userId");
147 String chinese = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.CHINESE);
148 String math = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.MATH);
149 String english = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ENGLISH);
150 String physics = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.PHYSICS);
151 String chemistry = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.CHEMISTRY);
152 String history = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.HISTORY);
153 String geography = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.GEOGRAPHY);
154 String political = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.POLITICAL);
155 String biology = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.BIOLOGY);
156 String science = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.SCIENCE);
152 //子账户id 157 //子账户id
153 String childsidid = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID); 158 String childsidid = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.CHILDSID);
154 //账户类型 159 //账户类型
155 String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.ACCOUNT); 160 String accounts = SaveParam.getInstance().getCustomizeParam(getActivity(),SaveParam.ACCOUNT);
156 try { 161 try {
157 String id = null; 162 String id = null;
158 String piblish = "清华大学出版社"; 163 //String piblish = "清华大学出版社";
159 if ("2".equals(accounts)){ 164 if ("2".equals(accounts)){
160 id =childsidid; 165 id =childsidid;
161 }else { 166 }else {
162 id = userID; 167 id = userID;
163 } 168 }
164 169
165 //修改版本信息 170 //修改版本信息
166 HttpManager.getInstance().changepublishinfo(getActivity(),id,piblish 171 HttpManager.getInstance().changepublishinfo(getActivity(),id,"人民教育出版社"
167 ,piblish,piblish,piblish,piblish,piblish,piblish,piblish,piblish,piblish); 172 ,"人民教育出版社","人民教育出版社","人民教育出版社","人民教育出版社","人民教育出版社",
173 "人民教育出版社","人民教育出版社","人民教育出版社","人民教育出版社");
168 174
169 } catch (NumberFormatException e) { 175 } catch (NumberFormatException e) {
170 e.printStackTrace(); 176 e.printStackTrace();
171 } 177 }
172 178
173 179
174 180
175 break; 181 break;
176 } 182 }
177 183
178 } 184 }
185
186 @Override
187 public void versionOnItemClick(ArrayList<VersionInfo.DataBean> data, int position, int type) {
188 String imageurl = data.get(position).getPressCover();
189 String publishs = data.get(position).getPressName();
190 simpleDraweeView.setImageURI(imageurl);
191 publish.setText(publishs);
192 String subject = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.SUBJECT);
193 Log.e("test","选择的科目"+subject);
194 if ("语文".equals(subject)) {
195 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.CHINESE,publishs);
196 }else {
197 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.CHINESE,publish.getText().toString());
198 }
199 if ("数学".equals(subject)) {
200 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.MATH,publishs);
201 }
202 if ("英语".equals(subject)) {
203 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.ENGLISH,publishs);
204 }
205 if ("物理".equals(subject)) {
206 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.PHYSICS,publishs);
207 }
208 if ("化学".equals(subject)) {
209 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.CHEMISTRY,publishs);
210 }
211 if ("历史".equals(subject)) {
212 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.HISTORY,publishs);
213 }
214 if ("地理".equals(subject)) {
215 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.GEOGRAPHY,publishs);
216 }
217 if ("政治".equals(subject)) {
218 SaveParam.getInstance().saveLoginParam(getActivity(),SaveParam.POLITICAL,publishs);
219 }
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
1 package com.hjx.personalcenter.http; 1 package com.hjx.personalcenter.http;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.app.ProgressDialog; 4 import android.app.ProgressDialog;
5 import android.content.Context; 5 import android.content.Context;
6 import android.content.Intent; 6 import android.content.Intent;
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.Message; 8 import android.os.Message;
9 import android.util.Log; 9 import android.util.Log;
10 import android.view.KeyEvent; 10 import android.view.KeyEvent;
11 import android.widget.Toast; 11 import android.widget.Toast;
12 12
13 import com.google.gson.Gson; 13 import com.google.gson.Gson;
14 import com.hjx.personalcenter.R; 14 import com.hjx.personalcenter.R;
15 import com.hjx.personalcenter.activity.LoginAndRegisterActivity; 15 import com.hjx.personalcenter.activity.LoginAndRegisterActivity;
16 import com.hjx.personalcenter.activity.TheStartPageActivity; 16 import com.hjx.personalcenter.activity.TheStartPageActivity;
17 import com.hjx.personalcenter.db.Content; 17 import com.hjx.personalcenter.db.Content;
18 import com.hjx.personalcenter.db.SaveParam; 18 import com.hjx.personalcenter.db.SaveParam;
19 import com.hjx.personalcenter.gson.GsonTool; 19 import com.hjx.personalcenter.gson.GsonTool;
20 import com.hjx.personalcenter.model.AppVersion; 20 import com.hjx.personalcenter.model.AppVersion;
21 import com.hjx.personalcenter.model.CardInfo; 21 import com.hjx.personalcenter.model.CardInfo;
22 import com.hjx.personalcenter.model.ChildsInfo; 22 import com.hjx.personalcenter.model.ChildsInfo;
23 import com.hjx.personalcenter.model.CityInfo; 23 import com.hjx.personalcenter.model.CityInfo;
24 import com.hjx.personalcenter.model.CountyInfo; 24 import com.hjx.personalcenter.model.CountyInfo;
25 import com.hjx.personalcenter.model.DefautPublishInfo; 25 import com.hjx.personalcenter.model.DefautPublishInfo;
26 import com.hjx.personalcenter.model.GradeInfo; 26 import com.hjx.personalcenter.model.GradeInfo;
27 import com.hjx.personalcenter.model.PesonalInfo; 27 import com.hjx.personalcenter.model.PesonalInfo;
28 import com.hjx.personalcenter.model.ProvinceInfo; 28 import com.hjx.personalcenter.model.ProvinceInfo;
29 import com.hjx.personalcenter.model.SchoolInfo; 29 import com.hjx.personalcenter.model.SchoolInfo;
30 import com.hjx.personalcenter.model.SignInfo; 30 import com.hjx.personalcenter.model.SignInfo;
31 import com.hjx.personalcenter.model.VersionInfo; 31 import com.hjx.personalcenter.model.VersionInfo;
32 import com.hjx.personalcenter.model.VideoInfo; 32 import com.hjx.personalcenter.model.VideoInfo;
33 import com.hjx.personalcenter.util.AlertUtils; 33 import com.hjx.personalcenter.util.AlertUtils;
34 import com.hjx.personalcenter.util.DialogPermission; 34 import com.hjx.personalcenter.util.DialogPermission;
35 import com.loopj.android.http.AsyncHttpResponseHandler; 35 import com.loopj.android.http.AsyncHttpResponseHandler;
36 import com.loopj.android.http.JsonHttpResponseHandler; 36 import com.loopj.android.http.JsonHttpResponseHandler;
37 import com.loopj.android.http.RequestParams; 37 import com.loopj.android.http.RequestParams;
38 38
39 import org.apache.http.Header; 39 import org.apache.http.Header;
40 import org.apache.http.entity.ByteArrayEntity; 40 import org.apache.http.entity.ByteArrayEntity;
41 import org.apache.http.message.BasicHeader; 41 import org.apache.http.message.BasicHeader;
42 import org.apache.http.protocol.HTTP; 42 import org.apache.http.protocol.HTTP;
43 import org.json.JSONException; 43 import org.json.JSONException;
44 import org.json.JSONObject; 44 import org.json.JSONObject;
45 45
46 import java.io.File; 46 import java.io.File;
47 import java.io.FileNotFoundException; 47 import java.io.FileNotFoundException;
48 import java.io.UnsupportedEncodingException; 48 import java.io.UnsupportedEncodingException;
49 import java.util.ArrayList; 49 import java.util.ArrayList;
50 import java.util.List; 50 import java.util.List;
51 51
52 public class HttpManager { 52 public class HttpManager {
53 private static HttpManager instance; 53 private static HttpManager instance;
54 private ProgressDialog mProgress = null; 54 private ProgressDialog mProgress = null;
55 55
56 public static HttpManager getInstance() { 56 public static HttpManager getInstance() {
57 if (instance == null) { 57 if (instance == null) {
58 instance = new HttpManager(); 58 instance = new HttpManager();
59 } 59 }
60 return instance; 60 return instance;
61 } 61 }
62 62
63 63
64 //登录接口 64 //登录接口
65 65
66 public void login(final String username, final String password, final Context mContext, final Handler handler) { 66 public void login(final String username, final String password, final Context mContext, final Handler handler) {
67 mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", 67 mProgress = DialogPermission.showProgress(mContext, null, "正在登录...",
68 false, true, null); 68 true, true, null);
69 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 69 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
70 HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { 70 HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() {
71 @Override 71 @Override
72 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 72 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
73 closeProgress(); 73 closeProgress();
74 Message msg = Message.obtain(); 74 Message msg = Message.obtain();
75 msg.what = HttpCode.LOGIN_SUCESS; 75 msg.what = HttpCode.LOGIN_SUCESS;
76 msg.obj = new String(arg2); 76 msg.obj = new String(arg2);
77 handler.sendMessage(msg); 77 handler.sendMessage(msg);
78 78
79 79
80 } 80 }
81 81
82 @Override 82 @Override
83 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 83 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
84 closeProgress(); 84 closeProgress();
85 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 85 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
86 } 86 }
87 }); 87 });
88 } 88 }
89 89
90 //注册接口 90 //注册接口
91 public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { 91 public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) {
92 mProgress = DialogPermission.showProgress(context, null, "正在注册...", 92 mProgress = DialogPermission.showProgress(context, null, "正在注册...",
93 false, true, null); 93 false, true, null);
94 JSONObject jsonObject = new JSONObject(); 94 JSONObject jsonObject = new JSONObject();
95 ByteArrayEntity entity = null; 95 ByteArrayEntity entity = null;
96 try { 96 try {
97 jsonObject.put(HttpKey.USERNAME, username); 97 jsonObject.put(HttpKey.USERNAME, username);
98 jsonObject.put(HttpKey.PASSWORD, password); 98 jsonObject.put(HttpKey.PASSWORD, password);
99 jsonObject.put(HttpKey.SMSCODE, smscode); 99 jsonObject.put(HttpKey.SMSCODE, smscode);
100 jsonObject.put(HttpKey.SOURCE, source); 100 jsonObject.put(HttpKey.SOURCE, source);
101 Log.e("test", "jsonObject" + jsonObject); 101 Log.e("test", "jsonObject" + jsonObject);
102 entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); 102 entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8"));
103 entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); 103 entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
104 } catch (JSONException e) { 104 } catch (JSONException e) {
105 e.printStackTrace(); 105 e.printStackTrace();
106 } catch (UnsupportedEncodingException e) { 106 } catch (UnsupportedEncodingException e) {
107 e.printStackTrace(); 107 e.printStackTrace();
108 } 108 }
109 HttpClient.getInstance().addHeader("Accept", "*/*"); 109 HttpClient.getInstance().addHeader("Accept", "*/*");
110 HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { 110 HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() {
111 @Override 111 @Override
112 public void onSuccess(int statusCode, Header[] headers, JSONObject response) { 112 public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
113 super.onSuccess(statusCode, headers, response); 113 super.onSuccess(statusCode, headers, response);
114 closeProgress(); 114 closeProgress();
115 Log.e("test", "onSuccess" + response); 115 Log.e("test", "onSuccess" + response);
116 Message msg = Message.obtain(); 116 Message msg = Message.obtain();
117 msg.what = HttpCode.REGISTERED_SUCESS; 117 msg.what = HttpCode.REGISTERED_SUCESS;
118 msg.obj = response; 118 msg.obj = response;
119 handler.sendMessage(msg); 119 handler.sendMessage(msg);
120 120
121 } 121 }
122 122
123 @Override 123 @Override
124 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { 124 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
125 super.onFailure(statusCode, headers, throwable, errorResponse); 125 super.onFailure(statusCode, headers, throwable, errorResponse);
126 closeProgress(); 126 closeProgress();
127 Log.e("test", "onFailure" + errorResponse); 127 Log.e("test", "onFailure" + errorResponse);
128 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); 128 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!");
129 } 129 }
130 130
131 }); 131 });
132 } 132 }
133 133
134 //注册验证码 134 //注册验证码
135 public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { 135 public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) {
136 RequestParams params = new RequestParams(); 136 RequestParams params = new RequestParams();
137 params.put(HttpKey.TYPE, type); 137 params.put(HttpKey.TYPE, type);
138 params.put(HttpKey.MOBIL, mobile); 138 params.put(HttpKey.MOBIL, mobile);
139 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 139 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
140 HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { 140 HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() {
141 141
142 @Override 142 @Override
143 public void onSuccess(int statusCode, Header[] headers, JSONObject response) { 143 public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
144 Log.e("test", "onSuccess-----" + response); 144 Log.e("test", "onSuccess-----" + response);
145 Message msg = Message.obtain(); 145 Message msg = Message.obtain();
146 msg.what = HttpCode.AUTHCODE_SUCESS; 146 msg.what = HttpCode.AUTHCODE_SUCESS;
147 msg.obj = response; 147 msg.obj = response;
148 handler.sendMessage(msg); 148 handler.sendMessage(msg);
149 } 149 }
150 150
151 @Override 151 @Override
152 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { 152 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
153 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 153 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
154 } 154 }
155 }); 155 });
156 } 156 }
157 157
158 158
159 //手机号是否注册 159 //手机号是否注册
160 public void isregistered(final String mobile, final Handler handler, final Context mContext) { 160 public void isregistered(final String mobile, final Handler handler, final Context mContext) {
161 RequestParams params = new RequestParams(); 161 RequestParams params = new RequestParams();
162 params.put(HttpKey.USERNAME, mobile); 162 params.put(HttpKey.USERNAME, mobile);
163 HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { 163 HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() {
164 @Override 164 @Override
165 public void onSuccess(int statusCode, Header[] headers, JSONObject response) { 165 public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
166 Log.e("test", "isregistered" + response.toString()); 166 Log.e("test", "isregistered" + response.toString());
167 Message msg = Message.obtain(); 167 Message msg = Message.obtain();
168 msg.what = HttpCode.IS_REFISTER; 168 msg.what = HttpCode.IS_REFISTER;
169 msg.obj = response; 169 msg.obj = response;
170 handler.sendMessage(msg); 170 handler.sendMessage(msg);
171 171
172 } 172 }
173 173
174 @Override 174 @Override
175 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { 175 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
176 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 176 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
177 177
178 } 178 }
179 }); 179 });
180 } 180 }
181 181
182 //修改密码 182 //修改密码
183 public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { 183 public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) {
184 RequestParams params = new RequestParams(); 184 RequestParams params = new RequestParams();
185 params.put(HttpKey.USERNAME, username); 185 params.put(HttpKey.USERNAME, username);
186 params.put(HttpKey.OLDPASS, old_pwd1); 186 params.put(HttpKey.OLDPASS, old_pwd1);
187 params.put(HttpKey.NEWPASS, newpassword3); 187 params.put(HttpKey.NEWPASS, newpassword3);
188 HttpClient.getInstance().addHeader("Accept", "*/*"); 188 HttpClient.getInstance().addHeader("Accept", "*/*");
189 HttpClient.getInstance().setTimeout(10 * 1000); 189 HttpClient.getInstance().setTimeout(10 * 1000);
190 HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { 190 HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() {
191 @Override 191 @Override
192 public void onSuccess(int i, Header[] headers, byte[] bytes) { 192 public void onSuccess(int i, Header[] headers, byte[] bytes) {
193 try { 193 try {
194 JSONObject jsonObject = new JSONObject(new String(bytes)); 194 JSONObject jsonObject = new JSONObject(new String(bytes));
195 String status = jsonObject.optString("status"); 195 String status = jsonObject.optString("status");
196 if (status.equals("100")) { 196 if (status.equals("100")) {
197 Log.e("test", "onSuccess" + new String(bytes)); 197 Log.e("test", "onSuccess" + new String(bytes));
198 Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); 198 Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show();
199 SaveParam.getInstance().clearData((Activity) context); 199 SaveParam.getInstance().clearData((Activity) context);
200 Intent intent = new Intent(); 200 Intent intent = new Intent();
201 intent.setClass(context, LoginAndRegisterActivity.class); 201 intent.setClass(context, LoginAndRegisterActivity.class);
202 ((Activity) context).startActivity(intent); 202 ((Activity) context).startActivity(intent);
203 ((Activity) context).finish(); 203 ((Activity) context).finish();
204 } else { 204 } else {
205 Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); 205 Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show();
206 } 206 }
207 } catch (JSONException e) { 207 } catch (JSONException e) {
208 e.printStackTrace(); 208 e.printStackTrace();
209 } 209 }
210 } 210 }
211 211
212 @Override 212 @Override
213 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 213 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
214 Log.e("test", "onFailure" + new String(bytes)); 214 Log.e("test", "onFailure" + new String(bytes));
215 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); 215 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!");
216 } 216 }
217 }); 217 });
218 218
219 } 219 }
220 220
221 //忘记密码 221 //忘记密码
222 public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { 222 public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) {
223 RequestParams params = new RequestParams(); 223 RequestParams params = new RequestParams();
224 params.put(HttpKey.USERNAME, forot_pwd_phone1); 224 params.put(HttpKey.USERNAME, forot_pwd_phone1);
225 params.put(HttpKey.PASSWORD, forot_pwd_pwd3); 225 params.put(HttpKey.PASSWORD, forot_pwd_pwd3);
226 params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); 226 params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1);
227 HttpClient.getInstance().addHeader("Accept", "*/*"); 227 HttpClient.getInstance().addHeader("Accept", "*/*");
228 HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { 228 HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() {
229 @Override 229 @Override
230 public void onSuccess(int i, Header[] headers, byte[] bytes) { 230 public void onSuccess(int i, Header[] headers, byte[] bytes) {
231 try { 231 try {
232 JSONObject jsonObject = new JSONObject(new String(bytes)); 232 JSONObject jsonObject = new JSONObject(new String(bytes));
233 String status = jsonObject.optString("status"); 233 String status = jsonObject.optString("status");
234 if (status.equals("100")) { 234 if (status.equals("100")) {
235 Log.e("test", "onSuccess" + new String(bytes)); 235 Log.e("test", "onSuccess" + new String(bytes));
236 Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); 236 Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show();
237 ((Activity) context).finish(); 237 ((Activity) context).finish();
238 } else { 238 } else {
239 Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); 239 Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show();
240 } 240 }
241 } catch (JSONException e) { 241 } catch (JSONException e) {
242 e.printStackTrace(); 242 e.printStackTrace();
243 } 243 }
244 } 244 }
245 245
246 @Override 246 @Override
247 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 247 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
248 Log.e("test", "onFailure" + new String(bytes)); 248 Log.e("test", "onFailure" + new String(bytes));
249 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); 249 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!");
250 } 250 }
251 }); 251 });
252 252
253 } 253 }
254 254
255 //保存用户登录信息 255 //保存用户登录信息
256 public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) { 256 public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) {
257 SaveParam.getInstance().saveLoginParam(context, "username", username); 257 SaveParam.getInstance().saveLoginParam(context, "username", username);
258 SaveParam.getInstance().saveLoginParam(context, "password", password); 258 SaveParam.getInstance().saveLoginParam(context, "password", password);
259 SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); 259 SaveParam.getInstance().saveLoginParam(context, "access_token", access_token);
260 SaveParam.getInstance().saveLoginParam(context, "userId", userId); 260 SaveParam.getInstance().saveLoginParam(context, "userId", userId);
261 261
262 262
263 } 263 }
264 264
265 //提交保卡信息 265 //提交保卡信息
266 public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, 266 public void subcardinfo(final Context context, long userId, String customerName, String customerAddress,
267 String buyAddress, String buyTime, String alterSaleCall, 267 String buyAddress, String buyTime, String alterSaleCall,
268 String productModel, String deviceNumber, String macAddress, 268 String productModel, String deviceNumber, String macAddress,
269 String mobilePhone) { 269 String mobilePhone) {
270 mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", 270 mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...",
271 false, true, null); 271 false, true, null);
272 RequestParams params = new RequestParams(); 272 RequestParams params = new RequestParams();
273 273
274 params.put(HttpKey.USEID, userId); 274 params.put(HttpKey.USEID, userId);
275 params.put(HttpKey.CUSTOMENAME, customerName); 275 params.put(HttpKey.CUSTOMENAME, customerName);
276 params.put(HttpKey.CUSTOMADRESS, customerAddress); 276 params.put(HttpKey.CUSTOMADRESS, customerAddress);
277 params.put(HttpKey.BUYADREES, buyAddress); 277 params.put(HttpKey.BUYADREES, buyAddress);
278 params.put(HttpKey.BUYTIME, buyTime); 278 params.put(HttpKey.BUYTIME, buyTime);
279 params.put(HttpKey.ALTERSALECALL, alterSaleCall); 279 params.put(HttpKey.ALTERSALECALL, alterSaleCall);
280 params.put(HttpKey.PRODUCTMODEL, productModel); 280 params.put(HttpKey.PRODUCTMODEL, productModel);
281 params.put(HttpKey.DEVICENUMBER, deviceNumber); 281 params.put(HttpKey.DEVICENUMBER, deviceNumber);
282 params.put(HttpKey.MACADRESS, macAddress); 282 params.put(HttpKey.MACADRESS, macAddress);
283 params.put(HttpKey.MOBILPHONE, mobilePhone); 283 params.put(HttpKey.MOBILPHONE, mobilePhone);
284 284
285 HttpClient.getInstance().addHeader("Accept", "*/*"); 285 HttpClient.getInstance().addHeader("Accept", "*/*");
286 286
287 Log.e("test", "params" + params); 287 Log.e("test", "params" + params);
288 HttpClient.getInstance().setTimeout(5 * 1000); 288 HttpClient.getInstance().setTimeout(5 * 1000);
289 HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { 289 HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() {
290 @Override 290 @Override
291 public void onSuccess(int i, Header[] headers, byte[] bytes) { 291 public void onSuccess(int i, Header[] headers, byte[] bytes) {
292 JSONObject jsonObject = null; 292 JSONObject jsonObject = null;
293 closeProgress(); 293 closeProgress();
294 try { 294 try {
295 jsonObject = new JSONObject(new String(bytes)); 295 jsonObject = new JSONObject(new String(bytes));
296 String status = jsonObject.optString("status"); 296 String status = jsonObject.optString("status");
297 if (status.equals("1")) { 297 if (status.equals("1")) {
298 Log.e("test", "onSuccess" + jsonObject); 298 Log.e("test", "onSuccess" + jsonObject);
299 Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); 299 Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show();
300 Intent intent = new Intent(); 300 Intent intent = new Intent();
301 intent.setClass((Activity) context, TheStartPageActivity.class); 301 intent.setClass((Activity) context, TheStartPageActivity.class);
302 ((Activity) context).startActivity(intent); 302 ((Activity) context).startActivity(intent);
303 ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); 303 ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout);
304 ((Activity) context).finish(); 304 ((Activity) context).finish();
305 } else { 305 } else {
306 Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); 306 Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show();
307 } 307 }
308 } catch (JSONException e) { 308 } catch (JSONException e) {
309 e.printStackTrace(); 309 e.printStackTrace();
310 } 310 }
311 311
312 312
313 } 313 }
314 314
315 @Override 315 @Override
316 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 316 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
317 Log.e("test", "onFailure" + (throwable)); 317 Log.e("test", "onFailure" + (throwable));
318 closeProgress(); 318 closeProgress();
319 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); 319 AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!");
320 320
321 } 321 }
322 }); 322 });
323 323
324 } 324 }
325 325
326 //获取保卡信息 326 //获取保卡信息
327 public void getcardinfo(final Context mContext, long userId, final Handler handler) { 327 public void getcardinfo(final Context mContext, long userId, final Handler handler) {
328 mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", 328 mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...",
329 false, true, null); 329 false, true, null);
330 HttpClient.getInstance().setTimeout(5 * 1000); 330 HttpClient.getInstance().setTimeout(5 * 1000);
331 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 331 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
332 HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { 332 HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() {
333 @Override 333 @Override
334 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 334 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
335 closeProgress(); 335 closeProgress();
336 Log.e("test", "保卡信息" + new String(arg2)); 336 Log.e("test", "保卡信息" + new String(arg2));
337 try { 337 try {
338 JSONObject jsonObject = new JSONObject(new String(arg2)); 338 JSONObject jsonObject = new JSONObject(new String(arg2));
339 int status = jsonObject.optInt("status"); 339 int status = jsonObject.optInt("status");
340 if (status == 1) { 340 if (status == 1) {
341 CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 341 CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据
342 CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); 342 CardInfo.DataBean schoolInfoBeanList = cardInfo.getData();
343 Message msg = Message.obtain(); 343 Message msg = Message.obtain();
344 msg.what = HttpCode.SUCHCARDINFO; 344 msg.what = HttpCode.SUCHCARDINFO;
345 msg.obj = schoolInfoBeanList; 345 msg.obj = schoolInfoBeanList;
346 handler.sendMessage(msg); 346 handler.sendMessage(msg);
347 347
348 348
349 } else { 349 } else {
350 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 350 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
351 351
352 } 352 }
353 } catch (JSONException e) { 353 } catch (JSONException e) {
354 e.printStackTrace(); 354 e.printStackTrace();
355 } 355 }
356 356
357 } 357 }
358 358
359 @Override 359 @Override
360 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 360 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
361 closeProgress(); 361 closeProgress();
362 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 362 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
363 } 363 }
364 }); 364 });
365 } 365 }
366 366
367 //修改保卡信息电话 367 //修改保卡信息电话
368 public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { 368 public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) {
369 RequestParams params = new RequestParams(); 369 RequestParams params = new RequestParams();
370 params.put("userId", userId); 370 params.put("userId", userId);
371 params.put("customerPhone", customerPhone); 371 params.put("customerPhone", customerPhone);
372 params.put("authCode", authCode); 372 params.put("authCode", authCode);
373 HttpClient.getInstance().addHeader("Accept", "*/*"); 373 HttpClient.getInstance().addHeader("Accept", "*/*");
374 HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { 374 HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() {
375 @Override 375 @Override
376 public void onSuccess(int i, Header[] headers, byte[] bytes) { 376 public void onSuccess(int i, Header[] headers, byte[] bytes) {
377 try { 377 try {
378 JSONObject jsonObject = new JSONObject(new String(bytes)); 378 JSONObject jsonObject = new JSONObject(new String(bytes));
379 String status = jsonObject.optString("status"); 379 String status = jsonObject.optString("status");
380 if (status.equals("1")) { 380 if (status.equals("1")) {
381 Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); 381 Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show();
382 if (Content.authcodeflag==2){ 382 if (Content.authcodeflag==2){
383 SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); 383 SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone);
384 }else if (Content.authcodeflag==1){ 384 }else if (Content.authcodeflag==1){
385 SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); 385 SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone);
386 }else { 386 }else {
387 AlertUtils.showToast(mContext, "修改未知的手机号"); 387 AlertUtils.showToast(mContext, "修改未知的手机号");
388 } 388 }
389 ((Activity) mContext).finish(); 389 ((Activity) mContext).finish();
390 } else if (status.equals("1001")) { 390 } else if (status.equals("1001")) {
391 Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); 391 Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show();
392 } else { 392 } else {
393 AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); 393 AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试");
394 } 394 }
395 } catch (JSONException e) { 395 } catch (JSONException e) {
396 e.printStackTrace(); 396 e.printStackTrace();
397 } 397 }
398 } 398 }
399 399
400 @Override 400 @Override
401 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 401 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
402 Log.e("test", "onFailure" + new String(bytes)); 402 Log.e("test", "onFailure" + new String(bytes));
403 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 403 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
404 } 404 }
405 }); 405 });
406 } 406 }
407 407
408 //修改保卡信息地址 408 //修改保卡信息地址
409 public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { 409 public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) {
410 RequestParams params = new RequestParams(); 410 RequestParams params = new RequestParams();
411 params.put("userId", userId); 411 params.put("userId", userId);
412 params.put("customerPhone", customerPhone); 412 params.put("customerPhone", customerPhone);
413 params.put("authCode", authCode); 413 params.put("authCode", authCode);
414 params.put("customerAddress", customerAddress); 414 params.put("customerAddress", customerAddress);
415 HttpClient.getInstance().addHeader("Accept", "*/*"); 415 HttpClient.getInstance().addHeader("Accept", "*/*");
416 HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { 416 HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() {
417 @Override 417 @Override
418 public void onSuccess(int i, Header[] headers, byte[] bytes) { 418 public void onSuccess(int i, Header[] headers, byte[] bytes) {
419 try { 419 try {
420 JSONObject jsonObject = new JSONObject(new String(bytes)); 420 JSONObject jsonObject = new JSONObject(new String(bytes));
421 String status = jsonObject.optString("status"); 421 String status = jsonObject.optString("status");
422 if (status.equals("1")) { 422 if (status.equals("1")) {
423 Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); 423 Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show();
424 SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); 424 SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress);
425 ((Activity) mContext).finish(); 425 ((Activity) mContext).finish();
426 } else { 426 } else {
427 AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); 427 AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试");
428 } 428 }
429 } catch (JSONException e) { 429 } catch (JSONException e) {
430 e.printStackTrace(); 430 e.printStackTrace();
431 } 431 }
432 } 432 }
433 433
434 @Override 434 @Override
435 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 435 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
436 Log.e("test", "onFailure" + new String(bytes)); 436 Log.e("test", "onFailure" + new String(bytes));
437 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 437 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
438 } 438 }
439 }); 439 });
440 } 440 }
441 441
442 //验证是否保卡信息 442 //验证是否保卡信息
443 public void cardinfocheck(final Context mContext, long userId, final Handler handler) { 443 public void cardinfocheck(final Context mContext, long userId, final Handler handler) {
444 mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", 444 mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...",
445 false, true, null); 445 false, true, null);
446 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 446 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
447 HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { 447 HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() {
448 @Override 448 @Override
449 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 449 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
450 Log.e("test", "---" + new String(arg2)); 450 Log.e("test", "---" + new String(arg2));
451 closeProgress(); 451 closeProgress();
452 Message msg = Message.obtain(); 452 Message msg = Message.obtain();
453 msg.what = HttpCode.CHECKCARD; 453 msg.what = HttpCode.CHECKCARD;
454 msg.obj = new String(arg2); 454 msg.obj = new String(arg2);
455 handler.sendMessage(msg); 455 handler.sendMessage(msg);
456 456
457 457
458 } 458 }
459 459
460 @Override 460 @Override
461 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 461 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
462 closeProgress(); 462 closeProgress();
463 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 463 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
464 //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); 464 //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show();
465 } 465 }
466 }); 466 });
467 } 467 }
468 468
469 ///获取年级 469 ///获取年级
470 public void getgrade(final Context mContext, final Handler handler) { 470 public void getgrade(final Context mContext, final Handler handler) {
471 HttpClient.getInstance().addHeader("Accept", "application/json"); 471 HttpClient.getInstance().addHeader("Accept", "application/json");
472 HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { 472 HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() {
473 @Override 473 @Override
474 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 474 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
475 Log.e("test", "年级" + new String(arg2)); 475 Log.e("test", "年级" + new String(arg2));
476 GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 476 GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据
477 List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); 477 List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>();
478 for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { 478 for (int i = 0; i < gradeInfo.getData().size() - 2; i++) {
479 String name = gradeInfo.getData().get(i).getName(); 479 String name = gradeInfo.getData().get(i).getName();
480 int id = gradeInfo.getData().get(i).getId(); 480 int id = gradeInfo.getData().get(i).getId();
481 List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); 481 List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren();
482 for (int j = 0; j < gradeinfoList.size(); j++) { 482 for (int j = 0; j < gradeinfoList.size(); j++) {
483 String secondname = gradeinfoList.get(j).getName(); 483 String secondname = gradeinfoList.get(j).getName();
484 int secondid = gradeinfoList.get(j).getId(); 484 int secondid = gradeinfoList.get(j).getId();
485 GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); 485 GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean();
486 dataBean.setName(secondname); 486 dataBean.setName(secondname);
487 dataBean.setId(secondid); 487 dataBean.setId(secondid);
488 gradeInfoLists.add(dataBean); 488 gradeInfoLists.add(dataBean);
489 } 489 }
490 490
491 } 491 }
492 492
493 Message message = Message.obtain(); 493 Message message = Message.obtain();
494 message.what = HttpCode.GRADER; 494 message.what = HttpCode.GRADER;
495 message.obj = gradeInfoLists; 495 message.obj = gradeInfoLists;
496 handler.sendMessage(message); 496 handler.sendMessage(message);
497 497
498 498
499 } 499 }
500 500
501 @Override 501 @Override
502 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 502 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
503 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 503 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
504 } 504 }
505 }); 505 });
506 } 506 }
507 507
508 /** 508 /**
509 * 获取学校 509 * 获取学校
510 * 510 *
511 * @param mContext 511 * @param mContext
512 * @param regionId 512 * @param regionId
513 * @param gradeId 513 * @param gradeId
514 * @param handler 514 * @param handler
515 */ 515 */
516 public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { 516 public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) {
517 HttpClient.getInstance().addHeader("Accept", "application/json"); 517 HttpClient.getInstance().addHeader("Accept", "application/json");
518 HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { 518 HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() {
519 @Override 519 @Override
520 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 520 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
521 Log.e("test", "学校" + new String(arg2)); 521 Log.e("test", "学校" + new String(arg2));
522 try { 522 try {
523 JSONObject jsonObject = new JSONObject(new String(arg2)); 523 JSONObject jsonObject = new JSONObject(new String(arg2));
524 int status = jsonObject.optInt("status"); 524 int status = jsonObject.optInt("status");
525 if (status == 1) { 525 if (status == 1) {
526 SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 526 SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据
527 List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); 527 List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData();
528 Message message = Message.obtain(); 528 Message message = Message.obtain();
529 message.what = HttpCode.SCHOOL; 529 message.what = HttpCode.SCHOOL;
530 message.obj = schoolInfoBeanList; 530 message.obj = schoolInfoBeanList;
531 handler.sendMessage(message); 531 handler.sendMessage(message);
532 532
533 533
534 } else { 534 } else {
535 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 535 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
536 536
537 } 537 }
538 } catch (JSONException e) { 538 } catch (JSONException e) {
539 e.printStackTrace(); 539 e.printStackTrace();
540 } 540 }
541 541
542 } 542 }
543 543
544 @Override 544 @Override
545 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 545 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
546 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 546 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
547 } 547 }
548 }); 548 });
549 } 549 }
550 550
551 551
552 /** 552 /**
553 * 获取个人信息 553 * 获取个人信息
554 * 554 *
555 * @param mContext 555 * @param mContext
556 * @param userId 556 * @param userId
557 * @param handler 557 * @param handler
558 */ 558 */
559 public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { 559 public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) {
560 // mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", 560 // mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...",
561 // false, true, null); 561 // false, true, null);
562 HttpClient.getInstance().addHeader("Accept", "application/json"); 562 HttpClient.getInstance().addHeader("Accept", "application/json");
563 HttpClient.getInstance().setConnectTimeout(5 * 1000); 563 HttpClient.getInstance().setConnectTimeout(5 * 1000);
564 HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { 564 HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() {
565 @Override 565 @Override
566 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 566 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
567 closeProgress(); 567 closeProgress();
568 Log.e("test", "个人信息" + new String(arg2)); 568 Log.e("test", "个人信息" + new String(arg2));
569 try { 569 try {
570 JSONObject jsonObject = new JSONObject(new String(arg2)); 570 JSONObject jsonObject = new JSONObject(new String(arg2));
571 int status = jsonObject.optInt("status"); 571 int status = jsonObject.optInt("status");
572 if (status == 1) { 572 if (status == 1) {
573 PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 573 PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据
574 PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); 574 PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData();
575 Message message = Message.obtain(); 575 Message message = Message.obtain();
576 message.what = HttpCode.GETINFO; 576 message.what = HttpCode.GETINFO;
577 message.obj = pesonalInfoBeanList; 577 message.obj = pesonalInfoBeanList;
578 handler.sendMessage(message); 578 handler.sendMessage(message);
579 579
580 580
581 } else { 581 } else {
582 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 582 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
583 583
584 } 584 }
585 } catch (JSONException e) { 585 } catch (JSONException e) {
586 e.printStackTrace(); 586 e.printStackTrace();
587 } 587 }
588 588
589 589
590 } 590 }
591 591
592 @Override 592 @Override
593 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 593 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
594 closeProgress(); 594 closeProgress();
595 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 595 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
596 } 596 }
597 }); 597 });
598 } 598 }
599 599
600 //修改个人信息 600 //修改个人信息
601 public void changepresonalinfo(final Context mContext, Long id, int type 601 public void changepresonalinfo(final Context mContext, Long id, int type
602 , String name, String birthday, int gradeId, long regionId, 602 , String name, String birthday, int gradeId, long regionId,
603 Object schoolId, String qq, String gender 603 Object schoolId, String qq, String gender
604 , String regionName, String devicenumber) throws UnsupportedEncodingException { 604 , String regionName, String devicenumber) throws UnsupportedEncodingException {
605 mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", 605 mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...",
606 false, true, null); 606 false, true, null);
607 RequestParams params = new RequestParams(); 607 RequestParams params = new RequestParams();
608 608
609 params.put(HttpKey.USEID, id); 609 params.put(HttpKey.USEID, id);
610 params.put(HttpKey.TYPE, type); 610 params.put(HttpKey.TYPE, type);
611 params.put(HttpKey.NAME, name); 611 params.put(HttpKey.NAME, name);
612 params.put(HttpKey.BIRDays, birthday); 612 params.put(HttpKey.BIRDays, birthday);
613 params.put(HttpKey.GRADE, gradeId); 613 params.put(HttpKey.GRADE, gradeId);
614 params.put(HttpKey.REGION, regionId); 614 params.put(HttpKey.REGION, regionId);
615 params.put(HttpKey.SCHOOL, schoolId); 615 params.put(HttpKey.SCHOOL, schoolId);
616 params.put(HttpKey.QQ, qq); 616 params.put(HttpKey.QQ, qq);
617 params.put(HttpKey.GENDER, gender); 617 params.put(HttpKey.GENDER, gender);
618 params.put(HttpKey.REGIONNAME, regionName); 618 params.put(HttpKey.REGIONNAME, regionName);
619 params.put(HttpKey.DEVINUMBER, devicenumber); 619 params.put(HttpKey.DEVINUMBER, devicenumber);
620 Log.e("test", "个人信息" + params); 620 Log.e("test", "个人信息" + params);
621 HttpClient.getInstance().addHeader("Accept", "*/*"); 621 HttpClient.getInstance().addHeader("Accept", "*/*");
622 HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { 622 HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() {
623 @Override 623 @Override
624 public void onSuccess(int statusCode, Header[] headers, JSONObject response) { 624 public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
625 super.onSuccess(statusCode, headers, response); 625 super.onSuccess(statusCode, headers, response);
626 closeProgress(); 626 closeProgress();
627 String status = response.optString("status"); 627 String status = response.optString("status");
628 if (status.equals("1")) { 628 if (status.equals("1")) {
629 Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); 629 Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show();
630 ((Activity) mContext).finish(); 630 ((Activity) mContext).finish();
631 } else { 631 } else {
632 AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); 632 AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试");
633 } 633 }
634 634
635 } 635 }
636 636
637 @Override 637 @Override
638 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { 638 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
639 super.onFailure(statusCode, headers, throwable, errorResponse); 639 super.onFailure(statusCode, headers, throwable, errorResponse);
640 closeProgress(); 640 closeProgress();
641 Log.e("test", "onFailure" + errorResponse); 641 Log.e("test", "onFailure" + errorResponse);
642 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 642 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
643 } 643 }
644 644
645 }); 645 });
646 } 646 }
647 //提交注册信息 647 //提交注册信息
648 public void subregisterinfo(final Context mContext, Long userId 648 public void subregisterinfo(final Context mContext, Long userId
649 , String name, int gradeId, long regionId, String regionName, Object schoolId, 649 , String name, int gradeId, long regionId, String regionName, Object schoolId,
650 String math, String english, String physics, String chinese, String chemistry, 650 String math, String english, String physics, String chinese, String chemistry,
651 String history, String geography, String political, String biology, String science, final Handler handler){ 651 String history, String geography, String political, String biology, String science, final Handler handler){
652 mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", 652 mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...",
653 false, true, null); 653 false, true, null);
654 RequestParams params = new RequestParams(); 654 RequestParams params = new RequestParams();
655 655
656 params.put(HttpKey.USEID, userId); 656 params.put(HttpKey.USEID, userId);
657 params.put(HttpKey.NAME, name); 657 params.put(HttpKey.NAME, name);
658 params.put(HttpKey.GRADE, gradeId); 658 params.put(HttpKey.GRADE, gradeId);
659 params.put(HttpKey.REGION, regionId); 659 params.put(HttpKey.REGION, regionId);
660 params.put(HttpKey.SCHOOL, schoolId); 660 params.put(HttpKey.SCHOOL, schoolId);
661 params.put(HttpKey.REGIONNAME, regionName); 661 params.put(HttpKey.REGIONNAME, regionName);
662 params.put(HttpKey.MATH, math); 662 params.put(HttpKey.MATH, math);
663 params.put(HttpKey.ENGLISH, english); 663 params.put(HttpKey.ENGLISH, english);
664 params.put(HttpKey.PHYSICES, physics); 664 params.put(HttpKey.PHYSICES, physics);
665 params.put(HttpKey.CHINESE, chinese); 665 params.put(HttpKey.CHINESE, chinese);
666 params.put(HttpKey.CHEMISTRY, chemistry); 666 params.put(HttpKey.CHEMISTRY, chemistry);
667 params.put(HttpKey.HISTIRY, history); 667 params.put(HttpKey.HISTIRY, history);
668 params.put(HttpKey.GEOGRAPHY, geography); 668 params.put(HttpKey.GEOGRAPHY, geography);
669 params.put(HttpKey.POLITICAL, political); 669 params.put(HttpKey.POLITICAL, political);
670 params.put(HttpKey.BIOLOGY, biology); 670 params.put(HttpKey.BIOLOGY, biology);
671 params.put(HttpKey.SCIENCE, science); 671 params.put(HttpKey.SCIENCE, science);
672 672
673 Log.e("test", "注册信息" + params); 673 Log.e("test", "注册信息" + params);
674 HttpClient.getInstance().addHeader("Accept", "*/*"); 674 HttpClient.getInstance().addHeader("Accept", "*/*");
675 HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { 675 HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() {
676 @Override 676 @Override
677 public void onSuccess(int statusCode, Header[] headers, JSONObject response) { 677 public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
678 super.onSuccess(statusCode, headers, response); 678 super.onSuccess(statusCode, headers, response);
679 closeProgress(); 679 closeProgress();
680 Message message = Message.obtain(); 680 Message message = Message.obtain();
681 message.what = HttpCode.REGISTERINFO_SUCESS; 681 message.what = HttpCode.REGISTERINFO_SUCESS;
682 message.obj = new String(String.valueOf(response)); 682 message.obj = new String(String.valueOf(response));
683 handler.sendMessage(message); 683 handler.sendMessage(message);
684 684
685 } 685 }
686 686
687 @Override 687 @Override
688 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { 688 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
689 super.onFailure(statusCode, headers, throwable, errorResponse); 689 super.onFailure(statusCode, headers, throwable, errorResponse);
690 closeProgress(); 690 closeProgress();
691 Log.e("test", "onFailure" + errorResponse); 691 Log.e("test", "onFailure" + errorResponse);
692 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 692 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
693 } 693 }
694 694
695 }); 695 });
696 } 696 }
697 //修改版本信息 697 //修改版本信息
698 public void changepublishinfo(final Context mContext, String userId, 698 public void changepublishinfo(final Context mContext, String userId,
699 String math, String english, String physics, String chinese, String chemistry, 699 String math, String english, String physics, String chinese, String chemistry,
700 String history, String geography, String political, String biology, String science){ 700 String history, String geography, String political, String biology, String science){
701 mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", 701 mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...",
702 false, true, null); 702 false, true, null);
703 RequestParams params = new RequestParams(); 703 RequestParams params = new RequestParams();
704 params.put(HttpKey.USEID, userId); 704 params.put(HttpKey.USEID, userId);
705 params.put(HttpKey.MATH, math); 705 params.put(HttpKey.MATH, math);
706 params.put(HttpKey.ENGLISH, english); 706 params.put(HttpKey.ENGLISH, english);
707 params.put(HttpKey.PHYSICES, physics); 707 params.put(HttpKey.PHYSICES, physics);
708 params.put(HttpKey.CHINESE, chinese); 708 params.put(HttpKey.CHINESE, chinese);
709 params.put(HttpKey.CHEMISTRY, chemistry); 709 params.put(HttpKey.CHEMISTRY, chemistry);
710 params.put(HttpKey.HISTIRY, history); 710 params.put(HttpKey.HISTIRY, history);
711 params.put(HttpKey.GEOGRAPHY, geography); 711 params.put(HttpKey.GEOGRAPHY, geography);
712 params.put(HttpKey.POLITICAL, political); 712 params.put(HttpKey.POLITICAL, political);
713 params.put(HttpKey.BIOLOGY, biology); 713 params.put(HttpKey.BIOLOGY, biology);
714 params.put(HttpKey.SCIENCE, science); 714 params.put(HttpKey.SCIENCE, science);
715 715
716 Log.e("test", "版本信息信息" + params); 716 Log.e("test", "版本信息信息" + params);
717 HttpClient.getInstance().addHeader("Accept", "*/*"); 717 HttpClient.getInstance().addHeader("Accept", "*/*");
718 HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { 718 HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() {
719 @Override 719 @Override
720 public void onSuccess(int statusCode, Header[] headers, JSONObject response) { 720 public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
721 super.onSuccess(statusCode, headers, response); 721 super.onSuccess(statusCode, headers, response);
722 closeProgress(); 722 closeProgress();
723 String status = response.optString("status"); 723 String status = response.optString("status");
724 if (status.equals("1")) { 724 if (status.equals("1")) {
725 Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); 725 Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show();
726 ((Activity) mContext).finish(); 726 ((Activity) mContext).finish();
727 } else { 727 } else {
728 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); 728 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试");
729 } 729 }
730 730
731 } 731 }
732 732
733 @Override 733 @Override
734 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { 734 public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
735 super.onFailure(statusCode, headers, throwable, errorResponse); 735 super.onFailure(statusCode, headers, throwable, errorResponse);
736 closeProgress(); 736 closeProgress();
737 Log.e("test", "onFailure" + errorResponse); 737 Log.e("test", "onFailure" + errorResponse);
738 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 738 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
739 } 739 }
740 740
741 }); 741 });
742 } 742 }
743 743
744 //修改个性签名 744 //修改个性签名
745 public void changsignature(final Context mContext, long userId, int type, final String signature) { 745 public void changsignature(final Context mContext, long userId, int type, final String signature) {
746 RequestParams params = new RequestParams(); 746 RequestParams params = new RequestParams();
747 params.put("userId", userId); 747 params.put("userId", userId);
748 params.put("type", type); 748 params.put("type", type);
749 params.put("signature", signature); 749 params.put("signature", signature);
750 HttpClient.getInstance().addHeader("Accept", "*/*"); 750 HttpClient.getInstance().addHeader("Accept", "*/*");
751 HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { 751 HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() {
752 @Override 752 @Override
753 public void onSuccess(int i, Header[] headers, byte[] bytes) { 753 public void onSuccess(int i, Header[] headers, byte[] bytes) {
754 try { 754 try {
755 JSONObject jsonObject = new JSONObject(new String(bytes)); 755 JSONObject jsonObject = new JSONObject(new String(bytes));
756 String status = jsonObject.optString("status"); 756 String status = jsonObject.optString("status");
757 if (status.equals("1")) { 757 if (status.equals("1")) {
758 Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); 758 Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show();
759 } else { 759 } else {
760 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); 760 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试");
761 } 761 }
762 } catch (JSONException e) { 762 } catch (JSONException e) {
763 e.printStackTrace(); 763 e.printStackTrace();
764 } 764 }
765 } 765 }
766 766
767 @Override 767 @Override
768 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 768 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
769 Log.e("test", "onFailure" + new String(bytes)); 769 Log.e("test", "onFailure" + new String(bytes));
770 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 770 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
771 } 771 }
772 }); 772 });
773 } 773 }
774 774
775 /** 775 /**
776 * 获取个性签名 776 * 获取个性签名
777 * 777 *
778 * @param mContext 778 * @param mContext
779 * @param userId 779 * @param userId
780 * @param handler 780 * @param handler
781 */ 781 */
782 public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { 782 public void getsignatures(final Context mContext, long userId, int type, final Handler handler) {
783 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 783 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
784 HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { 784 HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() {
785 @Override 785 @Override
786 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 786 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
787 Log.e("test", "个性签名" + new String(arg2)); 787 Log.e("test", "个性签名" + new String(arg2));
788 try { 788 try {
789 JSONObject jsonObject = new JSONObject(new String(arg2)); 789 JSONObject jsonObject = new JSONObject(new String(arg2));
790 int status = jsonObject.optInt("status"); 790 int status = jsonObject.optInt("status");
791 if (status == 1) { 791 if (status == 1) {
792 SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 792 SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据
793 SignInfo.DataBean signInfoBeanList = signInfo.getData(); 793 SignInfo.DataBean signInfoBeanList = signInfo.getData();
794 Message message = Message.obtain(); 794 Message message = Message.obtain();
795 message.what = HttpCode.SIGN; 795 message.what = HttpCode.SIGN;
796 message.obj = signInfoBeanList; 796 message.obj = signInfoBeanList;
797 handler.sendMessage(message); 797 handler.sendMessage(message);
798 798
799 799
800 } else if (status == 1000) { 800 } else if (status == 1000) {
801 //AlertUtils.showToast(mContext, "您还没有签名哦"); 801 //AlertUtils.showToast(mContext, "您还没有签名哦");
802 802
803 } else { 803 } else {
804 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 804 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
805 } 805 }
806 } catch (JSONException e) { 806 } catch (JSONException e) {
807 e.printStackTrace(); 807 e.printStackTrace();
808 } 808 }
809 809
810 810
811 } 811 }
812 812
813 @Override 813 @Override
814 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 814 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
815 Log.e("test", "失败原因" + arg3); 815 Log.e("test", "失败原因" + arg3);
816 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 816 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
817 } 817 }
818 }); 818 });
819 } 819 }
820 820
821 /** 821 /**
822 * 用户反馈 822 * 用户反馈
823 * 823 *
824 * @param mContext 824 * @param mContext
825 * @param userId 825 * @param userId
826 * @param content 826 * @param content
827 * @param contact 827 * @param contact
828 * @param imgs 828 * @param imgs
829 * @param feedtype 829 * @param feedtype
830 * @throws UnsupportedEncodingException 830 * @throws UnsupportedEncodingException
831 */ 831 */
832 public void feedback(final Context mContext, String userId, String content, 832 public void feedback(final Context mContext, String userId, String content,
833 String contact, String imgs, String feedtype) throws UnsupportedEncodingException { 833 String contact, String imgs, String feedtype) throws UnsupportedEncodingException {
834 mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", 834 mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...",
835 false, true, null); 835 false, true, null);
836 File file = new File(imgs); 836 File file = new File(imgs);
837 if (file.exists() && file.length() > 0) { 837 if (file.exists() && file.length() > 0) {
838 RequestParams params = new RequestParams(); 838 RequestParams params = new RequestParams();
839 try { 839 try {
840 params.put("userId", userId); 840 params.put("userId", userId);
841 params.put("content", content); 841 params.put("content", content);
842 params.put("contact", contact); 842 params.put("contact", contact);
843 params.put("imgs", file); 843 params.put("imgs", file);
844 params.put("feedtype", feedtype); 844 params.put("feedtype", feedtype);
845 } catch (FileNotFoundException e) { 845 } catch (FileNotFoundException e) {
846 e.printStackTrace(); 846 e.printStackTrace();
847 } 847 }
848 Log.e("test", "onSuccess" + params); 848 Log.e("test", "onSuccess" + params);
849 HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { 849 HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() {
850 @Override 850 @Override
851 public void onSuccess(int i, Header[] headers, byte[] bytes) { 851 public void onSuccess(int i, Header[] headers, byte[] bytes) {
852 closeProgress(); 852 closeProgress();
853 Log.e("test", "onSuccess" + new String(bytes)); 853 Log.e("test", "onSuccess" + new String(bytes));
854 try { 854 try {
855 JSONObject jsonObject = new JSONObject(new String(bytes)); 855 JSONObject jsonObject = new JSONObject(new String(bytes));
856 String status = jsonObject.optString("status"); 856 String status = jsonObject.optString("status");
857 if (status.equals("1")) { 857 if (status.equals("1")) {
858 Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); 858 Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show();
859 ((Activity) mContext).finish(); 859 ((Activity) mContext).finish();
860 } else { 860 } else {
861 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); 861 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试");
862 } 862 }
863 } catch (JSONException e) { 863 } catch (JSONException e) {
864 e.printStackTrace(); 864 e.printStackTrace();
865 } 865 }
866 } 866 }
867 867
868 @Override 868 @Override
869 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 869 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
870 closeProgress(); 870 closeProgress();
871 Log.e("test", "错误信息" + new String(bytes)); 871 Log.e("test", "错误信息" + new String(bytes));
872 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 872 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
873 873
874 } 874 }
875 }); 875 });
876 } else { 876 } else {
877 Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); 877 Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show();
878 } 878 }
879 } 879 }
880 880
881 /** 881 /**
882 * 查询子账户信息 882 * 查询子账户信息
883 * 883 *
884 * @param mContext 884 * @param mContext
885 * @param userId 885 * @param userId
886 * @param handler 886 * @param handler
887 */ 887 */
888 public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { 888 public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) {
889 mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", 889 mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...",
890 false, true, null); 890 false, true, null);
891 891
892 Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); 892 Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber);
893 HttpClient.getInstance().setTimeout(5 * 1000); 893 HttpClient.getInstance().setTimeout(5 * 1000);
894 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 894 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
895 HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { 895 HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() {
896 @Override 896 @Override
897 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 897 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
898 closeProgress(); 898 closeProgress();
899 Log.e("test", "子账户信息" + new String(arg2)); 899 Log.e("test", "子账户信息" + new String(arg2));
900 try { 900 try {
901 JSONObject jsonObject = new JSONObject(new String(arg2)); 901 JSONObject jsonObject = new JSONObject(new String(arg2));
902 int status = jsonObject.optInt("status"); 902 int status = jsonObject.optInt("status");
903 if (status == 1) { 903 if (status == 1) {
904 ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 904 ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据
905 Log.e("test", "子账户信息" + childsInfo); 905 Log.e("test", "子账户信息" + childsInfo);
906 List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); 906 List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData();
907 Log.e("test", "子账户信息" + schoolInfoBeanList); 907 Log.e("test", "子账户信息" + schoolInfoBeanList);
908 Message msg = Message.obtain(); 908 Message msg = Message.obtain();
909 msg.what = HttpCode.CHILDS_SUCESS; 909 msg.what = HttpCode.CHILDS_SUCESS;
910 msg.obj = schoolInfoBeanList; 910 msg.obj = schoolInfoBeanList;
911 handler.sendMessage(msg); 911 handler.sendMessage(msg);
912 912
913 }else { 913 }else {
914 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); 914 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!");
915 915
916 } 916 }
917 } catch (JSONException e) { 917 } catch (JSONException e) {
918 e.printStackTrace(); 918 e.printStackTrace();
919 919
920 } 920 }
921 921
922 } 922 }
923 923
924 @Override 924 @Override
925 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 925 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
926 closeProgress(); 926 closeProgress();
927 // Log.e("test", "错误信息" + new String(arg2)); 927 // Log.e("test", "错误信息" + new String(arg2));
928 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 928 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
929 } 929 }
930 }); 930 });
931 931
932 } 932 }
933 933
934 /** 934 /**
935 * 删除子账户信息 935 * 删除子账户信息
936 * 936 *
937 * @param mContext 937 * @param mContext
938 * @param subAccountId 938 * @param subAccountId
939 */ 939 */
940 public void deletechildAccountinfo(final Context mContext, String subAccountId) { 940 public void deletechildAccountinfo(final Context mContext, String subAccountId) {
941 mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", 941 mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...",
942 false, true, null); 942 false, true, null);
943 HttpClient.getInstance().setTimeout(5 * 1000); 943 HttpClient.getInstance().setTimeout(5 * 1000);
944 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 944 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
945 HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { 945 HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() {
946 @Override 946 @Override
947 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 947 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
948 closeProgress(); 948 closeProgress();
949 Log.e("test", "子账户信息" + new String(arg2)); 949 Log.e("test", "子账户信息" + new String(arg2));
950 try { 950 try {
951 JSONObject jsonObject = new JSONObject(new String(arg2)); 951 JSONObject jsonObject = new JSONObject(new String(arg2));
952 int status = jsonObject.optInt("status"); 952 int status = jsonObject.optInt("status");
953 if (status == 1) { 953 if (status == 1) {
954 AlertUtils.showToast(mContext, "子账号删除成功!"); 954 AlertUtils.showToast(mContext, "子账号删除成功!");
955 ((Activity) mContext).finish(); 955 ((Activity) mContext).finish();
956 } else { 956 } else {
957 AlertUtils.showToast(mContext, "你好,子账号删除失败!"); 957 AlertUtils.showToast(mContext, "你好,子账号删除失败!");
958 958
959 } 959 }
960 } catch (JSONException e) { 960 } catch (JSONException e) {
961 e.printStackTrace(); 961 e.printStackTrace();
962 } 962 }
963 963
964 } 964 }
965 965
966 @Override 966 @Override
967 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 967 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
968 closeProgress(); 968 closeProgress();
969 Log.e("test", "错误信息" + new String(arg2)); 969 Log.e("test", "错误信息" + new String(arg2));
970 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 970 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
971 } 971 }
972 }); 972 });
973 973
974 } 974 }
975 975
976 /** 976 /**
977 * 添加子账户信息 977 * 添加子账户信息
978 */ 978 */
979 public void addchildAccountinfo(final Context mContext, long parentId, String image, 979 public void addchildAccountinfo(final Context mContext, long parentId, String image,
980 String name, final Long grade, Object school, Long region 980 String name, final Long grade, Object school, Long region
981 , String deviceNumber, String regionName) { 981 , String deviceNumber, String regionName) {
982 mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", 982 mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...",
983 false, true, null); 983 false, true, null);
984 RequestParams params = new RequestParams(); 984 RequestParams params = new RequestParams();
985 985
986 params.put(HttpKey.PARENTID, parentId); 986 params.put(HttpKey.PARENTID, parentId);
987 params.put(HttpKey.IMAGE, image); 987 params.put(HttpKey.IMAGE, image);
988 params.put(HttpKey.NAME, name); 988 params.put(HttpKey.NAME, name);
989 params.put(HttpKey.GRADE, grade); 989 params.put(HttpKey.GRADE, grade);
990 params.put(HttpKey.SCHOOL, school); 990 params.put(HttpKey.SCHOOL, school);
991 params.put(HttpKey.REGION, region); 991 params.put(HttpKey.REGION, region);
992 params.put(HttpKey.DEVINUMBER, deviceNumber); 992 params.put(HttpKey.DEVINUMBER, deviceNumber);
993 params.put(HttpKey.REGIONNAME, regionName); 993 params.put(HttpKey.REGIONNAME, regionName);
994 994
995 Log.e("test", "子账户信息" + params); 995 Log.e("test", "子账户信息" + params);
996 HttpClient.getInstance().addHeader("Accept", "*/*"); 996 HttpClient.getInstance().addHeader("Accept", "*/*");
997 HttpClient.getInstance().setTimeout(5 * 1000); 997 HttpClient.getInstance().setTimeout(5 * 1000);
998 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 998 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
999 HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { 999 HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() {
1000 @Override 1000 @Override
1001 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1001 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1002 closeProgress(); 1002 closeProgress();
1003 1003
1004 Log.e("test", "子账户信息" + new String(arg2)); 1004 Log.e("test", "子账户信息" + new String(arg2));
1005 try { 1005 try {
1006 JSONObject jsonObject = new JSONObject(new String(arg2)); 1006 JSONObject jsonObject = new JSONObject(new String(arg2));
1007 int status = jsonObject.optInt("status"); 1007 int status = jsonObject.optInt("status");
1008 if (status == 1) { 1008 if (status == 1) {
1009 AlertUtils.showToast(mContext, "子账号添加成功!"); 1009 AlertUtils.showToast(mContext, "子账号添加成功!");
1010 ((Activity) mContext).finish(); 1010 ((Activity) mContext).finish();
1011 } else { 1011 } else {
1012 AlertUtils.showToast(mContext, "你好,子账号添加失败!"); 1012 AlertUtils.showToast(mContext, "你好,子账号添加失败!");
1013 1013
1014 } 1014 }
1015 } catch (JSONException e) { 1015 } catch (JSONException e) {
1016 e.printStackTrace(); 1016 e.printStackTrace();
1017 } 1017 }
1018 1018
1019 } 1019 }
1020 1020
1021 @Override 1021 @Override
1022 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1022 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1023 closeProgress(); 1023 closeProgress();
1024 Log.e("test", "错误信息" + new String(arg2)); 1024 Log.e("test", "错误信息" + new String(arg2));
1025 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1025 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1026 } 1026 }
1027 }); 1027 });
1028 1028
1029 } 1029 }
1030 1030
1031 /** 1031 /**
1032 * 切换子账户信息 1032 * 切换子账户信息
1033 * 1033 *
1034 * @param mContext 1034 * @param mContext
1035 * @param subAccountId 1035 * @param subAccountId
1036 */ 1036 */
1037 public void changechildAccountinfo(final Context mContext, String subAccountId, long userId 1037 public void changechildAccountinfo(final Context mContext, String subAccountId, long userId
1038 , String deviceNumber, int type) { 1038 , String deviceNumber, int type) {
1039 mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", 1039 mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...",
1040 false, true, null); 1040 false, true, null);
1041 HttpClient.getInstance().setTimeout(5 * 1000); 1041 HttpClient.getInstance().setTimeout(5 * 1000);
1042 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1042 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1043 HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId 1043 HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId
1044 + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { 1044 + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() {
1045 @Override 1045 @Override
1046 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1046 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1047 closeProgress(); 1047 closeProgress();
1048 Log.e("test", "子账户信息" + new String(arg2)); 1048 Log.e("test", "子账户信息" + new String(arg2));
1049 try { 1049 try {
1050 JSONObject jsonObject = new JSONObject(new String(arg2)); 1050 JSONObject jsonObject = new JSONObject(new String(arg2));
1051 int status = jsonObject.optInt("status"); 1051 int status = jsonObject.optInt("status");
1052 if (status == 1) { 1052 if (status == 1) {
1053 AlertUtils.showToast(mContext, "子账号切换成功!"); 1053 AlertUtils.showToast(mContext, "子账号切换成功!");
1054 ((Activity) mContext).finish(); 1054 ((Activity) mContext).finish();
1055 1055
1056 } else { 1056 } else {
1057 AlertUtils.showToast(mContext, "你好,子账号切换失败!"); 1057 AlertUtils.showToast(mContext, "你好,子账号切换失败!");
1058 1058
1059 } 1059 }
1060 } catch (JSONException e) { 1060 } catch (JSONException e) {
1061 e.printStackTrace(); 1061 e.printStackTrace();
1062 } 1062 }
1063 1063
1064 } 1064 }
1065 1065
1066 @Override 1066 @Override
1067 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1067 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1068 closeProgress(); 1068 closeProgress();
1069 Log.e("test", "错误信息" + new String(arg2)); 1069 Log.e("test", "错误信息" + new String(arg2));
1070 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1070 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1071 } 1071 }
1072 }); 1072 });
1073 1073
1074 } 1074 }
1075 1075
1076 /** 1076 /**
1077 * 切换主账户信息 1077 * 切换主账户信息
1078 * 1078 *
1079 * @param mContext 1079 * @param mContext
1080 * @param type 1080 * @param type
1081 */ 1081 */
1082 public void Accountinfo(final Context mContext, long userId 1082 public void Accountinfo(final Context mContext, long userId
1083 , String deviceNumber, int type) { 1083 , String deviceNumber, int type) {
1084 mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", 1084 mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...",
1085 false, true, null); 1085 false, true, null);
1086 HttpClient.getInstance().setTimeout(5 * 1000); 1086 HttpClient.getInstance().setTimeout(5 * 1000);
1087 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1087 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1088 HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber 1088 HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber
1089 + "&type=" + type, new AsyncHttpResponseHandler() { 1089 + "&type=" + type, new AsyncHttpResponseHandler() {
1090 @Override 1090 @Override
1091 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1091 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1092 closeProgress(); 1092 closeProgress();
1093 Log.e("test", "子账户信息" + new String(arg2)); 1093 Log.e("test", "子账户信息" + new String(arg2));
1094 try { 1094 try {
1095 JSONObject jsonObject = new JSONObject(new String(arg2)); 1095 JSONObject jsonObject = new JSONObject(new String(arg2));
1096 int status = jsonObject.optInt("status"); 1096 int status = jsonObject.optInt("status");
1097 if (status == 1) { 1097 if (status == 1) {
1098 AlertUtils.showToast(mContext, "主账号切换成功!"); 1098 AlertUtils.showToast(mContext, "主账号切换成功!");
1099 ((Activity) mContext).finish(); 1099 ((Activity) mContext).finish();
1100 1100
1101 } else { 1101 } else {
1102 AlertUtils.showToast(mContext, "你好,主账号切换失败!"); 1102 AlertUtils.showToast(mContext, "你好,主账号切换失败!");
1103 1103
1104 } 1104 }
1105 } catch (JSONException e) { 1105 } catch (JSONException e) {
1106 e.printStackTrace(); 1106 e.printStackTrace();
1107 } 1107 }
1108 1108
1109 } 1109 }
1110 1110
1111 @Override 1111 @Override
1112 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1112 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1113 closeProgress(); 1113 closeProgress();
1114 Log.e("test", "错误信息" + new String(arg2)); 1114 Log.e("test", "错误信息" + new String(arg2));
1115 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1115 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1116 } 1116 }
1117 }); 1117 });
1118 1118
1119 } 1119 }
1120 1120
1121 /** 1121 /**
1122 * 头像拍张 1122 * 头像拍张
1123 * 1123 *
1124 * @param mContext 1124 * @param mContext
1125 * @param userId 1125 * @param userId
1126 * @param img 1126 * @param img
1127 * @throws UnsupportedEncodingException 1127 * @throws UnsupportedEncodingException
1128 */ 1128 */
1129 public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { 1129 public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException {
1130 File file = new File(img); 1130 File file = new File(img);
1131 if (file.exists() && file.length() > 0) { 1131 if (file.exists() && file.length() > 0) {
1132 RequestParams params = new RequestParams(); 1132 RequestParams params = new RequestParams();
1133 try { 1133 try {
1134 params.put("userId", userId); 1134 params.put("userId", userId);
1135 params.put("type", type); 1135 params.put("type", type);
1136 params.put("img", file); 1136 params.put("img", file);
1137 } catch (FileNotFoundException e) { 1137 } catch (FileNotFoundException e) {
1138 e.printStackTrace(); 1138 e.printStackTrace();
1139 } 1139 }
1140 Log.e("test", "params" + params); 1140 Log.e("test", "params" + params);
1141 HttpClient.getInstance().setTimeout(5 * 1000); 1141 HttpClient.getInstance().setTimeout(5 * 1000);
1142 HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { 1142 HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() {
1143 @Override 1143 @Override
1144 public void onSuccess(int i, Header[] headers, byte[] bytes) { 1144 public void onSuccess(int i, Header[] headers, byte[] bytes) {
1145 Log.e("test", "onSuccess" + new String(bytes)); 1145 Log.e("test", "onSuccess" + new String(bytes));
1146 try { 1146 try {
1147 JSONObject jsonObject = new JSONObject(new String(bytes)); 1147 JSONObject jsonObject = new JSONObject(new String(bytes));
1148 String status = jsonObject.optString("status"); 1148 String status = jsonObject.optString("status");
1149 JSONObject jsonObject1 =jsonObject.getJSONObject("data"); 1149 JSONObject jsonObject1 =jsonObject.getJSONObject("data");
1150 String imagUrl = jsonObject1.optString("imgUrl"); 1150 String imagUrl = jsonObject1.optString("imgUrl");
1151 SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); 1151 SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl);
1152 if (status.equals("1")) { 1152 if (status.equals("1")) {
1153 Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); 1153 Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show();
1154 } else { 1154 } else {
1155 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); 1155 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试");
1156 } 1156 }
1157 } catch (JSONException e) { 1157 } catch (JSONException e) {
1158 e.printStackTrace(); 1158 e.printStackTrace();
1159 } 1159 }
1160 } 1160 }
1161 1161
1162 @Override 1162 @Override
1163 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 1163 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
1164 closeProgress(); 1164 closeProgress();
1165 Log.e("test", "错误信息" + new String(bytes)); 1165 Log.e("test", "错误信息" + new String(bytes));
1166 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1166 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1167 1167
1168 } 1168 }
1169 }); 1169 });
1170 } else { 1170 } else {
1171 Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); 1171 Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show();
1172 } 1172 }
1173 } 1173 }
1174 /** 1174 /**
1175 * 头像默认 1175 * 头像默认
1176 * 1176 *
1177 * @param mContext 1177 * @param mContext
1178 * @param userId 1178 * @param userId
1179 * @param 1179 * @param
1180 * @throws UnsupportedEncodingException 1180 * @throws UnsupportedEncodingException
1181 */ 1181 */
1182 public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { 1182 public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException {
1183 RequestParams params = new RequestParams(); 1183 RequestParams params = new RequestParams();
1184 params.put("userId", userId); 1184 params.put("userId", userId);
1185 params.put("type", type); 1185 params.put("type", type);
1186 params.put("defaultImg", defaultImg); 1186 params.put("defaultImg", defaultImg);
1187 Log.e("test", "params" + params); 1187 Log.e("test", "params" + params);
1188 HttpClient.getInstance().setTimeout(5 * 1000); 1188 HttpClient.getInstance().setTimeout(5 * 1000);
1189 HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { 1189 HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() {
1190 @Override 1190 @Override
1191 public void onSuccess(int i, Header[] headers, byte[] bytes) { 1191 public void onSuccess(int i, Header[] headers, byte[] bytes) {
1192 Log.e("test", "onSuccess" + new String(bytes)); 1192 Log.e("test", "onSuccess" + new String(bytes));
1193 try { 1193 try {
1194 JSONObject jsonObject = new JSONObject(new String(bytes)); 1194 JSONObject jsonObject = new JSONObject(new String(bytes));
1195 String status = jsonObject.optString("status"); 1195 String status = jsonObject.optString("status");
1196 JSONObject jsonObject1 =jsonObject.getJSONObject("data"); 1196 JSONObject jsonObject1 =jsonObject.getJSONObject("data");
1197 String imagUrl = jsonObject1.optString("imgUrl"); 1197 String imagUrl = jsonObject1.optString("imgUrl");
1198 SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); 1198 SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl);
1199 if (status.equals("1")) { 1199 if (status.equals("1")) {
1200 Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); 1200 Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show();
1201 } else { 1201 } else {
1202 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); 1202 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试");
1203 } 1203 }
1204 } catch (JSONException e) { 1204 } catch (JSONException e) {
1205 e.printStackTrace(); 1205 e.printStackTrace();
1206 } 1206 }
1207 } 1207 }
1208 1208
1209 @Override 1209 @Override
1210 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { 1210 public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
1211 closeProgress(); 1211 closeProgress();
1212 Log.e("test", "错误信息" + new String(bytes)); 1212 Log.e("test", "错误信息" + new String(bytes));
1213 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1213 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1214 1214
1215 } 1215 }
1216 }); 1216 });
1217 } 1217 }
1218 1218
1219 /** 1219 /**
1220 * 检查注册信息是否完整 1220 * 检查注册信息是否完整
1221 * @param mContext 1221 * @param mContext
1222 * @param userId 1222 * @param userId
1223 */ 1223 */
1224 public void registerinfocheck(final Context mContext, long userId, final Handler handler) { 1224 public void registerinfocheck(final Context mContext, long userId, final Handler handler) {
1225 mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", 1225 mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...",
1226 false, true, null); 1226 false, true, null);
1227 HttpClient.getInstance().setTimeout(5 * 1000); 1227 HttpClient.getInstance().setTimeout(5 * 1000);
1228 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1228 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1229 HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId , new AsyncHttpResponseHandler() { 1229 HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId , new AsyncHttpResponseHandler() {
1230 @Override 1230 @Override
1231 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1231 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1232 closeProgress(); 1232 closeProgress();
1233 Log.e("test", "注册信息" + new String(arg2)); 1233 Log.e("test", "注册信息" + new String(arg2));
1234 Message msg = Message.obtain(); 1234 Message msg = Message.obtain();
1235 msg.what = HttpCode.REGISTER_SUCESS; 1235 msg.what = HttpCode.REGISTER_SUCESS;
1236 msg.obj = new String(arg2); 1236 msg.obj = new String(arg2);
1237 handler.sendMessage(msg); 1237 handler.sendMessage(msg);
1238 1238
1239 } 1239 }
1240 1240
1241 @Override 1241 @Override
1242 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1242 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1243 closeProgress(); 1243 closeProgress();
1244 // Log.e("test", "错误信息" + new String(arg2)); 1244 // Log.e("test", "错误信息" + new String(arg2));
1245 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1245 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1246 1246
1247 } 1247 }
1248 }); 1248 });
1249 1249
1250 } 1250 }
1251 /** 1251 /**
1252 * 获取最近学习视频 1252 * 获取最近学习视频
1253 * @param mContext 1253 * @param mContext
1254 * @param userId 1254 * @param userId
1255 */ 1255 */
1256 public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { 1256 public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) {
1257 mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", 1257 mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...",
1258 false, true, null); 1258 false, true, null);
1259 HttpClient.getInstance().setTimeout(5 * 1000); 1259 HttpClient.getInstance().setTimeout(5 * 1000);
1260 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1260 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1261 HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId , new AsyncHttpResponseHandler() { 1261 HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId , new AsyncHttpResponseHandler() {
1262 @Override 1262 @Override
1263 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1263 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1264 closeProgress(); 1264 closeProgress();
1265 Log.e("test", "近学习视频" + new String(arg2)); 1265 Log.e("test", "近学习视频" + new String(arg2));
1266 try { 1266 try {
1267 JSONObject jsonObject = new JSONObject(new String(arg2)); 1267 JSONObject jsonObject = new JSONObject(new String(arg2));
1268 int status = jsonObject.optInt("status"); 1268 int status = jsonObject.optInt("status");
1269 if (status == 1) { 1269 if (status == 1) {
1270 VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 1270 VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据
1271 List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); 1271 List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData();
1272 Message msg = Message.obtain(); 1272 Message msg = Message.obtain();
1273 msg.what = HttpCode.GETVIDIO_SUCESS; 1273 msg.what = HttpCode.GETVIDIO_SUCESS;
1274 msg.obj = schoolInfoBeanList; 1274 msg.obj = schoolInfoBeanList;
1275 handler.sendMessage(msg); 1275 handler.sendMessage(msg);
1276 1276
1277 }else { 1277 }else {
1278 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); 1278 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!");
1279 1279
1280 } 1280 }
1281 } catch (JSONException e) { 1281 } catch (JSONException e) {
1282 e.printStackTrace(); 1282 e.printStackTrace();
1283 1283
1284 } 1284 }
1285 1285
1286 } 1286 }
1287 1287
1288 @Override 1288 @Override
1289 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1289 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1290 closeProgress(); 1290 closeProgress();
1291 // Log.e("test", "错误信息" + new String(arg2)); 1291 // Log.e("test", "错误信息" + new String(arg2));
1292 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1292 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1293 1293
1294 } 1294 }
1295 }); 1295 });
1296 1296
1297 } 1297 }
1298 1298
1299 1299
1300 /** 1300 /**
1301 * 系统升级 1301 * 系统升级
1302 * 1302 *
1303 * @param mContext 1303 * @param mContext
1304 * @param pid appName 1304 * @param pid appName
1305 */ 1305 */
1306 public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { 1306 public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) {
1307 mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", 1307 mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...",
1308 false, true, null); 1308 false, true, null);
1309 HttpClient.getInstance().setTimeout(5 * 1000); 1309 HttpClient.getInstance().setTimeout(5 * 1000);
1310 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1310 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1311 HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { 1311 HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() {
1312 @Override 1312 @Override
1313 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1313 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1314 closeProgress(); 1314 closeProgress();
1315 Log.e("test", "版本升级信息" + new String(arg2)); 1315 Log.e("test", "版本升级信息" + new String(arg2));
1316 AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 1316 AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据
1317 Message msg = Message.obtain(); 1317 Message msg = Message.obtain();
1318 msg.what = HttpCode.APPUPDATE_SUCESS; 1318 msg.what = HttpCode.APPUPDATE_SUCESS;
1319 msg.obj = appVersion; 1319 msg.obj = appVersion;
1320 handler.sendMessage(msg); 1320 handler.sendMessage(msg);
1321 1321
1322 1322
1323 } 1323 }
1324 1324
1325 @Override 1325 @Override
1326 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1326 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1327 closeProgress(); 1327 closeProgress();
1328 Log.e("test", "错误信息" + new String(arg2)); 1328 Log.e("test", "错误信息" + new String(arg2));
1329 } 1329 }
1330 }); 1330 });
1331 1331
1332 } 1332 }
1333 //版本信息 1333 //版本信息
1334 public void versioninfo(final Context mContext,String subjectName, final Handler handler) { 1334 public void versioninfo(final Context mContext,String subjectName, final Handler handler) {
1335 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1335 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1336 HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() { 1336 HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() {
1337 @Override 1337 @Override
1338 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1338 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1339 Log.e("test", "版本信息" + new String(arg2)); 1339 Log.e("test", "版本信息" + new String(arg2));
1340 try { 1340 try {
1341 JSONObject jsonObject = new JSONObject(new String(arg2)); 1341 JSONObject jsonObject = new JSONObject(new String(arg2));
1342 int status = jsonObject.optInt("status"); 1342 int status = jsonObject.optInt("status");
1343 if (status == 1) { 1343 if (status == 1) {
1344 VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 1344 VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据
1345 List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); 1345 List<VersionInfo.DataBean> versionInfoList = versionInfo.getData();
1346 Message message = Message.obtain(); 1346 Message message = Message.obtain();
1347 message.what = HttpCode.VERSION_SUCESS; 1347 message.what = HttpCode.VERSION_SUCESS;
1348 message.obj = versionInfoList; 1348 message.obj = versionInfoList;
1349 handler.sendMessage(message); 1349 handler.sendMessage(message);
1350 1350
1351 } else if(status == 1000){ 1351 } else if(status == 1000){
1352 AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); 1352 AlertUtils.showToast(mContext, "你好,该科目没有版本信息");
1353 1353
1354 }else { 1354 }else {
1355 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 1355 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
1356 } 1356 }
1357 } catch (JSONException e) { 1357 } catch (JSONException e) {
1358 e.printStackTrace(); 1358 e.printStackTrace();
1359 } 1359 }
1360 1360
1361 1361
1362 } 1362 }
1363 1363
1364 @Override 1364 @Override
1365 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1365 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1366 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1366 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1367 } 1367 }
1368 }); 1368 });
1369 } 1369 }
1370 1370
1371 1371
1372 1372
1373 1373
1374 1374
1375 1375
1376 ///省级接口 1376 ///省级接口
1377 public void provices(final Context mContext, final Handler handler) { 1377 public void provices(final Context mContext, final Handler handler) {
1378 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1378 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1379 HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { 1379 HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() {
1380 @Override 1380 @Override
1381 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1381 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1382 Log.e("test", "省" + new String(arg2)); 1382 Log.e("test", "省" + new String(arg2));
1383 try { 1383 try {
1384 JSONObject jsonObject = new JSONObject(new String(arg2)); 1384 JSONObject jsonObject = new JSONObject(new String(arg2));
1385 int status = jsonObject.optInt("status"); 1385 int status = jsonObject.optInt("status");
1386 if (status == 100) { 1386 if (status == 100) {
1387 ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 1387 ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据
1388 Log.e("test", "状态码" + provinceInfo.getStatus()); 1388 Log.e("test", "状态码" + provinceInfo.getStatus());
1389 List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); 1389 List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces();
1390 Message message = Message.obtain(); 1390 Message message = Message.obtain();
1391 message.what = HttpCode.PROVICES; 1391 message.what = HttpCode.PROVICES;
1392 message.obj = provincesBeanList; 1392 message.obj = provincesBeanList;
1393 handler.sendMessage(message); 1393 handler.sendMessage(message);
1394 1394
1395 1395
1396 } else { 1396 } else {
1397 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 1397 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
1398 1398
1399 } 1399 }
1400 } catch (JSONException e) { 1400 } catch (JSONException e) {
1401 e.printStackTrace(); 1401 e.printStackTrace();
1402 } 1402 }
1403 1403
1404 1404
1405 } 1405 }
1406 1406
1407 @Override 1407 @Override
1408 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1408 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1409 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1409 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1410 } 1410 }
1411 }); 1411 });
1412 } 1412 }
1413 //获取版本信息接口 1413 //获取版本信息接口
1414 public void getpublishinfo(final Context mContext, long userId,int gradeId, final Handler handler) { 1414 public void getpublishinfo(final Context mContext, long userId,int gradeId, final Handler handler) {
1415 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1415 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1416 HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { 1416 HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() {
1417 @Override 1417 @Override
1418 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1418 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1419 Log.e("test", "获取版本信息接口" + new String(arg2)); 1419 Log.e("test", "获取版本信息接口" + new String(arg2));
1420 try { 1420 try {
1421 JSONObject jsonObject = new JSONObject(new String(arg2)); 1421 JSONObject jsonObject = new JSONObject(new String(arg2));
1422 int status = jsonObject.optInt("status"); 1422 int status = jsonObject.optInt("status");
1423 if (status == 1) { 1423 if (status == 1) {
1424 Gson gson = new Gson(); 1424 Gson gson = new Gson();
1425 DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); 1425 DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class);
1426 List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); 1426 List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData();
1427 Message message = Message.obtain(); 1427 Message message = Message.obtain();
1428 message.what = HttpCode.PUBLISH_SUCESS; 1428 message.what = HttpCode.PUBLISH_SUCESS;
1429 message.obj = defautPublishInfoBeanList; 1429 message.obj = defautPublishInfoBeanList;
1430 handler.sendMessage(message); 1430 handler.sendMessage(message);
1431 1431
1432 } else { 1432 } else {
1433 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 1433 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
1434 1434
1435 } 1435 }
1436 } catch (JSONException e) { 1436 } catch (JSONException e) {
1437 e.printStackTrace(); 1437 e.printStackTrace();
1438 } 1438 }
1439 1439
1440 1440
1441 } 1441 }
1442 1442
1443 @Override 1443 @Override
1444 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1444 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1445 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1445 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1446 } 1446 }
1447 }); 1447 });
1448 } 1448 }
1449 1449
1450 1450
1451 //市级接口 1451 //市级接口
1452 public void cityinfo(final Context mContext, long regionId, final Handler handler) { 1452 public void cityinfo(final Context mContext, long regionId, final Handler handler) {
1453 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1453 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1454 HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { 1454 HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() {
1455 @Override 1455 @Override
1456 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1456 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1457 Log.e("test", "市" + new String(arg2)); 1457 Log.e("test", "市" + new String(arg2));
1458 try { 1458 try {
1459 JSONObject jsonObject = new JSONObject(new String(arg2)); 1459 JSONObject jsonObject = new JSONObject(new String(arg2));
1460 int status = jsonObject.optInt("status"); 1460 int status = jsonObject.optInt("status");
1461 if (status == 100) { 1461 if (status == 100) {
1462 Gson gson = new Gson(); 1462 Gson gson = new Gson();
1463 CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); 1463 CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class);
1464 List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); 1464 List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities();
1465 Message message = Message.obtain(); 1465 Message message = Message.obtain();
1466 message.what = HttpCode.CITYS; 1466 message.what = HttpCode.CITYS;
1467 message.obj = cityInfoBeanList; 1467 message.obj = cityInfoBeanList;
1468 handler.sendMessage(message); 1468 handler.sendMessage(message);
1469 1469
1470 } else { 1470 } else {
1471 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 1471 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
1472 1472
1473 } 1473 }
1474 } catch (JSONException e) { 1474 } catch (JSONException e) {
1475 e.printStackTrace(); 1475 e.printStackTrace();
1476 } 1476 }
1477 1477
1478 1478
1479 } 1479 }
1480 1480
1481 @Override 1481 @Override
1482 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1482 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1483 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1483 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1484 } 1484 }
1485 }); 1485 });
1486 } 1486 }
1487 1487
1488 //区县级接口 1488 //区县级接口
1489 public void countyinfo(final Context mContext, int parentId, final Handler handler) { 1489 public void countyinfo(final Context mContext, int parentId, final Handler handler) {
1490 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 1490 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
1491 HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { 1491 HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() {
1492 @Override 1492 @Override
1493 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { 1493 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1494 Log.e("test", "区" + new String(arg2)); 1494 Log.e("test", "区" + new String(arg2));
1495 try { 1495 try {
1496 JSONObject jsonObject = new JSONObject(new String(arg2)); 1496 JSONObject jsonObject = new JSONObject(new String(arg2));
1497 int status = jsonObject.optInt("status"); 1497 int status = jsonObject.optInt("status");
1498 if (status == 100) { 1498 if (status == 100) {
1499 Gson gson = new Gson(); 1499 Gson gson = new Gson();
1500 CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); 1500 CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class);
1501 List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); 1501 List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties();
1502 Message message = Message.obtain(); 1502 Message message = Message.obtain();
1503 message.what = HttpCode.COUNTRY; 1503 message.what = HttpCode.COUNTRY;
1504 message.obj = countyInfoInfoBeanList; 1504 message.obj = countyInfoInfoBeanList;
1505 handler.sendMessage(message); 1505 handler.sendMessage(message);
1506 } else { 1506 } else {
1507 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); 1507 AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!");
1508 1508
1509 } 1509 }
1510 } catch (JSONException e) { 1510 } catch (JSONException e) {
1511 e.printStackTrace(); 1511 e.printStackTrace();
1512 } 1512 }
1513 1513
1514 1514
1515 } 1515 }
1516 1516
1517 @Override 1517 @Override
1518 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { 1518 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
1519 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); 1519 AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!");
1520 } 1520 }
1521 }); 1521 });
1522 } 1522 }
1523 1523
1524 1524
1525 private void closeProgress() { 1525 private void closeProgress() {
1526 try { 1526 try {
1527 if (mProgress != null) { 1527 if (mProgress != null) {
1528 mProgress.dismiss(); 1528 mProgress.dismiss();
1529 mProgress = null; 1529 mProgress = null;
1530 } 1530 }
1531 } catch (Exception e) { 1531 } catch (Exception e) {
1532 e.printStackTrace(); 1532 e.printStackTrace();
1533 } 1533 }
1534 } 1534 }
1535 public boolean onKeyDown(int keyCode, KeyEvent event) 1535 public boolean onKeyDown(int keyCode, KeyEvent event)
1536 { 1536 {
1537 if (keyCode == KeyEvent.KEYCODE_BACK ) 1537 if (keyCode == KeyEvent.KEYCODE_BACK )
1538 { 1538 {
1539 1539
1540 HttpManager.getInstance().closeProgress(); 1540 HttpManager.getInstance().closeProgress();
1541 } 1541 }
1542 1542
1543 return false; 1543 return false;
1544 1544
1545 } 1545 }
1546 1546
1547 } 1547 }
1548 1548
PersonalCenter/app/src/main/java/com/hjx/personalcenter/service/CenterService.java
1 package com.hjx.personalcenter.service; 1 package com.hjx.personalcenter.service;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.IBinder; 4 import android.os.IBinder;
5 import android.os.RemoteException; 5 import android.os.RemoteException;
6 import android.util.Log; 6 import android.util.Log;
7 7
8 import com.google.gson.Gson; 8 import com.google.gson.Gson;
9 import com.hjx.personalcenter.activity.LoginAndRegisterActivity; 9 import com.hjx.personalcenter.activity.LoginAndRegisterActivity;
10 import com.hjx.personalcenter.db.SaveParam; 10 import com.hjx.personalcenter.db.SaveParam;
11 import com.hjx.personalcenter.model.CardInfo; 11 import com.hjx.personalcenter.model.CardInfo;
12 import com.hjx.personalcenter.model.LoginInfo; 12 import com.hjx.personalcenter.model.LoginInfo;
13 import com.hjx.personalcenter.util.GetDevicesUtil; 13 import com.hjx.personalcenter.util.GetDevicesUtil;
14 14
15 /** 15 /**
16 * Created by h on 2017/9/1. 16 * Created by h on 2017/9/1.
17 */ 17 */
18 18
19 public class CenterService extends BaseService { 19 public class CenterService extends BaseService {
20 enum ACTIVITY_ACTION{ 20 enum ACTIVITY_ACTION{
21 userinfo_activity 21 userinfo_activity
22 } 22 }
23 public CenterService(){ 23 public CenterService(){
24 24
25 } 25 }
26 IPresonalInterface.Stub binder = new IPresonalInterface.Stub() { 26 IPresonalInterface.Stub binder = new IPresonalInterface.Stub() {
27 @Override 27 @Override
28 public String sayHello() throws RemoteException { 28 public String sayHello() throws RemoteException {
29 return "这是测试AIDL的方法"; 29 return "这是测试AIDL的方法";
30 } 30 }
31 31
32 @Override 32 @Override
33 public String viewPage(String action) throws RemoteException { 33 public String viewPage(String action) throws RemoteException {
34 String result = null; 34 String result = null;
35 if(action.equals(ACTIVITY_ACTION.userinfo_activity.toString())){ 35 if(action.equals(ACTIVITY_ACTION.userinfo_activity.toString())){
36 //登录界面 36 //登录界面
37 Intent intent = new Intent(); 37 Intent intent = new Intent();
38 intent.setClass(CenterService.this, LoginAndRegisterActivity.class); 38 intent.setClass(CenterService.this, LoginAndRegisterActivity.class);
39 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 39 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
40 startActivity(intent); 40 startActivity(intent);
41 result= "跳转成功"; 41 result= "跳转成功";
42 } 42 }
43 43
44 return result; 44 return result;
45 } 45 }
46 46
47 @Override 47 @Override
48 public String getSimpleUser() throws RemoteException { 48 public String getSimpleUser() throws RemoteException {
49 String logininfo = null; 49 String logininfo = null;
50 Gson gson = new Gson(); 50 Gson gson = new Gson();
51 LoginInfo loginInfo = new LoginInfo(); 51 LoginInfo loginInfo = new LoginInfo();
52 String islogin = SaveParam.getInstance().getLoginParam(getApplication(),"login"); 52 String islogin = SaveParam.getInstance().getLoginParam(getApplication(),"login");
53 //子账户id
54 String childsidid = SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CHILDSID);
55 //账户类型
56 String accounts = SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ACCOUNT);
53 if ("true".equals(islogin)){ 57 if ("true".equals(islogin)){
54 loginInfo.setUsername(SaveParam.getInstance().getLoginParam(getApplication(), "username")); 58 loginInfo.setUsername(SaveParam.getInstance().getLoginParam(getApplication(), "username"));
55 loginInfo.setPassword(SaveParam.getInstance().getLoginParam(getApplication(), "password")); 59 loginInfo.setPassword(SaveParam.getInstance().getLoginParam(getApplication(), "password"));
56 loginInfo.setAccess_token(SaveParam.getInstance().getLoginParam(getApplication(), "access_token")); 60 loginInfo.setAccess_token(SaveParam.getInstance().getLoginParam(getApplication(), "access_token"));
57 loginInfo.setLoginStatus(SaveParam.getInstance().getLoginParam(getApplication(), "login")); 61 loginInfo.setLoginStatus(SaveParam.getInstance().getLoginParam(getApplication(), "login"));
58 loginInfo.setUserId(SaveParam.getInstance().getLoginParam(getApplication(), "userId")); 62
63 if ("2".equals(accounts)){
64 loginInfo.setUserId(childsidid);
65 }else {
66 loginInfo.setUserId(SaveParam.getInstance().getLoginParam(getApplication(), "userId"));
67 }
59 68
60 logininfo =gson.toJson(loginInfo); 69 logininfo =gson.toJson(loginInfo);
61 70
62 Log.e("test","登录信息"+logininfo); 71 Log.e("test","登录信息"+logininfo);
63 72
64 } 73 }
65 74
66 return logininfo; 75 return logininfo;
67 } 76 }
68 //保卡信息 77 //保卡信息
69 @Override 78 @Override
70 public String getcardUser() throws RemoteException { 79 public String getcardUser() throws RemoteException {
71 String results = null; 80 String results = null;
72 // CardInfo cardInfo = new CardInfo(); 81 // CardInfo cardInfo = new CardInfo();
73 CardInfo.DataBean dataBean = new CardInfo.DataBean(); 82 CardInfo.DataBean dataBean = new CardInfo.DataBean();
74 Gson gson = new Gson(); 83 Gson gson = new Gson();
75 84
76 //获取设备信息 85 //获取设备信息
77 dataBean.setProductModel(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceModel()); 86 dataBean.setProductModel(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceModel());
78 dataBean.setDeviceNumber(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceNumber()); 87 dataBean.setDeviceNumber(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceNumber());
79 dataBean.setMacAddress(GetDevicesUtil.getDevicesInfo(getApplication()).getMac()); 88 dataBean.setMacAddress(GetDevicesUtil.getDevicesInfo(getApplication()).getMac());
80 //获取保卡信息 89 //获取保卡信息
81 dataBean.setCustomerName(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CUNSTEMNAME)); 90 dataBean.setCustomerName(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CUNSTEMNAME));
82 dataBean.setCustomerAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ADRESSCUNSTEM)); 91 dataBean.setCustomerAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ADRESSCUNSTEM));
83 dataBean.setBuyTime(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTIME)); 92 dataBean.setBuyTime(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTIME));
84 dataBean.setBuyAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPADRESS)); 93 dataBean.setBuyAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPADRESS));
85 dataBean.setAlterSaleCall(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTLEPHONE)); 94 dataBean.setAlterSaleCall(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTLEPHONE));
86 dataBean.setMobilePhone(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CARDPHONE)); 95 dataBean.setMobilePhone(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CARDPHONE));
87 // cardInfo.setData(dataBean); 96 // cardInfo.setData(dataBean);
88 results =gson.toJson(dataBean); 97 results =gson.toJson(dataBean);
89 Log.e("test","保卡信息"+results); 98 Log.e("test","保卡信息"+results);
90 return results; 99 return results;
91 100
92 } 101 }
93 102
94 @Override 103 @Override
95 public String getUserInfo() throws RemoteException { 104 public String getUserInfo() throws RemoteException {
96 return null; 105 return null;
97 } 106 }
98 107
99 @Override 108 @Override
100 public String logout() throws RemoteException { 109 public String logout() throws RemoteException {
101 return null; 110 return null;
102 } 111 }
103 112
104 @Override 113 @Override
105 public String validateToken() throws RemoteException { 114 public String validateToken() throws RemoteException {
106 return null; 115 return null;
107 } 116 }
108 117
109 @Override 118 @Override
110 public String getDeviceID() throws RemoteException { 119 public String getDeviceID() throws RemoteException {
111 return null; 120 return null;
112 } 121 }
113 122
114 @Override 123 @Override
115 public String getChildsInfo() throws RemoteException { 124 public String getChildsInfo() throws RemoteException {
116 return null; 125 return null;
117 } 126 }
118 }; 127 };
119 128
120 @Override 129 @Override
121 public IBinder onBind(Intent intent) { 130 public IBinder onBind(Intent intent) {
122 return binder; 131 return binder;
123 } 132 }
124 } 133 }
125 134
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/DialogPermission.java
1 package com.hjx.personalcenter.util; 1 package com.hjx.personalcenter.util;
2 2
3 import android.app.AlertDialog; 3 import android.app.AlertDialog;
4 import android.app.ProgressDialog; 4 import android.app.ProgressDialog;
5 import android.content.Context; 5 import android.content.Context;
6 import android.content.DialogInterface; 6 import android.content.DialogInterface;
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.provider.Settings; 8 import android.provider.Settings;
9 import android.util.Log; 9 import android.util.Log;
10 10
11 /** 11 /**
12 * 权限提示对话框 12 * 权限提示对话框
13 * Created by yf on 2016/7/25. 13 * Created by yf on 2016/7/25.
14 */ 14 */
15 public class DialogPermission { 15 public class DialogPermission {
16 Context mContext; 16 Context mContext;
17 String mNotice; 17 String mNotice;
18 18
19 public DialogPermission(Context context, String notice) { 19 public DialogPermission(Context context, String notice) {
20 mContext = context; 20 mContext = context;
21 mNotice = notice; 21 mNotice = notice;
22 showDialog(); 22 showDialog();
23 } 23 }
24 24
25 private void showDialog() { 25 private void showDialog() {
26 new AlertDialog.Builder(mContext).setTitle("系统提示")//设置对话框标题 26 new AlertDialog.Builder(mContext).setTitle("系统提示")//设置对话框标题
27 27
28 .setMessage(mNotice)//设置显示的内容 28 .setMessage(mNotice)//设置显示的内容
29 29
30 .setPositiveButton("设置", new DialogInterface.OnClickListener() {//添加确定按钮 30 .setPositiveButton("设置", new DialogInterface.OnClickListener() {//添加确定按钮
31 31
32 @Override 32 @Override
33 33
34 public void onClick(DialogInterface dialog, int which) {//确定按钮的响应事件 34 public void onClick(DialogInterface dialog, int which) {//确定按钮的响应事件
35 Intent intent = new Intent(Settings.ACTION_APN_SETTINGS); 35 Intent intent = new Intent(Settings.ACTION_APN_SETTINGS);
36 mContext.startActivity(intent); 36 mContext.startActivity(intent);
37 } 37 }
38 38
39 }).setNegativeButton("放弃", new DialogInterface.OnClickListener() {//添加返回按钮 39 }).setNegativeButton("放弃", new DialogInterface.OnClickListener() {//添加返回按钮
40 @Override 40 @Override
41 public void onClick(DialogInterface dialog, int which) {//响应事件 41 public void onClick(DialogInterface dialog, int which) {//响应事件
42 42
43 Log.i("DialogPermission", "Dialog关闭"); 43 Log.i("DialogPermission", "Dialog关闭");
44 } 44 }
45 }).show();//在按键响应事件中显示此对话框 45 }).show();//在按键响应事件中显示此对话框
46 46
47 } 47 }
48 48
49 /** 49 /**
50 * 显示进度条 50 * 显示进度条
51 * 51 *
52 * @param context 环境 52 * @param context 环境
53 * @param title 标题 53 * @param title 标题
54 * @param message 信息 54 * @param message 信息
55 * @param indeterminate 确定性 55 * @param indeterminate 确定性
56 * @param cancelable 可撤销 56 * @param cancelable 可撤销
57 * @return 57 * @return
58 */ 58 */
59 public static ProgressDialog showProgress(Context context, 59 public static ProgressDialog showProgress(Context context,
60 CharSequence title, CharSequence message, boolean indeterminate, 60 CharSequence title, CharSequence message, boolean indeterminate,
61 boolean cancelable, DialogInterface.OnDismissListener listener) { 61 boolean cancelable, DialogInterface.OnDismissListener listener) {
62 ProgressDialog dialog = new ProgressDialog(context); 62 ProgressDialog dialog = new ProgressDialog(context);
63 dialog.setTitle(title); 63 dialog.setTitle(title);
64 dialog.setMessage(message); 64 dialog.setMessage(message);
65 dialog.setIndeterminate(indeterminate); 65 dialog.setIndeterminate(indeterminate);
66 dialog.setCancelable(false); 66 dialog.setCancelable(true);
67 dialog.setCanceledOnTouchOutside(false);
67 // dialog.setDefaultButton(false); 68 // dialog.setDefaultButton(false);
68 if (cancelable && listener != null) 69 if (cancelable && listener != null)
69 dialog.setOnDismissListener(listener); 70 dialog.setOnDismissListener(listener);
70 71
71 dialog.show(); 72 dialog.show();
72 return dialog; 73 return dialog;
73 } 74 }
74 75
75 private void closeProgress() { 76 private void closeProgress() {
76 try { 77 try {
77 if (mProgress != null) { 78 if (mProgress != null) {
78 mProgress.dismiss(); 79 mProgress.dismiss();
79 mProgress = null; 80 mProgress = null;
80 } 81 }
81 } catch (Exception e) { 82 } catch (Exception e) {
82 e.printStackTrace(); 83 e.printStackTrace();
83 } 84 }
84 } 85 }
85 86
86 private ProgressDialog mProgress = null; 87 private ProgressDialog mProgress = null;
87 88
88 } 89 }
89 90
PersonalCenter/app/src/main/res/layout/activity_account_management.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:fresco="http://schemas.android.com/apk/res-auto" 3 xmlns:fresco="http://schemas.android.com/apk/res-auto"
4 android:layout_width="match_parent" 4 android:layout_width="match_parent"
5 android:layout_height="match_parent" 5 android:layout_height="match_parent"
6 android:orientation="vertical"> 6 android:orientation="vertical">
7 7
8 <RelativeLayout 8 <RelativeLayout
9 android:id="@+id/title" 9 android:id="@+id/title"
10 android:layout_width="match_parent" 10 android:layout_width="match_parent"
11 android:layout_height="wrap_content" 11 android:layout_height="wrap_content"
12 android:background="@color/login_text_blue" 12 android:background="@color/login_text_blue"
13 android:minHeight="50dp"> 13 android:minHeight="50dp">
14 14
15 <ImageView 15 <ImageView
16 android:id="@+id/cancel" 16 android:id="@+id/cancel"
17 android:layout_width="wrap_content" 17 android:layout_width="wrap_content"
18 android:layout_height="wrap_content" 18 android:layout_height="wrap_content"
19 android:layout_centerVertical="true" 19 android:layout_centerVertical="true"
20 android:paddingLeft="20dp" 20 android:paddingLeft="20dp"
21 android:paddingRight="20dp" 21 android:paddingRight="20dp"
22 android:src="@mipmap/title_back" /> 22 android:src="@mipmap/title_back" />
23 23
24 <TextView 24 <TextView
25 android:id="@+id/menu_title" 25 android:id="@+id/menu_title"
26 android:layout_width="wrap_content" 26 android:layout_width="wrap_content"
27 android:layout_height="wrap_content" 27 android:layout_height="wrap_content"
28 android:layout_centerInParent="true" 28 android:layout_centerInParent="true"
29 android:text="@string/account_management" 29 android:text="@string/account_management"
30 android:textColor="@android:color/white" 30 android:textColor="@android:color/white"
31 android:textSize="22sp" /> 31 android:textSize="22sp" />
32 </RelativeLayout> 32 </RelativeLayout>
33 33
34 <LinearLayout 34 <LinearLayout
35 android:layout_width="wrap_content" 35 android:layout_width="wrap_content"
36 android:layout_height="wrap_content" 36 android:layout_height="wrap_content"
37 android:layout_margin="20dp" 37 android:layout_margin="20dp"
38 android:gravity="center_vertical" 38 android:gravity="center_vertical"
39 android:orientation="horizontal"> 39 android:orientation="horizontal">
40 40
41 <View 41 <View
42 android:layout_width="5dp" 42 android:layout_width="5dp"
43 android:layout_height="20dp" 43 android:layout_height="20dp"
44 android:background="@color/login_text_blue"> 44 android:background="@color/login_text_blue">
45 45
46 </View> 46 </View>
47 47
48 <TextView 48 <TextView
49 android:layout_width="wrap_content" 49 android:layout_width="wrap_content"
50 android:layout_height="wrap_content" 50 android:layout_height="wrap_content"
51 android:layout_marginLeft="5dp" 51 android:layout_marginLeft="5dp"
52 android:text="账户安全" 52 android:text="账户安全"
53 android:textSize="22sp" /> 53 android:textSize="22sp" />
54 54
55 </LinearLayout> 55 </LinearLayout>
56 56
57 <LinearLayout 57 <LinearLayout
58 android:layout_width="match_parent" 58 android:layout_width="match_parent"
59 android:layout_height="wrap_content" 59 android:layout_height="wrap_content"
60 android:layout_marginLeft="60dp" 60 android:layout_marginLeft="60dp"
61 android:orientation="vertical"> 61 android:orientation="vertical">
62 62
63 <LinearLayout 63 <LinearLayout
64 android:layout_width="match_parent" 64 android:layout_width="match_parent"
65 android:layout_height="wrap_content"> 65 android:layout_height="wrap_content">
66 66
67 67
68 <TextView 68 <TextView
69 android:layout_width="0dp" 69 android:layout_width="0dp"
70 android:layout_height="wrap_content" 70 android:layout_height="wrap_content"
71 android:layout_weight="1.5" 71 android:layout_weight="1.5"
72 android:text="当前绑定手机号" 72 android:text="当前绑定手机号"
73 android:textSize="22sp" /> 73 android:textSize="22sp" />
74 74
75 <TextView 75 <TextView
76 android:id="@+id/cunt_username" 76 android:id="@+id/cunt_username"
77 android:layout_width="0dp" 77 android:layout_width="0dp"
78 android:layout_height="wrap_content" 78 android:layout_height="wrap_content"
79 android:layout_marginLeft="50dp" 79 android:layout_marginLeft="50dp"
80 android:layout_weight="6" 80 android:layout_weight="6"
81 android:text="" 81 android:text=""
82 android:textSize="22sp" /> 82 android:textSize="22sp" />
83 83
84 <TextView 84 <TextView
85 android:id="@+id/changBangding" 85 android:id="@+id/changBangding"
86 android:layout_width="0dp" 86 android:layout_width="0dp"
87 android:layout_height="wrap_content" 87 android:layout_height="wrap_content"
88 android:layout_weight="1" 88 android:layout_weight="1"
89 android:text="更换绑定" 89 android:text="更换绑定"
90 android:textSize="22sp" /> 90 android:textSize="22sp" />
91 91
92 <ImageView 92 <ImageView
93 android:layout_width="wrap_content" 93 android:layout_width="wrap_content"
94 android:layout_height="wrap_content" 94 android:layout_height="wrap_content"
95 android:layout_weight="0.1" 95 android:layout_weight="0.1"
96 android:padding="10dp" 96 android:padding="10dp"
97 android:src="@mipmap/youjiantou" /> 97 android:src="@mipmap/youjiantou" />
98 </LinearLayout> 98 </LinearLayout>
99 99
100 <LinearLayout 100 <LinearLayout
101 android:layout_width="match_parent" 101 android:layout_width="match_parent"
102 android:layout_height="wrap_content" 102 android:layout_height="wrap_content"
103 android:layout_marginTop="30dp"> 103 android:layout_marginTop="30dp">
104 104
105 105
106 <TextView 106 <TextView
107 android:layout_width="0dp" 107 android:layout_width="0dp"
108 android:layout_height="wrap_content" 108 android:layout_height="wrap_content"
109 android:layout_weight="1.5" 109 android:layout_weight="1.5"
110 android:text="登录密码" 110 android:text="登录密码"
111 android:textSize="22sp" /> 111 android:textSize="22sp" />
112 112
113 <TextView 113 <TextView
114 android:layout_width="0dp" 114 android:layout_width="0dp"
115 android:layout_height="wrap_content" 115 android:layout_height="wrap_content"
116 android:layout_marginLeft="50dp" 116 android:layout_marginLeft="50dp"
117 android:layout_weight="6" 117 android:layout_weight="6"
118 android:text="已设置" 118 android:text="已设置"
119 android:textSize="22sp" /> 119 android:textSize="22sp" />
120 120
121 <TextView 121 <TextView
122 android:id="@+id/changpassword" 122 android:id="@+id/changpassword"
123 android:layout_width="0dp" 123 android:layout_width="0dp"
124 android:layout_height="wrap_content" 124 android:layout_height="wrap_content"
125 android:layout_weight="1" 125 android:layout_weight="1"
126 android:text="修改密码" 126 android:text="修改密码"
127 android:textSize="22sp" /> 127 android:textSize="22sp" />
128 128
129 <ImageView 129 <ImageView
130 android:layout_width="wrap_content" 130 android:layout_width="wrap_content"
131 android:layout_height="wrap_content" 131 android:layout_height="wrap_content"
132 android:layout_weight="0.1" 132 android:layout_weight="0.1"
133 android:padding="10dp" 133 android:padding="10dp"
134 android:src="@mipmap/youjiantou" /> 134 android:src="@mipmap/youjiantou" />
135 </LinearLayout> 135 </LinearLayout>
136 136
137 </LinearLayout> 137 </LinearLayout>
138 138
139 <View 139 <View
140 android:layout_width="match_parent" 140 android:layout_width="match_parent"
141 android:layout_height="0.7dp" 141 android:layout_height="0.7dp"
142 android:layout_margin="20dp" 142 android:layout_margin="20dp"
143 android:background="#FF909090" /> 143 android:background="#FF909090" />
144 144
145 <LinearLayout 145 <LinearLayout
146 android:layout_width="wrap_content" 146 android:layout_width="wrap_content"
147 android:layout_height="wrap_content" 147 android:layout_height="wrap_content"
148 android:layout_margin="20dp" 148 android:layout_margin="20dp"
149 android:gravity="center_vertical" 149 android:gravity="center_vertical"
150 android:orientation="horizontal"> 150 android:orientation="horizontal">
151 151
152 <View 152 <View
153 android:layout_width="5dp" 153 android:layout_width="5dp"
154 android:layout_height="20dp" 154 android:layout_height="20dp"
155 android:background="@color/login_text_blue"> 155 android:background="@color/login_text_blue">
156 156
157 </View> 157 </View>
158 158
159 <TextView 159 <TextView
160 android:layout_width="wrap_content" 160 android:layout_width="wrap_content"
161 android:layout_height="wrap_content" 161 android:layout_height="wrap_content"
162 android:layout_marginLeft="5dp" 162 android:layout_marginLeft="5dp"
163 android:text="子账户管理" 163 android:text="子账户管理"
164 android:textSize="22sp" /> 164 android:textSize="22sp" />
165 165
166 </LinearLayout> 166 </LinearLayout>
167 167
168 <LinearLayout 168 <LinearLayout
169 android:layout_width="match_parent" 169 android:layout_width="match_parent"
170 android:layout_height="match_parent" 170 android:layout_height="match_parent"
171 android:layout_marginLeft="30dp" 171 android:layout_marginLeft="30dp"
172 android:orientation="vertical"> 172 android:orientation="vertical">
173 173
174 <LinearLayout 174 <LinearLayout
175 android:layout_width="match_parent" 175 android:layout_width="match_parent"
176 android:layout_height="wrap_content"> 176 android:layout_height="wrap_content">
177 177
178 <LinearLayout 178 <LinearLayout
179 android:layout_width="0dp" 179 android:layout_width="0dp"
180 android:layout_height="wrap_content" 180 android:layout_height="wrap_content"
181 android:layout_weight="1"> 181 android:layout_weight="1">
182 182
183 <LinearLayout 183 <LinearLayout
184 android:id="@+id/ll_zhu_backgrangd" 184 android:id="@+id/ll_zhu_backgrangd"
185 android:layout_width="wrap_content" 185 android:layout_width="wrap_content"
186 android:layout_height="wrap_content" 186 android:layout_height="wrap_content"
187 android:background="@drawable/corcle_blue_bg" 187 android:background="@drawable/corcle_blue_bg"
188 android:orientation="vertical"> 188 android:orientation="vertical">
189 189
190 <LinearLayout 190 <LinearLayout
191 android:layout_width="match_parent" 191 android:layout_width="match_parent"
192 android:layout_height="wrap_content" 192 android:layout_height="wrap_content"
193 android:orientation="horizontal"> 193 android:orientation="horizontal">
194 194
195 <com.facebook.drawee.view.SimpleDraweeView 195 <com.facebook.drawee.view.SimpleDraweeView
196 android:id="@+id/tv_account_head" 196 android:id="@+id/tv_account_head"
197 android:layout_width="60dp" 197 android:layout_width="60dp"
198 android:layout_height="60dp" 198 android:layout_height="60dp"
199 android:layout_margin="10dp" 199 android:layout_margin="10dp"
200 fresco:placeholderImage="@mipmap/header_default" 200 fresco:placeholderImage="@mipmap/header_default"
201 fresco:placeholderImageScaleType="fitCenter" 201 fresco:placeholderImageScaleType="fitCenter"
202 fresco:roundAsCircle="true" /> 202 fresco:roundAsCircle="true" />
203 203
204 <LinearLayout 204 <LinearLayout
205 android:layout_width="0dp" 205 android:layout_width="0dp"
206 android:layout_height="wrap_content" 206 android:layout_height="wrap_content"
207 android:layout_marginLeft="10dp" 207 android:layout_marginLeft="10dp"
208 android:layout_marginTop="10dp" 208 android:layout_marginTop="10dp"
209 android:layout_weight="1" 209 android:layout_weight="1"
210 android:orientation="vertical"> 210 android:orientation="vertical">
211 211
212 <TextView 212 <TextView
213 android:id="@+id/tv_account_name" 213 android:id="@+id/tv_account_name"
214 android:layout_width="wrap_content" 214 android:layout_width="wrap_content"
215 android:layout_height="wrap_content" 215 android:layout_height="wrap_content"
216 android:text="" 216 android:text=""
217 android:textSize="18sp" /> 217 android:textSize="18sp" />
218 218
219 <TextView 219 <TextView
220 android:id="@+id/tv_account_grade" 220 android:id="@+id/tv_account_grade"
221 android:layout_width="wrap_content" 221 android:layout_width="wrap_content"
222 android:layout_height="wrap_content" 222 android:layout_height="wrap_content"
223 android:text="" 223 android:text=""
224 android:textSize="18sp" /> 224 android:textSize="18sp" />
225 225
226 <TextView 226 <TextView
227 android:id="@+id/tv_account_school" 227 android:id="@+id/tv_account_school"
228 android:layout_width="wrap_content" 228 android:layout_width="wrap_content"
229 android:layout_height="wrap_content" 229 android:layout_height="wrap_content"
230 android:text="" 230 android:text=""
231 android:textSize="18sp" /> 231 android:textSize="18sp" />
232 232
233 <TextView 233 <TextView
234 android:id="@+id/tv_account_adress" 234 android:id="@+id/tv_account_adress"
235 android:layout_width="wrap_content" 235 android:layout_width="wrap_content"
236 android:layout_height="wrap_content" 236 android:layout_height="wrap_content"
237 android:text="" 237 android:text=""
238 android:textSize="18sp" /> 238 android:textSize="18sp" />
239 239
240 240
241 </LinearLayout> 241 </LinearLayout>
242 242
243 <ImageView 243 <ImageView
244 android:id="@+id/iv_shiyongzhong" 244 android:id="@+id/iv_shiyongzhong"
245 android:layout_width="wrap_content" 245 android:layout_width="wrap_content"
246 android:layout_height="wrap_content" 246 android:layout_height="wrap_content"
247 android:layout_gravity="right" 247 android:layout_gravity="right"
248 android:layout_marginLeft="60dp" 248 android:layout_marginLeft="60dp"
249 android:src="@mipmap/shiyongzhong" 249 android:src="@mipmap/shiyongzhong"
250 android:visibility="gone" /> 250 android:visibility="gone" />
251 251
252 </LinearLayout> 252 </LinearLayout>
253 253
254 <View 254 <View
255 android:layout_width="match_parent" 255 android:layout_width="match_parent"
256 android:layout_height="0.7dp" 256 android:layout_height="0.7dp"
257 android:layout_margin="10dp" 257 android:layout_margin="10dp"
258 android:background="@color/cutoff_line"> 258 android:background="@color/cutoff_line">
259 259
260 </View> 260 </View>
261 261
262 <LinearLayout 262 <LinearLayout
263 android:layout_width="match_parent" 263 android:layout_width="match_parent"
264 android:layout_height="wrap_content" 264 android:layout_height="wrap_content"
265 android:layout_marginBottom="10dp" 265 android:layout_marginBottom="10dp"
266 android:orientation="horizontal"> 266 android:orientation="horizontal">
267 267
268 <TextView 268 <TextView
269 android:id="@+id/change_zhu_account" 269 android:id="@+id/change_zhu_account"
270 android:layout_width="0dp" 270 android:layout_width="0dp"
271 android:layout_height="wrap_content" 271 android:layout_height="wrap_content"
272 android:layout_weight="1" 272 android:layout_weight="1"
273 android:gravity="center" 273 android:gravity="center"
274 android:text="切换主账户" 274 android:text="切换主账户"
275 android:textSize="18sp" /> 275 android:textSize="18sp" />
276 276
277 277
278 </LinearLayout> 278 </LinearLayout>
279 279
280 </LinearLayout> 280 </LinearLayout>
281 281
282 282
283 </LinearLayout> 283 </LinearLayout>
284 284
285 <LinearLayout 285 <LinearLayout
286 android:layout_width="0dp" 286 android:layout_width="0dp"
287 android:layout_height="wrap_content" 287 android:layout_height="wrap_content"
288 android:layout_weight="1"> 288 android:layout_weight="1">
289 289
290 </LinearLayout> 290 </LinearLayout>
291 291
292 <LinearLayout 292 <LinearLayout
293 android:layout_width="0dp" 293 android:layout_width="0dp"
294 android:layout_height="wrap_content" 294 android:layout_height="wrap_content"
295 android:layout_weight="1"> 295 android:layout_weight="1">
296 296
297 </LinearLayout> 297 </LinearLayout>
298 </LinearLayout> 298 </LinearLayout>
299 299
300 <RelativeLayout 300 <RelativeLayout
301 android:layout_width="match_parent" 301 android:layout_width="match_parent"
302 android:layout_height="wrap_content" 302 android:layout_height="wrap_content"
303 android:layout_marginTop="20dp" 303 android:layout_marginTop="20dp"
304 android:orientation="horizontal"> 304 android:orientation="horizontal">
305 305
306 <android.support.v7.widget.RecyclerView 306 <android.support.v7.widget.RecyclerView
307 android:id="@+id/id_recyclerview_horizontal" 307 android:id="@+id/id_recyclerview_horizontal"
308 android:layout_width="wrap_content" 308 android:layout_width="wrap_content"
309 android:layout_height="wrap_content" 309 android:layout_height="wrap_content"
310 android:layout_centerVertical="true" 310 android:layout_centerVertical="true"
311 android:layout_toLeftOf="@+id/add_account" 311 android:layout_toLeftOf="@+id/add_account"
312 android:scrollbars="none"></android.support.v7.widget.RecyclerView> 312 android:scrollbars="none">
313
314 </android.support.v7.widget.RecyclerView>
313 315
314 <LinearLayout 316 <LinearLayout
315 android:id="@+id/add_account" 317 android:id="@+id/add_account"
316 android:layout_width="415dp" 318 android:layout_width="415dp"
317 android:layout_height="165dp" 319 android:layout_height="165dp"
318 android:layout_alignParentRight="true" 320 android:layout_alignParentRight="true"
319 android:layout_marginLeft="10dp" 321 android:layout_marginLeft="10dp"
320 android:layout_marginRight="20dp" 322 android:layout_marginRight="20dp"
321 android:background="@drawable/corcle_black_bg" 323 android:background="@drawable/corcle_black_bg"
322 android:gravity="center"> 324 android:gravity="center">
323 325
324 <ImageView 326 <ImageView
325 android:layout_width="wrap_content" 327 android:layout_width="wrap_content"
326 android:layout_height="wrap_content" 328 android:layout_height="wrap_content"
327 android:src="@mipmap/jia" /> 329 android:src="@mipmap/jia" />
328 330
329 </LinearLayout> 331 </LinearLayout>
330 332
331 333
332 </RelativeLayout> 334 </RelativeLayout>
333 335
334 </LinearLayout> 336 </LinearLayout>
335 337
336 338
337 </LinearLayout> 339 </LinearLayout>
PersonalCenter/app/src/main/res/layout/activity_binding_code.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" 3 android:orientation="vertical"
4 android:layout_width="match_parent" 4 android:layout_width="match_parent"
5 android:gravity="center" 5 android:gravity="center"
6 android:layout_height="match_parent"> 6 android:layout_height="match_parent">
7 <ImageView 7 <LinearLayout
8 android:id="@+id/EQpicture"
9 android:layout_width="wrap_content" 8 android:layout_width="wrap_content"
10 android:layout_height="wrap_content" /> 9 android:layout_height="wrap_content"
10 android:orientation="vertical"
11 android:gravity="center">
12 <ImageView
13 android:id="@+id/EQpicture"
14 android:layout_width="wrap_content"
15 android:layout_height="wrap_content" />
16 <TextView
17 android:layout_width="wrap_content"
18 android:layout_height="wrap_content"
19 android:paddingLeft="250dp"
20 android:paddingRight="250dp"
21 android:textSize="18sp"
22 android:text="方式一:扫描上图中的二维码,下载“好记星家教老师”app,打开app,再次扫描二维码完成绑定,若您已下载最新版app,则可直接扫描二维码绑定即可开始管理您的机器;
23 "/>
24 <TextView
25 android:layout_marginTop="5dp"
26 android:layout_width="wrap_content"
27 android:layout_height="wrap_content"
28 android:paddingLeft="250dp"
29 android:paddingRight="250dp"
30 android:textSize="18sp"
31 android:text="方式二:打开本机找到“家长控制”应用,输入初始密码“123456”,进入后,即可开始管理您的机器。"/>
32
33 <RelativeLayout
34 android:layout_width="wrap_content"
35 android:layout_height="wrap_content"
36 android:layout_alignParentBottom="true"
37 android:layout_marginTop="20dp"
38 android:paddingLeft="250dp"
39 android:paddingRight="250dp">
40 <Button
41 android:id="@+id/btn_next_tep"
42 style="@style/button_login_register_style"
43 android:layout_marginBottom="50dp"
44 android:text="下一步" />
45 </RelativeLayout>
46
47 </LinearLayout>
48
11 49
PersonalCenter/app/src/main/res/layout/fragment_loginandregister_login.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent" 3 android:layout_width="match_parent"
4 android:layout_height="match_parent" 4 android:layout_height="match_parent"
5 android:background="#ffffffff" 5 android:background="#ffffffff"
6 android:orientation="vertical" 6 android:orientation="vertical"
7 android:paddingLeft="250dp" 7 android:paddingLeft="300dp"
8 android:paddingRight="250dp" > 8 android:paddingRight="300dp" >
9 9
10 10
11 <EditText 11 <EditText
12 android:id="@+id/et_phonenumber" 12 android:id="@+id/et_phonenumber"
13 style="@style/login_register_edit_style" 13 style="@style/login_register_edit_style"
14 android:layout_marginTop="20dp" 14 android:layout_marginTop="20dp"
15 android:textColor="@color/login_text_black" 15 android:textColor="@color/login_text_black"
16 android:inputType="phone" 16 android:inputType="phone"
17 android:hint="手机号" /> 17 android:hint="手机号" />
18 18
19 <EditText 19 <EditText
20 android:id="@+id/et_password" 20 android:id="@+id/et_password"
21 style="@style/login_register_edit_style" 21 style="@style/login_register_edit_style"
22 android:layout_below="@id/et_phonenumber" 22 android:layout_below="@id/et_phonenumber"
23 android:layout_marginTop="30dp" 23 android:layout_marginTop="30dp"
24 android:textColor="@color/login_text_black" 24 android:textColor="@color/login_text_black"
25 android:hint="密码" 25 android:hint="密码"
26 android:inputType="textPassword" /> 26 android:inputType="textPassword" />
27 27
28 <Button 28 <Button
29 android:id="@+id/btn_login" 29 android:id="@+id/btn_login"
30 style="@style/button_login_register_style" 30 style="@style/button_login_register_style"
31 android:layout_below="@id/et_password" 31 android:layout_below="@id/et_password"
32 android:layout_marginTop="30dp" 32 android:layout_marginTop="30dp"
33 android:text="登 录" /> 33 android:text="登 录" />
34 34
35 <TextView 35 <TextView
36 android:id="@+id/tv_forget_pwd" 36 android:id="@+id/tv_forget_pwd"
37 style="@style/text_forget_pwd_style" 37 style="@style/text_forget_pwd_style"
38 android:layout_alignParentRight="true" 38 android:layout_alignParentRight="true"
39 android:layout_below="@id/btn_login" 39 android:layout_below="@id/btn_login"
40 android:layout_marginTop="15dp" 40 android:layout_marginTop="15dp"
41 android:text="@string/forget_pwd" 41 android:text="@string/forget_pwd"
42 android:textColor="@color/btn_text_color" /> 42 android:textColor="@color/btn_text_color" />
43 43
44 </RelativeLayout> 44 </RelativeLayout>
PersonalCenter/app/src/main/res/layout/fragment_loginandregister_register.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent" 3 android:layout_width="match_parent"
4 android:layout_height="match_parent" 4 android:layout_height="match_parent"
5 android:background="#ffffffff" 5 android:background="#ffffffff"
6 android:orientation="vertical" 6 android:orientation="vertical"
7 android:paddingLeft="250dp" 7 android:paddingLeft="300dp"
8 android:paddingRight="250dp"> 8 android:paddingRight="300dp">
9 9
10 <EditText 10 <EditText
11 android:id="@+id/et_phonenumber" 11 android:id="@+id/et_phonenumber"
12 style="@style/login_register_edit_style" 12 style="@style/login_register_edit_style"
13 android:layout_marginTop="20dp" 13 android:layout_marginTop="20dp"
14 android:hint="手机号" 14 android:hint="手机号"
15 android:inputType="phone" /> 15 android:inputType="phone" />
16 16
17 <TextView 17 <TextView
18 android:id="@+id/phonenumber_error_hint" 18 android:id="@+id/phonenumber_error_hint"
19 style="@style/registererrhint_style" 19 style="@style/registererrhint_style"
20 android:layout_below="@id/et_phonenumber" /> 20 android:layout_below="@id/et_phonenumber" />
21 21
22 <LinearLayout 22 <LinearLayout
23 android:id="@+id/rl_authcode" 23 android:id="@+id/rl_authcode"
24 android:layout_width="match_parent" 24 android:layout_width="match_parent"
25 android:layout_height="wrap_content" 25 android:layout_height="wrap_content"
26 android:layout_below="@id/et_phonenumber" 26 android:layout_below="@id/et_phonenumber"
27 android:layout_marginTop="30dp" 27 android:layout_marginTop="30dp"
28 android:orientation="horizontal"> 28 android:orientation="horizontal">
29 29
30 <EditText 30 <EditText
31 android:id="@+id/et_authcode" 31 android:id="@+id/et_authcode"
32 style="@style/login_register_edit_rect_style" 32 style="@style/login_register_edit_rect_style"
33 android:layout_marginRight="-4px" 33 android:layout_marginRight="-4px"
34 android:layout_weight="1" 34 android:layout_weight="1"
35 android:hint="验证码" 35 android:hint="验证码"
36 android:numeric="integer" /> 36 android:numeric="integer" />
37 37
38 <Button 38 <Button
39 android:id="@+id/btn_authcode" 39 android:id="@+id/btn_authcode"
40 style="@style/login_register_btn_authcode_rect_style" 40 style="@style/login_register_btn_authcode_rect_style"
41 android:layout_marginLeft="0px"
42 android:layout_marginTop="0px"
43 android:layout_weight="2" 41 android:layout_weight="2"
44 android:text="获取验证码" 42 android:text="获取验证码"
45 android:textColor="@color/btn_text_color" /> 43 android:textColor="@color/btn_text_color" />
46 </LinearLayout> 44 </LinearLayout>
47 45
48 <TextView 46 <TextView
49 android:id="@+id/authcode_error_hint" 47 android:id="@+id/authcode_error_hint"
50 style="@style/registererrhint_style" 48 style="@style/registererrhint_style"
51 android:layout_below="@id/rl_authcode" /> 49 android:layout_below="@id/rl_authcode" />
52 50
53 <RelativeLayout 51 <RelativeLayout
54 android:id="@+id/pwd_rl" 52 android:id="@+id/pwd_rl"
55 android:layout_width="match_parent" 53 android:layout_width="match_parent"
56 android:layout_height="wrap_content" 54 android:layout_height="wrap_content"
57 android:layout_below="@id/rl_authcode" 55 android:layout_below="@id/rl_authcode"
58 android:layout_marginTop="30dp"> 56 android:layout_marginTop="30dp">
59 57
60 <EditText 58 <EditText
61 android:id="@+id/et_password" 59 android:id="@+id/et_password"
62 style="@style/login_register_edit_style" 60 style="@style/login_register_edit_style"
63 android:hint="密码为英文和数字组成,最少8位" 61 android:hint="密码为英文和数字组成,最少8位"
64 android:inputType="textPassword" /> 62 android:inputType="textPassword" />
65 63
66 <ImageView 64 <ImageView
67 android:id="@+id/iv_pwd_change" 65 android:id="@+id/iv_pwd_change"
68 android:padding="10dp" 66 android:padding="10dp"
69 android:layout_marginRight="10dp" 67 android:layout_marginRight="10dp"
70 android:layout_marginLeft="10dp" 68 android:layout_marginLeft="10dp"
71 android:layout_width="40dp" 69 android:layout_width="40dp"
72 android:layout_height="wrap_content" 70 android:layout_height="wrap_content"
73 android:layout_alignParentRight="true" 71 android:layout_alignParentRight="true"
74 android:layout_centerVertical="true" 72 android:layout_centerVertical="true"
75 android:src="@mipmap/pwd_hide" /> 73 android:src="@mipmap/pwd_hide" />
76 </RelativeLayout> 74 </RelativeLayout>
77 75
78 <TextView 76 <TextView
79 android:id="@+id/password_error_hint" 77 android:id="@+id/password_error_hint"
80 style="@style/registererrhint_style" 78 style="@style/registererrhint_style"
81 android:layout_below="@id/pwd_rl" /> 79 android:layout_below="@id/pwd_rl" />
82 80
83 <Button 81 <Button
84 android:id="@+id/btn_register" 82 android:id="@+id/btn_register"
85 style="@style/button_login_register_style" 83 style="@style/button_login_register_style"
86 android:layout_below="@id/pwd_rl" 84 android:layout_below="@id/pwd_rl"
87 android:layout_marginTop="30dp" 85 android:layout_marginTop="30dp"
88 android:text="立即注册" /> 86 android:text="立即注册" />
89 87
90 </RelativeLayout> 88 </RelativeLayout>
PersonalCenter/app/src/main/res/values/strings.xml
1 <resources> 1 <resources>
2 <string name="app_name">PersonalCenter</string> 2 <string name="app_name">个人中心</string>
3 3
4 4
5 5
6 //登录注册 6 //登录注册
7 <string name="cancel">取 消</string> 7 <string name="cancel">取 消</string>
8 <string name="ok">确 定</string> 8 <string name="ok">确 定</string>
9 <string name="forget_pwd">忘记密码</string> 9 <string name="forget_pwd">忘记密码</string>
10 <string name="string_menu_title">忘记密码</string> 10 <string name="string_menu_title">忘记密码</string>
11 <string name="string_regist_info">填写注册信息</string> 11 <string name="string_regist_info">填写注册信息</string>
12 <string name="string_textbook_info">选择教材版本</string> 12 <string name="string_textbook_info">选择教材版本</string>
13 <string name="string_regist_username">用户名</string> 13 <string name="string_regist_username">用户名</string>
14 <string name="string_regist_region">地区</string> 14 <string name="string_regist_region">地区</string>
15 <string name="string_regist_grade">年级</string> 15 <string name="string_regist_grade">年级</string>
16 <string name="string_regist_school">学校</string> 16 <string name="string_regist_school">学校</string>
17 <string name="string_regist_next">下一步</string> 17 <string name="string_regist_next">下一步</string>
18 <string name="string_start_page">开始学习体验</string> 18 <string name="string_start_page">开始学习体验</string>
19 <string name="bangding">绑定家长控制</string> 19 <string name="bangding">绑定家长控制</string>
20 <string name="finish">完成</string> 20 <string name="finish">完成</string>
21 <string name="account_management">账户管理</string> 21 <string name="account_management">账户管理</string>
22 <string name="changge_preson">修改个人信息</string> 22 <string name="changge_preson">修改个人信息</string>
23 23
24 //电子保卡 24 //电子保卡
25 <string name="string_electroniccard_info_title">填写保卡信息</string> 25 <string name="string_electroniccard_info_title">填写保卡信息</string>
26 <string name="string_electroniccard_info_fill">填写电子保卡</string> 26 <string name="string_electroniccard_info_fill">填写电子保卡</string>
27 <string name="change_electroniccard_info_fill">修改保卡信息</string> 27 <string name="change_electroniccard_info_fill">修改保卡信息</string>
28 <string name="string_electroniccard_info_change">修改保卡信息</string> 28 <string name="string_electroniccard_info_change">修改保卡信息</string>
29 <string name="string_electroniccard_info_ok">确认保卡信息</string> 29 <string name="string_electroniccard_info_ok">确认保卡信息</string>
30 <string name="string_electroniccard_info_look">好记星-电子报卡</string> 30 <string name="string_electroniccard_info_look">好记星-电子保卡</string>
31 <string name="string_electroniccard_change_bangding">更换绑定</string> 31 <string name="string_electroniccard_change_bangding">更换绑定</string>
32 <string name="electronic_card">温馨提示:若您想修改的相关信息请拨打客服电话</string> 32 <string name="electronic_card">温馨提示:若您想修改的相关信息请拨打客服电话</string>
33 <string name="electronic_card1">请先填写《好记星-电子保卡》信息</string> 33 <string name="electronic_card1">请先填写《好记星-电子保卡》信息</string>
34 <string name="electronic_card2">该信息是本产品的三包证明,为维护您的合法权益,请认真填写</string> 34 <string name="electronic_card2">该信息是本产品的三包证明,为维护您的合法权益,请认真填写</string>
35 <string name="electronic_card3">您已填写完《好记星-电子保卡》信息</string> 35 <string name="electronic_card3">您已填写完《好记星-电子保卡》信息</string>
36 <string name="electronic_card4">您也可以设置家长管理,用手机及时了解和管理孩子的学习情况</string> 36 <string name="electronic_card4">您也可以设置家长管理,用手机及时了解和管理孩子的学习情况</string>
37 37
38 //意见反馈 38 //意见反馈
39 <string name="feedback">写下您对我们产品的意见吧,我们将努力完善,最多输入500字。</string> 39 <string name="feedback">写下您对我们产品的意见吧,我们将努力完善,最多输入500字。</string>
40 <string name="qq">QQ或手机号码</string> 40 <string name="qq">QQ或手机号码</string>
41 <string name="hint">留下您的联系方式,方便与您沟通。</string> 41 <string name="hint">留下您的联系方式,方便与您沟通。</string>
42 42
43 43
44 //个人中心 44 //个人中心
45 <string name="titel_preson">个人中心</string> 45 <string name="titel_preson">个人中心</string>
46 46
47 47
48 48
49 </resources> 49 </resources>
50 50
PersonalCenter/app/src/main/res/values/styles.xml
1 <resources> 1 <resources>
2 2
3 <!-- Base application theme. --> 3 <!-- Base application theme. -->
4 <style name="AppTheme" parent="Theme.AppCompat"> 4 <style name="AppTheme" parent="Theme.AppCompat">
5 <!-- Customize your theme here. --> 5 <!-- Customize your theme here. -->
6 <item name="colorPrimary">@color/colorPrimary</item> 6 <item name="colorPrimary">@color/colorPrimary</item>
7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8 <item name="colorAccent">@color/colorAccent</item> 8 <item name="colorAccent">@color/colorAccent</item>
9 </style> 9 </style>
10 10
11 <style name="login_register_edit_style"> 11 <style name="login_register_edit_style">
12 <item name="android:textSize">19sp</item> 12 <item name="android:textSize">19sp</item>
13 <item name="android:singleLine">true</item> 13 <item name="android:singleLine">true</item>
14 <item name="android:background">@drawable/selector_edittext_bg</item> 14 <item name="android:background">@drawable/selector_edittext_bg</item>
15 <item name="android:layout_width">match_parent</item> 15 <item name="android:layout_width">match_parent</item>
16 <item name="android:layout_height">wrap_content</item> 16 <item name="android:layout_height">wrap_content</item>
17 <item name="android:textColorHint">@color/login_edittext_hint</item> 17 <item name="android:textColorHint">@color/login_edittext_hint</item>
18 <item name="android:padding">10dp</item> 18 <item name="android:padding">10dp</item>
19 </style> 19 </style>
20 20
21 <style name="login_register_edit_rect_style"> 21 <style name="login_register_edit_rect_style">
22 <item name="android:textSize">19sp</item> 22 <item name="android:textSize">19sp</item>
23 <item name="android:singleLine">true</item> 23 <item name="android:singleLine">true</item>
24 <item name="android:background">@drawable/selector_edittext_rect_bg</item> 24 <item name="android:background">@drawable/selector_edittext_rect_bg</item>
25 <item name="android:layout_width">match_parent</item> 25 <item name="android:layout_width">match_parent</item>
26 <item name="android:layout_height">wrap_content</item> 26 <item name="android:layout_height">wrap_content</item>
27 <item name="android:textColorHint">@color/login_edittext_hint</item> 27 <item name="android:textColorHint">@color/login_edittext_hint</item>
28 <item name="android:padding">10dp</item> 28 <item name="android:paddingRight">10dp</item>
29 <item name="android:paddingTop">10dp</item>
30 <item name="android:paddingLeft">10dp</item>
31 <item name="android:paddingBottom">12dp</item>
29 </style> 32 </style>
30 33
31 <style name="login_register_btn_authcode_rect_style"> 34 <style name="login_register_btn_authcode_rect_style">
32 <item name="android:textSize">19sp</item> 35 <item name="android:textSize">19sp</item>
33 <item name="android:singleLine">true</item> 36 <item name="android:singleLine">true</item>
34 <item name="android:background">@drawable/btn_rect_normal</item> 37 <item name="android:background">@drawable/btn_rect_normal</item>
35 <item name="android:layout_width">match_parent</item> 38 <item name="android:layout_width">match_parent</item>
36 <item name="android:layout_height">wrap_content</item> 39 <item name="android:layout_height">wrap_content</item>
37 <item name="android:textColorHint">@color/login_edittext_hint</item> 40 <item name="android:textColorHint">@color/login_edittext_hint</item>
38 <item name="android:padding">10dp</item> 41 <item name="android:padding">10dp</item>
39 </style> 42 </style>
40 <style name="text_login_register_style" > 43 <style name="text_login_register_style" >
41 <item name="android:layout_width">wrap_content</item> 44 <item name="android:layout_width">wrap_content</item>
42 <item name="android:layout_height">wrap_content</item> 45 <item name="android:layout_height">wrap_content</item>
43 <item name="android:textSize">22sp</item> 46 <item name="android:textSize">22sp</item>
44 <item name="android:gravity">center</item> 47 <item name="android:gravity">center</item>
45 <item name="android:padding">10dp</item> 48 <item name="android:padding">10dp</item>
46 </style> 49 </style>
47 <style name="button_login_register_style"> 50 <style name="button_login_register_style">
48 <item name="android:layout_width">match_parent</item> 51 <item name="android:layout_width">match_parent</item>
49 <item name="android:layout_height">wrap_content</item> 52 <item name="android:layout_height">wrap_content</item>
50 <item name="android:background">@drawable/selector_blue_btn_bg</item> 53 <item name="android:background">@drawable/selector_blue_btn_bg</item>
51 <item name="android:textSize">23sp</item> 54 <item name="android:textSize">23sp</item>
52 55
53 <item name="android:gravity">center</item> 56 <item name="android:gravity">center</item>
54 <item name="android:padding">10dp</item> 57 <item name="android:padding">10dp</item>
55 <item name="android:textColor">@android:color/white</item> 58 <item name="android:textColor">@android:color/white</item>
56 </style> 59 </style>
57 <style name="text_forget_pwd_style" > 60 <style name="text_forget_pwd_style" >
58 <item name="android:layout_width">wrap_content</item> 61 <item name="android:layout_width">wrap_content</item>
59 <item name="android:layout_height">wrap_content</item> 62 <item name="android:layout_height">wrap_content</item>
60 <item name="android:textSize">18sp</item> 63 <item name="android:textSize">18sp</item>
61 <item name="android:gravity">center</item> 64 <item name="android:gravity">center</item>
62 <item name="android:padding">8dp</item> 65 <item name="android:padding">8dp</item>
63 </style> 66 </style>
64 <style name="registererrhint_style"> 67 <style name="registererrhint_style">
65 <item name="android:textSize">14dip</item> 68 <item name="android:textSize">14dip</item>
66 <item name="android:layout_width">match_parent</item> 69 <item name="android:layout_width">match_parent</item>
67 <item name="android:layout_height">wrap_content</item> 70 <item name="android:layout_height">wrap_content</item>
68 <item name="android:textColor">@color/error_hint</item> 71 <item name="android:textColor">@color/error_hint</item>
69 <item name="android:layout_marginTop">5dip</item> 72 <item name="android:layout_marginTop">5dip</item>
70 </style> 73 </style>
71 <style name="iv_pwd_change_style"> 74 <style name="iv_pwd_change_style">
72 <item name="android:layout_width">wrap_content</item> 75 <item name="android:layout_width">wrap_content</item>
73 <item name="android:layout_height">wrap_content</item> 76 <item name="android:layout_height">wrap_content</item>
74 <item name="android:background">@mipmap/pwd_hide</item> 77 <item name="android:background">@mipmap/pwd_hide</item>
75 <item name="android:layout_alignParentRight">true</item> 78 <item name="android:layout_alignParentRight">true</item>
76 <item name="android:layout_centerVertical">true</item> 79 <item name="android:layout_centerVertical">true</item>
77 <item name="android:layout_marginRight">15dp</item> 80 <item name="android:layout_marginRight">15dp</item>
78 </style> 81 </style>
79 <style name="dialogWindowAnim" parent="android:Animation" mce_bogus="1"> 82 <style name="dialogWindowAnim" parent="android:Animation" mce_bogus="1">
80 <item name="android:windowEnterAnimation">@anim/dialog_enter_anim</item> 83 <item name="android:windowEnterAnimation">@anim/dialog_enter_anim</item>
81 <item name="android:windowExitAnimation">@anim/dialog_exit_anim</item> 84 <item name="android:windowExitAnimation">@anim/dialog_exit_anim</item>
82 </style> 85 </style>
83 86
84 87
85 88
86 89
87 </resources> 90 </resources>
88 91