Commit 8906c924008d7791f990b4d08f0dd65b8455cdb4

Authored by xiongwei
1 parent cc35aeb72a
Exists in master

recyclerview实现数据分离,定时器的修改

PersonalCenter/.idea/misc.xml
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="EntryPointsManager"> 3 <component name="EntryPointsManager">
4 <entry_points version="2.0" /> 4 <entry_points version="2.0" />
5 </component> 5 </component>
6 <component name="NullableNotNullManager"> 6 <component name="NullableNotNullManager">
7 <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> 7 <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
8 <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> 8 <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
9 <option name="myNullables"> 9 <option name="myNullables">
10 <value> 10 <value>
11 <list size="4"> 11 <list size="4">
12 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> 12 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
13 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> 13 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
14 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> 14 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
15 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> 15 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
16 </list> 16 </list>
17 </value> 17 </value>
18 </option> 18 </option>
19 <option name="myNotNulls"> 19 <option name="myNotNulls">
20 <value> 20 <value>
21 <list size="4"> 21 <list size="4">
22 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> 22 <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
23 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> 23 <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
24 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> 24 <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
25 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> 25 <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
26 </list> 26 </list>
27 </value> 27 </value>
28 </option> 28 </option>
29 </component> 29 </component>
30 <component name="ProjectLevelVcsManager" settingsEditedManually="false"> 30 <component name="ProjectLevelVcsManager" settingsEditedManually="false">
31 <OptionsSetting value="true" id="Add" /> 31 <OptionsSetting value="true" id="Add" />
32 <OptionsSetting value="true" id="Remove" /> 32 <OptionsSetting value="true" id="Remove" />
33 <OptionsSetting value="true" id="Checkout" /> 33 <OptionsSetting value="true" id="Checkout" />
34 <OptionsSetting value="true" id="Update" /> 34 <OptionsSetting value="true" id="Update" />
35 <OptionsSetting value="true" id="Status" /> 35 <OptionsSetting value="true" id="Status" />
36 <OptionsSetting value="true" id="Edit" /> 36 <OptionsSetting value="true" id="Edit" />
37 <ConfirmationsSetting value="0" id="Add" /> 37 <ConfirmationsSetting value="0" id="Add" />
38 <ConfirmationsSetting value="0" id="Remove" /> 38 <ConfirmationsSetting value="0" id="Remove" />
39 </component> 39 </component>
40 <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> 40 <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
41 <output url="file://$PROJECT_DIR$/build/classes" /> 41 <output url="file://$PROJECT_DIR$/build/classes" />
42 </component> 42 </component>
43 <component name="ProjectType"> 43 <component name="ProjectType">
44 <option name="id" value="Android" /> 44 <option name="id" value="Android" />
45 </component> 45 </component>
46 </project> 46 </project>
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 * Created by h on 2017/8/12. 31 * Created by h on 2017/8/12.
32 */ 32 */
33 33
34 public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener { 34 public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener {
35 private TextView changbangding,changpassword,usernames, 35 private TextView changbangding,changpassword,usernames,
36 tv_username,tv_grade,tv_school,tv_adress,tv_changzhu; 36 tv_username,tv_grade,tv_school,tv_adress,tv_changzhu;
37 private ImageView iv_useing,cancel; 37 private ImageView iv_useing,cancel;
38 private SimpleDraweeView mSimpleDraweeView; 38 private SimpleDraweeView mSimpleDraweeView;
39 private RecyclerView listview; 39 private RecyclerView listview;
40 private LinearLayout add_accunt,ll_zhu_backgrangd; 40 private LinearLayout add_accunt,ll_zhu_backgrangd;
41 private AccountChildsAdapter childsAdapter; 41 private AccountChildsAdapter childsAdapter;
42 private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>(); 42 private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>();
43 Handler handler = new Handler(){ 43 Handler handler = new Handler(){
44 @Override 44 @Override
45 public void handleMessage(Message msg) { 45 public void handleMessage(Message msg) {
46 super.handleMessage(msg); 46 super.handleMessage(msg);
47 switch (msg.what){ 47 switch (msg.what){
48 case HttpCode.CHILDS_SUCESS: 48 case HttpCode.CHILDS_SUCESS:
49 String name = null;
50 String grade = null;
51 String school = null;
52 String addr = null;
53 String phote = null;
54 List<ChildsInfo.DataBean> childList = new ArrayList<>() ;
55 List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>)msg.obj ;
56 for (int i = 0; i < list.size(); i++) {
57 int type = list.get(i).getType();
58 if(type == 1){
59 name = list.get(i).getName();
60 grade = list.get(i).getGrade();
61 school = list.get(i).getSchool();
62 addr = list.get(i).getRegion();
63 phote = list.get(i).getImage();
64 }else if (type == 2){
65 childList.add(list.get(i));
66 }
67 }
68 tv_username.setText(name);
69 tv_grade.setText(grade);
70 tv_school.setText(school);
71 tv_adress.setText(addr);
49 data.clear(); 72 data.clear();
50 data.addAll( (List<ChildsInfo.DataBean>)msg.obj); 73 data.addAll(childList);
51 childsAdapter.notifyDataSetChanged(); 74 childsAdapter.notifyDataSetChanged();
52 break; 75 break;
53 } 76 }
54 } 77 }
55 }; 78 };
56 @Override 79 @Override
57 protected void onCreate(Bundle savedInstanceState) { 80 protected void onCreate(Bundle savedInstanceState) {
58 super.onCreate(savedInstanceState); 81 super.onCreate(savedInstanceState);
59 setContentView(R.layout.activity_account_management); 82 setContentView(R.layout.activity_account_management);
60 83
61 initView(); 84 initView();
62 initData(); 85 initData();
63 initLister(); 86 initLister();
64 } 87 }
65 88
66 private void initView() { 89 private void initView() {
67 changbangding = (TextView) findViewById(R.id.changBangding); 90 changbangding = (TextView) findViewById(R.id.changBangding);
68 changpassword = (TextView) findViewById(R.id.changpassword); 91 changpassword = (TextView) findViewById(R.id.changpassword);
69 usernames = (TextView) findViewById(R.id.cunt_username); 92 usernames = (TextView) findViewById(R.id.cunt_username);
70 tv_username = (TextView) findViewById(R.id.tv_account_name); 93 tv_username = (TextView) findViewById(R.id.tv_account_name);
71 tv_grade = (TextView) findViewById(R.id.tv_account_grade); 94 tv_grade = (TextView) findViewById(R.id.tv_account_grade);
72 tv_school = (TextView) findViewById(R.id.tv_account_school); 95 tv_school = (TextView) findViewById(R.id.tv_account_school);
73 tv_adress = (TextView) findViewById(R.id.tv_account_adress); 96 tv_adress = (TextView) findViewById(R.id.tv_account_adress);
74 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head); 97 mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head);
75 iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong); 98 iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong);
76 cancel = (ImageView) findViewById(R.id.cancel); 99 cancel = (ImageView) findViewById(R.id.cancel);
77 add_accunt = (LinearLayout) findViewById(R.id.add_account); 100 add_accunt = (LinearLayout) findViewById(R.id.add_account);
78 ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd); 101 ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd);
79 tv_changzhu = (TextView) findViewById(R.id.change_zhu_account); 102 tv_changzhu = (TextView) findViewById(R.id.change_zhu_account);
80 listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); 103 listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal);
81 } 104 }
82 105
83 private void initData() { 106 private void initData() {
84 String cunt_username = SaveParam.getInstance().getLoginParam(this,"username"); 107 String cunt_username = SaveParam.getInstance().getLoginParam(this,"username");
85 String tv_usernames = SaveParam.getInstance().getLoginParam(this,SaveParam.USERNAME); 108 String tv_usernames = SaveParam.getInstance().getLoginParam(this,SaveParam.USERNAME);
86 String tv_grades = SaveParam.getInstance().getLoginParam(this,SaveParam.GRADES); 109 String tv_grades = SaveParam.getInstance().getLoginParam(this,SaveParam.GRADES);
87 String tv_schools = SaveParam.getInstance().getLoginParam(this,SaveParam.SCHOOL); 110 String tv_schools = SaveParam.getInstance().getLoginParam(this,SaveParam.SCHOOL);
88 String tv_adresss = SaveParam.getInstance().getLoginParam(this,SaveParam.ADRESS); 111 String tv_adresss = SaveParam.getInstance().getLoginParam(this,SaveParam.ADRESS);
89 String account = SaveParam.getInstance().getLoginParam(this,SaveParam.ACCOUNT); 112 String account = SaveParam.getInstance().getLoginParam(this,SaveParam.ACCOUNT);
90 usernames.setText(cunt_username); 113 usernames.setText(cunt_username);
91 tv_username.setText(tv_usernames); 114
92 tv_grade.setText(tv_grades);
93 tv_school.setText(tv_schools);
94 tv_adress.setText(tv_adresss);
95 if (account.equals("1")){ 115 if (account.equals("1")){
96 tv_changzhu.setText("使用中"); 116 tv_changzhu.setText("使用中");
97 tv_changzhu.setEnabled(false); 117 tv_changzhu.setEnabled(false);
98 iv_useing.setVisibility(View.VISIBLE); 118 iv_useing.setVisibility(View.VISIBLE);
99 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); 119 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg);
100 }else { 120 }else {
101 121
102 tv_changzhu.setText("切换主账户"); 122 tv_changzhu.setText("切换主账户");
103 tv_changzhu.setEnabled(true); 123 tv_changzhu.setEnabled(true);
104 iv_useing.setVisibility(View.GONE); 124 iv_useing.setVisibility(View.GONE);
105 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg); 125 ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg);
106 } 126 }
107 127
108 128
109 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); 129 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
110 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); 130 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
111 listview.setLayoutManager(linearLayoutManager); 131 listview.setLayoutManager(linearLayoutManager);
112 childsAdapter = new AccountChildsAdapter(data,this); 132 childsAdapter = new AccountChildsAdapter(data,this);
113 listview.addItemDecoration(new RecyclerViewSpaceItem(10)); 133 listview.addItemDecoration(new RecyclerViewSpaceItem(10));
114 listview.setAdapter(childsAdapter); 134 listview.setAdapter(childsAdapter);
115 childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() { 135 childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() {
116 @Override 136 @Override
117 public void onItemClick(View view, int position) { 137 public void onItemClick(View view, int position) {
118 138
119 AlertUtils.showToast(AccountManagementActivity.this,"你点击了"+data.get(position)); 139 AlertUtils.showToast(AccountManagementActivity.this,"你点击了"+data.get(position));
120 } 140 }
121 }); 141 });
122 142
123 } 143 }
124 144
125 145
126 private void initLister() { 146 private void initLister() {
127 changbangding.setOnClickListener(this); 147 changbangding.setOnClickListener(this);
128 changpassword.setOnClickListener(this); 148 changpassword.setOnClickListener(this);
129 cancel.setOnClickListener(this); 149 cancel.setOnClickListener(this);
130 add_accunt.setOnClickListener(this); 150 add_accunt.setOnClickListener(this);
131 tv_changzhu.setOnClickListener(this); 151 tv_changzhu.setOnClickListener(this);
132 152
133 153
134 154
135 } 155 }
136 156
137 @Override 157 @Override
138 public void onClick(View v) { 158 public void onClick(View v) {
139 switch (v.getId()){ 159 switch (v.getId()){
140 case R.id.changBangding: 160 case R.id.changBangding:
141 Intent changebangding = new Intent(); 161 Intent changebangding = new Intent();
142 changebangding.setClass(AccountManagementActivity.this,ChangeBangDingActivity.class); 162 changebangding.setClass(AccountManagementActivity.this,ChangeBangDingActivity.class);
143 startActivity(changebangding); 163 startActivity(changebangding);
144 overridePendingTransition(R.anim.rightin, R.anim.rightout); 164 overridePendingTransition(R.anim.rightin, R.anim.rightout);
145 break; 165 break;
146 case R.id.changpassword: 166 case R.id.changpassword:
147 Content.authcodeflag = 1; 167 Content.authcodeflag = 1;
148 Intent changpwd = new Intent(); 168 Intent changpwd = new Intent();
149 changpwd.setClass(AccountManagementActivity.this,ChangePasswordActivity.class); 169 changpwd.setClass(AccountManagementActivity.this,ChangePasswordActivity.class);
150 startActivity(changpwd); 170 startActivity(changpwd);
151 overridePendingTransition(R.anim.rightin, R.anim.rightout); 171 overridePendingTransition(R.anim.rightin, R.anim.rightout);
152 break; 172 break;
153 case R.id.add_account: 173 case R.id.add_account:
154 Content.accountflag = 2; 174 Content.accountflag = 2;
155 Intent account = new Intent(); 175 Intent account = new Intent();
156 account.setClass(AccountManagementActivity.this,RegisterInfoActivity.class); 176 account.setClass(AccountManagementActivity.this,RegisterInfoActivity.class);
157 startActivity(account); 177 startActivity(account);
158 overridePendingTransition(R.anim.rightin, R.anim.rightout); 178 overridePendingTransition(R.anim.rightin, R.anim.rightout);
159 179
160 break; 180 break;
161 case R.id.change_zhu_account: 181 case R.id.change_zhu_account:
162 Content.changgeaccountflag =1; 182 Content.changgeaccountflag =1;
163 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 183 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
164 SaveParam.getInstance().saveLoginParam(this,SaveParam.ACCOUNT,"1"); 184 SaveParam.getInstance().saveLoginParam(this,SaveParam.ACCOUNT,"1");
165 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); 185 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
166 try { 186 try {
167 long auserID = Long.parseLong(userID); 187 long auserID = Long.parseLong(userID);
168 HttpManager.getInstance().Accountinfo(AccountManagementActivity.this,auserID, 188 HttpManager.getInstance().Accountinfo(AccountManagementActivity.this,auserID,
169 devicenumber,1); 189 devicenumber,1);
170 190
171 } catch (NumberFormatException e) { 191 } catch (NumberFormatException e) {
172 e.printStackTrace(); 192 e.printStackTrace();
173 } 193 }
174 194
175 195
176 break; 196 break;
177 case R.id.cancel: 197 case R.id.cancel:
178 finish(); 198 finish();
179 break; 199 break;
180 200
181 } 201 }
182 202
183 } 203 }
184 204
185 @Override 205 @Override
186 protected void onResume() { 206 protected void onResume() {
187 super.onResume(); 207 super.onResume();
188 String userID = SaveParam.getInstance().getLoginParam(this,"userId"); 208 String userID = SaveParam.getInstance().getLoginParam(this,"userId");
189 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); 209 String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber();
190 try { 210 try {
191 long auserID = Long.parseLong(userID); 211 long auserID = Long.parseLong(userID);
192 HttpManager.getInstance().getchildAccountinfo(this,auserID,devicenumber,handler); 212 HttpManager.getInstance().getchildAccountinfo(this,auserID,devicenumber,handler);
193 213
194 } catch (NumberFormatException e) { 214 } catch (NumberFormatException e) {
195 e.printStackTrace(); 215 e.printStackTrace();
196 } 216 }
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.Timer;
27 import java.util.TimerTask;
28
26 /** 29 /**
27 * 忘记密码 30 * 忘记密码
28 * Created by h on 2017/6/17. 31 * Created by h on 2017/6/17.
29 */ 32 */
30 33
31 public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener { 34 public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener {
32 private ImageView back_forgit, iv_pwd_change; 35 private ImageView back_forgit, iv_pwd_change;
33 private EditText forot_pwd_phone, forot_pwd_anthcode, forot_pwd_pwd, forot_pwd_pwd2; 36 private EditText forot_pwd_phone, forot_pwd_anthcode, forot_pwd_pwd, forot_pwd_pwd2;
34 private Button forot_pwd_sub, forot_pwd_getanthcode; 37 private Button forot_pwd_sub, forot_pwd_getanthcode;
35 private String forot_pwd_phone1; 38 private String forot_pwd_phone1;
36 private String forot_pwd_anthcode1; 39 private String forot_pwd_anthcode1;
37 private String forot_pwd_pwd3; 40 private String forot_pwd_pwd3;
38 private String forot_pwd_pwd4; 41 private String forot_pwd_pwd4;
39 private String typeStr = "login"; 42 private String typeStr = "login";
40 private int i = 0; 43 private int i = 0;
41 private Thread thread; 44 private Thread thread;
42 public static Boolean showPassword = false; 45 public static Boolean showPassword = false;
43 46
44 Handler handler = new Handler() { 47 Handler handler = new Handler() {
45 @Override 48 @Override
46 public void handleMessage(Message msg) { 49 public void handleMessage(Message msg) {
47 super.handleMessage(msg); 50 super.handleMessage(msg);
48 try { 51 try {
49 JSONObject jsonObject; 52 JSONObject jsonObject;
50 String status; 53 String status;
51 switch (msg.what) { 54 switch (msg.what) {
52 case HttpCode.PASSWORD_SUCESS: 55 case HttpCode.PASSWORD_SUCESS:
53 jsonObject = (JSONObject) msg.obj; 56 jsonObject = (JSONObject) msg.obj;
54 status = jsonObject.getString("status"); 57 status = jsonObject.getString("status");
55 // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); 58 // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message"));
56 if (status.equals("100")) { 59 if (status.equals("100")) {
57 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改成功"); 60 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改成功");
58 } 61 }
59 62
60 break; 63 break;
61 case HttpCode.PASSWORD_FAIL: 64 case HttpCode.PASSWORD_FAIL:
62 jsonObject = (JSONObject) msg.obj; 65 jsonObject = (JSONObject) msg.obj;
63 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。"); 66 AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。");
64 break; 67 break;
65 case HttpCode.AUTHCODE_SUCESS1: 68 case HttpCode.AUTHCODE_SUCESS1:
66 jsonObject = (JSONObject) msg.obj; 69 jsonObject = (JSONObject) msg.obj;
67 status = jsonObject.optString("status"); 70 status = jsonObject.optString("status");
68 if (status.equals("100")) { 71 if (status.equals("100")) {
69 AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功"); 72 AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功");
70 } 73 }
71 //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); 74 //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message"));
72 break; 75 break;
73 case HttpCode.AUTHCODE_FAIL1: 76 case HttpCode.AUTHCODE_FAIL1:
74 jsonObject = (JSONObject) msg.obj; 77 jsonObject = (JSONObject) msg.obj;
75 AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络")); 78 AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络"));
76 break; 79 break;
77 case HttpCode.IS_REFISTER: 80 case HttpCode.IS_REFISTER:
78 jsonObject = (JSONObject) msg.obj; 81 jsonObject = (JSONObject) msg.obj;
79 status = jsonObject.getString("status"); 82 status = jsonObject.getString("status");
80 if (status.equals("true")) { 83 if (status.equals("true")) {
81 getauthcode(); 84 getauthcode();
82 85
83 } else { 86 } else {
84 AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册"); 87 AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册");
85 } 88 }
86 break; 89 break;
87 case 21: 90 case 21:
88 forot_pwd_getanthcode.setEnabled(false); 91 forot_pwd_getanthcode.setEnabled(false);
89 forot_pwd_getanthcode.setClickable(false); 92 forot_pwd_getanthcode.setClickable(false);
90 forot_pwd_getanthcode.setText(Integer.toString(i--) + " s"); 93 forot_pwd_getanthcode.setText(Integer.toString(i--) + " s");
91 if (i <= 0) { 94 if (i <= 0) {
92 forot_pwd_getanthcode.setEnabled(true); 95 forot_pwd_getanthcode.setEnabled(true);
93 forot_pwd_getanthcode.setClickable(true); 96 forot_pwd_getanthcode.setClickable(true);
94 forot_pwd_getanthcode.setText("获取验证码"); 97 forot_pwd_getanthcode.setText("获取验证码");
95 98
96 } 99 }
97 break; 100 break;
98 } 101 }
99 } catch (JSONException e) { 102 } catch (JSONException e) {
100 e.printStackTrace(); 103 e.printStackTrace();
101 } 104 }
102 } 105 }
103 }; 106 };
104 107
105 @Override 108 @Override
106 protected void onCreate(Bundle savedInstanceState) { 109 protected void onCreate(Bundle savedInstanceState) {
107 super.onCreate(savedInstanceState); 110 super.onCreate(savedInstanceState);
108 setContentView(R.layout.activity_forgetpsword); 111 setContentView(R.layout.activity_forgetpsword);
109 initView(); 112 initView();
110 setLister(); 113 setLister();
111 } 114 }
112 115
113 //获取验证码 116 //获取验证码
114 private void getauthcode() { 117 private void getauthcode() {
115 forot_pwd_anthcode.requestFocus(); 118 forot_pwd_anthcode.requestFocus();
116 HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this); 119 HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this);
117 i = 60; 120 i = 60;
118 if (thread == null) { 121 if (thread == null) {
119 thread = new Thread(new ThreadShow()); 122 thread = new Thread(new ThreadShow());
120 thread.start(); 123 thread.start();
121 124
122 } 125 }
123 126
124 } 127 }
125 128
126 private void initView() { 129 private void initView() {
127 forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber); 130 forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber);
128 forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode); 131 forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode);
129 forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword); 132 forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword);
130 forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword); 133 forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword);
131 forot_pwd_sub = (Button) findViewById(R.id.btn_ok); 134 forot_pwd_sub = (Button) findViewById(R.id.btn_ok);
132 forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode); 135 forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode);
133 iv_pwd_change = (ImageView) findViewById(R.id.iv_pwd_change); 136 iv_pwd_change = (ImageView) findViewById(R.id.iv_pwd_change);
134 back_forgit = (ImageView) findViewById(R.id.cancel); 137 back_forgit = (ImageView) findViewById(R.id.cancel);
135 } 138 }
136 139
137 private void setLister() { 140 private void setLister() {
138 iv_pwd_change.setOnClickListener(this); 141 iv_pwd_change.setOnClickListener(this);
139 back_forgit.setOnClickListener(this); 142 back_forgit.setOnClickListener(this);
140 forot_pwd_sub.setOnClickListener(this); 143 forot_pwd_sub.setOnClickListener(this);
141 forot_pwd_getanthcode.setOnClickListener(this); 144 forot_pwd_getanthcode.setOnClickListener(this);
142 145
143 } 146 }
144 147
145 148
146 @Override 149 @Override
147 public void onClick(View view) { 150 public void onClick(View view) {
148 switch (view.getId()) { 151 switch (view.getId()) {
149 case R.id.btn_ok: 152 case R.id.btn_ok:
150 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 153 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
151 forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim(); 154 forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim();
152 forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim(); 155 forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim();
153 forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim(); 156 forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim();
154 if (TextUtils.isEmpty(forot_pwd_phone1) || 157 if (TextUtils.isEmpty(forot_pwd_phone1) ||
155 TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)) { 158 TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)) {
156 AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整"); 159 AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整");
157 return; 160 return;
158 } else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)) { 161 } else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)) {
159 AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误"); 162 AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误");
160 163
161 } 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) {
162 AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位"); 165 AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位");
163 } 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)) {
164 AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成"); 167 AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成");
165 } else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)) { 168 } else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)) {
166 AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致"); 169 AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致");
167 return; 170 return;
168 } else { 171 } else {
169 //忘记密码接口 172 //忘记密码接口
170 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);
171 } 174 }
172 break; 175 break;
173 case R.id.btn_authcode: 176 case R.id.btn_authcode:
174 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 177 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
175 if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)) { 178 if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)) {
176 AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号"); 179 AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号");
177 } else { 180 } else {
178 forot_pwd_anthcode.requestFocus(); 181 forot_pwd_anthcode.requestFocus();
179 ifregister(); 182 ifregister();
180 183
181 } 184 }
182 185
183 break; 186 break;
184 case R.id.iv_pwd_change: 187 case R.id.iv_pwd_change:
185 if (showPassword) {//显示密码 188 if (showPassword) {//显示密码
186 showPassword = !showPassword; 189 showPassword = !showPassword;
187 iv_pwd_change.setImageResource(R.mipmap.pwd_open); 190 iv_pwd_change.setImageResource(R.mipmap.pwd_open);
188 forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); 191 forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
189 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); 192 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length());
190 } else {//隐藏密码 193 } else {//隐藏密码
191 showPassword = !showPassword; 194 showPassword = !showPassword;
192 iv_pwd_change.setImageResource(R.mipmap.pwd_hide); 195 iv_pwd_change.setImageResource(R.mipmap.pwd_hide);
193 forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); 196 forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
194 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); 197 forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length());
195 } 198 }
196 break; 199 break;
197 200
198 case R.id.cancel: 201 case R.id.cancel:
199 finish(); 202 finish();
200 break; 203 break;
201 } 204 }
202 } 205 }
203 206
204 //是否注册 207 //是否注册
205 private void ifregister() { 208 private void ifregister() {
206 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); 209 forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim();
207 HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this); 210 HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this);
208 } 211 }
209 212
210 // 线程类 定时器 213 // 线程类 定时器
211 class ThreadShow implements Runnable { 214 class ThreadShow implements Runnable {
212 215
213 @Override 216 @Override
214 public void run() { 217 public void run() {
215 // TODO Auto-generated method stub 218 // TODO Auto-generated method stub
216 while (true) { 219 while (true) {
217 try { 220 try {
218 Thread.sleep(1000); 221 Thread.sleep(1000);
219 // thread.interrupt(); 222 // thread.interrupt();
220 Message msg = new Message(); 223 Message msg = new Message();
221 msg.what = 21; 224 msg.what = 21;
222 handler.sendMessage(msg); 225 handler.sendMessage(msg);
223 System.out.println("内存泄露..."); 226 System.out.println("内存泄露...");
224 } catch (Exception e) { 227 } catch (Exception e) {
225 // TODO Auto-generated catch block 228 // TODO Auto-generated catch block
226 e.printStackTrace(); 229 e.printStackTrace();
227 System.out.println("thread error..."); 230 System.out.println("thread error...");
228 } 231 }
229 } 232 }
230 } 233 }
231 } 234 }
232 } 235 }
233 236
PersonalCenter/app/src/test/java/com/hjx/personalcenter/ExampleUnitTest.java
1 package com.hjx.personalcenter; 1 package com.hjx.personalcenter;
2 2
3 import org.junit.Test; 3 import org.junit.Test;
4 4
5 import java.util.Timer;
6 import java.util.TimerTask;
7
5 import static org.junit.Assert.*; 8 import static org.junit.Assert.*;
6 9
7 /** 10 /**
8 * Example local unit test, which will execute on the development machine (host). 11 * Example local unit test, which will execute on the development machine (host).
9 * 12 *
10 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> 13 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11 */ 14 */
12 public class ExampleUnitTest { 15 public class ExampleUnitTest {
13 @Test 16 @Test
14 public void addition_isCorrect() throws Exception { 17 public void addition_isCorrect() throws Exception {
15 assertEquals(4, 2 + 2); 18 // assertEquals(4, 2 + 2);
19 Timer timer = new Timer();
20 timer.schedule(new TimerTask() {
21 @Override
22 public void run() {
23 System.out.print("爆炸");
24 }
25 }, 60 * 1000, 1000);
16 } 26 }
17 } 27 }