Commit 4aa2829e26ff304be4f3c9f89a66b58032388c6d
1 parent
5465ea3ac3
Exists in
master
个人中心地址字段的分开,修复禅道上的BUG
Showing
5 changed files
with
19 additions
and
7 deletions
Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.os.Handler; | 9 | import android.os.Handler; |
10 | import android.os.Message; | 10 | import android.os.Message; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.support.annotation.NonNull; | 12 | import android.support.annotation.NonNull; |
13 | import android.support.v4.content.FileProvider; | 13 | import android.support.v4.content.FileProvider; |
14 | import android.support.v7.app.AppCompatActivity; | 14 | import android.support.v7.app.AppCompatActivity; |
15 | import android.support.v7.widget.LinearLayoutManager; | 15 | import android.support.v7.widget.LinearLayoutManager; |
16 | import android.support.v7.widget.RecyclerView; | 16 | import android.support.v7.widget.RecyclerView; |
17 | import android.util.Log; | 17 | import android.util.Log; |
18 | import android.view.KeyEvent; | 18 | import android.view.KeyEvent; |
19 | import android.view.View; | 19 | import android.view.View; |
20 | import android.widget.ImageView; | 20 | import android.widget.ImageView; |
21 | import android.widget.LinearLayout; | 21 | import android.widget.LinearLayout; |
22 | import android.widget.TextView; | 22 | import android.widget.TextView; |
23 | import android.widget.Toast; | 23 | import android.widget.Toast; |
24 | 24 | ||
25 | import com.facebook.drawee.backends.pipeline.Fresco; | 25 | import com.facebook.drawee.backends.pipeline.Fresco; |
26 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 26 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
27 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 27 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
28 | import com.facebook.drawee.generic.RoundingParams; | 28 | import com.facebook.drawee.generic.RoundingParams; |
29 | import com.facebook.drawee.interfaces.DraweeController; | 29 | import com.facebook.drawee.interfaces.DraweeController; |
30 | import com.facebook.drawee.view.SimpleDraweeView; | 30 | import com.facebook.drawee.view.SimpleDraweeView; |
31 | import com.hjx.personalcenter.R; | 31 | import com.hjx.personalcenter.R; |
32 | import com.hjx.personalcenter.adapter.GalleryAdapter; | 32 | import com.hjx.personalcenter.adapter.GalleryAdapter; |
33 | import com.hjx.personalcenter.adapter.VideoAdapter; | 33 | import com.hjx.personalcenter.adapter.VideoAdapter; |
34 | import com.hjx.personalcenter.customdialog.HeadDialog; | 34 | import com.hjx.personalcenter.customdialog.HeadDialog; |
35 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; | 35 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; |
36 | import com.hjx.personalcenter.db.SaveParam; | 36 | import com.hjx.personalcenter.db.SaveParam; |
37 | import com.hjx.personalcenter.http.HttpCode; | 37 | import com.hjx.personalcenter.http.HttpCode; |
38 | import com.hjx.personalcenter.http.HttpManager; | 38 | import com.hjx.personalcenter.http.HttpManager; |
39 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 39 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
40 | import com.hjx.personalcenter.model.DefautPublishInfo; | 40 | import com.hjx.personalcenter.model.DefautPublishInfo; |
41 | import com.hjx.personalcenter.model.PesonalInfo; | 41 | import com.hjx.personalcenter.model.PesonalInfo; |
42 | import com.hjx.personalcenter.model.SignInfo; | 42 | import com.hjx.personalcenter.model.SignInfo; |
43 | import com.hjx.personalcenter.model.VideoInfo; | 43 | import com.hjx.personalcenter.model.VideoInfo; |
44 | import com.hjx.personalcenter.update.UpdateChecker; | 44 | import com.hjx.personalcenter.update.UpdateChecker; |
45 | import com.hjx.personalcenter.util.AlertUtils; | 45 | import com.hjx.personalcenter.util.AlertUtils; |
46 | import com.hjx.personalcenter.util.BrithdayStar; | 46 | import com.hjx.personalcenter.util.BrithdayStar; |
47 | import com.hjx.personalcenter.util.CropUtils; | 47 | import com.hjx.personalcenter.util.CropUtils; |
48 | import com.hjx.personalcenter.util.DialogPermission; | 48 | import com.hjx.personalcenter.util.DialogPermission; |
49 | import com.hjx.personalcenter.util.FileUtil; | 49 | import com.hjx.personalcenter.util.FileUtil; |
50 | import com.hjx.personalcenter.util.GetDevicesUtil; | 50 | import com.hjx.personalcenter.util.GetDevicesUtil; |
51 | import com.hjx.personalcenter.util.PermissionUtil; | 51 | import com.hjx.personalcenter.util.PermissionUtil; |
52 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 52 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
53 | import com.mylhyl.circledialog.CircleDialog; | 53 | import com.mylhyl.circledialog.CircleDialog; |
54 | import com.mylhyl.circledialog.callback.ConfigInput; | 54 | import com.mylhyl.circledialog.callback.ConfigInput; |
55 | import com.mylhyl.circledialog.params.InputParams; | 55 | import com.mylhyl.circledialog.params.InputParams; |
56 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 56 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
57 | import com.zaaach.toprightmenu.MenuItem; | 57 | import com.zaaach.toprightmenu.MenuItem; |
58 | import com.zaaach.toprightmenu.TopRightMenu; | 58 | import com.zaaach.toprightmenu.TopRightMenu; |
59 | 59 | ||
60 | import org.json.JSONException; | 60 | import org.json.JSONException; |
61 | import org.json.JSONObject; | 61 | import org.json.JSONObject; |
62 | 62 | ||
63 | import java.io.File; | 63 | import java.io.File; |
64 | import java.io.UnsupportedEncodingException; | 64 | import java.io.UnsupportedEncodingException; |
65 | import java.util.ArrayList; | 65 | import java.util.ArrayList; |
66 | import java.util.List; | 66 | import java.util.List; |
67 | 67 | ||
68 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 68 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
69 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; | 69 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; |
70 | private TextView tv_edit_presoninfo, tv_sign, | 70 | private TextView tv_edit_presoninfo, tv_sign, |
71 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 71 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
72 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; | 72 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; |
73 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; | 73 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; |
74 | private TopRightMenu mTopRightMenu; | 74 | private TopRightMenu mTopRightMenu; |
75 | //水平滑动 | 75 | //水平滑动 |
76 | private RecyclerView mRecyclerView; | 76 | private RecyclerView mRecyclerView; |
77 | private RecyclerView mRecyclerViewpublish; | 77 | private RecyclerView mRecyclerViewpublish; |
78 | private VideoAdapter RecyclerViewadapter; | 78 | private VideoAdapter RecyclerViewadapter; |
79 | private GalleryAdapter RecyclerViewadapterpublish; | 79 | private GalleryAdapter RecyclerViewadapterpublish; |
80 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); | 80 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
81 | 81 | ||
82 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); | 82 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); |
83 | private boolean showIcon = true; | 83 | private boolean showIcon = true; |
84 | private boolean dimBg = true; | 84 | private boolean dimBg = true; |
85 | private boolean needAnim = true; | 85 | private boolean needAnim = true; |
86 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 86 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
87 | private static final int REQUEST_CODE_ALBUM = 2; | 87 | private static final int REQUEST_CODE_ALBUM = 2; |
88 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 88 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
89 | SimpleDraweeView mSimpleDraweeView; | 89 | SimpleDraweeView mSimpleDraweeView; |
90 | private File file; | 90 | private File file; |
91 | private Uri uri; | 91 | private Uri uri; |
92 | Handler handler = new Handler() { | 92 | Handler handler = new Handler() { |
93 | @Override | 93 | @Override |
94 | public void handleMessage(Message msg) { | 94 | public void handleMessage(Message msg) { |
95 | super.handleMessage(msg); | 95 | super.handleMessage(msg); |
96 | switch (msg.what) { | 96 | switch (msg.what) { |
97 | case HttpCode.GETINFO: | 97 | case HttpCode.GETINFO: |
98 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; | 98 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; |
99 | tv_username.setText(cardinfoBean.getNickName()); | 99 | tv_username.setText(cardinfoBean.getNickName()); |
100 | tv_username1.setText(cardinfoBean.getNickName()); | 100 | tv_username1.setText(cardinfoBean.getNickName()); |
101 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); | 101 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); |
102 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); | 102 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); |
103 | tv_useinfo_qq.setText(cardinfoBean.getQq()); | 103 | tv_useinfo_qq.setText(cardinfoBean.getQq()); |
104 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); | 104 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); |
105 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); | 105 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); |
106 | String sex = cardinfoBean.getGender(); | 106 | String sex = cardinfoBean.getGender(); |
107 | if ("0".equals(sex)) { | 107 | if ("0".equals(sex)) { |
108 | tv_sex.setText("男"); | 108 | tv_sex.setText("男"); |
109 | iv_sex.setImageResource(R.mipmap.men); | 109 | iv_sex.setImageResource(R.mipmap.men); |
110 | } else { | 110 | } else { |
111 | tv_sex.setText("女"); | 111 | tv_sex.setText("女"); |
112 | iv_sex.setImageResource(R.mipmap.women); | 112 | iv_sex.setImageResource(R.mipmap.women); |
113 | } | 113 | } |
114 | mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); | 114 | mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); |
115 | //加载星座 | 115 | //加载星座 |
116 | BrithdayStar brithdayStar = new BrithdayStar(); | 116 | BrithdayStar brithdayStar = new BrithdayStar(); |
117 | if (cardinfoBean.getBirthday() ==null||"".equals(cardinfoBean.getBirthday())) { | 117 | if (cardinfoBean.getBirthday() ==null||"".equals(cardinfoBean.getBirthday())) { |
118 | tv_mygad.setText(""); | 118 | tv_mygad.setText(""); |
119 | } else { | 119 | } else { |
120 | String xiongzuo = brithdayStar.getConstellations(cardinfoBean.getBirthday()); | 120 | String xiongzuo = brithdayStar.getConstellations(cardinfoBean.getBirthday()); |
121 | tv_mygad.setText(xiongzuo); | 121 | tv_mygad.setText(xiongzuo); |
122 | } | 122 | } |
123 | //保存个人信息 | 123 | //保存个人信息 |
124 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTUSERNAME,cardinfoBean.getNickName()); | 124 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTUSERNAME,cardinfoBean.getNickName()); |
125 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTGRADES,cardinfoBean.getGrade().getGradeName()); | 125 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTGRADES,cardinfoBean.getGrade().getGradeName()); |
126 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTSCHOOL,cardinfoBean.getSchool().getSchoolName()); | 126 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTSCHOOL,cardinfoBean.getSchool().getSchoolName()); |
127 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTCONSTELLATION,cardinfoBean.getBirthday()); | 127 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTCONSTELLATION,cardinfoBean.getBirthday()); |
128 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTSEX,tv_sex.getText().toString()); | 128 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTSEX,tv_sex.getText().toString()); |
129 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTQQ,cardinfoBean.getQq()); | 129 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTQQ,cardinfoBean.getQq()); |
130 | //SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTADRESS,cardinfoBean.getRegion().getRegionName()); | 130 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTADRESS,cardinfoBean.getRegion().getRegionName()); |
131 | SaveParam.getInstance().saveLoginParam(MainActivity.this,SaveParam.ACCOUNTXINGZUO,cardinfoBean.getAddress()); | ||
131 | String graderID = cardinfoBean.getGrade().getGradeId(); | 132 | String graderID = cardinfoBean.getGrade().getGradeId(); |
132 | Log.e("test","nianji"+graderID); | 133 | Log.e("test","nianji"+graderID); |
133 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, graderID); | 134 | SaveParam.getInstance().saveLoginParam(MainActivity.this, SaveParam.GRADENS, graderID); |
134 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); | 135 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
135 | //账户类型 | 136 | //账户类型 |
136 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); | 137 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
137 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); | 138 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); |
138 | 139 | ||
139 | try { | 140 | try { |
140 | Object auserID; | 141 | Object auserID; |
141 | int type; | 142 | int type; |
142 | int graderIDs = Integer.parseInt(graderID); | 143 | int graderIDs = Integer.parseInt(graderID); |
143 | if ("2".equals(accounts)) { | 144 | if ("2".equals(accounts)) { |
144 | type = Integer.parseInt(accounts); | 145 | type = Integer.parseInt(accounts); |
145 | auserID = childID; | 146 | auserID = childID; |
146 | } else { | 147 | } else { |
147 | type = Integer.parseInt(accounts); | 148 | type = Integer.parseInt(accounts); |
148 | auserID = Long.parseLong(userID); | 149 | auserID = Long.parseLong(userID); |
149 | } | 150 | } |
150 | //获取版本信息 | 151 | //获取版本信息 |
151 | //Log.e("test","nianji"+graderID+auserID+"sssss"+type); | 152 | //Log.e("test","nianji"+graderID+auserID+"sssss"+type); |
152 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); | 153 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); |
153 | 154 | ||
154 | } catch (NumberFormatException e) { | 155 | } catch (NumberFormatException e) { |
155 | e.printStackTrace(); | 156 | e.printStackTrace(); |
156 | } | 157 | } |
157 | 158 | ||
158 | break; | 159 | break; |
159 | case HttpCode.SIGN: | 160 | case HttpCode.SIGN: |
160 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; | 161 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; |
161 | if (dataBean.getSignature() == null) { | 162 | if (dataBean.getSignature() == null) { |
162 | tv_sign.setText("你还未设置个性签名"); | 163 | tv_sign.setText("你还未设置个性签名"); |
163 | } else { | 164 | } else { |
164 | tv_sign.setText(dataBean.getSignature()); | 165 | tv_sign.setText(dataBean.getSignature()); |
165 | } | 166 | } |
166 | 167 | ||
167 | break; | 168 | break; |
168 | case HttpCode.PUBLISH_SUCESS: | 169 | case HttpCode.PUBLISH_SUCESS: |
169 | defautPublishInfos.clear(); | 170 | defautPublishInfos.clear(); |
170 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); | 171 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); |
171 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 172 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
172 | break; | 173 | break; |
173 | case HttpCode.GETVIDIO_SUCESS: | 174 | case HttpCode.GETVIDIO_SUCESS: |
174 | videoinfo.clear(); | 175 | videoinfo.clear(); |
175 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); | 176 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); |
176 | RecyclerViewadapter.notifyDataSetChanged(); | 177 | RecyclerViewadapter.notifyDataSetChanged(); |
177 | break; | 178 | break; |
178 | case HttpCode.SUCHCARDINFOONE: | 179 | case HttpCode.SUCHCARDINFOONE: |
179 | JSONObject jsonObject; | 180 | JSONObject jsonObject; |
180 | String status; | 181 | String status; |
181 | try { | 182 | try { |
182 | jsonObject = new JSONObject((String) msg.obj); | 183 | jsonObject = new JSONObject((String) msg.obj); |
183 | status = jsonObject.getString("status"); | 184 | status = jsonObject.getString("status"); |
184 | if (status.equals("1")) { | 185 | if (status.equals("1")) { |
185 | tv_yangji.setVisibility(View.GONE); | 186 | tv_yangji.setVisibility(View.GONE); |
186 | iv_look_card.setVisibility(View.VISIBLE); | 187 | iv_look_card.setVisibility(View.VISIBLE); |
187 | } else if (status.equals("2001")) { | 188 | } else if (status.equals("2001")) { |
188 | tv_yangji.setVisibility(View.GONE); | 189 | tv_yangji.setVisibility(View.GONE); |
189 | iv_look_card.setVisibility(View.VISIBLE); | 190 | iv_look_card.setVisibility(View.VISIBLE); |
190 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息,请重新登录"); | 191 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息,请重新登录"); |
191 | SaveParam.getInstance().clearData(MainActivity.this); | 192 | SaveParam.getInstance().clearData(MainActivity.this); |
192 | Intent settingintent = new Intent(); | 193 | Intent settingintent = new Intent(); |
193 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 194 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
194 | startActivity(settingintent); | 195 | startActivity(settingintent); |
195 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 196 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
196 | finish(); | 197 | finish(); |
197 | } else if (status.equals("2002")) { | 198 | } else if (status.equals("2002")) { |
198 | iv_look_card.setVisibility(View.GONE); | 199 | iv_look_card.setVisibility(View.GONE); |
199 | tv_yangji.setVisibility(View.VISIBLE); | 200 | tv_yangji.setVisibility(View.VISIBLE); |
200 | 201 | ||
201 | } else { | 202 | } else { |
202 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); | 203 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); |
203 | } | 204 | } |
204 | } catch (JSONException e) { | 205 | } catch (JSONException e) { |
205 | e.printStackTrace(); | 206 | e.printStackTrace(); |
206 | } | 207 | } |
207 | 208 | ||
208 | 209 | ||
209 | } | 210 | } |
210 | } | 211 | } |
211 | }; | 212 | }; |
212 | 213 | ||
213 | @Override | 214 | @Override |
214 | protected void onCreate(Bundle savedInstanceState) { | 215 | protected void onCreate(Bundle savedInstanceState) { |
215 | super.onCreate(savedInstanceState); | 216 | super.onCreate(savedInstanceState); |
216 | Fresco.initialize(this); | 217 | Fresco.initialize(this); |
217 | setContentView(R.layout.activity_main); | 218 | setContentView(R.layout.activity_main); |
218 | SysApplication.getInstance().addActivity(this); | 219 | SysApplication.getInstance().addActivity(this); |
219 | initView(); | 220 | initView(); |
220 | initData(); | 221 | initData(); |
221 | initLister(); | 222 | initLister(); |
222 | updateVersion(); | 223 | updateVersion(); |
223 | } | 224 | } |
224 | 225 | ||
225 | //////版本更新 | 226 | //////版本更新 |
226 | private void updateVersion() { | 227 | private void updateVersion() { |
227 | UpdateChecker updateChecker = new UpdateChecker(this); | 228 | UpdateChecker updateChecker = new UpdateChecker(this); |
228 | updateChecker.checkForUpdates(); | 229 | updateChecker.checkForUpdates(); |
229 | 230 | ||
230 | 231 | ||
231 | } | 232 | } |
232 | 233 | ||
233 | private void initView() { | 234 | private void initView() { |
234 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 235 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
235 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); | 236 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); |
236 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); | 237 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); |
237 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 238 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
238 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 239 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
239 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 240 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
240 | //头像 | 241 | //头像 |
241 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); | 242 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); |
242 | //初始化个人信息 | 243 | //初始化个人信息 |
243 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 244 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
244 | tv_username = (TextView) findViewById(R.id.tv_username); | 245 | tv_username = (TextView) findViewById(R.id.tv_username); |
245 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 246 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
246 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 247 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
247 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 248 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
248 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 249 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
249 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 250 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
250 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 251 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
251 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 252 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
252 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 253 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
253 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); | 254 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); |
254 | //跳转其他应用 | 255 | //跳转其他应用 |
255 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); | 256 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); |
256 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); | 257 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); |
257 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); | 258 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); |
258 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); | 259 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); |
259 | // | 260 | // |
260 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 261 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
261 | mRecyclerViewpublish = (RecyclerView) findViewById(R.id.id_recyclerview_pubish); | 262 | mRecyclerViewpublish = (RecyclerView) findViewById(R.id.id_recyclerview_pubish); |
262 | 263 | ||
263 | } | 264 | } |
264 | 265 | ||
265 | 266 | ||
266 | private void initData() { | 267 | private void initData() { |
267 | //初始化图片 | 268 | //初始化图片 |
268 | file = new File(FileUtil.getCachePath(this), "user-header.jpg"); | 269 | file = new File(FileUtil.getCachePath(this), "user-header.jpg"); |
269 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 270 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
270 | uri = Uri.fromFile(file); | 271 | uri = Uri.fromFile(file); |
271 | } else { | 272 | } else { |
272 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 273 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
273 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 274 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
274 | } | 275 | } |
275 | //设置布局管理器 | 276 | //设置布局管理器 |
276 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 277 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
277 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); | 278 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
278 | 279 | ||
279 | LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); | 280 | LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); |
280 | linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); | 281 | linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); |
281 | 282 | ||
282 | mRecyclerView.setLayoutManager(linearLayoutManager); | 283 | mRecyclerView.setLayoutManager(linearLayoutManager); |
283 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); | 284 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); |
284 | 285 | ||
285 | mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); | 286 | mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); |
286 | mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); | 287 | mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); |
287 | 288 | ||
288 | //设置视频适配器 | 289 | //设置视频适配器 |
289 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); | 290 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); |
290 | RecyclerViewadapterpublish = new GalleryAdapter(this, defautPublishInfos); | 291 | RecyclerViewadapterpublish = new GalleryAdapter(this, defautPublishInfos); |
291 | 292 | ||
292 | //版本信息适配器 | 293 | //版本信息适配器 |
293 | mRecyclerView.setAdapter(RecyclerViewadapter); | 294 | mRecyclerView.setAdapter(RecyclerViewadapter); |
294 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); | 295 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); |
295 | 296 | ||
296 | //判断保卡信息是否为样机 | 297 | //判断保卡信息是否为样机 |
297 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); | 298 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); |
298 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); | 299 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); |
299 | if ("1".equals(yangji)) { | 300 | if ("1".equals(yangji)) { |
300 | iv_look_card.setVisibility(View.GONE); | 301 | iv_look_card.setVisibility(View.GONE); |
301 | tv_yangji.setVisibility(View.VISIBLE); | 302 | tv_yangji.setVisibility(View.VISIBLE); |
302 | } else { | 303 | } else { |
303 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); | 304 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); |
304 | 305 | ||
305 | } | 306 | } |
306 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 307 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
307 | //获取个性签名 | 308 | //获取个性签名 |
308 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 309 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
309 | try { | 310 | try { |
310 | long auserID = Long.parseLong(userID); | 311 | long auserID = Long.parseLong(userID); |
311 | int typeaccount1 = Integer.parseInt(typeaccount); | 312 | int typeaccount1 = Integer.parseInt(typeaccount); |
312 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); | 313 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); |
313 | 314 | ||
314 | } catch (NumberFormatException e) { | 315 | } catch (NumberFormatException e) { |
315 | e.printStackTrace(); | 316 | e.printStackTrace(); |
316 | } | 317 | } |
317 | 318 | ||
318 | 319 | ||
319 | } | 320 | } |
320 | 321 | ||
321 | private void initLister() { | 322 | private void initLister() { |
322 | iv_imformatioan.setOnClickListener(this); | 323 | iv_imformatioan.setOnClickListener(this); |
323 | iv_look_card.setOnClickListener(this); | 324 | iv_look_card.setOnClickListener(this); |
324 | tv_edit_presoninfo.setOnClickListener(this); | 325 | tv_edit_presoninfo.setOnClickListener(this); |
325 | iv_setting.setOnClickListener(this); | 326 | iv_setting.setOnClickListener(this); |
326 | iv_sign.setOnClickListener(this); | 327 | iv_sign.setOnClickListener(this); |
327 | mSimpleDraweeView.setOnClickListener(this); | 328 | mSimpleDraweeView.setOnClickListener(this); |
328 | linel_mycuoti.setOnClickListener(this); | 329 | linel_mycuoti.setOnClickListener(this); |
329 | linel_mynote.setOnClickListener(this); | 330 | linel_mynote.setOnClickListener(this); |
330 | linel_mycollege.setOnClickListener(this); | 331 | linel_mycollege.setOnClickListener(this); |
331 | linel_myclass.setOnClickListener(this); | 332 | linel_myclass.setOnClickListener(this); |
332 | 333 | ||
333 | } | 334 | } |
334 | 335 | ||
335 | @Override | 336 | @Override |
336 | public void onClick(View v) { | 337 | public void onClick(View v) { |
337 | switch (v.getId()) { | 338 | switch (v.getId()) { |
338 | case R.id.iv_imformatioan: | 339 | case R.id.iv_imformatioan: |
339 | Intent intent = new Intent(); | 340 | Intent intent = new Intent(); |
340 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 341 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
341 | startActivity(intent); | 342 | startActivity(intent); |
342 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 343 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
343 | break; | 344 | break; |
344 | case R.id.iv_look_card: | 345 | case R.id.iv_look_card: |
345 | Intent lookintent = new Intent(); | 346 | Intent lookintent = new Intent(); |
346 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 347 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
347 | startActivity(lookintent); | 348 | startActivity(lookintent); |
348 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 349 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
349 | break; | 350 | break; |
350 | case R.id.tv_edit_presoninfo: | 351 | case R.id.tv_edit_presoninfo: |
351 | Intent editintent = new Intent(); | 352 | Intent editintent = new Intent(); |
352 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 353 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
353 | startActivity(editintent); | 354 | startActivity(editintent); |
354 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 355 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
355 | break; | 356 | break; |
356 | case R.id.iv_head: | 357 | case R.id.iv_head: |
357 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 358 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
358 | break; | 359 | break; |
359 | case R.id.iv_setting: | 360 | case R.id.iv_setting: |
360 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 361 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
361 | List<MenuItem> menuItems = new ArrayList<>(); | 362 | List<MenuItem> menuItems = new ArrayList<>(); |
362 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); | 363 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); |
363 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); | 364 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); |
364 | mTopRightMenu | 365 | mTopRightMenu |
365 | .setHeight(150) //默认高度480 | 366 | .setHeight(150) //默认高度480 |
366 | .setWidth(320) //默认宽度wrap_content | 367 | .setWidth(320) //默认宽度wrap_content |
367 | .showIcon(showIcon) //显示菜单图标,默认为true | 368 | .showIcon(showIcon) //显示菜单图标,默认为true |
368 | .dimBackground(dimBg) //背景变暗,默认为true | 369 | .dimBackground(dimBg) //背景变暗,默认为true |
369 | .needAnimationStyle(needAnim) //显示动画,默认为true | 370 | .needAnimationStyle(needAnim) //显示动画,默认为true |
370 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 371 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
371 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 372 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
372 | @Override | 373 | @Override |
373 | public void onMenuItemClick(int position) { | 374 | public void onMenuItemClick(int position) { |
374 | switch (position) { | 375 | switch (position) { |
375 | case 0: | 376 | case 0: |
376 | new CircleDialog.Builder(MainActivity.this) | 377 | new CircleDialog.Builder(MainActivity.this) |
377 | .setCanceledOnTouchOutside(false) | 378 | .setCanceledOnTouchOutside(false) |
378 | .setWidth(0.4f) | 379 | .setWidth(0.4f) |
379 | .setCancelable(false) | 380 | .setCancelable(false) |
380 | .setText("您确定要退出,更换其他账号登录吗?") | 381 | .setText("您确定要退出,更换其他账号登录吗?") |
381 | .setNegative("取消", null) | 382 | .setNegative("取消", null) |
382 | .setPositive("确定", new View.OnClickListener() { | 383 | .setPositive("确定", new View.OnClickListener() { |
383 | @Override | 384 | @Override |
384 | public void onClick(View v) { | 385 | public void onClick(View v) { |
385 | //清除数据 | 386 | //清除数据 |
386 | SaveParam.getInstance().clearData(MainActivity.this); | 387 | SaveParam.getInstance().clearData(MainActivity.this); |
387 | Intent settingintent = new Intent(); | 388 | Intent settingintent = new Intent(); |
388 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 389 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
389 | startActivity(settingintent); | 390 | startActivity(settingintent); |
390 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 391 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
391 | finish(); | 392 | finish(); |
392 | } | 393 | } |
393 | }) | 394 | }) |
394 | .show(); | 395 | .show(); |
395 | break; | 396 | break; |
396 | case 1: | 397 | case 1: |
397 | Intent accontMintent = new Intent(); | 398 | Intent accontMintent = new Intent(); |
398 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 399 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
399 | startActivity(accontMintent); | 400 | startActivity(accontMintent); |
400 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 401 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
401 | break; | 402 | break; |
402 | } | 403 | } |
403 | } | 404 | } |
404 | }) | 405 | }) |
405 | .addMenuList(menuItems) | 406 | .addMenuList(menuItems) |
406 | .showAsDropDown(iv_setting, -250, 0); | 407 | .showAsDropDown(iv_setting, -250, 0); |
407 | break; | 408 | break; |
408 | case R.id.iv_sign: | 409 | case R.id.iv_sign: |
409 | new CircleDialog.Builder(this) | 410 | new CircleDialog.Builder(this) |
410 | .setCanceledOnTouchOutside(false) | 411 | .setCanceledOnTouchOutside(false) |
411 | .setCancelable(true) | 412 | .setCancelable(true) |
412 | .setTitle("个性签名") | 413 | .setTitle("个性签名") |
413 | .setInputHint("请输入个性签名") | 414 | .setInputHint("请输入个性签名") |
414 | .setWidth(0.5f) | 415 | .setWidth(0.5f) |
415 | .configInput(new ConfigInput() { | 416 | .configInput(new ConfigInput() { |
416 | @Override | 417 | @Override |
417 | public void onConfig(InputParams params) { | 418 | public void onConfig(InputParams params) { |
418 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 419 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
419 | } | 420 | } |
420 | }) | 421 | }) |
421 | .setNegative("取消", null) | 422 | .setNegative("取消", null) |
422 | .setPositiveInput("确定", new OnInputClickListener() { | 423 | .setPositiveInput("确定", new OnInputClickListener() { |
423 | @Override | 424 | @Override |
424 | public void onClick(String text, View v) { | 425 | public void onClick(String text, View v) { |
425 | if (text.equals("")) { | 426 | if (text.equals("")) { |
426 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 427 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
427 | } else { | 428 | } else { |
428 | try { | 429 | try { |
429 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); | 430 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
430 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); | 431 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
431 | long auserID = Long.parseLong(userID); | 432 | long auserID = Long.parseLong(userID); |
432 | int typeaccount1 = Integer.parseInt(typeaccount); | 433 | int typeaccount1 = Integer.parseInt(typeaccount); |
433 | HttpManager.getInstance().changsignature(MainActivity.this, auserID, typeaccount1, text); | 434 | HttpManager.getInstance().changsignature(MainActivity.this, auserID, typeaccount1, text); |
434 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 435 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
435 | } catch (NumberFormatException e) { | 436 | } catch (NumberFormatException e) { |
436 | e.printStackTrace(); | 437 | e.printStackTrace(); |
437 | } | 438 | } |
438 | 439 | ||
439 | tv_sign.setText(text); | 440 | tv_sign.setText(text); |
440 | } | 441 | } |
441 | 442 | ||
442 | } | 443 | } |
443 | }) | 444 | }) |
444 | .show(); | 445 | .show(); |
445 | break; | 446 | break; |
446 | case R.id.linel_mycuoti: | 447 | case R.id.linel_mycuoti: |
447 | AlertUtils.showToast(this, "我的错题 "); | 448 | AlertUtils.showToast(this, "我的错题 "); |
448 | break; | 449 | break; |
449 | case R.id.linel_mynote: | 450 | case R.id.linel_mynote: |
450 | AlertUtils.showToast(this, "我的笔记 "); | 451 | AlertUtils.showToast(this, "我的笔记 "); |
451 | break; | 452 | break; |
452 | case R.id.linel_mycollege: | 453 | case R.id.linel_mycollege: |
453 | AlertUtils.showToast(this, "我的收藏 "); | 454 | AlertUtils.showToast(this, "我的收藏 "); |
454 | break; | 455 | break; |
455 | case R.id.linel_myclass: | 456 | case R.id.linel_myclass: |
456 | AlertUtils.showToast(this, "我的班级 "); | 457 | AlertUtils.showToast(this, "我的班级 "); |
457 | break; | 458 | break; |
458 | } | 459 | } |
459 | 460 | ||
460 | } | 461 | } |
461 | 462 | ||
462 | @Override | 463 | @Override |
463 | protected void onPause() { | 464 | protected void onPause() { |
464 | super.onPause(); | 465 | super.onPause(); |
465 | } | 466 | } |
466 | 467 | ||
467 | @Override | 468 | @Override |
468 | protected void onResume() { | 469 | protected void onResume() { |
469 | super.onResume(); | 470 | super.onResume(); |
470 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 471 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
471 | //账户类型 | 472 | //账户类型 |
472 | String accounts = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 473 | String accounts = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
473 | try { | 474 | try { |
474 | int graderID; | 475 | int graderID; |
475 | long auserID = Long.parseLong(userID); | 476 | long auserID = Long.parseLong(userID); |
476 | int typeaccount1 = Integer.parseInt(accounts); | 477 | int typeaccount1 = Integer.parseInt(accounts); |
477 | //获取最近播放视频 | 478 | //获取最近播放视频 |
478 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); | 479 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); |
479 | //获取个人信息 | 480 | //获取个人信息 |
480 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, auserID, typeaccount1, handler); | 481 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, auserID, typeaccount1, handler); |
481 | 482 | ||
482 | 483 | ||
483 | } catch (NumberFormatException e) { | 484 | } catch (NumberFormatException e) { |
484 | e.printStackTrace(); | 485 | e.printStackTrace(); |
485 | } | 486 | } |
486 | 487 | ||
487 | } | 488 | } |
488 | 489 | ||
489 | //回调头像监听 | 490 | //回调头像监听 |
490 | @Override | 491 | @Override |
491 | public void heard(Context context, View v, int headpitiaon) { | 492 | public void heard(Context context, View v, int headpitiaon) { |
492 | String picUrl = ""; | 493 | String picUrl = ""; |
493 | String userID; | 494 | String userID; |
494 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 495 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
495 | if ("2".equals(typeaccount)) { | 496 | if ("2".equals(typeaccount)) { |
496 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 497 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
497 | } else { | 498 | } else { |
498 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 499 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
499 | } | 500 | } |
500 | switch (v.getId()) { | 501 | switch (v.getId()) { |
501 | //选择默认图片 | 502 | //选择默认图片 |
502 | case R.id.oktakephone: | 503 | case R.id.oktakephone: |
503 | if (headpitiaon == 1) { | 504 | if (headpitiaon == 1) { |
504 | mSimpleDraweeView.setImageDrawable(null); | 505 | mSimpleDraweeView.setImageDrawable(null); |
505 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); | 506 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
506 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; | 507 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; |
507 | try { | 508 | try { |
508 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 509 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
509 | } catch (UnsupportedEncodingException e) { | 510 | } catch (UnsupportedEncodingException e) { |
510 | e.printStackTrace(); | 511 | e.printStackTrace(); |
511 | } | 512 | } |
512 | } else if (headpitiaon == 2) { | 513 | } else if (headpitiaon == 2) { |
513 | mSimpleDraweeView.setImageDrawable(null); | 514 | mSimpleDraweeView.setImageDrawable(null); |
514 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); | 515 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
515 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; | 516 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; |
516 | try { | 517 | try { |
517 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 518 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
518 | } catch (UnsupportedEncodingException e) { | 519 | } catch (UnsupportedEncodingException e) { |
519 | e.printStackTrace(); | 520 | e.printStackTrace(); |
520 | } | 521 | } |
521 | } else if (headpitiaon == 3) { | 522 | } else if (headpitiaon == 3) { |
522 | mSimpleDraweeView.setImageDrawable(null); | 523 | mSimpleDraweeView.setImageDrawable(null); |
523 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); | 524 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
524 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; | 525 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; |
525 | try { | 526 | try { |
526 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 527 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
527 | } catch (UnsupportedEncodingException e) { | 528 | } catch (UnsupportedEncodingException e) { |
528 | e.printStackTrace(); | 529 | e.printStackTrace(); |
529 | } | 530 | } |
530 | } else if (headpitiaon == 4) { | 531 | } else if (headpitiaon == 4) { |
531 | mSimpleDraweeView.setImageDrawable(null); | 532 | mSimpleDraweeView.setImageDrawable(null); |
532 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); | 533 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
533 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png"; | 534 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png"; |
534 | try { | 535 | try { |
535 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); | 536 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
536 | } catch (UnsupportedEncodingException e) { | 537 | } catch (UnsupportedEncodingException e) { |
537 | e.printStackTrace(); | 538 | e.printStackTrace(); |
538 | } | 539 | } |
539 | } else { | 540 | } else { |
540 | mSimpleDraweeView.setImageDrawable(null); | 541 | mSimpleDraweeView.setImageDrawable(null); |
541 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); | 542 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); |
542 | ; | 543 | ; |
543 | } | 544 | } |
544 | 545 | ||
545 | break; | 546 | break; |
546 | case R.id.canceltakephone: | 547 | case R.id.canceltakephone: |
547 | 548 | ||
548 | break; | 549 | break; |
549 | //拍摄和相册 | 550 | //拍摄和相册 |
550 | case R.id.take_pic: | 551 | case R.id.take_pic: |
551 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 552 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
552 | uploadAvatarFromPhotoRequest(); | 553 | uploadAvatarFromPhotoRequest(); |
553 | } | 554 | } |
554 | break; | 555 | break; |
555 | case R.id.xiangce: | 556 | case R.id.xiangce: |
556 | uploadAvatarFromAlbumRequest(); | 557 | uploadAvatarFromAlbumRequest(); |
557 | break; | 558 | break; |
558 | 559 | ||
559 | } | 560 | } |
560 | 561 | ||
561 | } | 562 | } |
562 | //照相 | 563 | //照相 |
563 | private void uploadAvatarFromPhotoRequest() { | 564 | private void uploadAvatarFromPhotoRequest() { |
564 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 565 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
565 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 566 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
566 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 567 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
567 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 568 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
568 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 569 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
569 | } | 570 | } |
570 | //选择图库 | 571 | //选择图库 |
571 | private void uploadAvatarFromAlbumRequest() { | 572 | private void uploadAvatarFromAlbumRequest() { |
572 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 573 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
573 | photoPickerIntent.setType("image/*"); | 574 | photoPickerIntent.setType("image/*"); |
574 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 575 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
575 | } | 576 | } |
576 | 577 | ||
577 | //回掉 | 578 | //回掉 |
578 | @Override | 579 | @Override |
579 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 580 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
580 | super.onActivityResult(requestCode, resultCode, data); | 581 | super.onActivityResult(requestCode, resultCode, data); |
581 | if (resultCode != -1) { | 582 | if (resultCode != -1) { |
582 | return; | 583 | return; |
583 | } | 584 | } |
584 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 585 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
585 | Uri newUri; | 586 | Uri newUri; |
586 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 587 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
587 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 588 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
588 | } else { | 589 | } else { |
589 | newUri = data.getData(); | 590 | newUri = data.getData(); |
590 | } | 591 | } |
591 | if (newUri != null) { | 592 | if (newUri != null) { |
592 | startPhotoZoom(newUri); | 593 | startPhotoZoom(newUri); |
593 | } else { | 594 | } else { |
594 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 595 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
595 | } | 596 | } |
596 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 597 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
597 | startPhotoZoom(uri); | 598 | startPhotoZoom(uri); |
598 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 599 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
599 | uploadAvatarFromPhoto(); | 600 | uploadAvatarFromPhoto(); |
600 | } | 601 | } |
601 | } | 602 | } |
602 | 603 | ||
603 | private void uploadAvatarFromPhoto() { | 604 | private void uploadAvatarFromPhoto() { |
604 | compressAndUploadAvatar(file.getPath()); | 605 | compressAndUploadAvatar(file.getPath()); |
605 | 606 | ||
606 | } | 607 | } |
607 | 608 | ||
608 | private void compressAndUploadAvatar(String fileSrc) { | 609 | private void compressAndUploadAvatar(String fileSrc) { |
609 | 610 | ||
610 | 611 | ||
611 | //上传到服务器 | 612 | //上传到服务器 |
612 | 613 | ||
613 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 614 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
614 | String mimeType = "image/*"; | 615 | String mimeType = "image/*"; |
615 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 616 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
616 | //String fileName = cover.getName(); | 617 | //String fileName = cover.getName(); |
617 | String userID; | 618 | String userID; |
618 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 619 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
619 | if ("2".equals(typeaccount)) { | 620 | if ("2".equals(typeaccount)) { |
620 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | 621 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); |
621 | } else { | 622 | } else { |
622 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 623 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
623 | } | 624 | } |
624 | 625 | ||
625 | //上传头像 | 626 | //上传头像 |
626 | 627 | ||
627 | try { | 628 | try { |
628 | HttpManager.getInstance().header(this, userID, typeaccount, file.getPath()); | 629 | HttpManager.getInstance().header(this, userID, typeaccount, file.getPath()); |
629 | } catch (UnsupportedEncodingException e) { | 630 | } catch (UnsupportedEncodingException e) { |
630 | e.printStackTrace(); | 631 | e.printStackTrace(); |
631 | } | 632 | } |
632 | 633 | ||
633 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 634 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
634 | //Fresco设置圆形头像 | 635 | //Fresco设置圆形头像 |
635 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 636 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
636 | GenericDraweeHierarchy hierarchy = builder | 637 | GenericDraweeHierarchy hierarchy = builder |
637 | .setDesiredAspectRatio(1f) | 638 | .setDesiredAspectRatio(1f) |
638 | .setFailureImage(R.mipmap.blank) | 639 | .setFailureImage(R.mipmap.blank) |
639 | //圆形头像 | 640 | //圆形头像 |
640 | .setRoundingParams(RoundingParams.asCircle()) | 641 | .setRoundingParams(RoundingParams.asCircle()) |
641 | .build(); | 642 | .build(); |
642 | 643 | ||
643 | //加载本地图片 | 644 | //加载本地图片 |
644 | Uri uri = Uri.fromFile(cover); | 645 | Uri uri = Uri.fromFile(cover); |
645 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 646 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
646 | .setOldController(mSimpleDraweeView.getController()) | 647 | .setOldController(mSimpleDraweeView.getController()) |
647 | .setUri(uri) | 648 | .setUri(uri) |
648 | .build(); | 649 | .build(); |
649 | mSimpleDraweeView.setHierarchy(hierarchy); | 650 | mSimpleDraweeView.setHierarchy(hierarchy); |
650 | mSimpleDraweeView.setController(controller); | 651 | mSimpleDraweeView.setController(controller); |
651 | 652 | ||
652 | } | 653 | } |
653 | 654 | ||
654 | public void startPhotoZoom(Uri uri) { | 655 | public void startPhotoZoom(Uri uri) { |
655 | Intent intent = new Intent("com.android.camera.action.CROP"); | 656 | Intent intent = new Intent("com.android.camera.action.CROP"); |
656 | intent.setDataAndType(uri, "image/*"); | 657 | intent.setDataAndType(uri, "image/*"); |
657 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 658 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
658 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 659 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
659 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 660 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
660 | intent.putExtra("aspectY", 1);// x:y=1:1 | 661 | intent.putExtra("aspectY", 1);// x:y=1:1 |
661 | // intent.putExtra("outputX", 400);//图片输出大小 | 662 | // intent.putExtra("outputX", 400);//图片输出大小 |
662 | // intent.putExtra("outputY", 400); | 663 | // intent.putExtra("outputY", 400); |
663 | intent.putExtra("output", Uri.fromFile(file)); | 664 | intent.putExtra("output", Uri.fromFile(file)); |
664 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 665 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
665 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 666 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
666 | } | 667 | } |
667 | 668 | ||
668 | @Override | 669 | @Override |
669 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 670 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
670 | switch (requestCode) { | 671 | switch (requestCode) { |
671 | 672 | ||
672 | case PermissionUtil.REQUEST_SHOWCAMERA: | 673 | case PermissionUtil.REQUEST_SHOWCAMERA: |
673 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 674 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
674 | // Permission Granted | 675 | // Permission Granted |
675 | uploadAvatarFromPhotoRequest(); | 676 | uploadAvatarFromPhotoRequest(); |
676 | 677 | ||
677 | } else { | 678 | } else { |
678 | if (!SharedPreferenceMark.getHasShowCamera()) { | 679 | if (!SharedPreferenceMark.getHasShowCamera()) { |
679 | SharedPreferenceMark.setHasShowCamera(true); | 680 | SharedPreferenceMark.setHasShowCamera(true); |
680 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 681 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
681 | 682 | ||
682 | } else { | 683 | } else { |
683 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 684 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
684 | .show(); | 685 | .show(); |
685 | } | 686 | } |
686 | } | 687 | } |
687 | break; | 688 | break; |
688 | default: | 689 | default: |
689 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 690 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
690 | } | 691 | } |
691 | } | 692 | } |
692 | 693 | ||
693 | private long exitTime = 0; | 694 | private long exitTime = 0; |
694 | 695 | ||
695 | @Override | 696 | @Override |
696 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 697 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
697 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 698 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
698 | if ((System.currentTimeMillis() - exitTime) > 2000) { | 699 | if ((System.currentTimeMillis() - exitTime) > 2000) { |
699 | Toast.makeText(getApplicationContext(), "再按一次退出程序", | 700 | Toast.makeText(getApplicationContext(), "再按一次退出程序", |
700 | Toast.LENGTH_SHORT).show(); | 701 | Toast.LENGTH_SHORT).show(); |
701 | exitTime = System.currentTimeMillis(); | 702 | exitTime = System.currentTimeMillis(); |
702 | } else { | 703 | } else { |
703 | SysApplication.getInstance().finishActivity(MainActivity.this); | 704 | SysApplication.getInstance().finishActivity(MainActivity.this); |
704 | } | 705 | } |
705 | return false; | 706 | return false; |
706 | } | 707 | } |
707 | return super.onKeyDown(keyCode, event); | 708 | return super.onKeyDown(keyCode, event); |
708 | } | 709 | } |
709 | } | 710 | } |
710 | 711 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/PresonInfoFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.graphics.Color; | 3 | import android.graphics.Color; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.annotation.Nullable; | 5 | import android.support.annotation.Nullable; |
6 | import android.support.v4.app.Fragment; | 6 | import android.support.v4.app.Fragment; |
7 | import android.support.v4.view.ViewPager; | 7 | import android.support.v4.view.ViewPager; |
8 | import android.util.Log; | 8 | import android.util.Log; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.EditText; | 14 | import android.widget.EditText; |
15 | import android.widget.ImageView; | 15 | import android.widget.ImageView; |
16 | import android.widget.LinearLayout; | 16 | import android.widget.LinearLayout; |
17 | import android.widget.TextView; | 17 | import android.widget.TextView; |
18 | 18 | ||
19 | import com.bigkoo.pickerview.TimePickerView; | 19 | import com.bigkoo.pickerview.TimePickerView; |
20 | import com.hjx.personalcenter.R; | 20 | import com.hjx.personalcenter.R; |
21 | import com.hjx.personalcenter.activity.ChangePresonalInfoActivity; | 21 | import com.hjx.personalcenter.activity.ChangePresonalInfoActivity; |
22 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 22 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
23 | import com.hjx.personalcenter.customdialog.CountryDialog; | 23 | import com.hjx.personalcenter.customdialog.CountryDialog; |
24 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 24 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
25 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 25 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
26 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 26 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
27 | import com.hjx.personalcenter.db.Content; | 27 | import com.hjx.personalcenter.db.Content; |
28 | import com.hjx.personalcenter.db.SaveParam; | 28 | import com.hjx.personalcenter.db.SaveParam; |
29 | import com.hjx.personalcenter.http.HttpManager; | 29 | import com.hjx.personalcenter.http.HttpManager; |
30 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 30 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
31 | import com.hjx.personalcenter.model.CityInfo; | 31 | import com.hjx.personalcenter.model.CityInfo; |
32 | import com.hjx.personalcenter.model.CountyInfo; | 32 | import com.hjx.personalcenter.model.CountyInfo; |
33 | import com.hjx.personalcenter.model.GradeInfo; | 33 | import com.hjx.personalcenter.model.GradeInfo; |
34 | import com.hjx.personalcenter.model.ProvinceInfo; | 34 | import com.hjx.personalcenter.model.ProvinceInfo; |
35 | import com.hjx.personalcenter.model.SchoolInfo; | 35 | import com.hjx.personalcenter.model.SchoolInfo; |
36 | import com.hjx.personalcenter.util.AlertUtils; | 36 | import com.hjx.personalcenter.util.AlertUtils; |
37 | import com.hjx.personalcenter.util.GetDevicesUtil; | 37 | import com.hjx.personalcenter.util.GetDevicesUtil; |
38 | import com.mylhyl.circledialog.CircleDialog; | 38 | import com.mylhyl.circledialog.CircleDialog; |
39 | import com.mylhyl.circledialog.callback.ConfigDialog; | 39 | import com.mylhyl.circledialog.callback.ConfigDialog; |
40 | import com.mylhyl.circledialog.params.DialogParams; | 40 | import com.mylhyl.circledialog.params.DialogParams; |
41 | 41 | ||
42 | import org.apache.http.util.TextUtils; | 42 | import org.apache.http.util.TextUtils; |
43 | 43 | ||
44 | import java.text.SimpleDateFormat; | 44 | import java.text.SimpleDateFormat; |
45 | import java.util.ArrayList; | 45 | import java.util.ArrayList; |
46 | import java.util.Date; | 46 | import java.util.Date; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Created by h on 2017/8/12. | 49 | * Created by h on 2017/8/12. |
50 | */ | 50 | */ |
51 | 51 | ||
52 | public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack | 52 | public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack |
53 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { | 53 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { |
54 | private View mView; | 54 | private View mView; |
55 | private int type; | 55 | private int type; |
56 | private TimePickerView pvTime; | 56 | private TimePickerView pvTime; |
57 | private LinearLayout tv_version; | 57 | private LinearLayout tv_version; |
58 | 58 | ||
59 | private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; | 59 | private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; |
60 | private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender, sub; | 60 | private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender, sub; |
61 | public static String TABLAYOUT_FRAGMENT = "presonfragment"; | 61 | public static String TABLAYOUT_FRAGMENT = "presonfragment"; |
62 | private ImageView my_adress, my_sex, my_bthday, my_grade, my_school, ccancel; | 62 | private ImageView my_adress, my_sex, my_bthday, my_grade, my_school, ccancel; |
63 | 63 | ||
64 | 64 | ||
65 | public static PresonInfoFragment newInstance(int type) { | 65 | public static PresonInfoFragment newInstance(int type) { |
66 | PresonInfoFragment fragment = new PresonInfoFragment(); | 66 | PresonInfoFragment fragment = new PresonInfoFragment(); |
67 | Bundle bundle = new Bundle(); | 67 | Bundle bundle = new Bundle(); |
68 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 68 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
69 | fragment.setArguments(bundle); | 69 | fragment.setArguments(bundle); |
70 | return fragment; | 70 | return fragment; |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | @Override | 74 | @Override |
75 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 75 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
76 | if (mView == null) { | 76 | if (mView == null) { |
77 | mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); | 77 | mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); |
78 | Content.changeinfoflag = false; | 78 | Content.changeinfoflag = false; |
79 | initView(mView); | 79 | initView(mView); |
80 | initData(); | 80 | initData(); |
81 | setLister(); | 81 | setLister(); |
82 | initTimePicker(); | 82 | initTimePicker(); |
83 | 83 | ||
84 | 84 | ||
85 | } | 85 | } |
86 | return mView; | 86 | return mView; |
87 | } | 87 | } |
88 | 88 | ||
89 | //初始化 | 89 | //初始化 |
90 | private void initView(View mView) { | 90 | private void initView(View mView) { |
91 | tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); | 91 | tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); |
92 | tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); | 92 | tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); |
93 | tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); | 93 | tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); |
94 | tv_sex = (TextView) mView.findViewById(R.id.tv_sex); | 94 | tv_sex = (TextView) mView.findViewById(R.id.tv_sex); |
95 | tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); | 95 | tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); |
96 | tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); | 96 | tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); |
97 | tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); | 97 | tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); |
98 | tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); | 98 | tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); |
99 | my_adress = (ImageView) mView.findViewById(R.id.my_adress); | 99 | my_adress = (ImageView) mView.findViewById(R.id.my_adress); |
100 | my_sex = (ImageView) mView.findViewById(R.id.my_sex); | 100 | my_sex = (ImageView) mView.findViewById(R.id.my_sex); |
101 | my_bthday = (ImageView) mView.findViewById(R.id.my_bthday); | 101 | my_bthday = (ImageView) mView.findViewById(R.id.my_bthday); |
102 | my_grade = (ImageView) mView.findViewById(R.id.my_grade); | 102 | my_grade = (ImageView) mView.findViewById(R.id.my_grade); |
103 | my_school = (ImageView) mView.findViewById(R.id.my_school); | 103 | my_school = (ImageView) mView.findViewById(R.id.my_school); |
104 | sub = (TextView) mView.findViewById(R.id.presonal_sub); | 104 | sub = (TextView) mView.findViewById(R.id.presonal_sub); |
105 | ccancel = (ImageView) mView.findViewById(R.id.cancel); | 105 | ccancel = (ImageView) mView.findViewById(R.id.cancel); |
106 | tv_version = (LinearLayout) mView.findViewById(R.id.tv_version); | 106 | tv_version = (LinearLayout) mView.findViewById(R.id.tv_version); |
107 | 107 | ||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | private void initData() { | 111 | private void initData() { |
112 | //初始化个人信息 | 112 | //初始化个人信息 |
113 | String name = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTUSERNAME); | 113 | String name = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTUSERNAME); |
114 | //String adress1 = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTADRESS); | 114 | String adress1 = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTADRESS); |
115 | //String adress2 = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTXINGZUO); | 115 | String adress2 = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTXINGZUO); |
116 | String sex = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTSEX); | 116 | String sex = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTSEX); |
117 | String bithday = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTCONSTELLATION); | 117 | String bithday = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTCONSTELLATION); |
118 | String qq = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTQQ); | 118 | String qq = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTQQ); |
119 | String grader = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTGRADES); | 119 | String grader = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTGRADES); |
120 | String school = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTSCHOOL); | 120 | String school = SaveParam.getInstance().getLoginParam(getActivity(),SaveParam.ACCOUNTSCHOOL); |
121 | tv_username1.setText(name); | 121 | tv_username1.setText(name); |
122 | tv_useinfo_qq.setText(qq); | 122 | tv_useinfo_qq.setText(qq); |
123 | tv_sex.setText(sex); | 123 | tv_sex.setText(sex); |
124 | tv_useinfo_birthday.setText(bithday); | 124 | tv_useinfo_birthday.setText(bithday); |
125 | tv_useinfo_gender.setText(grader); | 125 | tv_useinfo_gender.setText(grader); |
126 | tv_useinfo_school.setText(school); | 126 | tv_useinfo_school.setText(school); |
127 | // tv_useinfo_adress1.setText(adress2); | 127 | tv_useinfo_adress1.setText(adress2); |
128 | // tv_useinfo_adress.setText(adress1); | 128 | tv_useinfo_adress.setText(adress1); |
129 | 129 | ||
130 | 130 | ||
131 | 131 | ||
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | private void setLister() { | 135 | private void setLister() { |
136 | tv_sex.setOnClickListener(this); | 136 | tv_sex.setOnClickListener(this); |
137 | tv_useinfo_adress.setOnClickListener(this); | 137 | tv_useinfo_adress.setOnClickListener(this); |
138 | tv_useinfo_birthday.setOnClickListener(this); | 138 | tv_useinfo_birthday.setOnClickListener(this); |
139 | tv_useinfo_school.setOnClickListener(this); | 139 | tv_useinfo_school.setOnClickListener(this); |
140 | tv_useinfo_gender.setOnClickListener(this); | 140 | tv_useinfo_gender.setOnClickListener(this); |
141 | my_adress.setOnClickListener(this); | 141 | my_adress.setOnClickListener(this); |
142 | my_sex.setOnClickListener(this); | 142 | my_sex.setOnClickListener(this); |
143 | my_bthday.setOnClickListener(this); | 143 | my_bthday.setOnClickListener(this); |
144 | my_grade.setOnClickListener(this); | 144 | my_grade.setOnClickListener(this); |
145 | my_school.setOnClickListener(this); | 145 | my_school.setOnClickListener(this); |
146 | sub.setOnClickListener(this); | 146 | sub.setOnClickListener(this); |
147 | tv_version.setOnClickListener(this); | 147 | tv_version.setOnClickListener(this); |
148 | ccancel.setOnClickListener(this); | 148 | ccancel.setOnClickListener(this); |
149 | } | 149 | } |
150 | 150 | ||
151 | @Override | 151 | @Override |
152 | public void onClick(View v) { | 152 | public void onClick(View v) { |
153 | String presonal1 = tv_username1.getText().toString().trim(); | 153 | String presonal1 = tv_username1.getText().toString().trim(); |
154 | String presonal2 = tv_useinfo_adress1.getText().toString().trim(); | 154 | String presonal2 = tv_useinfo_adress1.getText().toString().trim(); |
155 | String presonal3 = tv_sex.getText().toString().trim(); | 155 | String presonal3 = tv_sex.getText().toString().trim(); |
156 | String presonal4 = tv_useinfo_adress.getText().toString().trim(); | 156 | String presonal4 = tv_useinfo_adress.getText().toString().trim(); |
157 | String presonal5 = tv_useinfo_birthday.getText().toString().trim(); | 157 | String presonal5 = tv_useinfo_birthday.getText().toString().trim(); |
158 | String presonal6 = tv_useinfo_school.getText().toString().trim(); | 158 | String presonal6 = tv_useinfo_school.getText().toString().trim(); |
159 | String presonal7 = tv_useinfo_gender.getText().toString().trim(); | 159 | String presonal7 = tv_useinfo_gender.getText().toString().trim(); |
160 | String presonal8 = tv_useinfo_qq.getText().toString().trim(); | 160 | String presonal8 = tv_useinfo_qq.getText().toString().trim(); |
161 | switch (v.getId()) { | 161 | switch (v.getId()) { |
162 | case R.id.tv_sex: | 162 | case R.id.tv_sex: |
163 | case R.id.my_sex: | 163 | case R.id.my_sex: |
164 | final String[] items = {"男", "女"}; | 164 | final String[] items = {"男", "女"}; |
165 | new CircleDialog.Builder(getActivity()) | 165 | new CircleDialog.Builder(getActivity()) |
166 | .configDialog(new ConfigDialog() { | 166 | .configDialog(new ConfigDialog() { |
167 | @Override | 167 | @Override |
168 | public void onConfig(DialogParams params) { | 168 | public void onConfig(DialogParams params) { |
169 | //增加弹出动画 | 169 | //增加弹出动画 |
170 | params.gravity = Gravity.CENTER; | 170 | params.gravity = Gravity.CENTER; |
171 | } | 171 | } |
172 | }) | 172 | }) |
173 | .setTitle("请选择性别") | 173 | .setTitle("请选择性别") |
174 | .setWidth(0.5f) | 174 | .setWidth(0.5f) |
175 | .setItems(items, new AdapterView.OnItemClickListener() { | 175 | .setItems(items, new AdapterView.OnItemClickListener() { |
176 | @Override | 176 | @Override |
177 | public void onItemClick(AdapterView<?> parent, View view, int | 177 | public void onItemClick(AdapterView<?> parent, View view, int |
178 | position, long id) { | 178 | position, long id) { |
179 | switch (position) { | 179 | switch (position) { |
180 | case 0: | 180 | case 0: |
181 | tv_sex.setText("男"); | 181 | tv_sex.setText("男"); |
182 | break; | 182 | break; |
183 | case 1: | 183 | case 1: |
184 | tv_sex.setText("女"); | 184 | tv_sex.setText("女"); |
185 | break; | 185 | break; |
186 | } | 186 | } |
187 | 187 | ||
188 | } | 188 | } |
189 | }) | 189 | }) |
190 | .show(); | 190 | .show(); |
191 | break; | 191 | break; |
192 | case R.id.tv_useinfo_adress: | 192 | case R.id.tv_useinfo_adress: |
193 | case R.id.my_adress: | 193 | case R.id.my_adress: |
194 | tv_useinfo_school.setText(""); | 194 | tv_useinfo_school.setText(""); |
195 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); | 195 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); |
196 | break; | 196 | break; |
197 | case R.id.tv_useinfo_birthday: | 197 | case R.id.tv_useinfo_birthday: |
198 | case R.id.my_bthday: | 198 | case R.id.my_bthday: |
199 | pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view | 199 | pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view |
200 | break; | 200 | break; |
201 | case R.id.tv_useinfo_school: | 201 | case R.id.tv_useinfo_school: |
202 | case R.id.my_school: | 202 | case R.id.my_school: |
203 | if (TextUtils.isEmpty(presonal4) || | 203 | if (TextUtils.isEmpty(presonal4) || |
204 | TextUtils.isEmpty(presonal7)) { | 204 | TextUtils.isEmpty(presonal7)) { |
205 | AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); | 205 | AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); |
206 | return; | 206 | return; |
207 | } else { | 207 | } else { |
208 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); | 208 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | break; | 212 | break; |
213 | case R.id.tv_useinfo_gender: | 213 | case R.id.tv_useinfo_gender: |
214 | case R.id.my_grade: | 214 | case R.id.my_grade: |
215 | tv_useinfo_school.setText(""); | 215 | tv_useinfo_school.setText(""); |
216 | Content.changeinfoflag = true; | 216 | Content.changeinfoflag = true; |
217 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); | 217 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); |
218 | break; | 218 | break; |
219 | case R.id.cancel: | 219 | case R.id.cancel: |
220 | getActivity().finish(); | 220 | getActivity().finish(); |
221 | break; | 221 | break; |
222 | case R.id.tv_version: | 222 | case R.id.tv_version: |
223 | final ChangePresonalInfoActivity mainActivity = (ChangePresonalInfoActivity) getActivity(); | 223 | final ChangePresonalInfoActivity mainActivity = (ChangePresonalInfoActivity) getActivity(); |
224 | mainActivity.setFragment2Fragment(new ChangePresonalInfoActivity.Fragment2Fragment() { | 224 | mainActivity.setFragment2Fragment(new ChangePresonalInfoActivity.Fragment2Fragment() { |
225 | @Override | 225 | @Override |
226 | public void gotoFragment(ViewPager viewPager) { | 226 | public void gotoFragment(ViewPager viewPager) { |
227 | //fragment传递数据 | 227 | //fragment传递数据 |
228 | viewPager.setCurrentItem(1); | 228 | viewPager.setCurrentItem(1); |
229 | } | 229 | } |
230 | }); | 230 | }); |
231 | mainActivity.forSkip(); | 231 | mainActivity.forSkip(); |
232 | break; | 232 | break; |
233 | case R.id.presonal_sub: | 233 | case R.id.presonal_sub: |
234 | Log.e("test", "你提交个人信息"); | 234 | Log.e("test", "你提交个人信息"); |
235 | if (TextUtils.isEmpty(presonal1) || | 235 | if (TextUtils.isEmpty(presonal1) || |
236 | TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || | 236 | TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || |
237 | TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || | 237 | TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || |
238 | TextUtils.isEmpty(presonal8)) { | 238 | TextUtils.isEmpty(presonal8)) { |
239 | AlertUtils.showToast(getActivity(), "请将信息填写完整!"); | 239 | AlertUtils.showToast(getActivity(), "请将信息填写完整!"); |
240 | return; | 240 | return; |
241 | } else { | 241 | } else { |
242 | int a = 0, b = 0; | 242 | int a = 0, b = 0; |
243 | int d = 1; | 243 | int d = 1; |
244 | Object schoolids; | 244 | Object schoolids; |
245 | Long f = null; | 245 | Long f = null; |
246 | String regionId = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.COUNTRY); | 246 | String regionId = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.COUNTRY); |
247 | String regionId1 = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.CITYS); | 247 | String regionId1 = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.CITYS); |
248 | if (regionId == null) { | 248 | if (regionId == null) { |
249 | regionId = regionId1; | 249 | regionId = regionId1; |
250 | } | 250 | } |
251 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CHILDSGRADENS); | 251 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CHILDSGRADENS); |
252 | String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOOlID); | 252 | String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOOlID); |
253 | String type = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); | 253 | String type = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); |
254 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 254 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
255 | String devicenumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); | 255 | String devicenumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); |
256 | String changeinfo = null; | 256 | String changeinfo = null; |
257 | if ("男".equals(presonal3)) { | 257 | if ("男".equals(presonal3)) { |
258 | changeinfo = "male"; | 258 | changeinfo = "male"; |
259 | } else { | 259 | } else { |
260 | changeinfo = "female"; | 260 | changeinfo = "female"; |
261 | } | 261 | } |
262 | try { | 262 | try { |
263 | a = Integer.parseInt(regionId); | 263 | a = Integer.parseInt(regionId); |
264 | b = Integer.parseInt(grade); | 264 | b = Integer.parseInt(grade); |
265 | if (TextUtils.isEmpty(presonal6)) { | 265 | if (TextUtils.isEmpty(presonal6)) { |
266 | schoolids = null; | 266 | schoolids = null; |
267 | } else { | 267 | } else { |
268 | schoolids = Long.parseLong(schoolid); | 268 | schoolids = Long.parseLong(schoolid); |
269 | } | 269 | } |
270 | d = Integer.parseInt(type); | 270 | d = Integer.parseInt(type); |
271 | f = Long.parseLong(userID); | 271 | f = Long.parseLong(userID); |
272 | //提交个人信息 | 272 | //提交个人信息 |
273 | HttpManager.getInstance().changepresonalinfo(getActivity(), | 273 | HttpManager.getInstance().changepresonalinfo(getActivity(), |
274 | f, d, presonal1, presonal5, b, a, schoolids, presonal8, changeinfo, presonal4 + presonal2, devicenumber); | 274 | f, d, presonal1, presonal5, b, a, schoolids, presonal8, changeinfo, presonal4 ,presonal2,devicenumber); |
275 | 275 | ||
276 | } catch (Exception e) { | 276 | } catch (Exception e) { |
277 | e.printStackTrace(); | 277 | e.printStackTrace(); |
278 | } | 278 | } |
279 | 279 | ||
280 | break; | 280 | break; |
281 | 281 | ||
282 | } | 282 | } |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | //自定义时间选择器 | 286 | //自定义时间选择器 |
287 | private void initTimePicker() { | 287 | private void initTimePicker() { |
288 | //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) | 288 | //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) |
289 | //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | 289 | //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 |
290 | // Calendar selectedDate = Calendar.getInstance(); | 290 | // Calendar selectedDate = Calendar.getInstance(); |
291 | // Calendar startDate = Calendar.getInstance(); | 291 | // Calendar startDate = Calendar.getInstance(); |
292 | // startDate.set(1900, 1, 1); | 292 | // startDate.set(1900, 1, 1); |
293 | // Calendar endDate = Calendar.getInstance(); | 293 | // Calendar endDate = Calendar.getInstance(); |
294 | // endDate.set(2100, 1, 1); | 294 | // endDate.set(2100, 1, 1); |
295 | //时间选择器 | 295 | //时间选择器 |
296 | pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { | 296 | pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { |
297 | @Override | 297 | @Override |
298 | public void onTimeSelect(Date date, View v) {//选中事件回调 | 298 | public void onTimeSelect(Date date, View v) {//选中事件回调 |
299 | // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null | 299 | // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null |
300 | /*btn_Time.setText(getTime(date));*/ | 300 | /*btn_Time.setText(getTime(date));*/ |
301 | TextView btn = (TextView) v; | 301 | TextView btn = (TextView) v; |
302 | btn.setText(getTime(date)); | 302 | btn.setText(getTime(date)); |
303 | } | 303 | } |
304 | }) | 304 | }) |
305 | //年月日时分秒 的显示与否,不设置则默认全部显示 | 305 | //年月日时分秒 的显示与否,不设置则默认全部显示 |
306 | .setType(new boolean[]{true, true, true, false, false, false}) | 306 | .setType(new boolean[]{true, true, true, false, false, false}) |
307 | .setLabel("", "", "", "", "", "") | 307 | .setLabel("", "", "", "", "", "") |
308 | .isCenterLabel(false) | 308 | .isCenterLabel(false) |
309 | .setDividerColor(Color.DKGRAY) | 309 | .setDividerColor(Color.DKGRAY) |
310 | .setContentSize(21) | 310 | .setContentSize(21) |
311 | // .setDate(selectedDate) | 311 | // .setDate(selectedDate) |
312 | // .setRangDate(startDate, endDate) | 312 | // .setRangDate(startDate, endDate) |
313 | .setBackgroundId(0x80000000) //设置外部遮罩颜色 | 313 | .setBackgroundId(0x80000000) //设置外部遮罩颜色 |
314 | .setDecorView(null) | 314 | .setDecorView(null) |
315 | .setTitleText("出生日期") | 315 | .setTitleText("出生日期") |
316 | .setTitleSize(22) | 316 | .setTitleSize(22) |
317 | .setCancelColor(Color.GRAY) | 317 | .setCancelColor(Color.GRAY) |
318 | .setSubCalSize(22) | 318 | .setSubCalSize(22) |
319 | .setDividerColor(Color.GRAY) | 319 | .setDividerColor(Color.GRAY) |
320 | .setSubmitColor(Color.GRAY) | 320 | .setSubmitColor(Color.GRAY) |
321 | .build(); | 321 | .build(); |
322 | } | 322 | } |
323 | 323 | ||
324 | private String getTime(Date date) {//可根据需要自行截取数据显示 | 324 | private String getTime(Date date) {//可根据需要自行截取数据显示 |
325 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | 325 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
326 | return format.format(date); | 326 | return format.format(date); |
327 | } | 327 | } |
328 | 328 | ||
329 | @Override | 329 | @Override |
330 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | 330 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { |
331 | String regionName = data.get(position).getRegionName(); | 331 | String regionName = data.get(position).getRegionName(); |
332 | String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); | 332 | String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); |
333 | SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); | 333 | SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); |
334 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); | 334 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); |
335 | tv_useinfo_adress.setText(""); | 335 | tv_useinfo_adress.setText(""); |
336 | tv_useinfo_adress.setText(provice + regionName); | 336 | tv_useinfo_adress.setText(provice + regionName); |
337 | 337 | ||
338 | 338 | ||
339 | } | 339 | } |
340 | 340 | ||
341 | @Override | 341 | @Override |
342 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { | 342 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { |
343 | String regionName = data.get(position).getRegionName(); | 343 | String regionName = data.get(position).getRegionName(); |
344 | String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); | 344 | String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); |
345 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); | 345 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); |
346 | tv_useinfo_adress.setText(""); | 346 | tv_useinfo_adress.setText(""); |
347 | tv_useinfo_adress.setText(provices + citys + regionName); | 347 | tv_useinfo_adress.setText(provices + citys + regionName); |
348 | 348 | ||
349 | } | 349 | } |
350 | 350 | ||
351 | @Override | 351 | @Override |
352 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | 352 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { |
353 | String regionName = data.get(position).getName(); | 353 | String regionName = data.get(position).getName(); |
354 | tv_useinfo_gender.setText(regionName); | 354 | tv_useinfo_gender.setText(regionName); |
355 | } | 355 | } |
356 | 356 | ||
357 | @Override | 357 | @Override |
358 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { | 358 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
359 | String regionName = data.get(position).getRegionName(); | 359 | String regionName = data.get(position).getRegionName(); |
360 | SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); | 360 | SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); |
361 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); | 361 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); |
362 | tv_useinfo_adress.setText(""); | 362 | tv_useinfo_adress.setText(""); |
363 | tv_useinfo_adress.setText(regionName); | 363 | tv_useinfo_adress.setText(regionName); |
364 | } | 364 | } |
365 | 365 | ||
366 | @Override | 366 | @Override |
367 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { | 367 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { |
368 | String regionName = data.get(position).getSchoolName(); | 368 | String regionName = data.get(position).getSchoolName(); |
369 | tv_useinfo_school.setText(regionName); | 369 | tv_useinfo_school.setText(regionName); |
370 | 370 | ||
371 | 371 | ||
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpKey.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /**请求参数 | 3 | /**请求参数 |
4 | * Created by wei on 2017/6/20. | 4 | * Created by wei on 2017/6/20. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpKey { | 7 | public class HttpKey { |
8 | //注册key | 8 | //注册key |
9 | public static String USERNAME = "username"; | 9 | public static String USERNAME = "username"; |
10 | public static String PASSWORD = "password"; | 10 | public static String PASSWORD = "password"; |
11 | public static String SMSCODE = "smscode"; | 11 | public static String SMSCODE = "smscode"; |
12 | public static String SOURCE = "source"; | 12 | public static String SOURCE = "source"; |
13 | //忘记密码 | 13 | //忘记密码 |
14 | public static String AUTHCODE = "authCode"; | 14 | public static String AUTHCODE = "authCode"; |
15 | //注册验证码和忘记密码验证码 | 15 | //注册验证码和忘记密码验证码 |
16 | public static String TYPE = "type"; | 16 | public static String TYPE = "type"; |
17 | public static String MOBIL = "mobile"; | 17 | public static String MOBIL = "mobile"; |
18 | //修改密码 | 18 | //修改密码 |
19 | public static String OLDPASS = "oldPass"; | 19 | public static String OLDPASS = "oldPass"; |
20 | public static String NEWPASS = "newPass"; | 20 | public static String NEWPASS = "newPass"; |
21 | //提交保卡 | 21 | //提交保卡 |
22 | public static String USEID = "userId"; | 22 | public static String USEID = "userId"; |
23 | public static String CUSTOMENAME = "customerName"; | 23 | public static String CUSTOMENAME = "customerName"; |
24 | public static String CUSTOMADRESS = "customerAddress"; | 24 | public static String CUSTOMADRESS = "customerAddress"; |
25 | public static String BUYADREES = "buyAddress"; | 25 | public static String BUYADREES = "buyAddress"; |
26 | public static String BUYTIME = "buyTime"; | 26 | public static String BUYTIME = "buyTime"; |
27 | public static String ALTERSALECALL = "alterSaleCall"; | 27 | public static String ALTERSALECALL = "alterSaleCall"; |
28 | public static String PRODUCTMODEL = "productModel"; | 28 | public static String PRODUCTMODEL = "productModel"; |
29 | public static String DEVICENUMBER = "deviceNumber"; | 29 | public static String DEVICENUMBER = "deviceNumber"; |
30 | public static String MACADRESS = "macAddress"; | 30 | public static String MACADRESS = "macAddress"; |
31 | public static String MOBILPHONE = "customerPhone"; | 31 | public static String MOBILPHONE = "customerPhone"; |
32 | //提交子账户信息 | 32 | //提交子账户信息 |
33 | public static String PARENTID = "parentId"; | 33 | public static String PARENTID = "parentId"; |
34 | public static String IMAGE = "image"; | 34 | public static String IMAGE = "image"; |
35 | public static String NAME = "name"; | 35 | public static String NAME = "name"; |
36 | public static String GRADE = "gradeId"; | 36 | public static String GRADE = "gradeId"; |
37 | public static String SCHOOL = "schoolId"; | 37 | public static String SCHOOL = "schoolId"; |
38 | public static String REGION = "regionId"; | 38 | public static String REGION = "regionId"; |
39 | public static String DEVINUMBER = "deviceNumber"; | 39 | public static String DEVINUMBER = "deviceNumber"; |
40 | public static String REGIONNAME = "regionName"; | 40 | public static String REGIONNAME = "regionName"; |
41 | public static String ADDDRESS = "address"; | ||
41 | //提交个人信息 | 42 | //提交个人信息 |
42 | public static String ID = "id"; | 43 | public static String ID = "id"; |
43 | public static String BIRDays = "birthday"; | 44 | public static String BIRDays = "birthday"; |
44 | public static String QQ = "qq"; | 45 | public static String QQ = "qq"; |
45 | public static String GENDER = "gender"; | 46 | public static String GENDER = "gender"; |
46 | //版本信息 | 47 | //版本信息 |
47 | public static String CHINESE = "chinese"; | 48 | public static String CHINESE = "chinese"; |
48 | public static String MATH = "math"; | 49 | public static String MATH = "math"; |
49 | public static String ENGLISH = "english"; | 50 | public static String ENGLISH = "english"; |
50 | public static String PHYSICES = "physics"; | 51 | public static String PHYSICES = "physics"; |
51 | public static String CHEMISTRY = "chemistry"; | 52 | public static String CHEMISTRY = "chemistry"; |
52 | public static String HISTIRY = "history"; | 53 | public static String HISTIRY = "history"; |
53 | public static String GEOGRAPHY = "geography"; | 54 | public static String GEOGRAPHY = "geography"; |
54 | public static String POLITICAL = "political"; | 55 | public static String POLITICAL = "political"; |
55 | public static String BIOLOGY = "biology"; | 56 | public static String BIOLOGY = "biology"; |
56 | public static String SCIENCE = "science"; | 57 | public static String SCIENCE = "science"; |
57 | 58 | ||
58 | 59 | ||
59 | 60 | ||
60 | 61 | ||
61 | 62 | ||
62 | 63 | ||
63 | 64 | ||
64 | 65 | ||
65 | 66 | ||
66 | } | 67 | } |
67 | 68 |
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 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.DEVINUMBER, devicenumber); | 694 | params.put(HttpKey.DEVINUMBER, devicenumber); |
694 | Log.e("test", "个人信息" + params); | 695 | Log.e("test", "个人信息" + params); |
695 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 696 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
696 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 697 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
697 | @Override | 698 | @Override |
698 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 699 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
699 | super.onSuccess(statusCode, headers, response); | 700 | super.onSuccess(statusCode, headers, response); |
700 | closeProgress(); | 701 | closeProgress(); |
701 | String status = response.optString("status"); | 702 | String status = response.optString("status"); |
702 | if (status.equals("1")) { | 703 | if (status.equals("1")) { |
703 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 704 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
704 | ((Activity) mContext).finish(); | 705 | ((Activity) mContext).finish(); |
705 | } else { | 706 | } else { |
706 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 707 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
707 | } | 708 | } |
708 | 709 | ||
709 | } | 710 | } |
710 | 711 | ||
711 | @Override | 712 | @Override |
712 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 713 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
713 | super.onFailure(statusCode, headers, throwable, errorResponse); | 714 | super.onFailure(statusCode, headers, throwable, errorResponse); |
714 | closeProgress(); | 715 | closeProgress(); |
715 | Log.e("test", "onFailure" + errorResponse); | 716 | Log.e("test", "onFailure" + errorResponse); |
716 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 717 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
717 | } | 718 | } |
718 | 719 | ||
719 | }); | 720 | }); |
720 | } | 721 | } |
721 | 722 | ||
722 | //提交注册信息 | 723 | //提交注册信息 |
723 | public void subregisterinfo(final Context mContext, Long userId | 724 | public void subregisterinfo(final Context mContext, Long userId |
724 | , 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, |
725 | String math, String english, String physics, String chemistry, | 726 | String math, String english, String physics, String chemistry, |
726 | 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) { |
727 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 728 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
728 | false, true, null); | 729 | false, true, null); |
729 | RequestParams params = new RequestParams(); | 730 | RequestParams params = new RequestParams(); |
730 | 731 | ||
731 | params.put(HttpKey.USEID, userId); | 732 | params.put(HttpKey.USEID, userId); |
732 | params.put(HttpKey.NAME, name); | 733 | params.put(HttpKey.NAME, name); |
733 | params.put(HttpKey.GRADE, gradeId); | 734 | params.put(HttpKey.GRADE, gradeId); |
734 | params.put(HttpKey.REGION, regionId); | 735 | params.put(HttpKey.REGION, regionId); |
735 | params.put(HttpKey.SCHOOL, schoolId); | 736 | params.put(HttpKey.SCHOOL, schoolId); |
736 | params.put(HttpKey.REGIONNAME, regionName); | 737 | params.put(HttpKey.REGIONNAME, regionName); |
737 | params.put(HttpKey.MATH, math); | 738 | params.put(HttpKey.MATH, math); |
738 | params.put(HttpKey.ENGLISH, english); | 739 | params.put(HttpKey.ENGLISH, english); |
739 | params.put(HttpKey.PHYSICES, physics); | 740 | params.put(HttpKey.PHYSICES, physics); |
740 | params.put(HttpKey.CHEMISTRY, chemistry); | 741 | params.put(HttpKey.CHEMISTRY, chemistry); |
741 | params.put(HttpKey.HISTIRY, history); | 742 | params.put(HttpKey.HISTIRY, history); |
742 | params.put(HttpKey.GEOGRAPHY, geography); | 743 | params.put(HttpKey.GEOGRAPHY, geography); |
743 | params.put(HttpKey.POLITICAL, political); | 744 | params.put(HttpKey.POLITICAL, political); |
744 | params.put(HttpKey.BIOLOGY, biology); | 745 | params.put(HttpKey.BIOLOGY, biology); |
745 | params.put(HttpKey.SCIENCE, science); | 746 | params.put(HttpKey.SCIENCE, science); |
746 | 747 | ||
747 | Log.e("test", "注册信息" + params); | 748 | Log.e("test", "注册信息" + params); |
748 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 749 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
749 | HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { | 750 | HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { |
750 | @Override | 751 | @Override |
751 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 752 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
752 | super.onSuccess(statusCode, headers, response); | 753 | super.onSuccess(statusCode, headers, response); |
753 | closeProgress(); | 754 | closeProgress(); |
754 | Message message = Message.obtain(); | 755 | Message message = Message.obtain(); |
755 | message.what = HttpCode.REGISTERINFO_SUCESS; | 756 | message.what = HttpCode.REGISTERINFO_SUCESS; |
756 | message.obj = new String(String.valueOf(response)); | 757 | message.obj = new String(String.valueOf(response)); |
757 | handler.sendMessage(message); | 758 | handler.sendMessage(message); |
758 | 759 | ||
759 | } | 760 | } |
760 | 761 | ||
761 | @Override | 762 | @Override |
762 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 763 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
763 | super.onFailure(statusCode, headers, throwable, errorResponse); | 764 | super.onFailure(statusCode, headers, throwable, errorResponse); |
764 | closeProgress(); | 765 | closeProgress(); |
765 | Log.e("test", "onFailure" + errorResponse); | 766 | Log.e("test", "onFailure" + errorResponse); |
766 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 767 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
767 | } | 768 | } |
768 | 769 | ||
769 | }); | 770 | }); |
770 | } | 771 | } |
771 | 772 | ||
772 | //修改版本信息 | 773 | //修改版本信息 |
773 | public void changepublishinfo(final Context mContext, String userId, String chinese, | 774 | public void changepublishinfo(final Context mContext, String userId, String chinese, |
774 | String math, String english, String physics, String chemistry, | 775 | String math, String english, String physics, String chemistry, |
775 | String history, String geography, String political, String biology, String science) { | 776 | String history, String geography, String political, String biology, String science) { |
776 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 777 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
777 | false, true, null); | 778 | false, true, null); |
778 | RequestParams params = new RequestParams(); | 779 | RequestParams params = new RequestParams(); |
779 | params.put(HttpKey.USEID, userId); | 780 | params.put(HttpKey.USEID, userId); |
780 | params.put(HttpKey.CHINESE, chinese); | 781 | params.put(HttpKey.CHINESE, chinese); |
781 | params.put(HttpKey.MATH, math); | 782 | params.put(HttpKey.MATH, math); |
782 | params.put(HttpKey.ENGLISH, english); | 783 | params.put(HttpKey.ENGLISH, english); |
783 | params.put(HttpKey.PHYSICES, physics); | 784 | params.put(HttpKey.PHYSICES, physics); |
784 | params.put(HttpKey.CHEMISTRY, chemistry); | 785 | params.put(HttpKey.CHEMISTRY, chemistry); |
785 | params.put(HttpKey.HISTIRY, history); | 786 | params.put(HttpKey.HISTIRY, history); |
786 | params.put(HttpKey.GEOGRAPHY, geography); | 787 | params.put(HttpKey.GEOGRAPHY, geography); |
787 | params.put(HttpKey.POLITICAL, political); | 788 | params.put(HttpKey.POLITICAL, political); |
788 | params.put(HttpKey.BIOLOGY, biology); | 789 | params.put(HttpKey.BIOLOGY, biology); |
789 | params.put(HttpKey.SCIENCE, science); | 790 | params.put(HttpKey.SCIENCE, science); |
790 | 791 | ||
791 | Log.e("test", "版本信息信息" + params); | 792 | Log.e("test", "版本信息信息" + params); |
792 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 793 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
793 | HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { | 794 | HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { |
794 | @Override | 795 | @Override |
795 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 796 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
796 | super.onSuccess(statusCode, headers, response); | 797 | super.onSuccess(statusCode, headers, response); |
797 | closeProgress(); | 798 | closeProgress(); |
798 | String status = response.optString("status"); | 799 | String status = response.optString("status"); |
799 | if (status.equals("1")) { | 800 | if (status.equals("1")) { |
800 | Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); | 801 | Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); |
801 | ((Activity) mContext).finish(); | 802 | ((Activity) mContext).finish(); |
802 | } else { | 803 | } else { |
803 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 804 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
804 | } | 805 | } |
805 | 806 | ||
806 | } | 807 | } |
807 | 808 | ||
808 | @Override | 809 | @Override |
809 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 810 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
810 | super.onFailure(statusCode, headers, throwable, errorResponse); | 811 | super.onFailure(statusCode, headers, throwable, errorResponse); |
811 | closeProgress(); | 812 | closeProgress(); |
812 | Log.e("test", "onFailure" + errorResponse); | 813 | Log.e("test", "onFailure" + errorResponse); |
813 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 814 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
814 | } | 815 | } |
815 | 816 | ||
816 | }); | 817 | }); |
817 | } | 818 | } |
818 | 819 | ||
819 | //修改个性签名 | 820 | //修改个性签名 |
820 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 821 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
821 | RequestParams params = new RequestParams(); | 822 | RequestParams params = new RequestParams(); |
822 | params.put("userId", userId); | 823 | params.put("userId", userId); |
823 | params.put("type", type); | 824 | params.put("type", type); |
824 | params.put("signature", signature); | 825 | params.put("signature", signature); |
825 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 826 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
826 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 827 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
827 | @Override | 828 | @Override |
828 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 829 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
829 | try { | 830 | try { |
830 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 831 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
831 | String status = jsonObject.optString("status"); | 832 | String status = jsonObject.optString("status"); |
832 | if (status.equals("1")) { | 833 | if (status.equals("1")) { |
833 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 834 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
834 | } else { | 835 | } else { |
835 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 836 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
836 | } | 837 | } |
837 | } catch (JSONException e) { | 838 | } catch (JSONException e) { |
838 | e.printStackTrace(); | 839 | e.printStackTrace(); |
839 | } | 840 | } |
840 | } | 841 | } |
841 | 842 | ||
842 | @Override | 843 | @Override |
843 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 844 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
844 | //Log.e("test", "onFailure" + new String(bytes)); | 845 | //Log.e("test", "onFailure" + new String(bytes)); |
845 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 846 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
846 | } | 847 | } |
847 | }); | 848 | }); |
848 | } | 849 | } |
849 | 850 | ||
850 | /** | 851 | /** |
851 | * 获取个性签名 | 852 | * 获取个性签名 |
852 | * | 853 | * |
853 | * @param mContext | 854 | * @param mContext |
854 | * @param userId | 855 | * @param userId |
855 | * @param handler | 856 | * @param handler |
856 | */ | 857 | */ |
857 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 858 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
858 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 859 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
859 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 860 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
860 | @Override | 861 | @Override |
861 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 862 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
862 | Log.e("test", "个性签名" + new String(arg2)); | 863 | Log.e("test", "个性签名" + new String(arg2)); |
863 | try { | 864 | try { |
864 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 865 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
865 | int status = jsonObject.optInt("status"); | 866 | int status = jsonObject.optInt("status"); |
866 | if (status == 1) { | 867 | if (status == 1) { |
867 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 868 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
868 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 869 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
869 | Message message = Message.obtain(); | 870 | Message message = Message.obtain(); |
870 | message.what = HttpCode.SIGN; | 871 | message.what = HttpCode.SIGN; |
871 | message.obj = signInfoBeanList; | 872 | message.obj = signInfoBeanList; |
872 | handler.sendMessage(message); | 873 | handler.sendMessage(message); |
873 | 874 | ||
874 | 875 | ||
875 | } else if (status == 1000) { | 876 | } else if (status == 1000) { |
876 | //AlertUtils.showToast(mContext, "您还没有签名哦"); | 877 | //AlertUtils.showToast(mContext, "您还没有签名哦"); |
877 | 878 | ||
878 | } else { | 879 | } else { |
879 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 880 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
880 | } | 881 | } |
881 | } catch (JSONException e) { | 882 | } catch (JSONException e) { |
882 | e.printStackTrace(); | 883 | e.printStackTrace(); |
883 | } | 884 | } |
884 | 885 | ||
885 | 886 | ||
886 | } | 887 | } |
887 | 888 | ||
888 | @Override | 889 | @Override |
889 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 890 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
890 | //Log.e("test", "失败原因" + arg3); | 891 | //Log.e("test", "失败原因" + arg3); |
891 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 892 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
892 | } | 893 | } |
893 | }); | 894 | }); |
894 | } | 895 | } |
895 | 896 | ||
896 | /** | 897 | /** |
897 | * 用户反馈 | 898 | * 用户反馈 |
898 | * | 899 | * |
899 | * @param mContext | 900 | * @param mContext |
900 | * @param userId | 901 | * @param userId |
901 | * @param content | 902 | * @param content |
902 | * @param contact | 903 | * @param contact |
903 | * @param imgs | 904 | * @param imgs |
904 | * @param feedtype | 905 | * @param feedtype |
905 | * @throws UnsupportedEncodingException | 906 | * @throws UnsupportedEncodingException |
906 | */ | 907 | */ |
907 | public void feedback(final Context mContext, String userId, String content, | 908 | public void feedback(final Context mContext, String userId, String content, |
908 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 909 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
909 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 910 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
910 | false, true, null); | 911 | false, true, null); |
911 | File file = new File(imgs); | 912 | File file = new File(imgs); |
912 | RequestParams params = new RequestParams(); | 913 | RequestParams params = new RequestParams(); |
913 | try { | 914 | try { |
914 | params.put("userId", userId); | 915 | params.put("userId", userId); |
915 | params.put("content", content); | 916 | params.put("content", content); |
916 | params.put("contact", contact); | 917 | params.put("contact", contact); |
917 | if (file.exists() && file.length() > 0) { | 918 | if (file.exists() && file.length() > 0) { |
918 | params.put("imgs", file); | 919 | params.put("imgs", file); |
919 | } | 920 | } |
920 | params.put("feedtype", feedtype); | 921 | params.put("feedtype", feedtype); |
921 | } catch (FileNotFoundException e) { | 922 | } catch (FileNotFoundException e) { |
922 | e.printStackTrace(); | 923 | e.printStackTrace(); |
923 | } | 924 | } |
924 | Log.e("test", "onSuccess" + params); | 925 | Log.e("test", "onSuccess" + params); |
925 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 926 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
926 | @Override | 927 | @Override |
927 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 928 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
928 | closeProgress(); | 929 | closeProgress(); |
929 | Log.e("test", "onSuccess" + new String(bytes)); | 930 | Log.e("test", "onSuccess" + new String(bytes)); |
930 | try { | 931 | try { |
931 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 932 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
932 | String status = jsonObject.optString("status"); | 933 | String status = jsonObject.optString("status"); |
933 | if (status.equals("1")) { | 934 | if (status.equals("1")) { |
934 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 935 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
935 | ((Activity) mContext).finish(); | 936 | ((Activity) mContext).finish(); |
936 | } else { | 937 | } else { |
937 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 938 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
938 | } | 939 | } |
939 | } catch (JSONException e) { | 940 | } catch (JSONException e) { |
940 | e.printStackTrace(); | 941 | e.printStackTrace(); |
941 | } | 942 | } |
942 | } | 943 | } |
943 | 944 | ||
944 | @Override | 945 | @Override |
945 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 946 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
946 | closeProgress(); | 947 | closeProgress(); |
947 | //Log.e("test", "错误信息" + new String(bytes)); | 948 | //Log.e("test", "错误信息" + new String(bytes)); |
948 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 949 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
949 | 950 | ||
950 | } | 951 | } |
951 | }); | 952 | }); |
952 | 953 | ||
953 | } | 954 | } |
954 | 955 | ||
955 | /** | 956 | /** |
956 | * 查询子账户信息 | 957 | * 查询子账户信息 |
957 | * | 958 | * |
958 | * @param mContext | 959 | * @param mContext |
959 | * @param userId | 960 | * @param userId |
960 | * @param handler | 961 | * @param handler |
961 | */ | 962 | */ |
962 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 963 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
963 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...", | 964 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...", |
964 | false, true, null); | 965 | false, true, null); |
965 | 966 | ||
966 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 967 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
967 | HttpClient.getInstance().setTimeout(5 * 1000); | 968 | HttpClient.getInstance().setTimeout(5 * 1000); |
968 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 969 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
969 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 970 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
970 | @Override | 971 | @Override |
971 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 972 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
972 | closeProgress(); | 973 | closeProgress(); |
973 | Log.e("test", "子账户信息" + new String(arg2)); | 974 | Log.e("test", "子账户信息" + new String(arg2)); |
974 | try { | 975 | try { |
975 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 976 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
976 | int status = jsonObject.optInt("status"); | 977 | int status = jsonObject.optInt("status"); |
977 | if (status == 1) { | 978 | if (status == 1) { |
978 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 979 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
979 | Log.e("test", "子账户信息" + childsInfo); | 980 | Log.e("test", "子账户信息" + childsInfo); |
980 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 981 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
981 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 982 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
982 | Message msg = Message.obtain(); | 983 | Message msg = Message.obtain(); |
983 | msg.what = HttpCode.CHILDS_SUCESS; | 984 | msg.what = HttpCode.CHILDS_SUCESS; |
984 | msg.obj = schoolInfoBeanList; | 985 | msg.obj = schoolInfoBeanList; |
985 | handler.sendMessage(msg); | 986 | handler.sendMessage(msg); |
986 | 987 | ||
987 | } else { | 988 | } else { |
988 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 989 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
989 | 990 | ||
990 | } | 991 | } |
991 | } catch (JSONException e) { | 992 | } catch (JSONException e) { |
992 | e.printStackTrace(); | 993 | e.printStackTrace(); |
993 | 994 | ||
994 | } | 995 | } |
995 | 996 | ||
996 | } | 997 | } |
997 | 998 | ||
998 | @Override | 999 | @Override |
999 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1000 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1000 | closeProgress(); | 1001 | closeProgress(); |
1001 | // Log.e("test", "错误信息" + new String(arg2)); | 1002 | // Log.e("test", "错误信息" + new String(arg2)); |
1002 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1003 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1003 | } | 1004 | } |
1004 | }); | 1005 | }); |
1005 | 1006 | ||
1006 | } | 1007 | } |
1007 | 1008 | ||
1008 | /** | 1009 | /** |
1009 | * 删除子账户信息 | 1010 | * 删除子账户信息 |
1010 | * | 1011 | * |
1011 | * @param mContext | 1012 | * @param mContext |
1012 | * @param subAccountId | 1013 | * @param subAccountId |
1013 | */ | 1014 | */ |
1014 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 1015 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
1015 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 1016 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
1016 | false, true, null); | 1017 | false, true, null); |
1017 | HttpClient.getInstance().setTimeout(5 * 1000); | 1018 | HttpClient.getInstance().setTimeout(5 * 1000); |
1018 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1019 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1019 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 1020 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
1020 | @Override | 1021 | @Override |
1021 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1022 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1022 | closeProgress(); | 1023 | closeProgress(); |
1023 | Log.e("test", "子账户信息" + new String(arg2)); | 1024 | Log.e("test", "子账户信息" + new String(arg2)); |
1024 | try { | 1025 | try { |
1025 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1026 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1026 | int status = jsonObject.optInt("status"); | 1027 | int status = jsonObject.optInt("status"); |
1027 | if (status == 1) { | 1028 | if (status == 1) { |
1028 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 1029 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
1029 | ((Activity) mContext).finish(); | 1030 | ((Activity) mContext).finish(); |
1030 | } else { | 1031 | } else { |
1031 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 1032 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
1032 | 1033 | ||
1033 | } | 1034 | } |
1034 | } catch (JSONException e) { | 1035 | } catch (JSONException e) { |
1035 | e.printStackTrace(); | 1036 | e.printStackTrace(); |
1036 | } | 1037 | } |
1037 | 1038 | ||
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | @Override | 1041 | @Override |
1041 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1042 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1042 | closeProgress(); | 1043 | closeProgress(); |
1043 | Log.e("test", "错误信息" + new String(arg2)); | 1044 | Log.e("test", "错误信息" + new String(arg2)); |
1044 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1045 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1045 | } | 1046 | } |
1046 | }); | 1047 | }); |
1047 | 1048 | ||
1048 | } | 1049 | } |
1049 | 1050 | ||
1050 | /** | 1051 | /** |
1051 | * 添加子账户信息 | 1052 | * 添加子账户信息 |
1052 | */ | 1053 | */ |
1053 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 1054 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
1054 | String name, final Long grade, Object school, Long region | 1055 | String name, final Long grade, Object school, Long region |
1055 | , String deviceNumber, String regionName) { | 1056 | , String deviceNumber, String regionName) { |
1056 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 1057 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
1057 | false, true, null); | 1058 | false, true, null); |
1058 | RequestParams params = new RequestParams(); | 1059 | RequestParams params = new RequestParams(); |
1059 | 1060 | ||
1060 | params.put(HttpKey.PARENTID, parentId); | 1061 | params.put(HttpKey.PARENTID, parentId); |
1061 | params.put(HttpKey.IMAGE, image); | 1062 | params.put(HttpKey.IMAGE, image); |
1062 | params.put(HttpKey.NAME, name); | 1063 | params.put(HttpKey.NAME, name); |
1063 | params.put(HttpKey.GRADE, grade); | 1064 | params.put(HttpKey.GRADE, grade); |
1064 | params.put(HttpKey.SCHOOL, school); | 1065 | params.put(HttpKey.SCHOOL, school); |
1065 | params.put(HttpKey.REGION, region); | 1066 | params.put(HttpKey.REGION, region); |
1066 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 1067 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
1067 | params.put(HttpKey.REGIONNAME, regionName); | 1068 | params.put(HttpKey.REGIONNAME, regionName); |
1068 | 1069 | ||
1069 | Log.e("test", "子账户信息" + params); | 1070 | Log.e("test", "子账户信息" + params); |
1070 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 1071 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
1071 | HttpClient.getInstance().setTimeout(5 * 1000); | 1072 | HttpClient.getInstance().setTimeout(5 * 1000); |
1072 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1073 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1073 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 1074 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
1074 | @Override | 1075 | @Override |
1075 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1076 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1076 | closeProgress(); | 1077 | closeProgress(); |
1077 | 1078 | ||
1078 | Log.e("test", "子账户信息" + new String(arg2)); | 1079 | Log.e("test", "子账户信息" + new String(arg2)); |
1079 | try { | 1080 | try { |
1080 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1081 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1081 | int status = jsonObject.optInt("status"); | 1082 | int status = jsonObject.optInt("status"); |
1082 | if (status == 1) { | 1083 | if (status == 1) { |
1083 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 1084 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
1084 | ((Activity) mContext).finish(); | 1085 | ((Activity) mContext).finish(); |
1085 | } else { | 1086 | } else { |
1086 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 1087 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
1087 | 1088 | ||
1088 | } | 1089 | } |
1089 | } catch (JSONException e) { | 1090 | } catch (JSONException e) { |
1090 | e.printStackTrace(); | 1091 | e.printStackTrace(); |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | } | 1094 | } |
1094 | 1095 | ||
1095 | @Override | 1096 | @Override |
1096 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1097 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1097 | closeProgress(); | 1098 | closeProgress(); |
1098 | Log.e("test", "错误信息" + new String(arg2)); | 1099 | Log.e("test", "错误信息" + new String(arg2)); |
1099 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1100 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1100 | } | 1101 | } |
1101 | }); | 1102 | }); |
1102 | 1103 | ||
1103 | } | 1104 | } |
1104 | 1105 | ||
1105 | /** | 1106 | /** |
1106 | * 切换子账户信息 | 1107 | * 切换子账户信息 |
1107 | * | 1108 | * |
1108 | * @param mContext | 1109 | * @param mContext |
1109 | * @param subAccountId | 1110 | * @param subAccountId |
1110 | */ | 1111 | */ |
1111 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 1112 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
1112 | , String deviceNumber, int type) { | 1113 | , String deviceNumber, int type) { |
1113 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1114 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
1114 | false, true, null); | 1115 | false, true, null); |
1115 | HttpClient.getInstance().setTimeout(5 * 1000); | 1116 | HttpClient.getInstance().setTimeout(5 * 1000); |
1116 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1117 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1117 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 1118 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
1118 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 1119 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
1119 | @Override | 1120 | @Override |
1120 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1121 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1121 | closeProgress(); | 1122 | closeProgress(); |
1122 | Log.e("test", "子账户信息" + new String(arg2)); | 1123 | Log.e("test", "子账户信息" + new String(arg2)); |
1123 | try { | 1124 | try { |
1124 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1125 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1125 | int status = jsonObject.optInt("status"); | 1126 | int status = jsonObject.optInt("status"); |
1126 | if (status == 1) { | 1127 | if (status == 1) { |
1127 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 1128 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
1128 | ((Activity) mContext).finish(); | 1129 | ((Activity) mContext).finish(); |
1129 | 1130 | ||
1130 | } else { | 1131 | } else { |
1131 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 1132 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
1132 | 1133 | ||
1133 | } | 1134 | } |
1134 | } catch (JSONException e) { | 1135 | } catch (JSONException e) { |
1135 | e.printStackTrace(); | 1136 | e.printStackTrace(); |
1136 | } | 1137 | } |
1137 | 1138 | ||
1138 | } | 1139 | } |
1139 | 1140 | ||
1140 | @Override | 1141 | @Override |
1141 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1142 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1142 | closeProgress(); | 1143 | closeProgress(); |
1143 | //Log.e("test", "错误信息" + new String(arg2)); | 1144 | //Log.e("test", "错误信息" + new String(arg2)); |
1144 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1145 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1145 | } | 1146 | } |
1146 | }); | 1147 | }); |
1147 | 1148 | ||
1148 | } | 1149 | } |
1149 | 1150 | ||
1150 | /** | 1151 | /** |
1151 | * 切换主账户信息 | 1152 | * 切换主账户信息 |
1152 | * | 1153 | * |
1153 | * @param mContext | 1154 | * @param mContext |
1154 | * @param type | 1155 | * @param type |
1155 | */ | 1156 | */ |
1156 | public void Accountinfo(final Context mContext, long userId | 1157 | public void Accountinfo(final Context mContext, long userId |
1157 | , String deviceNumber, int type) { | 1158 | , String deviceNumber, int type) { |
1158 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 1159 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
1159 | false, true, null); | 1160 | false, true, null); |
1160 | HttpClient.getInstance().setTimeout(5 * 1000); | 1161 | HttpClient.getInstance().setTimeout(5 * 1000); |
1161 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1162 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1162 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 1163 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
1163 | + "&type=" + type, new AsyncHttpResponseHandler() { | 1164 | + "&type=" + type, new AsyncHttpResponseHandler() { |
1164 | @Override | 1165 | @Override |
1165 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1166 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1166 | closeProgress(); | 1167 | closeProgress(); |
1167 | Log.e("test", "子账户信息" + new String(arg2)); | 1168 | Log.e("test", "子账户信息" + new String(arg2)); |
1168 | try { | 1169 | try { |
1169 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1170 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1170 | int status = jsonObject.optInt("status"); | 1171 | int status = jsonObject.optInt("status"); |
1171 | if (status == 1) { | 1172 | if (status == 1) { |
1172 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1173 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
1173 | ((Activity) mContext).finish(); | 1174 | ((Activity) mContext).finish(); |
1174 | 1175 | ||
1175 | } else { | 1176 | } else { |
1176 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1177 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
1177 | 1178 | ||
1178 | } | 1179 | } |
1179 | } catch (JSONException e) { | 1180 | } catch (JSONException e) { |
1180 | e.printStackTrace(); | 1181 | e.printStackTrace(); |
1181 | } | 1182 | } |
1182 | 1183 | ||
1183 | } | 1184 | } |
1184 | 1185 | ||
1185 | @Override | 1186 | @Override |
1186 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1187 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1187 | closeProgress(); | 1188 | closeProgress(); |
1188 | Log.e("test", "错误信息" + new String(arg2)); | 1189 | Log.e("test", "错误信息" + new String(arg2)); |
1189 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1190 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1190 | } | 1191 | } |
1191 | }); | 1192 | }); |
1192 | 1193 | ||
1193 | } | 1194 | } |
1194 | 1195 | ||
1195 | /** | 1196 | /** |
1196 | * 头像拍张 | 1197 | * 头像拍张 |
1197 | * | 1198 | * |
1198 | * @param mContext | 1199 | * @param mContext |
1199 | * @param userId | 1200 | * @param userId |
1200 | * @param img | 1201 | * @param img |
1201 | * @throws UnsupportedEncodingException | 1202 | * @throws UnsupportedEncodingException |
1202 | */ | 1203 | */ |
1203 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 1204 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
1204 | File file = new File(img); | 1205 | File file = new File(img); |
1205 | if (file.exists() && file.length() > 0) { | 1206 | if (file.exists() && file.length() > 0) { |
1206 | RequestParams params = new RequestParams(); | 1207 | RequestParams params = new RequestParams(); |
1207 | try { | 1208 | try { |
1208 | params.put("userId", userId); | 1209 | params.put("userId", userId); |
1209 | params.put("type", type); | 1210 | params.put("type", type); |
1210 | params.put("img", file); | 1211 | params.put("img", file); |
1211 | } catch (FileNotFoundException e) { | 1212 | } catch (FileNotFoundException e) { |
1212 | e.printStackTrace(); | 1213 | e.printStackTrace(); |
1213 | } | 1214 | } |
1214 | Log.e("test", "params" + params); | 1215 | Log.e("test", "params" + params); |
1215 | HttpClient.getInstance().setTimeout(5 * 1000); | 1216 | HttpClient.getInstance().setTimeout(5 * 1000); |
1216 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1217 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
1217 | @Override | 1218 | @Override |
1218 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1219 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1219 | Log.e("test", "onSuccess" + new String(bytes)); | 1220 | Log.e("test", "onSuccess" + new String(bytes)); |
1220 | try { | 1221 | try { |
1221 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1222 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1222 | String status = jsonObject.optString("status"); | 1223 | String status = jsonObject.optString("status"); |
1223 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); | 1224 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); |
1224 | String imagUrl = jsonObject1.optString("imgUrl"); | 1225 | String imagUrl = jsonObject1.optString("imgUrl"); |
1225 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); | 1226 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); |
1226 | if (status.equals("1")) { | 1227 | if (status.equals("1")) { |
1227 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1228 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1228 | } else { | 1229 | } else { |
1229 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1230 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1230 | } | 1231 | } |
1231 | } catch (JSONException e) { | 1232 | } catch (JSONException e) { |
1232 | e.printStackTrace(); | 1233 | e.printStackTrace(); |
1233 | } | 1234 | } |
1234 | } | 1235 | } |
1235 | 1236 | ||
1236 | @Override | 1237 | @Override |
1237 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1238 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1238 | closeProgress(); | 1239 | closeProgress(); |
1239 | Log.e("test", "错误信息" + new String(bytes)); | 1240 | Log.e("test", "错误信息" + new String(bytes)); |
1240 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1241 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1241 | 1242 | ||
1242 | } | 1243 | } |
1243 | }); | 1244 | }); |
1244 | } else { | 1245 | } else { |
1245 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1246 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
1246 | } | 1247 | } |
1247 | } | 1248 | } |
1248 | 1249 | ||
1249 | /** | 1250 | /** |
1250 | * 头像默认 | 1251 | * 头像默认 |
1251 | * | 1252 | * |
1252 | * @param mContext | 1253 | * @param mContext |
1253 | * @param userId | 1254 | * @param userId |
1254 | * @param | 1255 | * @param |
1255 | * @throws UnsupportedEncodingException | 1256 | * @throws UnsupportedEncodingException |
1256 | */ | 1257 | */ |
1257 | public void headerdeft(final Context mContext, String userId, String type, String defaultImg) throws UnsupportedEncodingException { | 1258 | public void headerdeft(final Context mContext, String userId, String type, String defaultImg) throws UnsupportedEncodingException { |
1258 | RequestParams params = new RequestParams(); | 1259 | RequestParams params = new RequestParams(); |
1259 | params.put("userId", userId); | 1260 | params.put("userId", userId); |
1260 | params.put("type", type); | 1261 | params.put("type", type); |
1261 | params.put("defaultImg", defaultImg); | 1262 | params.put("defaultImg", defaultImg); |
1262 | Log.e("test", "params" + params); | 1263 | Log.e("test", "params" + params); |
1263 | HttpClient.getInstance().setTimeout(5 * 1000); | 1264 | HttpClient.getInstance().setTimeout(5 * 1000); |
1264 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | 1265 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { |
1265 | @Override | 1266 | @Override |
1266 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1267 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1267 | Log.e("test", "onSuccess" + new String(bytes)); | 1268 | Log.e("test", "onSuccess" + new String(bytes)); |
1268 | try { | 1269 | try { |
1269 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1270 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1270 | String status = jsonObject.optString("status"); | 1271 | String status = jsonObject.optString("status"); |
1271 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); | 1272 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); |
1272 | String imagUrl = jsonObject1.optString("imgUrl"); | 1273 | String imagUrl = jsonObject1.optString("imgUrl"); |
1273 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); | 1274 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); |
1274 | if (status.equals("1")) { | 1275 | if (status.equals("1")) { |
1275 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1276 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1276 | } else { | 1277 | } else { |
1277 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1278 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1278 | } | 1279 | } |
1279 | } catch (JSONException e) { | 1280 | } catch (JSONException e) { |
1280 | e.printStackTrace(); | 1281 | e.printStackTrace(); |
1281 | } | 1282 | } |
1282 | } | 1283 | } |
1283 | 1284 | ||
1284 | @Override | 1285 | @Override |
1285 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1286 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1286 | closeProgress(); | 1287 | closeProgress(); |
1287 | Log.e("test", "错误信息" + new String(bytes)); | 1288 | Log.e("test", "错误信息" + new String(bytes)); |
1288 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1289 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1289 | 1290 | ||
1290 | } | 1291 | } |
1291 | }); | 1292 | }); |
1292 | } | 1293 | } |
1293 | 1294 | ||
1294 | /** | 1295 | /** |
1295 | * 检查注册信息是否完整 | 1296 | * 检查注册信息是否完整 |
1296 | * | 1297 | * |
1297 | * @param mContext | 1298 | * @param mContext |
1298 | * @param userId | 1299 | * @param userId |
1299 | */ | 1300 | */ |
1300 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { | 1301 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { |
1301 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", | 1302 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", |
1302 | false, true, null); | 1303 | false, true, null); |
1303 | HttpClient.getInstance().setTimeout(5 * 1000); | 1304 | HttpClient.getInstance().setTimeout(5 * 1000); |
1304 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1305 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1305 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId, new AsyncHttpResponseHandler() { | 1306 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId, new AsyncHttpResponseHandler() { |
1306 | @Override | 1307 | @Override |
1307 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1308 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1308 | closeProgress(); | 1309 | closeProgress(); |
1309 | Log.e("test", "注册信息" + new String(arg2)); | 1310 | Log.e("test", "注册信息" + new String(arg2)); |
1310 | Message msg = Message.obtain(); | 1311 | Message msg = Message.obtain(); |
1311 | msg.what = HttpCode.REGISTER_SUCESS; | 1312 | msg.what = HttpCode.REGISTER_SUCESS; |
1312 | msg.obj = new String(arg2); | 1313 | msg.obj = new String(arg2); |
1313 | handler.sendMessage(msg); | 1314 | handler.sendMessage(msg); |
1314 | 1315 | ||
1315 | } | 1316 | } |
1316 | 1317 | ||
1317 | @Override | 1318 | @Override |
1318 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1319 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1319 | closeProgress(); | 1320 | closeProgress(); |
1320 | // Log.e("test", "错误信息" + new String(arg2)); | 1321 | // Log.e("test", "错误信息" + new String(arg2)); |
1321 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1322 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1322 | 1323 | ||
1323 | } | 1324 | } |
1324 | }); | 1325 | }); |
1325 | 1326 | ||
1326 | } | 1327 | } |
1327 | 1328 | ||
1328 | /** | 1329 | /** |
1329 | * 获取最近学习视频 | 1330 | * 获取最近学习视频 |
1330 | * | 1331 | * |
1331 | * @param mContext | 1332 | * @param mContext |
1332 | * @param userId | 1333 | * @param userId |
1333 | */ | 1334 | */ |
1334 | public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { | 1335 | public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { |
1335 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", | 1336 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", |
1336 | false, true, null); | 1337 | false, true, null); |
1337 | HttpClient.getInstance().setTimeout(5 * 1000); | 1338 | HttpClient.getInstance().setTimeout(5 * 1000); |
1338 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1339 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1339 | HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId, new AsyncHttpResponseHandler() { | 1340 | HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId, new AsyncHttpResponseHandler() { |
1340 | @Override | 1341 | @Override |
1341 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1342 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1342 | closeProgress(); | 1343 | closeProgress(); |
1343 | Log.e("test", "近学习视频" + new String(arg2)); | 1344 | Log.e("test", "近学习视频" + new String(arg2)); |
1344 | try { | 1345 | try { |
1345 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1346 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1346 | int status = jsonObject.optInt("status"); | 1347 | int status = jsonObject.optInt("status"); |
1347 | if (status == 1) { | 1348 | if (status == 1) { |
1348 | VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 | 1349 | VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 |
1349 | List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); | 1350 | List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); |
1350 | Message msg = Message.obtain(); | 1351 | Message msg = Message.obtain(); |
1351 | msg.what = HttpCode.GETVIDIO_SUCESS; | 1352 | msg.what = HttpCode.GETVIDIO_SUCESS; |
1352 | msg.obj = schoolInfoBeanList; | 1353 | msg.obj = schoolInfoBeanList; |
1353 | handler.sendMessage(msg); | 1354 | handler.sendMessage(msg); |
1354 | 1355 | ||
1355 | } else { | 1356 | } else { |
1356 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 1357 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
1357 | 1358 | ||
1358 | } | 1359 | } |
1359 | } catch (JSONException e) { | 1360 | } catch (JSONException e) { |
1360 | e.printStackTrace(); | 1361 | e.printStackTrace(); |
1361 | 1362 | ||
1362 | } | 1363 | } |
1363 | 1364 | ||
1364 | } | 1365 | } |
1365 | 1366 | ||
1366 | @Override | 1367 | @Override |
1367 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1368 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1368 | closeProgress(); | 1369 | closeProgress(); |
1369 | // Log.e("test", "错误信息" + new String(arg2)); | 1370 | // Log.e("test", "错误信息" + new String(arg2)); |
1370 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1371 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1371 | 1372 | ||
1372 | } | 1373 | } |
1373 | }); | 1374 | }); |
1374 | 1375 | ||
1375 | } | 1376 | } |
1376 | 1377 | ||
1377 | 1378 | ||
1378 | /** | 1379 | /** |
1379 | * 系统升级 | 1380 | * 系统升级 |
1380 | * | 1381 | * |
1381 | * @param mContext | 1382 | * @param mContext |
1382 | * @param pid appName | 1383 | * @param pid appName |
1383 | */ | 1384 | */ |
1384 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1385 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
1385 | // mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", | 1386 | // mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", |
1386 | // false, true, null); | 1387 | // false, true, null); |
1387 | HttpClient.getInstance().setTimeout(5 * 1000); | 1388 | HttpClient.getInstance().setTimeout(5 * 1000); |
1388 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1389 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1389 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1390 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
1390 | @Override | 1391 | @Override |
1391 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1392 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1392 | //closeProgress(); | 1393 | //closeProgress(); |
1393 | Log.e("test", "版本升级信息" + new String(arg2)); | 1394 | Log.e("test", "版本升级信息" + new String(arg2)); |
1394 | Gson gson = new Gson(); | 1395 | Gson gson = new Gson(); |
1395 | List<AppVersion> applist = gson.fromJson(new String(arg2), | 1396 | List<AppVersion> applist = gson.fromJson(new String(arg2), |
1396 | new TypeToken<List<AppVersion>>() {}.getType()); | 1397 | new TypeToken<List<AppVersion>>() {}.getType()); |
1397 | Log.e("test", "版本升级信息" + applist); | 1398 | Log.e("test", "版本升级信息" + applist); |
1398 | Message msg = Message.obtain(); | 1399 | Message msg = Message.obtain(); |
1399 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1400 | msg.what = HttpCode.APPUPDATE_SUCESS; |
1400 | msg.obj = applist; | 1401 | msg.obj = applist; |
1401 | handler.sendMessage(msg); | 1402 | handler.sendMessage(msg); |
1402 | 1403 | ||
1403 | 1404 | ||
1404 | 1405 | ||
1405 | } | 1406 | } |
1406 | 1407 | ||
1407 | @Override | 1408 | @Override |
1408 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1409 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1409 | //closeProgress(); | 1410 | //closeProgress(); |
1410 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1411 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1411 | } | 1412 | } |
1412 | }); | 1413 | }); |
1413 | 1414 | ||
1414 | } | 1415 | } |
1415 | 1416 | ||
1416 | //版本信息 | 1417 | //版本信息 |
1417 | public void versioninfo(final Context mContext, String subjectName, final Handler handler) { | 1418 | public void versioninfo(final Context mContext, String subjectName, final Handler handler) { |
1418 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1419 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1419 | HttpClient.getInstance().get(HttpUrl.getversionURL + "?subjectName=" + subjectName, new AsyncHttpResponseHandler() { | 1420 | HttpClient.getInstance().get(HttpUrl.getversionURL + "?subjectName=" + subjectName, new AsyncHttpResponseHandler() { |
1420 | @Override | 1421 | @Override |
1421 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1422 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1422 | Log.e("test", "版本信息" + new String(arg2)); | 1423 | Log.e("test", "版本信息" + new String(arg2)); |
1423 | try { | 1424 | try { |
1424 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1425 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1425 | int status = jsonObject.optInt("status"); | 1426 | int status = jsonObject.optInt("status"); |
1426 | if (status == 1) { | 1427 | if (status == 1) { |
1427 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 | 1428 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 |
1428 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); | 1429 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); |
1429 | Message message = Message.obtain(); | 1430 | Message message = Message.obtain(); |
1430 | message.what = HttpCode.VERSION_SUCESS; | 1431 | message.what = HttpCode.VERSION_SUCESS; |
1431 | message.obj = versionInfoList; | 1432 | message.obj = versionInfoList; |
1432 | handler.sendMessage(message); | 1433 | handler.sendMessage(message); |
1433 | 1434 | ||
1434 | } else if (status == 1000) { | 1435 | } else if (status == 1000) { |
1435 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); | 1436 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); |
1436 | 1437 | ||
1437 | } else { | 1438 | } else { |
1438 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1439 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1439 | } | 1440 | } |
1440 | } catch (JSONException e) { | 1441 | } catch (JSONException e) { |
1441 | e.printStackTrace(); | 1442 | e.printStackTrace(); |
1442 | } | 1443 | } |
1443 | 1444 | ||
1444 | 1445 | ||
1445 | } | 1446 | } |
1446 | 1447 | ||
1447 | @Override | 1448 | @Override |
1448 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1449 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1449 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1450 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1450 | } | 1451 | } |
1451 | }); | 1452 | }); |
1452 | } | 1453 | } |
1453 | 1454 | ||
1454 | 1455 | ||
1455 | ///省级接口 | 1456 | ///省级接口 |
1456 | public void provices(final Context mContext, final Handler handler) { | 1457 | public void provices(final Context mContext, final Handler handler) { |
1457 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1458 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1458 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1459 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
1459 | @Override | 1460 | @Override |
1460 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1461 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1461 | Log.e("test", "省" + new String(arg2)); | 1462 | Log.e("test", "省" + new String(arg2)); |
1462 | try { | 1463 | try { |
1463 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1464 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1464 | int status = jsonObject.optInt("status"); | 1465 | int status = jsonObject.optInt("status"); |
1465 | if (status == 100) { | 1466 | if (status == 100) { |
1466 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1467 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
1467 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1468 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
1468 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1469 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
1469 | Message message = Message.obtain(); | 1470 | Message message = Message.obtain(); |
1470 | message.what = HttpCode.PROVICES; | 1471 | message.what = HttpCode.PROVICES; |
1471 | message.obj = provincesBeanList; | 1472 | message.obj = provincesBeanList; |
1472 | handler.sendMessage(message); | 1473 | handler.sendMessage(message); |
1473 | 1474 | ||
1474 | 1475 | ||
1475 | } else { | 1476 | } else { |
1476 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1477 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1477 | 1478 | ||
1478 | } | 1479 | } |
1479 | } catch (JSONException e) { | 1480 | } catch (JSONException e) { |
1480 | e.printStackTrace(); | 1481 | e.printStackTrace(); |
1481 | } | 1482 | } |
1482 | 1483 | ||
1483 | 1484 | ||
1484 | } | 1485 | } |
1485 | 1486 | ||
1486 | @Override | 1487 | @Override |
1487 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1488 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1488 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1489 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1489 | } | 1490 | } |
1490 | }); | 1491 | }); |
1491 | } | 1492 | } |
1492 | 1493 | ||
1493 | //获取版本信息接口 | 1494 | //获取版本信息接口 |
1494 | public void getpublishinfo(final Context mContext, Object userId, int gradeId, int type, final Handler handler) { | 1495 | public void getpublishinfo(final Context mContext, Object userId, int gradeId, int type, final Handler handler) { |
1495 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1496 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1496 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId + "&gradeId=" + gradeId + "&type=" + type, new AsyncHttpResponseHandler() { | 1497 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId + "&gradeId=" + gradeId + "&type=" + type, new AsyncHttpResponseHandler() { |
1497 | @Override | 1498 | @Override |
1498 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1499 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1499 | Log.e("test", "获取版本信息接口" + new String(arg2)); | 1500 | Log.e("test", "获取版本信息接口" + new String(arg2)); |
1500 | try { | 1501 | try { |
1501 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1502 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1502 | int status = jsonObject.optInt("status"); | 1503 | int status = jsonObject.optInt("status"); |
1503 | if (status == 1) { | 1504 | if (status == 1) { |
1504 | Gson gson = new Gson(); | 1505 | Gson gson = new Gson(); |
1505 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); | 1506 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); |
1506 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); | 1507 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); |
1507 | Message message = Message.obtain(); | 1508 | Message message = Message.obtain(); |
1508 | message.what = HttpCode.PUBLISH_SUCESS; | 1509 | message.what = HttpCode.PUBLISH_SUCESS; |
1509 | message.obj = defautPublishInfoBeanList; | 1510 | message.obj = defautPublishInfoBeanList; |
1510 | handler.sendMessage(message); | 1511 | handler.sendMessage(message); |
1511 | 1512 | ||
1512 | } else { | 1513 | } else { |
1513 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1514 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1514 | 1515 | ||
1515 | } | 1516 | } |
1516 | } catch (JSONException e) { | 1517 | } catch (JSONException e) { |
1517 | e.printStackTrace(); | 1518 | e.printStackTrace(); |
1518 | } | 1519 | } |
1519 | 1520 | ||
1520 | 1521 | ||
1521 | } | 1522 | } |
1522 | 1523 | ||
1523 | @Override | 1524 | @Override |
1524 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1525 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1525 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1526 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1526 | } | 1527 | } |
1527 | }); | 1528 | }); |
1528 | } | 1529 | } |
1529 | 1530 | ||
1530 | 1531 | ||
1531 | //市级接口 | 1532 | //市级接口 |
1532 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1533 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
1533 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1534 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1534 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1535 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
1535 | @Override | 1536 | @Override |
1536 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1537 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1537 | Log.e("test", "市" + new String(arg2)); | 1538 | Log.e("test", "市" + new String(arg2)); |
1538 | try { | 1539 | try { |
1539 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1540 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1540 | int status = jsonObject.optInt("status"); | 1541 | int status = jsonObject.optInt("status"); |
1541 | if (status == 100) { | 1542 | if (status == 100) { |
1542 | Gson gson = new Gson(); | 1543 | Gson gson = new Gson(); |
1543 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1544 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
1544 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1545 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
1545 | Message message = Message.obtain(); | 1546 | Message message = Message.obtain(); |
1546 | message.what = HttpCode.CITYS; | 1547 | message.what = HttpCode.CITYS; |
1547 | message.obj = cityInfoBeanList; | 1548 | message.obj = cityInfoBeanList; |
1548 | handler.sendMessage(message); | 1549 | handler.sendMessage(message); |
1549 | 1550 | ||
1550 | } else { | 1551 | } else { |
1551 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1552 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1552 | 1553 | ||
1553 | } | 1554 | } |
1554 | } catch (JSONException e) { | 1555 | } catch (JSONException e) { |
1555 | e.printStackTrace(); | 1556 | e.printStackTrace(); |
1556 | } | 1557 | } |
1557 | 1558 | ||
1558 | 1559 | ||
1559 | } | 1560 | } |
1560 | 1561 | ||
1561 | @Override | 1562 | @Override |
1562 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1563 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1563 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1564 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1564 | } | 1565 | } |
1565 | }); | 1566 | }); |
1566 | } | 1567 | } |
1567 | 1568 | ||
1568 | //区县级接口 | 1569 | //区县级接口 |
1569 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1570 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
1570 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1571 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1571 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1572 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
1572 | @Override | 1573 | @Override |
1573 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1574 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1574 | Log.e("test", "区" + new String(arg2)); | 1575 | Log.e("test", "区" + new String(arg2)); |
1575 | try { | 1576 | try { |
1576 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1577 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1577 | int status = jsonObject.optInt("status"); | 1578 | int status = jsonObject.optInt("status"); |
1578 | if (status == 100) { | 1579 | if (status == 100) { |
1579 | Gson gson = new Gson(); | 1580 | Gson gson = new Gson(); |
1580 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1581 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
1581 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1582 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
1582 | Message message = Message.obtain(); | 1583 | Message message = Message.obtain(); |
1583 | message.what = HttpCode.COUNTRY; | 1584 | message.what = HttpCode.COUNTRY; |
1584 | message.obj = countyInfoInfoBeanList; | 1585 | message.obj = countyInfoInfoBeanList; |
1585 | handler.sendMessage(message); | 1586 | handler.sendMessage(message); |
1586 | } else { | 1587 | } else { |
1587 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1588 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1588 | 1589 | ||
1589 | } | 1590 | } |
1590 | } catch (JSONException e) { | 1591 | } catch (JSONException e) { |
1591 | e.printStackTrace(); | 1592 | e.printStackTrace(); |
1592 | } | 1593 | } |
1593 | 1594 | ||
1594 | 1595 | ||
1595 | } | 1596 | } |
1596 | 1597 | ||
1597 | @Override | 1598 | @Override |
1598 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1599 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1599 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1600 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1600 | } | 1601 | } |
1601 | }); | 1602 | }); |
1602 | } | 1603 | } |
1603 | 1604 | ||
1604 | 1605 | ||
1605 | private void closeProgress() { | 1606 | private void closeProgress() { |
1606 | try { | 1607 | try { |
1607 | if (mProgress != null) { | 1608 | if (mProgress != null) { |
1608 | mProgress.dismiss(); | 1609 | mProgress.dismiss(); |
1609 | mProgress = null; | 1610 | mProgress = null; |
1610 | } | 1611 | } |
1611 | } catch (Exception e) { | 1612 | } catch (Exception e) { |
1612 | e.printStackTrace(); | 1613 | e.printStackTrace(); |
1613 | } | 1614 | } |
1614 | } | 1615 | } |
1615 | 1616 | ||
1616 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 1617 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
1617 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 1618 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
1618 | 1619 | ||
1619 | HttpManager.getInstance().closeProgress(); | 1620 | HttpManager.getInstance().closeProgress(); |
1620 | } | 1621 | } |
1621 | 1622 | ||
1622 | return false; | 1623 | return false; |
1623 | 1624 | ||
1624 | } | 1625 | } |
1625 | 1626 | ||
1626 | } | 1627 | } |
1627 | 1628 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/PesonalInfo.java
1 | package com.hjx.personalcenter.model; | 1 | package com.hjx.personalcenter.model; |
2 | 2 | ||
3 | import java.io.Serializable; | 3 | import java.io.Serializable; |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * Created by h on 2017/8/22. | 6 | * Created by h on 2017/8/22. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | public class PesonalInfo implements Serializable{ | 9 | public class PesonalInfo implements Serializable{ |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * status : 1 | 12 | * status : 1 |
13 | * pageSize : 0 | 13 | * pageSize : 0 |
14 | * data : {"region":{"regionName":"闵行区","regionId":"310112"},"nickName":"1688kkkkkkkkk","gender":"female","school":{"schoolId":"499705","schoolName":"上海五中"},"grade":{"gradeName":"初中六年级","gradeId":"9"},"birthday":"2017-09-12","qq":"1666600"} | 14 | * data : {"region":{"regionName":"闵行区","regionId":"310112"},"nickName":"1688kkkkkkkkk","gender":"female","school":{"schoolId":"499705","schoolName":"上海五中"},"grade":{"gradeName":"初中六年级","gradeId":"9"},"birthday":"2017-09-12","qq":"1666600"} |
15 | * msg : success | 15 | * msg : success |
16 | * pageNum : 0 | 16 | * pageNum : 0 |
17 | */ | 17 | */ |
18 | 18 | ||
19 | private int status; | 19 | private int status; |
20 | private int pageSize; | 20 | private int pageSize; |
21 | private DataBean data; | 21 | private DataBean data; |
22 | private String msg; | 22 | private String msg; |
23 | private int pageNum; | 23 | private int pageNum; |
24 | 24 | ||
25 | public int getStatus() { | 25 | public int getStatus() { |
26 | return status; | 26 | return status; |
27 | } | 27 | } |
28 | 28 | ||
29 | public void setStatus(int status) { | 29 | public void setStatus(int status) { |
30 | this.status = status; | 30 | this.status = status; |
31 | } | 31 | } |
32 | 32 | ||
33 | public int getPageSize() { | 33 | public int getPageSize() { |
34 | return pageSize; | 34 | return pageSize; |
35 | } | 35 | } |
36 | 36 | ||
37 | public void setPageSize(int pageSize) { | 37 | public void setPageSize(int pageSize) { |
38 | this.pageSize = pageSize; | 38 | this.pageSize = pageSize; |
39 | } | 39 | } |
40 | 40 | ||
41 | public DataBean getData() { | 41 | public DataBean getData() { |
42 | return data; | 42 | return data; |
43 | } | 43 | } |
44 | 44 | ||
45 | public void setData(DataBean data) { | 45 | public void setData(DataBean data) { |
46 | this.data = data; | 46 | this.data = data; |
47 | } | 47 | } |
48 | 48 | ||
49 | public String getMsg() { | 49 | public String getMsg() { |
50 | return msg; | 50 | return msg; |
51 | } | 51 | } |
52 | 52 | ||
53 | public void setMsg(String msg) { | 53 | public void setMsg(String msg) { |
54 | this.msg = msg; | 54 | this.msg = msg; |
55 | } | 55 | } |
56 | 56 | ||
57 | public int getPageNum() { | 57 | public int getPageNum() { |
58 | return pageNum; | 58 | return pageNum; |
59 | } | 59 | } |
60 | 60 | ||
61 | public void setPageNum(int pageNum) { | 61 | public void setPageNum(int pageNum) { |
62 | this.pageNum = pageNum; | 62 | this.pageNum = pageNum; |
63 | } | 63 | } |
64 | 64 | ||
65 | public static class DataBean { | 65 | public static class DataBean { |
66 | /** | 66 | /** |
67 | * region : {"regionName":"闵行区","regionId":"310112"} | 67 | * region : {"regionName":"闵行区","regionId":"310112"} |
68 | * nickName : 1688kkkkkkkkk | 68 | * nickName : 1688kkkkkkkkk |
69 | * gender : female | 69 | * gender : female |
70 | * school : {"schoolId":"499705","schoolName":"上海五中"} | 70 | * school : {"schoolId":"499705","schoolName":"上海五中"} |
71 | * grade : {"gradeName":"初中六年级","gradeId":"9"} | 71 | * grade : {"gradeName":"初中六年级","gradeId":"9"} |
72 | * birthday : 2017-09-12 | 72 | * birthday : 2017-09-12 |
73 | * qq : 1666600 | 73 | * qq : 1666600 |
74 | */ | 74 | */ |
75 | 75 | ||
76 | private RegionBean region; | 76 | private RegionBean region; |
77 | private String nickName; | 77 | private String nickName; |
78 | private String gender; | 78 | private String gender; |
79 | 79 | ||
80 | public String getAddress() { | ||
81 | return address; | ||
82 | } | ||
83 | |||
84 | public void setAddress(String address) { | ||
85 | this.address = address; | ||
86 | } | ||
87 | |||
88 | private String address; | ||
80 | private String portrait; | 89 | private String portrait; |
81 | private SchoolBean school; | 90 | private SchoolBean school; |
82 | private GradeBean grade; | 91 | private GradeBean grade; |
83 | private String birthday; | 92 | private String birthday; |
84 | private String qq; | 93 | private String qq; |
85 | public String getPortrait() { | 94 | public String getPortrait() { |
86 | return portrait; | 95 | return portrait; |
87 | } | 96 | } |
88 | 97 | ||
89 | public void setPortrait(String portrait) { | 98 | public void setPortrait(String portrait) { |
90 | this.portrait = portrait; | 99 | this.portrait = portrait; |
91 | } | 100 | } |
92 | public RegionBean getRegion() { | 101 | public RegionBean getRegion() { |
93 | return region; | 102 | return region; |
94 | } | 103 | } |
95 | 104 | ||
96 | public void setRegion(RegionBean region) { | 105 | public void setRegion(RegionBean region) { |
97 | this.region = region; | 106 | this.region = region; |
98 | } | 107 | } |
99 | 108 | ||
100 | public String getNickName() { | 109 | public String getNickName() { |
101 | return nickName; | 110 | return nickName; |
102 | } | 111 | } |
103 | 112 | ||
104 | public void setNickName(String nickName) { | 113 | public void setNickName(String nickName) { |
105 | this.nickName = nickName; | 114 | this.nickName = nickName; |
106 | } | 115 | } |
107 | 116 | ||
108 | public String getGender() { | 117 | public String getGender() { |
109 | return gender; | 118 | return gender; |
110 | } | 119 | } |
111 | 120 | ||
112 | public void setGender(String gender) { | 121 | public void setGender(String gender) { |
113 | this.gender = gender; | 122 | this.gender = gender; |
114 | } | 123 | } |
115 | 124 | ||
116 | public SchoolBean getSchool() { | 125 | public SchoolBean getSchool() { |
117 | return school; | 126 | return school; |
118 | } | 127 | } |
119 | 128 | ||
120 | public void setSchool(SchoolBean school) { | 129 | public void setSchool(SchoolBean school) { |
121 | this.school = school; | 130 | this.school = school; |
122 | } | 131 | } |
123 | 132 | ||
124 | public GradeBean getGrade() { | 133 | public GradeBean getGrade() { |
125 | return grade; | 134 | return grade; |
126 | } | 135 | } |
127 | 136 | ||
128 | public void setGrade(GradeBean grade) { | 137 | public void setGrade(GradeBean grade) { |
129 | this.grade = grade; | 138 | this.grade = grade; |
130 | } | 139 | } |
131 | 140 | ||
132 | public String getBirthday() { | 141 | public String getBirthday() { |
133 | return birthday; | 142 | return birthday; |
134 | } | 143 | } |
135 | 144 | ||
136 | public void setBirthday(String birthday) { | 145 | public void setBirthday(String birthday) { |
137 | this.birthday = birthday; | 146 | this.birthday = birthday; |
138 | } | 147 | } |
139 | 148 | ||
140 | public String getQq() { | 149 | public String getQq() { |
141 | return qq; | 150 | return qq; |
142 | } | 151 | } |
143 | 152 | ||
144 | public void setQq(String qq) { | 153 | public void setQq(String qq) { |
145 | this.qq = qq; | 154 | this.qq = qq; |
146 | } | 155 | } |
147 | 156 | ||
148 | public static class RegionBean { | 157 | public static class RegionBean { |
149 | /** | 158 | /** |
150 | * regionName : 闵行区 | 159 | * regionName : 闵行区 |
151 | * regionId : 310112 | 160 | * regionId : 310112 |
152 | */ | 161 | */ |
153 | 162 | ||
154 | private String regionName; | 163 | private String regionName; |
155 | private String regionId; | 164 | private String regionId; |
156 | 165 | ||
157 | public String getRegionName() { | 166 | public String getRegionName() { |
158 | return regionName; | 167 | return regionName; |
159 | } | 168 | } |
160 | 169 | ||
161 | public void setRegionName(String regionName) { | 170 | public void setRegionName(String regionName) { |
162 | this.regionName = regionName; | 171 | this.regionName = regionName; |
163 | } | 172 | } |
164 | 173 | ||
165 | public String getRegionId() { | 174 | public String getRegionId() { |
166 | return regionId; | 175 | return regionId; |
167 | } | 176 | } |
168 | 177 | ||
169 | public void setRegionId(String regionId) { | 178 | public void setRegionId(String regionId) { |
170 | this.regionId = regionId; | 179 | this.regionId = regionId; |
171 | } | 180 | } |
172 | } | 181 | } |
173 | 182 | ||
174 | public static class SchoolBean { | 183 | public static class SchoolBean { |
175 | /** | 184 | /** |
176 | * schoolId : 499705 | 185 | * schoolId : 499705 |
177 | * schoolName : 上海五中 | 186 | * schoolName : 上海五中 |
178 | */ | 187 | */ |
179 | 188 | ||
180 | private String schoolId; | 189 | private String schoolId; |
181 | private String schoolName; | 190 | private String schoolName; |
182 | 191 | ||
183 | public String getSchoolId() { | 192 | public String getSchoolId() { |
184 | return schoolId; | 193 | return schoolId; |
185 | } | 194 | } |
186 | 195 | ||
187 | public void setSchoolId(String schoolId) { | 196 | public void setSchoolId(String schoolId) { |
188 | this.schoolId = schoolId; | 197 | this.schoolId = schoolId; |
189 | } | 198 | } |
190 | 199 | ||
191 | public String getSchoolName() { | 200 | public String getSchoolName() { |
192 | return schoolName; | 201 | return schoolName; |
193 | } | 202 | } |
194 | 203 | ||
195 | public void setSchoolName(String schoolName) { | 204 | public void setSchoolName(String schoolName) { |
196 | this.schoolName = schoolName; | 205 | this.schoolName = schoolName; |
197 | } | 206 | } |
198 | } | 207 | } |
199 | 208 | ||
200 | public static class GradeBean { | 209 | public static class GradeBean { |
201 | /** | 210 | /** |
202 | * gradeName : 初中六年级 | 211 | * gradeName : 初中六年级 |
203 | * gradeId : 9 | 212 | * gradeId : 9 |
204 | */ | 213 | */ |
205 | 214 | ||
206 | private String gradeName; | 215 | private String gradeName; |
207 | private String gradeId; | 216 | private String gradeId; |
208 | 217 | ||
209 | public String getGradeName() { | 218 | public String getGradeName() { |
210 | return gradeName; | 219 | return gradeName; |
211 | } | 220 | } |
212 | 221 | ||
213 | public void setGradeName(String gradeName) { | 222 | public void setGradeName(String gradeName) { |
214 | this.gradeName = gradeName; | 223 | this.gradeName = gradeName; |
215 | } | 224 | } |
216 | 225 | ||
217 | public String getGradeId() { | 226 | public String getGradeId() { |
218 | return gradeId; | 227 | return gradeId; |
219 | } | 228 | } |
220 | 229 | ||
221 | public void setGradeId(String gradeId) { | 230 | public void setGradeId(String gradeId) { |
222 | this.gradeId = gradeId; | 231 | this.gradeId = gradeId; |
223 | } | 232 | } |
224 | } | 233 | } |
225 | } | 234 | } |
226 | } | 235 | } |
227 | 236 |