Commit 7b881e316bc5047d0cc4cc49d6d7e6586f963cbd

Authored by xiongwei
1 parent 11eee1b3af
Exists in master

省,市 ,区接口调试

PersonalCenter/.idea/misc.xml
... ... @@ -77,7 +77,7 @@
77 77 <ConfirmationsSetting value="0" id="Add" />
78 78 <ConfirmationsSetting value="0" id="Remove" />
79 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 81 <output url="file://$PROJECT_DIR$/build/classes" />
82 82 </component>
83 83 <component name="ProjectType">
... ...
PersonalCenter/app/build.gradle
... ... @@ -38,4 +38,5 @@ dependencies {
38 38 compile project(':circledialog')
39 39 compile project(':pickerview')
40 40 compile files('libs/android-async-http-1.4.8.jar')
  41 + compile 'com.google.code.gson:gson:2.7'
41 42 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePasswordActivity.java
... ... @@ -14,7 +14,7 @@ import com.hjx.personalcenter.R;
14 14 import com.hjx.personalcenter.http.HttpManager;
15 15 import com.hjx.personalcenter.util.AlertUtils;
16 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 20 * Created by h on 2017/6/27.
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
... ... @@ -2,8 +2,6 @@ package com.hjx.personalcenter.activity;
2 2  
3 3 import android.content.Intent;
4 4 import android.os.Bundle;
5   -import android.os.Handler;
6   -import android.os.Message;
7 5 import android.support.v7.app.AppCompatActivity;
8 6 import android.view.View;
9 7 import android.widget.Button;
... ... @@ -13,12 +11,8 @@ import android.widget.TextView;
13 11 import com.hjx.personalcenter.R;
14 12 import com.hjx.personalcenter.customdialog.GradeListDialog;
15 13 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
16   -import com.hjx.personalcenter.http.HttpCode;
17 14 import com.hjx.personalcenter.http.HttpManager;
18 15  
19   -import org.json.JSONException;
20   -import org.json.JSONObject;
21   -
22 16 /**填写注册信息 熊巍
23 17 * Created by h on 2017/8/9.
24 18 */
... ... @@ -28,24 +22,6 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
28 22 private TextView et_region,et_grade,et_school;
29 23 private Button btn_ok;
30 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 26 @Override
51 27 protected void onCreate(Bundle savedInstanceState) {
... ... @@ -102,7 +78,7 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
102 78 }
103 79 //选择地区
104 80 private void choiseregion() {
105   - HttpManager.getInstance().provices(RegisterInfoActivity.this,handler);
  81 + HttpManager.getInstance().countyinfo(RegisterInfoActivity.this,210300);
106 82 ProvinceListDialog.getInstance().show(getSupportFragmentManager(), "ProvinceListDialog");
107 83 }
108 84 //选择年级
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/areapicker/AreaBean.java
... ... @@ -1,68 +0,0 @@
1   -/**
2   - * HaoJiXing Teacher Q&A
3   - * copyright(C)2013- Acorn International
4   - *
5   - * packeage:com.ozing.callteacher.widget.areapicker.Province.java
6   - * create:2013年8月8日上午11:20:30
7   - */
8   -package com.hjx.personalcenter.areapicker;
9   -
10   -/**
11   - * @author jixiaolong<jixiaolong@chinadrtv.com>
12   - * @code: 015261
13   - */
14   -public class AreaBean {
15   - public static final int PROVINCE = 0x11;
16   - public static final int CITY = 0x12;
17   - public static final int COUNTY = 0x13;
18   - protected int level;
19   - protected String id;
20   - protected String name;
21   - protected String fullName;
22   - protected String parentId;
23   -
24   - public int getLevel() {
25   - return level;
26   - }
27   -
28   - public void setLevel(int level) {
29   - this.level = level;
30   - }
31   -
32   - public String getId() {
33   - return id;
34   - }
35   -
36   - public void setId(String id) {
37   - this.id = id;
38   - }
39   -
40   - public String getName() {
41   - return name;
42   - }
43   -
44   - public void setName(String name) {
45   - this.name = name;
46   - }
47   -
48   - public String getFullName() {
49   - return fullName;
50   - }
51   -
52   - public void setFullName(String fullName) {
53   - this.fullName = fullName;
54   - }
55   -
56   - public String getParentId() {
57   - return parentId;
58   - }
59   -
60   - public void setParentId(String parentId) {
61   - this.parentId = parentId;
62   - }
63   -
64   - @Override
65   - public String toString() {
66   - return fullName;
67   - }
68   -}
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
... ... @@ -44,8 +44,10 @@ public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.
44 44 public void onActivityCreated(Bundle savedInstanceState) {
45 45 super.onActivityCreated(savedInstanceState);
46 46 listView = (ListView) getView().findViewById(R.id.listadapter);
47   - for (int i=0;i<=50;i++){
48   - data.add("aaa"+i);
  47 +
  48 + for (int i =0 ; i<50;i++){
  49 + data.add("sss"+1);
  50 +
49 51 }
50 52  
51 53 listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data);
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
... ... @@ -0,0 +1,57 @@
  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 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/RemoteException.java
... ... @@ -1,34 +0,0 @@
1   -/**
2   - * HaoJiXing Teacher Q&A
3   - * copyright(C)2013- Acorn International
4   - *
5   - * packeage:com.ozing.callteacher.parser.RemoteException.java
6   - * create:2013年7月25日下午1:58:14
7   - */
8   -package com.hjx.personalcenter.exception;
9   -
10   -/**
11   - * @author jixiaolong<jixiaolong@chinadrtv.com>
12   - * @code: 015261
13   - */
14   -public class RemoteException extends Exception {
15   - private ResponseError error;
16   - /**
17   - *
18   - */
19   - private static final long serialVersionUID = -9062978963856572686L;
20   - public RemoteException(String error) {
21   - super(error);
22   - this.error = new ResponseError();
23   - this.error.setMessage(error);
24   - this.error.setStatus(-1);
25   - }
26   - public RemoteException(ResponseError error) {
27   - super(error.getMessage());
28   - this.error = error;
29   - }
30   -
31   - public ResponseError getError() {
32   - return error;
33   - }
34   -}
PersonalCenter/app/src/main/java/com/hjx/personalcenter/exception/ResponseError.java
... ... @@ -1,35 +0,0 @@
1   -/**
2   - * HaoJiXing Teacher Q&A
3   - * copyright(C)2013- Acorn International
4   - *
5   - * packeage:com.ozing.callteacher.parser.ResponseError.java
6   - * create:2013年9月29日下午3:30:17
7   - */
8   -package com.hjx.personalcenter.exception;
9   -
10   -
11   -/**
12   - * @author jixiaolong<jixiaolong@chinadrtv.com>
13   - * @code: 015261
14   - */
15   -public class ResponseError {
16   - private int status = -1;
17   - private String message;
18   - public int getStatus() {
19   - return status;
20   - }
21   - public void setStatus(int status) {
22   - this.status = status;
23   - }
24   - public String getMessage() {
25   - return message;
26   - }
27   - public void setMessage(String message) {
28   - this.message = message;
29   - }
30   -
31   - public boolean hasError(){
32   - return status!=0 && status!=100;
33   - }
34   -
35   -}
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
... ... @@ -9,9 +9,13 @@ import android.os.Message;
9 9 import android.util.Log;
10 10 import android.widget.Toast;
11 11  
  12 +import com.google.gson.Gson;
12 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 18 import com.hjx.personalcenter.util.DialogPermission;
14   -import com.hjx.personalcenter.util.SaveParam;
15 19 import com.loopj.android.http.AsyncHttpResponseHandler;
16 20 import com.loopj.android.http.JsonHttpResponseHandler;
17 21 import com.loopj.android.http.RequestParams;
... ... @@ -289,17 +293,52 @@ public class HttpManager {
289 293 SaveParam.getInstance().saveLoginParam(context,"gender", gender);
290 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 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 327 @Override
297 328 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);
  329 + Log.e("test", "市" + new String(arg2));
  330 + Gson gson = new Gson();
  331 + CityInfo cityInfo = gson.fromJson(new String(arg2),CityInfo.class);
  332 + for (int i =0 ; i<cityInfo.getCities().size();i++){
  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 344 @Override
... ... @@ -308,7 +347,33 @@ public class HttpManager {
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 379 private void closeProgress() {
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
... ... @@ -13,6 +13,8 @@ public class HttpUrl {
13 13  
14 14 public static String loginUrl = GetDomain()+"/user/access_token";//登录
15 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 18 public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/
17 19 public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册
18 20 public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/CityInfo.java
... ... @@ -0,0 +1,80 @@
  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 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/CountyInfo.java
... ... @@ -0,0 +1,80 @@
  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 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/ProvinceInfo.java
... ... @@ -0,0 +1,80 @@
  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 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/BaseParser.java
... ... @@ -1,55 +0,0 @@
1   -/**
2   - * HaoJiXing Teacher Q&A
3   - * copyright(C)2013- Acorn International
4   - *
5   - * packeage:com.ozing.callteacher.parser.BaseParser.java
6   - * create:2013年7月25日下午1:58:14
7   - */
8   -package com.hjx.personalcenter.parser;
9   -
10   -import android.text.TextUtils;
11   -
12   -import com.hjx.personalcenter.exception.RemoteException;
13   -import com.hjx.personalcenter.exception.ResponseError;
14   -
15   -import org.json.JSONException;
16   -import org.json.JSONObject;
17   -
18   -/**
19   - * @author jixiaolong<jixiaolong@chinadrtv.com>
20   - * @code: 015261
21   - */
22   -public abstract class BaseParser<T> {
23   - public abstract T parse(String response) throws RemoteException, com.hjx.personalcenter.exception.RemoteException;
24   -
25   - public static ResponseError getError(String response){
26   - ResponseError error = new ResponseError();
27   - if(TextUtils.isEmpty(response)){
28   - error.setStatus(-1);
29   - error.setMessage("接口空数据");
30   - }else{
31   - if(response.contains("status")){
32   - //{"status":100,"message":"success","access_token":"0b129fa4-cd71-4777-89d0-215bf4652146"}
33   - //{"status":204,"message":"wrong password"}
34   - //{"status":200,"message":"user not exist"}
35   - try {
36   - JSONObject object = new JSONObject(response);
37   - int status = object.optInt("status");
38   - error.setStatus(status);
39   - if(status!=0 && status!=100){
40   - String msg = object.optString("message");
41   - if(!TextUtils.isEmpty(msg))
42   - error.setMessage(msg);
43   - }
44   - } catch (JSONException e) {
45   - error.setMessage("返回json数据错误:["+response+"]");
46   - }
47   - }else if(response.contains("error")){
48   - error.setMessage("服务器内部错误");
49   - }else{
50   - error.setStatus(100);
51   - }
52   - }
53   - return error;
54   - }
55   -}
PersonalCenter/app/src/main/java/com/hjx/personalcenter/parser/ProvinceParser.java
... ... @@ -1,56 +0,0 @@
1   -/**
2   - * HaoJiXing Teacher Q&A
3   - * copyright(C)2013- Acorn International
4   - *
5   - * packeage:com.ozing.callteacher.parser.ProvinceParser.java
6   - * create:2013年8月8日上午11:40:21
7   - */
8   -package com.hjx.personalcenter.parser;
9   -
10   -
11   -import com.hjx.personalcenter.areapicker.AreaBean;
12   -import com.hjx.personalcenter.exception.RemoteException;
13   -import com.hjx.personalcenter.exception.ResponseError;
14   -
15   -import org.json.JSONArray;
16   -import org.json.JSONException;
17   -import org.json.JSONObject;
18   -
19   -import java.util.ArrayList;
20   -import java.util.List;
21   -
22   -
23   -/**
24   - * @author jixiaolong<jixiaolong@chinadrtv.com>
25   - * @code: 015261
26   - */
27   -public class ProvinceParser extends BaseParser<List<AreaBean>> {
28   -
29   - @Override
30   - public List<AreaBean> parse(String response) throws RemoteException {
31   - ResponseError error = getError(response);
32   - if(error.hasError()){
33   - throw new RemoteException(error);
34   - }
35   -
36   - List<AreaBean> mList = new ArrayList<AreaBean>();
37   - try {
38   - JSONObject object = new JSONObject(response);
39   - JSONArray areaobj = object.getJSONArray("provinces");
40   - for(int i=0;i<areaobj.length();i++){
41   - JSONObject pro = areaobj.getJSONObject(i);
42   - AreaBean bean = new AreaBean();
43   - bean.setLevel(AreaBean.PROVINCE);
44   - bean.setId(pro.optString("regionId"));
45   - bean.setName(pro.optString("regionName"));
46   - bean.setFullName(pro.optString("regionName"));
47   - bean.setParentId(pro.optString("parentId"));
48   - mList.add(bean);
49   - }
50   - } catch (JSONException e) {
51   - e.printStackTrace();
52   - }
53   - return mList;
54   - }
55   -
56   -}
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/SaveParam.java
... ... @@ -1,57 +0,0 @@
1   -package com.hjx.personalcenter.util;
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   -}