Commit 11eee1b3afab04d3be24f5fc6a102fe1df57d6de
1 parent
661a7bcfd7
Exists in
master
登录,注册,忘记密码,验证码,修改密码,接口和逻辑的处理。
Showing
34 changed files
with
2021 additions
and
121 deletions
Show diff stats
PersonalCenter/app/build.gradle
... | ... | @@ -17,6 +17,12 @@ android { |
17 | 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
18 | 18 | } |
19 | 19 | } |
20 | + useLibrary 'org.apache.http.legacy' | |
21 | + sourceSets { | |
22 | + main { | |
23 | + jniLibs.srcDirs = ['libs'] | |
24 | + } | |
25 | + } | |
20 | 26 | } |
21 | 27 | |
22 | 28 | dependencies { |
... | ... | @@ -24,8 +30,12 @@ dependencies { |
24 | 30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
25 | 31 | exclude group: 'com.android.support', module: 'support-annotations' |
26 | 32 | }) |
33 | + compile 'com.tencent.bugly:crashreport:latest.release' | |
34 | + compile 'org.apache.httpcomponents:httpcore:4.4.1' | |
35 | + compile 'org.apache.httpcomponents:httpclient:4.5' | |
27 | 36 | compile 'com.android.support:appcompat-v7:25.3.1' |
28 | 37 | testCompile 'junit:junit:4.12' |
29 | 38 | compile project(':circledialog') |
30 | 39 | compile project(':pickerview') |
40 | + compile files('libs/android-async-http-1.4.8.jar') | |
31 | 41 | } | ... | ... |
PersonalCenter/app/libs/android-async-http-1.4.8.jar
No preview for this file type
PersonalCenter/app/src/main/AndroidManifest.xml
... | ... | @@ -115,7 +115,20 @@ |
115 | 115 | android:screenOrientation="landscape"> |
116 | 116 | |
117 | 117 | </activity> |
118 | - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
119 | 118 | </application> |
119 | + <!--权限--> | |
120 | + <uses-permission android:name="android.permission.CAMERA" /> | |
121 | + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
122 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
123 | + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | |
124 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
125 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
126 | + <uses-permission android:name="android.permission.CALL_PHONE" /> | |
127 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |
128 | + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | |
129 | + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | |
130 | + <uses-permission android:name="android.permission.INTERNET" /> | |
131 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
132 | + <uses-permission android:name="android.permission.READ_LOGS" /> | |
120 | 133 | |
121 | 134 | </manifest> |
122 | 135 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePasswordActivity.java
... | ... | @@ -2,17 +2,107 @@ package com.hjx.personalcenter.activity; |
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | 4 | import android.os.Bundle; |
5 | +import android.text.TextUtils; | |
6 | +import android.text.method.HideReturnsTransformationMethod; | |
7 | +import android.text.method.PasswordTransformationMethod; | |
8 | +import android.view.View; | |
9 | +import android.widget.Button; | |
10 | +import android.widget.EditText; | |
11 | +import android.widget.ImageView; | |
5 | 12 | |
6 | 13 | import com.hjx.personalcenter.R; |
14 | +import com.hjx.personalcenter.http.HttpManager; | |
15 | +import com.hjx.personalcenter.util.AlertUtils; | |
16 | +import com.hjx.personalcenter.util.PasswordCheckUtils; | |
17 | +import com.hjx.personalcenter.util.SaveParam; | |
7 | 18 | |
8 | -/** | |
9 | - * Created by h on 2017/8/9. | |
19 | +/**修改密码 | |
20 | + * Created by h on 2017/6/27. | |
10 | 21 | */ |
11 | 22 | |
12 | -public class ChangePasswordActivity extends Activity { | |
23 | +public class ChangePasswordActivity extends Activity implements View.OnClickListener { | |
24 | + private EditText old_pwd,newpassword,newpassword1; | |
25 | + private Button sub_change_pwd; | |
26 | + private ImageView back_change_pwd,eyes_iv_change1,eyes_iv_change2; | |
27 | + public static Boolean showPassword = false; | |
13 | 28 | @Override |
14 | 29 | protected void onCreate(Bundle savedInstanceState) { |
15 | 30 | super.onCreate(savedInstanceState); |
16 | 31 | setContentView(R.layout.activity_changepsword); |
32 | + initView(); | |
33 | + setLister(); | |
34 | + } | |
35 | + | |
36 | + private void initView() { | |
37 | + old_pwd = (EditText) findViewById(R.id.et_oldpassword); | |
38 | + newpassword = (EditText) findViewById(R.id.et_newpassword); | |
39 | + newpassword1 = (EditText) findViewById(R.id.et_again_newpassword); | |
40 | + sub_change_pwd = (Button) findViewById(R.id.btn_ok); | |
41 | + back_change_pwd = (ImageView) findViewById(R.id.cancel); | |
42 | + eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change); | |
43 | + | |
44 | + | |
45 | + } | |
46 | + | |
47 | + private void setLister() { | |
48 | + sub_change_pwd.setOnClickListener(this); | |
49 | + back_change_pwd.setOnClickListener(this); | |
50 | + eyes_iv_change1.setOnClickListener(this); | |
51 | + eyes_iv_change2.setOnClickListener(this); | |
52 | + } | |
53 | + | |
54 | + @Override | |
55 | + public void onClick(View v) { | |
56 | + String old_pwd1 = old_pwd.getText().toString().trim(); | |
57 | + String newpassword3 = newpassword.getText().toString().trim(); | |
58 | + String newpassword4 = newpassword1.getText().toString().trim(); | |
59 | + switch (v.getId()){ | |
60 | + //确认修改 | |
61 | + case R.id.btn_ok: | |
62 | + | |
63 | + //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password")); | |
64 | + if (TextUtils.isEmpty(old_pwd1)|| | |
65 | + TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){ | |
66 | + AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整"); | |
67 | + return; | |
68 | + }else if(newpassword3.length()<8||newpassword4.length()<8){ | |
69 | + AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位"); | |
70 | + }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | |
71 | + AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成"); | |
72 | + } | |
73 | + //得到原密码并且判断是否输入的一样 | |
74 | + else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){ | |
75 | + | |
76 | + AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误"); | |
77 | + | |
78 | + }else if (!newpassword3.equals(newpassword4)){ | |
79 | + AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致"); | |
80 | + return; | |
81 | + }else{ | |
82 | + //修改密码接口 | |
83 | + String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username"); | |
84 | + HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3); | |
85 | + } | |
86 | + | |
87 | + break; | |
88 | + case R.id.iv_pwd_change: | |
89 | + if(showPassword){//显示密码 | |
90 | + showPassword = !showPassword; | |
91 | + eyes_iv_change1.setImageResource(R.mipmap.pwd_open); | |
92 | + newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | |
93 | + newpassword.setSelection(newpassword.getText().toString().length()); | |
94 | + }else{//隐藏密码 | |
95 | + showPassword = !showPassword; | |
96 | + eyes_iv_change1.setImageResource(R.mipmap.pwd_hide); | |
97 | + newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); | |
98 | + newpassword.setSelection(newpassword.getText().toString().length()); | |
99 | + } | |
100 | + break; | |
101 | + | |
102 | + case R.id.cancel: | |
103 | + finish(); | |
104 | + break; | |
105 | + } | |
106 | + | |
17 | 107 | } |
18 | 108 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ForgotPasswordActivity.java
... | ... | @@ -2,17 +2,227 @@ package com.hjx.personalcenter.activity; |
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | 4 | import android.os.Bundle; |
5 | +import android.os.Handler; | |
6 | +import android.os.Message; | |
7 | +import android.text.TextUtils; | |
8 | +import android.text.method.HideReturnsTransformationMethod; | |
9 | +import android.text.method.PasswordTransformationMethod; | |
10 | +import android.view.View; | |
11 | +import android.widget.Button; | |
12 | +import android.widget.EditText; | |
13 | +import android.widget.ImageView; | |
5 | 14 | |
6 | 15 | import com.hjx.personalcenter.R; |
16 | +import com.hjx.personalcenter.http.HttpCode; | |
17 | +import com.hjx.personalcenter.http.HttpManager; | |
18 | +import com.hjx.personalcenter.util.AlertUtils; | |
19 | +import com.hjx.personalcenter.util.Judgment; | |
20 | +import com.hjx.personalcenter.util.PasswordCheckUtils; | |
21 | +import com.hjx.personalcenter.util.PhoneNumCheckUtils; | |
7 | 22 | |
8 | -/** | |
9 | - * Created by h on 2017/8/9. | |
23 | +import org.json.JSONException; | |
24 | +import org.json.JSONObject; | |
25 | + | |
26 | +/**忘记密码 | |
27 | + * Created by h on 2017/6/17. | |
10 | 28 | */ |
11 | 29 | |
12 | -public class ForgotPasswordActivity extends Activity { | |
30 | +public class ForgotPasswordActivity extends Activity implements View.OnClickListener { | |
31 | + private ImageView back_forgit,iv_pwd_change; | |
32 | + private EditText forot_pwd_phone,forot_pwd_anthcode,forot_pwd_pwd,forot_pwd_pwd2; | |
33 | + private Button forot_pwd_sub,forot_pwd_getanthcode; | |
34 | + private String forot_pwd_phone1; | |
35 | + private String forot_pwd_anthcode1; | |
36 | + private String forot_pwd_pwd3; | |
37 | + private String forot_pwd_pwd4; | |
38 | + private String typeStr = "login"; | |
39 | + private int i = 0; | |
40 | + private Thread thread; | |
41 | + public static Boolean showPassword = false; | |
42 | + | |
43 | + Handler handler = new Handler() { | |
44 | + @Override | |
45 | + public void handleMessage(Message msg) { | |
46 | + super.handleMessage(msg); | |
47 | + try { | |
48 | + JSONObject jsonObject; | |
49 | + String status; | |
50 | + switch (msg.what) { | |
51 | + case HttpCode.PASSWORD_SUCESS: | |
52 | + jsonObject = (JSONObject) msg.obj; | |
53 | + status = jsonObject.getString("status"); | |
54 | + // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); | |
55 | + if (status.equals("100")) { | |
56 | + AlertUtils.showToast(ForgotPasswordActivity.this,"密码修改成功"); | |
57 | + } | |
58 | + | |
59 | + break; | |
60 | + case HttpCode.PASSWORD_FAIL: | |
61 | + jsonObject = (JSONObject) msg.obj; | |
62 | + AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。"); | |
63 | + break; | |
64 | + case HttpCode.AUTHCODE_SUCESS1: | |
65 | + jsonObject = (JSONObject) msg.obj; | |
66 | + status = jsonObject.optString("status"); | |
67 | + if (status.equals("100")) { | |
68 | + AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功"); | |
69 | + } | |
70 | + //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); | |
71 | + break; | |
72 | + case HttpCode.AUTHCODE_FAIL1: | |
73 | + jsonObject = (JSONObject) msg.obj; | |
74 | + AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络")); | |
75 | + break; | |
76 | + case HttpCode.IS_REFISTER: | |
77 | + jsonObject = (JSONObject) msg.obj; | |
78 | + status = jsonObject.getString("status"); | |
79 | + if (status.equals("true")) { | |
80 | + getauthcode(); | |
81 | +// i = 60; | |
82 | +// new Thread(new ForgotPassword.ThreadShow()).start(); | |
83 | + | |
84 | + }else { | |
85 | + AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册"); | |
86 | + } | |
87 | + break; | |
88 | + case 1: | |
89 | + forot_pwd_getanthcode.setEnabled(false); | |
90 | + forot_pwd_getanthcode.setClickable(false); | |
91 | + forot_pwd_getanthcode.setText(Integer.toString(i--)+" s"); | |
92 | + if (i<=0){ | |
93 | + forot_pwd_getanthcode.setEnabled(true); | |
94 | + forot_pwd_getanthcode.setClickable(true); | |
95 | + forot_pwd_getanthcode.setText("获取验证码"); | |
96 | + | |
97 | + } | |
98 | + break; | |
99 | + } | |
100 | + } catch (JSONException e) { | |
101 | + e.printStackTrace(); | |
102 | + } | |
103 | + } | |
104 | + }; | |
13 | 105 | @Override |
14 | 106 | protected void onCreate(Bundle savedInstanceState) { |
15 | 107 | super.onCreate(savedInstanceState); |
16 | 108 | setContentView(R.layout.activity_forgetpsword); |
109 | + initView(); | |
110 | + setLister(); | |
111 | + } | |
112 | + //获取验证码 | |
113 | + private void getauthcode() { | |
114 | + forot_pwd_anthcode.requestFocus(); | |
115 | + HttpManager.getInstance().forgetauthCode(typeStr, forot_pwd_phone1, handler, this); | |
116 | + i = 60; | |
117 | + if(thread == null){ | |
118 | + thread = new Thread( new ThreadShow()); | |
119 | + thread.start(); | |
120 | + } | |
121 | + | |
122 | + } | |
123 | + | |
124 | + private void initView() { | |
125 | + forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber); | |
126 | + forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode); | |
127 | + forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword); | |
128 | + forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword); | |
129 | + forot_pwd_sub = (Button) findViewById(R.id.btn_ok); | |
130 | + forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode); | |
131 | + iv_pwd_change=(ImageView) findViewById(R.id.iv_pwd_change); | |
132 | + back_forgit= (ImageView) findViewById(R.id.cancel); | |
133 | + } | |
134 | + private void setLister() { | |
135 | + iv_pwd_change.setOnClickListener(this); | |
136 | + back_forgit.setOnClickListener(this); | |
137 | + forot_pwd_sub.setOnClickListener(this); | |
138 | + forot_pwd_getanthcode.setOnClickListener(this); | |
139 | + | |
140 | + } | |
141 | + | |
142 | + | |
143 | + @Override | |
144 | + public void onClick(View view) { | |
145 | + switch (view.getId()){ | |
146 | + case R.id.btn_ok: | |
147 | + forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); | |
148 | + forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim(); | |
149 | + forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim(); | |
150 | + forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim(); | |
151 | + if (TextUtils.isEmpty(forot_pwd_phone1)|| | |
152 | + TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)){ | |
153 | + AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整"); | |
154 | + return; | |
155 | + }else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)){ | |
156 | + AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误"); | |
157 | + | |
158 | + } | |
159 | + else if(forot_pwd_pwd3.length()<8||forot_pwd_pwd4.length()<8){ | |
160 | + AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位"); | |
161 | + }else if(!forot_pwd_pwd3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!forot_pwd_pwd4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | |
162 | + AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成"); | |
163 | + } | |
164 | + else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)){ | |
165 | + AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致"); | |
166 | + return; | |
167 | + }else { | |
168 | + //忘记密码接口 | |
169 | + HttpManager.getInstance().forgetpassword(this,forot_pwd_phone1,forot_pwd_pwd3,forot_pwd_anthcode1,handler); | |
170 | + } | |
171 | + break; | |
172 | + case R.id.btn_authcode: | |
173 | + forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); | |
174 | + if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)){ | |
175 | + AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号"); | |
176 | + }else { | |
177 | + forot_pwd_anthcode.requestFocus(); | |
178 | + ifregister(); | |
179 | + | |
180 | + } | |
181 | + | |
182 | + break; | |
183 | + case R.id.iv_pwd_change: | |
184 | + if(showPassword){//显示密码 | |
185 | + showPassword = !showPassword; | |
186 | + iv_pwd_change.setImageResource(R.mipmap.pwd_open); | |
187 | + forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | |
188 | + forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); | |
189 | + }else{//隐藏密码 | |
190 | + showPassword = !showPassword; | |
191 | + iv_pwd_change.setImageResource(R.mipmap.pwd_hide); | |
192 | + forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); | |
193 | + forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); | |
194 | + } | |
195 | + break; | |
196 | + | |
197 | + case R.id.cancel: | |
198 | + finish(); | |
199 | + break; | |
200 | + } | |
201 | + } | |
202 | + //是否注册 | |
203 | + private void ifregister() { | |
204 | + forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); | |
205 | + HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this); | |
206 | + } | |
207 | + // 线程类 定时器 | |
208 | + class ThreadShow implements Runnable { | |
209 | + | |
210 | + @Override | |
211 | + public void run() { | |
212 | + // TODO Auto-generated method stub | |
213 | + while (true) { | |
214 | + try { | |
215 | + Thread.sleep(1000); | |
216 | + Message msg = new Message(); | |
217 | + msg.what = 1; | |
218 | + handler.sendMessage(msg); | |
219 | + System.out.println("send..."); | |
220 | + } catch (Exception e) { | |
221 | + // TODO Auto-generated catch block | |
222 | + e.printStackTrace(); | |
223 | + System.out.println("thread error..."); | |
224 | + } | |
225 | + } | |
226 | + } | |
17 | 227 | } |
18 | 228 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
... | ... | @@ -2,6 +2,8 @@ package com.hjx.personalcenter.activity; |
2 | 2 | |
3 | 3 | import android.content.Intent; |
4 | 4 | import android.os.Bundle; |
5 | +import android.os.Handler; | |
6 | +import android.os.Message; | |
5 | 7 | import android.support.v7.app.AppCompatActivity; |
6 | 8 | import android.view.View; |
7 | 9 | import android.widget.Button; |
... | ... | @@ -9,7 +11,13 @@ import android.widget.EditText; |
9 | 11 | import android.widget.TextView; |
10 | 12 | |
11 | 13 | import com.hjx.personalcenter.R; |
12 | -import com.hjx.personalcenter.customdialog.ListDialog; | |
14 | +import com.hjx.personalcenter.customdialog.GradeListDialog; | |
15 | +import com.hjx.personalcenter.customdialog.ProvinceListDialog; | |
16 | +import com.hjx.personalcenter.http.HttpCode; | |
17 | +import com.hjx.personalcenter.http.HttpManager; | |
18 | + | |
19 | +import org.json.JSONException; | |
20 | +import org.json.JSONObject; | |
13 | 21 | |
14 | 22 | /**填写注册信息 熊巍 |
15 | 23 | * Created by h on 2017/8/9. |
... | ... | @@ -20,6 +28,24 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl |
20 | 28 | private TextView et_region,et_grade,et_school; |
21 | 29 | private Button btn_ok; |
22 | 30 | String[] items; |
31 | + Handler handler = new Handler() { | |
32 | + @Override | |
33 | + public void handleMessage(Message msg) { | |
34 | + super.handleMessage(msg); | |
35 | + try { | |
36 | + JSONObject jsonObject; | |
37 | + String status; | |
38 | + switch (msg.what) { | |
39 | + case HttpCode.PROVICES: | |
40 | + jsonObject = (JSONObject) msg.obj; | |
41 | + status = jsonObject.getString("status"); | |
42 | + | |
43 | + } | |
44 | + } catch (JSONException e) { | |
45 | + e.printStackTrace(); | |
46 | + } | |
47 | + } | |
48 | + }; | |
23 | 49 | |
24 | 50 | @Override |
25 | 51 | protected void onCreate(Bundle savedInstanceState) { |
... | ... | @@ -58,6 +84,7 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl |
58 | 84 | public void onClick(View v) { |
59 | 85 | switch (v.getId()){ |
60 | 86 | case R.id.et_region: |
87 | + choiseregion(); | |
61 | 88 | break; |
62 | 89 | case R.id.et_grade: |
63 | 90 | choisegrade(); |
... | ... | @@ -73,9 +100,14 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl |
73 | 100 | } |
74 | 101 | |
75 | 102 | } |
76 | - | |
103 | +//选择地区 | |
104 | + private void choiseregion() { | |
105 | + HttpManager.getInstance().provices(RegisterInfoActivity.this,handler); | |
106 | + ProvinceListDialog.getInstance().show(getSupportFragmentManager(), "ProvinceListDialog"); | |
107 | + } | |
108 | +//选择年级 | |
77 | 109 | private void choisegrade() { |
78 | - ListDialog.getInstance().show(getSupportFragmentManager(), "ListDialog"); | |
110 | + GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); | |
79 | 111 | |
80 | 112 | } |
81 | 113 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/areapicker/AreaBean.java
... | ... | @@ -0,0 +1,68 @@ |
1 | +/** | |
2 | + * HaoJiXing Teacher Q&A | |
3 | + * copyright(C)2013- Acorn International | |
4 | + * | |
5 | + * packeage:com.ozing.callteacher.widget.areapicker.Province.java | |
6 | + * create:2013年8月8日上午11:20:30 | |
7 | + */ | |
8 | +package com.hjx.personalcenter.areapicker; | |
9 | + | |
10 | +/** | |
11 | + * @author jixiaolong<jixiaolong@chinadrtv.com> | |
12 | + * @code: 015261 | |
13 | + */ | |
14 | +public class AreaBean { | |
15 | + public static final int PROVINCE = 0x11; | |
16 | + public static final int CITY = 0x12; | |
17 | + public static final int COUNTY = 0x13; | |
18 | + protected int level; | |
19 | + protected String id; | |
20 | + protected String name; | |
21 | + protected String fullName; | |
22 | + protected String parentId; | |
23 | + | |
24 | + public int getLevel() { | |
25 | + return level; | |
26 | + } | |
27 | + | |
28 | + public void setLevel(int level) { | |
29 | + this.level = level; | |
30 | + } | |
31 | + | |
32 | + public String getId() { | |
33 | + return id; | |
34 | + } | |
35 | + | |
36 | + public void setId(String id) { | |
37 | + this.id = id; | |
38 | + } | |
39 | + | |
40 | + public String getName() { | |
41 | + return name; | |
42 | + } | |
43 | + | |
44 | + public void setName(String name) { | |
45 | + this.name = name; | |
46 | + } | |
47 | + | |
48 | + public String getFullName() { | |
49 | + return fullName; | |
50 | + } | |
51 | + | |
52 | + public void setFullName(String fullName) { | |
53 | + this.fullName = fullName; | |
54 | + } | |
55 | + | |
56 | + public String getParentId() { | |
57 | + return parentId; | |
58 | + } | |
59 | + | |
60 | + public void setParentId(String parentId) { | |
61 | + this.parentId = parentId; | |
62 | + } | |
63 | + | |
64 | + @Override | |
65 | + public String toString() { | |
66 | + return fullName; | |
67 | + } | |
68 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
... | ... | @@ -0,0 +1,65 @@ |
1 | +package com.hjx.personalcenter.customdialog; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.graphics.Color; | |
5 | +import android.os.Bundle; | |
6 | +import android.view.Gravity; | |
7 | +import android.view.LayoutInflater; | |
8 | +import android.view.View; | |
9 | +import android.view.ViewGroup; | |
10 | +import android.widget.AdapterView; | |
11 | +import android.widget.ArrayAdapter; | |
12 | +import android.widget.ListView; | |
13 | +import android.widget.Toast; | |
14 | + | |
15 | +import com.hjx.personalcenter.R; | |
16 | +import com.mylhyl.circledialog.BaseCircleDialog; | |
17 | +import com.mylhyl.circledialog.res.values.CircleDimen; | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | + | |
21 | +/**自定义年级列表对话框 | |
22 | + * Created by h on 2017/8/10. | |
23 | + */ | |
24 | + | |
25 | +public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | |
26 | + ArrayAdapter listadapter; | |
27 | + ListView listView; | |
28 | + ArrayList<String> data = new ArrayList<>(); | |
29 | + public static GradeListDialog getInstance() { | |
30 | + GradeListDialog dialogFragment = new GradeListDialog(); | |
31 | + dialogFragment.setCanceledBack(true); | |
32 | + dialogFragment.setCanceledOnTouchOutside(true); | |
33 | + dialogFragment.setRadius(CircleDimen.RADIUS); | |
34 | + dialogFragment.setWidth(0.5f); | |
35 | + dialogFragment.setGravity(Gravity.CENTER); | |
36 | + dialogFragment.setBackgroundColor(Color.WHITE); | |
37 | + return dialogFragment; | |
38 | + } | |
39 | + @Override | |
40 | + public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | |
41 | + | |
42 | + return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); | |
43 | + } | |
44 | + @Override | |
45 | + public void onActivityCreated(Bundle savedInstanceState) { | |
46 | + super.onActivityCreated(savedInstanceState); | |
47 | + listView = (ListView) getView().findViewById(R.id.listadapter); | |
48 | + for (int i=0;i<=50;i++){ | |
49 | + data.add("sss"+i); | |
50 | + } | |
51 | + | |
52 | + listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); | |
53 | + listView.setAdapter(listadapter); | |
54 | + listView.setOnItemClickListener(this); | |
55 | + | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |
60 | + Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); | |
61 | + | |
62 | + dismiss(); | |
63 | + | |
64 | + } | |
65 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ListDialog.java
... | ... | @@ -1,65 +0,0 @@ |
1 | -package com.hjx.personalcenter.customdialog; | |
2 | - | |
3 | -import android.content.Context; | |
4 | -import android.graphics.Color; | |
5 | -import android.os.Bundle; | |
6 | -import android.view.Gravity; | |
7 | -import android.view.LayoutInflater; | |
8 | -import android.view.View; | |
9 | -import android.view.ViewGroup; | |
10 | -import android.widget.AdapterView; | |
11 | -import android.widget.ArrayAdapter; | |
12 | -import android.widget.ListView; | |
13 | -import android.widget.Toast; | |
14 | - | |
15 | -import com.hjx.personalcenter.R; | |
16 | -import com.mylhyl.circledialog.BaseCircleDialog; | |
17 | -import com.mylhyl.circledialog.res.values.CircleDimen; | |
18 | - | |
19 | -import java.util.ArrayList; | |
20 | - | |
21 | -/**自定义列表对话框 | |
22 | - * Created by h on 2017/8/10. | |
23 | - */ | |
24 | - | |
25 | -public class ListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | |
26 | - ArrayAdapter listadapter; | |
27 | - ListView listView; | |
28 | - ArrayList<String> data = new ArrayList<>(); | |
29 | - public static ListDialog getInstance() { | |
30 | - ListDialog dialogFragment = new ListDialog(); | |
31 | - dialogFragment.setCanceledBack(true); | |
32 | - dialogFragment.setCanceledOnTouchOutside(true); | |
33 | - dialogFragment.setRadius(CircleDimen.RADIUS); | |
34 | - dialogFragment.setWidth(0.5f); | |
35 | - dialogFragment.setGravity(Gravity.CENTER); | |
36 | - dialogFragment.setBackgroundColor(Color.WHITE); | |
37 | - return dialogFragment; | |
38 | - } | |
39 | - @Override | |
40 | - public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | |
41 | - | |
42 | - return inflater.inflate(R.layout.custom_adilog_list, container, false); | |
43 | - } | |
44 | - @Override | |
45 | - public void onActivityCreated(Bundle savedInstanceState) { | |
46 | - super.onActivityCreated(savedInstanceState); | |
47 | - listView = (ListView) getView().findViewById(R.id.listadapter); | |
48 | - for (int i=0;i<=50;i++){ | |
49 | - data.add("sss"+i); | |
50 | - } | |
51 | - | |
52 | - listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); | |
53 | - listView.setAdapter(listadapter); | |
54 | - listView.setOnItemClickListener(this); | |
55 | - | |
56 | - } | |
57 | - | |
58 | - @Override | |
59 | - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |
60 | - Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); | |
61 | - | |
62 | - dismiss(); | |
63 | - | |
64 | - } | |
65 | -} |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
... | ... | @@ -0,0 +1,64 @@ |
1 | +package com.hjx.personalcenter.customdialog; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.graphics.Color; | |
5 | +import android.os.Bundle; | |
6 | +import android.view.Gravity; | |
7 | +import android.view.LayoutInflater; | |
8 | +import android.view.View; | |
9 | +import android.view.ViewGroup; | |
10 | +import android.widget.AdapterView; | |
11 | +import android.widget.ArrayAdapter; | |
12 | +import android.widget.ListView; | |
13 | +import android.widget.Toast; | |
14 | + | |
15 | +import com.hjx.personalcenter.R; | |
16 | +import com.mylhyl.circledialog.BaseCircleDialog; | |
17 | +import com.mylhyl.circledialog.res.values.CircleDimen; | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | + | |
21 | +/**自定义年级列表对话框 | |
22 | + * Created by h on 2017/8/10. | |
23 | + */ | |
24 | + | |
25 | +public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | |
26 | + ArrayAdapter listadapter; | |
27 | + ListView listView; | |
28 | + ArrayList<String> data = new ArrayList<>(); | |
29 | + public static ProvinceListDialog getInstance() { | |
30 | + ProvinceListDialog dialogFragment = new ProvinceListDialog(); | |
31 | + dialogFragment.setCanceledBack(true); | |
32 | + dialogFragment.setCanceledOnTouchOutside(true); | |
33 | + dialogFragment.setRadius(CircleDimen.RADIUS); | |
34 | + dialogFragment.setWidth(0.5f); | |
35 | + dialogFragment.setGravity(Gravity.CENTER); | |
36 | + dialogFragment.setBackgroundColor(Color.WHITE); | |
37 | + return dialogFragment; | |
38 | + } | |
39 | + @Override | |
40 | + public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | |
41 | + return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | |
42 | + } | |
43 | + @Override | |
44 | + public void onActivityCreated(Bundle savedInstanceState) { | |
45 | + super.onActivityCreated(savedInstanceState); | |
46 | + listView = (ListView) getView().findViewById(R.id.listadapter); | |
47 | + for (int i=0;i<=50;i++){ | |
48 | + data.add("aaa"+i); | |
49 | + } | |
50 | + | |
51 | + listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); | |
52 | + listView.setAdapter(listadapter); | |
53 | + listView.setOnItemClickListener(this); | |
54 | + | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |
59 | + Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); | |
60 | + | |
61 | + dismiss(); | |
62 | + | |
63 | + } | |
64 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/RemoteException.java
... | ... | @@ -0,0 +1,34 @@ |
1 | +/** | |
2 | + * HaoJiXing Teacher Q&A | |
3 | + * copyright(C)2013- Acorn International | |
4 | + * | |
5 | + * packeage:com.ozing.callteacher.parser.RemoteException.java | |
6 | + * create:2013年7月25日下午1:58:14 | |
7 | + */ | |
8 | +package com.hjx.personalcenter.exception; | |
9 | + | |
10 | +/** | |
11 | + * @author jixiaolong<jixiaolong@chinadrtv.com> | |
12 | + * @code: 015261 | |
13 | + */ | |
14 | +public class RemoteException extends Exception { | |
15 | + private ResponseError error; | |
16 | + /** | |
17 | + * | |
18 | + */ | |
19 | + private static final long serialVersionUID = -9062978963856572686L; | |
20 | + public RemoteException(String error) { | |
21 | + super(error); | |
22 | + this.error = new ResponseError(); | |
23 | + this.error.setMessage(error); | |
24 | + this.error.setStatus(-1); | |
25 | + } | |
26 | + public RemoteException(ResponseError error) { | |
27 | + super(error.getMessage()); | |
28 | + this.error = error; | |
29 | + } | |
30 | + | |
31 | + public ResponseError getError() { | |
32 | + return error; | |
33 | + } | |
34 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/ResponseError.java
... | ... | @@ -0,0 +1,35 @@ |
1 | +/** | |
2 | + * HaoJiXing Teacher Q&A | |
3 | + * copyright(C)2013- Acorn International | |
4 | + * | |
5 | + * packeage:com.ozing.callteacher.parser.ResponseError.java | |
6 | + * create:2013年9月29日下午3:30:17 | |
7 | + */ | |
8 | +package com.hjx.personalcenter.exception; | |
9 | + | |
10 | + | |
11 | +/** | |
12 | + * @author jixiaolong<jixiaolong@chinadrtv.com> | |
13 | + * @code: 015261 | |
14 | + */ | |
15 | +public class ResponseError { | |
16 | + private int status = -1; | |
17 | + private String message; | |
18 | + public int getStatus() { | |
19 | + return status; | |
20 | + } | |
21 | + public void setStatus(int status) { | |
22 | + this.status = status; | |
23 | + } | |
24 | + public String getMessage() { | |
25 | + return message; | |
26 | + } | |
27 | + public void setMessage(String message) { | |
28 | + this.message = message; | |
29 | + } | |
30 | + | |
31 | + public boolean hasError(){ | |
32 | + return status!=0 && status!=100; | |
33 | + } | |
34 | + | |
35 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/LoginFragment.java
... | ... | @@ -4,15 +4,20 @@ import android.content.Intent; |
4 | 4 | import android.os.Bundle; |
5 | 5 | import android.support.annotation.Nullable; |
6 | 6 | import android.support.v4.app.Fragment; |
7 | +import android.text.TextUtils; | |
7 | 8 | import android.view.LayoutInflater; |
8 | 9 | import android.view.View; |
9 | 10 | import android.view.ViewGroup; |
10 | 11 | import android.widget.Button; |
12 | +import android.widget.EditText; | |
11 | 13 | import android.widget.TextView; |
12 | 14 | |
13 | 15 | import com.hjx.personalcenter.R; |
14 | 16 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; |
15 | 17 | import com.hjx.personalcenter.activity.MainActivity; |
18 | +import com.hjx.personalcenter.http.HttpManager; | |
19 | +import com.hjx.personalcenter.util.AlertUtils; | |
20 | +import com.hjx.personalcenter.util.PhoneNumCheckUtils; | |
16 | 21 | |
17 | 22 | /** |
18 | 23 | * 登录 |
... | ... | @@ -24,6 +29,7 @@ public class LoginFragment extends Fragment implements View.OnClickListener { |
24 | 29 | private int type; |
25 | 30 | private TextView tv_forget_pwd; |
26 | 31 | private Button btn_login; |
32 | + private EditText phonenumber,login_pwwd; | |
27 | 33 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
28 | 34 | Intent intent = new Intent(); |
29 | 35 | public static LoginFragment newInstance(int type) { |
... | ... | @@ -50,6 +56,8 @@ public class LoginFragment extends Fragment implements View.OnClickListener { |
50 | 56 | //初始化 |
51 | 57 | private void initView(View mView) { |
52 | 58 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); |
59 | + phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | |
60 | + login_pwwd = (EditText) mView.findViewById(R.id.et_password); | |
53 | 61 | btn_login = (Button) mView.findViewById(R.id.btn_login); |
54 | 62 | |
55 | 63 | } |
... | ... | @@ -70,11 +78,28 @@ public class LoginFragment extends Fragment implements View.OnClickListener { |
70 | 78 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
71 | 79 | break; |
72 | 80 | case R.id.btn_login: |
73 | - intent.setClass(getActivity(),MainActivity.class); | |
74 | - startActivity(intent); | |
75 | - getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | |
81 | + login(); | |
76 | 82 | break; |
77 | 83 | } |
78 | 84 | |
79 | 85 | } |
86 | + | |
87 | + private void login() { | |
88 | + final String name = phonenumber.getText().toString().trim(); | |
89 | + final String pwd = login_pwwd.getText().toString().trim(); | |
90 | + if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { | |
91 | + AlertUtils.showToast(getActivity(), "请输入手机号和密码"); | |
92 | + return; | |
93 | + }else if (!PhoneNumCheckUtils.isPhone(name)){ | |
94 | + AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | |
95 | + }else { | |
96 | + intent.setClass(getActivity(),MainActivity.class); | |
97 | + startActivity(intent); | |
98 | + getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | |
99 | + //登录接口 | |
100 | + HttpManager.getInstance().login(name,pwd, getActivity()); | |
101 | + } | |
102 | + | |
103 | + | |
104 | + } | |
80 | 105 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/RegisterFragment.java
... | ... | @@ -2,15 +2,30 @@ package com.hjx.personalcenter.fragment; |
2 | 2 | |
3 | 3 | import android.content.Intent; |
4 | 4 | import android.os.Bundle; |
5 | +import android.os.Handler; | |
6 | +import android.os.Message; | |
5 | 7 | import android.support.annotation.Nullable; |
6 | 8 | import android.support.v4.app.Fragment; |
9 | +import android.text.TextUtils; | |
10 | +import android.text.method.HideReturnsTransformationMethod; | |
11 | +import android.text.method.PasswordTransformationMethod; | |
7 | 12 | import android.view.LayoutInflater; |
8 | 13 | import android.view.View; |
9 | 14 | import android.view.ViewGroup; |
10 | 15 | import android.widget.Button; |
16 | +import android.widget.EditText; | |
17 | +import android.widget.ImageView; | |
11 | 18 | |
12 | 19 | import com.hjx.personalcenter.R; |
13 | 20 | import com.hjx.personalcenter.activity.RegisterInfoActivity; |
21 | +import com.hjx.personalcenter.http.HttpCode; | |
22 | +import com.hjx.personalcenter.http.HttpManager; | |
23 | +import com.hjx.personalcenter.util.AlertUtils; | |
24 | +import com.hjx.personalcenter.util.PasswordCheckUtils; | |
25 | +import com.hjx.personalcenter.util.PhoneNumCheckUtils; | |
26 | + | |
27 | +import org.json.JSONException; | |
28 | +import org.json.JSONObject; | |
14 | 29 | |
15 | 30 | /** |
16 | 31 | * 注册 |
... | ... | @@ -19,8 +34,16 @@ import com.hjx.personalcenter.activity.RegisterInfoActivity; |
19 | 34 | |
20 | 35 | public class RegisterFragment extends Fragment implements View.OnClickListener { |
21 | 36 | private View mView; |
22 | - private Button btn_register; | |
37 | + | |
38 | + private Button btn_register,get_authcode; | |
39 | + private EditText phonenumber,password,anth_6num;//;//密码 | |
40 | + private ImageView openeyes; | |
41 | + private String sourceStr ="android"; | |
42 | + private String typeStr = "register"; | |
43 | + private int i = 0; | |
44 | + private Thread thread; | |
23 | 45 | private int type; |
46 | + public static Boolean showPassword = false; | |
24 | 47 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
25 | 48 | |
26 | 49 | public static RegisterFragment newInstance(int type) { |
... | ... | @@ -31,6 +54,73 @@ public class RegisterFragment extends Fragment implements View.OnClickListener { |
31 | 54 | return fragment; |
32 | 55 | |
33 | 56 | } |
57 | + Handler handler = new Handler() { | |
58 | + @Override | |
59 | + public void handleMessage(Message msg) { | |
60 | + super.handleMessage(msg); | |
61 | + try { | |
62 | + JSONObject jsonObject; | |
63 | + String status; | |
64 | + switch (msg.what) { | |
65 | + case HttpCode.REGISTERED_SUCESS: | |
66 | + jsonObject = (JSONObject) msg.obj; | |
67 | + status = jsonObject.getString("status"); | |
68 | + //AlertUtils.showToast(RegisterActivity.this, jsonObject.optString("message")); | |
69 | + String access_token = jsonObject.getString("access_token"); | |
70 | + String userId = jsonObject.getString("userId"); | |
71 | + if (status.equals("100")) { | |
72 | + String usernameStr = phonenumber.getText().toString().trim(); | |
73 | + String passwordStr = password.getText().toString().trim(); | |
74 | + //HttpManager.getInstance().saveLoginInfo(usernameStr,passwordStr,access_token,"true",userId); | |
75 | + AlertUtils.showToast(getActivity(), "注册成功!"); | |
76 | + Intent intent = new Intent(); | |
77 | + intent.setClass(getActivity(),RegisterInfoActivity.class); | |
78 | + startActivity(intent); | |
79 | + getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | |
80 | + getActivity().finish(); | |
81 | + } | |
82 | + break; | |
83 | + case HttpCode.REGISTERED_FAIL: | |
84 | + AlertUtils.showToast(getActivity(), "注册失败"); | |
85 | + break; | |
86 | + case HttpCode.AUTHCODE_SUCESS: | |
87 | + jsonObject = (JSONObject) msg.obj; | |
88 | + status = jsonObject.optString("status"); | |
89 | + if (status.equals("100")) { | |
90 | + AlertUtils.showToast(getActivity(), "验证码发送成功"); | |
91 | + } | |
92 | + | |
93 | + break; | |
94 | + case HttpCode.AUTHCODE_FAIL: | |
95 | + jsonObject = (JSONObject) msg.obj; | |
96 | + AlertUtils.showToast(getActivity(), "验证码发送失败"); | |
97 | + break; | |
98 | + case HttpCode.IS_REFISTER: | |
99 | + jsonObject = (JSONObject) msg.obj; | |
100 | + status = jsonObject.getString("status"); | |
101 | + if (!status.equals("true")) { | |
102 | + getauthcode(); | |
103 | + | |
104 | + }else { | |
105 | + AlertUtils.showToast(getActivity(), "该手机号已经注册过了"); | |
106 | + } | |
107 | + break; | |
108 | + case 1: | |
109 | + get_authcode.setEnabled(false); | |
110 | + get_authcode.setClickable(false); | |
111 | + get_authcode.setText(Integer.toString(i--)+" s"); | |
112 | + if (i<=0){ | |
113 | + get_authcode.setEnabled(true); | |
114 | + get_authcode.setClickable(true); | |
115 | + get_authcode.setText("获取验证码"); | |
116 | + } | |
117 | + break; | |
118 | + } | |
119 | + } catch (JSONException e) { | |
120 | + e.printStackTrace(); | |
121 | + } | |
122 | + } | |
123 | + }; | |
34 | 124 | @Override |
35 | 125 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
36 | 126 | if (mView == null) { |
... | ... | @@ -45,12 +135,19 @@ public class RegisterFragment extends Fragment implements View.OnClickListener { |
45 | 135 | } |
46 | 136 | |
47 | 137 | private void initView(View mView) { |
138 | + get_authcode = (Button) mView.findViewById(R.id.btn_authcode); | |
139 | + anth_6num = (EditText) mView.findViewById(R.id.et_authcode); | |
140 | + phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | |
141 | + password = (EditText) mView.findViewById(R.id.et_password); | |
142 | + openeyes= (ImageView) mView.findViewById(R.id.iv_pwd_change); | |
48 | 143 | btn_register = (Button) mView.findViewById(R.id.btn_register); |
49 | 144 | |
50 | 145 | } |
51 | 146 | private void initData() { |
52 | 147 | } |
53 | 148 | private void setLister() { |
149 | + get_authcode.setOnClickListener(this); | |
150 | + openeyes.setOnClickListener(this); | |
54 | 151 | btn_register.setOnClickListener(this); |
55 | 152 | } |
56 | 153 | |
... | ... | @@ -59,12 +156,98 @@ public class RegisterFragment extends Fragment implements View.OnClickListener { |
59 | 156 | public void onClick(View v) { |
60 | 157 | switch (v.getId()){ |
61 | 158 | case R.id.btn_register: |
159 | + //测试 | |
62 | 160 | Intent intent = new Intent(); |
63 | 161 | intent.setClass(getActivity(),RegisterInfoActivity.class); |
64 | 162 | startActivity(intent); |
65 | 163 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
164 | + getActivity().finish(); | |
165 | + | |
166 | + String usernameStr = phonenumber.getText().toString().trim(); | |
167 | + String authcodeStr = anth_6num.getText().toString().trim(); | |
168 | + String passwordStr = password.getText().toString().trim(); | |
169 | + if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)||TextUtils.isEmpty(passwordStr)) { | |
170 | + AlertUtils.showToast(getActivity(), "手机号,密码和验证码不能为空"); | |
171 | + return; | |
172 | + } else if(passwordStr.length()<8){ | |
173 | + AlertUtils.showToast(getActivity(), "密码不能少于8位"); | |
174 | + }else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | |
175 | + AlertUtils.showToast(getActivity(), "手机号码输入错误"); | |
176 | + | |
177 | + }else if(!passwordStr.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | |
178 | + AlertUtils.showToast(getActivity(), "密码由英文和数字组成"); | |
179 | + }else { | |
180 | + register(); | |
181 | + } | |
182 | + | |
183 | + break; | |
184 | + case R.id.iv_pwd_change: | |
185 | + if(showPassword){//显示密码 | |
186 | + showPassword = !showPassword; | |
187 | + openeyes.setImageResource(R.mipmap.pwd_open); | |
188 | + password.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | |
189 | + password.setSelection(password.getText().toString().length()); | |
190 | + }else{//隐藏密码 | |
191 | + showPassword = !showPassword; | |
192 | + openeyes.setImageResource(R.mipmap.pwd_hide); | |
193 | + password.setTransformationMethod(PasswordTransformationMethod.getInstance()); | |
194 | + password.setSelection(password.getText().toString().length()); | |
195 | + } | |
196 | + break; | |
197 | + case R.id.btn_authcode: | |
198 | + usernameStr = phonenumber.getText().toString().trim(); | |
199 | + if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | |
200 | + AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | |
201 | + }else { | |
202 | + anth_6num.requestFocus(); | |
203 | + ifregister(); | |
204 | + } | |
205 | + | |
66 | 206 | break; |
67 | 207 | } |
68 | 208 | |
69 | 209 | } |
210 | + //获取验证码 | |
211 | + private void getauthcode() { | |
212 | + String usernameStr = phonenumber.getText().toString().trim(); | |
213 | + HttpManager.getInstance().authCode(typeStr, usernameStr, handler, getActivity()); | |
214 | + i = 60; | |
215 | + if(thread == null){ | |
216 | + thread = new Thread( new ThreadShow()); | |
217 | + thread.start(); | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + private void ifregister() { | |
222 | + String usernameStr = phonenumber.getText().toString().trim(); | |
223 | + HttpManager.getInstance().isregistered(usernameStr, handler, getActivity()); | |
224 | + } | |
225 | + | |
226 | + private void register() { | |
227 | + String usernameStr = phonenumber.getText().toString().trim(); | |
228 | + String authcodeStr = anth_6num.getText().toString().trim(); | |
229 | + String passwordStr = password.getText().toString().trim(); | |
230 | + HttpManager.getInstance().register(getActivity(), usernameStr, passwordStr, authcodeStr, sourceStr,handler); | |
231 | + } | |
232 | + // 线程类 定时器 | |
233 | + class ThreadShow implements Runnable { | |
234 | + | |
235 | + @Override | |
236 | + public void run() { | |
237 | + // TODO Auto-generated method stub | |
238 | + while (true) { | |
239 | + try { | |
240 | + Thread.sleep(1000); | |
241 | + Message msg = new Message(); | |
242 | + msg.what = 1; | |
243 | + handler.sendMessage(msg); | |
244 | + System.out.println("send..."); | |
245 | + } catch (Exception e) { | |
246 | + // TODO Auto-generated catch block | |
247 | + e.printStackTrace(); | |
248 | + System.out.println("thread error..."); | |
249 | + } | |
250 | + } | |
251 | + } | |
252 | + } | |
70 | 253 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpClient.java
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.hjx.personalcenter.http; | |
2 | + | |
3 | + | |
4 | +import com.loopj.android.http.AsyncHttpClient; | |
5 | + | |
6 | +public class HttpClient extends AsyncHttpClient { | |
7 | + private static HttpClient client; | |
8 | + | |
9 | + public static HttpClient getInstance() { | |
10 | + if(client == null) { | |
11 | + client = new HttpClient(); | |
12 | + } | |
13 | + return client; | |
14 | + } | |
15 | + private HttpClient() {} | |
16 | + | |
17 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
... | ... | @@ -0,0 +1,38 @@ |
1 | +package com.hjx.personalcenter.http; | |
2 | + | |
3 | +/** | |
4 | + * Created by wei on 2017/6/21. | |
5 | + */ | |
6 | + | |
7 | +public class HttpCode { | |
8 | + //登录 | |
9 | + public static final int LONGIN_SUCESS = 1; | |
10 | + public static final int LONGIN_FAIL = 0; | |
11 | + //注册 | |
12 | + public static final int REGISTERED_SUCESS = 2; | |
13 | + public static final int REGISTERED_FAIL = 3; | |
14 | + //注册验证码 | |
15 | + public static final int AUTHCODE_SUCESS = 4; | |
16 | + public static final int AUTHCODE_FAIL = 5; | |
17 | + //忘记密码验证码 | |
18 | + public static final int AUTHCODE_SUCESS1 = 6; | |
19 | + public static final int AUTHCODE_FAIL1 = 7; | |
20 | + //是否已经注册 | |
21 | + public static final int IS_REFISTER = 8; | |
22 | + //忘记密码 | |
23 | + public static final int PASSWORD_SUCESS = 9; | |
24 | + public static final int PASSWORD_FAIL = 10; | |
25 | + //s省 | |
26 | + public static final int PROVICES = 11; | |
27 | + //姓名 | |
28 | + public static final int CHANGENAME_SUCESS = 12; | |
29 | + //获取个人信息 | |
30 | + public static final int STUDENTINFO_SUCESS = 13; | |
31 | + //意见反馈 | |
32 | + public static final int FEEDBACL_SUCESS = 14; | |
33 | + //私人订制查询 | |
34 | + public static final int PRIVATEDZ = 15; | |
35 | + | |
36 | + | |
37 | + | |
38 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpKey.java
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.hjx.personalcenter.http; | |
2 | + | |
3 | +/**请求参数 | |
4 | + * Created by wei on 2017/6/20. | |
5 | + */ | |
6 | + | |
7 | +public class HttpKey { | |
8 | + //注册key | |
9 | + public static String USERNAME = "username"; | |
10 | + public static String PASSWORD = "password"; | |
11 | + public static String SMSCODE = "smscode"; | |
12 | + public static String SOURCE = "source"; | |
13 | + //忘记密码 | |
14 | + public static String AUTHCODE = "authCode"; | |
15 | + //注册验证码和忘记密码验证码 | |
16 | + public static String TYPE = "type"; | |
17 | + public static String MOBIL = "mobile"; | |
18 | + //修改密码 | |
19 | + public static String OLDPASS = "oldPass"; | |
20 | + public static String NEWPASS = "newPass"; | |
21 | + | |
22 | + | |
23 | + | |
24 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
... | ... | @@ -0,0 +1,325 @@ |
1 | +package com.hjx.personalcenter.http; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.app.ProgressDialog; | |
5 | +import android.content.Context; | |
6 | +import android.content.Intent; | |
7 | +import android.os.Handler; | |
8 | +import android.os.Message; | |
9 | +import android.util.Log; | |
10 | +import android.widget.Toast; | |
11 | + | |
12 | +import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | |
13 | +import com.hjx.personalcenter.util.DialogPermission; | |
14 | +import com.hjx.personalcenter.util.SaveParam; | |
15 | +import com.loopj.android.http.AsyncHttpResponseHandler; | |
16 | +import com.loopj.android.http.JsonHttpResponseHandler; | |
17 | +import com.loopj.android.http.RequestParams; | |
18 | + | |
19 | +import org.apache.http.Header; | |
20 | +import org.apache.http.entity.ByteArrayEntity; | |
21 | +import org.apache.http.message.BasicHeader; | |
22 | +import org.apache.http.protocol.HTTP; | |
23 | +import org.json.JSONException; | |
24 | +import org.json.JSONObject; | |
25 | + | |
26 | +import java.io.UnsupportedEncodingException; | |
27 | + | |
28 | +public class HttpManager { | |
29 | + private static HttpManager instance; | |
30 | + private ProgressDialog mProgress = null; | |
31 | + public static HttpManager getInstance() { | |
32 | + if (instance == null) { | |
33 | + instance = new HttpManager(); | |
34 | + } | |
35 | + return instance; | |
36 | + } | |
37 | + | |
38 | + | |
39 | + //登录接口 | |
40 | + | |
41 | + public void login(final String username, final String password, final Context mContext) { | |
42 | + mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | |
43 | + false, true, null); | |
44 | + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | |
45 | + HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | |
46 | + @Override | |
47 | + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | |
48 | + | |
49 | + String str = new String(arg2); | |
50 | + JSONObject jsonObject = null; | |
51 | + try { | |
52 | + jsonObject = new JSONObject(new String(arg2)); | |
53 | + String status = jsonObject.getString("status"); | |
54 | + if (status.equals("100")) { | |
55 | + String access_token = jsonObject.getString("access_token"); | |
56 | + String userId = jsonObject.getString("userId"); | |
57 | +// //登录成功,保存登录数据并且获取个人信息 | |
58 | + saveLoginInfo(mContext,username, password, access_token, "true", userId); | |
59 | + //HttpManager.getInstance().getuserinfo(username,mContext); | |
60 | + | |
61 | + }else if (status.equals("200")) { | |
62 | + closeProgress(); | |
63 | + Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); | |
64 | + return; | |
65 | + } else if(status.equals("204")){ | |
66 | + closeProgress(); | |
67 | + Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); | |
68 | + }else{ | |
69 | + closeProgress(); | |
70 | + Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | |
71 | + | |
72 | + | |
73 | + | |
74 | + } | |
75 | + } catch (JSONException e) { | |
76 | + e.printStackTrace(); | |
77 | + } | |
78 | + | |
79 | + | |
80 | + } | |
81 | + | |
82 | + @Override | |
83 | + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | |
84 | + closeProgress(); | |
85 | + Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); | |
86 | + } | |
87 | + }); | |
88 | + } | |
89 | + | |
90 | + //注册接口 | |
91 | + public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | |
92 | + mProgress = DialogPermission.showProgress(context, null, "正在注册...", | |
93 | + false, true, null); | |
94 | + JSONObject jsonObject = new JSONObject(); | |
95 | + ByteArrayEntity entity = null; | |
96 | + try { | |
97 | + jsonObject.put(HttpKey.USERNAME, username); | |
98 | + jsonObject.put(HttpKey.PASSWORD, password); | |
99 | + jsonObject.put(HttpKey.SMSCODE, smscode); | |
100 | + jsonObject.put(HttpKey.SOURCE, source); | |
101 | + Log.e("test", "jsonObject" + jsonObject); | |
102 | + entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | |
103 | + entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | |
104 | + } catch (JSONException e) { | |
105 | + e.printStackTrace(); | |
106 | + } catch (UnsupportedEncodingException e) { | |
107 | + e.printStackTrace(); | |
108 | + } | |
109 | + HttpClient.getInstance().addHeader("Accept", "*/*"); | |
110 | + HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | |
111 | + @Override | |
112 | + public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | |
113 | + super.onSuccess(statusCode, headers, response); | |
114 | + closeProgress(); | |
115 | + Log.e("test", "onSuccess" + response); | |
116 | + Message msg = Message.obtain(); | |
117 | + msg.what = HttpCode.REGISTERED_SUCESS; | |
118 | + msg.obj = response; | |
119 | + handler.sendMessage(msg); | |
120 | + | |
121 | + } | |
122 | + | |
123 | + @Override | |
124 | + public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | |
125 | + super.onFailure(statusCode, headers, throwable, errorResponse); | |
126 | + closeProgress(); | |
127 | + Log.e("test", "onFailure" + errorResponse); | |
128 | + Toast.makeText(context, "请检查网络。。", Toast.LENGTH_LONG).show(); | |
129 | + } | |
130 | + | |
131 | + }); | |
132 | + } | |
133 | + | |
134 | + //注册验证码 | |
135 | + public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | |
136 | + RequestParams params = new RequestParams(); | |
137 | + params.put(HttpKey.TYPE, type); | |
138 | + params.put(HttpKey.MOBIL, mobile); | |
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() { | |
141 | + | |
142 | + @Override | |
143 | + public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | |
144 | + Log.e("test", "onSuccess-----" + response); | |
145 | + Message msg = Message.obtain(); | |
146 | + msg.what = HttpCode.AUTHCODE_SUCESS; | |
147 | + msg.obj = response; | |
148 | + handler.sendMessage(msg); | |
149 | + } | |
150 | + | |
151 | + @Override | |
152 | + public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | |
153 | + Toast.makeText(mContext, "请检查网络。。" + errorResponse, Toast.LENGTH_LONG).show(); | |
154 | + } | |
155 | + }); | |
156 | + } | |
157 | + | |
158 | + //验证码 | |
159 | + public void forgetauthCode(final String type, final String mobile, final Handler handler, final Context mContext) { | |
160 | + RequestParams params = new RequestParams(); | |
161 | + params.put("type", type); | |
162 | + params.put("mobile", mobile); | |
163 | + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | |
164 | + HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | |
165 | + | |
166 | + @Override | |
167 | + public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | |
168 | + Log.e("test", "onSuccess-----" + response); | |
169 | + Message msg = Message.obtain(); | |
170 | + msg.what = HttpCode.AUTHCODE_SUCESS1; | |
171 | + msg.obj = response; | |
172 | + handler.sendMessage(msg); | |
173 | + } | |
174 | + | |
175 | + @Override | |
176 | + public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | |
177 | + Toast.makeText(mContext, "请检查网络。。" + errorResponse, Toast.LENGTH_LONG).show(); | |
178 | + } | |
179 | + }); | |
180 | + } | |
181 | + | |
182 | + //手机号是否注册 | |
183 | + public void isregistered(final String mobile, final Handler handler, final Context mContext) { | |
184 | + RequestParams params = new RequestParams(); | |
185 | + params.put(HttpKey.USERNAME, mobile); | |
186 | + HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | |
187 | + @Override | |
188 | + public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | |
189 | + Log.e("test", "isregistered" + response.toString()); | |
190 | + Message msg = Message.obtain(); | |
191 | + msg.what = HttpCode.IS_REFISTER; | |
192 | + msg.obj = response; | |
193 | + handler.sendMessage(msg); | |
194 | + | |
195 | + } | |
196 | + | |
197 | + @Override | |
198 | + public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | |
199 | + Toast.makeText(mContext, "失敗" + errorResponse, Toast.LENGTH_LONG).show(); | |
200 | + | |
201 | + } | |
202 | + }); | |
203 | + } | |
204 | + | |
205 | + //修改密码 | |
206 | + public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | |
207 | + RequestParams params = new RequestParams(); | |
208 | + params.put(HttpKey.USERNAME, username); | |
209 | + params.put(HttpKey.OLDPASS, old_pwd1); | |
210 | + params.put(HttpKey.NEWPASS, newpassword3); | |
211 | + HttpClient.getInstance().addHeader("Accept", "*/*"); | |
212 | + HttpClient.getInstance().setTimeout(10 * 1000); | |
213 | + HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | |
214 | + @Override | |
215 | + public void onSuccess(int i, Header[] headers, byte[] bytes) { | |
216 | + try { | |
217 | + JSONObject jsonObject = new JSONObject(new String(bytes)); | |
218 | + String status = jsonObject.optString("status"); | |
219 | + if (status.equals("100")) { | |
220 | + Log.e("test", "onSuccess" + new String(bytes)); | |
221 | + Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | |
222 | + SaveParam.getInstance().clearData((Activity) context); | |
223 | + Intent intent = new Intent(); | |
224 | + intent.setClass(context, LoginAndRegisterActivity.class); | |
225 | + ((Activity) context).startActivity(intent); | |
226 | + ((Activity) context).finish(); | |
227 | + } | |
228 | + } catch (JSONException e) { | |
229 | + e.printStackTrace(); | |
230 | + } | |
231 | + } | |
232 | + | |
233 | + @Override | |
234 | + public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | |
235 | + Log.e("test", "onFailure" + new String(bytes)); | |
236 | + Toast.makeText(context, "密码修改失败,请检查网络!", Toast.LENGTH_LONG).show(); | |
237 | + onFinish(); | |
238 | + } | |
239 | + }); | |
240 | + | |
241 | + } | |
242 | + | |
243 | + //忘记密码 | |
244 | + public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | |
245 | + RequestParams params = new RequestParams(); | |
246 | + params.put(HttpKey.USERNAME, forot_pwd_phone1); | |
247 | + params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | |
248 | + params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | |
249 | + HttpClient.getInstance().addHeader("Accept", "*/*"); | |
250 | + HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | |
251 | + @Override | |
252 | + public void onSuccess(int i, Header[] headers, byte[] bytes) { | |
253 | + try { | |
254 | + JSONObject jsonObject = new JSONObject(new String(bytes)); | |
255 | + String status = jsonObject.optString("status"); | |
256 | + if (status.equals("100")) { | |
257 | + Log.e("test", "onSuccess" + new String(bytes)); | |
258 | + Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | |
259 | + ((Activity) context).finish(); | |
260 | + } | |
261 | + } catch (JSONException e) { | |
262 | + e.printStackTrace(); | |
263 | + } | |
264 | + } | |
265 | + | |
266 | + @Override | |
267 | + public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | |
268 | + Log.e("test", "onFailure" + new String(bytes)); | |
269 | + Toast.makeText(context, "忘记密码修改失败,请检查网络!", Toast.LENGTH_LONG).show(); | |
270 | + } | |
271 | + }); | |
272 | + | |
273 | + } | |
274 | + | |
275 | + //保存用户登录信息 | |
276 | + public void saveLoginInfo(Context context,String username, String password, String access_token, String loginStatus, String userId) { | |
277 | + SaveParam.getInstance().saveLoginParam(context,"username", username); | |
278 | + SaveParam.getInstance().saveLoginParam(context,"password", password); | |
279 | + SaveParam.getInstance().saveLoginParam(context,"access_token", access_token); | |
280 | + SaveParam.getInstance().saveLoginParam(context,"login", loginStatus); | |
281 | + SaveParam.getInstance().saveLoginParam(context,"userId", userId); | |
282 | + | |
283 | + | |
284 | + } | |
285 | + | |
286 | + //保存用户个人信息 | |
287 | + public void savePresonInfo(Context context,String lastname, String gender, String mobilePortrait) { | |
288 | + SaveParam.getInstance().saveLoginParam(context,"lastname", lastname); | |
289 | + SaveParam.getInstance().saveLoginParam(context,"gender", gender); | |
290 | + SaveParam.getInstance().saveLoginParam(context,"mobilePortrait", mobilePortrait); | |
291 | + } | |
292 | + | |
293 | + public void provices(final Context mContext, final Handler handler) { | |
294 | + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | |
295 | + HttpClient.getInstance().get(HttpUrl.loginUrl, new AsyncHttpResponseHandler() { | |
296 | + @Override | |
297 | + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | |
298 | + Log.e("test", "isregistered" + arg2.toString()); | |
299 | + Message msg = Message.obtain(); | |
300 | + msg.what = HttpCode.PROVICES; | |
301 | + msg.obj = arg2; | |
302 | + handler.sendMessage(msg); | |
303 | + } | |
304 | + | |
305 | + @Override | |
306 | + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | |
307 | + Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); | |
308 | + } | |
309 | + }); | |
310 | + } | |
311 | + | |
312 | + | |
313 | + | |
314 | + private void closeProgress() { | |
315 | + try { | |
316 | + if (mProgress != null) { | |
317 | + mProgress.dismiss(); | |
318 | + mProgress = null; | |
319 | + } | |
320 | + } catch (Exception e) { | |
321 | + e.printStackTrace(); | |
322 | + } | |
323 | + } | |
324 | + | |
325 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
... | ... | @@ -0,0 +1,22 @@ |
1 | +package com.hjx.personalcenter.http; | |
2 | + | |
3 | +/** | |
4 | + * Created by h on 2017/8/15. | |
5 | + */ | |
6 | + | |
7 | +public class HttpUrl { | |
8 | + private final static String Enviroment = "DEVELOPMENT"; | |
9 | + | |
10 | + public static String GetDomain(){ | |
11 | + return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; | |
12 | + } | |
13 | + | |
14 | + public static String loginUrl = GetDomain()+"/user/access_token";//登录 | |
15 | + public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | |
16 | + public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | |
17 | + public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | |
18 | + public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | |
19 | + public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | |
20 | + public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | |
21 | + | |
22 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/BaseParser.java
... | ... | @@ -0,0 +1,55 @@ |
1 | +/** | |
2 | + * HaoJiXing Teacher Q&A | |
3 | + * copyright(C)2013- Acorn International | |
4 | + * | |
5 | + * packeage:com.ozing.callteacher.parser.BaseParser.java | |
6 | + * create:2013年7月25日下午1:58:14 | |
7 | + */ | |
8 | +package com.hjx.personalcenter.parser; | |
9 | + | |
10 | +import android.text.TextUtils; | |
11 | + | |
12 | +import com.hjx.personalcenter.exception.RemoteException; | |
13 | +import com.hjx.personalcenter.exception.ResponseError; | |
14 | + | |
15 | +import org.json.JSONException; | |
16 | +import org.json.JSONObject; | |
17 | + | |
18 | +/** | |
19 | + * @author jixiaolong<jixiaolong@chinadrtv.com> | |
20 | + * @code: 015261 | |
21 | + */ | |
22 | +public abstract class BaseParser<T> { | |
23 | + public abstract T parse(String response) throws RemoteException, com.hjx.personalcenter.exception.RemoteException; | |
24 | + | |
25 | + public static ResponseError getError(String response){ | |
26 | + ResponseError error = new ResponseError(); | |
27 | + if(TextUtils.isEmpty(response)){ | |
28 | + error.setStatus(-1); | |
29 | + error.setMessage("接口空数据"); | |
30 | + }else{ | |
31 | + if(response.contains("status")){ | |
32 | + //{"status":100,"message":"success","access_token":"0b129fa4-cd71-4777-89d0-215bf4652146"} | |
33 | + //{"status":204,"message":"wrong password"} | |
34 | + //{"status":200,"message":"user not exist"} | |
35 | + try { | |
36 | + JSONObject object = new JSONObject(response); | |
37 | + int status = object.optInt("status"); | |
38 | + error.setStatus(status); | |
39 | + if(status!=0 && status!=100){ | |
40 | + String msg = object.optString("message"); | |
41 | + if(!TextUtils.isEmpty(msg)) | |
42 | + error.setMessage(msg); | |
43 | + } | |
44 | + } catch (JSONException e) { | |
45 | + error.setMessage("返回json数据错误:["+response+"]"); | |
46 | + } | |
47 | + }else if(response.contains("error")){ | |
48 | + error.setMessage("服务器内部错误"); | |
49 | + }else{ | |
50 | + error.setStatus(100); | |
51 | + } | |
52 | + } | |
53 | + return error; | |
54 | + } | |
55 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/ProvinceParser.java
... | ... | @@ -0,0 +1,56 @@ |
1 | +/** | |
2 | + * HaoJiXing Teacher Q&A | |
3 | + * copyright(C)2013- Acorn International | |
4 | + * | |
5 | + * packeage:com.ozing.callteacher.parser.ProvinceParser.java | |
6 | + * create:2013年8月8日上午11:40:21 | |
7 | + */ | |
8 | +package com.hjx.personalcenter.parser; | |
9 | + | |
10 | + | |
11 | +import com.hjx.personalcenter.areapicker.AreaBean; | |
12 | +import com.hjx.personalcenter.exception.RemoteException; | |
13 | +import com.hjx.personalcenter.exception.ResponseError; | |
14 | + | |
15 | +import org.json.JSONArray; | |
16 | +import org.json.JSONException; | |
17 | +import org.json.JSONObject; | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | +import java.util.List; | |
21 | + | |
22 | + | |
23 | +/** | |
24 | + * @author jixiaolong<jixiaolong@chinadrtv.com> | |
25 | + * @code: 015261 | |
26 | + */ | |
27 | +public class ProvinceParser extends BaseParser<List<AreaBean>> { | |
28 | + | |
29 | + @Override | |
30 | + public List<AreaBean> parse(String response) throws RemoteException { | |
31 | + ResponseError error = getError(response); | |
32 | + if(error.hasError()){ | |
33 | + throw new RemoteException(error); | |
34 | + } | |
35 | + | |
36 | + List<AreaBean> mList = new ArrayList<AreaBean>(); | |
37 | + try { | |
38 | + JSONObject object = new JSONObject(response); | |
39 | + JSONArray areaobj = object.getJSONArray("provinces"); | |
40 | + for(int i=0;i<areaobj.length();i++){ | |
41 | + JSONObject pro = areaobj.getJSONObject(i); | |
42 | + AreaBean bean = new AreaBean(); | |
43 | + bean.setLevel(AreaBean.PROVINCE); | |
44 | + bean.setId(pro.optString("regionId")); | |
45 | + bean.setName(pro.optString("regionName")); | |
46 | + bean.setFullName(pro.optString("regionName")); | |
47 | + bean.setParentId(pro.optString("parentId")); | |
48 | + mList.add(bean); | |
49 | + } | |
50 | + } catch (JSONException e) { | |
51 | + e.printStackTrace(); | |
52 | + } | |
53 | + return mList; | |
54 | + } | |
55 | + | |
56 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/AlertUtils.java
... | ... | @@ -0,0 +1,11 @@ |
1 | +package com.hjx.personalcenter.util; | |
2 | + | |
3 | + | |
4 | +import android.content.Context; | |
5 | +import android.widget.Toast; | |
6 | + | |
7 | +public class AlertUtils { | |
8 | + public static void showToast(Context context, String msg) { | |
9 | + Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); | |
10 | + } | |
11 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/DialogPermission.java
... | ... | @@ -0,0 +1,88 @@ |
1 | +package com.hjx.personalcenter.util; | |
2 | + | |
3 | +import android.app.AlertDialog; | |
4 | +import android.app.ProgressDialog; | |
5 | +import android.content.Context; | |
6 | +import android.content.DialogInterface; | |
7 | +import android.content.Intent; | |
8 | +import android.provider.Settings; | |
9 | +import android.util.Log; | |
10 | + | |
11 | +/** | |
12 | + * 权限提示对话框 | |
13 | + * Created by yf on 2016/7/25. | |
14 | + */ | |
15 | +public class DialogPermission { | |
16 | + Context mContext; | |
17 | + String mNotice; | |
18 | + | |
19 | + public DialogPermission(Context context, String notice) { | |
20 | + mContext = context; | |
21 | + mNotice = notice; | |
22 | + showDialog(); | |
23 | + } | |
24 | + | |
25 | + private void showDialog() { | |
26 | + new AlertDialog.Builder(mContext).setTitle("系统提示")//设置对话框标题 | |
27 | + | |
28 | + .setMessage(mNotice)//设置显示的内容 | |
29 | + | |
30 | + .setPositiveButton("设置", new DialogInterface.OnClickListener() {//添加确定按钮 | |
31 | + | |
32 | + @Override | |
33 | + | |
34 | + public void onClick(DialogInterface dialog, int which) {//确定按钮的响应事件 | |
35 | + Intent intent = new Intent(Settings.ACTION_APN_SETTINGS); | |
36 | + mContext.startActivity(intent); | |
37 | + } | |
38 | + | |
39 | + }).setNegativeButton("放弃", new DialogInterface.OnClickListener() {//添加返回按钮 | |
40 | + @Override | |
41 | + public void onClick(DialogInterface dialog, int which) {//响应事件 | |
42 | + | |
43 | + Log.i("DialogPermission", "Dialog关闭"); | |
44 | + } | |
45 | + }).show();//在按键响应事件中显示此对话框 | |
46 | + | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * 显示进度条 | |
51 | + * | |
52 | + * @param context 环境 | |
53 | + * @param title 标题 | |
54 | + * @param message 信息 | |
55 | + * @param indeterminate 确定性 | |
56 | + * @param cancelable 可撤销 | |
57 | + * @return | |
58 | + */ | |
59 | + public static ProgressDialog showProgress(Context context, | |
60 | + CharSequence title, CharSequence message, boolean indeterminate, | |
61 | + boolean cancelable, DialogInterface.OnDismissListener listener) { | |
62 | + ProgressDialog dialog = new ProgressDialog(context); | |
63 | + dialog.setTitle(title); | |
64 | + dialog.setMessage(message); | |
65 | + dialog.setIndeterminate(indeterminate); | |
66 | + dialog.setCancelable(false); | |
67 | + // dialog.setDefaultButton(false); | |
68 | + if (cancelable && listener != null) | |
69 | + dialog.setOnDismissListener(listener); | |
70 | + | |
71 | + dialog.show(); | |
72 | + return dialog; | |
73 | + } | |
74 | + | |
75 | + private void closeProgress() { | |
76 | + try { | |
77 | + if (mProgress != null) { | |
78 | + mProgress.dismiss(); | |
79 | + mProgress = null; | |
80 | + } | |
81 | + } catch (Exception e) { | |
82 | + e.printStackTrace(); | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + private ProgressDialog mProgress = null; | |
87 | + | |
88 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/Judgment.java
... | ... | @@ -0,0 +1,233 @@ |
1 | +package com.hjx.personalcenter.util; | |
2 | + | |
3 | +import java.util.regex.Matcher; | |
4 | +import java.util.regex.Pattern; | |
5 | + | |
6 | +public class Judgment { | |
7 | + private static Judgment instance; | |
8 | + | |
9 | + public static Judgment getInstance() { | |
10 | + if (instance == null) { | |
11 | + instance = new Judgment(); | |
12 | + } | |
13 | + return instance; | |
14 | + } | |
15 | + | |
16 | + | |
17 | + // 是英文 | |
18 | + public boolean isEnglish(String english) { | |
19 | + Pattern pattern = Pattern.compile("^[A-Za-z]+$"); | |
20 | + Matcher m = pattern.matcher(english); | |
21 | + if (m.matches()) { | |
22 | + return true; | |
23 | + } else { | |
24 | + return false; | |
25 | + } | |
26 | + } | |
27 | + | |
28 | + public boolean isEnglishAndChinese(String str) { | |
29 | + int j = 0; | |
30 | + int k = 0; | |
31 | + int i = str.length(); | |
32 | + Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]"); | |
33 | + Matcher m = pattern.matcher(str); | |
34 | + while (m.find()) { | |
35 | + j++; | |
36 | + } | |
37 | + for (int idx = 0; idx < i; idx++) { | |
38 | + char c = str.charAt(idx); | |
39 | + int tmp = (int) c; | |
40 | + if ((tmp >= 'a' && tmp <= 'z') || (tmp >= 'A' && tmp <= 'Z') || tmp == '.') { | |
41 | + k++; | |
42 | + } | |
43 | + } | |
44 | + if (i == j + k) { | |
45 | + return true; | |
46 | + } else { | |
47 | + return false; | |
48 | + } | |
49 | + | |
50 | + } | |
51 | + | |
52 | + //英文和数字 | |
53 | + public boolean isEnglishAndDigit(String str) { | |
54 | + int j = 0; | |
55 | + int k = 0; | |
56 | + int i = str.length(); | |
57 | + for (int idx = 0; idx < str.length(); idx++) { | |
58 | + if (Character.isDigit(str.charAt(idx))) { | |
59 | + j++; | |
60 | + } | |
61 | + } | |
62 | + for (int idx = 0; idx < i; idx++) { | |
63 | + char c = str.charAt(idx); | |
64 | + if ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') { | |
65 | + k++; | |
66 | + } | |
67 | + } | |
68 | + if ((k + j) == i) { | |
69 | + return false; | |
70 | + } | |
71 | + | |
72 | + return true; | |
73 | + } | |
74 | + | |
75 | + public boolean isChinese(String name) { | |
76 | + int j = 0; | |
77 | + int i = name.length(); | |
78 | + Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]"); | |
79 | + Matcher m = pattern.matcher(name); | |
80 | + while (m.find()) { | |
81 | + j++; | |
82 | + } | |
83 | + if (i == j) { | |
84 | + return false; | |
85 | + } else { | |
86 | + return true; | |
87 | + } | |
88 | + } | |
89 | + | |
90 | + //中文和点 | |
91 | + public boolean isChineseandPoint(String name) { | |
92 | + int j = 0; | |
93 | + int i = name.length(); | |
94 | + int k = 0; | |
95 | + Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]"); | |
96 | + Matcher m = pattern.matcher(name); | |
97 | + while (m.find()) { | |
98 | + j++; | |
99 | + } | |
100 | + for (int idx = 0; idx < i; idx++) { | |
101 | + char c = name.charAt(idx); | |
102 | + if (c == '.') { | |
103 | + k++; | |
104 | + } | |
105 | + } | |
106 | + if (i == j + k) { | |
107 | + return true; | |
108 | + } else { | |
109 | + return false; | |
110 | + } | |
111 | + | |
112 | + } | |
113 | + | |
114 | + //数字和* | |
115 | + public boolean isJustDigitStar(String str) { | |
116 | + | |
117 | + int len = 0; | |
118 | + for (int idx = 0; idx < str.length(); idx++) { | |
119 | + if (Character.isDigit(str.charAt(idx)) || str.charAt(idx) == '*') { | |
120 | + len++; | |
121 | + } | |
122 | + } | |
123 | + | |
124 | + if (len == str.length()) { | |
125 | + return true; | |
126 | + } | |
127 | + | |
128 | + return false; | |
129 | + } | |
130 | + | |
131 | + // 所有都为数字 | |
132 | + public boolean isAllDigit(String str) { | |
133 | + int len = 0; | |
134 | + for (int idx = 0; idx < str.length(); idx++) { | |
135 | + if (Character.isDigit(str.charAt(idx))) { | |
136 | + len++; | |
137 | + } | |
138 | + } | |
139 | + if (len == str.length()) { | |
140 | + return true; | |
141 | + } | |
142 | + | |
143 | + return false; | |
144 | + } | |
145 | + | |
146 | + public boolean isEnglishAndBackSpace(String str) { | |
147 | + int len = 0; | |
148 | + for (int i = 0; i < str.length(); i++) { | |
149 | + char c = str.charAt(i); | |
150 | + if ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == ' ') { | |
151 | + len++; | |
152 | + } | |
153 | + } | |
154 | + if (len == str.length()) { | |
155 | + return true; | |
156 | + } | |
157 | + return false; | |
158 | + } | |
159 | + | |
160 | + // 地址 | |
161 | + public boolean isAddress(String address) { | |
162 | + int i = 0, j = 0, k = 0; | |
163 | + int count = address.length(); | |
164 | + Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]"); | |
165 | + Matcher m = pattern.matcher(address); | |
166 | + while (m.find()) { | |
167 | + i++; | |
168 | + } | |
169 | + for (int idx = 0; idx < count; idx++) { | |
170 | + char c = address.charAt(idx); | |
171 | + int tmp = (int) c; | |
172 | + if ((tmp >= 'a' && tmp <= 'z') || (tmp >= 'A' && tmp <= 'Z')) { | |
173 | + j++; | |
174 | + } | |
175 | + | |
176 | + if (Character.isDigit(address.charAt(idx))) { | |
177 | + k++; | |
178 | + } | |
179 | + | |
180 | + } | |
181 | + if ((i + j + k) == count) { | |
182 | + return true; | |
183 | + } else { | |
184 | + return false; | |
185 | + } | |
186 | + | |
187 | + } | |
188 | + | |
189 | + public boolean judgeContainsIAndO(String str) { | |
190 | + for (int i = 1; i < str.length(); i++) { | |
191 | + if (str.charAt(i) == 'I' || str.charAt(i) == 'O') { | |
192 | + return false; | |
193 | + } | |
194 | + } | |
195 | + return true; | |
196 | + } | |
197 | + | |
198 | + | |
199 | + //手机号码 | |
200 | + public boolean isPhoneNum(String phonenum) { | |
201 | + | |
202 | + if (phonenum.length() != 11 || !phonenum.substring(0, 1).equals("1")) { | |
203 | + return true; | |
204 | + } else { | |
205 | + return false; | |
206 | + } | |
207 | + } | |
208 | + | |
209 | + | |
210 | + public boolean valibrithday(String beginTime, String brithday) { | |
211 | + if (brithday != null) { | |
212 | + String brith[] = brithday.split("-"); | |
213 | + int year = Integer.parseInt(brith[0]); | |
214 | + int month = Integer.parseInt(brith[1]); | |
215 | + int day = Integer.parseInt(brith[2]); | |
216 | + String strBegin[] = beginTime.split("-"); | |
217 | + | |
218 | + int beginYear = Integer.parseInt(strBegin[0]); | |
219 | + int beginMonth = Integer.parseInt(strBegin[1]); | |
220 | + int beginDay = Integer.parseInt(strBegin[2]); | |
221 | + // 杈撳叆鐨勫紑濮嬫棩鏈熶笉鑳芥棭浜庡嚭鐢熸棩璧� | |
222 | + if ((beginYear * 365 + beginMonth * 30 + beginDay) > (year * 365 | |
223 | + + month * 30 + day)) { | |
224 | + return true; | |
225 | + } else { | |
226 | + return false; | |
227 | + } | |
228 | + | |
229 | + } else { | |
230 | + return false; | |
231 | + } | |
232 | + } | |
233 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/PasswordCheckUtils.java
... | ... | @@ -0,0 +1,68 @@ |
1 | +package com.hjx.personalcenter.util; | |
2 | + | |
3 | +import java.util.regex.Matcher; | |
4 | +import java.util.regex.Pattern; | |
5 | + | |
6 | +/** | |
7 | + * 密码格式验证 | |
8 | + * | |
9 | + * @author F | |
10 | + * | |
11 | + */ | |
12 | +public class PasswordCheckUtils { | |
13 | + | |
14 | + /** | |
15 | + * 只为字母和数字组成 | |
16 | + * ^ 匹配一行的开头位置 | |
17 | + (?![0-9]+$) 预测该位置后面不全是数字 | |
18 | + (?![a-zA-Z]+$) 预测该位置后面不全是字母 | |
19 | + [0-9A-Za-z] {8,24} 由8-24位数字或者字母组成 | |
20 | + $ 匹配行结尾位置 | |
21 | + */ | |
22 | + public static final String PASSWORD_CHAR_AND_NUMBER = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,24}$"; | |
23 | + | |
24 | + /** | |
25 | + * 可为纯数字/纯字母/数字和字母组成 | |
26 | + */ | |
27 | + public static final String PASSWORD_PATTERN = "^([a-zA-Z0-9]{3,24})$"; | |
28 | + | |
29 | + /** | |
30 | + * 纯数字 | |
31 | + * | |
32 | + * @param str | |
33 | + * @return | |
34 | + */ | |
35 | + public static boolean isNumeric(String str) { | |
36 | + for (int i = str.length(); --i >= 0;) { | |
37 | + if (!Character.isDigit(str.charAt(i))) { | |
38 | + return false; | |
39 | + } | |
40 | + } | |
41 | + return true; | |
42 | + } | |
43 | + | |
44 | + /** | |
45 | + * 纯字母 | |
46 | + * | |
47 | + * @param data | |
48 | + * @return | |
49 | + */ | |
50 | + public static boolean isChar(String data) { | |
51 | + for (int i = data.length(); --i >= 0;) { | |
52 | + char c = data.charAt(i); | |
53 | + if (((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) { | |
54 | + return true; | |
55 | + } else { | |
56 | + return false; | |
57 | + } | |
58 | + } | |
59 | + return true; | |
60 | + } | |
61 | + | |
62 | + public static boolean ispsd(String psd) { | |
63 | + Pattern p = Pattern.compile("^[a-zA-Z].*[0-9]|.*[0-9].*[a-zA-Z]"); | |
64 | + Matcher m = p.matcher(psd); | |
65 | + | |
66 | + return m.matches(); | |
67 | + } | |
68 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/PhoneNumCheckUtils.java
... | ... | @@ -0,0 +1,148 @@ |
1 | +package com.hjx.personalcenter.util; | |
2 | + | |
3 | +/** | |
4 | + * Created by l on 2017/7/18. | |
5 | + */ | |
6 | +import java.util.regex.Pattern; | |
7 | + | |
8 | +/** | |
9 | + * 手机号码或座机号码格式合法性验证 | |
10 | + * 判断手机号码是否合法(移动,联通,电信) | |
11 | + * | |
12 | + * @author F | |
13 | + * | |
14 | + */ | |
15 | +public class PhoneNumCheckUtils { | |
16 | + | |
17 | + private static final String PHONE_CALL_PATTERN = "^(\\(\\d{3,4}\\)|\\d{3,4}-)?\\d{7,8}(-\\d{1,4})?$"; | |
18 | + | |
19 | + /** | |
20 | + * 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700,173 | |
21 | + * **/ | |
22 | + private static final String CHINA_TELECOM_PATTERN = "(^1(33|53|7[37]|8[019])\\d{8}$)|(^1700\\d{7}$)"; | |
23 | + | |
24 | + /** | |
25 | + * 中国联通号码格式验证 手机段:130,131,132,155,156,185,186,145,176,1707,1708,1709 | |
26 | + * **/ | |
27 | + private static final String CHINA_UNICOM_PATTERN = "(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^170[7-9]\\d{7}$)"; | |
28 | + | |
29 | + /** | |
30 | + * 中国移动号码格式验证 | |
31 | + * 手机段:134,135,136,137,138,139,150,151,152,157,158,159,182,183,184 | |
32 | + * ,187,188,147,178,1705 | |
33 | + * | |
34 | + **/ | |
35 | + private static final String CHINA_MOBILE_PATTERN = "(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)"; | |
36 | + | |
37 | + /** | |
38 | + * 仅手机号格式校验 | |
39 | + */ | |
40 | + private static final String PHONE_PATTERN = new StringBuilder(300) | |
41 | + .append(CHINA_MOBILE_PATTERN).append("|") | |
42 | + .append(CHINA_TELECOM_PATTERN).append("|") | |
43 | + .append(CHINA_UNICOM_PATTERN).toString(); | |
44 | + | |
45 | + /** | |
46 | + * 手机和座机号格式校验 | |
47 | + */ | |
48 | + private static final String PHONE_TEL_PATTERN = new StringBuilder(350) | |
49 | + .append(PHONE_PATTERN).append("|").append("(") | |
50 | + .append(PHONE_CALL_PATTERN).append(")").toString(); | |
51 | + | |
52 | + /** | |
53 | + * 匹配多个号码以,、或空格隔开的格式,如 17750581369 | |
54 | + * 13306061248、(596)3370653,17750581369,13306061248 (0596)3370653 | |
55 | + */ | |
56 | + private static final String MULTI_PHONE_TEL_PATTERN = "^(?:(?:(?:(?:(?:(?:13[0-9])|(?:14[57])|(?:15[0-35-9])|(?:17[36-8])|(?:18[0-9]))\\d{8})|(?:170[057-9]\\d{7})|(?:\\(\\d{3,4}\\)|\\d{3,4}-)?\\d{7,8}(?:-\\d{1,4})?)[,\\s、])+)?(?:(?:(?:(?:13[0-9])|(?:14[57])|(?:15[0-35-9])|(?:17[36-8])|(?:18[0-9]))\\d{8})|(?:170[057-9]\\d{7})|(?:\\(\\d{3,4}\\)|\\d{3,4}-)?\\d{7,8}(?:-\\d{1,4})?)$"; | |
57 | + | |
58 | + /** | |
59 | + * 匹配多个号码以,、或空格隔开的格式,如 17750581369 | |
60 | + * 13306061248、(596)3370653,17750581369,13306061248 (0596)3370653 | |
61 | + * | |
62 | + * @param input | |
63 | + * @return | |
64 | + */ | |
65 | + public static boolean checkMultiPhone(String input) { | |
66 | + return match(MULTI_PHONE_TEL_PATTERN, input); | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * 仅手机号码校验 | |
71 | + * | |
72 | + * @param input | |
73 | + * @return | |
74 | + */ | |
75 | + public static boolean isPhone(String input) { | |
76 | + return match(PHONE_PATTERN, input); | |
77 | + } | |
78 | + | |
79 | + /** | |
80 | + * 手机号或座机号校验 | |
81 | + * | |
82 | + * @param input | |
83 | + * @return | |
84 | + */ | |
85 | + public static boolean isPhoneOrTel(String input) { | |
86 | + System.out.println(PHONE_TEL_PATTERN); | |
87 | + return match(PHONE_TEL_PATTERN, input); | |
88 | + } | |
89 | + | |
90 | + /** | |
91 | + * 验证电话号码的格式 | |
92 | + * | |
93 | + * @author F | |
94 | + * @param str | |
95 | + * 校验电话字符串 | |
96 | + * @return 返回true,否则为false | |
97 | + */ | |
98 | + public static boolean isPhoneCallNum(String str) { | |
99 | + return match(PHONE_CALL_PATTERN, str); | |
100 | + } | |
101 | + | |
102 | + /** | |
103 | + * 验证【电信】手机号码的格式 | |
104 | + * | |
105 | + * @author F | |
106 | + * @param str | |
107 | + * 校验手机字符串 | |
108 | + * @return 返回true,否则为false | |
109 | + */ | |
110 | + public static boolean isChinaTelecomPhoneNum(String str) { | |
111 | + return match(CHINA_TELECOM_PATTERN, str); | |
112 | + } | |
113 | + | |
114 | + /** | |
115 | + * 验证【联通】手机号码的格式 | |
116 | + * | |
117 | + * @author F | |
118 | + * @param str | |
119 | + * 校验手机字符串 | |
120 | + * @return 返回true,否则为false | |
121 | + */ | |
122 | + public static boolean isChinaUnicomPhoneNum(String str) { | |
123 | + return match(CHINA_UNICOM_PATTERN, str); | |
124 | + } | |
125 | + | |
126 | + /** | |
127 | + * 验证【移动】手机号码的格式 | |
128 | + * | |
129 | + * @author F | |
130 | + * @param str | |
131 | + * 校验手机字符串 | |
132 | + * @return 返回true,否则为false | |
133 | + */ | |
134 | + public static boolean isChinaMobilePhoneNum(String str) { | |
135 | + return match(CHINA_MOBILE_PATTERN, str); | |
136 | + } | |
137 | + | |
138 | + /** | |
139 | + * 匹配函数 | |
140 | + * | |
141 | + * @param regex | |
142 | + * @param input | |
143 | + * @return | |
144 | + */ | |
145 | + private static boolean match(String regex, String input) { | |
146 | + return Pattern.matches(regex, input); | |
147 | + } | |
148 | +} | ... | ... |
PersonalCenter/app/src/main/res/layout/activity_forgetpsword.xml
... | ... | @@ -98,7 +98,14 @@ |
98 | 98 | |
99 | 99 | <ImageView |
100 | 100 | android:id="@+id/iv_pwd_change" |
101 | - style="@style/iv_pwd_change_style" /> | |
101 | + android:padding="10dp" | |
102 | + android:layout_marginRight="10dp" | |
103 | + android:layout_marginLeft="10dp" | |
104 | + android:layout_width="40dp" | |
105 | + android:layout_height="wrap_content" | |
106 | + android:layout_alignParentRight="true" | |
107 | + android:layout_centerVertical="true" | |
108 | + android:src="@mipmap/pwd_hide"/> | |
102 | 109 | </RelativeLayout> |
103 | 110 | |
104 | 111 | <TextView | ... | ... |
PersonalCenter/app/src/main/res/layout/custom_adilog_gradelist.xml
... | ... | @@ -0,0 +1,38 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:orientation="vertical"> | |
6 | + | |
7 | + <RelativeLayout | |
8 | + android:id="@+id/title" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="wrap_content" | |
11 | + android:minHeight="70dp" > | |
12 | + | |
13 | + <ImageView | |
14 | + android:id="@+id/cancel" | |
15 | + android:layout_width="wrap_content" | |
16 | + android:layout_height="wrap_content" | |
17 | + android:layout_centerVertical="true" | |
18 | + android:layout_alignParentRight="true" | |
19 | + android:padding="20dp" | |
20 | + android:src="@mipmap/cancel_fork" /> | |
21 | + | |
22 | + <TextView | |
23 | + android:id="@+id/menu_title" | |
24 | + android:layout_width="wrap_content" | |
25 | + android:layout_height="wrap_content" | |
26 | + android:layout_centerInParent="true" | |
27 | + android:padding="20dp" | |
28 | + android:text="选年级" | |
29 | + android:textColor="@android:color/black" | |
30 | + android:textSize="22sp" /> | |
31 | + </RelativeLayout> | |
32 | + <ListView | |
33 | + android:id="@+id/listadapter" | |
34 | + android:layout_width="match_parent" | |
35 | + android:layout_height="400dp"> | |
36 | + | |
37 | + </ListView> | |
38 | +</LinearLayout> | ... | ... |
PersonalCenter/app/src/main/res/layout/custom_adilog_list.xml
... | ... | @@ -1,38 +0,0 @@ |
1 | -<?xml version="1.0" encoding="utf-8"?> | |
2 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | - android:layout_width="match_parent" | |
4 | - android:layout_height="match_parent" | |
5 | - android:orientation="vertical"> | |
6 | - | |
7 | - <RelativeLayout | |
8 | - android:id="@+id/title" | |
9 | - android:layout_width="match_parent" | |
10 | - android:layout_height="wrap_content" | |
11 | - android:minHeight="70dp" > | |
12 | - | |
13 | - <ImageView | |
14 | - android:id="@+id/cancel" | |
15 | - android:layout_width="wrap_content" | |
16 | - android:layout_height="wrap_content" | |
17 | - android:layout_centerVertical="true" | |
18 | - android:layout_alignParentRight="true" | |
19 | - android:padding="20dp" | |
20 | - android:src="@mipmap/cancel_fork" /> | |
21 | - | |
22 | - <TextView | |
23 | - android:id="@+id/menu_title" | |
24 | - android:layout_width="wrap_content" | |
25 | - android:layout_height="wrap_content" | |
26 | - android:layout_centerInParent="true" | |
27 | - android:padding="20dp" | |
28 | - android:text="选年级" | |
29 | - android:textColor="@android:color/black" | |
30 | - android:textSize="22sp" /> | |
31 | - </RelativeLayout> | |
32 | - <ListView | |
33 | - android:id="@+id/listadapter" | |
34 | - android:layout_width="match_parent" | |
35 | - android:layout_height="400dp"> | |
36 | - | |
37 | - </ListView> | |
38 | -</LinearLayout> |
PersonalCenter/app/src/main/res/layout/custom_adilog_provicelist.xml
... | ... | @@ -0,0 +1,38 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:orientation="vertical"> | |
6 | + | |
7 | + <RelativeLayout | |
8 | + android:id="@+id/title" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="wrap_content" | |
11 | + android:minHeight="70dp" > | |
12 | + | |
13 | + <ImageView | |
14 | + android:id="@+id/cancel" | |
15 | + android:layout_width="wrap_content" | |
16 | + android:layout_height="wrap_content" | |
17 | + android:layout_centerVertical="true" | |
18 | + android:layout_alignParentRight="true" | |
19 | + android:padding="20dp" | |
20 | + android:src="@mipmap/cancel_fork" /> | |
21 | + | |
22 | + <TextView | |
23 | + android:id="@+id/menu_title" | |
24 | + android:layout_width="wrap_content" | |
25 | + android:layout_height="wrap_content" | |
26 | + android:layout_centerInParent="true" | |
27 | + android:padding="20dp" | |
28 | + android:text="请选择省份" | |
29 | + android:textColor="@android:color/black" | |
30 | + android:textSize="22sp" /> | |
31 | + </RelativeLayout> | |
32 | + <ListView | |
33 | + android:id="@+id/listadapter" | |
34 | + android:layout_width="match_parent" | |
35 | + android:layout_height="400dp"> | |
36 | + | |
37 | + </ListView> | |
38 | +</LinearLayout> | ... | ... |
PersonalCenter/app/src/main/res/layout/fragment_loginandregister_register.xml
... | ... | @@ -65,7 +65,14 @@ |
65 | 65 | |
66 | 66 | <ImageView |
67 | 67 | android:id="@+id/iv_pwd_change" |
68 | - style="@style/iv_pwd_change_style" /> | |
68 | + android:padding="10dp" | |
69 | + android:layout_marginRight="10dp" | |
70 | + android:layout_marginLeft="10dp" | |
71 | + android:layout_width="40dp" | |
72 | + android:layout_height="wrap_content" | |
73 | + android:layout_alignParentRight="true" | |
74 | + android:layout_centerVertical="true" | |
75 | + android:src="@mipmap/pwd_hide" /> | |
69 | 76 | </RelativeLayout> |
70 | 77 | |
71 | 78 | <TextView | ... | ... |
PersonalCenter/app/src/main/res/mipmap-xhdpi/pwd_open.png
861 Bytes
PersonalCenter/app/src/main/res/values/strings.xml
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <string name="cancel">取 消</string> |
8 | 8 | <string name="ok">确 定</string> |
9 | 9 | <string name="forget_pwd">忘记密码</string> |
10 | - <string name="string_menu_title">修改密码</string> | |
10 | + <string name="string_menu_title">忘记密码</string> | |
11 | 11 | <string name="string_regist_info">填写注册信息</string> |
12 | 12 | <string name="string_textbook_info">选择教材版本</string> |
13 | 13 | <string name="string_regist_username">用户名</string> | ... | ... |