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
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
| 2 | 2 | ||
| 3 | android { | 3 | android { |
| 4 | compileSdkVersion 25 | 4 | compileSdkVersion 25 |
| 5 | buildToolsVersion "25.0.3" | 5 | buildToolsVersion "25.0.3" |
| 6 | defaultConfig { | 6 | defaultConfig { |
| 7 | applicationId "com.hjx.personalcenter" | 7 | applicationId "com.hjx.personalcenter" |
| 8 | minSdkVersion 15 | 8 | minSdkVersion 15 |
| 9 | targetSdkVersion 25 | 9 | targetSdkVersion 25 |
| 10 | versionCode 1 | 10 | versionCode 1 |
| 11 | versionName "1.0" | 11 | versionName "1.0" |
| 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
| 13 | } | 13 | } |
| 14 | buildTypes { | 14 | buildTypes { |
| 15 | release { | 15 | release { |
| 16 | minifyEnabled false | 16 | minifyEnabled false |
| 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 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 | dependencies { | 28 | dependencies { |
| 23 | compile fileTree(include: ['*.jar'], dir: 'libs') | 29 | compile fileTree(include: ['*.jar'], dir: 'libs') |
| 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
| 25 | exclude group: 'com.android.support', module: 'support-annotations' | 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 | compile 'com.android.support:appcompat-v7:25.3.1' | 36 | compile 'com.android.support:appcompat-v7:25.3.1' |
| 28 | testCompile 'junit:junit:4.12' | 37 | testCompile 'junit:junit:4.12' |
| 29 | compile project(':circledialog') | 38 | compile project(':circledialog') |
| 30 | compile project(':pickerview') | 39 | compile project(':pickerview') |
| 40 | compile files('libs/android-async-http-1.4.8.jar') | ||
| 31 | } | 41 | } |
| 32 | 42 |
PersonalCenter/app/libs/android-async-http-1.4.8.jar
No preview for this file type
PersonalCenter/app/src/main/AndroidManifest.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | package="com.hjx.personalcenter"> | 3 | package="com.hjx.personalcenter"> |
| 4 | 4 | ||
| 5 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 5 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
| 6 | <application | 6 | <application |
| 7 | android:allowBackup="true" | 7 | android:allowBackup="true" |
| 8 | android:icon="@mipmap/ic_launcher" | 8 | android:icon="@mipmap/ic_launcher" |
| 9 | android:label="@string/app_name" | 9 | android:label="@string/app_name" |
| 10 | android:supportsRtl="true" | 10 | android:supportsRtl="true" |
| 11 | android:theme="@style/Theme.AppCompat.Light.NoActionBar"> | 11 | android:theme="@style/Theme.AppCompat.Light.NoActionBar"> |
| 12 | <activity | 12 | <activity |
| 13 | android:name=".activity.MainActivity" | 13 | android:name=".activity.MainActivity" |
| 14 | android:launchMode="singleTask" | 14 | android:launchMode="singleTask" |
| 15 | android:screenOrientation="landscape"> | 15 | android:screenOrientation="landscape"> |
| 16 | <intent-filter> | 16 | <intent-filter> |
| 17 | <action android:name="android.intent.action.MAIN" /> | 17 | <action android:name="android.intent.action.MAIN" /> |
| 18 | 18 | ||
| 19 | <category android:name="android.intent.category.LAUNCHER" /> | 19 | <category android:name="android.intent.category.LAUNCHER" /> |
| 20 | </intent-filter> | 20 | </intent-filter> |
| 21 | </activity> | 21 | </activity> |
| 22 | <activity | 22 | <activity |
| 23 | android:name=".activity.LoginAndRegisterActivity" | 23 | android:name=".activity.LoginAndRegisterActivity" |
| 24 | android:launchMode="singleTask" | 24 | android:launchMode="singleTask" |
| 25 | android:screenOrientation="landscape"> | 25 | android:screenOrientation="landscape"> |
| 26 | 26 | ||
| 27 | </activity> | 27 | </activity> |
| 28 | <activity | 28 | <activity |
| 29 | android:name=".activity.ForgotPasswordActivity" | 29 | android:name=".activity.ForgotPasswordActivity" |
| 30 | android:launchMode="singleTask" | 30 | android:launchMode="singleTask" |
| 31 | android:screenOrientation="landscape"> | 31 | android:screenOrientation="landscape"> |
| 32 | 32 | ||
| 33 | </activity> | 33 | </activity> |
| 34 | <activity | 34 | <activity |
| 35 | android:name=".activity.ChangePasswordActivity" | 35 | android:name=".activity.ChangePasswordActivity" |
| 36 | android:launchMode="singleTask" | 36 | android:launchMode="singleTask" |
| 37 | android:screenOrientation="landscape"> | 37 | android:screenOrientation="landscape"> |
| 38 | 38 | ||
| 39 | </activity> | 39 | </activity> |
| 40 | <activity | 40 | <activity |
| 41 | android:name=".activity.RegisterInfoActivity" | 41 | android:name=".activity.RegisterInfoActivity" |
| 42 | android:launchMode="singleTask" | 42 | android:launchMode="singleTask" |
| 43 | android:screenOrientation="landscape"> | 43 | android:screenOrientation="landscape"> |
| 44 | 44 | ||
| 45 | </activity> | 45 | </activity> |
| 46 | <activity | 46 | <activity |
| 47 | android:name=".activity.ElectronicCardValidationActivity" | 47 | android:name=".activity.ElectronicCardValidationActivity" |
| 48 | android:launchMode="singleTask" | 48 | android:launchMode="singleTask" |
| 49 | android:screenOrientation="landscape"> | 49 | android:screenOrientation="landscape"> |
| 50 | 50 | ||
| 51 | </activity> | 51 | </activity> |
| 52 | <activity | 52 | <activity |
| 53 | android:name=".activity.ChangeBangDingActivity" | 53 | android:name=".activity.ChangeBangDingActivity" |
| 54 | android:launchMode="singleTask" | 54 | android:launchMode="singleTask" |
| 55 | android:screenOrientation="landscape"> | 55 | android:screenOrientation="landscape"> |
| 56 | 56 | ||
| 57 | </activity> | 57 | </activity> |
| 58 | <activity | 58 | <activity |
| 59 | android:name=".activity.ChangeElectronicCardInfoActivity" | 59 | android:name=".activity.ChangeElectronicCardInfoActivity" |
| 60 | android:launchMode="singleTask" | 60 | android:launchMode="singleTask" |
| 61 | android:screenOrientation="landscape"> | 61 | android:screenOrientation="landscape"> |
| 62 | 62 | ||
| 63 | </activity> | 63 | </activity> |
| 64 | <activity | 64 | <activity |
| 65 | android:name=".activity.ChangeEletronicCardPhoneActivity" | 65 | android:name=".activity.ChangeEletronicCardPhoneActivity" |
| 66 | android:launchMode="singleTask" | 66 | android:launchMode="singleTask" |
| 67 | android:screenOrientation="landscape"> | 67 | android:screenOrientation="landscape"> |
| 68 | 68 | ||
| 69 | </activity> | 69 | </activity> |
| 70 | <activity | 70 | <activity |
| 71 | android:name=".activity.ChoiseTextBookActivity" | 71 | android:name=".activity.ChoiseTextBookActivity" |
| 72 | android:launchMode="singleTask" | 72 | android:launchMode="singleTask" |
| 73 | android:screenOrientation="landscape"> | 73 | android:screenOrientation="landscape"> |
| 74 | 74 | ||
| 75 | </activity> | 75 | </activity> |
| 76 | <activity | 76 | <activity |
| 77 | android:name=".activity.TheStartPageActivity" | 77 | android:name=".activity.TheStartPageActivity" |
| 78 | android:launchMode="singleTask" | 78 | android:launchMode="singleTask" |
| 79 | android:screenOrientation="landscape"> | 79 | android:screenOrientation="landscape"> |
| 80 | 80 | ||
| 81 | </activity> | 81 | </activity> |
| 82 | <activity | 82 | <activity |
| 83 | android:name=".activity.ElectronicCardEditInfoActivity" | 83 | android:name=".activity.ElectronicCardEditInfoActivity" |
| 84 | android:launchMode="singleTask" | 84 | android:launchMode="singleTask" |
| 85 | android:screenOrientation="landscape"> | 85 | android:screenOrientation="landscape"> |
| 86 | 86 | ||
| 87 | </activity> | 87 | </activity> |
| 88 | <activity | 88 | <activity |
| 89 | android:name=".activity.ElectronicCardInfoOKActivity" | 89 | android:name=".activity.ElectronicCardInfoOKActivity" |
| 90 | android:launchMode="singleTask" | 90 | android:launchMode="singleTask" |
| 91 | android:screenOrientation="landscape"> | 91 | android:screenOrientation="landscape"> |
| 92 | 92 | ||
| 93 | </activity> | 93 | </activity> |
| 94 | <activity | 94 | <activity |
| 95 | android:name=".activity.ElectronicCardLookInfoActivity" | 95 | android:name=".activity.ElectronicCardLookInfoActivity" |
| 96 | android:launchMode="singleTask" | 96 | android:launchMode="singleTask" |
| 97 | android:screenOrientation="landscape"> | 97 | android:screenOrientation="landscape"> |
| 98 | 98 | ||
| 99 | </activity> | 99 | </activity> |
| 100 | <activity | 100 | <activity |
| 101 | android:name=".activity.FeedBackActivity" | 101 | android:name=".activity.FeedBackActivity" |
| 102 | android:launchMode="singleTask" | 102 | android:launchMode="singleTask" |
| 103 | android:screenOrientation="landscape"> | 103 | android:screenOrientation="landscape"> |
| 104 | 104 | ||
| 105 | </activity> | 105 | </activity> |
| 106 | <activity | 106 | <activity |
| 107 | android:name=".activity.AccountManagementActivity" | 107 | android:name=".activity.AccountManagementActivity" |
| 108 | android:launchMode="singleTask" | 108 | android:launchMode="singleTask" |
| 109 | android:screenOrientation="landscape"> | 109 | android:screenOrientation="landscape"> |
| 110 | 110 | ||
| 111 | </activity> | 111 | </activity> |
| 112 | <activity | 112 | <activity |
| 113 | android:name=".activity.ChangePresonalInfoActivity" | 113 | android:name=".activity.ChangePresonalInfoActivity" |
| 114 | android:launchMode="singleTask" | 114 | android:launchMode="singleTask" |
| 115 | android:screenOrientation="landscape"> | 115 | android:screenOrientation="landscape"> |
| 116 | 116 | ||
| 117 | </activity> | 117 | </activity> |
| 118 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| 119 | </application> | 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 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePasswordActivity.java
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.os.Bundle; | 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 | import com.hjx.personalcenter.R; | 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 | /** | 19 | /**修改密码 |
| 9 | * Created by h on 2017/8/9. | 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 | @Override | 28 | @Override |
| 14 | protected void onCreate(Bundle savedInstanceState) { | 29 | protected void onCreate(Bundle savedInstanceState) { |
| 15 | super.onCreate(savedInstanceState); | 30 | super.onCreate(savedInstanceState); |
| 16 | setContentView(R.layout.activity_changepsword); | 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 | } |
| 19 | 109 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ForgotPasswordActivity.java
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.os.Bundle; | 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 | import com.hjx.personalcenter.R; | 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 | /** | 23 | import org.json.JSONException; |
| 9 | * Created by h on 2017/8/9. | 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 | @Override | 105 | @Override |
| 14 | protected void onCreate(Bundle savedInstanceState) { | 106 | protected void onCreate(Bundle savedInstanceState) { |
| 15 | super.onCreate(savedInstanceState); | 107 | super.onCreate(savedInstanceState); |
| 16 | setContentView(R.layout.activity_forgetpsword); | 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 | } |
| 19 | 229 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.os.Handler; | ||
| 6 | import android.os.Message; | ||
| 5 | import android.support.v7.app.AppCompatActivity; | 7 | import android.support.v7.app.AppCompatActivity; |
| 6 | import android.view.View; | 8 | import android.view.View; |
| 7 | import android.widget.Button; | 9 | import android.widget.Button; |
| 8 | import android.widget.EditText; | 10 | import android.widget.EditText; |
| 9 | import android.widget.TextView; | 11 | import android.widget.TextView; |
| 10 | 12 | ||
| 11 | import com.hjx.personalcenter.R; | 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 | * Created by h on 2017/8/9. | 23 | * Created by h on 2017/8/9. |
| 16 | */ | 24 | */ |
| 17 | 25 | ||
| 18 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener { | 26 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener { |
| 19 | private EditText et_username; | 27 | private EditText et_username; |
| 20 | private TextView et_region,et_grade,et_school; | 28 | private TextView et_region,et_grade,et_school; |
| 21 | private Button btn_ok; | 29 | private Button btn_ok; |
| 22 | String[] items; | 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 | @Override | 50 | @Override |
| 25 | protected void onCreate(Bundle savedInstanceState) { | 51 | protected void onCreate(Bundle savedInstanceState) { |
| 26 | super.onCreate(savedInstanceState); | 52 | super.onCreate(savedInstanceState); |
| 27 | setContentView(R.layout.activity_registerinfo); | 53 | setContentView(R.layout.activity_registerinfo); |
| 28 | initView(); | 54 | initView(); |
| 29 | initData(); | 55 | initData(); |
| 30 | initLister(); | 56 | initLister(); |
| 31 | } | 57 | } |
| 32 | 58 | ||
| 33 | private void initView() { | 59 | private void initView() { |
| 34 | et_username = (EditText) findViewById(R.id.et_username); | 60 | et_username = (EditText) findViewById(R.id.et_username); |
| 35 | et_region = (TextView) findViewById(R.id.et_region); | 61 | et_region = (TextView) findViewById(R.id.et_region); |
| 36 | et_grade = (TextView) findViewById(R.id.et_grade); | 62 | et_grade = (TextView) findViewById(R.id.et_grade); |
| 37 | et_school = (TextView) findViewById(R.id.et_school); | 63 | et_school = (TextView) findViewById(R.id.et_school); |
| 38 | btn_ok = (Button) findViewById(R.id.btn_ok); | 64 | btn_ok = (Button) findViewById(R.id.btn_ok); |
| 39 | 65 | ||
| 40 | 66 | ||
| 41 | } | 67 | } |
| 42 | 68 | ||
| 43 | private void initData() { | 69 | private void initData() { |
| 44 | items = new String[] { "魏", "蜀", "吴" }; | 70 | items = new String[] { "魏", "蜀", "吴" }; |
| 45 | 71 | ||
| 46 | } | 72 | } |
| 47 | 73 | ||
| 48 | private void initLister() { | 74 | private void initLister() { |
| 49 | et_region.setOnClickListener(this); | 75 | et_region.setOnClickListener(this); |
| 50 | et_grade.setOnClickListener(this); | 76 | et_grade.setOnClickListener(this); |
| 51 | et_school.setOnClickListener(this); | 77 | et_school.setOnClickListener(this); |
| 52 | btn_ok.setOnClickListener(this); | 78 | btn_ok.setOnClickListener(this); |
| 53 | 79 | ||
| 54 | 80 | ||
| 55 | } | 81 | } |
| 56 | 82 | ||
| 57 | @Override | 83 | @Override |
| 58 | public void onClick(View v) { | 84 | public void onClick(View v) { |
| 59 | switch (v.getId()){ | 85 | switch (v.getId()){ |
| 60 | case R.id.et_region: | 86 | case R.id.et_region: |
| 87 | choiseregion(); | ||
| 61 | break; | 88 | break; |
| 62 | case R.id.et_grade: | 89 | case R.id.et_grade: |
| 63 | choisegrade(); | 90 | choisegrade(); |
| 64 | break; | 91 | break; |
| 65 | case R.id.et_school: | 92 | case R.id.et_school: |
| 66 | break; | 93 | break; |
| 67 | case R.id.btn_ok: | 94 | case R.id.btn_ok: |
| 68 | Intent intent = new Intent(); | 95 | Intent intent = new Intent(); |
| 69 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 96 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); |
| 70 | startActivity(intent); | 97 | startActivity(intent); |
| 71 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 98 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 72 | break; | 99 | break; |
| 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 | private void choisegrade() { | 109 | private void choisegrade() { |
| 78 | ListDialog.getInstance().show(getSupportFragmentManager(), "ListDialog"); | 110 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); |
| 79 | 111 | ||
| 80 | } | 112 | } |
| 81 | } | 113 | } |
| 82 | 114 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/areapicker/AreaBean.java
| File was created | 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 | } | ||
| 69 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
| File was created | 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 | } | ||
| 66 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ListDialog.java
| 1 | package com.hjx.personalcenter.customdialog; | File was deleted | |
| 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 | } | ||
| 66 | 1 | package com.hjx.personalcenter.customdialog; |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
| File was created | 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 | } | ||
| 65 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/RemoteException.java
| File was created | 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 | } | ||
| 35 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/ResponseError.java
| File was created | 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 | } | ||
| 36 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/LoginFragment.java
| 1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.support.annotation.Nullable; | 5 | import android.support.annotation.Nullable; |
| 6 | import android.support.v4.app.Fragment; | 6 | import android.support.v4.app.Fragment; |
| 7 | import android.text.TextUtils; | ||
| 7 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
| 8 | import android.view.View; | 9 | import android.view.View; |
| 9 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
| 10 | import android.widget.Button; | 11 | import android.widget.Button; |
| 12 | import android.widget.EditText; | ||
| 11 | import android.widget.TextView; | 13 | import android.widget.TextView; |
| 12 | 14 | ||
| 13 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
| 14 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; | 16 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; |
| 15 | import com.hjx.personalcenter.activity.MainActivity; | 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 | * 登录 |
| 19 | * Created by h on 2017/8/8. | 24 | * Created by h on 2017/8/8. |
| 20 | */ | 25 | */ |
| 21 | 26 | ||
| 22 | public class LoginFragment extends Fragment implements View.OnClickListener { | 27 | public class LoginFragment extends Fragment implements View.OnClickListener { |
| 23 | private View mView; | 28 | private View mView; |
| 24 | private int type; | 29 | private int type; |
| 25 | private TextView tv_forget_pwd; | 30 | private TextView tv_forget_pwd; |
| 26 | private Button btn_login; | 31 | private Button btn_login; |
| 32 | private EditText phonenumber,login_pwwd; | ||
| 27 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 33 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
| 28 | Intent intent = new Intent(); | 34 | Intent intent = new Intent(); |
| 29 | public static LoginFragment newInstance(int type) { | 35 | public static LoginFragment newInstance(int type) { |
| 30 | LoginFragment fragment = new LoginFragment(); | 36 | LoginFragment fragment = new LoginFragment(); |
| 31 | Bundle bundle = new Bundle(); | 37 | Bundle bundle = new Bundle(); |
| 32 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 38 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
| 33 | fragment.setArguments(bundle); | 39 | fragment.setArguments(bundle); |
| 34 | return fragment; | 40 | return fragment; |
| 35 | 41 | ||
| 36 | } | 42 | } |
| 37 | 43 | ||
| 38 | @Override | 44 | @Override |
| 39 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 45 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 40 | if (mView == null) { | 46 | if (mView == null) { |
| 41 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); | 47 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); |
| 42 | initView(mView); | 48 | initView(mView); |
| 43 | initData(); | 49 | initData(); |
| 44 | setLister(); | 50 | setLister(); |
| 45 | 51 | ||
| 46 | 52 | ||
| 47 | } | 53 | } |
| 48 | return mView; | 54 | return mView; |
| 49 | } | 55 | } |
| 50 | //初始化 | 56 | //初始化 |
| 51 | private void initView(View mView) { | 57 | private void initView(View mView) { |
| 52 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); | 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 | btn_login = (Button) mView.findViewById(R.id.btn_login); | 61 | btn_login = (Button) mView.findViewById(R.id.btn_login); |
| 54 | 62 | ||
| 55 | } | 63 | } |
| 56 | private void initData() { | 64 | private void initData() { |
| 57 | } | 65 | } |
| 58 | private void setLister() { | 66 | private void setLister() { |
| 59 | tv_forget_pwd.setOnClickListener(this); | 67 | tv_forget_pwd.setOnClickListener(this); |
| 60 | btn_login.setOnClickListener(this); | 68 | btn_login.setOnClickListener(this); |
| 61 | } | 69 | } |
| 62 | 70 | ||
| 63 | 71 | ||
| 64 | @Override | 72 | @Override |
| 65 | public void onClick(View v) { | 73 | public void onClick(View v) { |
| 66 | switch (v.getId()){ | 74 | switch (v.getId()){ |
| 67 | case R.id.tv_forget_pwd: | 75 | case R.id.tv_forget_pwd: |
| 68 | intent.setClass(getActivity(),ForgotPasswordActivity.class); | 76 | intent.setClass(getActivity(),ForgotPasswordActivity.class); |
| 69 | startActivity(intent); | 77 | startActivity(intent); |
| 70 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 78 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 71 | break; | 79 | break; |
| 72 | case R.id.btn_login: | 80 | case R.id.btn_login: |
| 73 | intent.setClass(getActivity(),MainActivity.class); | 81 | login(); |
| 74 | startActivity(intent); | ||
| 75 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | ||
| 76 | break; | 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 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/RegisterFragment.java
| 1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.os.Handler; | ||
| 6 | import android.os.Message; | ||
| 5 | import android.support.annotation.Nullable; | 7 | import android.support.annotation.Nullable; |
| 6 | import android.support.v4.app.Fragment; | 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 | import android.view.LayoutInflater; | 12 | import android.view.LayoutInflater; |
| 8 | import android.view.View; | 13 | import android.view.View; |
| 9 | import android.view.ViewGroup; | 14 | import android.view.ViewGroup; |
| 10 | import android.widget.Button; | 15 | import android.widget.Button; |
| 16 | import android.widget.EditText; | ||
| 17 | import android.widget.ImageView; | ||
| 11 | 18 | ||
| 12 | import com.hjx.personalcenter.R; | 19 | import com.hjx.personalcenter.R; |
| 13 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | 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 | * 注册 |
| 17 | * Created by Administrator on 2016/11/7. | 32 | * Created by Administrator on 2016/11/7. |
| 18 | */ | 33 | */ |
| 19 | 34 | ||
| 20 | public class RegisterFragment extends Fragment implements View.OnClickListener { | 35 | public class RegisterFragment extends Fragment implements View.OnClickListener { |
| 21 | private View mView; | 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 | private int type; | 45 | private int type; |
| 46 | public static Boolean showPassword = false; | ||
| 24 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 47 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
| 25 | 48 | ||
| 26 | public static RegisterFragment newInstance(int type) { | 49 | public static RegisterFragment newInstance(int type) { |
| 27 | RegisterFragment fragment = new RegisterFragment(); | 50 | RegisterFragment fragment = new RegisterFragment(); |
| 28 | Bundle bundle = new Bundle(); | 51 | Bundle bundle = new Bundle(); |
| 29 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 52 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
| 30 | fragment.setArguments(bundle); | 53 | fragment.setArguments(bundle); |
| 31 | return fragment; | 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 | @Override | 124 | @Override |
| 35 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 125 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 36 | if (mView == null) { | 126 | if (mView == null) { |
| 37 | mView = inflater.inflate(R.layout.fragment_loginandregister_register, container, false); | 127 | mView = inflater.inflate(R.layout.fragment_loginandregister_register, container, false); |
| 38 | initView(mView); | 128 | initView(mView); |
| 39 | initData(); | 129 | initData(); |
| 40 | setLister(); | 130 | setLister(); |
| 41 | 131 | ||
| 42 | 132 | ||
| 43 | } | 133 | } |
| 44 | return mView; | 134 | return mView; |
| 45 | } | 135 | } |
| 46 | 136 | ||
| 47 | private void initView(View mView) { | 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 | btn_register = (Button) mView.findViewById(R.id.btn_register); | 143 | btn_register = (Button) mView.findViewById(R.id.btn_register); |
| 49 | 144 | ||
| 50 | } | 145 | } |
| 51 | private void initData() { | 146 | private void initData() { |
| 52 | } | 147 | } |
| 53 | private void setLister() { | 148 | private void setLister() { |
| 149 | get_authcode.setOnClickListener(this); | ||
| 150 | openeyes.setOnClickListener(this); | ||
| 54 | btn_register.setOnClickListener(this); | 151 | btn_register.setOnClickListener(this); |
| 55 | } | 152 | } |
| 56 | 153 | ||
| 57 | 154 | ||
| 58 | @Override | 155 | @Override |
| 59 | public void onClick(View v) { | 156 | public void onClick(View v) { |
| 60 | switch (v.getId()){ | 157 | switch (v.getId()){ |
| 61 | case R.id.btn_register: | 158 | case R.id.btn_register: |
| 159 | //测试 | ||
| 62 | Intent intent = new Intent(); | 160 | Intent intent = new Intent(); |
| 63 | intent.setClass(getActivity(),RegisterInfoActivity.class); | 161 | intent.setClass(getActivity(),RegisterInfoActivity.class); |
| 64 | startActivity(intent); | 162 | startActivity(intent); |
| 65 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 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 | break; | 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 | } |
| 71 | 254 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpClient.java
| File was created | 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 | } | ||
| 18 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
| File was created | 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 | } | ||
| 39 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpKey.java
| File was created | 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 | } | ||
| 25 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
| File was created | 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 | } | ||
| 326 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
| File was created | 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 | } | ||
| 23 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/BaseParser.java
| File was created | 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 | } | ||
| 56 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/ProvinceParser.java
| File was created | 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 | } | ||
| 57 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/AlertUtils.java
| File was created | 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 | } | ||
| 12 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/DialogPermission.java
| File was created | 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 | } | ||
| 89 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/Judgment.java
| File was created | 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 | } | ||
| 234 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/PasswordCheckUtils.java
| File was created | 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 | } | ||
| 69 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/PhoneNumCheckUtils.java
| File was created | 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 | } | ||
| 149 |
PersonalCenter/app/src/main/res/layout/activity_forgetpsword.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
| 4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
| 5 | android:background="#ffffffff" | 5 | android:background="#ffffffff" |
| 6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
| 7 | 7 | ||
| 8 | <RelativeLayout | 8 | <RelativeLayout |
| 9 | android:id="@+id/title" | 9 | android:id="@+id/title" |
| 10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
| 11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
| 12 | android:background="@color/login_text_blue" | 12 | android:background="@color/login_text_blue" |
| 13 | android:minHeight="50dp"> | 13 | android:minHeight="50dp"> |
| 14 | 14 | ||
| 15 | <ImageView | 15 | <ImageView |
| 16 | android:id="@+id/cancel" | 16 | android:id="@+id/cancel" |
| 17 | android:layout_width="wrap_content" | 17 | android:layout_width="wrap_content" |
| 18 | android:layout_height="wrap_content" | 18 | android:layout_height="wrap_content" |
| 19 | android:layout_centerVertical="true" | 19 | android:layout_centerVertical="true" |
| 20 | android:paddingLeft="20dp" | 20 | android:paddingLeft="20dp" |
| 21 | android:paddingRight="20dp" | 21 | android:paddingRight="20dp" |
| 22 | android:src="@mipmap/title_back" /> | 22 | android:src="@mipmap/title_back" /> |
| 23 | 23 | ||
| 24 | <TextView | 24 | <TextView |
| 25 | android:id="@+id/menu_title" | 25 | android:id="@+id/menu_title" |
| 26 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
| 27 | android:layout_height="wrap_content" | 27 | android:layout_height="wrap_content" |
| 28 | android:layout_centerInParent="true" | 28 | android:layout_centerInParent="true" |
| 29 | android:text="@string/string_menu_title" | 29 | android:text="@string/string_menu_title" |
| 30 | android:textColor="@android:color/white" | 30 | android:textColor="@android:color/white" |
| 31 | android:textSize="22sp" /> | 31 | android:textSize="22sp" /> |
| 32 | </RelativeLayout> | 32 | </RelativeLayout> |
| 33 | 33 | ||
| 34 | <RelativeLayout | 34 | <RelativeLayout |
| 35 | android:layout_width="match_parent" | 35 | android:layout_width="match_parent" |
| 36 | android:layout_height="match_parent" | 36 | android:layout_height="match_parent" |
| 37 | android:layout_below="@id/title" | 37 | android:layout_below="@id/title" |
| 38 | android:background="#ffffffff" | 38 | android:background="#ffffffff" |
| 39 | android:orientation="vertical" | 39 | android:orientation="vertical" |
| 40 | android:paddingLeft="250dp" | 40 | android:paddingLeft="250dp" |
| 41 | android:paddingRight="250dp"> | 41 | android:paddingRight="250dp"> |
| 42 | 42 | ||
| 43 | <EditText | 43 | <EditText |
| 44 | android:id="@+id/et_phonenumber" | 44 | android:id="@+id/et_phonenumber" |
| 45 | style="@style/login_register_edit_style" | 45 | style="@style/login_register_edit_style" |
| 46 | android:layout_marginTop="150dp" | 46 | android:layout_marginTop="150dp" |
| 47 | android:hint="手机号" | 47 | android:hint="手机号" |
| 48 | android:inputType="phone" /> | 48 | android:inputType="phone" /> |
| 49 | 49 | ||
| 50 | <TextView | 50 | <TextView |
| 51 | android:id="@+id/phonenumber_error_hint" | 51 | android:id="@+id/phonenumber_error_hint" |
| 52 | style="@style/registererrhint_style" | 52 | style="@style/registererrhint_style" |
| 53 | android:layout_below="@id/et_phonenumber" /> | 53 | android:layout_below="@id/et_phonenumber" /> |
| 54 | 54 | ||
| 55 | <LinearLayout | 55 | <LinearLayout |
| 56 | android:id="@+id/rl_authcode" | 56 | android:id="@+id/rl_authcode" |
| 57 | android:layout_width="match_parent" | 57 | android:layout_width="match_parent" |
| 58 | android:layout_height="wrap_content" | 58 | android:layout_height="wrap_content" |
| 59 | android:layout_below="@id/et_phonenumber" | 59 | android:layout_below="@id/et_phonenumber" |
| 60 | android:layout_marginTop="30dp" | 60 | android:layout_marginTop="30dp" |
| 61 | android:orientation="horizontal"> | 61 | android:orientation="horizontal"> |
| 62 | 62 | ||
| 63 | <EditText | 63 | <EditText |
| 64 | android:id="@+id/et_authcode" | 64 | android:id="@+id/et_authcode" |
| 65 | style="@style/login_register_edit_rect_style" | 65 | style="@style/login_register_edit_rect_style" |
| 66 | android:layout_marginRight="-4px" | 66 | android:layout_marginRight="-4px" |
| 67 | android:layout_weight="1" | 67 | android:layout_weight="1" |
| 68 | android:hint="验证码" | 68 | android:hint="验证码" |
| 69 | android:numeric="integer" /> | 69 | android:numeric="integer" /> |
| 70 | 70 | ||
| 71 | <Button | 71 | <Button |
| 72 | android:id="@+id/btn_authcode" | 72 | android:id="@+id/btn_authcode" |
| 73 | style="@style/login_register_btn_authcode_rect_style" | 73 | style="@style/login_register_btn_authcode_rect_style" |
| 74 | android:layout_marginLeft="0px" | 74 | android:layout_marginLeft="0px" |
| 75 | android:layout_marginTop="0px" | 75 | android:layout_marginTop="0px" |
| 76 | android:layout_weight="2" | 76 | android:layout_weight="2" |
| 77 | android:text="获取验证码" | 77 | android:text="获取验证码" |
| 78 | android:textColor="@color/btn_text_color" /> | 78 | android:textColor="@color/btn_text_color" /> |
| 79 | </LinearLayout> | 79 | </LinearLayout> |
| 80 | 80 | ||
| 81 | <TextView | 81 | <TextView |
| 82 | android:id="@+id/authcode_error_hint" | 82 | android:id="@+id/authcode_error_hint" |
| 83 | style="@style/registererrhint_style" | 83 | style="@style/registererrhint_style" |
| 84 | android:layout_below="@id/rl_authcode" /> | 84 | android:layout_below="@id/rl_authcode" /> |
| 85 | 85 | ||
| 86 | <RelativeLayout | 86 | <RelativeLayout |
| 87 | android:id="@+id/pwd_rl" | 87 | android:id="@+id/pwd_rl" |
| 88 | android:layout_width="match_parent" | 88 | android:layout_width="match_parent" |
| 89 | android:layout_height="wrap_content" | 89 | android:layout_height="wrap_content" |
| 90 | android:layout_below="@id/rl_authcode" | 90 | android:layout_below="@id/rl_authcode" |
| 91 | android:layout_marginTop="30dp"> | 91 | android:layout_marginTop="30dp"> |
| 92 | 92 | ||
| 93 | <EditText | 93 | <EditText |
| 94 | android:id="@+id/et_newpassword" | 94 | android:id="@+id/et_newpassword" |
| 95 | style="@style/login_register_edit_style" | 95 | style="@style/login_register_edit_style" |
| 96 | android:hint="密码为英文和数字组成,最少8位" | 96 | android:hint="密码为英文和数字组成,最少8位" |
| 97 | android:inputType="textPassword" /> | 97 | android:inputType="textPassword" /> |
| 98 | 98 | ||
| 99 | <ImageView | 99 | <ImageView |
| 100 | android:id="@+id/iv_pwd_change" | 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 | </RelativeLayout> | 109 | </RelativeLayout> |
| 103 | 110 | ||
| 104 | <TextView | 111 | <TextView |
| 105 | android:id="@+id/newpassword_error_hint" | 112 | android:id="@+id/newpassword_error_hint" |
| 106 | style="@style/registererrhint_style" | 113 | style="@style/registererrhint_style" |
| 107 | android:layout_below="@id/pwd_rl" /> | 114 | android:layout_below="@id/pwd_rl" /> |
| 108 | 115 | ||
| 109 | <EditText | 116 | <EditText |
| 110 | android:id="@+id/et_again_newpassword" | 117 | android:id="@+id/et_again_newpassword" |
| 111 | style="@style/login_register_edit_style" | 118 | style="@style/login_register_edit_style" |
| 112 | android:layout_below="@id/pwd_rl" | 119 | android:layout_below="@id/pwd_rl" |
| 113 | android:layout_marginTop="30dp" | 120 | android:layout_marginTop="30dp" |
| 114 | android:hint="再次输入新密码" | 121 | android:hint="再次输入新密码" |
| 115 | android:inputType="textPassword" /> | 122 | android:inputType="textPassword" /> |
| 116 | 123 | ||
| 117 | <TextView | 124 | <TextView |
| 118 | android:id="@+id/again_newpassword_error_hint" | 125 | android:id="@+id/again_newpassword_error_hint" |
| 119 | style="@style/registererrhint_style" | 126 | style="@style/registererrhint_style" |
| 120 | android:layout_below="@id/et_again_newpassword" /> | 127 | android:layout_below="@id/et_again_newpassword" /> |
| 121 | 128 | ||
| 122 | <Button | 129 | <Button |
| 123 | android:id="@+id/btn_ok" | 130 | android:id="@+id/btn_ok" |
| 124 | style="@style/button_login_register_style" | 131 | style="@style/button_login_register_style" |
| 125 | android:layout_below="@id/et_again_newpassword" | 132 | android:layout_below="@id/et_again_newpassword" |
| 126 | android:layout_marginTop="30dp" | 133 | android:layout_marginTop="30dp" |
| 127 | android:text="确 定" /> | 134 | android:text="确 定" /> |
| 128 | </RelativeLayout> | 135 | </RelativeLayout> |
| 129 | 136 | ||
| 130 | </RelativeLayout> | 137 | </RelativeLayout> |
PersonalCenter/app/src/main/res/layout/custom_adilog_gradelist.xml
| File was created | 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> | ||
| 39 |
PersonalCenter/app/src/main/res/layout/custom_adilog_list.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | File was deleted | |
| 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> | ||
| 39 | 1 | <?xml version="1.0" encoding="utf-8"?> |
PersonalCenter/app/src/main/res/layout/custom_adilog_provicelist.xml
| File was created | 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> | ||
| 39 |
PersonalCenter/app/src/main/res/layout/fragment_loginandregister_register.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
| 4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
| 5 | android:background="#ffffffff" | 5 | android:background="#ffffffff" |
| 6 | android:orientation="vertical" | 6 | android:orientation="vertical" |
| 7 | android:paddingLeft="250dp" | 7 | android:paddingLeft="250dp" |
| 8 | android:paddingRight="250dp"> | 8 | android:paddingRight="250dp"> |
| 9 | 9 | ||
| 10 | <EditText | 10 | <EditText |
| 11 | android:id="@+id/et_phonenumber" | 11 | android:id="@+id/et_phonenumber" |
| 12 | style="@style/login_register_edit_style" | 12 | style="@style/login_register_edit_style" |
| 13 | android:layout_marginTop="20dp" | 13 | android:layout_marginTop="20dp" |
| 14 | android:hint="手机号" | 14 | android:hint="手机号" |
| 15 | android:inputType="phone" /> | 15 | android:inputType="phone" /> |
| 16 | 16 | ||
| 17 | <TextView | 17 | <TextView |
| 18 | android:id="@+id/phonenumber_error_hint" | 18 | android:id="@+id/phonenumber_error_hint" |
| 19 | style="@style/registererrhint_style" | 19 | style="@style/registererrhint_style" |
| 20 | android:layout_below="@id/et_phonenumber" /> | 20 | android:layout_below="@id/et_phonenumber" /> |
| 21 | 21 | ||
| 22 | <LinearLayout | 22 | <LinearLayout |
| 23 | android:id="@+id/rl_authcode" | 23 | android:id="@+id/rl_authcode" |
| 24 | android:layout_width="match_parent" | 24 | android:layout_width="match_parent" |
| 25 | android:layout_height="wrap_content" | 25 | android:layout_height="wrap_content" |
| 26 | android:layout_below="@id/et_phonenumber" | 26 | android:layout_below="@id/et_phonenumber" |
| 27 | android:layout_marginTop="30dp" | 27 | android:layout_marginTop="30dp" |
| 28 | android:orientation="horizontal"> | 28 | android:orientation="horizontal"> |
| 29 | 29 | ||
| 30 | <EditText | 30 | <EditText |
| 31 | android:id="@+id/et_authcode" | 31 | android:id="@+id/et_authcode" |
| 32 | style="@style/login_register_edit_rect_style" | 32 | style="@style/login_register_edit_rect_style" |
| 33 | android:layout_marginRight="-4px" | 33 | android:layout_marginRight="-4px" |
| 34 | android:layout_weight="1" | 34 | android:layout_weight="1" |
| 35 | android:hint="验证码" | 35 | android:hint="验证码" |
| 36 | android:numeric="integer" /> | 36 | android:numeric="integer" /> |
| 37 | 37 | ||
| 38 | <Button | 38 | <Button |
| 39 | android:id="@+id/btn_authcode" | 39 | android:id="@+id/btn_authcode" |
| 40 | style="@style/login_register_btn_authcode_rect_style" | 40 | style="@style/login_register_btn_authcode_rect_style" |
| 41 | android:layout_marginLeft="0px" | 41 | android:layout_marginLeft="0px" |
| 42 | android:layout_marginTop="0px" | 42 | android:layout_marginTop="0px" |
| 43 | android:layout_weight="2" | 43 | android:layout_weight="2" |
| 44 | android:text="获取验证码" | 44 | android:text="获取验证码" |
| 45 | android:textColor="@color/btn_text_color" /> | 45 | android:textColor="@color/btn_text_color" /> |
| 46 | </LinearLayout> | 46 | </LinearLayout> |
| 47 | 47 | ||
| 48 | <TextView | 48 | <TextView |
| 49 | android:id="@+id/authcode_error_hint" | 49 | android:id="@+id/authcode_error_hint" |
| 50 | style="@style/registererrhint_style" | 50 | style="@style/registererrhint_style" |
| 51 | android:layout_below="@id/rl_authcode" /> | 51 | android:layout_below="@id/rl_authcode" /> |
| 52 | 52 | ||
| 53 | <RelativeLayout | 53 | <RelativeLayout |
| 54 | android:id="@+id/pwd_rl" | 54 | android:id="@+id/pwd_rl" |
| 55 | android:layout_width="match_parent" | 55 | android:layout_width="match_parent" |
| 56 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
| 57 | android:layout_below="@id/rl_authcode" | 57 | android:layout_below="@id/rl_authcode" |
| 58 | android:layout_marginTop="30dp"> | 58 | android:layout_marginTop="30dp"> |
| 59 | 59 | ||
| 60 | <EditText | 60 | <EditText |
| 61 | android:id="@+id/et_password" | 61 | android:id="@+id/et_password" |
| 62 | style="@style/login_register_edit_style" | 62 | style="@style/login_register_edit_style" |
| 63 | android:hint="密码为英文和数字组成,最少8位" | 63 | android:hint="密码为英文和数字组成,最少8位" |
| 64 | android:inputType="textPassword" /> | 64 | android:inputType="textPassword" /> |
| 65 | 65 | ||
| 66 | <ImageView | 66 | <ImageView |
| 67 | android:id="@+id/iv_pwd_change" | 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 | </RelativeLayout> | 76 | </RelativeLayout> |
| 70 | 77 | ||
| 71 | <TextView | 78 | <TextView |
| 72 | android:id="@+id/password_error_hint" | 79 | android:id="@+id/password_error_hint" |
| 73 | style="@style/registererrhint_style" | 80 | style="@style/registererrhint_style" |
| 74 | android:layout_below="@id/pwd_rl" /> | 81 | android:layout_below="@id/pwd_rl" /> |
| 75 | 82 | ||
| 76 | <Button | 83 | <Button |
| 77 | android:id="@+id/btn_register" | 84 | android:id="@+id/btn_register" |
| 78 | style="@style/button_login_register_style" | 85 | style="@style/button_login_register_style" |
| 79 | android:layout_below="@id/pwd_rl" | 86 | android:layout_below="@id/pwd_rl" |
| 80 | android:layout_marginTop="30dp" | 87 | android:layout_marginTop="30dp" |
| 81 | android:text="立即注册" /> | 88 | android:text="立即注册" /> |
| 82 | 89 | ||
| 83 | </RelativeLayout> | 90 | </RelativeLayout> |
PersonalCenter/app/src/main/res/mipmap-xhdpi/pwd_open.png
861 Bytes
PersonalCenter/app/src/main/res/values/strings.xml
| 1 | <resources> | 1 | <resources> |
| 2 | <string name="app_name">PersonalCenter</string> | 2 | <string name="app_name">PersonalCenter</string> |
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | //登录注册 | 6 | //登录注册 |
| 7 | <string name="cancel">取 消</string> | 7 | <string name="cancel">取 消</string> |
| 8 | <string name="ok">确 定</string> | 8 | <string name="ok">确 定</string> |
| 9 | <string name="forget_pwd">忘记密码</string> | 9 | <string name="forget_pwd">忘记密码</string> |
| 10 | <string name="string_menu_title">修改密码</string> | 10 | <string name="string_menu_title">忘记密码</string> |
| 11 | <string name="string_regist_info">填写注册信息</string> | 11 | <string name="string_regist_info">填写注册信息</string> |
| 12 | <string name="string_textbook_info">选择教材版本</string> | 12 | <string name="string_textbook_info">选择教材版本</string> |
| 13 | <string name="string_regist_username">用户名</string> | 13 | <string name="string_regist_username">用户名</string> |
| 14 | <string name="string_regist_region">地区</string> | 14 | <string name="string_regist_region">地区</string> |
| 15 | <string name="string_regist_grade">年级</string> | 15 | <string name="string_regist_grade">年级</string> |
| 16 | <string name="string_regist_school">学校</string> | 16 | <string name="string_regist_school">学校</string> |
| 17 | <string name="string_regist_next">下一步</string> | 17 | <string name="string_regist_next">下一步</string> |
| 18 | <string name="string_start_page">开始学习体验</string> | 18 | <string name="string_start_page">开始学习体验</string> |
| 19 | <string name="bangding">绑定家长控制</string> | 19 | <string name="bangding">绑定家长控制</string> |
| 20 | <string name="finish">完成</string> | 20 | <string name="finish">完成</string> |
| 21 | <string name="account_management">账户管理</string> | 21 | <string name="account_management">账户管理</string> |
| 22 | <string name="changge_preson">修改个人信息</string> | 22 | <string name="changge_preson">修改个人信息</string> |
| 23 | 23 | ||
| 24 | //电子保卡 | 24 | //电子保卡 |
| 25 | <string name="string_electroniccard_info_title">填写保卡信息</string> | 25 | <string name="string_electroniccard_info_title">填写保卡信息</string> |
| 26 | <string name="string_electroniccard_info_fill">填写电子保卡</string> | 26 | <string name="string_electroniccard_info_fill">填写电子保卡</string> |
| 27 | <string name="change_electroniccard_info_fill">修改保卡信息</string> | 27 | <string name="change_electroniccard_info_fill">修改保卡信息</string> |
| 28 | <string name="string_electroniccard_info_change">修改保卡信息</string> | 28 | <string name="string_electroniccard_info_change">修改保卡信息</string> |
| 29 | <string name="string_electroniccard_info_ok">确认保卡信息</string> | 29 | <string name="string_electroniccard_info_ok">确认保卡信息</string> |
| 30 | <string name="string_electroniccard_info_look">好记星-电子报卡</string> | 30 | <string name="string_electroniccard_info_look">好记星-电子报卡</string> |
| 31 | <string name="string_electroniccard_change_bangding">更换绑定</string> | 31 | <string name="string_electroniccard_change_bangding">更换绑定</string> |
| 32 | <string name="electronic_card">温馨提示:若您想修改的相关信息请拨打客服电话</string> | 32 | <string name="electronic_card">温馨提示:若您想修改的相关信息请拨打客服电话</string> |
| 33 | <string name="electronic_card1">请先填写《好记星-电子保卡》信息</string> | 33 | <string name="electronic_card1">请先填写《好记星-电子保卡》信息</string> |
| 34 | <string name="electronic_card2">该信息是本产品的三包证明,为维护您的合法权益,请认真填写</string> | 34 | <string name="electronic_card2">该信息是本产品的三包证明,为维护您的合法权益,请认真填写</string> |
| 35 | <string name="electronic_card3">您已填写完《好记星-电子保卡》信息</string> | 35 | <string name="electronic_card3">您已填写完《好记星-电子保卡》信息</string> |
| 36 | <string name="electronic_card4">您也可以设置家长管理,用手机及时了解和管理孩子的学习情况</string> | 36 | <string name="electronic_card4">您也可以设置家长管理,用手机及时了解和管理孩子的学习情况</string> |
| 37 | 37 | ||
| 38 | //意见反馈 | 38 | //意见反馈 |
| 39 | <string name="feedback">写下您对我们产品的意见吧,我们将努力完善,最多输入500字。</string> | 39 | <string name="feedback">写下您对我们产品的意见吧,我们将努力完善,最多输入500字。</string> |
| 40 | <string name="qq">QQ或手机号码</string> | 40 | <string name="qq">QQ或手机号码</string> |
| 41 | <string name="hint">留下您的联系方式,方便与您沟通。</string> | 41 | <string name="hint">留下您的联系方式,方便与您沟通。</string> |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | //个人中心 | 44 | //个人中心 |
| 45 | <string name="titel_preson">个人中心</string> | 45 | <string name="titel_preson">个人中心</string> |
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | </resources> | 49 | </resources> |
| 50 | 50 |
PersonalCenter/pickerview/build.gradle
| 1 | apply plugin: 'com.android.library' | 1 | apply plugin: 'com.android.library' |
| 2 | apply plugin: 'maven' | 2 | apply plugin: 'maven' |
| 3 | apply plugin: 'com.novoda.bintray-release'//添加插件 | 3 | apply plugin: 'com.novoda.bintray-release'//添加插件 |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | android { | 7 | android { |
| 8 | compileSdkVersion 25 | 8 | compileSdkVersion 25 |
| 9 | buildToolsVersion "25.0.2" | 9 | buildToolsVersion "25.0.2" |
| 10 | 10 | ||
| 11 | defaultConfig { | 11 | defaultConfig { |
| 12 | minSdkVersion 15 | 12 | minSdkVersion 15 |
| 13 | targetSdkVersion 25 | 13 | targetSdkVersion 25 |
| 14 | versionCode 22 | 14 | versionCode 22 |
| 15 | versionName "3.2.6" | 15 | versionName "3.2.6" |
| 16 | } | 16 | } |
| 17 | buildTypes { | 17 | buildTypes { |
| 18 | release { | 18 | release { |
| 19 | minifyEnabled false | 19 | minifyEnabled false |
| 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
| 23 | lintOptions { | 23 | lintOptions { |
| 24 | abortOnError false | 24 | abortOnError false |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | allprojects { | 28 | allprojects { |
| 29 | tasks.withType(Javadoc) {//兼容中文字符 | 29 | tasks.withType(Javadoc) {//兼容中文字符 |
| 30 | options{ | 30 | options{ |
| 31 | encoding "UTF-8" | 31 | encoding "UTF-8" |
| 32 | charSet 'UTF-8' | 32 | charSet 'UTF-8' |
| 33 | links "http://docs.oracle.com/javase/7/docs/api" | 33 | links "http://docs.oracle.com/javase/7/docs/api" |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | } | 36 | } |
| 37 | publish { | 37 | publish { |
| 38 | userOrg = 'contrarywind'//bintray.com 用户名/组织名 user/org name | 38 | userOrg = 'contrarywind'//bintray.com 用户名/组织名 user/org name |
| 39 | groupId = 'com.contrarywind'//JCenter上显示的路径 path | 39 | groupId = 'com.contrarywind'//JCenter上显示的路径 path |
| 40 | artifactId = 'Android-PickerView'//项目名称 project name | 40 | artifactId = 'Android-PickerView'//项目名称 project name |
| 41 | publishVersion = '3.2.6'//版本号 version code | 41 | publishVersion = '3.2.6'//版本号 version code |
| 42 | desc = 'this is a pickerview for android'//项目描述 description | 42 | desc = 'this is a pickerview for android'//项目描述 description |
| 43 | website = 'https://github.com/Contrarywind/Android-PickerView' //项目网址链接 link | 43 | website = 'https://github.com/Contrarywind/Android-PickerView' //项目网址链接 link |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | dependencies { | 46 | dependencies { |
| 47 | compile fileTree(include: ['*.jar'], dir: 'libs') | 47 | compile fileTree(include: ['*.jar'], dir: 'libs') |
| 48 | |||
| 49 | } | 48 | } |