Commit 7b881e316bc5047d0cc4cc49d6d7e6586f963cbd
1 parent
11eee1b3af
Exists in
master
省,市 ,区接口调试
Showing
17 changed files
with
380 additions
and
342 deletions
Show diff stats
PersonalCenter/.idea/misc.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | <component name="EntryPointsManager"> | 3 | <component name="EntryPointsManager"> |
4 | <entry_points version="2.0" /> | 4 | <entry_points version="2.0" /> |
5 | </component> | 5 | </component> |
6 | <component name="NullableNotNullManager"> | 6 | <component name="NullableNotNullManager"> |
7 | <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> | 7 | <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> |
8 | <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> | 8 | <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> |
9 | <option name="myNullables"> | 9 | <option name="myNullables"> |
10 | <value> | 10 | <value> |
11 | <list size="4"> | 11 | <list size="4"> |
12 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> | 12 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> |
13 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> | 13 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> |
14 | <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | 14 | <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> |
15 | <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | 15 | <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> |
16 | </list> | 16 | </list> |
17 | </value> | 17 | </value> |
18 | </option> | 18 | </option> |
19 | <option name="myNotNulls"> | 19 | <option name="myNotNulls"> |
20 | <value> | 20 | <value> |
21 | <list size="4"> | 21 | <list size="4"> |
22 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> | 22 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> |
23 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> | 23 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> |
24 | <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> | 24 | <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> |
25 | <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> | 25 | <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> |
26 | </list> | 26 | </list> |
27 | </value> | 27 | </value> |
28 | </option> | 28 | </option> |
29 | </component> | 29 | </component> |
30 | <component name="ProjectInspectionProfilesVisibleTreeState"> | 30 | <component name="ProjectInspectionProfilesVisibleTreeState"> |
31 | <entry key="Project Default"> | 31 | <entry key="Project Default"> |
32 | <profile-state> | 32 | <profile-state> |
33 | <expanded-state> | 33 | <expanded-state> |
34 | <State> | 34 | <State> |
35 | <id /> | 35 | <id /> |
36 | </State> | 36 | </State> |
37 | <State> | 37 | <State> |
38 | <id>Class structureJava</id> | 38 | <id>Class structureJava</id> |
39 | </State> | 39 | </State> |
40 | <State> | 40 | <State> |
41 | <id>Code maturity issuesJava</id> | 41 | <id>Code maturity issuesJava</id> |
42 | </State> | 42 | </State> |
43 | <State> | 43 | <State> |
44 | <id>Java</id> | 44 | <id>Java</id> |
45 | </State> | 45 | </State> |
46 | <State> | 46 | <State> |
47 | <id>Java language level migration aidsJava</id> | 47 | <id>Java language level migration aidsJava</id> |
48 | </State> | 48 | </State> |
49 | <State> | 49 | <State> |
50 | <id>Javadoc issuesJava</id> | 50 | <id>Javadoc issuesJava</id> |
51 | </State> | 51 | </State> |
52 | <State> | 52 | <State> |
53 | <id>Performance issuesJava</id> | 53 | <id>Performance issuesJava</id> |
54 | </State> | 54 | </State> |
55 | <State> | 55 | <State> |
56 | <id>TestNGJava</id> | 56 | <id>TestNGJava</id> |
57 | </State> | 57 | </State> |
58 | <State> | 58 | <State> |
59 | <id>Threading issuesJava</id> | 59 | <id>Threading issuesJava</id> |
60 | </State> | 60 | </State> |
61 | </expanded-state> | 61 | </expanded-state> |
62 | <selected-state> | 62 | <selected-state> |
63 | <State> | 63 | <State> |
64 | <id>Android</id> | 64 | <id>Android</id> |
65 | </State> | 65 | </State> |
66 | </selected-state> | 66 | </selected-state> |
67 | </profile-state> | 67 | </profile-state> |
68 | </entry> | 68 | </entry> |
69 | </component> | 69 | </component> |
70 | <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | 70 | <component name="ProjectLevelVcsManager" settingsEditedManually="false"> |
71 | <OptionsSetting value="true" id="Add" /> | 71 | <OptionsSetting value="true" id="Add" /> |
72 | <OptionsSetting value="true" id="Remove" /> | 72 | <OptionsSetting value="true" id="Remove" /> |
73 | <OptionsSetting value="true" id="Checkout" /> | 73 | <OptionsSetting value="true" id="Checkout" /> |
74 | <OptionsSetting value="true" id="Update" /> | 74 | <OptionsSetting value="true" id="Update" /> |
75 | <OptionsSetting value="true" id="Status" /> | 75 | <OptionsSetting value="true" id="Status" /> |
76 | <OptionsSetting value="true" id="Edit" /> | 76 | <OptionsSetting value="true" id="Edit" /> |
77 | <ConfirmationsSetting value="0" id="Add" /> | 77 | <ConfirmationsSetting value="0" id="Add" /> |
78 | <ConfirmationsSetting value="0" id="Remove" /> | 78 | <ConfirmationsSetting value="0" id="Remove" /> |
79 | </component> | 79 | </component> |
80 | <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | 80 | <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
81 | <output url="file://$PROJECT_DIR$/build/classes" /> | 81 | <output url="file://$PROJECT_DIR$/build/classes" /> |
82 | </component> | 82 | </component> |
83 | <component name="ProjectType"> | 83 | <component name="ProjectType"> |
84 | <option name="id" value="Android" /> | 84 | <option name="id" value="Android" /> |
85 | </component> | 85 | </component> |
86 | </project> | 86 | </project> |
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' | 20 | useLibrary 'org.apache.http.legacy' |
21 | sourceSets { | 21 | sourceSets { |
22 | main { | 22 | main { |
23 | jniLibs.srcDirs = ['libs'] | 23 | jniLibs.srcDirs = ['libs'] |
24 | } | 24 | } |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | dependencies { | 28 | dependencies { |
29 | compile fileTree(include: ['*.jar'], dir: 'libs') | 29 | compile fileTree(include: ['*.jar'], dir: 'libs') |
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
31 | exclude group: 'com.android.support', module: 'support-annotations' | 31 | exclude group: 'com.android.support', module: 'support-annotations' |
32 | }) | 32 | }) |
33 | compile 'com.tencent.bugly:crashreport:latest.release' | 33 | compile 'com.tencent.bugly:crashreport:latest.release' |
34 | compile 'org.apache.httpcomponents:httpcore:4.4.1' | 34 | compile 'org.apache.httpcomponents:httpcore:4.4.1' |
35 | compile 'org.apache.httpcomponents:httpclient:4.5' | 35 | compile 'org.apache.httpcomponents:httpclient:4.5' |
36 | compile 'com.android.support:appcompat-v7:25.3.1' | 36 | compile 'com.android.support:appcompat-v7:25.3.1' |
37 | testCompile 'junit:junit:4.12' | 37 | testCompile 'junit:junit:4.12' |
38 | compile project(':circledialog') | 38 | compile project(':circledialog') |
39 | compile project(':pickerview') | 39 | compile project(':pickerview') |
40 | compile files('libs/android-async-http-1.4.8.jar') | 40 | compile files('libs/android-async-http-1.4.8.jar') |
41 | compile 'com.google.code.gson:gson:2.7' | ||
41 | } | 42 | } |
42 | 43 |
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; | 5 | import android.text.TextUtils; |
6 | import android.text.method.HideReturnsTransformationMethod; | 6 | import android.text.method.HideReturnsTransformationMethod; |
7 | import android.text.method.PasswordTransformationMethod; | 7 | import android.text.method.PasswordTransformationMethod; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.widget.Button; | 9 | import android.widget.Button; |
10 | import android.widget.EditText; | 10 | import android.widget.EditText; |
11 | import android.widget.ImageView; | 11 | import android.widget.ImageView; |
12 | 12 | ||
13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.http.HttpManager; | 14 | import com.hjx.personalcenter.http.HttpManager; |
15 | import com.hjx.personalcenter.util.AlertUtils; | 15 | import com.hjx.personalcenter.util.AlertUtils; |
16 | import com.hjx.personalcenter.util.PasswordCheckUtils; | 16 | import com.hjx.personalcenter.util.PasswordCheckUtils; |
17 | import com.hjx.personalcenter.util.SaveParam; | 17 | import com.hjx.personalcenter.db.SaveParam; |
18 | 18 | ||
19 | /**修改密码 | 19 | /**修改密码 |
20 | * Created by h on 2017/6/27. | 20 | * Created by h on 2017/6/27. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | public class ChangePasswordActivity extends Activity implements View.OnClickListener { | 23 | public class ChangePasswordActivity extends Activity implements View.OnClickListener { |
24 | private EditText old_pwd,newpassword,newpassword1; | 24 | private EditText old_pwd,newpassword,newpassword1; |
25 | private Button sub_change_pwd; | 25 | private Button sub_change_pwd; |
26 | private ImageView back_change_pwd,eyes_iv_change1,eyes_iv_change2; | 26 | private ImageView back_change_pwd,eyes_iv_change1,eyes_iv_change2; |
27 | public static Boolean showPassword = false; | 27 | public static Boolean showPassword = false; |
28 | @Override | 28 | @Override |
29 | protected void onCreate(Bundle savedInstanceState) { | 29 | protected void onCreate(Bundle savedInstanceState) { |
30 | super.onCreate(savedInstanceState); | 30 | super.onCreate(savedInstanceState); |
31 | setContentView(R.layout.activity_changepsword); | 31 | setContentView(R.layout.activity_changepsword); |
32 | initView(); | 32 | initView(); |
33 | setLister(); | 33 | setLister(); |
34 | } | 34 | } |
35 | 35 | ||
36 | private void initView() { | 36 | private void initView() { |
37 | old_pwd = (EditText) findViewById(R.id.et_oldpassword); | 37 | old_pwd = (EditText) findViewById(R.id.et_oldpassword); |
38 | newpassword = (EditText) findViewById(R.id.et_newpassword); | 38 | newpassword = (EditText) findViewById(R.id.et_newpassword); |
39 | newpassword1 = (EditText) findViewById(R.id.et_again_newpassword); | 39 | newpassword1 = (EditText) findViewById(R.id.et_again_newpassword); |
40 | sub_change_pwd = (Button) findViewById(R.id.btn_ok); | 40 | sub_change_pwd = (Button) findViewById(R.id.btn_ok); |
41 | back_change_pwd = (ImageView) findViewById(R.id.cancel); | 41 | back_change_pwd = (ImageView) findViewById(R.id.cancel); |
42 | eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change); | 42 | eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change); |
43 | 43 | ||
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | private void setLister() { | 47 | private void setLister() { |
48 | sub_change_pwd.setOnClickListener(this); | 48 | sub_change_pwd.setOnClickListener(this); |
49 | back_change_pwd.setOnClickListener(this); | 49 | back_change_pwd.setOnClickListener(this); |
50 | eyes_iv_change1.setOnClickListener(this); | 50 | eyes_iv_change1.setOnClickListener(this); |
51 | eyes_iv_change2.setOnClickListener(this); | 51 | eyes_iv_change2.setOnClickListener(this); |
52 | } | 52 | } |
53 | 53 | ||
54 | @Override | 54 | @Override |
55 | public void onClick(View v) { | 55 | public void onClick(View v) { |
56 | String old_pwd1 = old_pwd.getText().toString().trim(); | 56 | String old_pwd1 = old_pwd.getText().toString().trim(); |
57 | String newpassword3 = newpassword.getText().toString().trim(); | 57 | String newpassword3 = newpassword.getText().toString().trim(); |
58 | String newpassword4 = newpassword1.getText().toString().trim(); | 58 | String newpassword4 = newpassword1.getText().toString().trim(); |
59 | switch (v.getId()){ | 59 | switch (v.getId()){ |
60 | //确认修改 | 60 | //确认修改 |
61 | case R.id.btn_ok: | 61 | case R.id.btn_ok: |
62 | 62 | ||
63 | //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password")); | 63 | //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password")); |
64 | if (TextUtils.isEmpty(old_pwd1)|| | 64 | if (TextUtils.isEmpty(old_pwd1)|| |
65 | TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){ | 65 | TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){ |
66 | AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整"); | 66 | AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整"); |
67 | return; | 67 | return; |
68 | }else if(newpassword3.length()<8||newpassword4.length()<8){ | 68 | }else if(newpassword3.length()<8||newpassword4.length()<8){ |
69 | AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位"); | 69 | AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位"); |
70 | }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | 70 | }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ |
71 | AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成"); | 71 | AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成"); |
72 | } | 72 | } |
73 | //得到原密码并且判断是否输入的一样 | 73 | //得到原密码并且判断是否输入的一样 |
74 | else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){ | 74 | else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){ |
75 | 75 | ||
76 | AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误"); | 76 | AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误"); |
77 | 77 | ||
78 | }else if (!newpassword3.equals(newpassword4)){ | 78 | }else if (!newpassword3.equals(newpassword4)){ |
79 | AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致"); | 79 | AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致"); |
80 | return; | 80 | return; |
81 | }else{ | 81 | }else{ |
82 | //修改密码接口 | 82 | //修改密码接口 |
83 | String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username"); | 83 | String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username"); |
84 | HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3); | 84 | HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3); |
85 | } | 85 | } |
86 | 86 | ||
87 | break; | 87 | break; |
88 | case R.id.iv_pwd_change: | 88 | case R.id.iv_pwd_change: |
89 | if(showPassword){//显示密码 | 89 | if(showPassword){//显示密码 |
90 | showPassword = !showPassword; | 90 | showPassword = !showPassword; |
91 | eyes_iv_change1.setImageResource(R.mipmap.pwd_open); | 91 | eyes_iv_change1.setImageResource(R.mipmap.pwd_open); |
92 | newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 92 | newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
93 | newpassword.setSelection(newpassword.getText().toString().length()); | 93 | newpassword.setSelection(newpassword.getText().toString().length()); |
94 | }else{//隐藏密码 | 94 | }else{//隐藏密码 |
95 | showPassword = !showPassword; | 95 | showPassword = !showPassword; |
96 | eyes_iv_change1.setImageResource(R.mipmap.pwd_hide); | 96 | eyes_iv_change1.setImageResource(R.mipmap.pwd_hide); |
97 | newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 97 | newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
98 | newpassword.setSelection(newpassword.getText().toString().length()); | 98 | newpassword.setSelection(newpassword.getText().toString().length()); |
99 | } | 99 | } |
100 | break; | 100 | break; |
101 | 101 | ||
102 | case R.id.cancel: | 102 | case R.id.cancel: |
103 | finish(); | 103 | finish(); |
104 | break; | 104 | break; |
105 | } | 105 | } |
106 | 106 | ||
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 |
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; | ||
7 | import android.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
8 | import android.view.View; | 6 | import android.view.View; |
9 | import android.widget.Button; | 7 | import android.widget.Button; |
10 | import android.widget.EditText; | 8 | import android.widget.EditText; |
11 | import android.widget.TextView; | 9 | import android.widget.TextView; |
12 | 10 | ||
13 | import com.hjx.personalcenter.R; | 11 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 12 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
15 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 13 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
16 | import com.hjx.personalcenter.http.HttpCode; | ||
17 | import com.hjx.personalcenter.http.HttpManager; | 14 | import com.hjx.personalcenter.http.HttpManager; |
18 | 15 | ||
19 | import org.json.JSONException; | ||
20 | import org.json.JSONObject; | ||
21 | |||
22 | /**填写注册信息 熊巍 | 16 | /**填写注册信息 熊巍 |
23 | * Created by h on 2017/8/9. | 17 | * Created by h on 2017/8/9. |
24 | */ | 18 | */ |
25 | 19 | ||
26 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener { | 20 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener { |
27 | private EditText et_username; | 21 | private EditText et_username; |
28 | private TextView et_region,et_grade,et_school; | 22 | private TextView et_region,et_grade,et_school; |
29 | private Button btn_ok; | 23 | private Button btn_ok; |
30 | String[] items; | 24 | 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 | }; | ||
49 | 25 | ||
50 | @Override | 26 | @Override |
51 | protected void onCreate(Bundle savedInstanceState) { | 27 | protected void onCreate(Bundle savedInstanceState) { |
52 | super.onCreate(savedInstanceState); | 28 | super.onCreate(savedInstanceState); |
53 | setContentView(R.layout.activity_registerinfo); | 29 | setContentView(R.layout.activity_registerinfo); |
54 | initView(); | 30 | initView(); |
55 | initData(); | 31 | initData(); |
56 | initLister(); | 32 | initLister(); |
57 | } | 33 | } |
58 | 34 | ||
59 | private void initView() { | 35 | private void initView() { |
60 | et_username = (EditText) findViewById(R.id.et_username); | 36 | et_username = (EditText) findViewById(R.id.et_username); |
61 | et_region = (TextView) findViewById(R.id.et_region); | 37 | et_region = (TextView) findViewById(R.id.et_region); |
62 | et_grade = (TextView) findViewById(R.id.et_grade); | 38 | et_grade = (TextView) findViewById(R.id.et_grade); |
63 | et_school = (TextView) findViewById(R.id.et_school); | 39 | et_school = (TextView) findViewById(R.id.et_school); |
64 | btn_ok = (Button) findViewById(R.id.btn_ok); | 40 | btn_ok = (Button) findViewById(R.id.btn_ok); |
65 | 41 | ||
66 | 42 | ||
67 | } | 43 | } |
68 | 44 | ||
69 | private void initData() { | 45 | private void initData() { |
70 | items = new String[] { "魏", "蜀", "吴" }; | 46 | items = new String[] { "魏", "蜀", "吴" }; |
71 | 47 | ||
72 | } | 48 | } |
73 | 49 | ||
74 | private void initLister() { | 50 | private void initLister() { |
75 | et_region.setOnClickListener(this); | 51 | et_region.setOnClickListener(this); |
76 | et_grade.setOnClickListener(this); | 52 | et_grade.setOnClickListener(this); |
77 | et_school.setOnClickListener(this); | 53 | et_school.setOnClickListener(this); |
78 | btn_ok.setOnClickListener(this); | 54 | btn_ok.setOnClickListener(this); |
79 | 55 | ||
80 | 56 | ||
81 | } | 57 | } |
82 | 58 | ||
83 | @Override | 59 | @Override |
84 | public void onClick(View v) { | 60 | public void onClick(View v) { |
85 | switch (v.getId()){ | 61 | switch (v.getId()){ |
86 | case R.id.et_region: | 62 | case R.id.et_region: |
87 | choiseregion(); | 63 | choiseregion(); |
88 | break; | 64 | break; |
89 | case R.id.et_grade: | 65 | case R.id.et_grade: |
90 | choisegrade(); | 66 | choisegrade(); |
91 | break; | 67 | break; |
92 | case R.id.et_school: | 68 | case R.id.et_school: |
93 | break; | 69 | break; |
94 | case R.id.btn_ok: | 70 | case R.id.btn_ok: |
95 | Intent intent = new Intent(); | 71 | Intent intent = new Intent(); |
96 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 72 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); |
97 | startActivity(intent); | 73 | startActivity(intent); |
98 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 74 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
99 | break; | 75 | break; |
100 | } | 76 | } |
101 | 77 | ||
102 | } | 78 | } |
103 | //选择地区 | 79 | //选择地区 |
104 | private void choiseregion() { | 80 | private void choiseregion() { |
105 | HttpManager.getInstance().provices(RegisterInfoActivity.this,handler); | 81 | HttpManager.getInstance().countyinfo(RegisterInfoActivity.this,210300); |
106 | ProvinceListDialog.getInstance().show(getSupportFragmentManager(), "ProvinceListDialog"); | 82 | ProvinceListDialog.getInstance().show(getSupportFragmentManager(), "ProvinceListDialog"); |
107 | } | 83 | } |
108 | //选择年级 | 84 | //选择年级 |
109 | private void choisegrade() { | 85 | private void choisegrade() { |
110 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); | 86 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); |
111 | 87 | ||
112 | } | 88 | } |
113 | } | 89 | } |
114 | 90 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/areapicker/AreaBean.java
1 | /** | File was deleted | |
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 | 1 | /** |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.view.Gravity; | 6 | import android.view.Gravity; |
7 | import android.view.LayoutInflater; | 7 | import android.view.LayoutInflater; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.view.ViewGroup; | 9 | import android.view.ViewGroup; |
10 | import android.widget.AdapterView; | 10 | import android.widget.AdapterView; |
11 | import android.widget.ArrayAdapter; | 11 | import android.widget.ArrayAdapter; |
12 | import android.widget.ListView; | 12 | import android.widget.ListView; |
13 | import android.widget.Toast; | 13 | import android.widget.Toast; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.mylhyl.circledialog.BaseCircleDialog; | 16 | import com.mylhyl.circledialog.BaseCircleDialog; |
17 | import com.mylhyl.circledialog.res.values.CircleDimen; | 17 | import com.mylhyl.circledialog.res.values.CircleDimen; |
18 | 18 | ||
19 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
20 | 20 | ||
21 | /**自定义年级列表对话框 | 21 | /**自定义年级列表对话框 |
22 | * Created by h on 2017/8/10. | 22 | * Created by h on 2017/8/10. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 25 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
26 | ArrayAdapter listadapter; | 26 | ArrayAdapter listadapter; |
27 | ListView listView; | 27 | ListView listView; |
28 | ArrayList<String> data = new ArrayList<>(); | 28 | ArrayList<String> data = new ArrayList<>(); |
29 | public static ProvinceListDialog getInstance() { | 29 | public static ProvinceListDialog getInstance() { |
30 | ProvinceListDialog dialogFragment = new ProvinceListDialog(); | 30 | ProvinceListDialog dialogFragment = new ProvinceListDialog(); |
31 | dialogFragment.setCanceledBack(true); | 31 | dialogFragment.setCanceledBack(true); |
32 | dialogFragment.setCanceledOnTouchOutside(true); | 32 | dialogFragment.setCanceledOnTouchOutside(true); |
33 | dialogFragment.setRadius(CircleDimen.RADIUS); | 33 | dialogFragment.setRadius(CircleDimen.RADIUS); |
34 | dialogFragment.setWidth(0.5f); | 34 | dialogFragment.setWidth(0.5f); |
35 | dialogFragment.setGravity(Gravity.CENTER); | 35 | dialogFragment.setGravity(Gravity.CENTER); |
36 | dialogFragment.setBackgroundColor(Color.WHITE); | 36 | dialogFragment.setBackgroundColor(Color.WHITE); |
37 | return dialogFragment; | 37 | return dialogFragment; |
38 | } | 38 | } |
39 | @Override | 39 | @Override |
40 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 40 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
41 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 41 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
42 | } | 42 | } |
43 | @Override | 43 | @Override |
44 | public void onActivityCreated(Bundle savedInstanceState) { | 44 | public void onActivityCreated(Bundle savedInstanceState) { |
45 | super.onActivityCreated(savedInstanceState); | 45 | super.onActivityCreated(savedInstanceState); |
46 | listView = (ListView) getView().findViewById(R.id.listadapter); | 46 | listView = (ListView) getView().findViewById(R.id.listadapter); |
47 | for (int i=0;i<=50;i++){ | 47 | |
48 | data.add("aaa"+i); | 48 | for (int i =0 ; i<50;i++){ |
49 | data.add("sss"+1); | ||
50 | |||
49 | } | 51 | } |
50 | 52 | ||
51 | listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); | 53 | listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); |
52 | listView.setAdapter(listadapter); | 54 | listView.setAdapter(listadapter); |
53 | listView.setOnItemClickListener(this); | 55 | listView.setOnItemClickListener(this); |
54 | 56 | ||
55 | } | 57 | } |
56 | 58 | ||
57 | @Override | 59 | @Override |
58 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 60 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
59 | Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); | 61 | Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); |
60 | 62 | ||
61 | dismiss(); | 63 | dismiss(); |
62 | 64 | ||
63 | } | 65 | } |
64 | } | 66 | } |
65 | 67 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
File was created | 1 | package com.hjx.personalcenter.db; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.content.Context; | ||
5 | import android.content.SharedPreferences; | ||
6 | |||
7 | public class SaveParam { | ||
8 | |||
9 | private static SaveParam instance; | ||
10 | public static SaveParam getInstance(){ | ||
11 | if (instance==null){ | ||
12 | instance = new SaveParam(); | ||
13 | } | ||
14 | return instance; | ||
15 | } | ||
16 | |||
17 | |||
18 | public void saveLoginParam(Context context,String spname, String spstr) { | ||
19 | SharedPreferences sp = context.getSharedPreferences("loginparam", | ||
20 | Activity.MODE_PRIVATE); | ||
21 | |||
22 | sp.edit().putString(spname, spstr).commit(); | ||
23 | } | ||
24 | |||
25 | public String getLoginParam(Context context,String spname) { | ||
26 | SharedPreferences sp = context.getSharedPreferences("loginparam", | ||
27 | Activity.MODE_PRIVATE); | ||
28 | String param = sp.getString(spname, null); | ||
29 | return param; | ||
30 | } | ||
31 | public void clearData(Context context) { | ||
32 | SharedPreferences sp = context.getSharedPreferences("loginparam", | ||
33 | Activity.MODE_PRIVATE); | ||
34 | sp.edit().clear().commit(); | ||
35 | } | ||
36 | |||
37 | public void saveCustomizeParam(Context context,String spname, String spstr) { | ||
38 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | ||
39 | Activity.MODE_PRIVATE); | ||
40 | |||
41 | sp.edit().putString(spname, spstr).commit(); | ||
42 | |||
43 | } | ||
44 | |||
45 | public String getCustomizeParam(Context context,String spname) { | ||
46 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | ||
47 | Activity.MODE_PRIVATE); | ||
48 | String param = sp.getString(spname, null); | ||
49 | return param; | ||
50 | } | ||
51 | |||
52 | public void clearCustomizeParam(Context context ){ | ||
53 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | ||
54 | Activity.MODE_PRIVATE); | ||
55 | sp.edit().clear().commit(); | ||
56 | } | ||
57 | } | ||
58 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/RemoteException.java
1 | /** | File was deleted | |
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 | 1 | /** |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/ResponseError.java
1 | /** | File was deleted | |
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 | 1 | /** |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
5 | import android.content.Context; | 5 | import android.content.Context; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.util.Log; | 9 | import android.util.Log; |
10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
11 | 11 | ||
12 | import com.google.gson.Gson; | ||
12 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 13 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
14 | import com.hjx.personalcenter.db.SaveParam; | ||
15 | import com.hjx.personalcenter.model.CityInfo; | ||
16 | import com.hjx.personalcenter.model.CountyInfo; | ||
17 | import com.hjx.personalcenter.model.ProvinceInfo; | ||
13 | import com.hjx.personalcenter.util.DialogPermission; | 18 | import com.hjx.personalcenter.util.DialogPermission; |
14 | import com.hjx.personalcenter.util.SaveParam; | ||
15 | import com.loopj.android.http.AsyncHttpResponseHandler; | 19 | import com.loopj.android.http.AsyncHttpResponseHandler; |
16 | import com.loopj.android.http.JsonHttpResponseHandler; | 20 | import com.loopj.android.http.JsonHttpResponseHandler; |
17 | import com.loopj.android.http.RequestParams; | 21 | import com.loopj.android.http.RequestParams; |
18 | 22 | ||
19 | import org.apache.http.Header; | 23 | import org.apache.http.Header; |
20 | import org.apache.http.entity.ByteArrayEntity; | 24 | import org.apache.http.entity.ByteArrayEntity; |
21 | import org.apache.http.message.BasicHeader; | 25 | import org.apache.http.message.BasicHeader; |
22 | import org.apache.http.protocol.HTTP; | 26 | import org.apache.http.protocol.HTTP; |
23 | import org.json.JSONException; | 27 | import org.json.JSONException; |
24 | import org.json.JSONObject; | 28 | import org.json.JSONObject; |
25 | 29 | ||
26 | import java.io.UnsupportedEncodingException; | 30 | import java.io.UnsupportedEncodingException; |
27 | 31 | ||
28 | public class HttpManager { | 32 | public class HttpManager { |
29 | private static HttpManager instance; | 33 | private static HttpManager instance; |
30 | private ProgressDialog mProgress = null; | 34 | private ProgressDialog mProgress = null; |
31 | public static HttpManager getInstance() { | 35 | public static HttpManager getInstance() { |
32 | if (instance == null) { | 36 | if (instance == null) { |
33 | instance = new HttpManager(); | 37 | instance = new HttpManager(); |
34 | } | 38 | } |
35 | return instance; | 39 | return instance; |
36 | } | 40 | } |
37 | 41 | ||
38 | 42 | ||
39 | //登录接口 | 43 | //登录接口 |
40 | 44 | ||
41 | public void login(final String username, final String password, final Context mContext) { | 45 | public void login(final String username, final String password, final Context mContext) { |
42 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 46 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
43 | false, true, null); | 47 | false, true, null); |
44 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 48 | 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() { | 49 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
46 | @Override | 50 | @Override |
47 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 51 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
48 | 52 | ||
49 | String str = new String(arg2); | 53 | String str = new String(arg2); |
50 | JSONObject jsonObject = null; | 54 | JSONObject jsonObject = null; |
51 | try { | 55 | try { |
52 | jsonObject = new JSONObject(new String(arg2)); | 56 | jsonObject = new JSONObject(new String(arg2)); |
53 | String status = jsonObject.getString("status"); | 57 | String status = jsonObject.getString("status"); |
54 | if (status.equals("100")) { | 58 | if (status.equals("100")) { |
55 | String access_token = jsonObject.getString("access_token"); | 59 | String access_token = jsonObject.getString("access_token"); |
56 | String userId = jsonObject.getString("userId"); | 60 | String userId = jsonObject.getString("userId"); |
57 | // //登录成功,保存登录数据并且获取个人信息 | 61 | // //登录成功,保存登录数据并且获取个人信息 |
58 | saveLoginInfo(mContext,username, password, access_token, "true", userId); | 62 | saveLoginInfo(mContext,username, password, access_token, "true", userId); |
59 | //HttpManager.getInstance().getuserinfo(username,mContext); | 63 | //HttpManager.getInstance().getuserinfo(username,mContext); |
60 | 64 | ||
61 | }else if (status.equals("200")) { | 65 | }else if (status.equals("200")) { |
62 | closeProgress(); | 66 | closeProgress(); |
63 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); | 67 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); |
64 | return; | 68 | return; |
65 | } else if(status.equals("204")){ | 69 | } else if(status.equals("204")){ |
66 | closeProgress(); | 70 | closeProgress(); |
67 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); | 71 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); |
68 | }else{ | 72 | }else{ |
69 | closeProgress(); | 73 | closeProgress(); |
70 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 74 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
71 | 75 | ||
72 | 76 | ||
73 | 77 | ||
74 | } | 78 | } |
75 | } catch (JSONException e) { | 79 | } catch (JSONException e) { |
76 | e.printStackTrace(); | 80 | e.printStackTrace(); |
77 | } | 81 | } |
78 | 82 | ||
79 | 83 | ||
80 | } | 84 | } |
81 | 85 | ||
82 | @Override | 86 | @Override |
83 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 87 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
84 | closeProgress(); | 88 | closeProgress(); |
85 | Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); | 89 | Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); |
86 | } | 90 | } |
87 | }); | 91 | }); |
88 | } | 92 | } |
89 | 93 | ||
90 | //注册接口 | 94 | //注册接口 |
91 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 95 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
92 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 96 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
93 | false, true, null); | 97 | false, true, null); |
94 | JSONObject jsonObject = new JSONObject(); | 98 | JSONObject jsonObject = new JSONObject(); |
95 | ByteArrayEntity entity = null; | 99 | ByteArrayEntity entity = null; |
96 | try { | 100 | try { |
97 | jsonObject.put(HttpKey.USERNAME, username); | 101 | jsonObject.put(HttpKey.USERNAME, username); |
98 | jsonObject.put(HttpKey.PASSWORD, password); | 102 | jsonObject.put(HttpKey.PASSWORD, password); |
99 | jsonObject.put(HttpKey.SMSCODE, smscode); | 103 | jsonObject.put(HttpKey.SMSCODE, smscode); |
100 | jsonObject.put(HttpKey.SOURCE, source); | 104 | jsonObject.put(HttpKey.SOURCE, source); |
101 | Log.e("test", "jsonObject" + jsonObject); | 105 | Log.e("test", "jsonObject" + jsonObject); |
102 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 106 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
103 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 107 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
104 | } catch (JSONException e) { | 108 | } catch (JSONException e) { |
105 | e.printStackTrace(); | 109 | e.printStackTrace(); |
106 | } catch (UnsupportedEncodingException e) { | 110 | } catch (UnsupportedEncodingException e) { |
107 | e.printStackTrace(); | 111 | e.printStackTrace(); |
108 | } | 112 | } |
109 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 113 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
110 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 114 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
111 | @Override | 115 | @Override |
112 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 116 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
113 | super.onSuccess(statusCode, headers, response); | 117 | super.onSuccess(statusCode, headers, response); |
114 | closeProgress(); | 118 | closeProgress(); |
115 | Log.e("test", "onSuccess" + response); | 119 | Log.e("test", "onSuccess" + response); |
116 | Message msg = Message.obtain(); | 120 | Message msg = Message.obtain(); |
117 | msg.what = HttpCode.REGISTERED_SUCESS; | 121 | msg.what = HttpCode.REGISTERED_SUCESS; |
118 | msg.obj = response; | 122 | msg.obj = response; |
119 | handler.sendMessage(msg); | 123 | handler.sendMessage(msg); |
120 | 124 | ||
121 | } | 125 | } |
122 | 126 | ||
123 | @Override | 127 | @Override |
124 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 128 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
125 | super.onFailure(statusCode, headers, throwable, errorResponse); | 129 | super.onFailure(statusCode, headers, throwable, errorResponse); |
126 | closeProgress(); | 130 | closeProgress(); |
127 | Log.e("test", "onFailure" + errorResponse); | 131 | Log.e("test", "onFailure" + errorResponse); |
128 | Toast.makeText(context, "请检查网络。。", Toast.LENGTH_LONG).show(); | 132 | Toast.makeText(context, "请检查网络。。", Toast.LENGTH_LONG).show(); |
129 | } | 133 | } |
130 | 134 | ||
131 | }); | 135 | }); |
132 | } | 136 | } |
133 | 137 | ||
134 | //注册验证码 | 138 | //注册验证码 |
135 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 139 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
136 | RequestParams params = new RequestParams(); | 140 | RequestParams params = new RequestParams(); |
137 | params.put(HttpKey.TYPE, type); | 141 | params.put(HttpKey.TYPE, type); |
138 | params.put(HttpKey.MOBIL, mobile); | 142 | params.put(HttpKey.MOBIL, mobile); |
139 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 143 | 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() { | 144 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
141 | 145 | ||
142 | @Override | 146 | @Override |
143 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 147 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
144 | Log.e("test", "onSuccess-----" + response); | 148 | Log.e("test", "onSuccess-----" + response); |
145 | Message msg = Message.obtain(); | 149 | Message msg = Message.obtain(); |
146 | msg.what = HttpCode.AUTHCODE_SUCESS; | 150 | msg.what = HttpCode.AUTHCODE_SUCESS; |
147 | msg.obj = response; | 151 | msg.obj = response; |
148 | handler.sendMessage(msg); | 152 | handler.sendMessage(msg); |
149 | } | 153 | } |
150 | 154 | ||
151 | @Override | 155 | @Override |
152 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 156 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
153 | Toast.makeText(mContext, "请检查网络。。" + errorResponse, Toast.LENGTH_LONG).show(); | 157 | Toast.makeText(mContext, "请检查网络。。" + errorResponse, Toast.LENGTH_LONG).show(); |
154 | } | 158 | } |
155 | }); | 159 | }); |
156 | } | 160 | } |
157 | 161 | ||
158 | //验证码 | 162 | //验证码 |
159 | public void forgetauthCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 163 | public void forgetauthCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
160 | RequestParams params = new RequestParams(); | 164 | RequestParams params = new RequestParams(); |
161 | params.put("type", type); | 165 | params.put("type", type); |
162 | params.put("mobile", mobile); | 166 | params.put("mobile", mobile); |
163 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 167 | 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() { | 168 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
165 | 169 | ||
166 | @Override | 170 | @Override |
167 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 171 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
168 | Log.e("test", "onSuccess-----" + response); | 172 | Log.e("test", "onSuccess-----" + response); |
169 | Message msg = Message.obtain(); | 173 | Message msg = Message.obtain(); |
170 | msg.what = HttpCode.AUTHCODE_SUCESS1; | 174 | msg.what = HttpCode.AUTHCODE_SUCESS1; |
171 | msg.obj = response; | 175 | msg.obj = response; |
172 | handler.sendMessage(msg); | 176 | handler.sendMessage(msg); |
173 | } | 177 | } |
174 | 178 | ||
175 | @Override | 179 | @Override |
176 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 180 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
177 | Toast.makeText(mContext, "请检查网络。。" + errorResponse, Toast.LENGTH_LONG).show(); | 181 | Toast.makeText(mContext, "请检查网络。。" + errorResponse, Toast.LENGTH_LONG).show(); |
178 | } | 182 | } |
179 | }); | 183 | }); |
180 | } | 184 | } |
181 | 185 | ||
182 | //手机号是否注册 | 186 | //手机号是否注册 |
183 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 187 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
184 | RequestParams params = new RequestParams(); | 188 | RequestParams params = new RequestParams(); |
185 | params.put(HttpKey.USERNAME, mobile); | 189 | params.put(HttpKey.USERNAME, mobile); |
186 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 190 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
187 | @Override | 191 | @Override |
188 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 192 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
189 | Log.e("test", "isregistered" + response.toString()); | 193 | Log.e("test", "isregistered" + response.toString()); |
190 | Message msg = Message.obtain(); | 194 | Message msg = Message.obtain(); |
191 | msg.what = HttpCode.IS_REFISTER; | 195 | msg.what = HttpCode.IS_REFISTER; |
192 | msg.obj = response; | 196 | msg.obj = response; |
193 | handler.sendMessage(msg); | 197 | handler.sendMessage(msg); |
194 | 198 | ||
195 | } | 199 | } |
196 | 200 | ||
197 | @Override | 201 | @Override |
198 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 202 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
199 | Toast.makeText(mContext, "失敗" + errorResponse, Toast.LENGTH_LONG).show(); | 203 | Toast.makeText(mContext, "失敗" + errorResponse, Toast.LENGTH_LONG).show(); |
200 | 204 | ||
201 | } | 205 | } |
202 | }); | 206 | }); |
203 | } | 207 | } |
204 | 208 | ||
205 | //修改密码 | 209 | //修改密码 |
206 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 210 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
207 | RequestParams params = new RequestParams(); | 211 | RequestParams params = new RequestParams(); |
208 | params.put(HttpKey.USERNAME, username); | 212 | params.put(HttpKey.USERNAME, username); |
209 | params.put(HttpKey.OLDPASS, old_pwd1); | 213 | params.put(HttpKey.OLDPASS, old_pwd1); |
210 | params.put(HttpKey.NEWPASS, newpassword3); | 214 | params.put(HttpKey.NEWPASS, newpassword3); |
211 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 215 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
212 | HttpClient.getInstance().setTimeout(10 * 1000); | 216 | HttpClient.getInstance().setTimeout(10 * 1000); |
213 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 217 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
214 | @Override | 218 | @Override |
215 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 219 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
216 | try { | 220 | try { |
217 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 221 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
218 | String status = jsonObject.optString("status"); | 222 | String status = jsonObject.optString("status"); |
219 | if (status.equals("100")) { | 223 | if (status.equals("100")) { |
220 | Log.e("test", "onSuccess" + new String(bytes)); | 224 | Log.e("test", "onSuccess" + new String(bytes)); |
221 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 225 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
222 | SaveParam.getInstance().clearData((Activity) context); | 226 | SaveParam.getInstance().clearData((Activity) context); |
223 | Intent intent = new Intent(); | 227 | Intent intent = new Intent(); |
224 | intent.setClass(context, LoginAndRegisterActivity.class); | 228 | intent.setClass(context, LoginAndRegisterActivity.class); |
225 | ((Activity) context).startActivity(intent); | 229 | ((Activity) context).startActivity(intent); |
226 | ((Activity) context).finish(); | 230 | ((Activity) context).finish(); |
227 | } | 231 | } |
228 | } catch (JSONException e) { | 232 | } catch (JSONException e) { |
229 | e.printStackTrace(); | 233 | e.printStackTrace(); |
230 | } | 234 | } |
231 | } | 235 | } |
232 | 236 | ||
233 | @Override | 237 | @Override |
234 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 238 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
235 | Log.e("test", "onFailure" + new String(bytes)); | 239 | Log.e("test", "onFailure" + new String(bytes)); |
236 | Toast.makeText(context, "密码修改失败,请检查网络!", Toast.LENGTH_LONG).show(); | 240 | Toast.makeText(context, "密码修改失败,请检查网络!", Toast.LENGTH_LONG).show(); |
237 | onFinish(); | 241 | onFinish(); |
238 | } | 242 | } |
239 | }); | 243 | }); |
240 | 244 | ||
241 | } | 245 | } |
242 | 246 | ||
243 | //忘记密码 | 247 | //忘记密码 |
244 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 248 | 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(); | 249 | RequestParams params = new RequestParams(); |
246 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 250 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
247 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 251 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
248 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 252 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
249 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 253 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
250 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 254 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
251 | @Override | 255 | @Override |
252 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 256 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
253 | try { | 257 | try { |
254 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 258 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
255 | String status = jsonObject.optString("status"); | 259 | String status = jsonObject.optString("status"); |
256 | if (status.equals("100")) { | 260 | if (status.equals("100")) { |
257 | Log.e("test", "onSuccess" + new String(bytes)); | 261 | Log.e("test", "onSuccess" + new String(bytes)); |
258 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 262 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
259 | ((Activity) context).finish(); | 263 | ((Activity) context).finish(); |
260 | } | 264 | } |
261 | } catch (JSONException e) { | 265 | } catch (JSONException e) { |
262 | e.printStackTrace(); | 266 | e.printStackTrace(); |
263 | } | 267 | } |
264 | } | 268 | } |
265 | 269 | ||
266 | @Override | 270 | @Override |
267 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 271 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
268 | Log.e("test", "onFailure" + new String(bytes)); | 272 | Log.e("test", "onFailure" + new String(bytes)); |
269 | Toast.makeText(context, "忘记密码修改失败,请检查网络!", Toast.LENGTH_LONG).show(); | 273 | Toast.makeText(context, "忘记密码修改失败,请检查网络!", Toast.LENGTH_LONG).show(); |
270 | } | 274 | } |
271 | }); | 275 | }); |
272 | 276 | ||
273 | } | 277 | } |
274 | 278 | ||
275 | //保存用户登录信息 | 279 | //保存用户登录信息 |
276 | public void saveLoginInfo(Context context,String username, String password, String access_token, String loginStatus, String userId) { | 280 | public void saveLoginInfo(Context context,String username, String password, String access_token, String loginStatus, String userId) { |
277 | SaveParam.getInstance().saveLoginParam(context,"username", username); | 281 | SaveParam.getInstance().saveLoginParam(context,"username", username); |
278 | SaveParam.getInstance().saveLoginParam(context,"password", password); | 282 | SaveParam.getInstance().saveLoginParam(context,"password", password); |
279 | SaveParam.getInstance().saveLoginParam(context,"access_token", access_token); | 283 | SaveParam.getInstance().saveLoginParam(context,"access_token", access_token); |
280 | SaveParam.getInstance().saveLoginParam(context,"login", loginStatus); | 284 | SaveParam.getInstance().saveLoginParam(context,"login", loginStatus); |
281 | SaveParam.getInstance().saveLoginParam(context,"userId", userId); | 285 | SaveParam.getInstance().saveLoginParam(context,"userId", userId); |
282 | 286 | ||
283 | 287 | ||
284 | } | 288 | } |
285 | 289 | ||
286 | //保存用户个人信息 | 290 | //保存用户个人信息 |
287 | public void savePresonInfo(Context context,String lastname, String gender, String mobilePortrait) { | 291 | public void savePresonInfo(Context context,String lastname, String gender, String mobilePortrait) { |
288 | SaveParam.getInstance().saveLoginParam(context,"lastname", lastname); | 292 | SaveParam.getInstance().saveLoginParam(context,"lastname", lastname); |
289 | SaveParam.getInstance().saveLoginParam(context,"gender", gender); | 293 | SaveParam.getInstance().saveLoginParam(context,"gender", gender); |
290 | SaveParam.getInstance().saveLoginParam(context,"mobilePortrait", mobilePortrait); | 294 | SaveParam.getInstance().saveLoginParam(context,"mobilePortrait", mobilePortrait); |
291 | } | 295 | } |
296 | ///省级接口 | ||
297 | public void provices(final Context mContext) { | ||
298 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||
299 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | ||
300 | @Override | ||
301 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
302 | Log.e("test", "省" + new String(arg2)); | ||
303 | Gson gson = new Gson(); | ||
304 | ProvinceInfo provinceInfo = gson.fromJson(new String(arg2),ProvinceInfo.class); | ||
305 | for (int i =0 ; i<provinceInfo.getProvinces().size();i++){ | ||
306 | Log.e("test", "省" +provinceInfo.getProvinces().get(i) | ||
307 | .getParentId()); | ||
308 | Log.e("test", "省" +provinceInfo.getProvinces().get(i) | ||
309 | .getRegionId()); | ||
310 | Log.e("test", "省" +provinceInfo.getProvinces().get(i).getRegionName()+""); | ||
311 | |||
312 | } | ||
292 | 313 | ||
293 | public void provices(final Context mContext, final Handler handler) { | 314 | |
315 | } | ||
316 | |||
317 | @Override | ||
318 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
319 | Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); | ||
320 | } | ||
321 | }); | ||
322 | } | ||
323 | //市级接口 | ||
324 | public void cityinfo(final Context mContext,int regionId) { | ||
294 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 325 | 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() { | 326 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
296 | @Override | 327 | @Override |
297 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 328 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
298 | Log.e("test", "isregistered" + arg2.toString()); | 329 | Log.e("test", "市" + new String(arg2)); |
299 | Message msg = Message.obtain(); | 330 | Gson gson = new Gson(); |
300 | msg.what = HttpCode.PROVICES; | 331 | CityInfo cityInfo = gson.fromJson(new String(arg2),CityInfo.class); |
301 | msg.obj = arg2; | 332 | for (int i =0 ; i<cityInfo.getCities().size();i++){ |
302 | handler.sendMessage(msg); | 333 | Log.e("test", "市" +cityInfo.getCities().get(i) |
334 | .getParentId()); | ||
335 | Log.e("test", "市" +cityInfo.getCities().get(i) | ||
336 | .getRegionId()); | ||
337 | Log.e("test", "市" +cityInfo.getCities().get(i).getRegionName()+""); | ||
338 | |||
339 | } | ||
340 | |||
341 | |||
303 | } | 342 | } |
304 | 343 | ||
305 | @Override | 344 | @Override |
306 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 345 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
307 | Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); | 346 | Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); |
308 | } | 347 | } |
309 | }); | 348 | }); |
310 | } | 349 | } |
350 | //区县级接口 | ||
351 | public void countyinfo(final Context mContext,int parentId) { | ||
352 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||
353 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | ||
354 | @Override | ||
355 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
356 | Log.e("test", "区" + new String(arg2)); | ||
357 | Gson gson = new Gson(); | ||
358 | CountyInfo countyInfo = gson.fromJson(new String(arg2),CountyInfo.class); | ||
359 | for (int i =0 ; i<countyInfo.getCounties().size();i++){ | ||
360 | Log.e("test", "区" +countyInfo.getCounties().get(i) | ||
361 | .getParentId()); | ||
362 | Log.e("test", "区" +countyInfo.getCounties().get(i) | ||
363 | .getRegionId()); | ||
364 | Log.e("test", "区" +countyInfo.getCounties().get(i).getRegionName()+""); | ||
365 | |||
366 | } | ||
367 | |||
311 | 368 | ||
369 | } | ||
370 | |||
371 | @Override | ||
372 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
373 | Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show(); | ||
374 | } | ||
375 | }); | ||
376 | } | ||
312 | 377 | ||
313 | 378 | ||
314 | private void closeProgress() { | 379 | private void closeProgress() { |
315 | try { | 380 | try { |
316 | if (mProgress != null) { | 381 | if (mProgress != null) { |
317 | mProgress.dismiss(); | 382 | mProgress.dismiss(); |
318 | mProgress = null; | 383 | mProgress = null; |
319 | } | 384 | } |
320 | } catch (Exception e) { | 385 | } catch (Exception e) { |
321 | e.printStackTrace(); | 386 | e.printStackTrace(); |
322 | } | 387 | } |
323 | } | 388 | } |
324 | 389 | ||
325 | } | 390 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by h on 2017/8/15. | 4 | * Created by h on 2017/8/15. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpUrl { | 7 | public class HttpUrl { |
8 | private final static String Enviroment = "DEVELOPMENT"; | 8 | private final static String Enviroment = "DEVELOPMENT"; |
9 | 9 | ||
10 | public static String GetDomain(){ | 10 | public static String GetDomain(){ |
11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; | 11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; |
12 | } | 12 | } |
13 | 13 | ||
14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 | 14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 |
15 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | 15 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 |
16 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 | ||
17 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 | ||
16 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | 18 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ |
17 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | 19 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 |
18 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | 20 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 |
19 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | 21 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 |
20 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | 22 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 |
21 | 23 | ||
22 | } | 24 | } |
23 | 25 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/CityInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/8/16. | ||
7 | */ | ||
8 | |||
9 | public class CityInfo { | ||
10 | |||
11 | /** | ||
12 | * status : 100 | ||
13 | * message : success | ||
14 | * cities : [{"regionId":210100,"parentId":210000,"regionName":"沈阳"},{"regionId":210200,"parentId":210000,"regionName":"大连"},{"regionId":210300,"parentId":210000,"regionName":"鞍山"},{"regionId":210400,"parentId":210000,"regionName":"抚顺"},{"regionId":210500,"parentId":210000,"regionName":"本溪"},{"regionId":210600,"parentId":210000,"regionName":"丹东"},{"regionId":210700,"parentId":210000,"regionName":"锦州"},{"regionId":210800,"parentId":210000,"regionName":"营口"},{"regionId":210900,"parentId":210000,"regionName":"阜新"},{"regionId":211000,"parentId":210000,"regionName":"辽阳"},{"regionId":211100,"parentId":210000,"regionName":"盘锦"},{"regionId":211200,"parentId":210000,"regionName":"铁岭"},{"regionId":211300,"parentId":210000,"regionName":"朝阳"},{"regionId":211400,"parentId":210000,"regionName":"葫芦岛"}] | ||
15 | */ | ||
16 | |||
17 | private int status; | ||
18 | private String message; | ||
19 | private List<CitiesBean> cities; | ||
20 | |||
21 | public int getStatus() { | ||
22 | return status; | ||
23 | } | ||
24 | |||
25 | public void setStatus(int status) { | ||
26 | this.status = status; | ||
27 | } | ||
28 | |||
29 | public String getMessage() { | ||
30 | return message; | ||
31 | } | ||
32 | |||
33 | public void setMessage(String message) { | ||
34 | this.message = message; | ||
35 | } | ||
36 | |||
37 | public List<CitiesBean> getCities() { | ||
38 | return cities; | ||
39 | } | ||
40 | |||
41 | public void setCities(List<CitiesBean> cities) { | ||
42 | this.cities = cities; | ||
43 | } | ||
44 | |||
45 | public static class CitiesBean { | ||
46 | /** | ||
47 | * regionId : 210100 | ||
48 | * parentId : 210000 | ||
49 | * regionName : 沈阳 | ||
50 | */ | ||
51 | |||
52 | private int regionId; | ||
53 | private int parentId; | ||
54 | private String regionName; | ||
55 | |||
56 | public int getRegionId() { | ||
57 | return regionId; | ||
58 | } | ||
59 | |||
60 | public void setRegionId(int regionId) { | ||
61 | this.regionId = regionId; | ||
62 | } | ||
63 | |||
64 | public int getParentId() { | ||
65 | return parentId; | ||
66 | } | ||
67 | |||
68 | public void setParentId(int parentId) { | ||
69 | this.parentId = parentId; | ||
70 | } | ||
71 | |||
72 | public String getRegionName() { | ||
73 | return regionName; | ||
74 | } | ||
75 | |||
76 | public void setRegionName(String regionName) { | ||
77 | this.regionName = regionName; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/CountyInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/8/16. | ||
7 | */ | ||
8 | |||
9 | public class CountyInfo { | ||
10 | |||
11 | /** | ||
12 | * status : 100 | ||
13 | * message : success | ||
14 | * counties : [{"regionId":210302,"parentId":210300,"regionName":"铁东"},{"regionId":210303,"parentId":210300,"regionName":"铁西"},{"regionId":210304,"parentId":210300,"regionName":"立山"},{"regionId":210311,"parentId":210300,"regionName":"千山"},{"regionId":210321,"parentId":210300,"regionName":"台安"},{"regionId":210323,"parentId":210300,"regionName":"岫岩"},{"regionId":210381,"parentId":210300,"regionName":"海城"}] | ||
15 | */ | ||
16 | |||
17 | private int status; | ||
18 | private String message; | ||
19 | private List<CountiesBean> counties; | ||
20 | |||
21 | public int getStatus() { | ||
22 | return status; | ||
23 | } | ||
24 | |||
25 | public void setStatus(int status) { | ||
26 | this.status = status; | ||
27 | } | ||
28 | |||
29 | public String getMessage() { | ||
30 | return message; | ||
31 | } | ||
32 | |||
33 | public void setMessage(String message) { | ||
34 | this.message = message; | ||
35 | } | ||
36 | |||
37 | public List<CountiesBean> getCounties() { | ||
38 | return counties; | ||
39 | } | ||
40 | |||
41 | public void setCounties(List<CountiesBean> counties) { | ||
42 | this.counties = counties; | ||
43 | } | ||
44 | |||
45 | public static class CountiesBean { | ||
46 | /** | ||
47 | * regionId : 210302 | ||
48 | * parentId : 210300 | ||
49 | * regionName : 铁东 | ||
50 | */ | ||
51 | |||
52 | private int regionId; | ||
53 | private int parentId; | ||
54 | private String regionName; | ||
55 | |||
56 | public int getRegionId() { | ||
57 | return regionId; | ||
58 | } | ||
59 | |||
60 | public void setRegionId(int regionId) { | ||
61 | this.regionId = regionId; | ||
62 | } | ||
63 | |||
64 | public int getParentId() { | ||
65 | return parentId; | ||
66 | } | ||
67 | |||
68 | public void setParentId(int parentId) { | ||
69 | this.parentId = parentId; | ||
70 | } | ||
71 | |||
72 | public String getRegionName() { | ||
73 | return regionName; | ||
74 | } | ||
75 | |||
76 | public void setRegionName(String regionName) { | ||
77 | this.regionName = regionName; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/ProvinceInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/8/16. | ||
7 | */ | ||
8 | |||
9 | public class ProvinceInfo { | ||
10 | |||
11 | /** | ||
12 | * status : 100 | ||
13 | * message : success | ||
14 | * provinces : [{"parentId":0,"regionId":110000,"regionName":"北京"},{"parentId":0,"regionId":120000,"regionName":"天津"},{"parentId":0,"regionId":130000,"regionName":"河北"},{"parentId":0,"regionId":140000,"regionName":"山西"},{"parentId":0,"regionId":150000,"regionName":"内蒙古"},{"parentId":0,"regionId":210000,"regionName":"辽宁"},{"parentId":0,"regionId":220000,"regionName":"吉林"},{"parentId":0,"regionId":230000,"regionName":"黑龙江"},{"parentId":0,"regionId":310000,"regionName":"上海"},{"parentId":0,"regionId":320000,"regionName":"江苏"},{"parentId":0,"regionId":330000,"regionName":"浙江"},{"parentId":0,"regionId":340000,"regionName":"安徽"},{"parentId":0,"regionId":350000,"regionName":"福建"},{"parentId":0,"regionId":360000,"regionName":"江西"},{"parentId":0,"regionId":370000,"regionName":"山东"},{"parentId":0,"regionId":410000,"regionName":"河南"},{"parentId":0,"regionId":420000,"regionName":"湖北"},{"parentId":0,"regionId":430000,"regionName":"湖南"},{"parentId":0,"regionId":440000,"regionName":"广东"},{"parentId":0,"regionId":450000,"regionName":"广西"},{"parentId":0,"regionId":460000,"regionName":"海南"},{"parentId":0,"regionId":500000,"regionName":"重庆"},{"parentId":0,"regionId":510000,"regionName":"四川"},{"parentId":0,"regionId":520000,"regionName":"贵州"},{"parentId":0,"regionId":530000,"regionName":"云南"},{"parentId":0,"regionId":540000,"regionName":"西藏"},{"parentId":0,"regionId":610000,"regionName":"陕西"},{"parentId":0,"regionId":620000,"regionName":"甘肃"},{"parentId":0,"regionId":630000,"regionName":"青海"},{"parentId":0,"regionId":640000,"regionName":"宁夏"},{"parentId":0,"regionId":650000,"regionName":"新疆"},{"parentId":0,"regionId":710000,"regionName":"台湾"},{"parentId":0,"regionId":810000,"regionName":"香港"},{"parentId":0,"regionId":820000,"regionName":"澳门"}] | ||
15 | */ | ||
16 | |||
17 | private int status; | ||
18 | private String message; | ||
19 | private List<ProvincesBean> provinces; | ||
20 | |||
21 | public int getStatus() { | ||
22 | return status; | ||
23 | } | ||
24 | |||
25 | public void setStatus(int status) { | ||
26 | this.status = status; | ||
27 | } | ||
28 | |||
29 | public String getMessage() { | ||
30 | return message; | ||
31 | } | ||
32 | |||
33 | public void setMessage(String message) { | ||
34 | this.message = message; | ||
35 | } | ||
36 | |||
37 | public List<ProvincesBean> getProvinces() { | ||
38 | return provinces; | ||
39 | } | ||
40 | |||
41 | public void setProvinces(List<ProvincesBean> provinces) { | ||
42 | this.provinces = provinces; | ||
43 | } | ||
44 | |||
45 | public static class ProvincesBean { | ||
46 | /** | ||
47 | * parentId : 0 | ||
48 | * regionId : 110000 | ||
49 | * regionName : 北京 | ||
50 | */ | ||
51 | |||
52 | private int parentId; | ||
53 | private int regionId; | ||
54 | private String regionName; | ||
55 | |||
56 | public int getParentId() { | ||
57 | return parentId; | ||
58 | } | ||
59 | |||
60 | public void setParentId(int parentId) { | ||
61 | this.parentId = parentId; | ||
62 | } | ||
63 | |||
64 | public int getRegionId() { | ||
65 | return regionId; | ||
66 | } | ||
67 | |||
68 | public void setRegionId(int regionId) { | ||
69 | this.regionId = regionId; | ||
70 | } | ||
71 | |||
72 | public String getRegionName() { | ||
73 | return regionName; | ||
74 | } | ||
75 | |||
76 | public void setRegionName(String regionName) { | ||
77 | this.regionName = regionName; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/BaseParser.java
1 | /** | File was deleted | |
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 | 1 | /** |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/ProvinceParser.java
1 | /** | File was deleted | |
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 | 1 | /** |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/SaveParam.java
1 | package com.hjx.personalcenter.util; | File was deleted | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.content.Context; | ||
5 | import android.content.SharedPreferences; | ||
6 | |||
7 | public class SaveParam { | ||
8 | |||
9 | private static SaveParam instance; | ||
10 | public static SaveParam getInstance(){ | ||
11 | if (instance==null){ | ||
12 | instance = new SaveParam(); | ||
13 | } | ||
14 | return instance; | ||
15 | } | ||
16 | |||
17 | |||
18 | public void saveLoginParam(Context context,String spname, String spstr) { | ||
19 | SharedPreferences sp = context.getSharedPreferences("loginparam", | ||
20 | Activity.MODE_PRIVATE); | ||
21 | |||
22 | sp.edit().putString(spname, spstr).commit(); | ||
23 | } | ||
24 | |||
25 | public String getLoginParam(Context context,String spname) { | ||
26 | SharedPreferences sp = context.getSharedPreferences("loginparam", | ||
27 | Activity.MODE_PRIVATE); | ||
28 | String param = sp.getString(spname, null); | ||
29 | return param; | ||
30 | } | ||
31 | public void clearData(Context context) { | ||
32 | SharedPreferences sp = context.getSharedPreferences("loginparam", | ||
33 | Activity.MODE_PRIVATE); | ||
34 | sp.edit().clear().commit(); | ||
35 | } | ||
36 | |||
37 | public void saveCustomizeParam(Context context,String spname, String spstr) { | ||
38 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | ||
39 | Activity.MODE_PRIVATE); | ||
40 | |||
41 | sp.edit().putString(spname, spstr).commit(); | ||
42 | |||
43 | } | ||
44 | |||
45 | public String getCustomizeParam(Context context,String spname) { | ||
46 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | ||
47 | Activity.MODE_PRIVATE); | ||
48 | String param = sp.getString(spname, null); | ||
49 | return param; | ||
50 | } | ||
51 | |||
52 | public void clearCustomizeParam(Context context ){ | ||
53 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | ||
54 | Activity.MODE_PRIVATE); | ||
55 | sp.edit().clear().commit(); | ||
56 | } | ||
57 | } | ||
58 | 1 | package com.hjx.personalcenter.util; |