Commit 9c450bb01aac6f8d208b4397546568819e1f8ba2
1 parent
15bd869561
Exists in
master
调试接口和逻辑以及奔溃处理
Showing
9 changed files
with
414 additions
and
33 deletions
Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/AccountManagementActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.os.Handler; | 5 | import android.os.Handler; |
6 | import android.os.Message; | 6 | import android.os.Message; |
7 | import android.support.v7.app.AppCompatActivity; | 7 | import android.support.v7.app.AppCompatActivity; |
8 | import android.support.v7.widget.LinearLayoutManager; | 8 | import android.support.v7.widget.LinearLayoutManager; |
9 | import android.support.v7.widget.RecyclerView; | 9 | import android.support.v7.widget.RecyclerView; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.widget.ImageView; | 11 | import android.widget.ImageView; |
12 | import android.widget.LinearLayout; | 12 | import android.widget.LinearLayout; |
13 | import android.widget.TextView; | 13 | import android.widget.TextView; |
14 | 14 | ||
15 | import com.facebook.drawee.view.SimpleDraweeView; | 15 | import com.facebook.drawee.view.SimpleDraweeView; |
16 | import com.hjx.personalcenter.R; | 16 | import com.hjx.personalcenter.R; |
17 | import com.hjx.personalcenter.adapter.AccountChildsAdapter; | 17 | import com.hjx.personalcenter.adapter.AccountChildsAdapter; |
18 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; | 18 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; |
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.http.HttpCode; | 21 | import com.hjx.personalcenter.http.HttpCode; |
22 | import com.hjx.personalcenter.http.HttpManager; | 22 | import com.hjx.personalcenter.http.HttpManager; |
23 | import com.hjx.personalcenter.model.ChildsInfo; | 23 | import com.hjx.personalcenter.model.ChildsInfo; |
24 | import com.hjx.personalcenter.util.AlertUtils; | 24 | import com.hjx.personalcenter.util.AlertUtils; |
25 | import com.hjx.personalcenter.util.GetDevicesUtil; | 25 | import com.hjx.personalcenter.util.GetDevicesUtil; |
26 | 26 | ||
27 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
28 | import java.util.List; | 28 | import java.util.List; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * 账户管理 熊巍 | 31 | * 账户管理 熊巍 |
32 | * Created by h on 2017/8/12. | 32 | * Created by h on 2017/8/12. |
33 | */ | 33 | */ |
34 | 34 | ||
35 | public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener { | 35 | public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener { |
36 | private TextView changbangding, changpassword, usernames, | 36 | private TextView changbangding, changpassword, usernames, |
37 | tv_username, tv_grade, tv_school, tv_adress, tv_changzhu; | 37 | tv_username, tv_grade, tv_school, tv_adress, tv_changzhu; |
38 | private ImageView iv_useing, cancel; | 38 | private ImageView iv_useing, cancel; |
39 | private SimpleDraweeView mSimpleDraweeView; | 39 | private SimpleDraweeView mSimpleDraweeView; |
40 | private RecyclerView listview; | 40 | private RecyclerView listview; |
41 | private LinearLayout add_accunt, ll_zhu_backgrangd; | 41 | private LinearLayout add_accunt, ll_zhu_backgrangd; |
42 | private AccountChildsAdapter childsAdapter; | 42 | private AccountChildsAdapter childsAdapter; |
43 | private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>(); | 43 | private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>(); |
44 | Handler handler = new Handler() { | 44 | Handler handler = new Handler() { |
45 | @Override | 45 | @Override |
46 | public void handleMessage(Message msg) { | 46 | public void handleMessage(Message msg) { |
47 | super.handleMessage(msg); | 47 | super.handleMessage(msg); |
48 | switch (msg.what) { | 48 | switch (msg.what) { |
49 | case HttpCode.CHILDS_SUCESS: | 49 | case HttpCode.CHILDS_SUCESS: |
50 | ChildsInfo childsInfo = new ChildsInfo(); | 50 | ChildsInfo childsInfo = new ChildsInfo(); |
51 | if (childsInfo.getStatus()==1000) { | 51 | if (childsInfo.getStatus()==1000) { |
52 | String names =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.USERNAME); | 52 | String names =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.USERNAME); |
53 | String adress =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.ADRESS); | 53 | String adress =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.ADRESS); |
54 | String grades =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.GRADES); | 54 | String grades =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.GRADES); |
55 | String schools =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.SCHOOL); | 55 | String schools =SaveParam.getInstance().getLoginParam(AccountManagementActivity.this, SaveParam.SCHOOL); |
56 | tv_username.setText(names); | 56 | tv_username.setText(names); |
57 | tv_grade.setText(grades); | 57 | tv_grade.setText(grades); |
58 | tv_school.setText(schools); | 58 | tv_school.setText(schools); |
59 | tv_adress.setText(adress); | 59 | tv_adress.setText(adress); |
60 | tv_changzhu.setText("使用中"); | 60 | tv_changzhu.setText("使用中"); |
61 | tv_changzhu.setEnabled(false); | 61 | tv_changzhu.setEnabled(false); |
62 | iv_useing.setVisibility(View.VISIBLE); | 62 | iv_useing.setVisibility(View.VISIBLE); |
63 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); | 63 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); |
64 | //mSimpleDraweeView.setImageURI(phote); | 64 | //mSimpleDraweeView.setImageURI(phote); |
65 | 65 | ||
66 | } else { | 66 | } else { |
67 | String name = null; | 67 | String name = null; |
68 | String grade = null; | 68 | String grade = null; |
69 | String school = null; | 69 | String school = null; |
70 | String addr = null; | 70 | String addr = null; |
71 | String phote = null; | 71 | String phote = null; |
72 | List<ChildsInfo.DataBean> childList = new ArrayList<>(); | 72 | List<ChildsInfo.DataBean> childList = new ArrayList<>(); |
73 | List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>) msg.obj; | 73 | List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>) msg.obj; |
74 | for (int i = 0; i < list.size(); i++) { | 74 | for (int i = 0; i < list.size(); i++) { |
75 | int type = list.get(i).getType(); | 75 | int type = list.get(i).getType(); |
76 | if (type == 1) { | 76 | if (type == 1) { |
77 | name = list.get(i).getName(); | 77 | name = list.get(i).getName(); |
78 | grade = list.get(i).getGrade(); | 78 | grade = list.get(i).getGrade(); |
79 | school = list.get(i).getSchool(); | 79 | school = list.get(i).getSchool(); |
80 | addr = list.get(i).getRegion(); | 80 | addr = list.get(i).getRegion(); |
81 | phote = list.get(i).getImage(); | 81 | phote = list.get(i).getImage(); |
82 | } else if (type == 2) { | 82 | } else if (type == 2) { |
83 | childList.add(list.get(i)); | 83 | childList.add(list.get(i)); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | tv_username.setText(name); | 86 | tv_username.setText(name); |
87 | tv_grade.setText(grade); | 87 | tv_grade.setText(grade); |
88 | tv_school.setText(school); | 88 | tv_school.setText(school); |
89 | tv_adress.setText(addr); | 89 | tv_adress.setText(addr); |
90 | mSimpleDraweeView.setImageURI(phote); | 90 | mSimpleDraweeView.setImageURI(phote); |
91 | data.clear(); | 91 | data.clear(); |
92 | data.addAll(childList); | 92 | data.addAll(childList); |
93 | childsAdapter.notifyDataSetChanged(); | 93 | childsAdapter.notifyDataSetChanged(); |
94 | } | 94 | } |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | 99 | ||
100 | @Override | 100 | @Override |
101 | protected void onCreate(Bundle savedInstanceState) { | 101 | protected void onCreate(Bundle savedInstanceState) { |
102 | super.onCreate(savedInstanceState); | 102 | super.onCreate(savedInstanceState); |
103 | setContentView(R.layout.activity_account_management); | 103 | setContentView(R.layout.activity_account_management); |
104 | 104 | ||
105 | initView(); | 105 | initView(); |
106 | initData(); | 106 | initData(); |
107 | initLister(); | 107 | initLister(); |
108 | } | 108 | } |
109 | 109 | ||
110 | private void initView() { | 110 | private void initView() { |
111 | changbangding = (TextView) findViewById(R.id.changBangding); | 111 | changbangding = (TextView) findViewById(R.id.changBangding); |
112 | changpassword = (TextView) findViewById(R.id.changpassword); | 112 | changpassword = (TextView) findViewById(R.id.changpassword); |
113 | usernames = (TextView) findViewById(R.id.cunt_username); | 113 | usernames = (TextView) findViewById(R.id.cunt_username); |
114 | tv_username = (TextView) findViewById(R.id.tv_account_name); | 114 | tv_username = (TextView) findViewById(R.id.tv_account_name); |
115 | tv_grade = (TextView) findViewById(R.id.tv_account_grade); | 115 | tv_grade = (TextView) findViewById(R.id.tv_account_grade); |
116 | tv_school = (TextView) findViewById(R.id.tv_account_school); | 116 | tv_school = (TextView) findViewById(R.id.tv_account_school); |
117 | tv_adress = (TextView) findViewById(R.id.tv_account_adress); | 117 | tv_adress = (TextView) findViewById(R.id.tv_account_adress); |
118 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head); | 118 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head); |
119 | iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong); | 119 | iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong); |
120 | cancel = (ImageView) findViewById(R.id.cancel); | 120 | cancel = (ImageView) findViewById(R.id.cancel); |
121 | add_accunt = (LinearLayout) findViewById(R.id.add_account); | 121 | add_accunt = (LinearLayout) findViewById(R.id.add_account); |
122 | ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd); | 122 | ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd); |
123 | tv_changzhu = (TextView) findViewById(R.id.change_zhu_account); | 123 | tv_changzhu = (TextView) findViewById(R.id.change_zhu_account); |
124 | listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 124 | listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
125 | } | 125 | } |
126 | 126 | ||
127 | private void initData() { | 127 | private void initData() { |
128 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); | 128 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); |
129 | String account = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 129 | String account = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
130 | usernames.setText(cunt_username); | 130 | usernames.setText(cunt_username); |
131 | 131 | ||
132 | if (account.equals("1")) { | 132 | if (account.equals("1")) { |
133 | tv_changzhu.setText("使用中"); | 133 | tv_changzhu.setText("使用中"); |
134 | tv_changzhu.setEnabled(false); | 134 | tv_changzhu.setEnabled(false); |
135 | iv_useing.setVisibility(View.VISIBLE); | 135 | iv_useing.setVisibility(View.VISIBLE); |
136 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); | 136 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); |
137 | } else { | 137 | } else { |
138 | 138 | ||
139 | tv_changzhu.setText("切换主账户"); | 139 | tv_changzhu.setText("切换主账户"); |
140 | tv_changzhu.setEnabled(true); | 140 | tv_changzhu.setEnabled(true); |
141 | iv_useing.setVisibility(View.GONE); | 141 | iv_useing.setVisibility(View.GONE); |
142 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg); | 142 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 146 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
147 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); | 147 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
148 | listview.setLayoutManager(linearLayoutManager); | 148 | listview.setLayoutManager(linearLayoutManager); |
149 | childsAdapter = new AccountChildsAdapter(data, this); | 149 | childsAdapter = new AccountChildsAdapter(data, this); |
150 | listview.addItemDecoration(new RecyclerViewSpaceItem(10)); | 150 | listview.addItemDecoration(new RecyclerViewSpaceItem(10)); |
151 | listview.setAdapter(childsAdapter); | 151 | listview.setAdapter(childsAdapter); |
152 | childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() { | 152 | childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() { |
153 | @Override | 153 | @Override |
154 | public void onItemClick(View view, int position) { | 154 | public void onItemClick(View view, int position) { |
155 | 155 | ||
156 | AlertUtils.showToast(AccountManagementActivity.this, "你点击了" + data.get(position)); | 156 | AlertUtils.showToast(AccountManagementActivity.this, "你点击了" + data.get(position)); |
157 | } | 157 | } |
158 | }); | 158 | }); |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | private void initLister() { | 163 | private void initLister() { |
164 | changbangding.setOnClickListener(this); | 164 | changbangding.setOnClickListener(this); |
165 | changpassword.setOnClickListener(this); | 165 | changpassword.setOnClickListener(this); |
166 | cancel.setOnClickListener(this); | 166 | cancel.setOnClickListener(this); |
167 | add_accunt.setOnClickListener(this); | 167 | add_accunt.setOnClickListener(this); |
168 | tv_changzhu.setOnClickListener(this); | 168 | tv_changzhu.setOnClickListener(this); |
169 | 169 | ||
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | @Override | 173 | @Override |
174 | public void onClick(View v) { | 174 | public void onClick(View v) { |
175 | switch (v.getId()) { | 175 | switch (v.getId()) { |
176 | case R.id.changBangding: | 176 | case R.id.changBangding: |
177 | Content.authcodeflag = 1; | ||
177 | Intent changebangding = new Intent(); | 178 | Intent changebangding = new Intent(); |
178 | changebangding.setClass(AccountManagementActivity.this, ChangeBangDingActivity.class); | 179 | changebangding.setClass(AccountManagementActivity.this, ElectronicCardValidationActivity.class); |
179 | startActivity(changebangding); | 180 | startActivity(changebangding); |
180 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 181 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
181 | break; | 182 | break; |
182 | case R.id.changpassword: | 183 | case R.id.changpassword: |
183 | Content.authcodeflag = 1; | ||
184 | Intent changpwd = new Intent(); | 184 | Intent changpwd = new Intent(); |
185 | changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class); | 185 | changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class); |
186 | startActivity(changpwd); | 186 | startActivity(changpwd); |
187 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 187 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
188 | break; | 188 | break; |
189 | case R.id.add_account: | 189 | case R.id.add_account: |
190 | Content.accountflag = 2; | ||
191 | Intent account = new Intent(); | 190 | Intent account = new Intent(); |
192 | account.setClass(AccountManagementActivity.this, RegisterInfoActivity.class); | 191 | account.setClass(AccountManagementActivity.this, RegisterInfoActivity.class); |
193 | startActivity(account); | 192 | startActivity(account); |
194 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 193 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
195 | 194 | ||
196 | break; | 195 | break; |
197 | case R.id.change_zhu_account: | 196 | case R.id.change_zhu_account: |
198 | Content.changgeaccountflag = 1; | 197 | Content.changgeaccountflag = 1; |
199 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 198 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
200 | SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ACCOUNT, "1"); | 199 | SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ACCOUNT, "1"); |
201 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | 200 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
202 | try { | 201 | try { |
203 | long auserID = Long.parseLong(userID); | 202 | long auserID = Long.parseLong(userID); |
204 | HttpManager.getInstance().Accountinfo(AccountManagementActivity.this, auserID, | 203 | HttpManager.getInstance().Accountinfo(AccountManagementActivity.this, auserID, |
205 | devicenumber, 1); | 204 | devicenumber, 1); |
206 | 205 | ||
207 | } catch (NumberFormatException e) { | 206 | } catch (NumberFormatException e) { |
208 | e.printStackTrace(); | 207 | e.printStackTrace(); |
209 | } | 208 | } |
210 | 209 | ||
211 | 210 | ||
212 | break; | 211 | break; |
213 | case R.id.cancel: | 212 | case R.id.cancel: |
214 | finish(); | 213 | finish(); |
215 | break; | 214 | break; |
216 | 215 | ||
217 | } | 216 | } |
218 | 217 | ||
219 | } | 218 | } |
220 | 219 | ||
221 | @Override | 220 | @Override |
222 | protected void onResume() { | 221 | protected void onResume() { |
223 | super.onResume(); | 222 | super.onResume(); |
224 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 223 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
225 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | 224 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
225 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); | ||
226 | usernames.setText(cunt_username); | ||
226 | try { | 227 | try { |
227 | long auserID = Long.parseLong(userID); | 228 | long auserID = Long.parseLong(userID); |
228 | HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler); | 229 | HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler); |
229 | 230 | ||
230 | } catch (NumberFormatException e) { | 231 | } catch (NumberFormatException e) { |
231 | e.printStackTrace(); | 232 | e.printStackTrace(); |
232 | } | 233 | } |
233 | } | 234 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardLookInfoActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.os.Handler; | 5 | import android.os.Handler; |
6 | import android.os.Message; | 6 | import android.os.Message; |
7 | import android.support.v7.app.AppCompatActivity; | 7 | import android.support.v7.app.AppCompatActivity; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.widget.ImageView; | 9 | import android.widget.ImageView; |
10 | import android.widget.TextView; | 10 | import android.widget.TextView; |
11 | 11 | ||
12 | import com.hjx.personalcenter.R; | 12 | import com.hjx.personalcenter.R; |
13 | import com.hjx.personalcenter.db.Content; | 13 | import com.hjx.personalcenter.db.Content; |
14 | import com.hjx.personalcenter.db.SaveParam; | 14 | import com.hjx.personalcenter.db.SaveParam; |
15 | import com.hjx.personalcenter.http.HttpCode; | 15 | import com.hjx.personalcenter.http.HttpCode; |
16 | import com.hjx.personalcenter.http.HttpManager; | 16 | import com.hjx.personalcenter.http.HttpManager; |
17 | import com.hjx.personalcenter.model.CardInfo; | 17 | import com.hjx.personalcenter.model.CardInfo; |
18 | import com.hjx.personalcenter.util.AlertUtils; | ||
18 | 19 | ||
19 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
20 | 21 | ||
21 | /** | 22 | /** |
22 | * Created by h on 2017/8/11. | 23 | * Created by h on 2017/8/11. |
23 | */ | 24 | */ |
24 | 25 | ||
25 | public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener{ | 26 | public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener { |
26 | private ImageView iv_last_step; | 27 | private ImageView iv_last_step; |
27 | private TextView usename,deviceModel,customer_address,mac_adress,shoptime,deviceNumber, | 28 | private TextView usename, deviceModel, customer_address, mac_adress, shoptime, deviceNumber, |
28 | shopadress,phone,tlePhone,tv_card_adress_change,tv_card_phone_change; | 29 | shopadress, phone, tlePhone, tv_card_adress_change, tv_card_phone_change; |
29 | private ArrayList<CardInfo.DataBean> data = new ArrayList<>(); | 30 | private ArrayList<CardInfo.DataBean> data = new ArrayList<>(); |
30 | 31 | ||
31 | Handler handler = new Handler(){ | 32 | Handler handler = new Handler() { |
32 | @Override | 33 | @Override |
33 | public void handleMessage(Message msg) { | 34 | public void handleMessage(Message msg) { |
34 | super.handleMessage(msg); | 35 | super.handleMessage(msg); |
35 | switch (msg.what){ | 36 | switch (msg.what) { |
36 | 37 | ||
37 | case HttpCode.SUCHCARDINFO: | 38 | case HttpCode.SUCHCARDINFO: |
38 | CardInfo.DataBean cardinfoBean =(CardInfo.DataBean)msg.obj; | 39 | CardInfo.DataBean cardinfoBean = (CardInfo.DataBean) msg.obj; |
39 | //获取设备信息 | 40 | if (cardinfoBean != null) { |
40 | deviceModel.setText(cardinfoBean.getProductModel()); | 41 | //获取设备信息 |
41 | deviceNumber.setText(cardinfoBean.getDeviceNumber()); | 42 | deviceModel.setText(cardinfoBean.getProductModel()); |
42 | mac_adress.setText(cardinfoBean.getMacAddress()); | 43 | deviceNumber.setText(cardinfoBean.getDeviceNumber()); |
43 | //获取保卡信息 | 44 | mac_adress.setText(cardinfoBean.getMacAddress()); |
44 | usename.setText(cardinfoBean.getCustomerName()); | 45 | //获取保卡信息 |
45 | customer_address.setText(cardinfoBean.getCustomerAddress()); | 46 | usename.setText(cardinfoBean.getCustomerName()); |
46 | shoptime.setText(cardinfoBean.getBuyTime()); | 47 | customer_address.setText(cardinfoBean.getCustomerAddress()); |
47 | shopadress.setText(cardinfoBean.getBuyAddress()); | 48 | shoptime.setText(cardinfoBean.getBuyTime()); |
48 | tlePhone.setText(cardinfoBean.getAlterSaleCall()); | 49 | shopadress.setText(cardinfoBean.getBuyAddress()); |
49 | phone.setText(cardinfoBean.getMobilePhone()); | 50 | tlePhone.setText(cardinfoBean.getAlterSaleCall()); |
50 | 51 | phone.setText(cardinfoBean.getMobilePhone()); | |
52 | }else { | ||
53 | AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"您的机器还没有保卡信息,请重新登录"); | ||
54 | } | ||
51 | 55 | ||
52 | break; | 56 | break; |
53 | 57 | ||
54 | } | 58 | } |
55 | 59 | ||
56 | } | 60 | } |
57 | }; | 61 | }; |
58 | 62 | ||
59 | @Override | 63 | @Override |
60 | protected void onCreate(Bundle savedInstanceState) { | 64 | protected void onCreate(Bundle savedInstanceState) { |
61 | super.onCreate(savedInstanceState); | 65 | super.onCreate(savedInstanceState); |
62 | setContentView(R.layout.activity_electronic_look_cardinfo); | 66 | setContentView(R.layout.activity_electronic_look_cardinfo); |
63 | initView(); | 67 | initView(); |
64 | initData(); | 68 | initData(); |
65 | initLister(); | 69 | initLister(); |
66 | } | 70 | } |
67 | 71 | ||
68 | @Override | 72 | @Override |
69 | protected void onResume() { | 73 | protected void onResume() { |
70 | super.onResume(); | 74 | super.onResume(); |
71 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 75 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
72 | try { | 76 | try { |
73 | Long a = Long.parseLong(userID); | 77 | Long a = Long.parseLong(userID); |
74 | HttpManager.getInstance().getcardinfo(this,a,handler); | 78 | HttpManager.getInstance().getcardinfo(this, a, handler); |
75 | } catch (NumberFormatException e) { | 79 | } catch (NumberFormatException e) { |
76 | e.printStackTrace(); | 80 | e.printStackTrace(); |
77 | } | 81 | } |
78 | } | 82 | } |
79 | 83 | ||
80 | private void initView() { | 84 | private void initView() { |
81 | usename = (TextView) findViewById(R.id.iv_card_username); | 85 | usename = (TextView) findViewById(R.id.iv_card_username); |
82 | iv_last_step = (ImageView) findViewById(R.id.cancel); | 86 | iv_last_step = (ImageView) findViewById(R.id.cancel); |
83 | deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); | 87 | deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); |
84 | customer_address = (TextView) findViewById(R.id.tv_card_adress); | 88 | customer_address = (TextView) findViewById(R.id.tv_card_adress); |
85 | mac_adress = (TextView) findViewById(R.id.tv_card_mac); | 89 | mac_adress = (TextView) findViewById(R.id.tv_card_mac); |
86 | shoptime = (TextView) findViewById(R.id.tv_card_time); | 90 | shoptime = (TextView) findViewById(R.id.tv_card_time); |
87 | deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber); | 91 | deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber); |
88 | shopadress = (TextView) findViewById(R.id.tv_card_shopAdress); | 92 | shopadress = (TextView) findViewById(R.id.tv_card_shopAdress); |
89 | phone = (TextView) findViewById(R.id.tv_card_phone); | 93 | phone = (TextView) findViewById(R.id.tv_card_phone); |
90 | tlePhone = (TextView) findViewById(R.id.tv_card_tleNember); | 94 | tlePhone = (TextView) findViewById(R.id.tv_card_tleNember); |
91 | tv_card_adress_change = (TextView) findViewById(R.id.tv_card_adress_change); | 95 | tv_card_adress_change = (TextView) findViewById(R.id.tv_card_adress_change); |
92 | tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change); | 96 | tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change); |
93 | } | 97 | } |
98 | |||
94 | private void initData() { | 99 | private void initData() { |
95 | 100 | ||
96 | // //获取设备信息 | 101 | // //获取设备信息 |
97 | // deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel()); | 102 | // deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel()); |
98 | // deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber()); | 103 | // deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber()); |
99 | // mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac()); | 104 | // mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac()); |
100 | // //获取保卡信息 | 105 | // //获取保卡信息 |
101 | // usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME)); | 106 | // usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME)); |
102 | // customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM)); | 107 | // customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM)); |
103 | // shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME)); | 108 | // shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME)); |
104 | // shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS)); | 109 | // shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS)); |
105 | // tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE)); | 110 | // tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE)); |
106 | // phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE)); | 111 | // phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE)); |
107 | 112 | ||
108 | 113 | ||
109 | } | 114 | } |
115 | |||
110 | private void initLister() { | 116 | private void initLister() { |
111 | tv_card_adress_change.setOnClickListener(this); | 117 | tv_card_adress_change.setOnClickListener(this); |
112 | tv_card_phone_change.setOnClickListener(this); | 118 | tv_card_phone_change.setOnClickListener(this); |
113 | iv_last_step.setOnClickListener(this); | 119 | iv_last_step.setOnClickListener(this); |
114 | } | 120 | } |
121 | |||
115 | @Override | 122 | @Override |
116 | public void onClick(View v) { | 123 | public void onClick(View v) { |
117 | switch (v.getId()){ | 124 | switch (v.getId()) { |
118 | case R.id.tv_card_adress_change: | 125 | case R.id.tv_card_adress_change: |
119 | Intent intent = new Intent(); | 126 | Intent intent = new Intent(); |
120 | intent.setClass(this,ChangeElectronicCardAdressInfoActivity.class); | 127 | intent.setClass(this, ChangeElectronicCardAdressInfoActivity.class); |
121 | startActivity(intent); | 128 | startActivity(intent); |
122 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 129 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
123 | 130 | ||
124 | break; | 131 | break; |
125 | case R.id.tv_card_phone_change: | 132 | case R.id.tv_card_phone_change: |
126 | Content.authcodeflag =2; | 133 | Content.authcodeflag = 2; |
127 | Intent intent1 = new Intent(); | 134 | Intent intent1 = new Intent(); |
128 | intent1.setClass(this,ElectronicCardValidationActivity.class); | 135 | intent1.setClass(this, ElectronicCardValidationActivity.class); |
129 | startActivity(intent1); | 136 | startActivity(intent1); |
130 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 137 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
131 | 138 | ||
132 | 139 | ||
133 | break; | 140 | break; |
134 | case R.id.cancel: | 141 | case R.id.cancel: |
135 | finish(); | 142 | finish(); |
136 | break; | 143 | break; |
137 | } | 144 | } |
138 | } | 145 | } |
139 | 146 | ||
140 | } | 147 | } |
141 | 148 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardValidationActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.os.Handler; | 5 | import android.os.Handler; |
6 | import android.os.Message; | 6 | import android.os.Message; |
7 | import android.support.v7.app.AppCompatActivity; | 7 | import android.support.v7.app.AppCompatActivity; |
8 | import android.text.TextUtils; | 8 | import android.text.TextUtils; |
9 | import android.view.View; | 9 | import android.view.View; |
10 | import android.widget.Button; | 10 | import android.widget.Button; |
11 | import android.widget.EditText; | 11 | import android.widget.EditText; |
12 | import android.widget.ImageView; | 12 | import android.widget.ImageView; |
13 | import android.widget.TextView; | 13 | import android.widget.TextView; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.db.Content; | 16 | import com.hjx.personalcenter.db.Content; |
17 | import com.hjx.personalcenter.db.SaveParam; | 17 | import com.hjx.personalcenter.db.SaveParam; |
18 | import com.hjx.personalcenter.http.HttpCode; | 18 | import com.hjx.personalcenter.http.HttpCode; |
19 | import com.hjx.personalcenter.http.HttpManager; | 19 | import com.hjx.personalcenter.http.HttpManager; |
20 | import com.hjx.personalcenter.util.AlertUtils; | 20 | import com.hjx.personalcenter.util.AlertUtils; |
21 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 21 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
22 | 22 | ||
23 | import org.json.JSONObject; | 23 | import org.json.JSONObject; |
24 | 24 | ||
25 | import java.util.TimerTask; | 25 | import java.util.TimerTask; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Created by h on 2017/8/9. | 28 | * Created by h on 2017/8/9. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | public class ElectronicCardValidationActivity extends AppCompatActivity implements View.OnClickListener { | 31 | public class ElectronicCardValidationActivity extends AppCompatActivity implements View.OnClickListener { |
32 | private Button btn_card_valiyanzhen,get_authcode; | 32 | private Button btn_card_valiyanzhen,get_authcode; |
33 | private EditText phonenumber,anth_6num;//;//密码 | 33 | private EditText phonenumber,anth_6num;//;//密码 |
34 | private TextView menu_title; | 34 | private TextView menu_title; |
35 | private ImageView cancel; | 35 | private ImageView cancel; |
36 | private int delayTime=60; | 36 | private int delayTime=60; |
37 | private java.util.Timer Delaytimer; | 37 | private java.util.Timer Delaytimer; |
38 | private String sourceStr ="android"; | 38 | private String sourceStr ="android"; |
39 | private String typeStr = "register"; | 39 | private String typeStr = "register"; |
40 | String authcode = ""; | 40 | String authcode = ""; |
41 | Handler handler = new Handler() { | 41 | Handler handler = new Handler() { |
42 | @Override | 42 | @Override |
43 | public void handleMessage(Message msg) { | 43 | public void handleMessage(Message msg) { |
44 | super.handleMessage(msg); | 44 | super.handleMessage(msg); |
45 | JSONObject jsonObject; | 45 | JSONObject jsonObject; |
46 | String status; | 46 | String status; |
47 | switch (msg.what) { | 47 | switch (msg.what) { |
48 | case HttpCode.AUTHCODE_SUCESS: | 48 | case HttpCode.AUTHCODE_SUCESS: |
49 | jsonObject = (JSONObject) msg.obj; | 49 | jsonObject = (JSONObject) msg.obj; |
50 | status = jsonObject.optString("status"); | 50 | status = jsonObject.optString("status"); |
51 | authcode = jsonObject.optString("jsessionid"); | 51 | authcode = jsonObject.optString("jsessionid"); |
52 | if (status.equals("100")) { | 52 | if (status.equals("100")) { |
53 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送成功"); | 53 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送成功"); |
54 | } | 54 | } |
55 | 55 | ||
56 | break; | 56 | break; |
57 | case HttpCode.AUTHCODE_FAIL: | 57 | case HttpCode.AUTHCODE_FAIL: |
58 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送失败"); | 58 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "验证码发送失败"); |
59 | break; | 59 | break; |
60 | case 21: | 60 | case 21: |
61 | if(delayTime<=0){ | 61 | if(delayTime<=0){ |
62 | if(Delaytimer!=null){ | 62 | if(Delaytimer!=null){ |
63 | Delaytimer.cancel(); | 63 | Delaytimer.cancel(); |
64 | } | 64 | } |
65 | get_authcode.setEnabled(true); | 65 | get_authcode.setEnabled(true); |
66 | get_authcode.setClickable(true); | 66 | get_authcode.setClickable(true); |
67 | get_authcode.setText("获取验证码"); | 67 | get_authcode.setText("获取验证码"); |
68 | delayTime=60; | 68 | delayTime=60; |
69 | }else{ | 69 | }else{ |
70 | get_authcode.setEnabled(false); | 70 | get_authcode.setEnabled(false); |
71 | get_authcode.setClickable(false); | 71 | get_authcode.setClickable(false); |
72 | get_authcode.setText(delayTime + " s"); | 72 | get_authcode.setText(delayTime + " s"); |
73 | } | 73 | } |
74 | break; | 74 | break; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | }; | 77 | }; |
78 | @Override | 78 | @Override |
79 | protected void onCreate(Bundle savedInstanceState) { | 79 | protected void onCreate(Bundle savedInstanceState) { |
80 | super.onCreate(savedInstanceState); | 80 | super.onCreate(savedInstanceState); |
81 | setContentView(R.layout.activity_electroniccard_validation); | 81 | setContentView(R.layout.activity_electroniccard_validation); |
82 | initView(); | 82 | initView(); |
83 | initData(); | 83 | initData(); |
84 | initLister(); | 84 | initLister(); |
85 | } | 85 | } |
86 | 86 | ||
87 | private void initView() { | 87 | private void initView() { |
88 | btn_card_valiyanzhen = (Button) findViewById(R.id.btn_card_valiyanzhen); | 88 | btn_card_valiyanzhen = (Button) findViewById(R.id.btn_card_valiyanzhen); |
89 | get_authcode = (Button) findViewById(R.id.btn_authcode); | 89 | get_authcode = (Button) findViewById(R.id.btn_authcode); |
90 | anth_6num = (EditText) findViewById(R.id.et_authcode); | 90 | anth_6num = (EditText) findViewById(R.id.et_authcode); |
91 | phonenumber = (EditText) findViewById(R.id.et_phonenumber); | 91 | phonenumber = (EditText) findViewById(R.id.et_phonenumber); |
92 | menu_title = (TextView) findViewById(R.id.menu_title); | 92 | menu_title = (TextView) findViewById(R.id.menu_title); |
93 | cancel = (ImageView) findViewById(R.id.cancel); | 93 | cancel = (ImageView) findViewById(R.id.cancel); |
94 | } | 94 | } |
95 | 95 | ||
96 | private void initData() { | 96 | private void initData() { |
97 | if (Content.authcodeflag==1){ | 97 | if (Content.authcodeflag==1){ |
98 | menu_title.setText("更换绑定"); | 98 | menu_title.setText("更换绑定"); |
99 | btn_card_valiyanzhen.setText("确定"); | 99 | btn_card_valiyanzhen.setText("确定"); |
100 | 100 | ||
101 | }else if (Content.authcodeflag==2){ | 101 | }else if (Content.authcodeflag==2){ |
102 | menu_title.setText("修改保卡信息"); | 102 | menu_title.setText("修改保卡信息"); |
103 | btn_card_valiyanzhen.setText("确定"); | 103 | btn_card_valiyanzhen.setText("确定"); |
104 | 104 | ||
105 | }else { | 105 | }else { |
106 | menu_title.setText("填写保卡信息"); | 106 | menu_title.setText("填写保卡信息"); |
107 | btn_card_valiyanzhen.setText("下一步"); | 107 | btn_card_valiyanzhen.setText("下一步"); |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | } | 112 | } |
113 | 113 | ||
114 | private void initLister() { | 114 | private void initLister() { |
115 | get_authcode.setOnClickListener(this); | 115 | get_authcode.setOnClickListener(this); |
116 | btn_card_valiyanzhen.setOnClickListener(this); | 116 | btn_card_valiyanzhen.setOnClickListener(this); |
117 | cancel.setOnClickListener(this); | 117 | cancel.setOnClickListener(this); |
118 | 118 | ||
119 | } | 119 | } |
120 | 120 | ||
121 | @Override | 121 | @Override |
122 | public void onClick(View v) { | 122 | public void onClick(View v) { |
123 | switch (v.getId()){ | 123 | switch (v.getId()){ |
124 | case R.id.btn_card_valiyanzhen: | 124 | case R.id.btn_card_valiyanzhen: |
125 | 125 | ||
126 | String usernameStr = phonenumber.getText().toString().trim(); | 126 | String usernameStr = phonenumber.getText().toString().trim(); |
127 | String authcodeStr = anth_6num.getText().toString().trim(); | 127 | String authcodeStr = anth_6num.getText().toString().trim(); |
128 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)) { | 128 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)) { |
129 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号,和验证码不能为空"); | 129 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号,和验证码不能为空"); |
130 | return; | 130 | return; |
131 | } else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | 131 | } else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ |
132 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号码输入错误"); | 132 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号码输入错误"); |
133 | 133 | ||
134 | }else if (!authcode.equals(authcodeStr)){ | 134 | }else if (!authcode.equals(authcodeStr)){ |
135 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确"); | 135 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确"); |
136 | }else { | 136 | }else { |
137 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 137 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
138 | int auserID = 0; | 138 | int auserID = 0; |
139 | try { | 139 | try { |
140 | auserID = Integer.parseInt(userID); | 140 | auserID = Integer.parseInt(userID); |
141 | } catch (NumberFormatException e) { | 141 | } catch (NumberFormatException e) { |
142 | e.printStackTrace(); | 142 | e.printStackTrace(); |
143 | } | 143 | } |
144 | if (Content.authcodeflag==1){ | 144 | if (Content.authcodeflag==1){ |
145 | //修改账户手机号 | 145 | //修改账户手机号 |
146 | HttpManager.getInstance().changecardinfophone(this, | 146 | HttpManager.getInstance().changecardinfophone(this, |
147 | auserID,usernameStr,authcodeStr); | 147 | auserID,usernameStr,authcodeStr); |
148 | 148 | ||
149 | |||
150 | }else if (Content.authcodeflag==2){ | 149 | }else if (Content.authcodeflag==2){ |
151 | //修改保卡手机号 | 150 | //修改保卡手机号 |
152 | HttpManager.getInstance().changecardinfophone(this, | 151 | HttpManager.getInstance().changecardinfophone(this, |
153 | auserID,usernameStr,authcodeStr); | 152 | auserID,usernameStr,authcodeStr); |
154 | }else { | 153 | }else { |
155 | String phone =phonenumber.getText().toString().trim(); | 154 | String phone =phonenumber.getText().toString().trim(); |
156 | SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phone ); | 155 | SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phone ); |
157 | Intent intent = new Intent(); | 156 | Intent intent = new Intent(); |
158 | intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); | 157 | intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); |
159 | startActivity(intent); | 158 | startActivity(intent); |
160 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 159 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
161 | } | 160 | } |
162 | // SaveParam.getInstance().saveLoginParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim()); | 161 | // SaveParam.getInstance().saveLoginParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim()); |
163 | // Intent intent = new Intent(); | 162 | // Intent intent = new Intent(); |
164 | // intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); | 163 | // intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); |
165 | // startActivity(intent); | 164 | // startActivity(intent); |
166 | // overridePendingTransition(R.anim.rightin, R.anim.rightout); | 165 | // overridePendingTransition(R.anim.rightin, R.anim.rightout); |
167 | } | 166 | } |
168 | break; | 167 | break; |
169 | case R.id.btn_authcode: | 168 | case R.id.btn_authcode: |
170 | String usernameStr1 = phonenumber.getText().toString().trim(); | 169 | String usernameStr1 = phonenumber.getText().toString().trim(); |
171 | if (!PhoneNumCheckUtils.isPhone(usernameStr1)){ | 170 | if (!PhoneNumCheckUtils.isPhone(usernameStr1)){ |
172 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "请输入正确的手机号"); | 171 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "请输入正确的手机号"); |
173 | }else { | 172 | }else { |
174 | anth_6num.requestFocus(); | 173 | anth_6num.requestFocus(); |
175 | HttpManager.getInstance().authCode(typeStr, usernameStr1, handler, ElectronicCardValidationActivity.this); | 174 | HttpManager.getInstance().authCode(typeStr, usernameStr1, handler, ElectronicCardValidationActivity.this); |
176 | valiDelay(); | 175 | valiDelay(); |
177 | 176 | ||
178 | } | 177 | } |
179 | 178 | ||
180 | break; | 179 | break; |
181 | case R.id.cancel: | 180 | case R.id.cancel: |
182 | finish(); | 181 | finish(); |
183 | break; | 182 | break; |
184 | } | 183 | } |
185 | } | 184 | } |
186 | // 线程类 定时器 | 185 | // 线程类 定时器 |
187 | public void valiDelay() { | 186 | public void valiDelay() { |
188 | 187 | ||
189 | Delaytimer = new java.util.Timer(true); | 188 | Delaytimer = new java.util.Timer(true); |
190 | 189 | ||
191 | 190 | ||
192 | TimerTask task = new TimerTask() { | 191 | TimerTask task = new TimerTask() { |
193 | public void run() { | 192 | public void run() { |
194 | //每次需要执行的代码放到这里面。 | 193 | //每次需要执行的代码放到这里面。 |
195 | delayTime--; | 194 | delayTime--; |
196 | handler.sendEmptyMessage(21); | 195 | handler.sendEmptyMessage(21); |
197 | } | 196 | } |
198 | }; | 197 | }; |
199 | Delaytimer.schedule(task, 1000,1000); | 198 | Delaytimer.schedule(task, 1000,1000); |
200 | } | 199 | } |
201 | } | 200 | } |
202 | 201 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MyApplication.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.app.Application; | 3 | import android.app.Application; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.graphics.drawable.Drawable; | ||
6 | import android.os.Looper; | ||
7 | import android.view.Gravity; | ||
8 | import android.widget.TextView; | ||
9 | import android.widget.Toast; | ||
5 | 10 | ||
6 | import com.facebook.drawee.backends.pipeline.Fresco; | 11 | import com.facebook.drawee.backends.pipeline.Fresco; |
12 | import com.hjx.personalcenter.R; | ||
13 | import com.hjx.personalcenter.crash.CrashHandler; | ||
7 | import com.hjx.personalcenter.util.ImageCache; | 14 | import com.hjx.personalcenter.util.ImageCache; |
8 | import com.squareup.leakcanary.LeakCanary; | 15 | import com.squareup.leakcanary.LeakCanary; |
9 | import com.tencent.bugly.crashreport.CrashReport; | 16 | import com.tencent.bugly.crashreport.CrashReport; |
10 | 17 | ||
11 | /** | 18 | /** |
12 | * Created by ${yf} on 2017/2/16. | 19 | * Created by ${yf} on 2017/2/16. |
13 | */ | 20 | */ |
14 | 21 | ||
15 | public class MyApplication extends Application { | 22 | public class MyApplication extends Application { |
16 | 23 | ||
17 | private ImageCache mImageCache; | 24 | private ImageCache mImageCache; |
18 | private static Context context; | 25 | private static Context context; |
19 | private static MyApplication instance; | 26 | private static MyApplication instance; |
20 | @Override | 27 | @Override |
21 | public void onCreate() { | 28 | public void onCreate() { |
22 | super.onCreate(); | ||
23 | context = getApplicationContext(); | 29 | context = getApplicationContext(); |
24 | //c初始化内存检测 | 30 | //c初始化内存检测 |
25 | LeakCanary.install(this); | 31 | LeakCanary.install(this); |
26 | //初始化Fresco | 32 | //初始化Fresco |
27 | Fresco.initialize(this); | 33 | Fresco.initialize(this); |
28 | mImageCache = new ImageCache(); | 34 | mImageCache = new ImageCache(); |
29 | instance = this; | 35 | instance = this; |
30 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); | 36 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); |
37 | CrashHandler crashHandler = CrashHandler.getInstance(); | ||
38 | crashHandler.init(getApplicationContext()); | ||
39 | crashHandler.registerHandler(new CrashHandler.ExceptionHandler() { | ||
40 | |||
41 | @Override | ||
42 | public boolean handleCrash(final Context context, final Throwable ex) { | ||
43 | new Thread(new Runnable() { | ||
44 | |||
45 | @Override | ||
46 | public void run() { | ||
47 | Looper.prepare(); | ||
48 | System.out.println("bcz = " + ex.toString()); | ||
49 | Toast toast = new Toast(context); | ||
50 | TextView tv = new TextView(context); | ||
51 | tv.setText(" 很抱歉,"+context.getString(R.string.app_name)+"崩溃了,我们会尽快修复."); | ||
52 | tv.setPadding(10, 10, 10, 10); | ||
53 | tv.setTextSize(20); | ||
54 | tv.setBackgroundResource(R.drawable.black_btn_default); | ||
55 | tv.setTextColor(context.getResources().getColor(android.R.color.white)); | ||
56 | Drawable drawable= context.getResources().getDrawable(R.drawable.sorry); | ||
57 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | ||
58 | tv.setCompoundDrawables(drawable,null,null,null); | ||
59 | toast.setView(tv); | ||
60 | toast.setGravity(Gravity.CENTER, 0, 0); | ||
61 | toast.setDuration(Toast.LENGTH_LONG); | ||
62 | toast.show(); | ||
63 | Looper.loop(); | ||
64 | } | ||
65 | }).start(); | ||
66 | try { | ||
67 | Thread.sleep(1000); | ||
68 | } catch (InterruptedException e) { | ||
69 | // TODO Auto-generated catch block | ||
70 | e.printStackTrace(); | ||
71 | } | ||
72 | return false; | ||
73 | } | ||
74 | }); | ||
75 | super.onCreate(); | ||
31 | } | 76 | } |
32 | public ImageCache getImageCache() { | 77 | public ImageCache getImageCache() { |
33 | return mImageCache; | 78 | return mImageCache; |
34 | } | 79 | } |
35 | 80 | ||
36 | public static Context getContext() { | 81 | public static Context getContext() { |
37 | return context; | 82 | return context; |
38 | } | 83 | } |
39 | public static MyApplication getInstance() { | 84 | public static MyApplication getInstance() { |
40 | return instance; | 85 | return instance; |
41 | } | 86 | } |
87 | |||
42 | } | 88 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/crash/CrashHandler.java
File was created | 1 | package com.hjx.personalcenter.crash; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.pm.PackageInfo; | ||
5 | import android.content.pm.PackageManager; | ||
6 | import android.net.wifi.WifiInfo; | ||
7 | import android.net.wifi.WifiManager; | ||
8 | import android.os.Build; | ||
9 | import android.os.Environment; | ||
10 | import android.util.Log; | ||
11 | |||
12 | import com.hjx.personalcenter.util.MachineUtil; | ||
13 | |||
14 | import org.json.JSONObject; | ||
15 | |||
16 | import java.io.BufferedReader; | ||
17 | import java.io.File; | ||
18 | import java.io.FileOutputStream; | ||
19 | import java.io.FileReader; | ||
20 | import java.io.IOException; | ||
21 | import java.io.PrintWriter; | ||
22 | import java.io.StringWriter; | ||
23 | import java.io.Writer; | ||
24 | import java.lang.Thread.UncaughtExceptionHandler; | ||
25 | import java.util.HashMap; | ||
26 | import java.util.Map; | ||
27 | |||
28 | |||
29 | /** | ||
30 | * UncaughtException处理类,当程序发生Uncaught异常的时候,有该类来接管程序,并记录发送错误报告. | ||
31 | * | ||
32 | * @author user | ||
33 | * | ||
34 | */ | ||
35 | public class CrashHandler implements UncaughtExceptionHandler { | ||
36 | |||
37 | public static final String TAG = "CrashHandler"; | ||
38 | // CrashHandler实例 | ||
39 | private static CrashHandler INSTANCE = null; | ||
40 | // 程序的Context对象 | ||
41 | private Context mContext = null; | ||
42 | private ExceptionHandler exceptionH = null; | ||
43 | private StringBuffer log; | ||
44 | |||
45 | // 文件保存路径 | ||
46 | public static final String LOG_DIR = Environment.getExternalStorageDirectory().toString()+"/hjx/log";; | ||
47 | |||
48 | private static final String APP_NAME = "APP_NAME"; | ||
49 | private static final String VERSION_NAME = "VERSION_NAME"; | ||
50 | private static final String VERSION_CODE = "VERSION_CODE"; | ||
51 | private static final String APP_MODLE = "APP_MODLE";// 手机型号 | ||
52 | private static final String CRASH_TIME = "CRASH_TIME"; | ||
53 | private static final String DEVICE_NUMBER = "DEVICE_NUMBER"; | ||
54 | // private static final String IMSI_CODE = "IMSI_CODE"; | ||
55 | // private static final String PHONE_NUMBER = "PHONE_NUMBER"; | ||
56 | private static final String OS_VERSION = "OS_VERSION"; | ||
57 | private static final String MAC_ADDRESS = "MAC_ADDRESS"; | ||
58 | |||
59 | /** 保证只有一个CrashHandler实例 */ | ||
60 | private CrashHandler() { | ||
61 | } | ||
62 | |||
63 | /** 获取CrashHandler实例 ,单例模式 */ | ||
64 | public static synchronized CrashHandler getInstance() { | ||
65 | if(INSTANCE == null){ | ||
66 | INSTANCE = new CrashHandler(); | ||
67 | } | ||
68 | return INSTANCE; | ||
69 | } | ||
70 | |||
71 | public interface ExceptionHandler{ | ||
72 | /** | ||
73 | * | ||
74 | * @param context | ||
75 | * @param ex | ||
76 | * @return 如果返回true消费这个throwable false不消费 | ||
77 | */ | ||
78 | public boolean handleCrash(Context context, Throwable ex); | ||
79 | } | ||
80 | |||
81 | public void registerHandler(ExceptionHandler handler){ | ||
82 | this.exceptionH = handler; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * 初始化 | ||
87 | * | ||
88 | * @param context | ||
89 | */ | ||
90 | public void init(Context context) { | ||
91 | mContext = context; | ||
92 | log = new StringBuffer(); | ||
93 | // 设置该CrashHandler为程序的默认处理器 | ||
94 | Thread.setDefaultUncaughtExceptionHandler(this); | ||
95 | } | ||
96 | |||
97 | /** | ||
98 | * 当UncaughtException发生时会转入该函数来处理 | ||
99 | */ | ||
100 | @Override | ||
101 | public void uncaughtException(Thread thread, Throwable ex) { | ||
102 | if (!handleException(ex)) { | ||
103 | // 收集设备参数信息 | ||
104 | collectDeviceInfo(mContext); | ||
105 | |||
106 | // 保存日志文件 | ||
107 | saveCrashInfo2File(ex); | ||
108 | // 解析文件信息 | ||
109 | //parseFile(path); | ||
110 | // 上传日志文件 | ||
111 | // try { | ||
112 | // urlPostFile(path); | ||
113 | // } catch (Exception e) { | ||
114 | // e.printStackTrace(); | ||
115 | // } | ||
116 | // 退出程序 | ||
117 | } | ||
118 | log.setLength(0); | ||
119 | android.os.Process.killProcess(android.os.Process.myPid()); | ||
120 | System.exit(1); | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * 应用程序自己处理未捕获的异常 | ||
125 | * | ||
126 | * @param ex | ||
127 | * @return true: 如果返回true消耗这个throwable false不消耗 | ||
128 | */ | ||
129 | private boolean handleException(Throwable ex) { | ||
130 | if (exceptionH == null) { | ||
131 | return false; | ||
132 | }else{ | ||
133 | return exceptionH.handleCrash(mContext, ex); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * 收集参数信息 | ||
139 | * | ||
140 | * @param ctx | ||
141 | */ | ||
142 | private void collectDeviceInfo(Context ctx) { | ||
143 | |||
144 | try { | ||
145 | PackageManager pm = ctx.getPackageManager(); | ||
146 | PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), | ||
147 | PackageManager.GET_META_DATA); | ||
148 | if (pi != null) { | ||
149 | String appName = pi.applicationInfo.loadLabel(pm).toString(); | ||
150 | String versionName = pi.versionName == null ? "null" | ||
151 | : pi.versionName; | ||
152 | String versionCode = pi.versionCode + ""; | ||
153 | log.append("{\"").append(APP_NAME).append("\":\"") | ||
154 | .append(appName).append("\",\"") | ||
155 | .append(VERSION_NAME).append("\":\"") | ||
156 | .append(versionName).append("\",\"") | ||
157 | .append(OS_VERSION).append("\":\"") | ||
158 | .append(Build.VERSION.RELEASE).append("\",\"") | ||
159 | .append(VERSION_CODE).append("\":\"") | ||
160 | .append(versionCode).append("\",\"") | ||
161 | .append(APP_MODLE).append("\":\"") | ||
162 | .append(Build.MODEL).append("\",\"") | ||
163 | .append(CRASH_TIME).append("\":\"") | ||
164 | .append(System.currentTimeMillis()).append("\""); | ||
165 | } | ||
166 | } catch (Exception e) { | ||
167 | Log.e(TAG, "an error occured when collect package info", e); | ||
168 | log.setLength(0); | ||
169 | log.append("{\"").append(APP_NAME).append("\":\"") | ||
170 | .append("unkown").append("\",\"") | ||
171 | .append(VERSION_NAME).append("\":\"") | ||
172 | .append("unkown").append("\",\"") | ||
173 | .append(OS_VERSION).append("\":\"") | ||
174 | .append(Build.VERSION.RELEASE).append("\",\"") | ||
175 | .append(VERSION_CODE).append("\":\"") | ||
176 | .append("unkown").append("\",\"") | ||
177 | .append(APP_MODLE).append("\":\"") | ||
178 | .append(Build.MODEL).append("\",\"") | ||
179 | .append(CRASH_TIME).append("\":\"") | ||
180 | .append(System.currentTimeMillis()).append("\""); | ||
181 | } | ||
182 | try { | ||
183 | //common android os | ||
184 | /* | ||
185 | TelephonyManager mTm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE); | ||
186 | String imei = mTm.getDeviceId(); | ||
187 | String imsi = mTm.getSubscriberId(); | ||
188 | String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得 | ||
189 | if(mTm != null){ | ||
190 | log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | ||
191 | .append(TextUtils.isEmpty(imei)?"unkown":imei).append("\",\"") | ||
192 | .append(IMSI_CODE).append("\":\"") | ||
193 | .append(TextUtils.isEmpty(imsi)?"unkown":imsi).append("\",\"") | ||
194 | .append(PHONE_NUMBER).append("\":\"") | ||
195 | .append(TextUtils.isEmpty(numer)?"unkown":numer).append("\"}"); | ||
196 | } | ||
197 | */ | ||
198 | //hjx machine | ||
199 | |||
200 | log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | ||
201 | .append(getCPUSerial(ctx)).append("\",\"") | ||
202 | .append(MAC_ADDRESS).append("\":\"") | ||
203 | .append(getMacAddress(ctx)).append("\"}"); | ||
204 | |||
205 | } catch (Exception e) { | ||
206 | /* | ||
207 | * common android os | ||
208 | log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | ||
209 | .append("unkown").append("\",\"") | ||
210 | .append(IMSI_CODE).append("\":\"") | ||
211 | .append("unkown").append("\",\"") | ||
212 | .append(PHONE_NUMBER).append("\":\"") | ||
213 | .append("unkown").append("\"}"); | ||
214 | */ | ||
215 | log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | ||
216 | .append("unkown").append("\",\"") | ||
217 | .append(MAC_ADDRESS).append("\":\"") | ||
218 | .append("unkown").append("\"}"); | ||
219 | Log.e(TAG, "an error occured when collect package info", e); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | private String getCPUSerial(Context context) { | ||
224 | return MachineUtil.getMachineCode(context); | ||
225 | } | ||
226 | |||
227 | private String getMacAddress(Context mContext){ | ||
228 | String ret = null; | ||
229 | try { | ||
230 | WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); | ||
231 | WifiInfo info = manager.getConnectionInfo(); | ||
232 | ret = info.getMacAddress(); | ||
233 | } catch (Exception e) { | ||
234 | Log.e(TAG, "get wifi address wrong", e); | ||
235 | } | ||
236 | return ret; | ||
237 | } | ||
238 | |||
239 | /** | ||
240 | * 保存错误信息到文件中 | ||
241 | * | ||
242 | * @param ex | ||
243 | * @return 返回文件名称,便于将文件传送到服务器 | ||
244 | */ | ||
245 | private String saveCrashInfo2File(Throwable ex) { | ||
246 | |||
247 | // SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); | ||
248 | Writer writer = new StringWriter(); | ||
249 | PrintWriter printWriter = new PrintWriter(writer); | ||
250 | ex.printStackTrace(printWriter); | ||
251 | Throwable cause = ex.getCause(); | ||
252 | while (cause != null) { | ||
253 | cause.printStackTrace(printWriter); | ||
254 | cause = cause.getCause(); | ||
255 | } | ||
256 | printWriter.close(); | ||
257 | String result = writer.toString(); | ||
258 | log.append("\n").append(result); | ||
259 | try { | ||
260 | // String name = mContext.getPackageName(); | ||
261 | // String time = formatter.format(new Date()); | ||
262 | String fileName = System.currentTimeMillis()+".log"; | ||
263 | if (Environment.getExternalStorageState().equals( | ||
264 | Environment.MEDIA_MOUNTED)) { | ||
265 | File dir = new File(LOG_DIR); | ||
266 | if (!dir.exists()) { | ||
267 | dir.mkdirs(); | ||
268 | } | ||
269 | FileOutputStream fos = new FileOutputStream(LOG_DIR+"/" | ||
270 | + fileName); | ||
271 | fos.write(log.toString().getBytes()); | ||
272 | fos.close(); | ||
273 | } | ||
274 | return fileName; | ||
275 | } catch (Exception e) { | ||
276 | Log.e(TAG, "an error occured while writing file...", e); | ||
277 | } | ||
278 | return null; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * 解析文件信息 | ||
283 | * | ||
284 | * @param filePath | ||
285 | * @return 装有相关信息的map | ||
286 | */ | ||
287 | @Deprecated | ||
288 | public Map<String, String> parseFile(String filePath) { | ||
289 | BufferedReader read = null; | ||
290 | try { | ||
291 | read = new BufferedReader(new FileReader(filePath)); | ||
292 | String line = read.readLine(); | ||
293 | JSONObject jsonObj = new JSONObject(line); | ||
294 | Map<String, String> map = new HashMap<String, String>(); | ||
295 | map.put(APP_NAME, jsonObj.optString(APP_NAME)); | ||
296 | map.put(APP_MODLE, jsonObj.optString(APP_MODLE)); | ||
297 | map.put(VERSION_NAME, jsonObj.optString(VERSION_NAME)); | ||
298 | map.put(VERSION_CODE, jsonObj.optString(VERSION_CODE)); | ||
299 | map.put(CRASH_TIME, jsonObj.optString(CRASH_TIME)); | ||
300 | StringBuffer sb = new StringBuffer(); | ||
301 | int readed = 0; | ||
302 | char[] buf = new char[1024]; | ||
303 | while((readed = read.read(buf))!=-1){ | ||
304 | sb.append(buf,0,readed); | ||
305 | } | ||
306 | map.put("CONTENT", sb.toString()); | ||
307 | return map; | ||
308 | } catch (Exception e) { | ||
309 | e.printStackTrace(); | ||
310 | } finally{ | ||
311 | try { | ||
312 | if(read != null) | ||
313 | read.close(); | ||
314 | } catch (IOException e) { | ||
315 | e.printStackTrace(); | ||
316 | } | ||
317 | } | ||
318 | return null; | ||
319 | } | ||
320 | } | ||
321 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/Content.java
1 | package com.hjx.personalcenter.db; | 1 | package com.hjx.personalcenter.db; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by h on 2017/8/17. | 4 | * Created by h on 2017/8/17. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class Content { | 7 | public class Content { |
8 | public static int authcodeflag;//1是进入填写保卡信息验证,2是修改保卡手机号验证,3是更改绑定验证 | 8 | public static int authcodeflag;//其他是进入填写保卡信息验证,2是修改保卡手机号验证,1是更改绑定验证 |
9 | public static int adressflag;//1购买地址,2客户地址 | 9 | public static int adressflag;//1购买地址,2客户地址 |
10 | public static int accountflag;//1主账户注册信息,2子账户注册信息 | 10 | public static int accountflag;//1主账户注册信息,2子账户注册信息 |
11 | public static int changgeaccountflag;//账户切换成功标志 | 11 | public static int changgeaccountflag;//账户切换成功标志 |
12 | public static int changeinfoflag;//1提交个人信息2是提交版本信息 | ||
12 | } | 13 | } |
13 | 14 |
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.provider.Settings; | 9 | import android.provider.Settings; |
10 | import android.support.v4.app.FragmentActivity; | 10 | import android.support.v4.app.FragmentActivity; |
11 | import android.util.Log; | 11 | import android.util.Log; |
12 | import android.view.Gravity; | 12 | import android.view.Gravity; |
13 | import android.view.View; | 13 | import android.view.View; |
14 | import android.widget.Toast; | 14 | import android.widget.Toast; |
15 | 15 | ||
16 | import com.google.gson.Gson; | 16 | import com.google.gson.Gson; |
17 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
19 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 19 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
20 | import com.hjx.personalcenter.db.Content; | ||
20 | import com.hjx.personalcenter.db.SaveParam; | 21 | import com.hjx.personalcenter.db.SaveParam; |
21 | import com.hjx.personalcenter.gson.GsonTool; | 22 | import com.hjx.personalcenter.gson.GsonTool; |
22 | import com.hjx.personalcenter.model.AppVersion; | 23 | import com.hjx.personalcenter.model.AppVersion; |
23 | import com.hjx.personalcenter.model.CardInfo; | 24 | import com.hjx.personalcenter.model.CardInfo; |
24 | import com.hjx.personalcenter.model.ChildsInfo; | 25 | import com.hjx.personalcenter.model.ChildsInfo; |
25 | import com.hjx.personalcenter.model.CityInfo; | 26 | import com.hjx.personalcenter.model.CityInfo; |
26 | import com.hjx.personalcenter.model.CountyInfo; | 27 | import com.hjx.personalcenter.model.CountyInfo; |
27 | import com.hjx.personalcenter.model.GradeInfo; | 28 | import com.hjx.personalcenter.model.GradeInfo; |
28 | import com.hjx.personalcenter.model.PesonalInfo; | 29 | import com.hjx.personalcenter.model.PesonalInfo; |
29 | import com.hjx.personalcenter.model.ProvinceInfo; | 30 | import com.hjx.personalcenter.model.ProvinceInfo; |
30 | import com.hjx.personalcenter.model.SchoolInfo; | 31 | import com.hjx.personalcenter.model.SchoolInfo; |
31 | import com.hjx.personalcenter.model.SignInfo; | 32 | import com.hjx.personalcenter.model.SignInfo; |
32 | import com.hjx.personalcenter.util.AlertUtils; | 33 | import com.hjx.personalcenter.util.AlertUtils; |
33 | import com.hjx.personalcenter.util.DialogPermission; | 34 | import com.hjx.personalcenter.util.DialogPermission; |
34 | import com.loopj.android.http.AsyncHttpResponseHandler; | 35 | import com.loopj.android.http.AsyncHttpResponseHandler; |
35 | import com.loopj.android.http.JsonHttpResponseHandler; | 36 | import com.loopj.android.http.JsonHttpResponseHandler; |
36 | import com.loopj.android.http.RequestParams; | 37 | import com.loopj.android.http.RequestParams; |
37 | import com.mylhyl.circledialog.CircleDialog; | 38 | import com.mylhyl.circledialog.CircleDialog; |
38 | import com.mylhyl.circledialog.callback.ConfigText; | 39 | import com.mylhyl.circledialog.callback.ConfigText; |
39 | import com.mylhyl.circledialog.params.TextParams; | 40 | import com.mylhyl.circledialog.params.TextParams; |
40 | 41 | ||
41 | import org.apache.http.Header; | 42 | import org.apache.http.Header; |
42 | import org.apache.http.entity.ByteArrayEntity; | 43 | import org.apache.http.entity.ByteArrayEntity; |
43 | import org.apache.http.message.BasicHeader; | 44 | import org.apache.http.message.BasicHeader; |
44 | import org.apache.http.protocol.HTTP; | 45 | import org.apache.http.protocol.HTTP; |
45 | import org.json.JSONException; | 46 | import org.json.JSONException; |
46 | import org.json.JSONObject; | 47 | import org.json.JSONObject; |
47 | 48 | ||
48 | import java.io.File; | 49 | import java.io.File; |
49 | import java.io.FileNotFoundException; | 50 | import java.io.FileNotFoundException; |
50 | import java.io.UnsupportedEncodingException; | 51 | import java.io.UnsupportedEncodingException; |
51 | import java.util.ArrayList; | 52 | import java.util.ArrayList; |
52 | import java.util.List; | 53 | import java.util.List; |
53 | 54 | ||
54 | public class HttpManager { | 55 | public class HttpManager { |
55 | private static HttpManager instance; | 56 | private static HttpManager instance; |
56 | private ProgressDialog mProgress = null; | 57 | private ProgressDialog mProgress = null; |
57 | 58 | ||
58 | public static HttpManager getInstance() { | 59 | public static HttpManager getInstance() { |
59 | if (instance == null) { | 60 | if (instance == null) { |
60 | instance = new HttpManager(); | 61 | instance = new HttpManager(); |
61 | } | 62 | } |
62 | return instance; | 63 | return instance; |
63 | } | 64 | } |
64 | 65 | ||
65 | 66 | ||
66 | //登录接口 | 67 | //登录接口 |
67 | 68 | ||
68 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 69 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
69 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 70 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
70 | false, true, null); | 71 | false, true, null); |
71 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 72 | 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() { | 73 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
73 | @Override | 74 | @Override |
74 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 75 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
75 | closeProgress(); | 76 | closeProgress(); |
76 | Message msg = Message.obtain(); | 77 | Message msg = Message.obtain(); |
77 | msg.what = HttpCode.LOGIN_SUCESS; | 78 | msg.what = HttpCode.LOGIN_SUCESS; |
78 | msg.obj = new String(arg2); | 79 | msg.obj = new String(arg2); |
79 | handler.sendMessage(msg); | 80 | handler.sendMessage(msg); |
80 | 81 | ||
81 | 82 | ||
82 | } | 83 | } |
83 | 84 | ||
84 | @Override | 85 | @Override |
85 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 86 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
86 | closeProgress(); | 87 | closeProgress(); |
87 | new CircleDialog.Builder((FragmentActivity) mContext) | 88 | new CircleDialog.Builder((FragmentActivity) mContext) |
88 | .setCanceledOnTouchOutside(false) | 89 | .setCanceledOnTouchOutside(false) |
89 | .setCancelable(false) | 90 | .setCancelable(false) |
90 | .setWidth(0.5f) | 91 | .setWidth(0.5f) |
91 | .configText(new ConfigText() { | 92 | .configText(new ConfigText() { |
92 | @Override | 93 | @Override |
93 | public void onConfig(TextParams params) { | 94 | public void onConfig(TextParams params) { |
94 | params.gravity = Gravity.CENTER; | 95 | params.gravity = Gravity.CENTER; |
95 | params.padding = new int[]{50, 50, 50, 50}; | 96 | params.padding = new int[]{50, 50, 50, 50}; |
96 | } | 97 | } |
97 | }) | 98 | }) |
98 | .setText("当前无网络,请检查网络设置") | 99 | .setText("当前无网络,请检查网络设置") |
99 | .setNegative("继续使用", null) | 100 | .setNegative("继续使用", null) |
100 | .setPositive("设置网络", new View.OnClickListener() { | 101 | .setPositive("设置网络", new View.OnClickListener() { |
101 | @Override | 102 | @Override |
102 | public void onClick(View v) { | 103 | public void onClick(View v) { |
103 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 104 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
104 | mContext.startActivity(intent); | 105 | mContext.startActivity(intent); |
105 | } | 106 | } |
106 | }) | 107 | }) |
107 | .show(); | 108 | .show(); |
108 | } | 109 | } |
109 | }); | 110 | }); |
110 | } | 111 | } |
111 | 112 | ||
112 | //注册接口 | 113 | //注册接口 |
113 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 114 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
114 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 115 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
115 | false, true, null); | 116 | false, true, null); |
116 | JSONObject jsonObject = new JSONObject(); | 117 | JSONObject jsonObject = new JSONObject(); |
117 | ByteArrayEntity entity = null; | 118 | ByteArrayEntity entity = null; |
118 | try { | 119 | try { |
119 | jsonObject.put(HttpKey.USERNAME, username); | 120 | jsonObject.put(HttpKey.USERNAME, username); |
120 | jsonObject.put(HttpKey.PASSWORD, password); | 121 | jsonObject.put(HttpKey.PASSWORD, password); |
121 | jsonObject.put(HttpKey.SMSCODE, smscode); | 122 | jsonObject.put(HttpKey.SMSCODE, smscode); |
122 | jsonObject.put(HttpKey.SOURCE, source); | 123 | jsonObject.put(HttpKey.SOURCE, source); |
123 | Log.e("test", "jsonObject" + jsonObject); | 124 | Log.e("test", "jsonObject" + jsonObject); |
124 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 125 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
125 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 126 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
126 | } catch (JSONException e) { | 127 | } catch (JSONException e) { |
127 | e.printStackTrace(); | 128 | e.printStackTrace(); |
128 | } catch (UnsupportedEncodingException e) { | 129 | } catch (UnsupportedEncodingException e) { |
129 | e.printStackTrace(); | 130 | e.printStackTrace(); |
130 | } | 131 | } |
131 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 132 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
132 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 133 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
133 | @Override | 134 | @Override |
134 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 135 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
135 | super.onSuccess(statusCode, headers, response); | 136 | super.onSuccess(statusCode, headers, response); |
136 | closeProgress(); | 137 | closeProgress(); |
137 | Log.e("test", "onSuccess" + response); | 138 | Log.e("test", "onSuccess" + response); |
138 | Message msg = Message.obtain(); | 139 | Message msg = Message.obtain(); |
139 | msg.what = HttpCode.REGISTERED_SUCESS; | 140 | msg.what = HttpCode.REGISTERED_SUCESS; |
140 | msg.obj = response; | 141 | msg.obj = response; |
141 | handler.sendMessage(msg); | 142 | handler.sendMessage(msg); |
142 | 143 | ||
143 | } | 144 | } |
144 | 145 | ||
145 | @Override | 146 | @Override |
146 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 147 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
147 | super.onFailure(statusCode, headers, throwable, errorResponse); | 148 | super.onFailure(statusCode, headers, throwable, errorResponse); |
148 | closeProgress(); | 149 | closeProgress(); |
149 | Log.e("test", "onFailure" + errorResponse); | 150 | Log.e("test", "onFailure" + errorResponse); |
150 | new CircleDialog.Builder((FragmentActivity) context) | 151 | new CircleDialog.Builder((FragmentActivity) context) |
151 | .setCanceledOnTouchOutside(false) | 152 | .setCanceledOnTouchOutside(false) |
152 | .setCancelable(false) | 153 | .setCancelable(false) |
153 | .setWidth(0.5f) | 154 | .setWidth(0.5f) |
154 | .configText(new ConfigText() { | 155 | .configText(new ConfigText() { |
155 | @Override | 156 | @Override |
156 | public void onConfig(TextParams params) { | 157 | public void onConfig(TextParams params) { |
157 | params.gravity = Gravity.CENTER; | 158 | params.gravity = Gravity.CENTER; |
158 | params.padding = new int[]{50, 50, 50, 50}; | 159 | params.padding = new int[]{50, 50, 50, 50}; |
159 | } | 160 | } |
160 | }) | 161 | }) |
161 | .setText("当前无网络,请检查网络设置") | 162 | .setText("当前无网络,请检查网络设置") |
162 | .setNegative("继续使用", null) | 163 | .setNegative("继续使用", null) |
163 | .setPositive("设置网络", new View.OnClickListener() { | 164 | .setPositive("设置网络", new View.OnClickListener() { |
164 | @Override | 165 | @Override |
165 | public void onClick(View v) { | 166 | public void onClick(View v) { |
166 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 167 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
167 | context.startActivity(intent); | 168 | context.startActivity(intent); |
168 | } | 169 | } |
169 | }) | 170 | }) |
170 | .show(); | 171 | .show(); |
171 | } | 172 | } |
172 | 173 | ||
173 | }); | 174 | }); |
174 | } | 175 | } |
175 | 176 | ||
176 | //注册验证码 | 177 | //注册验证码 |
177 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 178 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
178 | RequestParams params = new RequestParams(); | 179 | RequestParams params = new RequestParams(); |
179 | params.put(HttpKey.TYPE, type); | 180 | params.put(HttpKey.TYPE, type); |
180 | params.put(HttpKey.MOBIL, mobile); | 181 | params.put(HttpKey.MOBIL, mobile); |
181 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 182 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
182 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 183 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
183 | 184 | ||
184 | @Override | 185 | @Override |
185 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 186 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
186 | Log.e("test", "onSuccess-----" + response); | 187 | Log.e("test", "onSuccess-----" + response); |
187 | Message msg = Message.obtain(); | 188 | Message msg = Message.obtain(); |
188 | msg.what = HttpCode.AUTHCODE_SUCESS; | 189 | msg.what = HttpCode.AUTHCODE_SUCESS; |
189 | msg.obj = response; | 190 | msg.obj = response; |
190 | handler.sendMessage(msg); | 191 | handler.sendMessage(msg); |
191 | } | 192 | } |
192 | 193 | ||
193 | @Override | 194 | @Override |
194 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 195 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
195 | new CircleDialog.Builder((FragmentActivity) mContext) | 196 | new CircleDialog.Builder((FragmentActivity) mContext) |
196 | .setCanceledOnTouchOutside(false) | 197 | .setCanceledOnTouchOutside(false) |
197 | .setCancelable(false) | 198 | .setCancelable(false) |
198 | .setWidth(0.5f) | 199 | .setWidth(0.5f) |
199 | .configText(new ConfigText() { | 200 | .configText(new ConfigText() { |
200 | @Override | 201 | @Override |
201 | public void onConfig(TextParams params) { | 202 | public void onConfig(TextParams params) { |
202 | params.gravity = Gravity.CENTER; | 203 | params.gravity = Gravity.CENTER; |
203 | params.padding = new int[]{50, 50, 50, 50}; | 204 | params.padding = new int[]{50, 50, 50, 50}; |
204 | } | 205 | } |
205 | }) | 206 | }) |
206 | .setText("当前无网络,请检查网络设置") | 207 | .setText("当前无网络,请检查网络设置") |
207 | .setNegative("继续使用", null) | 208 | .setNegative("继续使用", null) |
208 | .setPositive("设置网络", new View.OnClickListener() { | 209 | .setPositive("设置网络", new View.OnClickListener() { |
209 | @Override | 210 | @Override |
210 | public void onClick(View v) { | 211 | public void onClick(View v) { |
211 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 212 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
212 | mContext.startActivity(intent); | 213 | mContext.startActivity(intent); |
213 | } | 214 | } |
214 | }) | 215 | }) |
215 | .show(); | 216 | .show(); |
216 | } | 217 | } |
217 | }); | 218 | }); |
218 | } | 219 | } |
219 | 220 | ||
220 | 221 | ||
221 | //手机号是否注册 | 222 | //手机号是否注册 |
222 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 223 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
223 | RequestParams params = new RequestParams(); | 224 | RequestParams params = new RequestParams(); |
224 | params.put(HttpKey.USERNAME, mobile); | 225 | params.put(HttpKey.USERNAME, mobile); |
225 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 226 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
226 | @Override | 227 | @Override |
227 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 228 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
228 | Log.e("test", "isregistered" + response.toString()); | 229 | Log.e("test", "isregistered" + response.toString()); |
229 | Message msg = Message.obtain(); | 230 | Message msg = Message.obtain(); |
230 | msg.what = HttpCode.IS_REFISTER; | 231 | msg.what = HttpCode.IS_REFISTER; |
231 | msg.obj = response; | 232 | msg.obj = response; |
232 | handler.sendMessage(msg); | 233 | handler.sendMessage(msg); |
233 | 234 | ||
234 | } | 235 | } |
235 | 236 | ||
236 | @Override | 237 | @Override |
237 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 238 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
238 | new CircleDialog.Builder((FragmentActivity) mContext) | 239 | new CircleDialog.Builder((FragmentActivity) mContext) |
239 | .setCanceledOnTouchOutside(false) | 240 | .setCanceledOnTouchOutside(false) |
240 | .setCancelable(false) | 241 | .setCancelable(false) |
241 | .setWidth(0.5f) | 242 | .setWidth(0.5f) |
242 | .configText(new ConfigText() { | 243 | .configText(new ConfigText() { |
243 | @Override | 244 | @Override |
244 | public void onConfig(TextParams params) { | 245 | public void onConfig(TextParams params) { |
245 | params.gravity = Gravity.CENTER; | 246 | params.gravity = Gravity.CENTER; |
246 | params.padding = new int[]{50, 50, 50, 50}; | 247 | params.padding = new int[]{50, 50, 50, 50}; |
247 | } | 248 | } |
248 | }) | 249 | }) |
249 | .setText("当前无网络,请检查网络设置") | 250 | .setText("当前无网络,请检查网络设置") |
250 | .setNegative("继续使用", null) | 251 | .setNegative("继续使用", null) |
251 | .setPositive("设置网络", new View.OnClickListener() { | 252 | .setPositive("设置网络", new View.OnClickListener() { |
252 | @Override | 253 | @Override |
253 | public void onClick(View v) { | 254 | public void onClick(View v) { |
254 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 255 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
255 | mContext.startActivity(intent); | 256 | mContext.startActivity(intent); |
256 | } | 257 | } |
257 | }) | 258 | }) |
258 | .show(); | 259 | .show(); |
259 | 260 | ||
260 | } | 261 | } |
261 | }); | 262 | }); |
262 | } | 263 | } |
263 | 264 | ||
264 | //修改密码 | 265 | //修改密码 |
265 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 266 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
266 | RequestParams params = new RequestParams(); | 267 | RequestParams params = new RequestParams(); |
267 | params.put(HttpKey.USERNAME, username); | 268 | params.put(HttpKey.USERNAME, username); |
268 | params.put(HttpKey.OLDPASS, old_pwd1); | 269 | params.put(HttpKey.OLDPASS, old_pwd1); |
269 | params.put(HttpKey.NEWPASS, newpassword3); | 270 | params.put(HttpKey.NEWPASS, newpassword3); |
270 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 271 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
271 | HttpClient.getInstance().setTimeout(10 * 1000); | 272 | HttpClient.getInstance().setTimeout(10 * 1000); |
272 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 273 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
273 | @Override | 274 | @Override |
274 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 275 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
275 | try { | 276 | try { |
276 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 277 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
277 | String status = jsonObject.optString("status"); | 278 | String status = jsonObject.optString("status"); |
278 | if (status.equals("100")) { | 279 | if (status.equals("100")) { |
279 | Log.e("test", "onSuccess" + new String(bytes)); | 280 | Log.e("test", "onSuccess" + new String(bytes)); |
280 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 281 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
281 | SaveParam.getInstance().clearData((Activity) context); | 282 | SaveParam.getInstance().clearData((Activity) context); |
282 | Intent intent = new Intent(); | 283 | Intent intent = new Intent(); |
283 | intent.setClass(context, LoginAndRegisterActivity.class); | 284 | intent.setClass(context, LoginAndRegisterActivity.class); |
284 | ((Activity) context).startActivity(intent); | 285 | ((Activity) context).startActivity(intent); |
285 | ((Activity) context).finish(); | 286 | ((Activity) context).finish(); |
286 | } else { | 287 | } else { |
287 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 288 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
288 | } | 289 | } |
289 | } catch (JSONException e) { | 290 | } catch (JSONException e) { |
290 | e.printStackTrace(); | 291 | e.printStackTrace(); |
291 | } | 292 | } |
292 | } | 293 | } |
293 | 294 | ||
294 | @Override | 295 | @Override |
295 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 296 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
296 | Log.e("test", "onFailure" + new String(bytes)); | 297 | Log.e("test", "onFailure" + new String(bytes)); |
297 | new CircleDialog.Builder((FragmentActivity) context) | 298 | new CircleDialog.Builder((FragmentActivity) context) |
298 | .setCanceledOnTouchOutside(false) | 299 | .setCanceledOnTouchOutside(false) |
299 | .setCancelable(false) | 300 | .setCancelable(false) |
300 | .setWidth(0.5f) | 301 | .setWidth(0.5f) |
301 | .configText(new ConfigText() { | 302 | .configText(new ConfigText() { |
302 | @Override | 303 | @Override |
303 | public void onConfig(TextParams params) { | 304 | public void onConfig(TextParams params) { |
304 | params.gravity = Gravity.CENTER; | 305 | params.gravity = Gravity.CENTER; |
305 | params.padding = new int[]{50, 50, 50, 50}; | 306 | params.padding = new int[]{50, 50, 50, 50}; |
306 | } | 307 | } |
307 | }) | 308 | }) |
308 | .setText("当前无网络,请检查网络设置") | 309 | .setText("当前无网络,请检查网络设置") |
309 | .setNegative("继续使用", null) | 310 | .setNegative("继续使用", null) |
310 | .setPositive("设置网络", new View.OnClickListener() { | 311 | .setPositive("设置网络", new View.OnClickListener() { |
311 | @Override | 312 | @Override |
312 | public void onClick(View v) { | 313 | public void onClick(View v) { |
313 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 314 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
314 | context.startActivity(intent); | 315 | context.startActivity(intent); |
315 | } | 316 | } |
316 | }) | 317 | }) |
317 | .show(); | 318 | .show(); |
318 | } | 319 | } |
319 | }); | 320 | }); |
320 | 321 | ||
321 | } | 322 | } |
322 | 323 | ||
323 | //忘记密码 | 324 | //忘记密码 |
324 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 325 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
325 | RequestParams params = new RequestParams(); | 326 | RequestParams params = new RequestParams(); |
326 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 327 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
327 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 328 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
328 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 329 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
329 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 330 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
330 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 331 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
331 | @Override | 332 | @Override |
332 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 333 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
333 | try { | 334 | try { |
334 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 335 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
335 | String status = jsonObject.optString("status"); | 336 | String status = jsonObject.optString("status"); |
336 | if (status.equals("100")) { | 337 | if (status.equals("100")) { |
337 | Log.e("test", "onSuccess" + new String(bytes)); | 338 | Log.e("test", "onSuccess" + new String(bytes)); |
338 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 339 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
339 | ((Activity) context).finish(); | 340 | ((Activity) context).finish(); |
340 | } else { | 341 | } else { |
341 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 342 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
342 | } | 343 | } |
343 | } catch (JSONException e) { | 344 | } catch (JSONException e) { |
344 | e.printStackTrace(); | 345 | e.printStackTrace(); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | @Override | 349 | @Override |
349 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 350 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
350 | Log.e("test", "onFailure" + new String(bytes)); | 351 | Log.e("test", "onFailure" + new String(bytes)); |
351 | new CircleDialog.Builder((FragmentActivity) context) | 352 | new CircleDialog.Builder((FragmentActivity) context) |
352 | .setCanceledOnTouchOutside(false) | 353 | .setCanceledOnTouchOutside(false) |
353 | .setCancelable(false) | 354 | .setCancelable(false) |
354 | .setWidth(0.5f) | 355 | .setWidth(0.5f) |
355 | .configText(new ConfigText() { | 356 | .configText(new ConfigText() { |
356 | @Override | 357 | @Override |
357 | public void onConfig(TextParams params) { | 358 | public void onConfig(TextParams params) { |
358 | params.gravity = Gravity.CENTER; | 359 | params.gravity = Gravity.CENTER; |
359 | params.padding = new int[]{50, 50, 50, 50}; | 360 | params.padding = new int[]{50, 50, 50, 50}; |
360 | } | 361 | } |
361 | }) | 362 | }) |
362 | .setText("当前无网络,请检查网络设置") | 363 | .setText("当前无网络,请检查网络设置") |
363 | .setNegative("继续使用", null) | 364 | .setNegative("继续使用", null) |
364 | .setPositive("设置网络", new View.OnClickListener() { | 365 | .setPositive("设置网络", new View.OnClickListener() { |
365 | @Override | 366 | @Override |
366 | public void onClick(View v) { | 367 | public void onClick(View v) { |
367 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 368 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
368 | context.startActivity(intent); | 369 | context.startActivity(intent); |
369 | } | 370 | } |
370 | }) | 371 | }) |
371 | .show(); | 372 | .show(); |
372 | } | 373 | } |
373 | }); | 374 | }); |
374 | 375 | ||
375 | } | 376 | } |
376 | 377 | ||
377 | //保存用户登录信息 | 378 | //保存用户登录信息 |
378 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 379 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
379 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 380 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
380 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 381 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
381 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 382 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
382 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 383 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
383 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 384 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
384 | 385 | ||
385 | 386 | ||
386 | } | 387 | } |
387 | 388 | ||
388 | //提交保卡信息 | 389 | //提交保卡信息 |
389 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 390 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
390 | String buyAddress, String buyTime, String alterSaleCall, | 391 | String buyAddress, String buyTime, String alterSaleCall, |
391 | String productModel, String deviceNumber, String macAddress, | 392 | String productModel, String deviceNumber, String macAddress, |
392 | String mobilePhone) { | 393 | String mobilePhone) { |
393 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 394 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
394 | false, true, null); | 395 | false, true, null); |
395 | RequestParams params = new RequestParams(); | 396 | RequestParams params = new RequestParams(); |
396 | 397 | ||
397 | params.put(HttpKey.USEID, userId); | 398 | params.put(HttpKey.USEID, userId); |
398 | params.put(HttpKey.CUSTOMENAME, customerName); | 399 | params.put(HttpKey.CUSTOMENAME, customerName); |
399 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 400 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
400 | params.put(HttpKey.BUYADREES, buyAddress); | 401 | params.put(HttpKey.BUYADREES, buyAddress); |
401 | params.put(HttpKey.BUYTIME, buyTime); | 402 | params.put(HttpKey.BUYTIME, buyTime); |
402 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 403 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
403 | params.put(HttpKey.PRODUCTMODEL, productModel); | 404 | params.put(HttpKey.PRODUCTMODEL, productModel); |
404 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 405 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
405 | params.put(HttpKey.MACADRESS, macAddress); | 406 | params.put(HttpKey.MACADRESS, macAddress); |
406 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 407 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
407 | 408 | ||
408 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 409 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
409 | 410 | ||
410 | Log.e("test", "params" + params); | 411 | Log.e("test", "params" + params); |
411 | HttpClient.getInstance().setTimeout(5 * 1000); | 412 | HttpClient.getInstance().setTimeout(5 * 1000); |
412 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 413 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
413 | @Override | 414 | @Override |
414 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 415 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
415 | JSONObject jsonObject = null; | 416 | JSONObject jsonObject = null; |
416 | closeProgress(); | 417 | closeProgress(); |
417 | try { | 418 | try { |
418 | jsonObject = new JSONObject(new String(bytes)); | 419 | jsonObject = new JSONObject(new String(bytes)); |
419 | String status = jsonObject.optString("status"); | 420 | String status = jsonObject.optString("status"); |
420 | if (status.equals("1")) { | 421 | if (status.equals("1")) { |
421 | Log.e("test", "onSuccess" + jsonObject); | 422 | Log.e("test", "onSuccess" + jsonObject); |
422 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 423 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
423 | Intent intent = new Intent(); | 424 | Intent intent = new Intent(); |
424 | intent.setClass((Activity) context, TheStartPageActivity.class); | 425 | intent.setClass((Activity) context, TheStartPageActivity.class); |
425 | ((Activity) context).startActivity(intent); | 426 | ((Activity) context).startActivity(intent); |
426 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 427 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
427 | ((Activity) context).finish(); | 428 | ((Activity) context).finish(); |
428 | } else { | 429 | } else { |
429 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); | 430 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); |
430 | } | 431 | } |
431 | } catch (JSONException e) { | 432 | } catch (JSONException e) { |
432 | e.printStackTrace(); | 433 | e.printStackTrace(); |
433 | } | 434 | } |
434 | 435 | ||
435 | 436 | ||
436 | } | 437 | } |
437 | 438 | ||
438 | @Override | 439 | @Override |
439 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 440 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
440 | Log.e("test", "onFailure" + (throwable)); | 441 | Log.e("test", "onFailure" + (throwable)); |
441 | closeProgress(); | 442 | closeProgress(); |
442 | new CircleDialog.Builder((FragmentActivity) context) | 443 | new CircleDialog.Builder((FragmentActivity) context) |
443 | .setCanceledOnTouchOutside(false) | 444 | .setCanceledOnTouchOutside(false) |
444 | .setCancelable(false) | 445 | .setCancelable(false) |
445 | .setWidth(0.5f) | 446 | .setWidth(0.5f) |
446 | .configText(new ConfigText() { | 447 | .configText(new ConfigText() { |
447 | @Override | 448 | @Override |
448 | public void onConfig(TextParams params) { | 449 | public void onConfig(TextParams params) { |
449 | params.gravity = Gravity.CENTER; | 450 | params.gravity = Gravity.CENTER; |
450 | params.padding = new int[]{50, 50, 50, 50}; | 451 | params.padding = new int[]{50, 50, 50, 50}; |
451 | } | 452 | } |
452 | }) | 453 | }) |
453 | .setText("当前无网络,请检查网络设置") | 454 | .setText("当前无网络,请检查网络设置") |
454 | .setNegative("继续使用", null) | 455 | .setNegative("继续使用", null) |
455 | .setPositive("设置网络", new View.OnClickListener() { | 456 | .setPositive("设置网络", new View.OnClickListener() { |
456 | @Override | 457 | @Override |
457 | public void onClick(View v) { | 458 | public void onClick(View v) { |
458 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 459 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
459 | context.startActivity(intent); | 460 | context.startActivity(intent); |
460 | } | 461 | } |
461 | }) | 462 | }) |
462 | .show(); | 463 | .show(); |
463 | 464 | ||
464 | } | 465 | } |
465 | }); | 466 | }); |
466 | 467 | ||
467 | } | 468 | } |
468 | 469 | ||
469 | //获取保卡信息 | 470 | //获取保卡信息 |
470 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { | 471 | public void getcardinfo(final Context mContext, long userId, final Handler handler) { |
471 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 472 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
472 | false, true, null); | 473 | false, true, null); |
473 | HttpClient.getInstance().setTimeout(5 * 1000); | 474 | HttpClient.getInstance().setTimeout(5 * 1000); |
474 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 475 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
475 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { | 476 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?userId=" + userId, new AsyncHttpResponseHandler() { |
476 | @Override | 477 | @Override |
477 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 478 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
478 | closeProgress(); | 479 | closeProgress(); |
479 | Log.e("test", "保卡信息" + new String(arg2)); | 480 | Log.e("test", "保卡信息" + new String(arg2)); |
480 | try { | 481 | try { |
481 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 482 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
482 | int status = jsonObject.optInt("status"); | 483 | int status = jsonObject.optInt("status"); |
483 | if (status == 1) { | 484 | if (status == 1) { |
484 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 485 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
485 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 486 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
486 | Message msg = Message.obtain(); | 487 | Message msg = Message.obtain(); |
487 | msg.what = HttpCode.SUCHCARDINFO; | 488 | msg.what = HttpCode.SUCHCARDINFO; |
488 | msg.obj = schoolInfoBeanList; | 489 | msg.obj = schoolInfoBeanList; |
489 | handler.sendMessage(msg); | 490 | handler.sendMessage(msg); |
490 | 491 | ||
491 | 492 | ||
492 | } else { | 493 | } else { |
493 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 494 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
494 | 495 | ||
495 | } | 496 | } |
496 | } catch (JSONException e) { | 497 | } catch (JSONException e) { |
497 | e.printStackTrace(); | 498 | e.printStackTrace(); |
498 | } | 499 | } |
499 | 500 | ||
500 | } | 501 | } |
501 | 502 | ||
502 | @Override | 503 | @Override |
503 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 504 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
504 | closeProgress(); | 505 | closeProgress(); |
505 | new CircleDialog.Builder((FragmentActivity) mContext) | 506 | new CircleDialog.Builder((FragmentActivity) mContext) |
506 | .setCanceledOnTouchOutside(false) | 507 | .setCanceledOnTouchOutside(false) |
507 | .setCancelable(false) | 508 | .setCancelable(false) |
508 | .setWidth(0.5f) | 509 | .setWidth(0.5f) |
509 | .configText(new ConfigText() { | 510 | .configText(new ConfigText() { |
510 | @Override | 511 | @Override |
511 | public void onConfig(TextParams params) { | 512 | public void onConfig(TextParams params) { |
512 | params.gravity = Gravity.CENTER; | 513 | params.gravity = Gravity.CENTER; |
513 | params.padding = new int[]{50, 50, 50, 50}; | 514 | params.padding = new int[]{50, 50, 50, 50}; |
514 | } | 515 | } |
515 | }) | 516 | }) |
516 | .setText("当前无网络,请检查网络设置") | 517 | .setText("当前无网络,请检查网络设置") |
517 | .setNegative("继续使用", null) | 518 | .setNegative("继续使用", null) |
518 | .setPositive("设置网络", new View.OnClickListener() { | 519 | .setPositive("设置网络", new View.OnClickListener() { |
519 | @Override | 520 | @Override |
520 | public void onClick(View v) { | 521 | public void onClick(View v) { |
521 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 522 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
522 | mContext.startActivity(intent); | 523 | mContext.startActivity(intent); |
523 | } | 524 | } |
524 | }) | 525 | }) |
525 | .show(); | 526 | .show(); |
526 | } | 527 | } |
527 | }); | 528 | }); |
528 | } | 529 | } |
529 | 530 | ||
530 | //修改保卡信息电话 | 531 | //修改保卡信息电话 |
531 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 532 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
532 | RequestParams params = new RequestParams(); | 533 | RequestParams params = new RequestParams(); |
533 | params.put("userId", userId); | 534 | params.put("userId", userId); |
534 | params.put("customerPhone", customerPhone); | 535 | params.put("customerPhone", customerPhone); |
535 | params.put("authCode", authCode); | 536 | params.put("authCode", authCode); |
536 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 537 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
537 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 538 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
538 | @Override | 539 | @Override |
539 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 540 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
540 | try { | 541 | try { |
541 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 542 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
542 | String status = jsonObject.optString("status"); | 543 | String status = jsonObject.optString("status"); |
543 | if (status.equals("1")) { | 544 | if (status.equals("1")) { |
544 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 545 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
545 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | 546 | if (Content.authcodeflag==2){ |
547 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | ||
548 | }else if (Content.authcodeflag==1){ | ||
549 | SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); | ||
550 | }else { | ||
551 | AlertUtils.showToast(mContext, "修改未知的手机号"); | ||
552 | } | ||
546 | ((Activity) mContext).finish(); | 553 | ((Activity) mContext).finish(); |
547 | } else if (status.equals("1001")) { | 554 | } else if (status.equals("1001")) { |
548 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 555 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
549 | } else { | 556 | } else { |
550 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 557 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
551 | } | 558 | } |
552 | } catch (JSONException e) { | 559 | } catch (JSONException e) { |
553 | e.printStackTrace(); | 560 | e.printStackTrace(); |
554 | } | 561 | } |
555 | } | 562 | } |
556 | 563 | ||
557 | @Override | 564 | @Override |
558 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 565 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
559 | Log.e("test", "onFailure" + new String(bytes)); | 566 | Log.e("test", "onFailure" + new String(bytes)); |
560 | new CircleDialog.Builder((FragmentActivity) mContext) | 567 | new CircleDialog.Builder((FragmentActivity) mContext) |
561 | .setCanceledOnTouchOutside(false) | 568 | .setCanceledOnTouchOutside(false) |
562 | .setCancelable(false) | 569 | .setCancelable(false) |
563 | .setWidth(0.5f) | 570 | .setWidth(0.5f) |
564 | .configText(new ConfigText() { | 571 | .configText(new ConfigText() { |
565 | @Override | 572 | @Override |
566 | public void onConfig(TextParams params) { | 573 | public void onConfig(TextParams params) { |
567 | params.gravity = Gravity.CENTER; | 574 | params.gravity = Gravity.CENTER; |
568 | params.padding = new int[]{50, 50, 50, 50}; | 575 | params.padding = new int[]{50, 50, 50, 50}; |
569 | } | 576 | } |
570 | }) | 577 | }) |
571 | .setText("当前无网络,请检查网络设置") | 578 | .setText("当前无网络,请检查网络设置") |
572 | .setNegative("继续使用", null) | 579 | .setNegative("继续使用", null) |
573 | .setPositive("设置网络", new View.OnClickListener() { | 580 | .setPositive("设置网络", new View.OnClickListener() { |
574 | @Override | 581 | @Override |
575 | public void onClick(View v) { | 582 | public void onClick(View v) { |
576 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 583 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
577 | mContext.startActivity(intent); | 584 | mContext.startActivity(intent); |
578 | } | 585 | } |
579 | }) | 586 | }) |
580 | .show(); | 587 | .show(); |
581 | } | 588 | } |
582 | }); | 589 | }); |
583 | } | 590 | } |
584 | 591 | ||
585 | //修改保卡信息地址 | 592 | //修改保卡信息地址 |
586 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 593 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
587 | RequestParams params = new RequestParams(); | 594 | RequestParams params = new RequestParams(); |
588 | params.put("userId", userId); | 595 | params.put("userId", userId); |
589 | params.put("customerPhone", customerPhone); | 596 | params.put("customerPhone", customerPhone); |
590 | params.put("authCode", authCode); | 597 | params.put("authCode", authCode); |
591 | params.put("customerAddress", customerAddress); | 598 | params.put("customerAddress", customerAddress); |
592 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 599 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
593 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 600 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
594 | @Override | 601 | @Override |
595 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 602 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
596 | try { | 603 | try { |
597 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 604 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
598 | String status = jsonObject.optString("status"); | 605 | String status = jsonObject.optString("status"); |
599 | if (status.equals("1")) { | 606 | if (status.equals("1")) { |
600 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 607 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
601 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); | 608 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); |
602 | ((Activity) mContext).finish(); | 609 | ((Activity) mContext).finish(); |
603 | } else { | 610 | } else { |
604 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 611 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
605 | } | 612 | } |
606 | } catch (JSONException e) { | 613 | } catch (JSONException e) { |
607 | e.printStackTrace(); | 614 | e.printStackTrace(); |
608 | } | 615 | } |
609 | } | 616 | } |
610 | 617 | ||
611 | @Override | 618 | @Override |
612 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 619 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
613 | Log.e("test", "onFailure" + new String(bytes)); | 620 | Log.e("test", "onFailure" + new String(bytes)); |
614 | new CircleDialog.Builder((FragmentActivity) mContext) | 621 | new CircleDialog.Builder((FragmentActivity) mContext) |
615 | .setCanceledOnTouchOutside(false) | 622 | .setCanceledOnTouchOutside(false) |
616 | .setCancelable(false) | 623 | .setCancelable(false) |
617 | .setWidth(0.5f) | 624 | .setWidth(0.5f) |
618 | .configText(new ConfigText() { | 625 | .configText(new ConfigText() { |
619 | @Override | 626 | @Override |
620 | public void onConfig(TextParams params) { | 627 | public void onConfig(TextParams params) { |
621 | params.gravity = Gravity.CENTER; | 628 | params.gravity = Gravity.CENTER; |
622 | params.padding = new int[]{50, 50, 50, 50}; | 629 | params.padding = new int[]{50, 50, 50, 50}; |
623 | } | 630 | } |
624 | }) | 631 | }) |
625 | .setText("当前无网络,请检查网络设置") | 632 | .setText("当前无网络,请检查网络设置") |
626 | .setNegative("继续使用", null) | 633 | .setNegative("继续使用", null) |
627 | .setPositive("设置网络", new View.OnClickListener() { | 634 | .setPositive("设置网络", new View.OnClickListener() { |
628 | @Override | 635 | @Override |
629 | public void onClick(View v) { | 636 | public void onClick(View v) { |
630 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 637 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
631 | mContext.startActivity(intent); | 638 | mContext.startActivity(intent); |
632 | } | 639 | } |
633 | }) | 640 | }) |
634 | .show(); | 641 | .show(); |
635 | } | 642 | } |
636 | }); | 643 | }); |
637 | } | 644 | } |
638 | 645 | ||
639 | //验证是否保卡信息 | 646 | //验证是否保卡信息 |
640 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { | 647 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { |
641 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 648 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
642 | false, true, null); | 649 | false, true, null); |
643 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 650 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
644 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { | 651 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?userId=" + userId, new AsyncHttpResponseHandler() { |
645 | @Override | 652 | @Override |
646 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 653 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
647 | Log.e("test", "---" + new String(arg2)); | 654 | Log.e("test", "---" + new String(arg2)); |
648 | closeProgress(); | 655 | closeProgress(); |
649 | Message msg = Message.obtain(); | 656 | Message msg = Message.obtain(); |
650 | msg.what = HttpCode.CHECKCARD; | 657 | msg.what = HttpCode.CHECKCARD; |
651 | msg.obj = new String(arg2); | 658 | msg.obj = new String(arg2); |
652 | handler.sendMessage(msg); | 659 | handler.sendMessage(msg); |
653 | 660 | ||
654 | 661 | ||
655 | } | 662 | } |
656 | 663 | ||
657 | @Override | 664 | @Override |
658 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 665 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
659 | closeProgress(); | 666 | closeProgress(); |
660 | new CircleDialog.Builder((FragmentActivity) mContext) | 667 | new CircleDialog.Builder((FragmentActivity) mContext) |
661 | .setCanceledOnTouchOutside(false) | 668 | .setCanceledOnTouchOutside(false) |
662 | .setCancelable(false) | 669 | .setCancelable(false) |
663 | .setWidth(0.5f) | 670 | .setWidth(0.5f) |
664 | .configText(new ConfigText() { | 671 | .configText(new ConfigText() { |
665 | @Override | 672 | @Override |
666 | public void onConfig(TextParams params) { | 673 | public void onConfig(TextParams params) { |
667 | params.gravity = Gravity.CENTER; | 674 | params.gravity = Gravity.CENTER; |
668 | params.padding = new int[]{50, 50, 50, 50}; | 675 | params.padding = new int[]{50, 50, 50, 50}; |
669 | } | 676 | } |
670 | }) | 677 | }) |
671 | .setText("当前无网络,请检查网络设置") | 678 | .setText("当前无网络,请检查网络设置") |
672 | .setNegative("继续使用", null) | 679 | .setNegative("继续使用", null) |
673 | .setPositive("设置网络", new View.OnClickListener() { | 680 | .setPositive("设置网络", new View.OnClickListener() { |
674 | @Override | 681 | @Override |
675 | public void onClick(View v) { | 682 | public void onClick(View v) { |
676 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 683 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
677 | mContext.startActivity(intent); | 684 | mContext.startActivity(intent); |
678 | } | 685 | } |
679 | }) | 686 | }) |
680 | .show(); | 687 | .show(); |
681 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 688 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
682 | } | 689 | } |
683 | }); | 690 | }); |
684 | } | 691 | } |
685 | 692 | ||
686 | ///获取年级 | 693 | ///获取年级 |
687 | public void getgrade(final Context mContext, final Handler handler) { | 694 | public void getgrade(final Context mContext, final Handler handler) { |
688 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 695 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
689 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 696 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
690 | @Override | 697 | @Override |
691 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 698 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
692 | Log.e("test", "年级" + new String(arg2)); | 699 | Log.e("test", "年级" + new String(arg2)); |
693 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 700 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
694 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 701 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
695 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { | 702 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { |
696 | String name = gradeInfo.getData().get(i).getName(); | 703 | String name = gradeInfo.getData().get(i).getName(); |
697 | int id = gradeInfo.getData().get(i).getId(); | 704 | int id = gradeInfo.getData().get(i).getId(); |
698 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 705 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
699 | for (int j = 0; j < gradeinfoList.size(); j++) { | 706 | for (int j = 0; j < gradeinfoList.size(); j++) { |
700 | String secondname = gradeinfoList.get(j).getName(); | 707 | String secondname = gradeinfoList.get(j).getName(); |
701 | int secondid = gradeinfoList.get(j).getId(); | 708 | int secondid = gradeinfoList.get(j).getId(); |
702 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 709 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
703 | dataBean.setName(secondname); | 710 | dataBean.setName(secondname); |
704 | dataBean.setId(secondid); | 711 | dataBean.setId(secondid); |
705 | gradeInfoLists.add(dataBean); | 712 | gradeInfoLists.add(dataBean); |
706 | } | 713 | } |
707 | 714 | ||
708 | } | 715 | } |
709 | 716 | ||
710 | Message message = Message.obtain(); | 717 | Message message = Message.obtain(); |
711 | message.what = HttpCode.GRADER; | 718 | message.what = HttpCode.GRADER; |
712 | message.obj = gradeInfoLists; | 719 | message.obj = gradeInfoLists; |
713 | handler.sendMessage(message); | 720 | handler.sendMessage(message); |
714 | 721 | ||
715 | 722 | ||
716 | } | 723 | } |
717 | 724 | ||
718 | @Override | 725 | @Override |
719 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 726 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
720 | new CircleDialog.Builder((FragmentActivity) mContext) | 727 | new CircleDialog.Builder((FragmentActivity) mContext) |
721 | .setCanceledOnTouchOutside(false) | 728 | .setCanceledOnTouchOutside(false) |
722 | .setCancelable(false) | 729 | .setCancelable(false) |
723 | .setWidth(0.5f) | 730 | .setWidth(0.5f) |
724 | .configText(new ConfigText() { | 731 | .configText(new ConfigText() { |
725 | @Override | 732 | @Override |
726 | public void onConfig(TextParams params) { | 733 | public void onConfig(TextParams params) { |
727 | params.gravity = Gravity.CENTER; | 734 | params.gravity = Gravity.CENTER; |
728 | params.padding = new int[]{50, 50, 50, 50}; | 735 | params.padding = new int[]{50, 50, 50, 50}; |
729 | } | 736 | } |
730 | }) | 737 | }) |
731 | .setText("当前无网络,请检查网络设置") | 738 | .setText("当前无网络,请检查网络设置") |
732 | .setNegative("继续使用", null) | 739 | .setNegative("继续使用", null) |
733 | .setPositive("设置网络", new View.OnClickListener() { | 740 | .setPositive("设置网络", new View.OnClickListener() { |
734 | @Override | 741 | @Override |
735 | public void onClick(View v) { | 742 | public void onClick(View v) { |
736 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 743 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
737 | mContext.startActivity(intent); | 744 | mContext.startActivity(intent); |
738 | } | 745 | } |
739 | }) | 746 | }) |
740 | .show(); | 747 | .show(); |
741 | } | 748 | } |
742 | }); | 749 | }); |
743 | } | 750 | } |
744 | 751 | ||
745 | /** | 752 | /** |
746 | * 获取学校 | 753 | * 获取学校 |
747 | * | 754 | * |
748 | * @param mContext | 755 | * @param mContext |
749 | * @param regionId | 756 | * @param regionId |
750 | * @param gradeId | 757 | * @param gradeId |
751 | * @param handler | 758 | * @param handler |
752 | */ | 759 | */ |
753 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 760 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
754 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 761 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
755 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 762 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
756 | @Override | 763 | @Override |
757 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 764 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
758 | Log.e("test", "学校" + new String(arg2)); | 765 | Log.e("test", "学校" + new String(arg2)); |
759 | try { | 766 | try { |
760 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 767 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
761 | int status = jsonObject.optInt("status"); | 768 | int status = jsonObject.optInt("status"); |
762 | if (status == 1) { | 769 | if (status == 1) { |
763 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 770 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
764 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 771 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
765 | Message message = Message.obtain(); | 772 | Message message = Message.obtain(); |
766 | message.what = HttpCode.SCHOOL; | 773 | message.what = HttpCode.SCHOOL; |
767 | message.obj = schoolInfoBeanList; | 774 | message.obj = schoolInfoBeanList; |
768 | handler.sendMessage(message); | 775 | handler.sendMessage(message); |
769 | 776 | ||
770 | 777 | ||
771 | } else { | 778 | } else { |
772 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 779 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
773 | 780 | ||
774 | } | 781 | } |
775 | } catch (JSONException e) { | 782 | } catch (JSONException e) { |
776 | e.printStackTrace(); | 783 | e.printStackTrace(); |
777 | } | 784 | } |
778 | 785 | ||
779 | } | 786 | } |
780 | 787 | ||
781 | @Override | 788 | @Override |
782 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 789 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
783 | new CircleDialog.Builder((FragmentActivity) mContext) | 790 | new CircleDialog.Builder((FragmentActivity) mContext) |
784 | .setCanceledOnTouchOutside(false) | 791 | .setCanceledOnTouchOutside(false) |
785 | .setCancelable(false) | 792 | .setCancelable(false) |
786 | .setWidth(0.5f) | 793 | .setWidth(0.5f) |
787 | .configText(new ConfigText() { | 794 | .configText(new ConfigText() { |
788 | @Override | 795 | @Override |
789 | public void onConfig(TextParams params) { | 796 | public void onConfig(TextParams params) { |
790 | params.gravity = Gravity.CENTER; | 797 | params.gravity = Gravity.CENTER; |
791 | params.padding = new int[]{50, 50, 50, 50}; | 798 | params.padding = new int[]{50, 50, 50, 50}; |
792 | } | 799 | } |
793 | }) | 800 | }) |
794 | .setText("当前无网络,请检查网络设置") | 801 | .setText("当前无网络,请检查网络设置") |
795 | .setNegative("继续使用", null) | 802 | .setNegative("继续使用", null) |
796 | .setPositive("设置网络", new View.OnClickListener() { | 803 | .setPositive("设置网络", new View.OnClickListener() { |
797 | @Override | 804 | @Override |
798 | public void onClick(View v) { | 805 | public void onClick(View v) { |
799 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 806 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
800 | mContext.startActivity(intent); | 807 | mContext.startActivity(intent); |
801 | } | 808 | } |
802 | }) | 809 | }) |
803 | .show(); | 810 | .show(); |
804 | } | 811 | } |
805 | }); | 812 | }); |
806 | } | 813 | } |
807 | 814 | ||
808 | 815 | ||
809 | /** | 816 | /** |
810 | * 获取个人信息 | 817 | * 获取个人信息 |
811 | * | 818 | * |
812 | * @param mContext | 819 | * @param mContext |
813 | * @param userId | 820 | * @param userId |
814 | * @param handler | 821 | * @param handler |
815 | */ | 822 | */ |
816 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { | 823 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { |
817 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 824 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
818 | false, true, null); | 825 | false, true, null); |
819 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 826 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
820 | HttpClient.getInstance().setConnectTimeout(5 * 1000); | 827 | HttpClient.getInstance().setConnectTimeout(5 * 1000); |
821 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 828 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
822 | @Override | 829 | @Override |
823 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 830 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
824 | closeProgress(); | 831 | closeProgress(); |
825 | Log.e("test", "个人信息" + new String(arg2)); | 832 | Log.e("test", "个人信息" + new String(arg2)); |
826 | try { | 833 | try { |
827 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 834 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
828 | int status = jsonObject.optInt("status"); | 835 | int status = jsonObject.optInt("status"); |
829 | if (status == 1) { | 836 | if (status == 1) { |
830 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 837 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
831 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 838 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
832 | Message message = Message.obtain(); | 839 | Message message = Message.obtain(); |
833 | message.what = HttpCode.GETINFO; | 840 | message.what = HttpCode.GETINFO; |
834 | message.obj = pesonalInfoBeanList; | 841 | message.obj = pesonalInfoBeanList; |
835 | handler.sendMessage(message); | 842 | handler.sendMessage(message); |
836 | 843 | ||
837 | 844 | ||
838 | } else { | 845 | } else { |
839 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 846 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
840 | 847 | ||
841 | } | 848 | } |
842 | } catch (JSONException e) { | 849 | } catch (JSONException e) { |
843 | e.printStackTrace(); | 850 | e.printStackTrace(); |
844 | } | 851 | } |
845 | 852 | ||
846 | 853 | ||
847 | } | 854 | } |
848 | 855 | ||
849 | @Override | 856 | @Override |
850 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 857 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
851 | closeProgress(); | 858 | closeProgress(); |
852 | new CircleDialog.Builder((FragmentActivity) mContext) | 859 | new CircleDialog.Builder((FragmentActivity) mContext) |
853 | .setCanceledOnTouchOutside(false) | 860 | .setCanceledOnTouchOutside(false) |
854 | .setCancelable(false) | 861 | .setCancelable(false) |
855 | .setWidth(0.5f) | 862 | .setWidth(0.5f) |
856 | .configText(new ConfigText() { | 863 | .configText(new ConfigText() { |
857 | @Override | 864 | @Override |
858 | public void onConfig(TextParams params) { | 865 | public void onConfig(TextParams params) { |
859 | params.gravity = Gravity.CENTER; | 866 | params.gravity = Gravity.CENTER; |
860 | params.padding = new int[]{50, 50, 50, 50}; | 867 | params.padding = new int[]{50, 50, 50, 50}; |
861 | } | 868 | } |
862 | }) | 869 | }) |
863 | .setText("当前无网络,请检查网络设置") | 870 | .setText("当前无网络,请检查网络设置") |
864 | .setNegative("继续使用", null) | 871 | .setNegative("继续使用", null) |
865 | .setPositive("设置网络", new View.OnClickListener() { | 872 | .setPositive("设置网络", new View.OnClickListener() { |
866 | @Override | 873 | @Override |
867 | public void onClick(View v) { | 874 | public void onClick(View v) { |
868 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 875 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
869 | mContext.startActivity(intent); | 876 | mContext.startActivity(intent); |
870 | } | 877 | } |
871 | }) | 878 | }) |
872 | .show(); | 879 | .show(); |
873 | } | 880 | } |
874 | }); | 881 | }); |
875 | } | 882 | } |
876 | 883 | ||
877 | //修改个人信息 | 884 | //修改个人信息 |
878 | public void changepresonalinfo(final Context mContext, Long id, int type | 885 | public void changepresonalinfo(final Context mContext, Long id, int type |
879 | , String name, String birthday, int gradeId, long regionId, | 886 | , String name, String birthday, int gradeId, long regionId, |
880 | Object schoolId, String qq, String gender | 887 | Object schoolId, String qq, String gender |
881 | , String regionName, String devicenumber) throws UnsupportedEncodingException { | 888 | , String regionName, String devicenumber) throws UnsupportedEncodingException { |
882 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 889 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
883 | false, true, null); | 890 | false, true, null); |
884 | RequestParams params = new RequestParams(); | 891 | RequestParams params = new RequestParams(); |
885 | 892 | ||
886 | params.put(HttpKey.USEID, id); | 893 | params.put(HttpKey.USEID, id); |
887 | params.put(HttpKey.TYPE, type); | 894 | params.put(HttpKey.TYPE, type); |
888 | params.put(HttpKey.NAME, name); | 895 | params.put(HttpKey.NAME, name); |
889 | params.put(HttpKey.BIRDays, birthday); | 896 | params.put(HttpKey.BIRDays, birthday); |
890 | params.put(HttpKey.GRADE, gradeId); | 897 | params.put(HttpKey.GRADE, gradeId); |
891 | params.put(HttpKey.REGION, regionId); | 898 | params.put(HttpKey.REGION, regionId); |
892 | params.put(HttpKey.SCHOOL, schoolId); | 899 | params.put(HttpKey.SCHOOL, schoolId); |
893 | params.put(HttpKey.QQ, qq); | 900 | params.put(HttpKey.QQ, qq); |
894 | params.put(HttpKey.GENDER, gender); | 901 | params.put(HttpKey.GENDER, gender); |
895 | params.put(HttpKey.REGIONNAME, regionName); | 902 | params.put(HttpKey.REGIONNAME, regionName); |
896 | params.put(HttpKey.DEVINUMBER, devicenumber); | 903 | params.put(HttpKey.DEVINUMBER, devicenumber); |
897 | Log.e("test", "个人信息" + params); | 904 | Log.e("test", "个人信息" + params); |
898 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 905 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
899 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 906 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
900 | @Override | 907 | @Override |
901 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 908 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
902 | super.onSuccess(statusCode, headers, response); | 909 | super.onSuccess(statusCode, headers, response); |
903 | closeProgress(); | 910 | closeProgress(); |
904 | String status = response.optString("status"); | 911 | String status = response.optString("status"); |
905 | if (status.equals("1")) { | 912 | if (status.equals("1")) { |
906 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 913 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
907 | ((Activity) mContext).finish(); | 914 | ((Activity) mContext).finish(); |
908 | } else { | 915 | } else { |
909 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 916 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
910 | } | 917 | } |
911 | 918 | ||
912 | } | 919 | } |
913 | 920 | ||
914 | @Override | 921 | @Override |
915 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 922 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
916 | super.onFailure(statusCode, headers, throwable, errorResponse); | 923 | super.onFailure(statusCode, headers, throwable, errorResponse); |
917 | closeProgress(); | 924 | closeProgress(); |
918 | Log.e("test", "onFailure" + errorResponse); | 925 | Log.e("test", "onFailure" + errorResponse); |
919 | new CircleDialog.Builder((FragmentActivity) mContext) | 926 | new CircleDialog.Builder((FragmentActivity) mContext) |
920 | .setCanceledOnTouchOutside(false) | 927 | .setCanceledOnTouchOutside(false) |
921 | .setCancelable(false) | 928 | .setCancelable(false) |
922 | .setWidth(0.5f) | 929 | .setWidth(0.5f) |
923 | .configText(new ConfigText() { | 930 | .configText(new ConfigText() { |
924 | @Override | 931 | @Override |
925 | public void onConfig(TextParams params) { | 932 | public void onConfig(TextParams params) { |
926 | params.gravity = Gravity.CENTER; | 933 | params.gravity = Gravity.CENTER; |
927 | params.padding = new int[]{50, 50, 50, 50}; | 934 | params.padding = new int[]{50, 50, 50, 50}; |
928 | } | 935 | } |
929 | }) | 936 | }) |
930 | .setText("当前无网络,请检查网络设置") | 937 | .setText("当前无网络,请检查网络设置") |
931 | .setNegative("继续使用", null) | 938 | .setNegative("继续使用", null) |
932 | .setPositive("设置网络", new View.OnClickListener() { | 939 | .setPositive("设置网络", new View.OnClickListener() { |
933 | @Override | 940 | @Override |
934 | public void onClick(View v) { | 941 | public void onClick(View v) { |
935 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 942 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
936 | mContext.startActivity(intent); | 943 | mContext.startActivity(intent); |
937 | } | 944 | } |
938 | }) | 945 | }) |
939 | .show(); | 946 | .show(); |
940 | } | 947 | } |
941 | 948 | ||
942 | }); | 949 | }); |
943 | } | 950 | } |
944 | 951 | ||
945 | //修改个性签名 | 952 | //修改个性签名 |
946 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 953 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
947 | RequestParams params = new RequestParams(); | 954 | RequestParams params = new RequestParams(); |
948 | params.put("userId", userId); | 955 | params.put("userId", userId); |
949 | params.put("type", type); | 956 | params.put("type", type); |
950 | params.put("signature", signature); | 957 | params.put("signature", signature); |
951 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 958 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
952 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 959 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
953 | @Override | 960 | @Override |
954 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 961 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
955 | try { | 962 | try { |
956 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 963 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
957 | String status = jsonObject.optString("status"); | 964 | String status = jsonObject.optString("status"); |
958 | if (status.equals("1")) { | 965 | if (status.equals("1")) { |
959 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 966 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
960 | } else { | 967 | } else { |
961 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 968 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
962 | } | 969 | } |
963 | } catch (JSONException e) { | 970 | } catch (JSONException e) { |
964 | e.printStackTrace(); | 971 | e.printStackTrace(); |
965 | } | 972 | } |
966 | } | 973 | } |
967 | 974 | ||
968 | @Override | 975 | @Override |
969 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 976 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
970 | Log.e("test", "onFailure" + new String(bytes)); | 977 | Log.e("test", "onFailure" + new String(bytes)); |
971 | new CircleDialog.Builder((FragmentActivity) mContext) | 978 | new CircleDialog.Builder((FragmentActivity) mContext) |
972 | .setCanceledOnTouchOutside(false) | 979 | .setCanceledOnTouchOutside(false) |
973 | .setCancelable(false) | 980 | .setCancelable(false) |
974 | .setWidth(0.5f) | 981 | .setWidth(0.5f) |
975 | .configText(new ConfigText() { | 982 | .configText(new ConfigText() { |
976 | @Override | 983 | @Override |
977 | public void onConfig(TextParams params) { | 984 | public void onConfig(TextParams params) { |
978 | params.gravity = Gravity.CENTER; | 985 | params.gravity = Gravity.CENTER; |
979 | params.padding = new int[]{50, 50, 50, 50}; | 986 | params.padding = new int[]{50, 50, 50, 50}; |
980 | } | 987 | } |
981 | }) | 988 | }) |
982 | .setText("当前无网络,请检查网络设置") | 989 | .setText("当前无网络,请检查网络设置") |
983 | .setNegative("继续使用", null) | 990 | .setNegative("继续使用", null) |
984 | .setPositive("设置网络", new View.OnClickListener() { | 991 | .setPositive("设置网络", new View.OnClickListener() { |
985 | @Override | 992 | @Override |
986 | public void onClick(View v) { | 993 | public void onClick(View v) { |
987 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 994 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
988 | mContext.startActivity(intent); | 995 | mContext.startActivity(intent); |
989 | } | 996 | } |
990 | }) | 997 | }) |
991 | .show(); | 998 | .show(); |
992 | } | 999 | } |
993 | }); | 1000 | }); |
994 | } | 1001 | } |
995 | 1002 | ||
996 | /** | 1003 | /** |
997 | * 获取个性签名 | 1004 | * 获取个性签名 |
998 | * | 1005 | * |
999 | * @param mContext | 1006 | * @param mContext |
1000 | * @param userId | 1007 | * @param userId |
1001 | * @param handler | 1008 | * @param handler |
1002 | */ | 1009 | */ |
1003 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 1010 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
1004 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1011 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1005 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 1012 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
1006 | @Override | 1013 | @Override |
1007 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1014 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1008 | Log.e("test", "个性签名" + new String(arg2)); | 1015 | Log.e("test", "个性签名" + new String(arg2)); |
1009 | try { | 1016 | try { |
1010 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1017 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1011 | int status = jsonObject.optInt("status"); | 1018 | int status = jsonObject.optInt("status"); |
1012 | if (status == 1) { | 1019 | if (status == 1) { |
1013 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 1020 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
1014 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 1021 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
1015 | Message message = Message.obtain(); | 1022 | Message message = Message.obtain(); |
1016 | message.what = HttpCode.SIGN; | 1023 | message.what = HttpCode.SIGN; |
1017 | message.obj = signInfoBeanList; | 1024 | message.obj = signInfoBeanList; |
1018 | handler.sendMessage(message); | 1025 | handler.sendMessage(message); |
1019 | 1026 | ||
1020 | 1027 | ||
1021 | } else if (status == 1000) { | 1028 | } else if (status == 1000) { |
1022 | AlertUtils.showToast(mContext, "您还没有签名哦"); | 1029 | AlertUtils.showToast(mContext, "您还没有签名哦"); |
1023 | 1030 | ||
1024 | } else { | 1031 | } else { |
1025 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1032 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1026 | } | 1033 | } |
1027 | } catch (JSONException e) { | 1034 | } catch (JSONException e) { |
1028 | e.printStackTrace(); | 1035 | e.printStackTrace(); |
1029 | } | 1036 | } |
1030 | 1037 | ||
1031 | 1038 | ||
1032 | } | 1039 | } |
1033 | 1040 | ||
1034 | @Override | 1041 | @Override |
1035 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1042 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1036 | Log.e("test", "失败原因" + arg3); | 1043 | Log.e("test", "失败原因" + arg3); |
1037 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1044 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1038 | } | 1045 | } |
1039 | }); | 1046 | }); |
1040 | } | 1047 | } |
1041 | 1048 | ||
1042 | /** | 1049 | /** |
1043 | * 用户反馈 | 1050 | * 用户反馈 |
1044 | * | 1051 | * |
1045 | * @param mContext | 1052 | * @param mContext |
1046 | * @param userId | 1053 | * @param userId |
1047 | * @param content | 1054 | * @param content |
1048 | * @param contact | 1055 | * @param contact |
1049 | * @param imgs | 1056 | * @param imgs |
1050 | * @param feedtype | 1057 | * @param feedtype |
1051 | * @throws UnsupportedEncodingException | 1058 | * @throws UnsupportedEncodingException |
1052 | */ | 1059 | */ |
1053 | public void feedback(final Context mContext, String userId, String content, | 1060 | public void feedback(final Context mContext, String userId, String content, |
1054 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 1061 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
1055 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 1062 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
1056 | false, true, null); | 1063 | false, true, null); |
1057 | File file = new File(imgs); | 1064 | File file = new File(imgs); |
1058 | if (file.exists() && file.length() > 0) { | 1065 | if (file.exists() && file.length() > 0) { |
1059 | RequestParams params = new RequestParams(); | 1066 | RequestParams params = new RequestParams(); |
1060 | try { | 1067 | try { |
1061 | params.put("userId", userId); | 1068 | params.put("userId", userId); |
1062 | params.put("content", content); | 1069 | params.put("content", content); |
1063 | params.put("contact", contact); | 1070 | params.put("contact", contact); |
1064 | params.put("imgs", file); | 1071 | params.put("imgs", file); |
1065 | params.put("feedtype", feedtype); | 1072 | params.put("feedtype", feedtype); |
1066 | } catch (FileNotFoundException e) { | 1073 | } catch (FileNotFoundException e) { |
1067 | e.printStackTrace(); | 1074 | e.printStackTrace(); |
1068 | } | 1075 | } |
1069 | Log.e("test", "onSuccess" + params); | 1076 | Log.e("test", "onSuccess" + params); |
1070 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 1077 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
1071 | @Override | 1078 | @Override |
1072 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1079 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1073 | closeProgress(); | 1080 | closeProgress(); |
1074 | Log.e("test", "onSuccess" + new String(bytes)); | 1081 | Log.e("test", "onSuccess" + new String(bytes)); |
1075 | try { | 1082 | try { |
1076 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1083 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1077 | String status = jsonObject.optString("status"); | 1084 | String status = jsonObject.optString("status"); |
1078 | if (status.equals("1")) { | 1085 | if (status.equals("1")) { |
1079 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 1086 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
1080 | ((Activity) mContext).finish(); | 1087 | ((Activity) mContext).finish(); |
1081 | } else { | 1088 | } else { |
1082 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1089 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1083 | } | 1090 | } |
1084 | } catch (JSONException e) { | 1091 | } catch (JSONException e) { |
1085 | e.printStackTrace(); | 1092 | e.printStackTrace(); |
1086 | } | 1093 | } |
1087 | } | 1094 | } |
1088 | 1095 | ||
1089 | @Override | 1096 | @Override |
1090 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1097 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1091 | closeProgress(); | 1098 | closeProgress(); |
1092 | Log.e("test", "错误信息" + new String(bytes)); | 1099 | Log.e("test", "错误信息" + new String(bytes)); |
1093 | new CircleDialog.Builder((FragmentActivity) mContext) | 1100 | new CircleDialog.Builder((FragmentActivity) mContext) |
1094 | .setCanceledOnTouchOutside(false) | 1101 | .setCanceledOnTouchOutside(false) |
1095 | .setCancelable(false) | 1102 | .setCancelable(false) |
1096 | .setWidth(0.5f) | 1103 | .setWidth(0.5f) |
1097 | .configText(new ConfigText() { | 1104 | .configText(new ConfigText() { |
1098 | @Override | 1105 | @Override |
1099 | public void onConfig(TextParams params) { | 1106 | public void onConfig(TextParams params) { |
1100 | params.gravity = Gravity.CENTER; | 1107 | params.gravity = Gravity.CENTER; |
1101 | params.padding = new int[]{50, 50, 50, 50}; | 1108 | params.padding = new int[]{50, 50, 50, 50}; |
1102 | } | 1109 | } |
1103 | }) | 1110 | }) |
1104 | .setText("当前无网络,请检查网络设置") | 1111 | .setText("当前无网络,请检查网络设置") |
1105 | .setNegative("继续使用", null) | 1112 | .setNegative("继续使用", null) |
1106 | .setPositive("设置网络", new View.OnClickListener() { | 1113 | .setPositive("设置网络", new View.OnClickListener() { |
1107 | @Override | 1114 | @Override |
1108 | public void onClick(View v) { | 1115 | public void onClick(View v) { |
1109 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1116 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1110 | mContext.startActivity(intent); | 1117 | mContext.startActivity(intent); |
1111 | } | 1118 | } |
1112 | }) | 1119 | }) |
1113 | .show(); | 1120 | .show(); |
1114 | 1121 | ||
1115 | } | 1122 | } |
1116 | }); | 1123 | }); |
1117 | } else { | 1124 | } else { |
1118 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1125 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
1119 | } | 1126 | } |
1120 | } | 1127 | } |
1121 | 1128 | ||
1122 | /** | 1129 | /** |
1123 | * 查询子账户信息 | 1130 | * 查询子账户信息 |
1124 | * | 1131 | * |
1125 | * @param mContext | 1132 | * @param mContext |
1126 | * @param userId | 1133 | * @param userId |
1127 | * @param handler | 1134 | * @param handler |
1128 | */ | 1135 | */ |
1129 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 1136 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
1130 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", | 1137 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", |
1131 | false, true, null); | 1138 | false, true, null); |
1132 | 1139 | ||
1133 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 1140 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
1134 | HttpClient.getInstance().setTimeout(5 * 1000); | 1141 | HttpClient.getInstance().setTimeout(5 * 1000); |
1135 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1142 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1136 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 1143 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
1137 | @Override | 1144 | @Override |
1138 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1145 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1139 | closeProgress(); | 1146 | closeProgress(); |
1140 | Log.e("test", "子账户信息" + new String(arg2)); | 1147 | Log.e("test", "子账户信息" + new String(arg2)); |
1141 | try { | 1148 | try { |
1142 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1149 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1143 | int status = jsonObject.optInt("status"); | 1150 | int status = jsonObject.optInt("status"); |
1144 | if (status == 1) { | 1151 | if (status == 1) { |
1145 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 1152 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
1146 | Log.e("test", "子账户信息" + childsInfo); | 1153 | Log.e("test", "子账户信息" + childsInfo); |
1147 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 1154 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
1148 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 1155 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
1149 | Message msg = Message.obtain(); | 1156 | Message msg = Message.obtain(); |
1150 | msg.what = HttpCode.CHILDS_SUCESS; | 1157 | msg.what = HttpCode.CHILDS_SUCESS; |
1151 | msg.obj = schoolInfoBeanList; | 1158 | msg.obj = schoolInfoBeanList; |
1152 | handler.sendMessage(msg); | 1159 | handler.sendMessage(msg); |
1153 | 1160 | ||
1154 | }else { | 1161 | }else { |
1155 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 1162 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
1156 | 1163 | ||
1157 | } | 1164 | } |
1158 | } catch (JSONException e) { | 1165 | } catch (JSONException e) { |
1159 | e.printStackTrace(); | 1166 | e.printStackTrace(); |
1160 | 1167 | ||
1161 | } | 1168 | } |
1162 | 1169 | ||
1163 | } | 1170 | } |
1164 | 1171 | ||
1165 | @Override | 1172 | @Override |
1166 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1173 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1167 | closeProgress(); | 1174 | closeProgress(); |
1168 | Log.e("test", "错误信息" + new String(arg2)); | 1175 | // Log.e("test", "错误信息" + new String(arg2)); |
1169 | new CircleDialog.Builder((FragmentActivity) mContext) | 1176 | new CircleDialog.Builder((FragmentActivity) mContext) |
1170 | .setCanceledOnTouchOutside(false) | 1177 | .setCanceledOnTouchOutside(false) |
1171 | .setCancelable(false) | 1178 | .setCancelable(false) |
1172 | .setWidth(0.5f) | 1179 | .setWidth(0.5f) |
1173 | .configText(new ConfigText() { | 1180 | .configText(new ConfigText() { |
1174 | @Override | 1181 | @Override |
1175 | public void onConfig(TextParams params) { | 1182 | public void onConfig(TextParams params) { |
1176 | params.gravity = Gravity.CENTER; | 1183 | params.gravity = Gravity.CENTER; |
1177 | params.padding = new int[]{50, 50, 50, 50}; | 1184 | params.padding = new int[]{50, 50, 50, 50}; |
1178 | } | 1185 | } |
1179 | }) | 1186 | }) |
1180 | .setText("当前无网络,请检查网络设置") | 1187 | .setText("当前无网络,请检查网络设置") |
1181 | .setNegative("继续使用", null) | 1188 | .setNegative("继续使用", null) |
1182 | .setPositive("设置网络", new View.OnClickListener() { | 1189 | .setPositive("设置网络", new View.OnClickListener() { |
1183 | @Override | 1190 | @Override |
1184 | public void onClick(View v) { | 1191 | public void onClick(View v) { |
1185 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1192 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1186 | mContext.startActivity(intent); | 1193 | mContext.startActivity(intent); |
1187 | } | 1194 | } |
1188 | }) | 1195 | }) |
1189 | .show(); | 1196 | .show(); |
1190 | } | 1197 | } |
1191 | }); | 1198 | }); |
1192 | 1199 | ||
1193 | } | 1200 | } |
1194 | 1201 | ||
1195 | /** | 1202 | /** |
1196 | * 删除子账户信息 | 1203 | * 删除子账户信息 |
1197 | * | 1204 | * |
1198 | * @param mContext | 1205 | * @param mContext |
1199 | * @param subAccountId | 1206 | * @param subAccountId |
1200 | */ | 1207 | */ |
1201 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 1208 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
1202 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 1209 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
1203 | false, true, null); | 1210 | false, true, null); |
1204 | HttpClient.getInstance().setTimeout(5 * 1000); | 1211 | HttpClient.getInstance().setTimeout(5 * 1000); |
1205 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1212 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1206 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 1213 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
1207 | @Override | 1214 | @Override |
1208 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1215 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1209 | closeProgress(); | 1216 | closeProgress(); |
1210 | Log.e("test", "子账户信息" + new String(arg2)); | 1217 | Log.e("test", "子账户信息" + new String(arg2)); |
1211 | try { | 1218 | try { |
1212 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1219 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1213 | int status = jsonObject.optInt("status"); | 1220 | int status = jsonObject.optInt("status"); |
1214 | if (status == 1) { | 1221 | if (status == 1) { |
1215 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 1222 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
1216 | ((Activity) mContext).finish(); | 1223 | ((Activity) mContext).finish(); |
1217 | } else { | 1224 | } else { |
1218 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 1225 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
1219 | 1226 | ||
1220 | } | 1227 | } |
1221 | } catch (JSONException e) { | 1228 | } catch (JSONException e) { |
1222 | e.printStackTrace(); | 1229 | e.printStackTrace(); |
1223 | } | 1230 | } |
1224 | 1231 | ||
1225 | } | 1232 | } |
1226 | 1233 | ||
1227 | @Override | 1234 | @Override |
1228 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1235 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1229 | closeProgress(); | 1236 | closeProgress(); |
1230 | Log.e("test", "错误信息" + new String(arg2)); | 1237 | Log.e("test", "错误信息" + new String(arg2)); |
1231 | new CircleDialog.Builder((FragmentActivity) mContext) | 1238 | new CircleDialog.Builder((FragmentActivity) mContext) |
1232 | .setCanceledOnTouchOutside(false) | 1239 | .setCanceledOnTouchOutside(false) |
1233 | .setCancelable(false) | 1240 | .setCancelable(false) |
1234 | .setWidth(0.5f) | 1241 | .setWidth(0.5f) |
1235 | .configText(new ConfigText() { | 1242 | .configText(new ConfigText() { |
1236 | @Override | 1243 | @Override |
1237 | public void onConfig(TextParams params) { | 1244 | public void onConfig(TextParams params) { |
1238 | params.gravity = Gravity.CENTER; | 1245 | params.gravity = Gravity.CENTER; |
1239 | params.padding = new int[]{50, 50, 50, 50}; | 1246 | params.padding = new int[]{50, 50, 50, 50}; |
1240 | } | 1247 | } |
1241 | }) | 1248 | }) |
1242 | .setText("当前无网络,请检查网络设置") | 1249 | .setText("当前无网络,请检查网络设置") |
1243 | .setNegative("继续使用", null) | 1250 | .setNegative("继续使用", null) |
1244 | .setPositive("设置网络", new View.OnClickListener() { | 1251 | .setPositive("设置网络", new View.OnClickListener() { |
1245 | @Override | 1252 | @Override |
1246 | public void onClick(View v) { | 1253 | public void onClick(View v) { |
1247 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1254 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1248 | mContext.startActivity(intent); | 1255 | mContext.startActivity(intent); |
1249 | } | 1256 | } |
1250 | }) | 1257 | }) |
1251 | .show(); | 1258 | .show(); |
1252 | } | 1259 | } |
1253 | }); | 1260 | }); |
1254 | 1261 | ||
1255 | } | 1262 | } |
1256 | 1263 | ||
1257 | /** | 1264 | /** |
1258 | * 添加子账户信息 | 1265 | * 添加子账户信息 |
1259 | */ | 1266 | */ |
1260 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 1267 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
1261 | String name, Long grade, Object school, Long region | 1268 | String name, Long grade, Object school, Long region |
1262 | , String deviceNumber, String regionName) { | 1269 | , String deviceNumber, String regionName) { |
1263 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 1270 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
1264 | false, true, null); | 1271 | false, true, null); |
1265 | RequestParams params = new RequestParams(); | 1272 | RequestParams params = new RequestParams(); |
1266 | 1273 | ||
1267 | params.put(HttpKey.PARENTID, parentId); | 1274 | params.put(HttpKey.PARENTID, parentId); |
1268 | params.put(HttpKey.IMAGE, image); | 1275 | params.put(HttpKey.IMAGE, image); |
1269 | params.put(HttpKey.NAME, name); | 1276 | params.put(HttpKey.NAME, name); |
1270 | params.put(HttpKey.GRADE, grade); | 1277 | params.put(HttpKey.GRADE, grade); |
1271 | params.put(HttpKey.SCHOOL, school); | 1278 | params.put(HttpKey.SCHOOL, school); |
1272 | params.put(HttpKey.REGION, region); | 1279 | params.put(HttpKey.REGION, region); |
1273 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 1280 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
1274 | params.put(HttpKey.REGIONNAME, regionName); | 1281 | params.put(HttpKey.REGIONNAME, regionName); |
1275 | 1282 | ||
1276 | Log.e("test", "子账户信息" + params); | 1283 | Log.e("test", "子账户信息" + params); |
1277 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 1284 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
1278 | HttpClient.getInstance().setTimeout(5 * 1000); | 1285 | HttpClient.getInstance().setTimeout(5 * 1000); |
1279 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1286 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1280 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 1287 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
1281 | @Override | 1288 | @Override |
1282 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1289 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1283 | closeProgress(); | 1290 | closeProgress(); |
1284 | 1291 | ||
1285 | Log.e("test", "子账户信息" + new String(arg2)); | 1292 | Log.e("test", "子账户信息" + new String(arg2)); |
1286 | try { | 1293 | try { |
1287 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1294 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1288 | int status = jsonObject.optInt("status"); | 1295 | int status = jsonObject.optInt("status"); |
1289 | if (status == 1) { | 1296 | if (status == 1) { |
1290 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 1297 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
1291 | ((Activity) mContext).finish(); | 1298 | ((Activity) mContext).finish(); |
1292 | } else { | 1299 | } else { |
1293 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 1300 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
1294 | 1301 | ||
1295 | } | 1302 | } |
1296 | } catch (JSONException e) { | 1303 | } catch (JSONException e) { |
1297 | e.printStackTrace(); | 1304 | e.printStackTrace(); |
1298 | } | 1305 | } |
1299 | 1306 | ||
1300 | } | 1307 | } |
1301 | 1308 | ||
1302 | @Override | 1309 | @Override |
1303 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1310 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1304 | closeProgress(); | 1311 | closeProgress(); |
1305 | Log.e("test", "错误信息" + new String(arg2)); | 1312 | Log.e("test", "错误信息" + new String(arg2)); |
1306 | new CircleDialog.Builder((FragmentActivity) mContext) | 1313 | new CircleDialog.Builder((FragmentActivity) mContext) |
1307 | .setCanceledOnTouchOutside(false) | 1314 | .setCanceledOnTouchOutside(false) |
1308 | .setCancelable(false) | 1315 | .setCancelable(false) |
1309 | .setWidth(0.5f) | 1316 | .setWidth(0.5f) |
1310 | .configText(new ConfigText() { | 1317 | .configText(new ConfigText() { |
1311 | @Override | 1318 | @Override |
1312 | public void onConfig(TextParams params) { | 1319 | public void onConfig(TextParams params) { |
1313 | params.gravity = Gravity.CENTER; | 1320 | params.gravity = Gravity.CENTER; |
1314 | params.padding = new int[]{50, 50, 50, 50}; | 1321 | params.padding = new int[]{50, 50, 50, 50}; |
1315 | } | 1322 | } |
1316 | }) | 1323 | }) |
1317 | .setText("当前无网络,请检查网络设置") | 1324 | .setText("当前无网络,请检查网络设置") |
1318 | .setNegative("继续使用", null) | 1325 | .setNegative("继续使用", null) |
1319 | .setPositive("设置网络", new View.OnClickListener() { | 1326 | .setPositive("设置网络", new View.OnClickListener() { |
1320 | @Override | 1327 | @Override |
1321 | public void onClick(View v) { | 1328 | public void onClick(View v) { |
1322 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1329 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1323 | mContext.startActivity(intent); | 1330 | mContext.startActivity(intent); |
1324 | } | 1331 | } |
1325 | }) | 1332 | }) |
1326 | .show(); | 1333 | .show(); |
1327 | } | 1334 | } |
1328 | }); | 1335 | }); |
1329 | 1336 | ||
1330 | } | 1337 | } |
1331 | 1338 | ||
1332 | /** | 1339 | /** |
1333 | * 切换子账户信息 | 1340 | * 切换子账户信息 |
1334 | * | 1341 | * |
1335 | * @param mContext | 1342 | * @param mContext |
1336 | * @param subAccountId | 1343 | * @param subAccountId |
1337 | */ | 1344 | */ |
1338 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 1345 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
1339 | , String deviceNumber, int type) { | 1346 | , String deviceNumber, int type) { |
1340 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1347 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
1341 | false, true, null); | 1348 | false, true, null); |
1342 | HttpClient.getInstance().setTimeout(5 * 1000); | 1349 | HttpClient.getInstance().setTimeout(5 * 1000); |
1343 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1350 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1344 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 1351 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
1345 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 1352 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
1346 | @Override | 1353 | @Override |
1347 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1354 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1348 | closeProgress(); | 1355 | closeProgress(); |
1349 | Log.e("test", "子账户信息" + new String(arg2)); | 1356 | Log.e("test", "子账户信息" + new String(arg2)); |
1350 | try { | 1357 | try { |
1351 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1358 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1352 | int status = jsonObject.optInt("status"); | 1359 | int status = jsonObject.optInt("status"); |
1353 | if (status == 1) { | 1360 | if (status == 1) { |
1354 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 1361 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
1355 | ((Activity) mContext).finish(); | 1362 | ((Activity) mContext).finish(); |
1356 | 1363 | ||
1357 | } else { | 1364 | } else { |
1358 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 1365 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
1359 | 1366 | ||
1360 | } | 1367 | } |
1361 | } catch (JSONException e) { | 1368 | } catch (JSONException e) { |
1362 | e.printStackTrace(); | 1369 | e.printStackTrace(); |
1363 | } | 1370 | } |
1364 | 1371 | ||
1365 | } | 1372 | } |
1366 | 1373 | ||
1367 | @Override | 1374 | @Override |
1368 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1375 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1369 | closeProgress(); | 1376 | closeProgress(); |
1370 | Log.e("test", "错误信息" + new String(arg2)); | 1377 | Log.e("test", "错误信息" + new String(arg2)); |
1371 | new CircleDialog.Builder((FragmentActivity) mContext) | 1378 | new CircleDialog.Builder((FragmentActivity) mContext) |
1372 | .setCanceledOnTouchOutside(false) | 1379 | .setCanceledOnTouchOutside(false) |
1373 | .setCancelable(false) | 1380 | .setCancelable(false) |
1374 | .setWidth(0.5f) | 1381 | .setWidth(0.5f) |
1375 | .configText(new ConfigText() { | 1382 | .configText(new ConfigText() { |
1376 | @Override | 1383 | @Override |
1377 | public void onConfig(TextParams params) { | 1384 | public void onConfig(TextParams params) { |
1378 | params.gravity = Gravity.CENTER; | 1385 | params.gravity = Gravity.CENTER; |
1379 | params.padding = new int[]{50, 50, 50, 50}; | 1386 | params.padding = new int[]{50, 50, 50, 50}; |
1380 | } | 1387 | } |
1381 | }) | 1388 | }) |
1382 | .setText("当前无网络,请检查网络设置") | 1389 | .setText("当前无网络,请检查网络设置") |
1383 | .setNegative("继续使用", null) | 1390 | .setNegative("继续使用", null) |
1384 | .setPositive("设置网络", new View.OnClickListener() { | 1391 | .setPositive("设置网络", new View.OnClickListener() { |
1385 | @Override | 1392 | @Override |
1386 | public void onClick(View v) { | 1393 | public void onClick(View v) { |
1387 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1394 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1388 | mContext.startActivity(intent); | 1395 | mContext.startActivity(intent); |
1389 | } | 1396 | } |
1390 | }) | 1397 | }) |
1391 | .show(); | 1398 | .show(); |
1392 | } | 1399 | } |
1393 | }); | 1400 | }); |
1394 | 1401 | ||
1395 | } | 1402 | } |
1396 | 1403 | ||
1397 | /** | 1404 | /** |
1398 | * 切换主账户信息 | 1405 | * 切换主账户信息 |
1399 | * | 1406 | * |
1400 | * @param mContext | 1407 | * @param mContext |
1401 | * @param type | 1408 | * @param type |
1402 | */ | 1409 | */ |
1403 | public void Accountinfo(final Context mContext, long userId | 1410 | public void Accountinfo(final Context mContext, long userId |
1404 | , String deviceNumber, int type) { | 1411 | , String deviceNumber, int type) { |
1405 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 1412 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
1406 | false, true, null); | 1413 | false, true, null); |
1407 | HttpClient.getInstance().setTimeout(5 * 1000); | 1414 | HttpClient.getInstance().setTimeout(5 * 1000); |
1408 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1415 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1409 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 1416 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
1410 | + "&type=" + type, new AsyncHttpResponseHandler() { | 1417 | + "&type=" + type, new AsyncHttpResponseHandler() { |
1411 | @Override | 1418 | @Override |
1412 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1419 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1413 | closeProgress(); | 1420 | closeProgress(); |
1414 | Log.e("test", "子账户信息" + new String(arg2)); | 1421 | Log.e("test", "子账户信息" + new String(arg2)); |
1415 | try { | 1422 | try { |
1416 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1423 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1417 | int status = jsonObject.optInt("status"); | 1424 | int status = jsonObject.optInt("status"); |
1418 | if (status == 1) { | 1425 | if (status == 1) { |
1419 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1426 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
1420 | ((Activity) mContext).finish(); | 1427 | ((Activity) mContext).finish(); |
1421 | 1428 | ||
1422 | } else { | 1429 | } else { |
1423 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1430 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
1424 | 1431 | ||
1425 | } | 1432 | } |
1426 | } catch (JSONException e) { | 1433 | } catch (JSONException e) { |
1427 | e.printStackTrace(); | 1434 | e.printStackTrace(); |
1428 | } | 1435 | } |
1429 | 1436 | ||
1430 | } | 1437 | } |
1431 | 1438 | ||
1432 | @Override | 1439 | @Override |
1433 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1440 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1434 | closeProgress(); | 1441 | closeProgress(); |
1435 | Log.e("test", "错误信息" + new String(arg2)); | 1442 | Log.e("test", "错误信息" + new String(arg2)); |
1436 | new CircleDialog.Builder((FragmentActivity) mContext) | 1443 | new CircleDialog.Builder((FragmentActivity) mContext) |
1437 | .setCanceledOnTouchOutside(false) | 1444 | .setCanceledOnTouchOutside(false) |
1438 | .setCancelable(false) | 1445 | .setCancelable(false) |
1439 | .setWidth(0.5f) | 1446 | .setWidth(0.5f) |
1440 | .configText(new ConfigText() { | 1447 | .configText(new ConfigText() { |
1441 | @Override | 1448 | @Override |
1442 | public void onConfig(TextParams params) { | 1449 | public void onConfig(TextParams params) { |
1443 | params.gravity = Gravity.CENTER; | 1450 | params.gravity = Gravity.CENTER; |
1444 | params.padding = new int[]{50, 50, 50, 50}; | 1451 | params.padding = new int[]{50, 50, 50, 50}; |
1445 | } | 1452 | } |
1446 | }) | 1453 | }) |
1447 | .setText("当前无网络,请检查网络设置") | 1454 | .setText("当前无网络,请检查网络设置") |
1448 | .setNegative("继续使用", null) | 1455 | .setNegative("继续使用", null) |
1449 | .setPositive("设置网络", new View.OnClickListener() { | 1456 | .setPositive("设置网络", new View.OnClickListener() { |
1450 | @Override | 1457 | @Override |
1451 | public void onClick(View v) { | 1458 | public void onClick(View v) { |
1452 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1459 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1453 | mContext.startActivity(intent); | 1460 | mContext.startActivity(intent); |
1454 | } | 1461 | } |
1455 | }) | 1462 | }) |
1456 | .show(); | 1463 | .show(); |
1457 | } | 1464 | } |
1458 | }); | 1465 | }); |
1459 | 1466 | ||
1460 | } | 1467 | } |
1461 | 1468 | ||
1462 | /** | 1469 | /** |
1463 | * 头像拍张 | 1470 | * 头像拍张 |
1464 | * | 1471 | * |
1465 | * @param mContext | 1472 | * @param mContext |
1466 | * @param userId | 1473 | * @param userId |
1467 | * @param img | 1474 | * @param img |
1468 | * @throws UnsupportedEncodingException | 1475 | * @throws UnsupportedEncodingException |
1469 | */ | 1476 | */ |
1470 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 1477 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
1471 | File file = new File(img); | 1478 | File file = new File(img); |
1472 | if (file.exists() && file.length() > 0) { | 1479 | if (file.exists() && file.length() > 0) { |
1473 | RequestParams params = new RequestParams(); | 1480 | RequestParams params = new RequestParams(); |
1474 | try { | 1481 | try { |
1475 | params.put("userId", userId); | 1482 | params.put("userId", userId); |
1476 | params.put("type", type); | 1483 | params.put("type", type); |
1477 | params.put("img", file); | 1484 | params.put("img", file); |
1478 | } catch (FileNotFoundException e) { | 1485 | } catch (FileNotFoundException e) { |
1479 | e.printStackTrace(); | 1486 | e.printStackTrace(); |
1480 | } | 1487 | } |
1481 | Log.e("test", "params" + params); | 1488 | Log.e("test", "params" + params); |
1482 | HttpClient.getInstance().setTimeout(5 * 1000); | 1489 | HttpClient.getInstance().setTimeout(5 * 1000); |
1483 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1490 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
1484 | @Override | 1491 | @Override |
1485 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1492 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1486 | Log.e("test", "onSuccess" + new String(bytes)); | 1493 | Log.e("test", "onSuccess" + new String(bytes)); |
1487 | try { | 1494 | try { |
1488 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1495 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1489 | String status = jsonObject.optString("status"); | 1496 | String status = jsonObject.optString("status"); |
1490 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1497 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
1491 | String imagUrl = jsonObject1.optString("imgUrl"); | 1498 | String imagUrl = jsonObject1.optString("imgUrl"); |
1492 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1499 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
1493 | if (status.equals("1")) { | 1500 | if (status.equals("1")) { |
1494 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1501 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1495 | } else { | 1502 | } else { |
1496 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1503 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1497 | } | 1504 | } |
1498 | } catch (JSONException e) { | 1505 | } catch (JSONException e) { |
1499 | e.printStackTrace(); | 1506 | e.printStackTrace(); |
1500 | } | 1507 | } |
1501 | } | 1508 | } |
1502 | 1509 | ||
1503 | @Override | 1510 | @Override |
1504 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1511 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1505 | closeProgress(); | 1512 | closeProgress(); |
1506 | Log.e("test", "错误信息" + new String(bytes)); | 1513 | Log.e("test", "错误信息" + new String(bytes)); |
1507 | new CircleDialog.Builder((FragmentActivity) mContext) | 1514 | new CircleDialog.Builder((FragmentActivity) mContext) |
1508 | .setCanceledOnTouchOutside(false) | 1515 | .setCanceledOnTouchOutside(false) |
1509 | .setCancelable(false) | 1516 | .setCancelable(false) |
1510 | .setWidth(0.5f) | 1517 | .setWidth(0.5f) |
1511 | .configText(new ConfigText() { | 1518 | .configText(new ConfigText() { |
1512 | @Override | 1519 | @Override |
1513 | public void onConfig(TextParams params) { | 1520 | public void onConfig(TextParams params) { |
1514 | params.gravity = Gravity.CENTER; | 1521 | params.gravity = Gravity.CENTER; |
1515 | params.padding = new int[]{50, 50, 50, 50}; | 1522 | params.padding = new int[]{50, 50, 50, 50}; |
1516 | } | 1523 | } |
1517 | }) | 1524 | }) |
1518 | .setText("当前无网络,请检查网络设置") | 1525 | .setText("当前无网络,请检查网络设置") |
1519 | .setNegative("继续使用", null) | 1526 | .setNegative("继续使用", null) |
1520 | .setPositive("设置网络", new View.OnClickListener() { | 1527 | .setPositive("设置网络", new View.OnClickListener() { |
1521 | @Override | 1528 | @Override |
1522 | public void onClick(View v) { | 1529 | public void onClick(View v) { |
1523 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1530 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1524 | mContext.startActivity(intent); | 1531 | mContext.startActivity(intent); |
1525 | } | 1532 | } |
1526 | }) | 1533 | }) |
1527 | .show(); | 1534 | .show(); |
1528 | 1535 | ||
1529 | } | 1536 | } |
1530 | }); | 1537 | }); |
1531 | } else { | 1538 | } else { |
1532 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1539 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
1533 | } | 1540 | } |
1534 | } | 1541 | } |
1535 | /** | 1542 | /** |
1536 | * 头像默认 | 1543 | * 头像默认 |
1537 | * | 1544 | * |
1538 | * @param mContext | 1545 | * @param mContext |
1539 | * @param userId | 1546 | * @param userId |
1540 | * @param | 1547 | * @param |
1541 | * @throws UnsupportedEncodingException | 1548 | * @throws UnsupportedEncodingException |
1542 | */ | 1549 | */ |
1543 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { | 1550 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { |
1544 | RequestParams params = new RequestParams(); | 1551 | RequestParams params = new RequestParams(); |
1545 | params.put("userId", userId); | 1552 | params.put("userId", userId); |
1546 | params.put("type", type); | 1553 | params.put("type", type); |
1547 | params.put("defaultImg", defaultImg); | 1554 | params.put("defaultImg", defaultImg); |
1548 | Log.e("test", "params" + params); | 1555 | Log.e("test", "params" + params); |
1549 | HttpClient.getInstance().setTimeout(5 * 1000); | 1556 | HttpClient.getInstance().setTimeout(5 * 1000); |
1550 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | 1557 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { |
1551 | @Override | 1558 | @Override |
1552 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1559 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1553 | Log.e("test", "onSuccess" + new String(bytes)); | 1560 | Log.e("test", "onSuccess" + new String(bytes)); |
1554 | try { | 1561 | try { |
1555 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1562 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1556 | String status = jsonObject.optString("status"); | 1563 | String status = jsonObject.optString("status"); |
1557 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1564 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); |
1558 | String imagUrl = jsonObject1.optString("imgUrl"); | 1565 | String imagUrl = jsonObject1.optString("imgUrl"); |
1559 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1566 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); |
1560 | if (status.equals("1")) { | 1567 | if (status.equals("1")) { |
1561 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1568 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1562 | } else { | 1569 | } else { |
1563 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1570 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1564 | } | 1571 | } |
1565 | } catch (JSONException e) { | 1572 | } catch (JSONException e) { |
1566 | e.printStackTrace(); | 1573 | e.printStackTrace(); |
1567 | } | 1574 | } |
1568 | } | 1575 | } |
1569 | 1576 | ||
1570 | @Override | 1577 | @Override |
1571 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1578 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1572 | closeProgress(); | 1579 | closeProgress(); |
1573 | Log.e("test", "错误信息" + new String(bytes)); | 1580 | Log.e("test", "错误信息" + new String(bytes)); |
1574 | new CircleDialog.Builder((FragmentActivity) mContext) | 1581 | new CircleDialog.Builder((FragmentActivity) mContext) |
1575 | .setCanceledOnTouchOutside(false) | 1582 | .setCanceledOnTouchOutside(false) |
1576 | .setCancelable(false) | 1583 | .setCancelable(false) |
1577 | .setWidth(0.5f) | 1584 | .setWidth(0.5f) |
1578 | .configText(new ConfigText() { | 1585 | .configText(new ConfigText() { |
1579 | @Override | 1586 | @Override |
1580 | public void onConfig(TextParams params) { | 1587 | public void onConfig(TextParams params) { |
1581 | params.gravity = Gravity.CENTER; | 1588 | params.gravity = Gravity.CENTER; |
1582 | params.padding = new int[]{50, 50, 50, 50}; | 1589 | params.padding = new int[]{50, 50, 50, 50}; |
1583 | } | 1590 | } |
1584 | }) | 1591 | }) |
1585 | .setText("当前无网络,请检查网络设置") | 1592 | .setText("当前无网络,请检查网络设置") |
1586 | .setNegative("继续使用", null) | 1593 | .setNegative("继续使用", null) |
1587 | .setPositive("设置网络", new View.OnClickListener() { | 1594 | .setPositive("设置网络", new View.OnClickListener() { |
1588 | @Override | 1595 | @Override |
1589 | public void onClick(View v) { | 1596 | public void onClick(View v) { |
1590 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1597 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1591 | mContext.startActivity(intent); | 1598 | mContext.startActivity(intent); |
1592 | } | 1599 | } |
1593 | }) | 1600 | }) |
1594 | .show(); | 1601 | .show(); |
1595 | 1602 | ||
1596 | } | 1603 | } |
1597 | }); | 1604 | }); |
1598 | } | 1605 | } |
1599 | 1606 | ||
1600 | 1607 | ||
1601 | /** | 1608 | /** |
1602 | * 系统升级 | 1609 | * 系统升级 |
1603 | * | 1610 | * |
1604 | * @param mContext | 1611 | * @param mContext |
1605 | * @param pid appName | 1612 | * @param pid appName |
1606 | */ | 1613 | */ |
1607 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1614 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
1608 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1615 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
1609 | false, true, null); | 1616 | false, true, null); |
1610 | HttpClient.getInstance().setTimeout(5 * 1000); | 1617 | HttpClient.getInstance().setTimeout(5 * 1000); |
1611 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1618 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1612 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1619 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
1613 | @Override | 1620 | @Override |
1614 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1621 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1615 | closeProgress(); | 1622 | closeProgress(); |
1616 | Log.e("test", "版本升级信息" + new String(arg2)); | 1623 | Log.e("test", "版本升级信息" + new String(arg2)); |
1617 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | 1624 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 |
1618 | Message msg = Message.obtain(); | 1625 | Message msg = Message.obtain(); |
1619 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1626 | msg.what = HttpCode.APPUPDATE_SUCESS; |
1620 | msg.obj = appVersion; | 1627 | msg.obj = appVersion; |
1621 | handler.sendMessage(msg); | 1628 | handler.sendMessage(msg); |
1622 | 1629 | ||
1623 | 1630 | ||
1624 | } | 1631 | } |
1625 | 1632 | ||
1626 | @Override | 1633 | @Override |
1627 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1634 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1628 | closeProgress(); | 1635 | closeProgress(); |
1629 | Log.e("test", "错误信息" + new String(arg2)); | 1636 | Log.e("test", "错误信息" + new String(arg2)); |
1630 | new CircleDialog.Builder((FragmentActivity) mContext) | 1637 | new CircleDialog.Builder((FragmentActivity) mContext) |
1631 | .setCanceledOnTouchOutside(false) | 1638 | .setCanceledOnTouchOutside(false) |
1632 | .setCancelable(false) | 1639 | .setCancelable(false) |
1633 | .setWidth(0.5f) | 1640 | .setWidth(0.5f) |
1634 | .configText(new ConfigText() { | 1641 | .configText(new ConfigText() { |
1635 | @Override | 1642 | @Override |
1636 | public void onConfig(TextParams params) { | 1643 | public void onConfig(TextParams params) { |
1637 | params.gravity = Gravity.CENTER; | 1644 | params.gravity = Gravity.CENTER; |
1638 | params.padding = new int[]{50, 50, 50, 50}; | 1645 | params.padding = new int[]{50, 50, 50, 50}; |
1639 | } | 1646 | } |
1640 | }) | 1647 | }) |
1641 | .setText("当前无网络,请检查网络设置") | 1648 | .setText("当前无网络,请检查网络设置") |
1642 | .setNegative("继续使用", null) | 1649 | .setNegative("继续使用", null) |
1643 | .setPositive("设置网络", new View.OnClickListener() { | 1650 | .setPositive("设置网络", new View.OnClickListener() { |
1644 | @Override | 1651 | @Override |
1645 | public void onClick(View v) { | 1652 | public void onClick(View v) { |
1646 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1653 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1647 | mContext.startActivity(intent); | 1654 | mContext.startActivity(intent); |
1648 | } | 1655 | } |
1649 | }) | 1656 | }) |
1650 | .show(); | 1657 | .show(); |
1651 | } | 1658 | } |
1652 | }); | 1659 | }); |
1653 | 1660 | ||
1654 | } | 1661 | } |
1655 | 1662 | ||
1656 | 1663 | ||
1657 | ///省级接口 | 1664 | ///省级接口 |
1658 | public void provices(final Context mContext, final Handler handler) { | 1665 | public void provices(final Context mContext, final Handler handler) { |
1659 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1666 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1660 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1667 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
1661 | @Override | 1668 | @Override |
1662 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1669 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1663 | Log.e("test", "省" + new String(arg2)); | 1670 | Log.e("test", "省" + new String(arg2)); |
1664 | try { | 1671 | try { |
1665 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1672 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1666 | int status = jsonObject.optInt("status"); | 1673 | int status = jsonObject.optInt("status"); |
1667 | if (status == 100) { | 1674 | if (status == 100) { |
1668 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1675 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
1669 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1676 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
1670 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1677 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
1671 | Message message = Message.obtain(); | 1678 | Message message = Message.obtain(); |
1672 | message.what = HttpCode.PROVICES; | 1679 | message.what = HttpCode.PROVICES; |
1673 | message.obj = provincesBeanList; | 1680 | message.obj = provincesBeanList; |
1674 | handler.sendMessage(message); | 1681 | handler.sendMessage(message); |
1675 | 1682 | ||
1676 | 1683 | ||
1677 | } else { | 1684 | } else { |
1678 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1685 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1679 | 1686 | ||
1680 | } | 1687 | } |
1681 | } catch (JSONException e) { | 1688 | } catch (JSONException e) { |
1682 | e.printStackTrace(); | 1689 | e.printStackTrace(); |
1683 | } | 1690 | } |
1684 | 1691 | ||
1685 | 1692 | ||
1686 | } | 1693 | } |
1687 | 1694 | ||
1688 | @Override | 1695 | @Override |
1689 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1696 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1690 | new CircleDialog.Builder((FragmentActivity) mContext) | 1697 | new CircleDialog.Builder((FragmentActivity) mContext) |
1691 | .setCanceledOnTouchOutside(false) | 1698 | .setCanceledOnTouchOutside(false) |
1692 | .setCancelable(false) | 1699 | .setCancelable(false) |
1693 | .setWidth(0.5f) | 1700 | .setWidth(0.5f) |
1694 | .configText(new ConfigText() { | 1701 | .configText(new ConfigText() { |
1695 | @Override | 1702 | @Override |
1696 | public void onConfig(TextParams params) { | 1703 | public void onConfig(TextParams params) { |
1697 | params.gravity = Gravity.CENTER; | 1704 | params.gravity = Gravity.CENTER; |
1698 | params.padding = new int[]{50, 50, 50, 50}; | 1705 | params.padding = new int[]{50, 50, 50, 50}; |
1699 | } | 1706 | } |
1700 | }) | 1707 | }) |
1701 | .setText("当前无网络,请检查网络设置") | 1708 | .setText("当前无网络,请检查网络设置") |
1702 | .setNegative("继续使用", null) | 1709 | .setNegative("继续使用", null) |
1703 | .setPositive("设置网络", new View.OnClickListener() { | 1710 | .setPositive("设置网络", new View.OnClickListener() { |
1704 | @Override | 1711 | @Override |
1705 | public void onClick(View v) { | 1712 | public void onClick(View v) { |
1706 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1713 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1707 | mContext.startActivity(intent); | 1714 | mContext.startActivity(intent); |
1708 | } | 1715 | } |
1709 | }) | 1716 | }) |
1710 | .show(); | 1717 | .show(); |
1711 | } | 1718 | } |
1712 | }); | 1719 | }); |
1713 | } | 1720 | } |
1714 | 1721 | ||
1715 | //市级接口 | 1722 | //市级接口 |
1716 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1723 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
1717 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1724 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1718 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1725 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
1719 | @Override | 1726 | @Override |
1720 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1727 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1721 | Log.e("test", "市" + new String(arg2)); | 1728 | Log.e("test", "市" + new String(arg2)); |
1722 | try { | 1729 | try { |
1723 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1730 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1724 | int status = jsonObject.optInt("status"); | 1731 | int status = jsonObject.optInt("status"); |
1725 | if (status == 100) { | 1732 | if (status == 100) { |
1726 | Gson gson = new Gson(); | 1733 | Gson gson = new Gson(); |
1727 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1734 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
1728 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1735 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
1729 | Message message = Message.obtain(); | 1736 | Message message = Message.obtain(); |
1730 | message.what = HttpCode.CITYS; | 1737 | message.what = HttpCode.CITYS; |
1731 | message.obj = cityInfoBeanList; | 1738 | message.obj = cityInfoBeanList; |
1732 | handler.sendMessage(message); | 1739 | handler.sendMessage(message); |
1733 | 1740 | ||
1734 | } else { | 1741 | } else { |
1735 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1742 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1736 | 1743 | ||
1737 | } | 1744 | } |
1738 | } catch (JSONException e) { | 1745 | } catch (JSONException e) { |
1739 | e.printStackTrace(); | 1746 | e.printStackTrace(); |
1740 | } | 1747 | } |
1741 | 1748 | ||
1742 | 1749 | ||
1743 | } | 1750 | } |
1744 | 1751 | ||
1745 | @Override | 1752 | @Override |
1746 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1753 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1747 | new CircleDialog.Builder((FragmentActivity) mContext) | 1754 | new CircleDialog.Builder((FragmentActivity) mContext) |
1748 | .setCanceledOnTouchOutside(false) | 1755 | .setCanceledOnTouchOutside(false) |
1749 | .setCancelable(false) | 1756 | .setCancelable(false) |
1750 | .setWidth(0.5f) | 1757 | .setWidth(0.5f) |
1751 | .configText(new ConfigText() { | 1758 | .configText(new ConfigText() { |
1752 | @Override | 1759 | @Override |
1753 | public void onConfig(TextParams params) { | 1760 | public void onConfig(TextParams params) { |
1754 | params.gravity = Gravity.CENTER; | 1761 | params.gravity = Gravity.CENTER; |
1755 | params.padding = new int[]{50, 50, 50, 50}; | 1762 | params.padding = new int[]{50, 50, 50, 50}; |
1756 | } | 1763 | } |
1757 | }) | 1764 | }) |
1758 | .setText("当前无网络,请检查网络设置") | 1765 | .setText("当前无网络,请检查网络设置") |
1759 | .setNegative("继续使用", null) | 1766 | .setNegative("继续使用", null) |
1760 | .setPositive("设置网络", new View.OnClickListener() { | 1767 | .setPositive("设置网络", new View.OnClickListener() { |
1761 | @Override | 1768 | @Override |
1762 | public void onClick(View v) { | 1769 | public void onClick(View v) { |
1763 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1770 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1764 | mContext.startActivity(intent); | 1771 | mContext.startActivity(intent); |
1765 | } | 1772 | } |
1766 | }) | 1773 | }) |
1767 | .show(); | 1774 | .show(); |
1768 | } | 1775 | } |
1769 | }); | 1776 | }); |
1770 | } | 1777 | } |
1771 | 1778 | ||
1772 | //区县级接口 | 1779 | //区县级接口 |
1773 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1780 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
1774 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1781 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1775 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1782 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
1776 | @Override | 1783 | @Override |
1777 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1784 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1778 | Log.e("test", "区" + new String(arg2)); | 1785 | Log.e("test", "区" + new String(arg2)); |
1779 | try { | 1786 | try { |
1780 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1787 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1781 | int status = jsonObject.optInt("status"); | 1788 | int status = jsonObject.optInt("status"); |
1782 | if (status == 100) { | 1789 | if (status == 100) { |
1783 | Gson gson = new Gson(); | 1790 | Gson gson = new Gson(); |
1784 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1791 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
1785 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1792 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
1786 | Message message = Message.obtain(); | 1793 | Message message = Message.obtain(); |
1787 | message.what = HttpCode.COUNTRY; | 1794 | message.what = HttpCode.COUNTRY; |
1788 | message.obj = countyInfoInfoBeanList; | 1795 | message.obj = countyInfoInfoBeanList; |
1789 | handler.sendMessage(message); | 1796 | handler.sendMessage(message); |
1790 | } else { | 1797 | } else { |
1791 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1798 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1792 | 1799 | ||
1793 | } | 1800 | } |
1794 | } catch (JSONException e) { | 1801 | } catch (JSONException e) { |
1795 | e.printStackTrace(); | 1802 | e.printStackTrace(); |
1796 | } | 1803 | } |
1797 | 1804 | ||
1798 | 1805 | ||
1799 | } | 1806 | } |
1800 | 1807 | ||
1801 | @Override | 1808 | @Override |
1802 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1809 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1803 | new CircleDialog.Builder((FragmentActivity) mContext) | 1810 | new CircleDialog.Builder((FragmentActivity) mContext) |
1804 | .setCanceledOnTouchOutside(false) | 1811 | .setCanceledOnTouchOutside(false) |
1805 | .setCancelable(false) | 1812 | .setCancelable(false) |
1806 | .setWidth(0.5f) | 1813 | .setWidth(0.5f) |
1807 | .configText(new ConfigText() { | 1814 | .configText(new ConfigText() { |
1808 | @Override | 1815 | @Override |
1809 | public void onConfig(TextParams params) { | 1816 | public void onConfig(TextParams params) { |
1810 | params.gravity = Gravity.CENTER; | 1817 | params.gravity = Gravity.CENTER; |
1811 | params.padding = new int[]{50, 50, 50, 50}; | 1818 | params.padding = new int[]{50, 50, 50, 50}; |
1812 | } | 1819 | } |
1813 | }) | 1820 | }) |
1814 | .setText("当前无网络,请检查网络设置") | 1821 | .setText("当前无网络,请检查网络设置") |
1815 | .setNegative("继续使用", null) | 1822 | .setNegative("继续使用", null) |
1816 | .setPositive("设置网络", new View.OnClickListener() { | 1823 | .setPositive("设置网络", new View.OnClickListener() { |
1817 | @Override | 1824 | @Override |
1818 | public void onClick(View v) { | 1825 | public void onClick(View v) { |
1819 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1826 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1820 | mContext.startActivity(intent); | 1827 | mContext.startActivity(intent); |
1821 | } | 1828 | } |
1822 | }) | 1829 | }) |
1823 | .show(); | 1830 | .show(); |
1824 | } | 1831 | } |
1825 | }); | 1832 | }); |
1826 | } | 1833 | } |
1827 | 1834 | ||
1828 | 1835 | ||
1829 | private void closeProgress() { | 1836 | private void closeProgress() { |
1830 | try { | 1837 | try { |
1831 | if (mProgress != null) { | 1838 | if (mProgress != null) { |
1832 | mProgress.dismiss(); | 1839 | mProgress.dismiss(); |
1833 | mProgress = null; | 1840 | mProgress = null; |
1834 | } | 1841 | } |
1835 | } catch (Exception e) { | 1842 | } catch (Exception e) { |
1836 | e.printStackTrace(); | 1843 | e.printStackTrace(); |
1837 | } | 1844 | } |
1838 | } | 1845 | } |
1839 | 1846 | ||
1840 | } | 1847 | } |
1841 | 1848 |
PersonalCenter/app/src/main/res/drawable/black_btn_default.9.png
946 Bytes
PersonalCenter/app/src/main/res/drawable/sorry.png
2.06 KB