Commit 296f7ef6a4b3b1147fc1a8f1c1d28d57d20c6948
1 parent
9fbe0a119f
Exists in
master
版本信息的BUG修复
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
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.view.KeyEvent; | 10 | import android.view.KeyEvent; |
| 11 | import android.widget.Toast; | 11 | import android.widget.Toast; |
| 12 | 12 | ||
| 13 | import com.google.gson.Gson; | 13 | import com.google.gson.Gson; |
| 14 | import com.google.gson.reflect.TypeToken; | 14 | import com.google.gson.reflect.TypeToken; |
| 15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
| 16 | import com.hjx.personalcenter.activity.BangDingCode; | 16 | import com.hjx.personalcenter.activity.BangDingCode; |
| 17 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 17 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
| 18 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 18 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
| 19 | import com.hjx.personalcenter.db.Content; | 19 | import com.hjx.personalcenter.db.Content; |
| 20 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
| 21 | import com.hjx.personalcenter.gson.GsonTool; | 21 | import com.hjx.personalcenter.gson.GsonTool; |
| 22 | import com.hjx.personalcenter.model.AppVersion; | 22 | import com.hjx.personalcenter.model.AppVersion; |
| 23 | import com.hjx.personalcenter.model.CardInfo; | 23 | import com.hjx.personalcenter.model.CardInfo; |
| 24 | import com.hjx.personalcenter.model.ChildsInfo; | 24 | import com.hjx.personalcenter.model.ChildsInfo; |
| 25 | import com.hjx.personalcenter.model.CityInfo; | 25 | import com.hjx.personalcenter.model.CityInfo; |
| 26 | import com.hjx.personalcenter.model.CountyInfo; | 26 | import com.hjx.personalcenter.model.CountyInfo; |
| 27 | import com.hjx.personalcenter.model.DefautPublishInfo; | 27 | import com.hjx.personalcenter.model.DefautPublishInfo; |
| 28 | import com.hjx.personalcenter.model.GradeInfo; | 28 | import com.hjx.personalcenter.model.GradeInfo; |
| 29 | import com.hjx.personalcenter.model.PesonalInfo; | 29 | import com.hjx.personalcenter.model.PesonalInfo; |
| 30 | import com.hjx.personalcenter.model.ProvinceInfo; | 30 | import com.hjx.personalcenter.model.ProvinceInfo; |
| 31 | import com.hjx.personalcenter.model.SchoolInfo; | 31 | import com.hjx.personalcenter.model.SchoolInfo; |
| 32 | import com.hjx.personalcenter.model.SignInfo; | 32 | import com.hjx.personalcenter.model.SignInfo; |
| 33 | import com.hjx.personalcenter.model.VersionInfo; | 33 | import com.hjx.personalcenter.model.VersionInfo; |
| 34 | import com.hjx.personalcenter.model.VideoInfo; | 34 | import com.hjx.personalcenter.model.VideoInfo; |
| 35 | import com.hjx.personalcenter.util.AlertUtils; | 35 | import com.hjx.personalcenter.util.AlertUtils; |
| 36 | import com.hjx.personalcenter.util.DialogPermission; | 36 | import com.hjx.personalcenter.util.DialogPermission; |
| 37 | import com.loopj.android.http.AsyncHttpResponseHandler; | 37 | import com.loopj.android.http.AsyncHttpResponseHandler; |
| 38 | import com.loopj.android.http.JsonHttpResponseHandler; | 38 | import com.loopj.android.http.JsonHttpResponseHandler; |
| 39 | import com.loopj.android.http.RequestParams; | 39 | import com.loopj.android.http.RequestParams; |
| 40 | 40 | ||
| 41 | import org.apache.http.Header; | 41 | import org.apache.http.Header; |
| 42 | import org.apache.http.entity.ByteArrayEntity; | 42 | import org.apache.http.entity.ByteArrayEntity; |
| 43 | import org.apache.http.message.BasicHeader; | 43 | import org.apache.http.message.BasicHeader; |
| 44 | import org.apache.http.protocol.HTTP; | 44 | import org.apache.http.protocol.HTTP; |
| 45 | import org.json.JSONException; | 45 | import org.json.JSONException; |
| 46 | import org.json.JSONObject; | 46 | import org.json.JSONObject; |
| 47 | 47 | ||
| 48 | import java.io.File; | 48 | import java.io.File; |
| 49 | import java.io.FileNotFoundException; | 49 | import java.io.FileNotFoundException; |
| 50 | import java.io.UnsupportedEncodingException; | 50 | import java.io.UnsupportedEncodingException; |
| 51 | import java.util.ArrayList; | 51 | import java.util.ArrayList; |
| 52 | import java.util.List; | 52 | import java.util.List; |
| 53 | 53 | ||
| 54 | public class HttpManager { | 54 | public class HttpManager { |
| 55 | private static HttpManager instance; | 55 | private static HttpManager instance; |
| 56 | private ProgressDialog mProgress = null; | 56 | private ProgressDialog mProgress = null; |
| 57 | 57 | ||
| 58 | public static HttpManager getInstance() { | 58 | public static HttpManager getInstance() { |
| 59 | if (instance == null) { | 59 | if (instance == null) { |
| 60 | instance = new HttpManager(); | 60 | instance = new HttpManager(); |
| 61 | } | 61 | } |
| 62 | return instance; | 62 | return instance; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | //登录接口 | 66 | //登录接口 |
| 67 | 67 | ||
| 68 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 68 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
| 69 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 69 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
| 70 | true, true, null); | 70 | true, true, null); |
| 71 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 71 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 72 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 72 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
| 73 | @Override | 73 | @Override |
| 74 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 74 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 75 | closeProgress(); | 75 | closeProgress(); |
| 76 | Message msg = Message.obtain(); | 76 | Message msg = Message.obtain(); |
| 77 | msg.what = HttpCode.LOGIN_SUCESS; | 77 | msg.what = HttpCode.LOGIN_SUCESS; |
| 78 | msg.obj = new String(arg2); | 78 | msg.obj = new String(arg2); |
| 79 | handler.sendMessage(msg); | 79 | handler.sendMessage(msg); |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 85 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 86 | closeProgress(); | 86 | closeProgress(); |
| 87 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 87 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 88 | } | 88 | } |
| 89 | }); | 89 | }); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | //注册接口 | 92 | //注册接口 |
| 93 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 93 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
| 94 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 94 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
| 95 | false, true, null); | 95 | false, true, null); |
| 96 | JSONObject jsonObject = new JSONObject(); | 96 | JSONObject jsonObject = new JSONObject(); |
| 97 | ByteArrayEntity entity = null; | 97 | ByteArrayEntity entity = null; |
| 98 | try { | 98 | try { |
| 99 | jsonObject.put(HttpKey.USERNAME, username); | 99 | jsonObject.put(HttpKey.USERNAME, username); |
| 100 | jsonObject.put(HttpKey.PASSWORD, password); | 100 | jsonObject.put(HttpKey.PASSWORD, password); |
| 101 | jsonObject.put(HttpKey.SMSCODE, smscode); | 101 | jsonObject.put(HttpKey.SMSCODE, smscode); |
| 102 | jsonObject.put(HttpKey.SOURCE, source); | 102 | jsonObject.put(HttpKey.SOURCE, source); |
| 103 | Log.e("test", "jsonObject" + jsonObject); | 103 | Log.e("test", "jsonObject" + jsonObject); |
| 104 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 104 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
| 105 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 105 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
| 106 | } catch (JSONException e) { | 106 | } catch (JSONException e) { |
| 107 | e.printStackTrace(); | 107 | e.printStackTrace(); |
| 108 | } catch (UnsupportedEncodingException e) { | 108 | } catch (UnsupportedEncodingException e) { |
| 109 | e.printStackTrace(); | 109 | e.printStackTrace(); |
| 110 | } | 110 | } |
| 111 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 111 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 112 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 112 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
| 113 | @Override | 113 | @Override |
| 114 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 114 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 115 | super.onSuccess(statusCode, headers, response); | 115 | super.onSuccess(statusCode, headers, response); |
| 116 | closeProgress(); | 116 | closeProgress(); |
| 117 | Log.e("test", "onSuccess" + response); | 117 | Log.e("test", "onSuccess" + response); |
| 118 | Message msg = Message.obtain(); | 118 | Message msg = Message.obtain(); |
| 119 | msg.what = HttpCode.REGISTERED_SUCESS; | 119 | msg.what = HttpCode.REGISTERED_SUCESS; |
| 120 | msg.obj = response; | 120 | msg.obj = response; |
| 121 | handler.sendMessage(msg); | 121 | handler.sendMessage(msg); |
| 122 | 122 | ||
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | @Override | 125 | @Override |
| 126 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 126 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 127 | super.onFailure(statusCode, headers, throwable, errorResponse); | 127 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 128 | closeProgress(); | 128 | closeProgress(); |
| 129 | Log.e("test", "onFailure" + errorResponse); | 129 | Log.e("test", "onFailure" + errorResponse); |
| 130 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 130 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | }); | 133 | }); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | //注册验证码 | 136 | //注册验证码 |
| 137 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 137 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
| 138 | RequestParams params = new RequestParams(); | 138 | RequestParams params = new RequestParams(); |
| 139 | params.put(HttpKey.TYPE, type); | 139 | params.put(HttpKey.TYPE, type); |
| 140 | params.put(HttpKey.MOBIL, mobile); | 140 | params.put(HttpKey.MOBIL, mobile); |
| 141 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 141 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 142 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 142 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
| 143 | 143 | ||
| 144 | @Override | 144 | @Override |
| 145 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 145 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 146 | Log.e("test", "onSuccess-----" + response); | 146 | Log.e("test", "onSuccess-----" + response); |
| 147 | Message msg = Message.obtain(); | 147 | Message msg = Message.obtain(); |
| 148 | msg.what = HttpCode.AUTHCODE_SUCESS; | 148 | msg.what = HttpCode.AUTHCODE_SUCESS; |
| 149 | msg.obj = response; | 149 | msg.obj = response; |
| 150 | handler.sendMessage(msg); | 150 | handler.sendMessage(msg); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | @Override | 153 | @Override |
| 154 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 154 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 155 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 155 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 156 | } | 156 | } |
| 157 | }); | 157 | }); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | //手机号是否注册 | 161 | //手机号是否注册 |
| 162 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 162 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
| 163 | RequestParams params = new RequestParams(); | 163 | RequestParams params = new RequestParams(); |
| 164 | params.put(HttpKey.USERNAME, mobile); | 164 | params.put(HttpKey.USERNAME, mobile); |
| 165 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 165 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
| 166 | @Override | 166 | @Override |
| 167 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 167 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 168 | Log.e("test", "isregistered" + response.toString()); | 168 | Log.e("test", "isregistered" + response.toString()); |
| 169 | Message msg = Message.obtain(); | 169 | Message msg = Message.obtain(); |
| 170 | msg.what = HttpCode.IS_REFISTER; | 170 | msg.what = HttpCode.IS_REFISTER; |
| 171 | msg.obj = response; | 171 | msg.obj = response; |
| 172 | handler.sendMessage(msg); | 172 | handler.sendMessage(msg); |
| 173 | 173 | ||
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | @Override | 176 | @Override |
| 177 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 177 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 178 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 178 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 179 | 179 | ||
| 180 | } | 180 | } |
| 181 | }); | 181 | }); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | //修改密码 | 184 | //修改密码 |
| 185 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 185 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
| 186 | mProgress = DialogPermission.showProgress(context, null, "正在修改密码...", | 186 | mProgress = DialogPermission.showProgress(context, null, "正在修改密码...", |
| 187 | false, true, null); | 187 | false, true, null); |
| 188 | RequestParams params = new RequestParams(); | 188 | RequestParams params = new RequestParams(); |
| 189 | params.put(HttpKey.USERNAME, username); | 189 | params.put(HttpKey.USERNAME, username); |
| 190 | params.put(HttpKey.OLDPASS, old_pwd1); | 190 | params.put(HttpKey.OLDPASS, old_pwd1); |
| 191 | params.put(HttpKey.NEWPASS, newpassword3); | 191 | params.put(HttpKey.NEWPASS, newpassword3); |
| 192 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 192 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 193 | HttpClient.getInstance().setTimeout(10 * 1000); | 193 | HttpClient.getInstance().setTimeout(10 * 1000); |
| 194 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 194 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
| 195 | @Override | 195 | @Override |
| 196 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 196 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 197 | closeProgress(); | 197 | closeProgress(); |
| 198 | try { | 198 | try { |
| 199 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 199 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 200 | String status = jsonObject.optString("status"); | 200 | String status = jsonObject.optString("status"); |
| 201 | if (status.equals("100")) { | 201 | if (status.equals("100")) { |
| 202 | Log.e("test", "onSuccess" + new String(bytes)); | 202 | Log.e("test", "onSuccess" + new String(bytes)); |
| 203 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 203 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
| 204 | SaveParam.getInstance().clearData((Activity) context); | 204 | SaveParam.getInstance().clearData((Activity) context); |
| 205 | Intent intent = new Intent(); | 205 | Intent intent = new Intent(); |
| 206 | intent.setClass(context, LoginAndRegisterActivity.class); | 206 | intent.setClass(context, LoginAndRegisterActivity.class); |
| 207 | ((Activity) context).startActivity(intent); | 207 | ((Activity) context).startActivity(intent); |
| 208 | ((Activity) context).finish(); | 208 | ((Activity) context).finish(); |
| 209 | } else { | 209 | } else { |
| 210 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 210 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
| 211 | } | 211 | } |
| 212 | } catch (JSONException e) { | 212 | } catch (JSONException e) { |
| 213 | e.printStackTrace(); | 213 | e.printStackTrace(); |
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | @Override | 217 | @Override |
| 218 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 218 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 219 | closeProgress(); | 219 | closeProgress(); |
| 220 | Log.e("test", "onFailure" + new String(bytes)); | 220 | Log.e("test", "onFailure" + new String(bytes)); |
| 221 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 221 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 222 | } | 222 | } |
| 223 | }); | 223 | }); |
| 224 | 224 | ||
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | //忘记密码 | 227 | //忘记密码 |
| 228 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 228 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
| 229 | RequestParams params = new RequestParams(); | 229 | RequestParams params = new RequestParams(); |
| 230 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 230 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
| 231 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 231 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
| 232 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 232 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
| 233 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 233 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 234 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 234 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
| 235 | @Override | 235 | @Override |
| 236 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 236 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 237 | try { | 237 | try { |
| 238 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 238 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 239 | String status = jsonObject.optString("status"); | 239 | String status = jsonObject.optString("status"); |
| 240 | if (status.equals("100")) { | 240 | if (status.equals("100")) { |
| 241 | Log.e("test", "onSuccess" + new String(bytes)); | 241 | Log.e("test", "onSuccess" + new String(bytes)); |
| 242 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 242 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
| 243 | ((Activity) context).finish(); | 243 | ((Activity) context).finish(); |
| 244 | } else { | 244 | } else { |
| 245 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 245 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
| 246 | } | 246 | } |
| 247 | } catch (JSONException e) { | 247 | } catch (JSONException e) { |
| 248 | e.printStackTrace(); | 248 | e.printStackTrace(); |
| 249 | } | 249 | } |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | @Override | 252 | @Override |
| 253 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 253 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 254 | Log.e("test", "onFailure" + new String(bytes)); | 254 | Log.e("test", "onFailure" + new String(bytes)); |
| 255 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 255 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 256 | } | 256 | } |
| 257 | }); | 257 | }); |
| 258 | 258 | ||
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | //保存用户登录信息 | 261 | //保存用户登录信息 |
| 262 | public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) { | 262 | public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) { |
| 263 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 263 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
| 264 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 264 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
| 265 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 265 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
| 266 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 266 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
| 267 | 267 | ||
| 268 | 268 | ||
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | //提交保卡信息 | 271 | //提交保卡信息 |
| 272 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 272 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
| 273 | String buyAddress, String buyTime, String alterSaleCall, | 273 | String buyAddress, String buyTime, String alterSaleCall, |
| 274 | String productModel, String deviceNumber, String macAddress, | 274 | String productModel, String deviceNumber, String macAddress, |
| 275 | String mobilePhone) { | 275 | String mobilePhone) { |
| 276 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 276 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
| 277 | false, true, null); | 277 | false, true, null); |
| 278 | RequestParams params = new RequestParams(); | 278 | RequestParams params = new RequestParams(); |
| 279 | 279 | ||
| 280 | params.put(HttpKey.USEID, userId); | 280 | params.put(HttpKey.USEID, userId); |
| 281 | params.put(HttpKey.CUSTOMENAME, customerName); | 281 | params.put(HttpKey.CUSTOMENAME, customerName); |
| 282 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 282 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
| 283 | params.put(HttpKey.BUYADREES, buyAddress); | 283 | params.put(HttpKey.BUYADREES, buyAddress); |
| 284 | params.put(HttpKey.BUYTIME, buyTime); | 284 | params.put(HttpKey.BUYTIME, buyTime); |
| 285 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 285 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
| 286 | params.put(HttpKey.PRODUCTMODEL, productModel); | 286 | params.put(HttpKey.PRODUCTMODEL, productModel); |
| 287 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 287 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
| 288 | params.put(HttpKey.MACADRESS, macAddress); | 288 | params.put(HttpKey.MACADRESS, macAddress); |
| 289 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 289 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
| 290 | 290 | ||
| 291 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 291 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 292 | 292 | ||
| 293 | Log.e("test", "params" + params); | 293 | Log.e("test", "params" + params); |
| 294 | HttpClient.getInstance().setTimeout(5 * 1000); | 294 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 295 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 295 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
| 296 | @Override | 296 | @Override |
| 297 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 297 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 298 | JSONObject jsonObject = null; | 298 | JSONObject jsonObject = null; |
| 299 | closeProgress(); | 299 | closeProgress(); |
| 300 | try { | 300 | try { |
| 301 | jsonObject = new JSONObject(new String(bytes)); | 301 | jsonObject = new JSONObject(new String(bytes)); |
| 302 | String status = jsonObject.optString("status"); | 302 | String status = jsonObject.optString("status"); |
| 303 | if (status.equals("1")) { | 303 | if (status.equals("1")) { |
| 304 | Log.e("test", "onSuccess" + jsonObject); | 304 | Log.e("test", "onSuccess" + jsonObject); |
| 305 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 305 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
| 306 | if (Content.cardintentflag == 1) { | 306 | if (Content.cardintentflag == 1) { |
| 307 | Intent intent = new Intent(); | 307 | Intent intent = new Intent(); |
| 308 | intent.setClass((Activity) context, TheStartPageActivity.class); | 308 | intent.setClass((Activity) context, TheStartPageActivity.class); |
| 309 | ((Activity) context).startActivity(intent); | 309 | ((Activity) context).startActivity(intent); |
| 310 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 310 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 311 | ((Activity) context).finish(); | 311 | ((Activity) context).finish(); |
| 312 | } else if (Content.cardintentflag == 2) { | 312 | } else if (Content.cardintentflag == 2) { |
| 313 | Intent intent = new Intent(); | 313 | Intent intent = new Intent(); |
| 314 | intent.setClass((Activity) context, BangDingCode.class); | 314 | intent.setClass((Activity) context, BangDingCode.class); |
| 315 | ((Activity) context).startActivity(intent); | 315 | ((Activity) context).startActivity(intent); |
| 316 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 316 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 317 | ((Activity) context).finish(); | 317 | ((Activity) context).finish(); |
| 318 | 318 | ||
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | 321 | ||
| 322 | } else { | 322 | } else { |
| 323 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); | 323 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); |
| 324 | } | 324 | } |
| 325 | } catch (JSONException e) { | 325 | } catch (JSONException e) { |
| 326 | e.printStackTrace(); | 326 | e.printStackTrace(); |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | 329 | ||
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | @Override | 332 | @Override |
| 333 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 333 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 334 | Log.e("test", "onFailure" + (throwable)); | 334 | Log.e("test", "onFailure" + (throwable)); |
| 335 | closeProgress(); | 335 | closeProgress(); |
| 336 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 336 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 337 | 337 | ||
| 338 | } | 338 | } |
| 339 | }); | 339 | }); |
| 340 | 340 | ||
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | //获取保卡信息 | 343 | //获取保卡信息 |
| 344 | public void getcardinfo(final Context mContext, String deviceNumber, final Handler handler) { | 344 | public void getcardinfo(final Context mContext, String deviceNumber, final Handler handler) { |
| 345 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 345 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
| 346 | false, true, null); | 346 | false, true, null); |
| 347 | HttpClient.getInstance().setTimeout(5 * 1000); | 347 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 348 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 348 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 349 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 349 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
| 350 | @Override | 350 | @Override |
| 351 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 351 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 352 | closeProgress(); | 352 | closeProgress(); |
| 353 | Log.e("test", "保卡信息" + new String(arg2)); | 353 | Log.e("test", "保卡信息" + new String(arg2)); |
| 354 | try { | 354 | try { |
| 355 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 355 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 356 | int status = jsonObject.optInt("status"); | 356 | int status = jsonObject.optInt("status"); |
| 357 | if (status == 1) { | 357 | if (status == 1) { |
| 358 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 358 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
| 359 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 359 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
| 360 | Message msg = Message.obtain(); | 360 | Message msg = Message.obtain(); |
| 361 | msg.what = HttpCode.SUCHCARDINFO; | 361 | msg.what = HttpCode.SUCHCARDINFO; |
| 362 | msg.obj = schoolInfoBeanList; | 362 | msg.obj = schoolInfoBeanList; |
| 363 | handler.sendMessage(msg); | 363 | handler.sendMessage(msg); |
| 364 | 364 | ||
| 365 | 365 | ||
| 366 | } else { | 366 | } else { |
| 367 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 367 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 368 | 368 | ||
| 369 | } | 369 | } |
| 370 | } catch (JSONException e) { | 370 | } catch (JSONException e) { |
| 371 | e.printStackTrace(); | 371 | e.printStackTrace(); |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | @Override | 376 | @Override |
| 377 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 377 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 378 | closeProgress(); | 378 | closeProgress(); |
| 379 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 379 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 380 | } | 380 | } |
| 381 | }); | 381 | }); |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | //获取是否为样机信息 | 384 | //获取是否为样机信息 |
| 385 | public void getcardinfo1(final Context mContext, String deviceNumber, final Handler handler) { | 385 | public void getcardinfo1(final Context mContext, String deviceNumber, final Handler handler) { |
| 386 | HttpClient.getInstance().setTimeout(5 * 1000); | 386 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 387 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 387 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 388 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 388 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
| 389 | @Override | 389 | @Override |
| 390 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 390 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 391 | closeProgress(); | 391 | closeProgress(); |
| 392 | Log.e("test", "保卡信息" + new String(arg2)); | 392 | Log.e("test", "保卡信息" + new String(arg2)); |
| 393 | Message msg = Message.obtain(); | 393 | Message msg = Message.obtain(); |
| 394 | msg.what = HttpCode.SUCHCARDINFOONE; | 394 | msg.what = HttpCode.SUCHCARDINFOONE; |
| 395 | msg.obj = new String(arg2); | 395 | msg.obj = new String(arg2); |
| 396 | handler.sendMessage(msg); | 396 | handler.sendMessage(msg); |
| 397 | 397 | ||
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | @Override | 400 | @Override |
| 401 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 401 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 402 | closeProgress(); | 402 | closeProgress(); |
| 403 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 403 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 404 | } | 404 | } |
| 405 | }); | 405 | }); |
| 406 | } | 406 | } |
| 407 | 407 | ||
| 408 | //修改账户电话 | 408 | //修改账户电话 |
| 409 | public void changeaccountphone(final Context mContext, long userId, final String username, String authCode) { | 409 | public void changeaccountphone(final Context mContext, long userId, final String username, String authCode) { |
| 410 | RequestParams params = new RequestParams(); | 410 | RequestParams params = new RequestParams(); |
| 411 | params.put("userId", userId); | 411 | params.put("userId", userId); |
| 412 | params.put("username", username); | 412 | params.put("username", username); |
| 413 | params.put("authCode", authCode); | 413 | params.put("authCode", authCode); |
| 414 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 414 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 415 | HttpClient.getInstance().post(HttpUrl.chageaccountphoneURL, params, new AsyncHttpResponseHandler() { | 415 | HttpClient.getInstance().post(HttpUrl.chageaccountphoneURL, params, new AsyncHttpResponseHandler() { |
| 416 | @Override | 416 | @Override |
| 417 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 417 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 418 | try { | 418 | try { |
| 419 | Log.e("test", "保卡信息" + new String(bytes)); | 419 | Log.e("test", "保卡信息" + new String(bytes)); |
| 420 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 420 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 421 | String status = jsonObject.optString("status"); | 421 | String status = jsonObject.optString("status"); |
| 422 | if (status.equals("1")) { | 422 | if (status.equals("1")) { |
| 423 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 423 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
| 424 | SaveParam.getInstance().saveLoginParam(mContext, "username", username); | 424 | SaveParam.getInstance().saveLoginParam(mContext, "username", username); |
| 425 | ((Activity) mContext).finish(); | 425 | ((Activity) mContext).finish(); |
| 426 | } else if (status.equals("1001")) { | 426 | } else if (status.equals("1001")) { |
| 427 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 427 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
| 428 | } | 428 | } |
| 429 | else if (status.equals("1006")) { | 429 | else if (status.equals("1006")) { |
| 430 | AlertUtils.showToast(mContext, "该手机号已存在,请使用其他手机号重新绑定!"); | 430 | AlertUtils.showToast(mContext, "该手机号已存在,请使用其他手机号重新绑定!"); |
| 431 | } else { | 431 | } else { |
| 432 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 432 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 433 | } | 433 | } |
| 434 | } catch (JSONException e) { | 434 | } catch (JSONException e) { |
| 435 | e.printStackTrace(); | 435 | e.printStackTrace(); |
| 436 | } | 436 | } |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | @Override | 439 | @Override |
| 440 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 440 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 441 | Log.e("test", "onFailure" + new String(bytes)); | 441 | Log.e("test", "onFailure" + new String(bytes)); |
| 442 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 442 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 443 | } | 443 | } |
| 444 | }); | 444 | }); |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | //修改保卡信息电话 | 447 | //修改保卡信息电话 |
| 448 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 448 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
| 449 | RequestParams params = new RequestParams(); | 449 | RequestParams params = new RequestParams(); |
| 450 | params.put("userId", userId); | 450 | params.put("userId", userId); |
| 451 | params.put("customerPhone", customerPhone); | 451 | params.put("customerPhone", customerPhone); |
| 452 | params.put("authCode", authCode); | 452 | params.put("authCode", authCode); |
| 453 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 453 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 454 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 454 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
| 455 | @Override | 455 | @Override |
| 456 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 456 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 457 | try { | 457 | try { |
| 458 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 458 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 459 | String status = jsonObject.optString("status"); | 459 | String status = jsonObject.optString("status"); |
| 460 | if (status.equals("1")) { | 460 | if (status.equals("1")) { |
| 461 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 461 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
| 462 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | 462 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); |
| 463 | ((Activity) mContext).finish(); | 463 | ((Activity) mContext).finish(); |
| 464 | } else if (status.equals("1001")) { | 464 | } else if (status.equals("1001")) { |
| 465 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 465 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
| 466 | } else { | 466 | } else { |
| 467 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 467 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 468 | } | 468 | } |
| 469 | } catch (JSONException e) { | 469 | } catch (JSONException e) { |
| 470 | e.printStackTrace(); | 470 | e.printStackTrace(); |
| 471 | } | 471 | } |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | @Override | 474 | @Override |
| 475 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 475 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 476 | Log.e("test", "onFailure" + new String(bytes)); | 476 | Log.e("test", "onFailure" + new String(bytes)); |
| 477 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 477 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 478 | } | 478 | } |
| 479 | }); | 479 | }); |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | //修改保卡信息地址 | 482 | //修改保卡信息地址 |
| 483 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 483 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
| 484 | RequestParams params = new RequestParams(); | 484 | RequestParams params = new RequestParams(); |
| 485 | params.put("userId", userId); | 485 | params.put("userId", userId); |
| 486 | params.put("customerPhone", customerPhone); | 486 | params.put("customerPhone", customerPhone); |
| 487 | params.put("authCode", authCode); | 487 | params.put("authCode", authCode); |
| 488 | params.put("customerAddress", customerAddress); | 488 | params.put("customerAddress", customerAddress); |
| 489 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 489 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 490 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 490 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
| 491 | @Override | 491 | @Override |
| 492 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 492 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 493 | try { | 493 | try { |
| 494 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 494 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 495 | String status = jsonObject.optString("status"); | 495 | String status = jsonObject.optString("status"); |
| 496 | if (status.equals("1")) { | 496 | if (status.equals("1")) { |
| 497 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); | 497 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); |
| 498 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); | 498 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); |
| 499 | ((Activity) mContext).finish(); | 499 | ((Activity) mContext).finish(); |
| 500 | } else { | 500 | } else { |
| 501 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 501 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 502 | } | 502 | } |
| 503 | } catch (JSONException e) { | 503 | } catch (JSONException e) { |
| 504 | e.printStackTrace(); | 504 | e.printStackTrace(); |
| 505 | } | 505 | } |
| 506 | } | 506 | } |
| 507 | 507 | ||
| 508 | @Override | 508 | @Override |
| 509 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 509 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 510 | Log.e("test", "onFailure" + new String(bytes)); | 510 | Log.e("test", "onFailure" + new String(bytes)); |
| 511 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 511 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 512 | } | 512 | } |
| 513 | }); | 513 | }); |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | //验证是否保卡信息 | 516 | //验证是否保卡信息 |
| 517 | public void cardinfocheck(final Context mContext, String deviceNumber, final Handler handler) { | 517 | public void cardinfocheck(final Context mContext, String deviceNumber, final Handler handler) { |
| 518 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 518 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
| 519 | false, true, null); | 519 | false, true, null); |
| 520 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 520 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 521 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 521 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
| 522 | @Override | 522 | @Override |
| 523 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 523 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 524 | Log.e("test", "验证保卡" + new String(arg2)); | 524 | Log.e("test", "验证保卡" + new String(arg2)); |
| 525 | closeProgress(); | 525 | closeProgress(); |
| 526 | Message msg = Message.obtain(); | 526 | Message msg = Message.obtain(); |
| 527 | msg.what = HttpCode.CHECKCARD; | 527 | msg.what = HttpCode.CHECKCARD; |
| 528 | msg.obj = new String(arg2); | 528 | msg.obj = new String(arg2); |
| 529 | handler.sendMessage(msg); | 529 | handler.sendMessage(msg); |
| 530 | 530 | ||
| 531 | 531 | ||
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | @Override | 534 | @Override |
| 535 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 535 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 536 | closeProgress(); | 536 | closeProgress(); |
| 537 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 537 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 538 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 538 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
| 539 | } | 539 | } |
| 540 | }); | 540 | }); |
| 541 | } | 541 | } |
| 542 | 542 | ||
| 543 | ///获取年级 | 543 | ///获取年级 |
| 544 | public void getgrade(final Context mContext, final Handler handler) { | 544 | public void getgrade(final Context mContext, final Handler handler) { |
| 545 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 545 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 546 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 546 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
| 547 | @Override | 547 | @Override |
| 548 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 548 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 549 | Log.e("test", "年级" + new String(arg2)); | 549 | Log.e("test", "年级" + new String(arg2)); |
| 550 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 550 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
| 551 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 551 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
| 552 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { | 552 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { |
| 553 | String name = gradeInfo.getData().get(i).getName(); | 553 | String name = gradeInfo.getData().get(i).getName(); |
| 554 | int id = gradeInfo.getData().get(i).getId(); | 554 | int id = gradeInfo.getData().get(i).getId(); |
| 555 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 555 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
| 556 | for (int j = 0; j < gradeinfoList.size(); j++) { | 556 | for (int j = 0; j < gradeinfoList.size(); j++) { |
| 557 | String secondname = gradeinfoList.get(j).getName(); | 557 | String secondname = gradeinfoList.get(j).getName(); |
| 558 | int secondid = gradeinfoList.get(j).getId(); | 558 | int secondid = gradeinfoList.get(j).getId(); |
| 559 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 559 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
| 560 | dataBean.setName(secondname); | 560 | dataBean.setName(secondname); |
| 561 | dataBean.setId(secondid); | 561 | dataBean.setId(secondid); |
| 562 | gradeInfoLists.add(dataBean); | 562 | gradeInfoLists.add(dataBean); |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | Message message = Message.obtain(); | 567 | Message message = Message.obtain(); |
| 568 | message.what = HttpCode.GRADER; | 568 | message.what = HttpCode.GRADER; |
| 569 | message.obj = gradeInfoLists; | 569 | message.obj = gradeInfoLists; |
| 570 | handler.sendMessage(message); | 570 | handler.sendMessage(message); |
| 571 | 571 | ||
| 572 | 572 | ||
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | @Override | 575 | @Override |
| 576 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 576 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 577 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 577 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 578 | } | 578 | } |
| 579 | }); | 579 | }); |
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | /** | 582 | /** |
| 583 | * 获取学校 | 583 | * 获取学校 |
| 584 | * | 584 | * |
| 585 | * @param mContext | 585 | * @param mContext |
| 586 | * @param regionId | 586 | * @param regionId |
| 587 | * @param gradeId | 587 | * @param gradeId |
| 588 | * @param handler | 588 | * @param handler |
| 589 | */ | 589 | */ |
| 590 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 590 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
| 591 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 591 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 592 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 592 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
| 593 | @Override | 593 | @Override |
| 594 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 594 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 595 | Log.e("test", "学校" + new String(arg2)); | 595 | Log.e("test", "学校" + new String(arg2)); |
| 596 | try { | 596 | try { |
| 597 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 597 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 598 | int status = jsonObject.optInt("status"); | 598 | int status = jsonObject.optInt("status"); |
| 599 | if (status == 1) { | 599 | if (status == 1) { |
| 600 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 600 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
| 601 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 601 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
| 602 | Message message = Message.obtain(); | 602 | Message message = Message.obtain(); |
| 603 | message.what = HttpCode.SCHOOL; | 603 | message.what = HttpCode.SCHOOL; |
| 604 | message.obj = schoolInfoBeanList; | 604 | message.obj = schoolInfoBeanList; |
| 605 | handler.sendMessage(message); | 605 | handler.sendMessage(message); |
| 606 | 606 | ||
| 607 | 607 | ||
| 608 | } else { | 608 | } else { |
| 609 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 609 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 610 | 610 | ||
| 611 | } | 611 | } |
| 612 | } catch (JSONException e) { | 612 | } catch (JSONException e) { |
| 613 | e.printStackTrace(); | 613 | e.printStackTrace(); |
| 614 | } | 614 | } |
| 615 | 615 | ||
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | @Override | 618 | @Override |
| 619 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 619 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 620 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 620 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 621 | } | 621 | } |
| 622 | }); | 622 | }); |
| 623 | } | 623 | } |
| 624 | 624 | ||
| 625 | 625 | ||
| 626 | /** | 626 | /** |
| 627 | * 获取个人信息 | 627 | * 获取个人信息 |
| 628 | * | 628 | * |
| 629 | * @param mContext | 629 | * @param mContext |
| 630 | * @param userId | 630 | * @param userId |
| 631 | * @param handler | 631 | * @param handler |
| 632 | */ | 632 | */ |
| 633 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { | 633 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { |
| 634 | // mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 634 | // mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
| 635 | // false, true, null); | 635 | // false, true, null); |
| 636 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 636 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
| 637 | HttpClient.getInstance().setConnectTimeout(5 * 1000); | 637 | HttpClient.getInstance().setConnectTimeout(5 * 1000); |
| 638 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 638 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 639 | @Override | 639 | @Override |
| 640 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 640 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 641 | closeProgress(); | 641 | closeProgress(); |
| 642 | Log.e("test", "个人信息" + new String(arg2)); | 642 | Log.e("test", "个人信息" + new String(arg2)); |
| 643 | try { | 643 | try { |
| 644 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 644 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 645 | int status = jsonObject.optInt("status"); | 645 | int status = jsonObject.optInt("status"); |
| 646 | if (status == 1) { | 646 | if (status == 1) { |
| 647 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 647 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
| 648 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 648 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
| 649 | Message message = Message.obtain(); | 649 | Message message = Message.obtain(); |
| 650 | message.what = HttpCode.GETINFO; | 650 | message.what = HttpCode.GETINFO; |
| 651 | message.obj = pesonalInfoBeanList; | 651 | message.obj = pesonalInfoBeanList; |
| 652 | handler.sendMessage(message); | 652 | handler.sendMessage(message); |
| 653 | 653 | ||
| 654 | 654 | ||
| 655 | } else { | 655 | } else { |
| 656 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 656 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 657 | 657 | ||
| 658 | } | 658 | } |
| 659 | } catch (JSONException e) { | 659 | } catch (JSONException e) { |
| 660 | e.printStackTrace(); | 660 | e.printStackTrace(); |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | 663 | ||
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | @Override | 666 | @Override |
| 667 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 667 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 668 | closeProgress(); | 668 | closeProgress(); |
| 669 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 669 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 670 | } | 670 | } |
| 671 | }); | 671 | }); |
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | //修改个人信息 | 674 | //修改个人信息 |
| 675 | public void changepresonalinfo(final Context mContext, Long id, int type | 675 | public void changepresonalinfo(final Context mContext, Long id, int type |
| 676 | , String name, String birthday, int gradeId, long regionId, | 676 | , String name, String birthday, int gradeId, long regionId, |
| 677 | Object schoolId, String qq, String gender | 677 | Object schoolId, String qq, String gender |
| 678 | , String regionName,String address, String devicenumber) throws UnsupportedEncodingException { | 678 | , String regionName,String address, String devicenumber) throws UnsupportedEncodingException { |
| 679 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 679 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
| 680 | false, true, null); | 680 | false, true, null); |
| 681 | RequestParams params = new RequestParams(); | 681 | RequestParams params = new RequestParams(); |
| 682 | 682 | ||
| 683 | params.put(HttpKey.USEID, id); | 683 | params.put(HttpKey.USEID, id); |
| 684 | params.put(HttpKey.TYPE, type); | 684 | params.put(HttpKey.TYPE, type); |
| 685 | params.put(HttpKey.NAME, name); | 685 | params.put(HttpKey.NAME, name); |
| 686 | params.put(HttpKey.BIRDays, birthday); | 686 | params.put(HttpKey.BIRDays, birthday); |
| 687 | params.put(HttpKey.GRADE, gradeId); | 687 | params.put(HttpKey.GRADE, gradeId); |
| 688 | params.put(HttpKey.REGION, regionId); | 688 | params.put(HttpKey.REGION, regionId); |
| 689 | params.put(HttpKey.SCHOOL, schoolId); | 689 | params.put(HttpKey.SCHOOL, schoolId); |
| 690 | params.put(HttpKey.QQ, qq); | 690 | params.put(HttpKey.QQ, qq); |
| 691 | params.put(HttpKey.GENDER, gender); | 691 | params.put(HttpKey.GENDER, gender); |
| 692 | params.put(HttpKey.REGIONNAME, regionName); | 692 | params.put(HttpKey.REGIONNAME, regionName); |
| 693 | params.put(HttpKey.ADDDRESS, address); | 693 | params.put(HttpKey.ADDDRESS, address); |
| 694 | params.put(HttpKey.DEVINUMBER, devicenumber); | 694 | params.put(HttpKey.DEVINUMBER, devicenumber); |
| 695 | Log.e("test", "个人信息" + params); | 695 | Log.e("test", "个人信息" + params); |
| 696 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 696 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 697 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 697 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
| 698 | @Override | 698 | @Override |
| 699 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 699 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 700 | super.onSuccess(statusCode, headers, response); | 700 | super.onSuccess(statusCode, headers, response); |
| 701 | closeProgress(); | 701 | closeProgress(); |
| 702 | String status = response.optString("status"); | 702 | String status = response.optString("status"); |
| 703 | if (status.equals("1")) { | 703 | if (status.equals("1")) { |
| 704 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 704 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
| 705 | ((Activity) mContext).finish(); | 705 | ((Activity) mContext).finish(); |
| 706 | } else { | 706 | } else { |
| 707 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 707 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | @Override | 712 | @Override |
| 713 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 713 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 714 | super.onFailure(statusCode, headers, throwable, errorResponse); | 714 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 715 | closeProgress(); | 715 | closeProgress(); |
| 716 | Log.e("test", "onFailure" + errorResponse); | 716 | Log.e("test", "onFailure" + errorResponse); |
| 717 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 717 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 718 | } | 718 | } |
| 719 | 719 | ||
| 720 | }); | 720 | }); |
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | //提交注册信息 | 723 | //提交注册信息 |
| 724 | public void subregisterinfo(final Context mContext, Long userId | 724 | public void subregisterinfo(final Context mContext, Long userId |
| 725 | , String name, int gradeId, long regionId, String regionName, Object schoolId, String chinese, | 725 | , String name, int gradeId, long regionId, String regionName, Object schoolId, String chinese, |
| 726 | String math, String english, String physics, String chemistry, | 726 | String math, String english, String physics, String chemistry, |
| 727 | String history, String geography, String political, String biology, String science, final Handler handler) { | 727 | String history, String geography, String political, String biology, String science, final Handler handler) { |
| 728 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 728 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
| 729 | false, true, null); | 729 | false, true, null); |
| 730 | RequestParams params = new RequestParams(); | 730 | RequestParams params = new RequestParams(); |
| 731 | 731 | ||
| 732 | params.put(HttpKey.USEID, userId); | 732 | params.put(HttpKey.USEID, userId); |
| 733 | params.put(HttpKey.NAME, name); | 733 | params.put(HttpKey.NAME, name); |
| 734 | params.put(HttpKey.GRADE, gradeId); | 734 | params.put(HttpKey.GRADE, gradeId); |
| 735 | params.put(HttpKey.REGION, regionId); | 735 | params.put(HttpKey.REGION, regionId); |
| 736 | params.put(HttpKey.SCHOOL, schoolId); | 736 | params.put(HttpKey.SCHOOL, schoolId); |
| 737 | params.put(HttpKey.REGIONNAME, regionName); | 737 | params.put(HttpKey.REGIONNAME, regionName); |
| 738 | params.put(HttpKey.MATH, math); | 738 | params.put(HttpKey.MATH, math); |
| 739 | params.put(HttpKey.ENGLISH, english); | 739 | params.put(HttpKey.ENGLISH, english); |
| 740 | params.put(HttpKey.CHINESE, chinese); | ||
| 740 | params.put(HttpKey.PHYSICES, physics); | 741 | params.put(HttpKey.PHYSICES, physics); |
| 741 | params.put(HttpKey.CHEMISTRY, chemistry); | 742 | params.put(HttpKey.CHEMISTRY, chemistry); |
| 742 | params.put(HttpKey.HISTIRY, history); | 743 | params.put(HttpKey.HISTIRY, history); |
| 743 | params.put(HttpKey.GEOGRAPHY, geography); | 744 | params.put(HttpKey.GEOGRAPHY, geography); |
| 744 | params.put(HttpKey.POLITICAL, political); | 745 | params.put(HttpKey.POLITICAL, political); |
| 745 | params.put(HttpKey.BIOLOGY, biology); | 746 | params.put(HttpKey.BIOLOGY, biology); |
| 746 | params.put(HttpKey.SCIENCE, science); | 747 | params.put(HttpKey.SCIENCE, science); |
| 747 | 748 | ||
| 748 | Log.e("test", "注册信息" + params); | 749 | Log.e("test", "注册信息" + params); |
| 749 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 750 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 750 | HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { | 751 | HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { |
| 751 | @Override | 752 | @Override |
| 752 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 753 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 753 | super.onSuccess(statusCode, headers, response); | 754 | super.onSuccess(statusCode, headers, response); |
| 754 | closeProgress(); | 755 | closeProgress(); |
| 755 | Message message = Message.obtain(); | 756 | Message message = Message.obtain(); |
| 756 | message.what = HttpCode.REGISTERINFO_SUCESS; | 757 | message.what = HttpCode.REGISTERINFO_SUCESS; |
| 757 | message.obj = new String(String.valueOf(response)); | 758 | message.obj = new String(String.valueOf(response)); |
| 758 | handler.sendMessage(message); | 759 | handler.sendMessage(message); |
| 759 | 760 | ||
| 760 | } | 761 | } |
| 761 | 762 | ||
| 762 | @Override | 763 | @Override |
| 763 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 764 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 764 | super.onFailure(statusCode, headers, throwable, errorResponse); | 765 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 765 | closeProgress(); | 766 | closeProgress(); |
| 766 | Log.e("test", "onFailure" + errorResponse); | 767 | Log.e("test", "onFailure" + errorResponse); |
| 767 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 768 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 768 | } | 769 | } |
| 769 | 770 | ||
| 770 | }); | 771 | }); |
| 771 | } | 772 | } |
| 772 | 773 | ||
| 773 | //修改版本信息 | 774 | //修改版本信息 |
| 774 | public void changepublishinfo(final Context mContext, String userId, String chinese, | 775 | public void changepublishinfo(final Context mContext, String userId, String chinese, |
| 775 | String math, String english, String physics, String chemistry, | 776 | String math, String english, String physics, String chemistry, |
| 776 | String history, String geography, String political, String biology, String science) { | 777 | String history, String geography, String political, String biology, String science) { |
| 777 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 778 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
| 778 | false, true, null); | 779 | false, true, null); |
| 779 | RequestParams params = new RequestParams(); | 780 | RequestParams params = new RequestParams(); |
| 780 | params.put(HttpKey.USEID, userId); | 781 | params.put(HttpKey.USEID, userId); |
| 781 | params.put(HttpKey.CHINESE, chinese); | 782 | params.put(HttpKey.CHINESE, chinese); |
| 782 | params.put(HttpKey.MATH, math); | 783 | params.put(HttpKey.MATH, math); |
| 783 | params.put(HttpKey.ENGLISH, english); | 784 | params.put(HttpKey.ENGLISH, english); |
| 784 | params.put(HttpKey.PHYSICES, physics); | 785 | params.put(HttpKey.PHYSICES, physics); |
| 785 | params.put(HttpKey.CHEMISTRY, chemistry); | 786 | params.put(HttpKey.CHEMISTRY, chemistry); |
| 786 | params.put(HttpKey.HISTIRY, history); | 787 | params.put(HttpKey.HISTIRY, history); |
| 787 | params.put(HttpKey.GEOGRAPHY, geography); | 788 | params.put(HttpKey.GEOGRAPHY, geography); |
| 788 | params.put(HttpKey.POLITICAL, political); | 789 | params.put(HttpKey.POLITICAL, political); |
| 789 | params.put(HttpKey.BIOLOGY, biology); | 790 | params.put(HttpKey.BIOLOGY, biology); |
| 790 | params.put(HttpKey.SCIENCE, science); | 791 | params.put(HttpKey.SCIENCE, science); |
| 791 | 792 | ||
| 792 | Log.e("test", "版本信息信息" + params); | 793 | Log.e("test", "版本信息信息" + params); |
| 793 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 794 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 794 | HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { | 795 | HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { |
| 795 | @Override | 796 | @Override |
| 796 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 797 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
| 797 | super.onSuccess(statusCode, headers, response); | 798 | super.onSuccess(statusCode, headers, response); |
| 798 | closeProgress(); | 799 | closeProgress(); |
| 799 | String status = response.optString("status"); | 800 | String status = response.optString("status"); |
| 800 | if (status.equals("1")) { | 801 | if (status.equals("1")) { |
| 801 | Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); | 802 | Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); |
| 802 | ((Activity) mContext).finish(); | 803 | ((Activity) mContext).finish(); |
| 803 | } else { | 804 | } else { |
| 804 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 805 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 805 | } | 806 | } |
| 806 | 807 | ||
| 807 | } | 808 | } |
| 808 | 809 | ||
| 809 | @Override | 810 | @Override |
| 810 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 811 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
| 811 | super.onFailure(statusCode, headers, throwable, errorResponse); | 812 | super.onFailure(statusCode, headers, throwable, errorResponse); |
| 812 | closeProgress(); | 813 | closeProgress(); |
| 813 | Log.e("test", "onFailure" + errorResponse); | 814 | Log.e("test", "onFailure" + errorResponse); |
| 814 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 815 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 815 | } | 816 | } |
| 816 | 817 | ||
| 817 | }); | 818 | }); |
| 818 | } | 819 | } |
| 819 | 820 | ||
| 820 | //修改个性签名 | 821 | //修改个性签名 |
| 821 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 822 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
| 822 | RequestParams params = new RequestParams(); | 823 | RequestParams params = new RequestParams(); |
| 823 | params.put("userId", userId); | 824 | params.put("userId", userId); |
| 824 | params.put("type", type); | 825 | params.put("type", type); |
| 825 | params.put("signature", signature); | 826 | params.put("signature", signature); |
| 826 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 827 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 827 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 828 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
| 828 | @Override | 829 | @Override |
| 829 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 830 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 830 | try { | 831 | try { |
| 831 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 832 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 832 | String status = jsonObject.optString("status"); | 833 | String status = jsonObject.optString("status"); |
| 833 | if (status.equals("1")) { | 834 | if (status.equals("1")) { |
| 834 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 835 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
| 835 | } else { | 836 | } else { |
| 836 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 837 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 837 | } | 838 | } |
| 838 | } catch (JSONException e) { | 839 | } catch (JSONException e) { |
| 839 | e.printStackTrace(); | 840 | e.printStackTrace(); |
| 840 | } | 841 | } |
| 841 | } | 842 | } |
| 842 | 843 | ||
| 843 | @Override | 844 | @Override |
| 844 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 845 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 845 | //Log.e("test", "onFailure" + new String(bytes)); | 846 | //Log.e("test", "onFailure" + new String(bytes)); |
| 846 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 847 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 847 | } | 848 | } |
| 848 | }); | 849 | }); |
| 849 | } | 850 | } |
| 850 | 851 | ||
| 851 | /** | 852 | /** |
| 852 | * 获取个性签名 | 853 | * 获取个性签名 |
| 853 | * | 854 | * |
| 854 | * @param mContext | 855 | * @param mContext |
| 855 | * @param userId | 856 | * @param userId |
| 856 | * @param handler | 857 | * @param handler |
| 857 | */ | 858 | */ |
| 858 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 859 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
| 859 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 860 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 860 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 861 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 861 | @Override | 862 | @Override |
| 862 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 863 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 863 | Log.e("test", "个性签名" + new String(arg2)); | 864 | Log.e("test", "个性签名" + new String(arg2)); |
| 864 | try { | 865 | try { |
| 865 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 866 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 866 | int status = jsonObject.optInt("status"); | 867 | int status = jsonObject.optInt("status"); |
| 867 | if (status == 1) { | 868 | if (status == 1) { |
| 868 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 869 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
| 869 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 870 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
| 870 | Message message = Message.obtain(); | 871 | Message message = Message.obtain(); |
| 871 | message.what = HttpCode.SIGN; | 872 | message.what = HttpCode.SIGN; |
| 872 | message.obj = signInfoBeanList; | 873 | message.obj = signInfoBeanList; |
| 873 | handler.sendMessage(message); | 874 | handler.sendMessage(message); |
| 874 | 875 | ||
| 875 | 876 | ||
| 876 | } else if (status == 1000) { | 877 | } else if (status == 1000) { |
| 877 | //AlertUtils.showToast(mContext, "您还没有签名哦"); | 878 | //AlertUtils.showToast(mContext, "您还没有签名哦"); |
| 878 | 879 | ||
| 879 | } else { | 880 | } else { |
| 880 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 881 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 881 | } | 882 | } |
| 882 | } catch (JSONException e) { | 883 | } catch (JSONException e) { |
| 883 | e.printStackTrace(); | 884 | e.printStackTrace(); |
| 884 | } | 885 | } |
| 885 | 886 | ||
| 886 | 887 | ||
| 887 | } | 888 | } |
| 888 | 889 | ||
| 889 | @Override | 890 | @Override |
| 890 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 891 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 891 | //Log.e("test", "失败原因" + arg3); | 892 | //Log.e("test", "失败原因" + arg3); |
| 892 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 893 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 893 | } | 894 | } |
| 894 | }); | 895 | }); |
| 895 | } | 896 | } |
| 896 | 897 | ||
| 897 | /** | 898 | /** |
| 898 | * 用户反馈 | 899 | * 用户反馈 |
| 899 | * | 900 | * |
| 900 | * @param mContext | 901 | * @param mContext |
| 901 | * @param userId | 902 | * @param userId |
| 902 | * @param content | 903 | * @param content |
| 903 | * @param contact | 904 | * @param contact |
| 904 | * @param imgs | 905 | * @param imgs |
| 905 | * @param feedtype | 906 | * @param feedtype |
| 906 | * @throws UnsupportedEncodingException | 907 | * @throws UnsupportedEncodingException |
| 907 | */ | 908 | */ |
| 908 | public void feedback(final Context mContext, String userId, String content, | 909 | public void feedback(final Context mContext, String userId, String content, |
| 909 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 910 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
| 910 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 911 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
| 911 | false, true, null); | 912 | false, true, null); |
| 912 | File file = new File(imgs); | 913 | File file = new File(imgs); |
| 913 | RequestParams params = new RequestParams(); | 914 | RequestParams params = new RequestParams(); |
| 914 | try { | 915 | try { |
| 915 | params.put("userId", userId); | 916 | params.put("userId", userId); |
| 916 | params.put("content", content); | 917 | params.put("content", content); |
| 917 | params.put("contact", contact); | 918 | params.put("contact", contact); |
| 918 | if (file.exists() && file.length() > 0) { | 919 | if (file.exists() && file.length() > 0) { |
| 919 | params.put("imgs", file); | 920 | params.put("imgs", file); |
| 920 | } | 921 | } |
| 921 | params.put("feedtype", feedtype); | 922 | params.put("feedtype", feedtype); |
| 922 | } catch (FileNotFoundException e) { | 923 | } catch (FileNotFoundException e) { |
| 923 | e.printStackTrace(); | 924 | e.printStackTrace(); |
| 924 | } | 925 | } |
| 925 | Log.e("test", "onSuccess" + params); | 926 | Log.e("test", "onSuccess" + params); |
| 926 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 927 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
| 927 | @Override | 928 | @Override |
| 928 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 929 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 929 | closeProgress(); | 930 | closeProgress(); |
| 930 | Log.e("test", "onSuccess" + new String(bytes)); | 931 | Log.e("test", "onSuccess" + new String(bytes)); |
| 931 | try { | 932 | try { |
| 932 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 933 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 933 | String status = jsonObject.optString("status"); | 934 | String status = jsonObject.optString("status"); |
| 934 | if (status.equals("1")) { | 935 | if (status.equals("1")) { |
| 935 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 936 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
| 936 | ((Activity) mContext).finish(); | 937 | ((Activity) mContext).finish(); |
| 937 | } else { | 938 | } else { |
| 938 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 939 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 939 | } | 940 | } |
| 940 | } catch (JSONException e) { | 941 | } catch (JSONException e) { |
| 941 | e.printStackTrace(); | 942 | e.printStackTrace(); |
| 942 | } | 943 | } |
| 943 | } | 944 | } |
| 944 | 945 | ||
| 945 | @Override | 946 | @Override |
| 946 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 947 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 947 | closeProgress(); | 948 | closeProgress(); |
| 948 | //Log.e("test", "错误信息" + new String(bytes)); | 949 | //Log.e("test", "错误信息" + new String(bytes)); |
| 949 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 950 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 950 | 951 | ||
| 951 | } | 952 | } |
| 952 | }); | 953 | }); |
| 953 | 954 | ||
| 954 | } | 955 | } |
| 955 | 956 | ||
| 956 | /** | 957 | /** |
| 957 | * 查询子账户信息 | 958 | * 查询子账户信息 |
| 958 | * | 959 | * |
| 959 | * @param mContext | 960 | * @param mContext |
| 960 | * @param userId | 961 | * @param userId |
| 961 | * @param handler | 962 | * @param handler |
| 962 | */ | 963 | */ |
| 963 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 964 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
| 964 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...", | 965 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...", |
| 965 | false, true, null); | 966 | false, true, null); |
| 966 | 967 | ||
| 967 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 968 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
| 968 | HttpClient.getInstance().setTimeout(5 * 1000); | 969 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 969 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 970 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 970 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 971 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
| 971 | @Override | 972 | @Override |
| 972 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 973 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 973 | closeProgress(); | 974 | closeProgress(); |
| 974 | Log.e("test", "子账户信息" + new String(arg2)); | 975 | Log.e("test", "子账户信息" + new String(arg2)); |
| 975 | try { | 976 | try { |
| 976 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 977 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 977 | int status = jsonObject.optInt("status"); | 978 | int status = jsonObject.optInt("status"); |
| 978 | if (status == 1) { | 979 | if (status == 1) { |
| 979 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 980 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
| 980 | Log.e("test", "子账户信息" + childsInfo); | 981 | Log.e("test", "子账户信息" + childsInfo); |
| 981 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 982 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
| 982 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 983 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
| 983 | Message msg = Message.obtain(); | 984 | Message msg = Message.obtain(); |
| 984 | msg.what = HttpCode.CHILDS_SUCESS; | 985 | msg.what = HttpCode.CHILDS_SUCESS; |
| 985 | msg.obj = schoolInfoBeanList; | 986 | msg.obj = schoolInfoBeanList; |
| 986 | handler.sendMessage(msg); | 987 | handler.sendMessage(msg); |
| 987 | 988 | ||
| 988 | } else { | 989 | } else { |
| 989 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 990 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
| 990 | 991 | ||
| 991 | } | 992 | } |
| 992 | } catch (JSONException e) { | 993 | } catch (JSONException e) { |
| 993 | e.printStackTrace(); | 994 | e.printStackTrace(); |
| 994 | 995 | ||
| 995 | } | 996 | } |
| 996 | 997 | ||
| 997 | } | 998 | } |
| 998 | 999 | ||
| 999 | @Override | 1000 | @Override |
| 1000 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1001 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1001 | closeProgress(); | 1002 | closeProgress(); |
| 1002 | // Log.e("test", "错误信息" + new String(arg2)); | 1003 | // Log.e("test", "错误信息" + new String(arg2)); |
| 1003 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1004 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1004 | } | 1005 | } |
| 1005 | }); | 1006 | }); |
| 1006 | 1007 | ||
| 1007 | } | 1008 | } |
| 1008 | 1009 | ||
| 1009 | /** | 1010 | /** |
| 1010 | * 删除子账户信息 | 1011 | * 删除子账户信息 |
| 1011 | * | 1012 | * |
| 1012 | * @param mContext | 1013 | * @param mContext |
| 1013 | * @param subAccountId | 1014 | * @param subAccountId |
| 1014 | */ | 1015 | */ |
| 1015 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 1016 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
| 1016 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 1017 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
| 1017 | false, true, null); | 1018 | false, true, null); |
| 1018 | HttpClient.getInstance().setTimeout(5 * 1000); | 1019 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1019 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1020 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1020 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 1021 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
| 1021 | @Override | 1022 | @Override |
| 1022 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1023 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1023 | closeProgress(); | 1024 | closeProgress(); |
| 1024 | Log.e("test", "子账户信息" + new String(arg2)); | 1025 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1025 | try { | 1026 | try { |
| 1026 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1027 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1027 | int status = jsonObject.optInt("status"); | 1028 | int status = jsonObject.optInt("status"); |
| 1028 | if (status == 1) { | 1029 | if (status == 1) { |
| 1029 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 1030 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
| 1030 | ((Activity) mContext).finish(); | 1031 | ((Activity) mContext).finish(); |
| 1031 | } else { | 1032 | } else { |
| 1032 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 1033 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
| 1033 | 1034 | ||
| 1034 | } | 1035 | } |
| 1035 | } catch (JSONException e) { | 1036 | } catch (JSONException e) { |
| 1036 | e.printStackTrace(); | 1037 | e.printStackTrace(); |
| 1037 | } | 1038 | } |
| 1038 | 1039 | ||
| 1039 | } | 1040 | } |
| 1040 | 1041 | ||
| 1041 | @Override | 1042 | @Override |
| 1042 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1043 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1043 | closeProgress(); | 1044 | closeProgress(); |
| 1044 | Log.e("test", "错误信息" + new String(arg2)); | 1045 | Log.e("test", "错误信息" + new String(arg2)); |
| 1045 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1046 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1046 | } | 1047 | } |
| 1047 | }); | 1048 | }); |
| 1048 | 1049 | ||
| 1049 | } | 1050 | } |
| 1050 | 1051 | ||
| 1051 | /** | 1052 | /** |
| 1052 | * 添加子账户信息 | 1053 | * 添加子账户信息 |
| 1053 | */ | 1054 | */ |
| 1054 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 1055 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
| 1055 | String name, final Long grade, Object school, Long region | 1056 | String name, final Long grade, Object school, Long region |
| 1056 | , String deviceNumber, String regionName) { | 1057 | , String deviceNumber, String regionName) { |
| 1057 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 1058 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
| 1058 | false, true, null); | 1059 | false, true, null); |
| 1059 | RequestParams params = new RequestParams(); | 1060 | RequestParams params = new RequestParams(); |
| 1060 | 1061 | ||
| 1061 | params.put(HttpKey.PARENTID, parentId); | 1062 | params.put(HttpKey.PARENTID, parentId); |
| 1062 | params.put(HttpKey.IMAGE, image); | 1063 | params.put(HttpKey.IMAGE, image); |
| 1063 | params.put(HttpKey.NAME, name); | 1064 | params.put(HttpKey.NAME, name); |
| 1064 | params.put(HttpKey.GRADE, grade); | 1065 | params.put(HttpKey.GRADE, grade); |
| 1065 | params.put(HttpKey.SCHOOL, school); | 1066 | params.put(HttpKey.SCHOOL, school); |
| 1066 | params.put(HttpKey.REGION, region); | 1067 | params.put(HttpKey.REGION, region); |
| 1067 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 1068 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
| 1068 | params.put(HttpKey.REGIONNAME, regionName); | 1069 | params.put(HttpKey.REGIONNAME, regionName); |
| 1069 | 1070 | ||
| 1070 | Log.e("test", "子账户信息" + params); | 1071 | Log.e("test", "子账户信息" + params); |
| 1071 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 1072 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
| 1072 | HttpClient.getInstance().setTimeout(5 * 1000); | 1073 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1073 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1074 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1074 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 1075 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
| 1075 | @Override | 1076 | @Override |
| 1076 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1077 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1077 | closeProgress(); | 1078 | closeProgress(); |
| 1078 | 1079 | ||
| 1079 | Log.e("test", "子账户信息" + new String(arg2)); | 1080 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1080 | try { | 1081 | try { |
| 1081 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1082 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1082 | int status = jsonObject.optInt("status"); | 1083 | int status = jsonObject.optInt("status"); |
| 1083 | if (status == 1) { | 1084 | if (status == 1) { |
| 1084 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 1085 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
| 1085 | ((Activity) mContext).finish(); | 1086 | ((Activity) mContext).finish(); |
| 1086 | } else { | 1087 | } else { |
| 1087 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 1088 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
| 1088 | 1089 | ||
| 1089 | } | 1090 | } |
| 1090 | } catch (JSONException e) { | 1091 | } catch (JSONException e) { |
| 1091 | e.printStackTrace(); | 1092 | e.printStackTrace(); |
| 1092 | } | 1093 | } |
| 1093 | 1094 | ||
| 1094 | } | 1095 | } |
| 1095 | 1096 | ||
| 1096 | @Override | 1097 | @Override |
| 1097 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1098 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1098 | closeProgress(); | 1099 | closeProgress(); |
| 1099 | Log.e("test", "错误信息" + new String(arg2)); | 1100 | Log.e("test", "错误信息" + new String(arg2)); |
| 1100 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1101 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1101 | } | 1102 | } |
| 1102 | }); | 1103 | }); |
| 1103 | 1104 | ||
| 1104 | } | 1105 | } |
| 1105 | 1106 | ||
| 1106 | /** | 1107 | /** |
| 1107 | * 切换子账户信息 | 1108 | * 切换子账户信息 |
| 1108 | * | 1109 | * |
| 1109 | * @param mContext | 1110 | * @param mContext |
| 1110 | * @param subAccountId | 1111 | * @param subAccountId |
| 1111 | */ | 1112 | */ |
| 1112 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 1113 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
| 1113 | , String deviceNumber, int type) { | 1114 | , String deviceNumber, int type) { |
| 1114 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1115 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
| 1115 | false, true, null); | 1116 | false, true, null); |
| 1116 | HttpClient.getInstance().setTimeout(5 * 1000); | 1117 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1117 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1118 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1118 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 1119 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
| 1119 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 1120 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
| 1120 | @Override | 1121 | @Override |
| 1121 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1122 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1122 | closeProgress(); | 1123 | closeProgress(); |
| 1123 | Log.e("test", "子账户信息" + new String(arg2)); | 1124 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1124 | try { | 1125 | try { |
| 1125 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1126 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1126 | int status = jsonObject.optInt("status"); | 1127 | int status = jsonObject.optInt("status"); |
| 1127 | if (status == 1) { | 1128 | if (status == 1) { |
| 1128 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 1129 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
| 1129 | ((Activity) mContext).finish(); | 1130 | ((Activity) mContext).finish(); |
| 1130 | 1131 | ||
| 1131 | } else { | 1132 | } else { |
| 1132 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 1133 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
| 1133 | 1134 | ||
| 1134 | } | 1135 | } |
| 1135 | } catch (JSONException e) { | 1136 | } catch (JSONException e) { |
| 1136 | e.printStackTrace(); | 1137 | e.printStackTrace(); |
| 1137 | } | 1138 | } |
| 1138 | 1139 | ||
| 1139 | } | 1140 | } |
| 1140 | 1141 | ||
| 1141 | @Override | 1142 | @Override |
| 1142 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1143 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1143 | closeProgress(); | 1144 | closeProgress(); |
| 1144 | //Log.e("test", "错误信息" + new String(arg2)); | 1145 | //Log.e("test", "错误信息" + new String(arg2)); |
| 1145 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1146 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1146 | } | 1147 | } |
| 1147 | }); | 1148 | }); |
| 1148 | 1149 | ||
| 1149 | } | 1150 | } |
| 1150 | 1151 | ||
| 1151 | /** | 1152 | /** |
| 1152 | * 切换主账户信息 | 1153 | * 切换主账户信息 |
| 1153 | * | 1154 | * |
| 1154 | * @param mContext | 1155 | * @param mContext |
| 1155 | * @param type | 1156 | * @param type |
| 1156 | */ | 1157 | */ |
| 1157 | public void Accountinfo(final Context mContext, long userId | 1158 | public void Accountinfo(final Context mContext, long userId |
| 1158 | , String deviceNumber, int type) { | 1159 | , String deviceNumber, int type) { |
| 1159 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 1160 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
| 1160 | false, true, null); | 1161 | false, true, null); |
| 1161 | HttpClient.getInstance().setTimeout(5 * 1000); | 1162 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1162 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1163 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1163 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 1164 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
| 1164 | + "&type=" + type, new AsyncHttpResponseHandler() { | 1165 | + "&type=" + type, new AsyncHttpResponseHandler() { |
| 1165 | @Override | 1166 | @Override |
| 1166 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1167 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1167 | closeProgress(); | 1168 | closeProgress(); |
| 1168 | Log.e("test", "子账户信息" + new String(arg2)); | 1169 | Log.e("test", "子账户信息" + new String(arg2)); |
| 1169 | try { | 1170 | try { |
| 1170 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1171 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1171 | int status = jsonObject.optInt("status"); | 1172 | int status = jsonObject.optInt("status"); |
| 1172 | if (status == 1) { | 1173 | if (status == 1) { |
| 1173 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1174 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
| 1174 | ((Activity) mContext).finish(); | 1175 | ((Activity) mContext).finish(); |
| 1175 | 1176 | ||
| 1176 | } else { | 1177 | } else { |
| 1177 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1178 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
| 1178 | 1179 | ||
| 1179 | } | 1180 | } |
| 1180 | } catch (JSONException e) { | 1181 | } catch (JSONException e) { |
| 1181 | e.printStackTrace(); | 1182 | e.printStackTrace(); |
| 1182 | } | 1183 | } |
| 1183 | 1184 | ||
| 1184 | } | 1185 | } |
| 1185 | 1186 | ||
| 1186 | @Override | 1187 | @Override |
| 1187 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1188 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1188 | closeProgress(); | 1189 | closeProgress(); |
| 1189 | Log.e("test", "错误信息" + new String(arg2)); | 1190 | Log.e("test", "错误信息" + new String(arg2)); |
| 1190 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1191 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1191 | } | 1192 | } |
| 1192 | }); | 1193 | }); |
| 1193 | 1194 | ||
| 1194 | } | 1195 | } |
| 1195 | 1196 | ||
| 1196 | /** | 1197 | /** |
| 1197 | * 头像拍张 | 1198 | * 头像拍张 |
| 1198 | * | 1199 | * |
| 1199 | * @param mContext | 1200 | * @param mContext |
| 1200 | * @param userId | 1201 | * @param userId |
| 1201 | * @param img | 1202 | * @param img |
| 1202 | * @throws UnsupportedEncodingException | 1203 | * @throws UnsupportedEncodingException |
| 1203 | */ | 1204 | */ |
| 1204 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 1205 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
| 1205 | File file = new File(img); | 1206 | File file = new File(img); |
| 1206 | if (file.exists() && file.length() > 0) { | 1207 | if (file.exists() && file.length() > 0) { |
| 1207 | RequestParams params = new RequestParams(); | 1208 | RequestParams params = new RequestParams(); |
| 1208 | try { | 1209 | try { |
| 1209 | params.put("userId", userId); | 1210 | params.put("userId", userId); |
| 1210 | params.put("type", type); | 1211 | params.put("type", type); |
| 1211 | params.put("img", file); | 1212 | params.put("img", file); |
| 1212 | } catch (FileNotFoundException e) { | 1213 | } catch (FileNotFoundException e) { |
| 1213 | e.printStackTrace(); | 1214 | e.printStackTrace(); |
| 1214 | } | 1215 | } |
| 1215 | Log.e("test", "params" + params); | 1216 | Log.e("test", "params" + params); |
| 1216 | HttpClient.getInstance().setTimeout(5 * 1000); | 1217 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1217 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1218 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
| 1218 | @Override | 1219 | @Override |
| 1219 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1220 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1220 | Log.e("test", "onSuccess" + new String(bytes)); | 1221 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1221 | try { | 1222 | try { |
| 1222 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1223 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 1223 | String status = jsonObject.optString("status"); | 1224 | String status = jsonObject.optString("status"); |
| 1224 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); | 1225 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); |
| 1225 | String imagUrl = jsonObject1.optString("imgUrl"); | 1226 | String imagUrl = jsonObject1.optString("imgUrl"); |
| 1226 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); | 1227 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); |
| 1227 | if (status.equals("1")) { | 1228 | if (status.equals("1")) { |
| 1228 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1229 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
| 1229 | } else { | 1230 | } else { |
| 1230 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1231 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 1231 | } | 1232 | } |
| 1232 | } catch (JSONException e) { | 1233 | } catch (JSONException e) { |
| 1233 | e.printStackTrace(); | 1234 | e.printStackTrace(); |
| 1234 | } | 1235 | } |
| 1235 | } | 1236 | } |
| 1236 | 1237 | ||
| 1237 | @Override | 1238 | @Override |
| 1238 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1239 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 1239 | closeProgress(); | 1240 | closeProgress(); |
| 1240 | Log.e("test", "错误信息" + new String(bytes)); | 1241 | Log.e("test", "错误信息" + new String(bytes)); |
| 1241 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1242 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1242 | 1243 | ||
| 1243 | } | 1244 | } |
| 1244 | }); | 1245 | }); |
| 1245 | } else { | 1246 | } else { |
| 1246 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1247 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
| 1247 | } | 1248 | } |
| 1248 | } | 1249 | } |
| 1249 | 1250 | ||
| 1250 | /** | 1251 | /** |
| 1251 | * 头像默认 | 1252 | * 头像默认 |
| 1252 | * | 1253 | * |
| 1253 | * @param mContext | 1254 | * @param mContext |
| 1254 | * @param userId | 1255 | * @param userId |
| 1255 | * @param | 1256 | * @param |
| 1256 | * @throws UnsupportedEncodingException | 1257 | * @throws UnsupportedEncodingException |
| 1257 | */ | 1258 | */ |
| 1258 | public void headerdeft(final Context mContext, String userId, String type, String defaultImg) throws UnsupportedEncodingException { | 1259 | public void headerdeft(final Context mContext, String userId, String type, String defaultImg) throws UnsupportedEncodingException { |
| 1259 | RequestParams params = new RequestParams(); | 1260 | RequestParams params = new RequestParams(); |
| 1260 | params.put("userId", userId); | 1261 | params.put("userId", userId); |
| 1261 | params.put("type", type); | 1262 | params.put("type", type); |
| 1262 | params.put("defaultImg", defaultImg); | 1263 | params.put("defaultImg", defaultImg); |
| 1263 | Log.e("test", "params" + params); | 1264 | Log.e("test", "params" + params); |
| 1264 | HttpClient.getInstance().setTimeout(5 * 1000); | 1265 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1265 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | 1266 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { |
| 1266 | @Override | 1267 | @Override |
| 1267 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1268 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
| 1268 | Log.e("test", "onSuccess" + new String(bytes)); | 1269 | Log.e("test", "onSuccess" + new String(bytes)); |
| 1269 | try { | 1270 | try { |
| 1270 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1271 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
| 1271 | String status = jsonObject.optString("status"); | 1272 | String status = jsonObject.optString("status"); |
| 1272 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); | 1273 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); |
| 1273 | String imagUrl = jsonObject1.optString("imgUrl"); | 1274 | String imagUrl = jsonObject1.optString("imgUrl"); |
| 1274 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); | 1275 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); |
| 1275 | if (status.equals("1")) { | 1276 | if (status.equals("1")) { |
| 1276 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1277 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
| 1277 | } else { | 1278 | } else { |
| 1278 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1279 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
| 1279 | } | 1280 | } |
| 1280 | } catch (JSONException e) { | 1281 | } catch (JSONException e) { |
| 1281 | e.printStackTrace(); | 1282 | e.printStackTrace(); |
| 1282 | } | 1283 | } |
| 1283 | } | 1284 | } |
| 1284 | 1285 | ||
| 1285 | @Override | 1286 | @Override |
| 1286 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1287 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
| 1287 | closeProgress(); | 1288 | closeProgress(); |
| 1288 | Log.e("test", "错误信息" + new String(bytes)); | 1289 | Log.e("test", "错误信息" + new String(bytes)); |
| 1289 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1290 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1290 | 1291 | ||
| 1291 | } | 1292 | } |
| 1292 | }); | 1293 | }); |
| 1293 | } | 1294 | } |
| 1294 | 1295 | ||
| 1295 | /** | 1296 | /** |
| 1296 | * 检查注册信息是否完整 | 1297 | * 检查注册信息是否完整 |
| 1297 | * | 1298 | * |
| 1298 | * @param mContext | 1299 | * @param mContext |
| 1299 | * @param userId | 1300 | * @param userId |
| 1300 | */ | 1301 | */ |
| 1301 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { | 1302 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { |
| 1302 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", | 1303 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", |
| 1303 | false, true, null); | 1304 | false, true, null); |
| 1304 | HttpClient.getInstance().setTimeout(5 * 1000); | 1305 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1305 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1306 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1306 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId, new AsyncHttpResponseHandler() { | 1307 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId, new AsyncHttpResponseHandler() { |
| 1307 | @Override | 1308 | @Override |
| 1308 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1309 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1309 | closeProgress(); | 1310 | closeProgress(); |
| 1310 | Log.e("test", "注册信息" + new String(arg2)); | 1311 | Log.e("test", "注册信息" + new String(arg2)); |
| 1311 | Message msg = Message.obtain(); | 1312 | Message msg = Message.obtain(); |
| 1312 | msg.what = HttpCode.REGISTER_SUCESS; | 1313 | msg.what = HttpCode.REGISTER_SUCESS; |
| 1313 | msg.obj = new String(arg2); | 1314 | msg.obj = new String(arg2); |
| 1314 | handler.sendMessage(msg); | 1315 | handler.sendMessage(msg); |
| 1315 | 1316 | ||
| 1316 | } | 1317 | } |
| 1317 | 1318 | ||
| 1318 | @Override | 1319 | @Override |
| 1319 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1320 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1320 | closeProgress(); | 1321 | closeProgress(); |
| 1321 | // Log.e("test", "错误信息" + new String(arg2)); | 1322 | // Log.e("test", "错误信息" + new String(arg2)); |
| 1322 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1323 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1323 | 1324 | ||
| 1324 | } | 1325 | } |
| 1325 | }); | 1326 | }); |
| 1326 | 1327 | ||
| 1327 | } | 1328 | } |
| 1328 | 1329 | ||
| 1329 | /** | 1330 | /** |
| 1330 | * 获取最近学习视频 | 1331 | * 获取最近学习视频 |
| 1331 | * | 1332 | * |
| 1332 | * @param mContext | 1333 | * @param mContext |
| 1333 | * @param userId | 1334 | * @param userId |
| 1334 | */ | 1335 | */ |
| 1335 | public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { | 1336 | public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { |
| 1336 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", | 1337 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", |
| 1337 | false, true, null); | 1338 | false, true, null); |
| 1338 | HttpClient.getInstance().setTimeout(5 * 1000); | 1339 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1339 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1340 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1340 | HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId, new AsyncHttpResponseHandler() { | 1341 | HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId, new AsyncHttpResponseHandler() { |
| 1341 | @Override | 1342 | @Override |
| 1342 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1343 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1343 | closeProgress(); | 1344 | closeProgress(); |
| 1344 | Log.e("test", "近学习视频" + new String(arg2)); | 1345 | Log.e("test", "近学习视频" + new String(arg2)); |
| 1345 | try { | 1346 | try { |
| 1346 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1347 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1347 | int status = jsonObject.optInt("status"); | 1348 | int status = jsonObject.optInt("status"); |
| 1348 | if (status == 1) { | 1349 | if (status == 1) { |
| 1349 | VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 | 1350 | VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 |
| 1350 | List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); | 1351 | List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); |
| 1351 | Message msg = Message.obtain(); | 1352 | Message msg = Message.obtain(); |
| 1352 | msg.what = HttpCode.GETVIDIO_SUCESS; | 1353 | msg.what = HttpCode.GETVIDIO_SUCESS; |
| 1353 | msg.obj = schoolInfoBeanList; | 1354 | msg.obj = schoolInfoBeanList; |
| 1354 | handler.sendMessage(msg); | 1355 | handler.sendMessage(msg); |
| 1355 | 1356 | ||
| 1356 | } else { | 1357 | } else { |
| 1357 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 1358 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
| 1358 | 1359 | ||
| 1359 | } | 1360 | } |
| 1360 | } catch (JSONException e) { | 1361 | } catch (JSONException e) { |
| 1361 | e.printStackTrace(); | 1362 | e.printStackTrace(); |
| 1362 | 1363 | ||
| 1363 | } | 1364 | } |
| 1364 | 1365 | ||
| 1365 | } | 1366 | } |
| 1366 | 1367 | ||
| 1367 | @Override | 1368 | @Override |
| 1368 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1369 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1369 | closeProgress(); | 1370 | closeProgress(); |
| 1370 | // Log.e("test", "错误信息" + new String(arg2)); | 1371 | // Log.e("test", "错误信息" + new String(arg2)); |
| 1371 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1372 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1372 | 1373 | ||
| 1373 | } | 1374 | } |
| 1374 | }); | 1375 | }); |
| 1375 | 1376 | ||
| 1376 | } | 1377 | } |
| 1377 | 1378 | ||
| 1378 | 1379 | ||
| 1379 | /** | 1380 | /** |
| 1380 | * 系统升级 | 1381 | * 系统升级 |
| 1381 | * | 1382 | * |
| 1382 | * @param mContext | 1383 | * @param mContext |
| 1383 | * @param pid appName | 1384 | * @param pid appName |
| 1384 | */ | 1385 | */ |
| 1385 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1386 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
| 1386 | // mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", | 1387 | // mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", |
| 1387 | // false, true, null); | 1388 | // false, true, null); |
| 1388 | HttpClient.getInstance().setTimeout(5 * 1000); | 1389 | HttpClient.getInstance().setTimeout(5 * 1000); |
| 1389 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1390 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1390 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1391 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
| 1391 | @Override | 1392 | @Override |
| 1392 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1393 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1393 | //closeProgress(); | 1394 | //closeProgress(); |
| 1394 | Log.e("test", "版本升级信息" + new String(arg2)); | 1395 | Log.e("test", "版本升级信息" + new String(arg2)); |
| 1395 | Gson gson = new Gson(); | 1396 | Gson gson = new Gson(); |
| 1396 | List<AppVersion> applist = gson.fromJson(new String(arg2), | 1397 | List<AppVersion> applist = gson.fromJson(new String(arg2), |
| 1397 | new TypeToken<List<AppVersion>>() {}.getType()); | 1398 | new TypeToken<List<AppVersion>>() {}.getType()); |
| 1398 | Log.e("test", "版本升级信息" + applist); | 1399 | Log.e("test", "版本升级信息" + applist); |
| 1399 | Message msg = Message.obtain(); | 1400 | Message msg = Message.obtain(); |
| 1400 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1401 | msg.what = HttpCode.APPUPDATE_SUCESS; |
| 1401 | msg.obj = applist; | 1402 | msg.obj = applist; |
| 1402 | handler.sendMessage(msg); | 1403 | handler.sendMessage(msg); |
| 1403 | 1404 | ||
| 1404 | 1405 | ||
| 1405 | 1406 | ||
| 1406 | } | 1407 | } |
| 1407 | 1408 | ||
| 1408 | @Override | 1409 | @Override |
| 1409 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1410 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1410 | //closeProgress(); | 1411 | //closeProgress(); |
| 1411 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1412 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1412 | } | 1413 | } |
| 1413 | }); | 1414 | }); |
| 1414 | 1415 | ||
| 1415 | } | 1416 | } |
| 1416 | 1417 | ||
| 1417 | //版本信息 | 1418 | //版本信息 |
| 1418 | public void versioninfo(final Context mContext, String subjectName, final Handler handler) { | 1419 | public void versioninfo(final Context mContext, String subjectName, final Handler handler) { |
| 1419 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1420 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1420 | HttpClient.getInstance().get(HttpUrl.getversionURL + "?subjectName=" + subjectName, new AsyncHttpResponseHandler() { | 1421 | HttpClient.getInstance().get(HttpUrl.getversionURL + "?subjectName=" + subjectName, new AsyncHttpResponseHandler() { |
| 1421 | @Override | 1422 | @Override |
| 1422 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1423 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1423 | Log.e("test", "版本信息" + new String(arg2)); | 1424 | Log.e("test", "版本信息" + new String(arg2)); |
| 1424 | try { | 1425 | try { |
| 1425 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1426 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1426 | int status = jsonObject.optInt("status"); | 1427 | int status = jsonObject.optInt("status"); |
| 1427 | if (status == 1) { | 1428 | if (status == 1) { |
| 1428 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 | 1429 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 |
| 1429 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); | 1430 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); |
| 1430 | Message message = Message.obtain(); | 1431 | Message message = Message.obtain(); |
| 1431 | message.what = HttpCode.VERSION_SUCESS; | 1432 | message.what = HttpCode.VERSION_SUCESS; |
| 1432 | message.obj = versionInfoList; | 1433 | message.obj = versionInfoList; |
| 1433 | handler.sendMessage(message); | 1434 | handler.sendMessage(message); |
| 1434 | 1435 | ||
| 1435 | } else if (status == 1000) { | 1436 | } else if (status == 1000) { |
| 1436 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); | 1437 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); |
| 1437 | 1438 | ||
| 1438 | } else { | 1439 | } else { |
| 1439 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1440 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1440 | } | 1441 | } |
| 1441 | } catch (JSONException e) { | 1442 | } catch (JSONException e) { |
| 1442 | e.printStackTrace(); | 1443 | e.printStackTrace(); |
| 1443 | } | 1444 | } |
| 1444 | 1445 | ||
| 1445 | 1446 | ||
| 1446 | } | 1447 | } |
| 1447 | 1448 | ||
| 1448 | @Override | 1449 | @Override |
| 1449 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1450 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1450 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1451 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1451 | } | 1452 | } |
| 1452 | }); | 1453 | }); |
| 1453 | } | 1454 | } |
| 1454 | 1455 | ||
| 1455 | 1456 | ||
| 1456 | ///省级接口 | 1457 | ///省级接口 |
| 1457 | public void provices(final Context mContext, final Handler handler) { | 1458 | public void provices(final Context mContext, final Handler handler) { |
| 1458 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1459 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1459 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1460 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
| 1460 | @Override | 1461 | @Override |
| 1461 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1462 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1462 | Log.e("test", "省" + new String(arg2)); | 1463 | Log.e("test", "省" + new String(arg2)); |
| 1463 | try { | 1464 | try { |
| 1464 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1465 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1465 | int status = jsonObject.optInt("status"); | 1466 | int status = jsonObject.optInt("status"); |
| 1466 | if (status == 100) { | 1467 | if (status == 100) { |
| 1467 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1468 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
| 1468 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1469 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
| 1469 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1470 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
| 1470 | Message message = Message.obtain(); | 1471 | Message message = Message.obtain(); |
| 1471 | message.what = HttpCode.PROVICES; | 1472 | message.what = HttpCode.PROVICES; |
| 1472 | message.obj = provincesBeanList; | 1473 | message.obj = provincesBeanList; |
| 1473 | handler.sendMessage(message); | 1474 | handler.sendMessage(message); |
| 1474 | 1475 | ||
| 1475 | 1476 | ||
| 1476 | } else { | 1477 | } else { |
| 1477 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1478 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1478 | 1479 | ||
| 1479 | } | 1480 | } |
| 1480 | } catch (JSONException e) { | 1481 | } catch (JSONException e) { |
| 1481 | e.printStackTrace(); | 1482 | e.printStackTrace(); |
| 1482 | } | 1483 | } |
| 1483 | 1484 | ||
| 1484 | 1485 | ||
| 1485 | } | 1486 | } |
| 1486 | 1487 | ||
| 1487 | @Override | 1488 | @Override |
| 1488 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1489 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1489 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1490 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1490 | } | 1491 | } |
| 1491 | }); | 1492 | }); |
| 1492 | } | 1493 | } |
| 1493 | 1494 | ||
| 1494 | //获取版本信息接口 | 1495 | //获取版本信息接口 |
| 1495 | public void getpublishinfo(final Context mContext, Object userId, int gradeId, int type, final Handler handler) { | 1496 | public void getpublishinfo(final Context mContext, Object userId, int gradeId, int type, final Handler handler) { |
| 1496 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1497 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1497 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId + "&gradeId=" + gradeId + "&type=" + type, new AsyncHttpResponseHandler() { | 1498 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId + "&gradeId=" + gradeId + "&type=" + type, new AsyncHttpResponseHandler() { |
| 1498 | @Override | 1499 | @Override |
| 1499 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1500 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1500 | Log.e("test", "获取版本信息接口" + new String(arg2)); | 1501 | Log.e("test", "获取版本信息接口" + new String(arg2)); |
| 1501 | try { | 1502 | try { |
| 1502 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1503 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1503 | int status = jsonObject.optInt("status"); | 1504 | int status = jsonObject.optInt("status"); |
| 1504 | if (status == 1) { | 1505 | if (status == 1) { |
| 1505 | Gson gson = new Gson(); | 1506 | Gson gson = new Gson(); |
| 1506 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); | 1507 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); |
| 1507 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); | 1508 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); |
| 1508 | Message message = Message.obtain(); | 1509 | Message message = Message.obtain(); |
| 1509 | message.what = HttpCode.PUBLISH_SUCESS; | 1510 | message.what = HttpCode.PUBLISH_SUCESS; |
| 1510 | message.obj = defautPublishInfoBeanList; | 1511 | message.obj = defautPublishInfoBeanList; |
| 1511 | handler.sendMessage(message); | 1512 | handler.sendMessage(message); |
| 1512 | 1513 | ||
| 1513 | } else { | 1514 | } else { |
| 1514 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1515 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1515 | 1516 | ||
| 1516 | } | 1517 | } |
| 1517 | } catch (JSONException e) { | 1518 | } catch (JSONException e) { |
| 1518 | e.printStackTrace(); | 1519 | e.printStackTrace(); |
| 1519 | } | 1520 | } |
| 1520 | 1521 | ||
| 1521 | 1522 | ||
| 1522 | } | 1523 | } |
| 1523 | 1524 | ||
| 1524 | @Override | 1525 | @Override |
| 1525 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1526 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1526 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1527 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1527 | } | 1528 | } |
| 1528 | }); | 1529 | }); |
| 1529 | } | 1530 | } |
| 1530 | 1531 | ||
| 1531 | 1532 | ||
| 1532 | //市级接口 | 1533 | //市级接口 |
| 1533 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1534 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
| 1534 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1535 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1535 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1536 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
| 1536 | @Override | 1537 | @Override |
| 1537 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1538 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1538 | Log.e("test", "市" + new String(arg2)); | 1539 | Log.e("test", "市" + new String(arg2)); |
| 1539 | try { | 1540 | try { |
| 1540 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1541 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1541 | int status = jsonObject.optInt("status"); | 1542 | int status = jsonObject.optInt("status"); |
| 1542 | if (status == 100) { | 1543 | if (status == 100) { |
| 1543 | Gson gson = new Gson(); | 1544 | Gson gson = new Gson(); |
| 1544 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1545 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
| 1545 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1546 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
| 1546 | Message message = Message.obtain(); | 1547 | Message message = Message.obtain(); |
| 1547 | message.what = HttpCode.CITYS; | 1548 | message.what = HttpCode.CITYS; |
| 1548 | message.obj = cityInfoBeanList; | 1549 | message.obj = cityInfoBeanList; |
| 1549 | handler.sendMessage(message); | 1550 | handler.sendMessage(message); |
| 1550 | 1551 | ||
| 1551 | } else { | 1552 | } else { |
| 1552 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1553 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1553 | 1554 | ||
| 1554 | } | 1555 | } |
| 1555 | } catch (JSONException e) { | 1556 | } catch (JSONException e) { |
| 1556 | e.printStackTrace(); | 1557 | e.printStackTrace(); |
| 1557 | } | 1558 | } |
| 1558 | 1559 | ||
| 1559 | 1560 | ||
| 1560 | } | 1561 | } |
| 1561 | 1562 | ||
| 1562 | @Override | 1563 | @Override |
| 1563 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1564 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1564 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1565 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1565 | } | 1566 | } |
| 1566 | }); | 1567 | }); |
| 1567 | } | 1568 | } |
| 1568 | 1569 | ||
| 1569 | //区县级接口 | 1570 | //区县级接口 |
| 1570 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1571 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
| 1571 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1572 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
| 1572 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1573 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
| 1573 | @Override | 1574 | @Override |
| 1574 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1575 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
| 1575 | Log.e("test", "区" + new String(arg2)); | 1576 | Log.e("test", "区" + new String(arg2)); |
| 1576 | try { | 1577 | try { |
| 1577 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1578 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
| 1578 | int status = jsonObject.optInt("status"); | 1579 | int status = jsonObject.optInt("status"); |
| 1579 | if (status == 100) { | 1580 | if (status == 100) { |
| 1580 | Gson gson = new Gson(); | 1581 | Gson gson = new Gson(); |
| 1581 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1582 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
| 1582 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1583 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
| 1583 | Message message = Message.obtain(); | 1584 | Message message = Message.obtain(); |
| 1584 | message.what = HttpCode.COUNTRY; | 1585 | message.what = HttpCode.COUNTRY; |
| 1585 | message.obj = countyInfoInfoBeanList; | 1586 | message.obj = countyInfoInfoBeanList; |
| 1586 | handler.sendMessage(message); | 1587 | handler.sendMessage(message); |
| 1587 | } else { | 1588 | } else { |
| 1588 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1589 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
| 1589 | 1590 | ||
| 1590 | } | 1591 | } |
| 1591 | } catch (JSONException e) { | 1592 | } catch (JSONException e) { |
| 1592 | e.printStackTrace(); | 1593 | e.printStackTrace(); |
| 1593 | } | 1594 | } |
| 1594 | 1595 | ||
| 1595 | 1596 | ||
| 1596 | } | 1597 | } |
| 1597 | 1598 | ||
| 1598 | @Override | 1599 | @Override |
| 1599 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1600 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
| 1600 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1601 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
| 1601 | } | 1602 | } |
| 1602 | }); | 1603 | }); |
| 1603 | } | 1604 | } |
| 1604 | 1605 | ||
| 1605 | 1606 | ||
| 1606 | private void closeProgress() { | 1607 | private void closeProgress() { |
| 1607 | try { | 1608 | try { |
| 1608 | if (mProgress != null) { | 1609 | if (mProgress != null) { |
| 1609 | mProgress.dismiss(); | 1610 | mProgress.dismiss(); |
| 1610 | mProgress = null; | 1611 | mProgress = null; |
| 1611 | } | 1612 | } |
| 1612 | } catch (Exception e) { | 1613 | } catch (Exception e) { |
| 1613 | e.printStackTrace(); | 1614 | e.printStackTrace(); |
| 1614 | } | 1615 | } |
| 1615 | } | 1616 | } |
| 1616 | 1617 | ||
| 1617 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 1618 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| 1618 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 1619 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| 1619 | 1620 | ||
| 1620 | HttpManager.getInstance().closeProgress(); | 1621 | HttpManager.getInstance().closeProgress(); |
| 1621 | } | 1622 | } |
| 1622 | 1623 | ||
| 1623 | return false; | 1624 | return false; |
| 1624 | 1625 | ||
| 1625 | } | 1626 | } |
| 1626 | 1627 | ||
| 1627 | } | 1628 | } |
| 1628 | 1629 |