Commit 522aba51246c4e675328f8b29e345eb60a01e831
1 parent
1671ec5d6d
Exists in
master
修复个人中心问题
Showing
28 changed files
with
390 additions
and
223 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 | String subAccountId = null; | 72 | String subAccountId = null; |
73 | List<ChildsInfo.DataBean> childList = new ArrayList<>(); | 73 | List<ChildsInfo.DataBean> childList = new ArrayList<>(); |
74 | List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>) msg.obj; | 74 | List<ChildsInfo.DataBean> list = (List<ChildsInfo.DataBean>) msg.obj; |
75 | for (int i = 0; i < list.size(); i++) { | 75 | for (int i = 0; i < list.size(); i++) { |
76 | int type = list.get(i).getType(); | 76 | int type = list.get(i).getType(); |
77 | if (type == 1) { | 77 | if (type == 1) { |
78 | name = list.get(i).getName(); | 78 | name = list.get(i).getName(); |
79 | grade = list.get(i).getGrade(); | 79 | grade = list.get(i).getGrade(); |
80 | school = list.get(i).getSchool(); | 80 | school = list.get(i).getSchool(); |
81 | addr = list.get(i).getRegion(); | 81 | addr = list.get(i).getRegion(); |
82 | phote = list.get(i).getImage(); | 82 | phote = list.get(i).getImage(); |
83 | subAccountId = list.get(i).getSubAccountId(); | 83 | subAccountId = list.get(i).getSubAccountId(); |
84 | } else if (type == 2) { | 84 | } else if (type == 2) { |
85 | childList.add(list.get(i)); | 85 | childList.add(list.get(i)); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | tv_username.setText(name); | 88 | tv_username.setText(name); |
89 | tv_grade.setText(grade); | 89 | tv_grade.setText(grade); |
90 | tv_school.setText(school); | 90 | tv_school.setText(school); |
91 | tv_adress.setText(addr); | 91 | tv_adress.setText(addr); |
92 | mSimpleDraweeView.setImageURI(phote); | 92 | mSimpleDraweeView.setImageURI(phote); |
93 | data.clear(); | 93 | data.clear(); |
94 | data.addAll(childList); | 94 | data.addAll(childList); |
95 | childsAdapter.notifyDataSetChanged(); | 95 | childsAdapter.notifyDataSetChanged(); |
96 | } | 96 | } |
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | }; | 100 | }; |
101 | 101 | ||
102 | @Override | 102 | @Override |
103 | protected void onCreate(Bundle savedInstanceState) { | 103 | protected void onCreate(Bundle savedInstanceState) { |
104 | super.onCreate(savedInstanceState); | 104 | super.onCreate(savedInstanceState); |
105 | setContentView(R.layout.activity_account_management); | 105 | setContentView(R.layout.activity_account_management); |
106 | SysApplication.getInstance().addActivity(this); | ||
107 | |||
108 | initView(); | 106 | initView(); |
109 | initData(); | 107 | initData(); |
110 | initLister(); | 108 | initLister(); |
111 | } | 109 | } |
112 | 110 | ||
113 | private void initView() { | 111 | private void initView() { |
114 | changbangding = (TextView) findViewById(R.id.changBangding); | 112 | changbangding = (TextView) findViewById(R.id.changBangding); |
115 | changpassword = (TextView) findViewById(R.id.changpassword); | 113 | changpassword = (TextView) findViewById(R.id.changpassword); |
116 | usernames = (TextView) findViewById(R.id.cunt_username); | 114 | usernames = (TextView) findViewById(R.id.cunt_username); |
117 | tv_username = (TextView) findViewById(R.id.tv_account_name); | 115 | tv_username = (TextView) findViewById(R.id.tv_account_name); |
118 | tv_grade = (TextView) findViewById(R.id.tv_account_grade); | 116 | tv_grade = (TextView) findViewById(R.id.tv_account_grade); |
119 | tv_school = (TextView) findViewById(R.id.tv_account_school); | 117 | tv_school = (TextView) findViewById(R.id.tv_account_school); |
120 | tv_adress = (TextView) findViewById(R.id.tv_account_adress); | 118 | tv_adress = (TextView) findViewById(R.id.tv_account_adress); |
121 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head); | 119 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.tv_account_head); |
122 | iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong); | 120 | iv_useing = (ImageView) findViewById(R.id.iv_shiyongzhong); |
123 | cancel = (ImageView) findViewById(R.id.cancel); | 121 | cancel = (ImageView) findViewById(R.id.cancel); |
124 | ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd); | 122 | ll_zhu_backgrangd = (LinearLayout) findViewById(R.id.ll_zhu_backgrangd); |
125 | tv_changzhu = (TextView) findViewById(R.id.change_zhu_account); | 123 | tv_changzhu = (TextView) findViewById(R.id.change_zhu_account); |
126 | listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 124 | listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
127 | } | 125 | } |
128 | 126 | ||
129 | private void initData() { | 127 | private void initData() { |
130 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); | 128 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); |
131 | String account = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); | 129 | String account = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
132 | usernames.setText(cunt_username); | 130 | usernames.setText(cunt_username); |
133 | 131 | ||
134 | if (account.equals("1")) { | 132 | if (account.equals("1")) { |
135 | tv_changzhu.setText("使用中"); | 133 | tv_changzhu.setText("使用中"); |
136 | tv_changzhu.setEnabled(false); | 134 | tv_changzhu.setEnabled(false); |
137 | iv_useing.setVisibility(View.VISIBLE); | 135 | iv_useing.setVisibility(View.VISIBLE); |
138 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); | 136 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_blue_bg); |
139 | } else { | 137 | } else { |
140 | 138 | ||
141 | tv_changzhu.setText("切换主账户"); | 139 | tv_changzhu.setText("切换主账户"); |
142 | tv_changzhu.setEnabled(true); | 140 | tv_changzhu.setEnabled(true); |
143 | iv_useing.setVisibility(View.GONE); | 141 | iv_useing.setVisibility(View.GONE); |
144 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg); | 142 | ll_zhu_backgrangd.setBackgroundResource(R.drawable.corcle_black_bg); |
145 | } | 143 | } |
146 | 144 | ||
147 | 145 | ||
148 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 146 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
149 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); | 147 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
150 | listview.setLayoutManager(linearLayoutManager); | 148 | listview.setLayoutManager(linearLayoutManager); |
151 | childsAdapter = new AccountChildsAdapter(data, this); | 149 | childsAdapter = new AccountChildsAdapter(data, this); |
152 | listview.addItemDecoration(new RecyclerViewSpaceItem(10)); | 150 | listview.addItemDecoration(new RecyclerViewSpaceItem(10)); |
153 | listview.setAdapter(childsAdapter); | 151 | listview.setAdapter(childsAdapter); |
154 | childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() { | 152 | childsAdapter.setOnItemClickListener(new AccountChildsAdapter.OnItemClickListener() { |
155 | @Override | 153 | @Override |
156 | public void onItemClick(View view, int position) { | 154 | public void onItemClick(View view, int position) { |
157 | 155 | ||
158 | AlertUtils.showToast(AccountManagementActivity.this, "你点击了" + data.get(position)); | 156 | AlertUtils.showToast(AccountManagementActivity.this, "你点击了" + data.get(position)); |
159 | } | 157 | } |
160 | }); | 158 | }); |
161 | 159 | ||
162 | } | 160 | } |
163 | 161 | ||
164 | 162 | ||
165 | private void initLister() { | 163 | private void initLister() { |
166 | changbangding.setOnClickListener(this); | 164 | changbangding.setOnClickListener(this); |
167 | changpassword.setOnClickListener(this); | 165 | changpassword.setOnClickListener(this); |
168 | cancel.setOnClickListener(this); | 166 | cancel.setOnClickListener(this); |
169 | tv_changzhu.setOnClickListener(this); | 167 | tv_changzhu.setOnClickListener(this); |
170 | 168 | ||
171 | 169 | ||
172 | } | 170 | } |
173 | 171 | ||
174 | @Override | 172 | @Override |
175 | public void onClick(View v) { | 173 | public void onClick(View v) { |
176 | switch (v.getId()) { | 174 | switch (v.getId()) { |
177 | case R.id.changBangding: | 175 | case R.id.changBangding: |
178 | Content.authcodeflag = 1; | 176 | Content.authcodeflag = 1; |
179 | Intent changebangding = new Intent(); | 177 | Intent changebangding = new Intent(); |
180 | changebangding.setClass(AccountManagementActivity.this, ElectronicCardValidationActivity.class); | 178 | changebangding.setClass(AccountManagementActivity.this, ElectronicCardValidationActivity.class); |
181 | startActivity(changebangding); | 179 | startActivity(changebangding); |
182 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 180 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
183 | break; | 181 | break; |
184 | case R.id.changpassword: | 182 | case R.id.changpassword: |
185 | Intent changpwd = new Intent(); | 183 | Intent changpwd = new Intent(); |
186 | changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class); | 184 | changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class); |
187 | startActivity(changpwd); | 185 | startActivity(changpwd); |
188 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 186 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
189 | break; | 187 | break; |
190 | case R.id.change_zhu_account: | 188 | case R.id.change_zhu_account: |
191 | Content.changgeaccountflag = 1; | 189 | Content.changgeaccountflag = 1; |
192 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 190 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
193 | SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ACCOUNT, "1"); | 191 | SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ACCOUNT, "1"); |
194 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | 192 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
195 | try { | 193 | try { |
196 | long auserID = Long.parseLong(userID); | 194 | long auserID = Long.parseLong(userID); |
197 | HttpManager.getInstance().Accountinfo(AccountManagementActivity.this, auserID, | 195 | HttpManager.getInstance().Accountinfo(AccountManagementActivity.this, auserID, |
198 | devicenumber, 1); | 196 | devicenumber, 1); |
199 | 197 | ||
200 | } catch (NumberFormatException e) { | 198 | } catch (NumberFormatException e) { |
201 | e.printStackTrace(); | 199 | e.printStackTrace(); |
202 | } | 200 | } |
203 | 201 | ||
204 | 202 | ||
205 | break; | 203 | break; |
206 | case R.id.cancel: | 204 | case R.id.cancel: |
207 | finish(); | 205 | finish(); |
208 | break; | 206 | break; |
209 | 207 | ||
210 | } | 208 | } |
211 | 209 | ||
212 | } | 210 | } |
213 | 211 | ||
214 | @Override | 212 | @Override |
215 | protected void onResume() { | 213 | protected void onResume() { |
216 | super.onResume(); | 214 | super.onResume(); |
217 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 215 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
218 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | 216 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
219 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); | 217 | String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); |
220 | usernames.setText(cunt_username); | 218 | usernames.setText(cunt_username); |
221 | try { | 219 | try { |
222 | long auserID = Long.parseLong(userID); | 220 | long auserID = Long.parseLong(userID); |
223 | HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler); | 221 | HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler); |
224 | 222 | ||
225 | } catch (NumberFormatException e) { | 223 | } catch (NumberFormatException e) { |
226 | e.printStackTrace(); | 224 | e.printStackTrace(); |
227 | } | 225 | } |
228 | } | 226 | } |
229 | } | 227 | } |
230 | 228 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeBangDingActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | 5 | ||
6 | import com.hjx.personalcenter.R; | 6 | import com.hjx.personalcenter.R; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Created by h on 2017/8/9. | 9 | * Created by h on 2017/8/9. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | public class ChangeBangDingActivity extends Activity { | 12 | public class ChangeBangDingActivity extends Activity { |
13 | @Override | 13 | @Override |
14 | protected void onCreate(Bundle savedInstanceState) { | 14 | protected void onCreate(Bundle savedInstanceState) { |
15 | super.onCreate(savedInstanceState); | 15 | super.onCreate(savedInstanceState); |
16 | setContentView(R.layout.activity_chage_binding); | 16 | setContentView(R.layout.activity_chage_binding); |
17 | SysApplication.getInstance().addActivity(this); | ||
18 | } | 17 | } |
19 | } | 18 | } |
20 | 19 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeEletronicCardPhoneActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.support.v7.app.AppCompatActivity; | 4 | import android.support.v7.app.AppCompatActivity; |
5 | 5 | ||
6 | import com.hjx.personalcenter.R; | 6 | import com.hjx.personalcenter.R; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Created by h on 2017/8/9. | 9 | * Created by h on 2017/8/9. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | public class ChangeEletronicCardPhoneActivity extends AppCompatActivity { | 12 | public class ChangeEletronicCardPhoneActivity extends AppCompatActivity { |
13 | 13 | ||
14 | 14 | ||
15 | @Override | 15 | @Override |
16 | protected void onCreate(Bundle savedInstanceState) { | 16 | protected void onCreate(Bundle savedInstanceState) { |
17 | super.onCreate(savedInstanceState); | 17 | super.onCreate(savedInstanceState); |
18 | setContentView(R.layout.activity_electronicard_phone); | 18 | setContentView(R.layout.activity_electronicard_phone); |
19 | SysApplication.getInstance().addActivity(this); | ||
20 | } | 19 | } |
21 | } | 20 | } |
22 | 21 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePasswordActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.support.v7.app.AppCompatActivity; | 4 | import android.support.v7.app.AppCompatActivity; |
5 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
6 | import android.text.method.HideReturnsTransformationMethod; | 6 | import android.text.method.HideReturnsTransformationMethod; |
7 | import android.text.method.PasswordTransformationMethod; | 7 | import android.text.method.PasswordTransformationMethod; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.widget.Button; | 9 | import android.widget.Button; |
10 | import android.widget.EditText; | 10 | import android.widget.EditText; |
11 | import android.widget.ImageView; | 11 | import android.widget.ImageView; |
12 | 12 | ||
13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.db.SaveParam; | 14 | import com.hjx.personalcenter.db.SaveParam; |
15 | import com.hjx.personalcenter.http.HttpManager; | 15 | import com.hjx.personalcenter.http.HttpManager; |
16 | import com.hjx.personalcenter.util.AlertUtils; | 16 | import com.hjx.personalcenter.util.AlertUtils; |
17 | import com.hjx.personalcenter.util.PasswordCheckUtils; | 17 | import com.hjx.personalcenter.util.PasswordCheckUtils; |
18 | 18 | ||
19 | /**修改密码 | 19 | /**修改密码 |
20 | * Created by h on 2017/6/27. | 20 | * Created by h on 2017/6/27. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | public class ChangePasswordActivity extends AppCompatActivity implements View.OnClickListener { | 23 | public class ChangePasswordActivity extends AppCompatActivity implements View.OnClickListener { |
24 | private EditText old_pwd,newpassword,newpassword1; | 24 | private EditText old_pwd,newpassword,newpassword1; |
25 | private Button sub_change_pwd; | 25 | private Button sub_change_pwd; |
26 | private ImageView back_change_pwd,eyes_iv_change1; | 26 | private ImageView back_change_pwd,eyes_iv_change1; |
27 | public static Boolean showPassword = false; | 27 | public static Boolean showPassword = false; |
28 | @Override | 28 | @Override |
29 | protected void onCreate(Bundle savedInstanceState) { | 29 | protected void onCreate(Bundle savedInstanceState) { |
30 | super.onCreate(savedInstanceState); | 30 | super.onCreate(savedInstanceState); |
31 | setContentView(R.layout.activity_changepsword); | 31 | setContentView(R.layout.activity_changepsword); |
32 | SysApplication.getInstance().addActivity(this); | ||
33 | initView(); | 32 | initView(); |
34 | setLister(); | 33 | setLister(); |
35 | } | 34 | } |
36 | 35 | ||
37 | private void initView() { | 36 | private void initView() { |
38 | old_pwd = (EditText) findViewById(R.id.et_oldpassword); | 37 | old_pwd = (EditText) findViewById(R.id.et_oldpassword); |
39 | newpassword = (EditText) findViewById(R.id.et_newpassword); | 38 | newpassword = (EditText) findViewById(R.id.et_newpassword); |
40 | newpassword1 = (EditText) findViewById(R.id.et_again_newpassword); | 39 | newpassword1 = (EditText) findViewById(R.id.et_again_newpassword); |
41 | sub_change_pwd = (Button) findViewById(R.id.btn_ok); | 40 | sub_change_pwd = (Button) findViewById(R.id.btn_ok); |
42 | back_change_pwd = (ImageView) findViewById(R.id.cancel); | 41 | back_change_pwd = (ImageView) findViewById(R.id.cancel); |
43 | eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change); | 42 | eyes_iv_change1 = (ImageView) findViewById(R.id.iv_pwd_change); |
44 | 43 | ||
45 | 44 | ||
46 | } | 45 | } |
47 | 46 | ||
48 | private void setLister() { | 47 | private void setLister() { |
49 | sub_change_pwd.setOnClickListener(this); | 48 | sub_change_pwd.setOnClickListener(this); |
50 | back_change_pwd.setOnClickListener(this); | 49 | back_change_pwd.setOnClickListener(this); |
51 | eyes_iv_change1.setOnClickListener(this); | 50 | eyes_iv_change1.setOnClickListener(this); |
52 | } | 51 | } |
53 | 52 | ||
54 | @Override | 53 | @Override |
55 | public void onClick(View v) { | 54 | public void onClick(View v) { |
56 | String old_pwd1 = old_pwd.getText().toString().trim(); | 55 | String old_pwd1 = old_pwd.getText().toString().trim(); |
57 | String newpassword3 = newpassword.getText().toString().trim(); | 56 | String newpassword3 = newpassword.getText().toString().trim(); |
58 | String newpassword4 = newpassword1.getText().toString().trim(); | 57 | String newpassword4 = newpassword1.getText().toString().trim(); |
59 | switch (v.getId()){ | 58 | switch (v.getId()){ |
60 | //确认修改 | 59 | //确认修改 |
61 | case R.id.btn_ok: | 60 | case R.id.btn_ok: |
62 | 61 | ||
63 | //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password")); | 62 | //Log.e("test","sp保存的密码是"+sp.getLoginParam(ChangePwd.this, "password")); |
64 | if (TextUtils.isEmpty(old_pwd1)|| | 63 | if (TextUtils.isEmpty(old_pwd1)|| |
65 | TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){ | 64 | TextUtils.isEmpty(newpassword3) || TextUtils.isEmpty(newpassword4)){ |
66 | AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整"); | 65 | AlertUtils.showToast(ChangePasswordActivity.this, "请将必填项填写完整"); |
67 | return; | 66 | return; |
68 | }else if(newpassword3.length()<8||newpassword4.length()<8){ | 67 | }else if(newpassword3.length()<8||newpassword4.length()<8){ |
69 | AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位"); | 68 | AlertUtils.showToast(ChangePasswordActivity.this,"密码不能少于8位"); |
70 | }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ | 69 | }else if(!newpassword3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)||!newpassword4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)){ |
71 | AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成"); | 70 | AlertUtils.showToast(ChangePasswordActivity.this, "密码必须由数字和字母组成"); |
72 | } | 71 | } |
73 | //得到原密码并且判断是否输入的一样 | 72 | //得到原密码并且判断是否输入的一样 |
74 | else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){ | 73 | else if(!SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"password").equals(old_pwd1)){ |
75 | 74 | ||
76 | AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误"); | 75 | AlertUtils.showToast(ChangePasswordActivity.this, "原密码输入错误"); |
77 | 76 | ||
78 | }else if (!newpassword3.equals(newpassword4)){ | 77 | }else if (!newpassword3.equals(newpassword4)){ |
79 | AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致"); | 78 | AlertUtils.showToast(ChangePasswordActivity.this, "两次密码输入不一致"); |
80 | return; | 79 | return; |
81 | }else{ | 80 | }else{ |
82 | //修改密码接口 | 81 | //修改密码接口 |
83 | String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username"); | 82 | String name = SaveParam.getInstance().getLoginParam(ChangePasswordActivity.this,"username"); |
84 | HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3); | 83 | HttpManager.getInstance().changepwd(this,name,old_pwd1,newpassword3); |
85 | } | 84 | } |
86 | 85 | ||
87 | break; | 86 | break; |
88 | case R.id.iv_pwd_change: | 87 | case R.id.iv_pwd_change: |
89 | if(showPassword){//显示密码 | 88 | if(showPassword){//显示密码 |
90 | showPassword = !showPassword; | 89 | showPassword = !showPassword; |
91 | eyes_iv_change1.setImageResource(R.mipmap.pwd_open); | 90 | eyes_iv_change1.setImageResource(R.mipmap.pwd_open); |
92 | newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 91 | newpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
93 | newpassword.setSelection(newpassword.getText().toString().length()); | 92 | newpassword.setSelection(newpassword.getText().toString().length()); |
94 | }else{//隐藏密码 | 93 | }else{//隐藏密码 |
95 | showPassword = !showPassword; | 94 | showPassword = !showPassword; |
96 | eyes_iv_change1.setImageResource(R.mipmap.pwd_hide); | 95 | eyes_iv_change1.setImageResource(R.mipmap.pwd_hide); |
97 | newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 96 | newpassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
98 | newpassword.setSelection(newpassword.getText().toString().length()); | 97 | newpassword.setSelection(newpassword.getText().toString().length()); |
99 | } | 98 | } |
100 | break; | 99 | break; |
101 | 100 | ||
102 | case R.id.cancel: | 101 | case R.id.cancel: |
103 | finish(); | 102 | finish(); |
104 | break; | 103 | break; |
105 | } | 104 | } |
106 | 105 | ||
107 | } | 106 | } |
108 | } | 107 | } |
109 | 108 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangePresonalInfoActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.support.v4.app.Fragment; | 4 | import android.support.v4.app.Fragment; |
5 | import android.support.v4.view.ViewPager; | 5 | import android.support.v4.view.ViewPager; |
6 | import android.support.v7.app.AppCompatActivity; | 6 | import android.support.v7.app.AppCompatActivity; |
7 | 7 | ||
8 | import com.hjx.personalcenter.R; | 8 | import com.hjx.personalcenter.R; |
9 | import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; | 9 | import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; |
10 | import com.hjx.personalcenter.fragment.PresonInfoFragment; | 10 | import com.hjx.personalcenter.fragment.PresonInfoFragment; |
11 | import com.hjx.personalcenter.fragment.VersionsInfoFragment; | 11 | import com.hjx.personalcenter.fragment.VersionsInfoFragment; |
12 | 12 | ||
13 | import java.util.ArrayList; | 13 | import java.util.ArrayList; |
14 | import java.util.Arrays; | 14 | import java.util.Arrays; |
15 | import java.util.List; | 15 | import java.util.List; |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Created by h on 2017/8/12. | 18 | * Created by h on 2017/8/12. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | public class ChangePresonalInfoActivity extends AppCompatActivity { | 21 | public class ChangePresonalInfoActivity extends AppCompatActivity { |
22 | private ViewPager viewPager; | 22 | private ViewPager viewPager; |
23 | // private SlidingTabLayout tableLayout; | 23 | // private SlidingTabLayout tableLayout; |
24 | private List<Fragment> presoninfo; | 24 | private List<Fragment> presoninfo; |
25 | private LoginAndRegisterAdapter presoninfodapter; | 25 | private LoginAndRegisterAdapter presoninfodapter; |
26 | public interface Fragment2Fragment{ | 26 | public interface Fragment2Fragment{ |
27 | public void gotoFragment(ViewPager viewPager); | 27 | public void gotoFragment(ViewPager viewPager); |
28 | } | 28 | } |
29 | private Fragment2Fragment fragment2Fragment; | 29 | private Fragment2Fragment fragment2Fragment; |
30 | public void setFragment2Fragment(Fragment2Fragment fragment2Fragment){ | 30 | public void setFragment2Fragment(Fragment2Fragment fragment2Fragment){ |
31 | this.fragment2Fragment = fragment2Fragment; | 31 | this.fragment2Fragment = fragment2Fragment; |
32 | } | 32 | } |
33 | public void forSkip(){ | 33 | public void forSkip(){ |
34 | if(fragment2Fragment!=null){ | 34 | if(fragment2Fragment!=null){ |
35 | fragment2Fragment.gotoFragment(viewPager); | 35 | fragment2Fragment.gotoFragment(viewPager); |
36 | } | 36 | } |
37 | } | 37 | } |
38 | private List<String> title = Arrays.asList("个人信息", "版本信息"); | 38 | private List<String> title = Arrays.asList("个人信息", "版本信息"); |
39 | @Override | 39 | @Override |
40 | protected void onCreate(Bundle savedInstanceState) { | 40 | protected void onCreate(Bundle savedInstanceState) { |
41 | super.onCreate(savedInstanceState); | 41 | super.onCreate(savedInstanceState); |
42 | setContentView(R.layout.activity_change_preson_info); | 42 | setContentView(R.layout.activity_change_preson_info); |
43 | SysApplication.getInstance().addActivity(this); | ||
44 | initView(); | 43 | initView(); |
45 | initData(); | 44 | initData(); |
46 | 45 | ||
47 | } | 46 | } |
48 | private void initView() { | 47 | private void initView() { |
49 | viewPager = (ViewPager) findViewById(R.id.viewpager_login); | 48 | viewPager = (ViewPager) findViewById(R.id.viewpager_login); |
50 | //tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); | 49 | //tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); |
51 | } | 50 | } |
52 | 51 | ||
53 | private void initData() { | 52 | private void initData() { |
54 | presoninfo = new ArrayList<>(); | 53 | presoninfo = new ArrayList<>(); |
55 | for (int i = 0; i < title.size(); i++) { | 54 | for (int i = 0; i < title.size(); i++) { |
56 | if (title.get(i).equals("个人信息")) { | 55 | if (title.get(i).equals("个人信息")) { |
57 | presoninfo.add(PresonInfoFragment.newInstance(i + 1)); | 56 | presoninfo.add(PresonInfoFragment.newInstance(i + 1)); |
58 | } else { | 57 | } else { |
59 | presoninfo.add(VersionsInfoFragment.newInstance(i + 1)); | 58 | presoninfo.add(VersionsInfoFragment.newInstance(i + 1)); |
60 | } | 59 | } |
61 | } | 60 | } |
62 | 61 | ||
63 | 62 | ||
64 | //设置Tab上的标题 | 63 | //设置Tab上的标题 |
65 | //tableLayout.setData(title); | 64 | //tableLayout.setData(title); |
66 | //设置关联的ViewPager | 65 | //设置关联的ViewPager |
67 | //tableLayout.setViewPager(viewPager, 0); | 66 | //tableLayout.setViewPager(viewPager, 0); |
68 | presoninfodapter = new LoginAndRegisterAdapter(presoninfo, getSupportFragmentManager()); | 67 | presoninfodapter = new LoginAndRegisterAdapter(presoninfo, getSupportFragmentManager()); |
69 | //给ViewPager设置适配器 | 68 | //给ViewPager设置适配器 |
70 | viewPager.setAdapter(presoninfodapter); | 69 | viewPager.setAdapter(presoninfodapter); |
71 | //设置滑动时数据不丢失 | 70 | //设置滑动时数据不丢失 |
72 | viewPager.setOffscreenPageLimit(1); | 71 | viewPager.setOffscreenPageLimit(1); |
73 | //将TabLayout和ViewPager关联起来。 | 72 | //将TabLayout和ViewPager关联起来。 |
74 | } | 73 | } |
75 | 74 | ||
76 | } | 75 | } |
77 | 76 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChoiseTextBookActivity.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.util.Log; | 8 | import android.util.Log; |
9 | import android.view.View; | 9 | import android.view.View; |
10 | import android.widget.AdapterView; | 10 | import android.widget.AdapterView; |
11 | import android.widget.Button; | 11 | import android.widget.Button; |
12 | import android.widget.GridView; | 12 | import android.widget.GridView; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | import android.widget.TextView; | 14 | import android.widget.TextView; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import com.facebook.drawee.view.SimpleDraweeView; | 17 | import com.facebook.drawee.view.SimpleDraweeView; |
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.adapter.GridAdapter; | 19 | import com.hjx.personalcenter.adapter.GridAdapter; |
20 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; | 20 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; |
21 | import com.hjx.personalcenter.customdialog.VerSionDialog; | 21 | import com.hjx.personalcenter.customdialog.VerSionDialog; |
22 | import com.hjx.personalcenter.db.SaveParam; | 22 | import com.hjx.personalcenter.db.SaveParam; |
23 | import com.hjx.personalcenter.http.HttpCode; | 23 | import com.hjx.personalcenter.http.HttpCode; |
24 | import com.hjx.personalcenter.http.HttpManager; | 24 | import com.hjx.personalcenter.http.HttpManager; |
25 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 25 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
26 | import com.hjx.personalcenter.model.DefautPublishInfo; | 26 | import com.hjx.personalcenter.model.DefautPublishInfo; |
27 | import com.hjx.personalcenter.model.VersionInfo; | 27 | import com.hjx.personalcenter.model.VersionInfo; |
28 | import com.hjx.personalcenter.util.AlertUtils; | 28 | import com.hjx.personalcenter.util.AlertUtils; |
29 | import com.hjx.personalcenter.util.GetDevicesUtil; | 29 | import com.hjx.personalcenter.util.GetDevicesUtil; |
30 | 30 | ||
31 | import org.json.JSONException; | 31 | import org.json.JSONException; |
32 | import org.json.JSONObject; | 32 | import org.json.JSONObject; |
33 | 33 | ||
34 | import java.util.ArrayList; | 34 | import java.util.ArrayList; |
35 | import java.util.List; | 35 | import java.util.List; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * 选择教材 | 38 | * 选择教材 |
39 | * Created by h on 2017/8/10. | 39 | * Created by h on 2017/8/10. |
40 | */ | 40 | */ |
41 | 41 | ||
42 | public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener, DialogCallBack.VersionCallBack { | 42 | public class ChoiseTextBookActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener, DialogCallBack.VersionCallBack { |
43 | private GridView gridView; | 43 | private GridView gridView; |
44 | private Button btn_ok; | 44 | private Button btn_ok; |
45 | private ImageView cancel; | 45 | private ImageView cancel; |
46 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); | 46 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
47 | private GridAdapter sim_adapter; | 47 | private GridAdapter sim_adapter; |
48 | private SimpleDraweeView simpleDraweeView; | 48 | private SimpleDraweeView simpleDraweeView; |
49 | private TextView publish; | 49 | private TextView publish; |
50 | private String chinese, math, english, physics, chemistry, history, geography, political, biology, science; | 50 | private String chinese, math, english, physics, chemistry, history, geography, political, biology, science; |
51 | 51 | ||
52 | 52 | ||
53 | Handler handler = new Handler() { | 53 | Handler handler = new Handler() { |
54 | @Override | 54 | @Override |
55 | public void handleMessage(Message msg) { | 55 | public void handleMessage(Message msg) { |
56 | super.handleMessage(msg); | 56 | super.handleMessage(msg); |
57 | JSONObject jsonObject; | 57 | JSONObject jsonObject; |
58 | String status; | 58 | String status; |
59 | switch (msg.what) { | 59 | switch (msg.what) { |
60 | case HttpCode.CHECKCARD: | 60 | case HttpCode.CHECKCARD: |
61 | try { | 61 | try { |
62 | jsonObject = new JSONObject((String) msg.obj); | 62 | jsonObject = new JSONObject((String) msg.obj); |
63 | status = jsonObject.optString("status"); | 63 | status = jsonObject.optString("status"); |
64 | if (status.equals("1")) { | 64 | if (status.equals("1")) { |
65 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); | 65 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您已经填写了保卡信息,请到主界面确认您的保卡信息是否正确!"); |
66 | Intent intent = new Intent(); | 66 | Intent intent = new Intent(); |
67 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); | 67 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); |
68 | ChoiseTextBookActivity.this.startActivity(intent); | 68 | ChoiseTextBookActivity.this.startActivity(intent); |
69 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 69 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
70 | } else if (status.equals("2001")) { | 70 | } else if (status.equals("2001")) { |
71 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); | 71 | ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog"); |
72 | } else if (status.equals("2002")) { | ||
73 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您的机器为样机,可直接使用!"); | ||
74 | Intent intent = new Intent(); | ||
75 | intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class); | ||
76 | ChoiseTextBookActivity.this.startActivity(intent); | ||
77 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | ||
72 | } | 78 | } |
73 | 79 | ||
74 | } catch (JSONException e) { | 80 | } catch (JSONException e) { |
75 | e.printStackTrace(); | 81 | e.printStackTrace(); |
76 | } | 82 | } |
77 | 83 | ||
78 | break; | 84 | break; |
79 | case HttpCode.PUBLISH_SUCESS: | 85 | case HttpCode.PUBLISH_SUCESS: |
80 | defautPublishInfos.clear(); | 86 | defautPublishInfos.clear(); |
81 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); | 87 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); |
82 | sim_adapter.notifyDataSetChanged(); | 88 | sim_adapter.notifyDataSetChanged(); |
83 | for (int i = 0; i < defautPublishInfos.size(); i++) { | 89 | for (int i = 0; i < defautPublishInfos.size(); i++) { |
84 | String subject = defautPublishInfos.get(i).getSubject(); | 90 | String subject = defautPublishInfos.get(i).getSubject(); |
85 | if (subject.equals("语文")) { | 91 | if (subject.equals("语文")) { |
86 | chinese = defautPublishInfos.get(i).getPress(); | 92 | chinese = defautPublishInfos.get(i).getPress(); |
87 | } else if (subject.equals("数学")) { | 93 | } else if (subject.equals("数学")) { |
88 | math = defautPublishInfos.get(i).getPress(); | 94 | math = defautPublishInfos.get(i).getPress(); |
89 | } else if (subject.equals("英语")) { | 95 | } else if (subject.equals("英语")) { |
90 | english = defautPublishInfos.get(i).getPress(); | 96 | english = defautPublishInfos.get(i).getPress(); |
91 | } else if (subject.equals("物理")) { | 97 | } else if (subject.equals("物理")) { |
92 | physics = defautPublishInfos.get(i).getPress(); | 98 | physics = defautPublishInfos.get(i).getPress(); |
93 | } else if (subject.equals("化学")) { | 99 | } else if (subject.equals("化学")) { |
94 | chemistry = defautPublishInfos.get(i).getPress(); | 100 | chemistry = defautPublishInfos.get(i).getPress(); |
95 | } else if (subject.equals("历史")) { | 101 | } else if (subject.equals("历史")) { |
96 | history = defautPublishInfos.get(i).getPress(); | 102 | history = defautPublishInfos.get(i).getPress(); |
97 | } else if (subject.equals("地理")) { | 103 | } else if (subject.equals("地理")) { |
98 | geography = defautPublishInfos.get(i).getPress(); | 104 | geography = defautPublishInfos.get(i).getPress(); |
99 | } else if (subject.equals("政治")) { | 105 | } else if (subject.equals("政治")) { |
100 | political = defautPublishInfos.get(i).getPress(); | 106 | political = defautPublishInfos.get(i).getPress(); |
101 | } else if (subject.equals("生物")) { | 107 | } else if (subject.equals("生物")) { |
102 | biology = defautPublishInfos.get(i).getPress(); | 108 | biology = defautPublishInfos.get(i).getPress(); |
103 | } else if (subject.equals("科学")) { | 109 | } else if (subject.equals("科学")) { |
104 | science = defautPublishInfos.get(i).getPress(); | 110 | science = defautPublishInfos.get(i).getPress(); |
105 | } | 111 | } |
106 | } | 112 | } |
107 | break; | 113 | break; |
108 | case HttpCode.REGISTERINFO_SUCESS: | 114 | case HttpCode.REGISTERINFO_SUCESS: |
109 | try { | 115 | try { |
110 | jsonObject = new JSONObject((String) msg.obj); | 116 | jsonObject = new JSONObject((String) msg.obj); |
111 | String statusregister = jsonObject.optString("status"); | 117 | String statusregister = jsonObject.optString("status"); |
112 | if (statusregister.equals("1")) { | 118 | if (statusregister.equals("1")) { |
113 | Toast.makeText(ChoiseTextBookActivity.this, "注册信息上传成功", Toast.LENGTH_LONG).show(); | 119 | Toast.makeText(ChoiseTextBookActivity.this, "注册信息上传成功", Toast.LENGTH_LONG).show(); |
114 | String deviceNumber = GetDevicesUtil.getDevicesInfo(ChoiseTextBookActivity.this).getDeviceNumber(); | 120 | String deviceNumber = GetDevicesUtil.getDevicesInfo(ChoiseTextBookActivity.this).getDeviceNumber(); |
115 | if (deviceNumber == null) { | 121 | if (deviceNumber == null) { |
116 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); | 122 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); |
117 | 123 | ||
118 | } else { | 124 | } else { |
119 | //验证保卡信息 | 125 | //验证保卡信息 |
120 | HttpManager.getInstance().cardinfocheck(ChoiseTextBookActivity.this, deviceNumber, handler); | 126 | HttpManager.getInstance().cardinfocheck(ChoiseTextBookActivity.this, deviceNumber, handler); |
121 | } | 127 | } |
122 | 128 | ||
123 | } else { | 129 | } else { |
124 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您好,服务器异常,请稍后重试"); | 130 | AlertUtils.showToast(ChoiseTextBookActivity.this, "您好,服务器异常,请稍后重试"); |
125 | } | 131 | } |
126 | } catch (JSONException e) { | 132 | } catch (JSONException e) { |
127 | e.printStackTrace(); | 133 | e.printStackTrace(); |
128 | } | 134 | } |
129 | 135 | ||
130 | 136 | ||
131 | break; | 137 | break; |
132 | 138 | ||
133 | } | 139 | } |
134 | 140 | ||
135 | } | 141 | } |
136 | }; | 142 | }; |
137 | 143 | ||
138 | @Override | 144 | @Override |
139 | protected void onCreate(Bundle savedInstanceState) { | 145 | protected void onCreate(Bundle savedInstanceState) { |
140 | super.onCreate(savedInstanceState); | 146 | super.onCreate(savedInstanceState); |
141 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 147 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
142 | String graderid = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS); | 148 | String graderid = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS); |
143 | String accounts = SaveParam.getInstance().getCustomizeParam(ChoiseTextBookActivity.this,SaveParam.ACCOUNT); | 149 | String accounts = SaveParam.getInstance().getCustomizeParam(ChoiseTextBookActivity.this,SaveParam.ACCOUNT); |
144 | try { | 150 | try { |
145 | long auserID = Long.parseLong(userID); | 151 | long auserID = Long.parseLong(userID); |
146 | int graderID = Integer.parseInt(graderid); | 152 | int graderID = Integer.parseInt(graderid); |
147 | int accountss = Integer.parseInt(accounts); | 153 | int accountss = Integer.parseInt(accounts); |
148 | //获取版本信息 | 154 | //获取版本信息 |
149 | HttpManager.getInstance().getpublishinfo(this, auserID, graderID,accountss, handler); | 155 | HttpManager.getInstance().getpublishinfo(this, auserID, graderID,accountss, handler); |
150 | 156 | ||
151 | } catch (NumberFormatException e) { | 157 | } catch (NumberFormatException e) { |
152 | e.printStackTrace(); | 158 | e.printStackTrace(); |
153 | } | 159 | } |
154 | setContentView(R.layout.activity_choisetextbook); | 160 | setContentView(R.layout.activity_choisetextbook); |
155 | SysApplication.getInstance().addActivity(this); | 161 | SysApplication.getInstance().addActivity(this); |
156 | initView(); | 162 | initView(); |
157 | initData(); | 163 | initData(); |
158 | initLister(); | 164 | initLister(); |
159 | } | 165 | } |
160 | 166 | ||
161 | private void initView() { | 167 | private void initView() { |
162 | gridView = (GridView) findViewById(R.id.grideview); | 168 | gridView = (GridView) findViewById(R.id.grideview); |
163 | cancel = (ImageView) findViewById(R.id.cancel); | 169 | cancel = (ImageView) findViewById(R.id.cancel); |
164 | btn_ok = (Button) findViewById(R.id.btn_ok); | 170 | btn_ok = (Button) findViewById(R.id.btn_ok); |
165 | } | 171 | } |
166 | 172 | ||
167 | private void initData() { | 173 | private void initData() { |
168 | sim_adapter = new GridAdapter(defautPublishInfos, this); | 174 | sim_adapter = new GridAdapter(defautPublishInfos, this); |
169 | //配置适配器 | 175 | //配置适配器 |
170 | gridView.setAdapter(sim_adapter); | 176 | gridView.setAdapter(sim_adapter); |
171 | 177 | ||
172 | } | 178 | } |
173 | 179 | ||
174 | private void initLister() { | 180 | private void initLister() { |
175 | btn_ok.setOnClickListener(this); | 181 | btn_ok.setOnClickListener(this); |
176 | cancel.setOnClickListener(this); | 182 | cancel.setOnClickListener(this); |
177 | gridView.setOnItemClickListener(this); | 183 | gridView.setOnItemClickListener(this); |
178 | 184 | ||
179 | } | 185 | } |
180 | 186 | ||
181 | @Override | 187 | @Override |
182 | public void onClick(View v) { | 188 | public void onClick(View v) { |
183 | switch (v.getId()) { | 189 | switch (v.getId()) { |
184 | case R.id.btn_ok: | 190 | case R.id.btn_ok: |
185 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 191 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
186 | String regionId = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.COUNTRY); | 192 | String regionId = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.COUNTRY); |
187 | String regionId1 = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.CITYS); | 193 | String regionId1 = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.CITYS); |
188 | if (regionId == null) { | 194 | if (regionId == null) { |
189 | regionId = regionId1; | 195 | regionId = regionId1; |
190 | } | 196 | } |
191 | String grade = SaveParam.getInstance().getCustomizeParam(ChoiseTextBookActivity.this, SaveParam.GRADENS); | 197 | String grade = SaveParam.getInstance().getCustomizeParam(ChoiseTextBookActivity.this, SaveParam.GRADENS); |
192 | String schoolid = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.SCHOOOlID); | 198 | String schoolid = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.SCHOOOlID); |
193 | String name = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.USERNAME); | 199 | String name = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.USERNAME); |
194 | String regeionname = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.ADRESS); | 200 | String regeionname = SaveParam.getInstance().getLoginParam(ChoiseTextBookActivity.this, SaveParam.ADRESS); |
195 | 201 | ||
196 | try { | 202 | try { |
197 | if (userID == null) { | 203 | if (userID == null) { |
198 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); | 204 | AlertUtils.showToast(ChoiseTextBookActivity.this, "连接超时请重新登录!"); |
199 | 205 | ||
200 | } else { | 206 | } else { |
201 | Object schoolID; | 207 | Object schoolID; |
202 | long auserID = Long.parseLong(userID); | 208 | long auserID = Long.parseLong(userID); |
203 | int gradeID = Integer.parseInt(grade); | 209 | int gradeID = Integer.parseInt(grade); |
204 | long regionID = Long.parseLong(regionId); | 210 | long regionID = Long.parseLong(regionId); |
205 | if (schoolid == null) { | 211 | if (schoolid == null) { |
206 | schoolID = null; | 212 | schoolID = null; |
207 | } else { | 213 | } else { |
208 | schoolID = Long.parseLong(schoolid); | 214 | schoolID = Long.parseLong(schoolid); |
209 | } | 215 | } |
210 | 216 | ||
211 | //提交注册信息 | 217 | //提交注册信息 |
212 | HttpManager.getInstance().subregisterinfo(ChoiseTextBookActivity.this, auserID, | 218 | HttpManager.getInstance().subregisterinfo(ChoiseTextBookActivity.this, auserID, |
213 | name, gradeID, regionID, regeionname, schoolID, math, english, chinese, physics, chemistry, history, geography, political, biology, science, handler); | 219 | name, gradeID, regionID, regeionname, schoolID, math, english, chinese, physics, chemistry, history, geography, political, biology, science, handler); |
214 | } | 220 | } |
215 | 221 | ||
216 | } catch (NumberFormatException e) { | 222 | } catch (NumberFormatException e) { |
217 | e.printStackTrace(); | 223 | e.printStackTrace(); |
218 | } | 224 | } |
219 | 225 | ||
220 | break; | 226 | break; |
221 | case R.id.cancel: | 227 | case R.id.cancel: |
222 | finish(); | 228 | finish(); |
223 | break; | 229 | break; |
224 | } | 230 | } |
225 | 231 | ||
226 | } | 232 | } |
227 | 233 | ||
228 | @Override | 234 | @Override |
229 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 235 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
230 | SaveParam.getInstance().saveLoginParam(this, SaveParam.SUBJECT, defautPublishInfos.get(position).getSubject()); | 236 | SaveParam.getInstance().saveLoginParam(this, SaveParam.SUBJECT, defautPublishInfos.get(position).getSubject()); |
231 | VerSionDialog.getInstance(this).show(getSupportFragmentManager(), "VerSionDialog"); | 237 | VerSionDialog.getInstance(this).show(getSupportFragmentManager(), "VerSionDialog"); |
232 | simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.image_publish); | 238 | simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.image_publish); |
233 | publish = (TextView) view.findViewById(R.id.tv_publish); | 239 | publish = (TextView) view.findViewById(R.id.tv_publish); |
234 | 240 | ||
235 | } | 241 | } |
236 | 242 | ||
237 | @Override | 243 | @Override |
238 | public void versionOnItemClick(ArrayList<VersionInfo.DataBean> data, int position, int type) { | 244 | public void versionOnItemClick(ArrayList<VersionInfo.DataBean> data, int position, int type) { |
239 | String imageurl = data.get(position).getPressCover(); | 245 | String imageurl = data.get(position).getPressCover(); |
240 | String publishs = data.get(position).getPressName(); | 246 | String publishs = data.get(position).getPressName(); |
241 | simpleDraweeView.setImageURI(imageurl); | 247 | simpleDraweeView.setImageURI(imageurl); |
242 | publish.setText(publishs); | 248 | publish.setText(publishs); |
243 | String subject = SaveParam.getInstance().getLoginParam(this, SaveParam.SUBJECT); | 249 | String subject = SaveParam.getInstance().getLoginParam(this, SaveParam.SUBJECT); |
244 | Log.e("test", "选择的科目" + subject); | 250 | Log.e("test", "选择的科目" + subject); |
245 | if ("语文".equals(subject)) { | 251 | if ("语文".equals(subject)) { |
246 | chinese = publishs; | 252 | chinese = publishs; |
247 | } else if ("数学".equals(subject)) { | 253 | } else if ("数学".equals(subject)) { |
248 | math = publishs; | 254 | math = publishs; |
249 | } else if ("英语".equals(subject)) { | 255 | } else if ("英语".equals(subject)) { |
250 | english = publishs; | 256 | english = publishs; |
251 | } else if ("物理".equals(subject)) { | 257 | } else if ("物理".equals(subject)) { |
252 | physics = publishs; | 258 | physics = publishs; |
253 | } else if ("化学".equals(subject)) { | 259 | } else if ("化学".equals(subject)) { |
254 | chemistry = publishs; | 260 | chemistry = publishs; |
255 | } else if ("历史".equals(subject)) { | 261 | } else if ("历史".equals(subject)) { |
256 | history = publishs; | 262 | history = publishs; |
257 | } else if ("地理".equals(subject)) { | 263 | } else if ("地理".equals(subject)) { |
258 | geography = publishs; | 264 | geography = publishs; |
259 | } else if ("政治".equals(subject)) { | 265 | } else if ("政治".equals(subject)) { |
260 | political = publishs; | 266 | political = publishs; |
261 | } else if ("生物".equals(subject)) { | 267 | } else if ("生物".equals(subject)) { |
262 | biology = publishs; | 268 | biology = publishs; |
263 | } else if ("科学".equals(subject)) { | 269 | } else if ("科学".equals(subject)) { |
264 | science = publishs; | 270 | science = publishs; |
265 | } | 271 | } |
266 | 272 | ||
267 | } | 273 | } |
268 | } | 274 | } |
269 | 275 |
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.http.HttpCode; | 14 | import com.hjx.personalcenter.http.HttpCode; |
15 | import com.hjx.personalcenter.http.HttpManager; | 15 | import com.hjx.personalcenter.http.HttpManager; |
16 | import com.hjx.personalcenter.model.CardInfo; | 16 | import com.hjx.personalcenter.model.CardInfo; |
17 | import com.hjx.personalcenter.util.AlertUtils; | 17 | import com.hjx.personalcenter.util.AlertUtils; |
18 | import com.hjx.personalcenter.util.GetDevicesUtil; | 18 | import com.hjx.personalcenter.util.GetDevicesUtil; |
19 | 19 | ||
20 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Created by h on 2017/8/11. | 23 | * Created by h on 2017/8/11. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener { | 26 | public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener { |
27 | private ImageView iv_last_step; | 27 | private ImageView iv_last_step; |
28 | private TextView usename, deviceModel, customer_address, mac_adress, shoptime, deviceNumber, | 28 | private TextView usename, deviceModel, customer_address, mac_adress, shoptime, deviceNumber, |
29 | shopadress, phone, tlePhone, tv_card_adress_change, tv_card_phone_change; | 29 | shopadress, phone, tlePhone, tv_card_adress_change, tv_card_phone_change; |
30 | private ArrayList<CardInfo.DataBean> data = new ArrayList<>(); | 30 | private ArrayList<CardInfo.DataBean> data = new ArrayList<>(); |
31 | 31 | ||
32 | Handler handler = new Handler() { | 32 | Handler handler = new Handler() { |
33 | @Override | 33 | @Override |
34 | public void handleMessage(Message msg) { | 34 | public void handleMessage(Message msg) { |
35 | super.handleMessage(msg); | 35 | super.handleMessage(msg); |
36 | switch (msg.what) { | 36 | switch (msg.what) { |
37 | 37 | ||
38 | case HttpCode.SUCHCARDINFO: | 38 | case HttpCode.SUCHCARDINFO: |
39 | CardInfo.DataBean cardinfoBean = (CardInfo.DataBean) msg.obj; | 39 | CardInfo.DataBean cardinfoBean = (CardInfo.DataBean) msg.obj; |
40 | if (cardinfoBean != null) { | 40 | if (cardinfoBean != null) { |
41 | //获取设备信息 | 41 | //获取设备信息 |
42 | deviceModel.setText(cardinfoBean.getProductModel()); | 42 | deviceModel.setText(cardinfoBean.getProductModel()); |
43 | deviceNumber.setText(cardinfoBean.getDeviceNumber()); | 43 | deviceNumber.setText(cardinfoBean.getDeviceNumber()); |
44 | mac_adress.setText(cardinfoBean.getMacAddress()); | 44 | mac_adress.setText(cardinfoBean.getMacAddress()); |
45 | //获取保卡信息 | 45 | //获取保卡信息 |
46 | usename.setText(cardinfoBean.getCustomerName()); | 46 | usename.setText(cardinfoBean.getCustomerName()); |
47 | customer_address.setText(cardinfoBean.getCustomerAddress()); | 47 | customer_address.setText(cardinfoBean.getCustomerAddress()); |
48 | shoptime.setText(cardinfoBean.getBuyTime()); | 48 | shoptime.setText(cardinfoBean.getBuyTime()); |
49 | shopadress.setText(cardinfoBean.getBuyAddress()); | 49 | shopadress.setText(cardinfoBean.getBuyAddress()); |
50 | tlePhone.setText(cardinfoBean.getAlterSaleCall()); | 50 | tlePhone.setText(cardinfoBean.getAlterSaleCall()); |
51 | phone.setText(cardinfoBean.getMobilePhone()); | 51 | phone.setText(cardinfoBean.getMobilePhone()); |
52 | }else { | 52 | }else { |
53 | AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"您的机器还没有保卡信息,请重新登录"); | 53 | AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"您的机器还没有保卡信息,请重新登录"); |
54 | } | 54 | } |
55 | 55 | ||
56 | break; | 56 | break; |
57 | 57 | ||
58 | } | 58 | } |
59 | 59 | ||
60 | } | 60 | } |
61 | }; | 61 | }; |
62 | 62 | ||
63 | @Override | 63 | @Override |
64 | protected void onCreate(Bundle savedInstanceState) { | 64 | protected void onCreate(Bundle savedInstanceState) { |
65 | super.onCreate(savedInstanceState); | 65 | super.onCreate(savedInstanceState); |
66 | setContentView(R.layout.activity_electronic_look_cardinfo); | 66 | setContentView(R.layout.activity_electronic_look_cardinfo); |
67 | SysApplication.getInstance().addActivity(this); | ||
68 | initView(); | 67 | initView(); |
69 | initData(); | 68 | initData(); |
70 | initLister(); | 69 | initLister(); |
71 | } | 70 | } |
72 | 71 | ||
73 | @Override | 72 | @Override |
74 | protected void onResume() { | 73 | protected void onResume() { |
75 | super.onResume(); | 74 | super.onResume(); |
76 | String deviceNumber = GetDevicesUtil.getDevicesInfo(ElectronicCardLookInfoActivity.this).getDeviceNumber(); | 75 | String deviceNumber = GetDevicesUtil.getDevicesInfo(ElectronicCardLookInfoActivity.this).getDeviceNumber(); |
77 | HttpManager.getInstance().getcardinfo(this, deviceNumber, handler); | 76 | HttpManager.getInstance().getcardinfo(this, deviceNumber, handler); |
78 | } | 77 | } |
79 | 78 | ||
80 | private void initView() { | 79 | private void initView() { |
81 | usename = (TextView) findViewById(R.id.iv_card_username); | 80 | usename = (TextView) findViewById(R.id.iv_card_username); |
82 | iv_last_step = (ImageView) findViewById(R.id.cancel); | 81 | iv_last_step = (ImageView) findViewById(R.id.cancel); |
83 | deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); | 82 | deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); |
84 | customer_address = (TextView) findViewById(R.id.tv_card_adress); | 83 | customer_address = (TextView) findViewById(R.id.tv_card_adress); |
85 | mac_adress = (TextView) findViewById(R.id.tv_card_mac); | 84 | mac_adress = (TextView) findViewById(R.id.tv_card_mac); |
86 | shoptime = (TextView) findViewById(R.id.tv_card_time); | 85 | shoptime = (TextView) findViewById(R.id.tv_card_time); |
87 | deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber); | 86 | deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber); |
88 | shopadress = (TextView) findViewById(R.id.tv_card_shopAdress); | 87 | shopadress = (TextView) findViewById(R.id.tv_card_shopAdress); |
89 | phone = (TextView) findViewById(R.id.tv_card_phone); | 88 | phone = (TextView) findViewById(R.id.tv_card_phone); |
90 | tlePhone = (TextView) findViewById(R.id.tv_card_tleNember); | 89 | tlePhone = (TextView) findViewById(R.id.tv_card_tleNember); |
91 | tv_card_adress_change = (TextView) findViewById(R.id.tv_card_adress_change); | 90 | 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); | 91 | tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change); |
93 | } | 92 | } |
94 | 93 | ||
95 | private void initData() { | 94 | private void initData() { |
96 | 95 | ||
97 | // //获取设备信息 | 96 | // //获取设备信息 |
98 | // deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel()); | 97 | // deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel()); |
99 | // deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber()); | 98 | // deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber()); |
100 | // mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac()); | 99 | // mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac()); |
101 | // //获取保卡信息 | 100 | // //获取保卡信息 |
102 | // usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME)); | 101 | // usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME)); |
103 | // customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM)); | 102 | // customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM)); |
104 | // shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME)); | 103 | // shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME)); |
105 | // shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS)); | 104 | // shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS)); |
106 | // tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE)); | 105 | // tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE)); |
107 | // phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE)); | 106 | // phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE)); |
108 | 107 | ||
109 | 108 | ||
110 | } | 109 | } |
111 | 110 | ||
112 | private void initLister() { | 111 | private void initLister() { |
113 | tv_card_adress_change.setOnClickListener(this); | 112 | tv_card_adress_change.setOnClickListener(this); |
114 | tv_card_phone_change.setOnClickListener(this); | 113 | tv_card_phone_change.setOnClickListener(this); |
115 | iv_last_step.setOnClickListener(this); | 114 | iv_last_step.setOnClickListener(this); |
116 | } | 115 | } |
117 | 116 | ||
118 | @Override | 117 | @Override |
119 | public void onClick(View v) { | 118 | public void onClick(View v) { |
120 | switch (v.getId()) { | 119 | switch (v.getId()) { |
121 | case R.id.tv_card_adress_change: | 120 | case R.id.tv_card_adress_change: |
122 | Intent intent = new Intent(); | 121 | Intent intent = new Intent(); |
123 | intent.setClass(this, ChangeElectronicCardAdressInfoActivity.class); | 122 | intent.setClass(this, ChangeElectronicCardAdressInfoActivity.class); |
124 | startActivity(intent); | 123 | startActivity(intent); |
125 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 124 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
126 | 125 | ||
127 | break; | 126 | break; |
128 | case R.id.tv_card_phone_change: | 127 | case R.id.tv_card_phone_change: |
129 | Content.authcodeflag = 2; | 128 | Content.authcodeflag = 2; |
130 | Intent intent1 = new Intent(); | 129 | Intent intent1 = new Intent(); |
131 | intent1.setClass(this, ElectronicCardValidationActivity.class); | 130 | intent1.setClass(this, ElectronicCardValidationActivity.class); |
132 | startActivity(intent1); | 131 | startActivity(intent1); |
133 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 132 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
134 | 133 | ||
135 | 134 | ||
136 | break; | 135 | break; |
137 | case R.id.cancel: | 136 | case R.id.cancel: |
138 | finish(); | 137 | finish(); |
139 | break; | 138 | break; |
140 | } | 139 | } |
141 | } | 140 | } |
142 | 141 | ||
143 | } | 142 | } |
144 | 143 |
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 | SysApplication.getInstance().addActivity(this); | 82 | SysApplication.getInstance().addActivity(this); |
83 | initView(); | 83 | initView(); |
84 | initData(); | 84 | initData(); |
85 | initLister(); | 85 | initLister(); |
86 | } | 86 | } |
87 | 87 | ||
88 | private void initView() { | 88 | private void initView() { |
89 | btn_card_valiyanzhen = (Button) findViewById(R.id.btn_card_valiyanzhen); | 89 | btn_card_valiyanzhen = (Button) findViewById(R.id.btn_card_valiyanzhen); |
90 | get_authcode = (Button) findViewById(R.id.btn_authcode); | 90 | get_authcode = (Button) findViewById(R.id.btn_authcode); |
91 | anth_6num = (EditText) findViewById(R.id.et_authcode); | 91 | anth_6num = (EditText) findViewById(R.id.et_authcode); |
92 | phonenumber = (EditText) findViewById(R.id.et_phonenumber); | 92 | phonenumber = (EditText) findViewById(R.id.et_phonenumber); |
93 | menu_title = (TextView) findViewById(R.id.menu_title); | 93 | menu_title = (TextView) findViewById(R.id.menu_title); |
94 | cancel = (ImageView) findViewById(R.id.cancel); | 94 | cancel = (ImageView) findViewById(R.id.cancel); |
95 | } | 95 | } |
96 | 96 | ||
97 | private void initData() { | 97 | private void initData() { |
98 | if (Content.authcodeflag==1){ | 98 | if (Content.authcodeflag==1){ |
99 | menu_title.setText("更换绑定"); | 99 | menu_title.setText("更换绑定"); |
100 | btn_card_valiyanzhen.setText("确定"); | 100 | btn_card_valiyanzhen.setText("确定"); |
101 | 101 | ||
102 | }else if (Content.authcodeflag==2){ | 102 | }else if (Content.authcodeflag==2){ |
103 | menu_title.setText("修改保卡信息"); | 103 | menu_title.setText("修改保卡信息"); |
104 | btn_card_valiyanzhen.setText("确定"); | 104 | btn_card_valiyanzhen.setText("确定"); |
105 | 105 | ||
106 | }else { | 106 | }else { |
107 | menu_title.setText("填写保卡信息"); | 107 | menu_title.setText("填写保卡信息"); |
108 | btn_card_valiyanzhen.setText("下一步"); | 108 | btn_card_valiyanzhen.setText("下一步"); |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | private void initLister() { | 115 | private void initLister() { |
116 | get_authcode.setOnClickListener(this); | 116 | get_authcode.setOnClickListener(this); |
117 | btn_card_valiyanzhen.setOnClickListener(this); | 117 | btn_card_valiyanzhen.setOnClickListener(this); |
118 | cancel.setOnClickListener(this); | 118 | cancel.setOnClickListener(this); |
119 | 119 | ||
120 | } | 120 | } |
121 | 121 | ||
122 | @Override | 122 | @Override |
123 | public void onClick(View v) { | 123 | public void onClick(View v) { |
124 | switch (v.getId()){ | 124 | switch (v.getId()){ |
125 | case R.id.btn_card_valiyanzhen: | 125 | case R.id.btn_card_valiyanzhen: |
126 | 126 | ||
127 | String usernameStr = phonenumber.getText().toString().trim(); | 127 | String usernameStr = phonenumber.getText().toString().trim(); |
128 | String authcodeStr = anth_6num.getText().toString().trim(); | 128 | String authcodeStr = anth_6num.getText().toString().trim(); |
129 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)) { | 129 | if (TextUtils.isEmpty(usernameStr) || TextUtils.isEmpty(authcodeStr)) { |
130 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号,和验证码不能为空"); | 130 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号,和验证码不能为空"); |
131 | return; | 131 | return; |
132 | } else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ | 132 | } else if (!PhoneNumCheckUtils.isPhone(usernameStr)){ |
133 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号码输入错误"); | 133 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "手机号码输入错误"); |
134 | 134 | ||
135 | }else if (!authcode.equals(authcodeStr)){ | 135 | }else if (!authcode.equals(authcodeStr)){ |
136 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确"); | 136 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确"); |
137 | }else { | 137 | }else { |
138 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 138 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
139 | int auserID = 0; | 139 | Long auserID = null; |
140 | try { | 140 | try { |
141 | auserID = Integer.parseInt(userID); | 141 | auserID = Long.parseLong(userID); |
142 | } catch (NumberFormatException e) { | 142 | } catch (NumberFormatException e) { |
143 | e.printStackTrace(); | 143 | e.printStackTrace(); |
144 | } | 144 | } |
145 | if (Content.authcodeflag==1){ | 145 | if (Content.authcodeflag==1){ |
146 | //修改账户手机号 | 146 | //修改账户手机号 |
147 | HttpManager.getInstance().changecardinfophone(this, | 147 | HttpManager.getInstance().changeaccountphone(this, |
148 | auserID,usernameStr,authcodeStr); | 148 | auserID,usernameStr,authcodeStr); |
149 | 149 | ||
150 | }else if (Content.authcodeflag==2){ | 150 | }else if (Content.authcodeflag==2){ |
151 | //修改保卡手机号 | 151 | //修改保卡手机号 |
152 | HttpManager.getInstance().changecardinfophone(this, | 152 | HttpManager.getInstance().changecardinfophone(this, |
153 | auserID,usernameStr,authcodeStr); | 153 | auserID,usernameStr,authcodeStr); |
154 | }else { | 154 | }else { |
155 | String phone =phonenumber.getText().toString().trim(); | 155 | String phone =phonenumber.getText().toString().trim(); |
156 | SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phone ); | 156 | SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phone ); |
157 | Intent intent = new Intent(); | 157 | Intent intent = new Intent(); |
158 | intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); | 158 | intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); |
159 | startActivity(intent); | 159 | startActivity(intent); |
160 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 160 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
161 | } | 161 | } |
162 | // SaveParam.getInstance().saveLoginParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim()); | 162 | // SaveParam.getInstance().saveLoginParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim()); |
163 | // Intent intent = new Intent(); | 163 | // Intent intent = new Intent(); |
164 | // intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); | 164 | // intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class); |
165 | // startActivity(intent); | 165 | // startActivity(intent); |
166 | // overridePendingTransition(R.anim.rightin, R.anim.rightout); | 166 | // overridePendingTransition(R.anim.rightin, R.anim.rightout); |
167 | } | 167 | } |
168 | break; | 168 | break; |
169 | case R.id.btn_authcode: | 169 | case R.id.btn_authcode: |
170 | String usernameStr1 = phonenumber.getText().toString().trim(); | 170 | String usernameStr1 = phonenumber.getText().toString().trim(); |
171 | if (!PhoneNumCheckUtils.isPhone(usernameStr1)){ | 171 | if (!PhoneNumCheckUtils.isPhone(usernameStr1)){ |
172 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "请输入正确的手机号"); | 172 | AlertUtils.showToast(ElectronicCardValidationActivity.this, "请输入正确的手机号"); |
173 | }else { | 173 | }else { |
174 | anth_6num.requestFocus(); | 174 | anth_6num.requestFocus(); |
175 | HttpManager.getInstance().authCode(typeStr, usernameStr1, handler, ElectronicCardValidationActivity.this); | 175 | HttpManager.getInstance().authCode(typeStr, usernameStr1, handler, ElectronicCardValidationActivity.this); |
176 | valiDelay(); | 176 | valiDelay(); |
177 | 177 | ||
178 | } | 178 | } |
179 | 179 | ||
180 | break; | 180 | break; |
181 | case R.id.cancel: | 181 | case R.id.cancel: |
182 | finish(); | 182 | finish(); |
183 | break; | 183 | break; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | // 线程类 定时器 | 186 | // 线程类 定时器 |
187 | public void valiDelay() { | 187 | public void valiDelay() { |
188 | 188 | ||
189 | Delaytimer = new java.util.Timer(true); | 189 | Delaytimer = new java.util.Timer(true); |
190 | 190 | ||
191 | 191 | ||
192 | TimerTask task = new TimerTask() { | 192 | TimerTask task = new TimerTask() { |
193 | public void run() { | 193 | public void run() { |
194 | //每次需要执行的代码放到这里面。 | 194 | //每次需要执行的代码放到这里面。 |
195 | delayTime--; | 195 | delayTime--; |
196 | handler.sendEmptyMessage(21); | 196 | handler.sendEmptyMessage(21); |
197 | } | 197 | } |
198 | }; | 198 | }; |
199 | Delaytimer.schedule(task, 1000,1000); | 199 | Delaytimer.schedule(task, 1000,1000); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.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.content.pm.PackageManager; | 4 | import android.content.pm.PackageManager; |
5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.provider.MediaStore; | 9 | import android.provider.MediaStore; |
10 | import android.support.annotation.NonNull; | 10 | import android.support.annotation.NonNull; |
11 | import android.support.v4.content.FileProvider; | 11 | import android.support.v4.content.FileProvider; |
12 | import android.support.v7.app.AppCompatActivity; | 12 | import android.support.v7.app.AppCompatActivity; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.view.Gravity; | 14 | import android.view.Gravity; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | import android.widget.AdapterView; | 16 | import android.widget.AdapterView; |
17 | import android.widget.EditText; | 17 | import android.widget.EditText; |
18 | import android.widget.ImageView; | 18 | import android.widget.ImageView; |
19 | import android.widget.TextView; | 19 | import android.widget.TextView; |
20 | import android.widget.Toast; | 20 | import android.widget.Toast; |
21 | 21 | ||
22 | import com.facebook.drawee.backends.pipeline.Fresco; | 22 | import com.facebook.drawee.backends.pipeline.Fresco; |
23 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 23 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
24 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 24 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
25 | import com.facebook.drawee.generic.RoundingParams; | 25 | import com.facebook.drawee.generic.RoundingParams; |
26 | import com.facebook.drawee.interfaces.DraweeController; | 26 | import com.facebook.drawee.interfaces.DraweeController; |
27 | import com.facebook.drawee.view.SimpleDraweeView; | 27 | import com.facebook.drawee.view.SimpleDraweeView; |
28 | import com.hjx.personalcenter.R; | 28 | import com.hjx.personalcenter.R; |
29 | import com.hjx.personalcenter.db.SaveParam; | 29 | import com.hjx.personalcenter.db.SaveParam; |
30 | import com.hjx.personalcenter.http.HttpManager; | 30 | import com.hjx.personalcenter.http.HttpManager; |
31 | import com.hjx.personalcenter.util.AlertUtils; | 31 | import com.hjx.personalcenter.util.AlertUtils; |
32 | import com.hjx.personalcenter.util.CropUtils; | 32 | import com.hjx.personalcenter.util.CropUtils; |
33 | import com.hjx.personalcenter.util.DialogPermission; | 33 | import com.hjx.personalcenter.util.DialogPermission; |
34 | import com.hjx.personalcenter.util.FileUtil; | 34 | import com.hjx.personalcenter.util.FileUtil; |
35 | import com.hjx.personalcenter.util.PermissionUtil; | 35 | import com.hjx.personalcenter.util.PermissionUtil; |
36 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 36 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
37 | import com.mylhyl.circledialog.CircleDialog; | 37 | import com.mylhyl.circledialog.CircleDialog; |
38 | import com.mylhyl.circledialog.callback.ConfigButton; | 38 | import com.mylhyl.circledialog.callback.ConfigButton; |
39 | import com.mylhyl.circledialog.callback.ConfigDialog; | 39 | import com.mylhyl.circledialog.callback.ConfigDialog; |
40 | import com.mylhyl.circledialog.params.ButtonParams; | 40 | import com.mylhyl.circledialog.params.ButtonParams; |
41 | import com.mylhyl.circledialog.params.DialogParams; | 41 | import com.mylhyl.circledialog.params.DialogParams; |
42 | 42 | ||
43 | import java.io.File; | 43 | import java.io.File; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Created by h on 2017/8/11. | 46 | * Created by h on 2017/8/11. |
47 | */ | 47 | */ |
48 | 48 | ||
49 | public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener { | 49 | public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener { |
50 | private ImageView iv_cance, iv_show, iv_take; | 50 | private ImageView iv_cance, iv_show, iv_take; |
51 | private EditText content, phone; | 51 | private EditText content, phone; |
52 | private TextView tv_sub; | 52 | private TextView tv_sub; |
53 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 53 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
54 | private static final int REQUEST_CODE_ALBUM = 2; | 54 | private static final int REQUEST_CODE_ALBUM = 2; |
55 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 55 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
56 | SimpleDraweeView mSimpleDraweeView; | 56 | SimpleDraweeView mSimpleDraweeView; |
57 | String type = "个人中心"; | 57 | String type = "个人中心"; |
58 | private File file; | 58 | private File file; |
59 | private Uri uri; | 59 | private Uri uri; |
60 | 60 | ||
61 | @Override | 61 | @Override |
62 | protected void onCreate(Bundle savedInstanceState) { | 62 | protected void onCreate(Bundle savedInstanceState) { |
63 | super.onCreate(savedInstanceState); | 63 | super.onCreate(savedInstanceState); |
64 | Fresco.initialize(this); | 64 | Fresco.initialize(this); |
65 | setContentView(R.layout.activity_feedback); | 65 | setContentView(R.layout.activity_feedback); |
66 | SysApplication.getInstance().addActivity(this); | ||
67 | initView(); | 66 | initView(); |
68 | initData(); | 67 | initData(); |
69 | initLister(); | 68 | initLister(); |
70 | } | 69 | } |
71 | 70 | ||
72 | private void initView() { | 71 | private void initView() { |
73 | iv_cance = (ImageView) findViewById(R.id.cancel); | 72 | iv_cance = (ImageView) findViewById(R.id.cancel); |
74 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv); | 73 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv); |
75 | iv_take = (ImageView) findViewById(R.id.iv_take); | 74 | iv_take = (ImageView) findViewById(R.id.iv_take); |
76 | content = (EditText) findViewById(R.id.feedback_content); | 75 | content = (EditText) findViewById(R.id.feedback_content); |
77 | phone = (EditText) findViewById(R.id.feedback_phone); | 76 | phone = (EditText) findViewById(R.id.feedback_phone); |
78 | tv_sub = (TextView) findViewById(R.id.feedback_sub); | 77 | tv_sub = (TextView) findViewById(R.id.feedback_sub); |
79 | 78 | ||
80 | } | 79 | } |
81 | 80 | ||
82 | private void initData() { | 81 | private void initData() { |
83 | file = new File(FileUtil.getCachePath(this), "user-feedback.jpg"); | 82 | file = new File(FileUtil.getCachePath(this), "user-feedback.jpg"); |
84 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 83 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
85 | uri = Uri.fromFile(file); | 84 | uri = Uri.fromFile(file); |
86 | } else { | 85 | } else { |
87 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 86 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
88 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 87 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
89 | } | 88 | } |
90 | 89 | ||
91 | } | 90 | } |
92 | 91 | ||
93 | private void initLister() { | 92 | private void initLister() { |
94 | iv_cance.setOnClickListener(this); | 93 | iv_cance.setOnClickListener(this); |
95 | iv_take.setOnClickListener(this); | 94 | iv_take.setOnClickListener(this); |
96 | tv_sub.setOnClickListener(this); | 95 | tv_sub.setOnClickListener(this); |
97 | mSimpleDraweeView.setOnClickListener(this); | 96 | mSimpleDraweeView.setOnClickListener(this); |
98 | 97 | ||
99 | } | 98 | } |
100 | 99 | ||
101 | @Override | 100 | @Override |
102 | public void onClick(View v) { | 101 | public void onClick(View v) { |
103 | String contents = content.getText().toString().trim(); | 102 | String contents = content.getText().toString().trim(); |
104 | String contants = phone.getText().toString().trim(); | 103 | String contants = phone.getText().toString().trim(); |
105 | switch (v.getId()) { | 104 | switch (v.getId()) { |
106 | case R.id.cancel: | 105 | case R.id.cancel: |
107 | finish(); | 106 | finish(); |
108 | break; | 107 | break; |
109 | case R.id.iv_take: | 108 | case R.id.iv_take: |
110 | choiceAvatar(); | 109 | choiceAvatar(); |
111 | break; | 110 | break; |
112 | case R.id.feedback_sub: | 111 | case R.id.feedback_sub: |
113 | //提交用户反馈 | 112 | //提交用户反馈 |
114 | if (TextUtils.isEmpty(contents)) { | 113 | if (TextUtils.isEmpty(contents)) { |
115 | AlertUtils.showToast(FeedBackActivity.this, "请将必填项填写完整"); | 114 | AlertUtils.showToast(FeedBackActivity.this, "请将必填项填写完整"); |
116 | return; | 115 | return; |
117 | } | 116 | } |
118 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 117 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
119 | try { | 118 | try { |
120 | HttpManager.getInstance().feedback(FeedBackActivity.this, userID, | 119 | HttpManager.getInstance().feedback(FeedBackActivity.this, userID, |
121 | contents,contants,file.getPath(),type); | 120 | contents,contants,file.getPath(),type); |
122 | } catch (Exception e) { | 121 | } catch (Exception e) { |
123 | e.printStackTrace(); | 122 | e.printStackTrace(); |
124 | } | 123 | } |
125 | break; | 124 | break; |
126 | case R.id.show_iv: | 125 | case R.id.show_iv: |
127 | 126 | ||
128 | 127 | ||
129 | break; | 128 | break; |
130 | } | 129 | } |
131 | } | 130 | } |
132 | 131 | ||
133 | //拍摄头像 | 132 | //拍摄头像 |
134 | private void choiceAvatar() { | 133 | private void choiceAvatar() { |
135 | final String[] items = {"拍照", "从相册选择"}; | 134 | final String[] items = {"拍照", "从相册选择"}; |
136 | new CircleDialog.Builder(this) | 135 | new CircleDialog.Builder(this) |
137 | .configDialog(new ConfigDialog() { | 136 | .configDialog(new ConfigDialog() { |
138 | @Override | 137 | @Override |
139 | public void onConfig(DialogParams params) { | 138 | public void onConfig(DialogParams params) { |
140 | //增加弹出动画 | 139 | //增加弹出动画 |
141 | params.gravity = Gravity.CENTER; | 140 | params.gravity = Gravity.CENTER; |
142 | } | 141 | } |
143 | }) | 142 | }) |
144 | .setTitle("请选择图片来源") | 143 | .setTitle("请选择图片来源") |
145 | .setWidth(0.5f) | 144 | .setWidth(0.5f) |
146 | .setItems(items, new AdapterView.OnItemClickListener() { | 145 | .setItems(items, new AdapterView.OnItemClickListener() { |
147 | @Override | 146 | @Override |
148 | public void onItemClick(AdapterView<?> parent, View view, int | 147 | public void onItemClick(AdapterView<?> parent, View view, int |
149 | position, long id) { | 148 | position, long id) { |
150 | switch (position) { | 149 | switch (position) { |
151 | case 0: | 150 | case 0: |
152 | if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) { | 151 | if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) { |
153 | uploadAvatarFromPhotoRequest(); | 152 | uploadAvatarFromPhotoRequest(); |
154 | } | 153 | } |
155 | break; | 154 | break; |
156 | case 1: | 155 | case 1: |
157 | uploadAvatarFromAlbumRequest(); | 156 | uploadAvatarFromAlbumRequest(); |
158 | break; | 157 | break; |
159 | } | 158 | } |
160 | 159 | ||
161 | } | 160 | } |
162 | }) | 161 | }) |
163 | .setNegative("取消", null) | 162 | .setNegative("取消", null) |
164 | .configNegative(new ConfigButton() { | 163 | .configNegative(new ConfigButton() { |
165 | @Override | 164 | @Override |
166 | public void onConfig(ButtonParams params) { | 165 | public void onConfig(ButtonParams params) { |
167 | //取消按钮字体颜色 | 166 | //取消按钮字体颜色 |
168 | params.textColor = Color.RED; | 167 | params.textColor = Color.RED; |
169 | } | 168 | } |
170 | }) | 169 | }) |
171 | .show(); | 170 | .show(); |
172 | 171 | ||
173 | 172 | ||
174 | } | 173 | } |
175 | 174 | ||
176 | //照相 | 175 | //照相 |
177 | private void uploadAvatarFromPhotoRequest() { | 176 | private void uploadAvatarFromPhotoRequest() { |
178 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 177 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
179 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 178 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
180 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 179 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
181 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 180 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
182 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 181 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
183 | } | 182 | } |
184 | 183 | ||
185 | //选择图库 | 184 | //选择图库 |
186 | private void uploadAvatarFromAlbumRequest() { | 185 | private void uploadAvatarFromAlbumRequest() { |
187 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 186 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
188 | photoPickerIntent.setType("image/*"); | 187 | photoPickerIntent.setType("image/*"); |
189 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 188 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
190 | } | 189 | } |
191 | 190 | ||
192 | //回掉 | 191 | //回掉 |
193 | @Override | 192 | @Override |
194 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 193 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
195 | super.onActivityResult(requestCode, resultCode, data); | 194 | super.onActivityResult(requestCode, resultCode, data); |
196 | if (resultCode != -1) { | 195 | if (resultCode != -1) { |
197 | return; | 196 | return; |
198 | } | 197 | } |
199 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 198 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
200 | Uri newUri; | 199 | Uri newUri; |
201 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 200 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
202 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 201 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
203 | } else { | 202 | } else { |
204 | newUri = data.getData(); | 203 | newUri = data.getData(); |
205 | } | 204 | } |
206 | if (newUri != null) { | 205 | if (newUri != null) { |
207 | uploadAvatarFromPhoto(); | 206 | //uploadAvatarFromPhoto(); |
208 | //裁剪图片 | 207 | //裁剪图片 |
209 | //startPhotoZoom(newUri); | 208 | startPhotoZoom(newUri); |
210 | } else { | 209 | } else { |
211 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 210 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
212 | } | 211 | } |
213 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 212 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
214 | uploadAvatarFromPhoto(); | 213 | uploadAvatarFromPhoto(); |
215 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 214 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
216 | uploadAvatarFromPhoto(); | 215 | uploadAvatarFromPhoto(); |
217 | } | 216 | } |
218 | } | 217 | } |
219 | 218 | ||
220 | private void uploadAvatarFromPhoto() { | 219 | private void uploadAvatarFromPhoto() { |
221 | compressAndUploadAvatar(file.getPath()); | 220 | compressAndUploadAvatar(file.getPath()); |
222 | 221 | ||
223 | } | 222 | } |
224 | 223 | ||
225 | private void compressAndUploadAvatar(String fileSrc) { | 224 | private void compressAndUploadAvatar(String fileSrc) { |
226 | 225 | ||
227 | 226 | ||
228 | //上传到服务器 | 227 | //上传到服务器 |
229 | 228 | ||
230 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 229 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
231 | String mimeType = "image/*"; | 230 | String mimeType = "image/*"; |
232 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 231 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
233 | //String fileName = cover.getName(); | 232 | //String fileName = cover.getName(); |
234 | //HttpManager.getInstance().header(this, fileSrc); | 233 | //HttpManager.getInstance().header(this, fileSrc); |
235 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 234 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
236 | //Fresco设置圆形头像 | 235 | //Fresco设置圆形头像 |
237 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 236 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
238 | GenericDraweeHierarchy hierarchy = builder | 237 | GenericDraweeHierarchy hierarchy = builder |
239 | .setDesiredAspectRatio(1f) | 238 | .setDesiredAspectRatio(1f) |
240 | .setFailureImage(R.mipmap.blank) | 239 | .setFailureImage(R.mipmap.blank) |
241 | //圆形头像 | 240 | //圆形头像 |
242 | .setRoundingParams(RoundingParams.fromCornersRadius(0.7f)) | 241 | .setRoundingParams(RoundingParams.fromCornersRadius(0.7f)) |
243 | .build(); | 242 | .build(); |
244 | 243 | ||
245 | //加载本地图片 | 244 | //加载本地图片 |
246 | Uri uri = Uri.fromFile(cover); | 245 | Uri uri = Uri.fromFile(cover); |
247 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 246 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
248 | .setOldController(mSimpleDraweeView.getController()) | 247 | .setOldController(mSimpleDraweeView.getController()) |
249 | .setUri(uri) | 248 | .setUri(uri) |
250 | .build(); | 249 | .build(); |
251 | mSimpleDraweeView.setHierarchy(hierarchy); | 250 | mSimpleDraweeView.setHierarchy(hierarchy); |
252 | mSimpleDraweeView.setController(controller); | 251 | mSimpleDraweeView.setController(controller); |
253 | 252 | ||
254 | } | 253 | } |
255 | 254 | ||
256 | public void startPhotoZoom(Uri uri) { | 255 | public void startPhotoZoom(Uri uri) { |
257 | Intent intent = new Intent("com.android.camera.action.CROP"); | 256 | Intent intent = new Intent("com.android.camera.action.CROP"); |
258 | intent.setDataAndType(uri, "image/*"); | 257 | intent.setDataAndType(uri, "image/*"); |
259 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 258 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
260 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 259 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
261 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 260 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
262 | intent.putExtra("aspectY", 1);// x:y=1:1 | 261 | intent.putExtra("aspectY", 1);// x:y=1:1 |
263 | // intent.putExtra("outputX", 400);//图片输出大小 | 262 | // intent.putExtra("outputX", 400);//图片输出大小 |
264 | // intent.putExtra("outputY", 400); | 263 | // intent.putExtra("outputY", 400); |
265 | intent.putExtra("output", Uri.fromFile(file)); | 264 | intent.putExtra("output", Uri.fromFile(file)); |
266 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 265 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
267 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 266 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
268 | } | 267 | } |
269 | 268 | ||
270 | @Override | 269 | @Override |
271 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 270 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
272 | switch (requestCode) { | 271 | switch (requestCode) { |
273 | 272 | ||
274 | case PermissionUtil.REQUEST_SHOWCAMERA: | 273 | case PermissionUtil.REQUEST_SHOWCAMERA: |
275 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 274 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
276 | // Permission Granted | 275 | // Permission Granted |
277 | uploadAvatarFromPhotoRequest(); | 276 | uploadAvatarFromPhotoRequest(); |
278 | 277 | ||
279 | } else { | 278 | } else { |
280 | if (!SharedPreferenceMark.getHasShowCamera()) { | 279 | if (!SharedPreferenceMark.getHasShowCamera()) { |
281 | SharedPreferenceMark.setHasShowCamera(true); | 280 | SharedPreferenceMark.setHasShowCamera(true); |
282 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 281 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
283 | 282 | ||
284 | } else { | 283 | } else { |
285 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 284 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
286 | .show(); | 285 | .show(); |
287 | } | 286 | } |
288 | } | 287 | } |
289 | break; | 288 | break; |
290 | default: | 289 | default: |
291 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 290 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
292 | } | 291 | } |
293 | } | 292 | } |
294 | } | 293 | } |
295 | 294 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ForgotPasswordActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.os.Handler; | 4 | import android.os.Handler; |
5 | import android.os.Message; | 5 | import android.os.Message; |
6 | import android.support.v7.app.AppCompatActivity; | 6 | import android.support.v7.app.AppCompatActivity; |
7 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
8 | import android.text.method.HideReturnsTransformationMethod; | 8 | import android.text.method.HideReturnsTransformationMethod; |
9 | import android.text.method.PasswordTransformationMethod; | 9 | import android.text.method.PasswordTransformationMethod; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.widget.Button; | 11 | import android.widget.Button; |
12 | import android.widget.EditText; | 12 | import android.widget.EditText; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.http.HttpCode; | 16 | import com.hjx.personalcenter.http.HttpCode; |
17 | import com.hjx.personalcenter.http.HttpManager; | 17 | import com.hjx.personalcenter.http.HttpManager; |
18 | import com.hjx.personalcenter.util.AlertUtils; | 18 | import com.hjx.personalcenter.util.AlertUtils; |
19 | import com.hjx.personalcenter.util.Judgment; | 19 | import com.hjx.personalcenter.util.Judgment; |
20 | import com.hjx.personalcenter.util.PasswordCheckUtils; | 20 | import com.hjx.personalcenter.util.PasswordCheckUtils; |
21 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 21 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
22 | 22 | ||
23 | import org.json.JSONException; | 23 | import org.json.JSONException; |
24 | import org.json.JSONObject; | 24 | import org.json.JSONObject; |
25 | 25 | ||
26 | import java.util.TimerTask; | 26 | import java.util.TimerTask; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * 忘记密码 | 29 | * 忘记密码 |
30 | * Created by h on 2017/6/17. | 30 | * Created by h on 2017/6/17. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener { | 33 | public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener { |
34 | private ImageView back_forgit, iv_pwd_change; | 34 | private ImageView back_forgit, iv_pwd_change; |
35 | private EditText forot_pwd_phone, forot_pwd_anthcode, forot_pwd_pwd, forot_pwd_pwd2; | 35 | private EditText forot_pwd_phone, forot_pwd_anthcode, forot_pwd_pwd, forot_pwd_pwd2; |
36 | private Button forot_pwd_sub, forot_pwd_getanthcode; | 36 | private Button forot_pwd_sub, forot_pwd_getanthcode; |
37 | private String forot_pwd_phone1; | 37 | private String forot_pwd_phone1; |
38 | private String forot_pwd_anthcode1; | 38 | private String forot_pwd_anthcode1; |
39 | private String forot_pwd_pwd3; | 39 | private String forot_pwd_pwd3; |
40 | private String forot_pwd_pwd4; | 40 | private String forot_pwd_pwd4; |
41 | private String typeStr = "login"; | 41 | private String typeStr = "login"; |
42 | private int delayTime=60; | 42 | private int delayTime=60; |
43 | private java.util.Timer Delaytimer; | 43 | private java.util.Timer Delaytimer; |
44 | public static Boolean showPassword = false; | 44 | public static Boolean showPassword = false; |
45 | 45 | ||
46 | Handler handler = new Handler() { | 46 | Handler handler = new Handler() { |
47 | @Override | 47 | @Override |
48 | public void handleMessage(Message msg) { | 48 | public void handleMessage(Message msg) { |
49 | super.handleMessage(msg); | 49 | super.handleMessage(msg); |
50 | try { | 50 | try { |
51 | JSONObject jsonObject; | 51 | JSONObject jsonObject; |
52 | String status; | 52 | String status; |
53 | switch (msg.what) { | 53 | switch (msg.what) { |
54 | case HttpCode.PASSWORD_SUCESS: | 54 | case HttpCode.PASSWORD_SUCESS: |
55 | jsonObject = (JSONObject) msg.obj; | 55 | jsonObject = (JSONObject) msg.obj; |
56 | status = jsonObject.getString("status"); | 56 | status = jsonObject.getString("status"); |
57 | // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); | 57 | // AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); |
58 | if (status.equals("100")) { | 58 | if (status.equals("100")) { |
59 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改成功"); | 59 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改成功"); |
60 | } | 60 | } |
61 | 61 | ||
62 | break; | 62 | break; |
63 | case HttpCode.PASSWORD_FAIL: | 63 | case HttpCode.PASSWORD_FAIL: |
64 | jsonObject = (JSONObject) msg.obj; | 64 | jsonObject = (JSONObject) msg.obj; |
65 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。"); | 65 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码修改失败,请检查网络是否畅通。"); |
66 | break; | 66 | break; |
67 | case HttpCode.AUTHCODE_SUCESS1: | 67 | case HttpCode.AUTHCODE_SUCESS1: |
68 | jsonObject = (JSONObject) msg.obj; | 68 | jsonObject = (JSONObject) msg.obj; |
69 | status = jsonObject.optString("status"); | 69 | status = jsonObject.optString("status"); |
70 | if (status.equals("100")) { | 70 | if (status.equals("100")) { |
71 | AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功"); | 71 | AlertUtils.showToast(ForgotPasswordActivity.this, "验证码发送成功"); |
72 | } | 72 | } |
73 | //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); | 73 | //AlertUtils.showToast(ForgotPassword.this, jsonObject.optString("message")); |
74 | break; | 74 | break; |
75 | case HttpCode.AUTHCODE_FAIL1: | 75 | case HttpCode.AUTHCODE_FAIL1: |
76 | jsonObject = (JSONObject) msg.obj; | 76 | jsonObject = (JSONObject) msg.obj; |
77 | AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络")); | 77 | AlertUtils.showToast(ForgotPasswordActivity.this, jsonObject.optString("验证码发送失败,请检查网络")); |
78 | break; | 78 | break; |
79 | case HttpCode.IS_REFISTER: | 79 | case HttpCode.IS_REFISTER: |
80 | jsonObject = (JSONObject) msg.obj; | 80 | jsonObject = (JSONObject) msg.obj; |
81 | status = jsonObject.getString("status"); | 81 | status = jsonObject.getString("status"); |
82 | if (status.equals("true")) { | 82 | if (status.equals("true")) { |
83 | getauthcode(); | 83 | getauthcode(); |
84 | 84 | ||
85 | } else { | 85 | } else { |
86 | AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册"); | 86 | AlertUtils.showToast(ForgotPasswordActivity.this, "该手机号没有注册"); |
87 | } | 87 | } |
88 | break; | 88 | break; |
89 | case 21: | 89 | case 21: |
90 | 90 | ||
91 | if(delayTime<=0){ | 91 | if(delayTime<=0){ |
92 | if(Delaytimer!=null){ | 92 | if(Delaytimer!=null){ |
93 | Delaytimer.cancel(); | 93 | Delaytimer.cancel(); |
94 | } | 94 | } |
95 | forot_pwd_getanthcode.setEnabled(true); | 95 | forot_pwd_getanthcode.setEnabled(true); |
96 | forot_pwd_getanthcode.setClickable(true); | 96 | forot_pwd_getanthcode.setClickable(true); |
97 | forot_pwd_getanthcode.setText("获取验证码"); | 97 | forot_pwd_getanthcode.setText("获取验证码"); |
98 | delayTime=60; | 98 | delayTime=60; |
99 | }else{ | 99 | }else{ |
100 | forot_pwd_getanthcode.setEnabled(false); | 100 | forot_pwd_getanthcode.setEnabled(false); |
101 | forot_pwd_getanthcode.setClickable(false); | 101 | forot_pwd_getanthcode.setClickable(false); |
102 | forot_pwd_getanthcode.setText(delayTime + " s"); | 102 | forot_pwd_getanthcode.setText(delayTime + " s"); |
103 | } | 103 | } |
104 | break; | 104 | break; |
105 | } | 105 | } |
106 | } catch (JSONException e) { | 106 | } catch (JSONException e) { |
107 | e.printStackTrace(); | 107 | e.printStackTrace(); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | }; | 110 | }; |
111 | 111 | ||
112 | @Override | 112 | @Override |
113 | protected void onCreate(Bundle savedInstanceState) { | 113 | protected void onCreate(Bundle savedInstanceState) { |
114 | super.onCreate(savedInstanceState); | 114 | super.onCreate(savedInstanceState); |
115 | setContentView(R.layout.activity_forgetpsword); | 115 | setContentView(R.layout.activity_forgetpsword); |
116 | SysApplication.getInstance().addActivity(this); | ||
117 | initView(); | 116 | initView(); |
118 | setLister(); | 117 | setLister(); |
119 | } | 118 | } |
120 | 119 | ||
121 | //获取验证码 | 120 | //获取验证码 |
122 | private void getauthcode() { | 121 | private void getauthcode() { |
123 | forot_pwd_anthcode.requestFocus(); | 122 | forot_pwd_anthcode.requestFocus(); |
124 | HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this); | 123 | HttpManager.getInstance().authCode(typeStr, forot_pwd_phone1, handler, this); |
125 | valiDelay(); | 124 | valiDelay(); |
126 | 125 | ||
127 | } | 126 | } |
128 | 127 | ||
129 | private void initView() { | 128 | private void initView() { |
130 | forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber); | 129 | forot_pwd_phone = (EditText) findViewById(R.id.et_phonenumber); |
131 | forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode); | 130 | forot_pwd_anthcode = (EditText) findViewById(R.id.et_authcode); |
132 | forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword); | 131 | forot_pwd_pwd = (EditText) findViewById(R.id.et_newpassword); |
133 | forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword); | 132 | forot_pwd_pwd2 = (EditText) findViewById(R.id.et_again_newpassword); |
134 | forot_pwd_sub = (Button) findViewById(R.id.btn_ok); | 133 | forot_pwd_sub = (Button) findViewById(R.id.btn_ok); |
135 | forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode); | 134 | forot_pwd_getanthcode = (Button) findViewById(R.id.btn_authcode); |
136 | iv_pwd_change = (ImageView) findViewById(R.id.iv_pwd_change); | 135 | iv_pwd_change = (ImageView) findViewById(R.id.iv_pwd_change); |
137 | back_forgit = (ImageView) findViewById(R.id.cancel); | 136 | back_forgit = (ImageView) findViewById(R.id.cancel); |
138 | } | 137 | } |
139 | 138 | ||
140 | private void setLister() { | 139 | private void setLister() { |
141 | iv_pwd_change.setOnClickListener(this); | 140 | iv_pwd_change.setOnClickListener(this); |
142 | back_forgit.setOnClickListener(this); | 141 | back_forgit.setOnClickListener(this); |
143 | forot_pwd_sub.setOnClickListener(this); | 142 | forot_pwd_sub.setOnClickListener(this); |
144 | forot_pwd_getanthcode.setOnClickListener(this); | 143 | forot_pwd_getanthcode.setOnClickListener(this); |
145 | 144 | ||
146 | } | 145 | } |
147 | 146 | ||
148 | 147 | ||
149 | @Override | 148 | @Override |
150 | public void onClick(View view) { | 149 | public void onClick(View view) { |
151 | switch (view.getId()) { | 150 | switch (view.getId()) { |
152 | case R.id.btn_ok: | 151 | case R.id.btn_ok: |
153 | forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); | 152 | forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); |
154 | forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim(); | 153 | forot_pwd_anthcode1 = forot_pwd_anthcode.getText().toString().trim(); |
155 | forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim(); | 154 | forot_pwd_pwd3 = forot_pwd_pwd.getText().toString().trim(); |
156 | forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim(); | 155 | forot_pwd_pwd4 = forot_pwd_pwd2.getText().toString().trim(); |
157 | if (TextUtils.isEmpty(forot_pwd_phone1) || | 156 | if (TextUtils.isEmpty(forot_pwd_phone1) || |
158 | TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)) { | 157 | TextUtils.isEmpty(forot_pwd_pwd3) || TextUtils.isEmpty(forot_pwd_pwd4)) { |
159 | AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整"); | 158 | AlertUtils.showToast(ForgotPasswordActivity.this, "请将必填项填写完整"); |
160 | return; | 159 | return; |
161 | } else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)) { | 160 | } else if (Judgment.getInstance().isPhoneNum(forot_pwd_phone1)) { |
162 | AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误"); | 161 | AlertUtils.showToast(ForgotPasswordActivity.this, "手机号码输入有误"); |
163 | 162 | ||
164 | } else if (forot_pwd_pwd3.length() < 8 || forot_pwd_pwd4.length() < 8) { | 163 | } else if (forot_pwd_pwd3.length() < 8 || forot_pwd_pwd4.length() < 8) { |
165 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位"); | 164 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码不能少于8位"); |
166 | } else if (!forot_pwd_pwd3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER) || !forot_pwd_pwd4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)) { | 165 | } else if (!forot_pwd_pwd3.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER) || !forot_pwd_pwd4.matches(PasswordCheckUtils.PASSWORD_CHAR_AND_NUMBER)) { |
167 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成"); | 166 | AlertUtils.showToast(ForgotPasswordActivity.this, "密码必须由英文和数字组成"); |
168 | } else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)) { | 167 | } else if (!forot_pwd_pwd3.equals(forot_pwd_pwd4)) { |
169 | AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致"); | 168 | AlertUtils.showToast(ForgotPasswordActivity.this, "两次输入的密码不一致"); |
170 | return; | 169 | return; |
171 | } else { | 170 | } else { |
172 | //忘记密码接口 | 171 | //忘记密码接口 |
173 | HttpManager.getInstance().forgetpassword(this, forot_pwd_phone1, forot_pwd_pwd3, forot_pwd_anthcode1, handler); | 172 | HttpManager.getInstance().forgetpassword(this, forot_pwd_phone1, forot_pwd_pwd3, forot_pwd_anthcode1, handler); |
174 | } | 173 | } |
175 | break; | 174 | break; |
176 | case R.id.btn_authcode: | 175 | case R.id.btn_authcode: |
177 | forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); | 176 | forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); |
178 | if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)) { | 177 | if (!PhoneNumCheckUtils.isPhone(forot_pwd_phone1)) { |
179 | AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号"); | 178 | AlertUtils.showToast(ForgotPasswordActivity.this, "请输入正确的手机号"); |
180 | } else { | 179 | } else { |
181 | forot_pwd_anthcode.requestFocus(); | 180 | forot_pwd_anthcode.requestFocus(); |
182 | ifregister(); | 181 | ifregister(); |
183 | 182 | ||
184 | } | 183 | } |
185 | 184 | ||
186 | break; | 185 | break; |
187 | case R.id.iv_pwd_change: | 186 | case R.id.iv_pwd_change: |
188 | if (showPassword) {//显示密码 | 187 | if (showPassword) {//显示密码 |
189 | showPassword = !showPassword; | 188 | showPassword = !showPassword; |
190 | iv_pwd_change.setImageResource(R.mipmap.pwd_open); | 189 | iv_pwd_change.setImageResource(R.mipmap.pwd_open); |
191 | forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 190 | forot_pwd_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
192 | forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); | 191 | forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); |
193 | } else {//隐藏密码 | 192 | } else {//隐藏密码 |
194 | showPassword = !showPassword; | 193 | showPassword = !showPassword; |
195 | iv_pwd_change.setImageResource(R.mipmap.pwd_hide); | 194 | iv_pwd_change.setImageResource(R.mipmap.pwd_hide); |
196 | forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 195 | forot_pwd_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
197 | forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); | 196 | forot_pwd_pwd.setSelection(forot_pwd_pwd.getText().toString().length()); |
198 | } | 197 | } |
199 | break; | 198 | break; |
200 | 199 | ||
201 | case R.id.cancel: | 200 | case R.id.cancel: |
202 | finish(); | 201 | finish(); |
203 | break; | 202 | break; |
204 | } | 203 | } |
205 | } | 204 | } |
206 | 205 | ||
207 | //是否注册 | 206 | //是否注册 |
208 | private void ifregister() { | 207 | private void ifregister() { |
209 | forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); | 208 | forot_pwd_phone1 = forot_pwd_phone.getText().toString().trim(); |
210 | HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this); | 209 | HttpManager.getInstance().isregistered(forot_pwd_phone1, handler, this); |
211 | } | 210 | } |
212 | 211 | ||
213 | // 线程类 定时器 | 212 | // 线程类 定时器 |
214 | public void valiDelay() { | 213 | public void valiDelay() { |
215 | 214 | ||
216 | Delaytimer = new java.util.Timer(true); | 215 | Delaytimer = new java.util.Timer(true); |
217 | 216 | ||
218 | 217 | ||
219 | TimerTask task = new TimerTask() { | 218 | TimerTask task = new TimerTask() { |
220 | public void run() { | 219 | public void run() { |
221 | //每次需要执行的代码放到这里面。 | 220 | //每次需要执行的代码放到这里面。 |
222 | delayTime--; | 221 | delayTime--; |
223 | handler.sendEmptyMessage(21); | 222 | handler.sendEmptyMessage(21); |
224 | } | 223 | } |
225 | }; | 224 | }; |
226 | Delaytimer.schedule(task, 1000,1000); | 225 | Delaytimer.schedule(task, 1000,1000); |
227 | } | 226 | } |
228 | } | 227 | } |
229 | 228 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/LoginAndRegisterActivity.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.provider.Settings; | 5 | import android.provider.Settings; |
6 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
7 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
8 | import android.support.v4.view.ViewPager; | 8 | import android.support.v4.view.ViewPager; |
9 | import android.support.v7.app.AppCompatActivity; | 9 | import android.support.v7.app.AppCompatActivity; |
10 | import android.view.Gravity; | 10 | import android.view.Gravity; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | 12 | ||
13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; | 14 | import com.hjx.personalcenter.adapter.LoginAndRegisterAdapter; |
15 | import com.hjx.personalcenter.db.SaveParam; | 15 | import com.hjx.personalcenter.db.SaveParam; |
16 | import com.hjx.personalcenter.fragment.LoginFragment; | 16 | import com.hjx.personalcenter.fragment.LoginFragment; |
17 | import com.hjx.personalcenter.fragment.RegisterFragment; | 17 | import com.hjx.personalcenter.fragment.RegisterFragment; |
18 | import com.hjx.personalcenter.thirdparty.SlidingTabLayout; | 18 | import com.hjx.personalcenter.thirdparty.SlidingTabLayout; |
19 | import com.hjx.personalcenter.util.NetUtils; | 19 | import com.hjx.personalcenter.util.NetUtils; |
20 | import com.mylhyl.circledialog.CircleDialog; | 20 | import com.mylhyl.circledialog.CircleDialog; |
21 | import com.mylhyl.circledialog.callback.ConfigText; | 21 | import com.mylhyl.circledialog.callback.ConfigText; |
22 | import com.mylhyl.circledialog.params.TextParams; | 22 | import com.mylhyl.circledialog.params.TextParams; |
23 | 23 | ||
24 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
25 | import java.util.Arrays; | 25 | import java.util.Arrays; |
26 | import java.util.List; | 26 | import java.util.List; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * 登录和注册 熊巍 | 29 | * 登录和注册 熊巍 |
30 | * Created by h on 2017/8/8. | 30 | * Created by h on 2017/8/8. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | public class LoginAndRegisterActivity extends AppCompatActivity { | 33 | public class LoginAndRegisterActivity extends AppCompatActivity { |
34 | private ViewPager viewPager; | 34 | private ViewPager viewPager; |
35 | private SlidingTabLayout tableLayout; | 35 | private SlidingTabLayout tableLayout; |
36 | private List<Fragment> loginlist; | 36 | private List<Fragment> loginlist; |
37 | private LoginAndRegisterAdapter logindapter; | 37 | private LoginAndRegisterAdapter logindapter; |
38 | private List<String> title = Arrays.asList("登录", "注册"); | 38 | private List<String> title = Arrays.asList("登录", "注册"); |
39 | 39 | ||
40 | @Override | 40 | @Override |
41 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 41 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
42 | super.onCreate(savedInstanceState); | 42 | super.onCreate(savedInstanceState); |
43 | //检查网络 | 43 | //检查网络 |
44 | boolean isconnect = NetUtils.isNetworkConnected(this); | 44 | boolean isconnect = NetUtils.isNetworkConnected(this); |
45 | if (!isconnect){ | 45 | if (!isconnect){ |
46 | new CircleDialog.Builder(this) | 46 | new CircleDialog.Builder(this) |
47 | .setCanceledOnTouchOutside(false) | 47 | .setCanceledOnTouchOutside(false) |
48 | .setCancelable(false) | 48 | .setCancelable(false) |
49 | .setWidth(0.5f) | 49 | .setWidth(0.5f) |
50 | .configText(new ConfigText() { | 50 | .configText(new ConfigText() { |
51 | @Override | 51 | @Override |
52 | public void onConfig(TextParams params) { | 52 | public void onConfig(TextParams params) { |
53 | params.gravity = Gravity.CENTER; | 53 | params.gravity = Gravity.CENTER; |
54 | params.padding = new int[]{50, 50, 50, 50}; | 54 | params.padding = new int[]{50, 50, 50, 50}; |
55 | } | 55 | } |
56 | }) | 56 | }) |
57 | .setText("当前无网络,请检查网络设置") | 57 | .setText("当前无网络,请检查网络设置") |
58 | .setNegative("继续使用", null) | 58 | .setNegative("继续使用", null) |
59 | .setPositive("设置网络", new View.OnClickListener() { | 59 | .setPositive("设置网络", new View.OnClickListener() { |
60 | @Override | 60 | @Override |
61 | public void onClick(View v) { | 61 | public void onClick(View v) { |
62 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 62 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
63 | startActivity(intent); | 63 | startActivity(intent); |
64 | } | 64 | } |
65 | }) | 65 | }) |
66 | .show(); | 66 | .show(); |
67 | } | 67 | } |
68 | String islogin =SaveParam.getInstance().getLoginParam(this,"login"); | 68 | String islogin =SaveParam.getInstance().getLoginParam(this,"login"); |
69 | String type =SaveParam.getInstance().getCustomizeParam(LoginAndRegisterActivity.this,SaveParam.ACCOUNT); | 69 | String type =SaveParam.getInstance().getCustomizeParam(LoginAndRegisterActivity.this,SaveParam.ACCOUNT); |
70 | if (type==null){ | 70 | if (type==null){ |
71 | SaveParam.getInstance().saveCustomizeParam(LoginAndRegisterActivity.this, SaveParam.ACCOUNT,"1"); | 71 | SaveParam.getInstance().saveCustomizeParam(LoginAndRegisterActivity.this, SaveParam.ACCOUNT,"1"); |
72 | } | 72 | } |
73 | if ("true".equals(islogin)){ | 73 | if ("true".equals(islogin)){ |
74 | Intent intent = new Intent(); | 74 | Intent intent = new Intent(); |
75 | intent.setClass(this,MainActivity.class); | 75 | intent.setClass(this,MainActivity.class); |
76 | startActivity(intent); | 76 | startActivity(intent); |
77 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 77 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
78 | finish(); | 78 | finish(); |
79 | 79 | ||
80 | } | 80 | } |
81 | setContentView(R.layout.activity_loginandregister); | 81 | setContentView(R.layout.activity_loginandregister); |
82 | SysApplication.getInstance().addActivity(this); | 82 | SysApplication.getInstance().addActivity(this); |
83 | initView(); | 83 | initView(); |
84 | initData(); | 84 | initData(); |
85 | setLister(); | 85 | setLister(); |
86 | } | 86 | } |
87 | 87 | ||
88 | private void initView() { | 88 | private void initView() { |
89 | viewPager = (ViewPager) findViewById(R.id.viewpager_login); | 89 | viewPager = (ViewPager) findViewById(R.id.viewpager_login); |
90 | tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); | 90 | tableLayout = (SlidingTabLayout) findViewById(R.id.TabLayout_id); |
91 | } | 91 | } |
92 | 92 | ||
93 | private void initData() { | 93 | private void initData() { |
94 | loginlist = new ArrayList<>(); | 94 | loginlist = new ArrayList<>(); |
95 | for (int i = 0; i < title.size(); i++) { | 95 | for (int i = 0; i < title.size(); i++) { |
96 | if (title.get(i).equals("登录")) { | 96 | if (title.get(i).equals("登录")) { |
97 | loginlist.add(LoginFragment.newInstance(i + 1)); | 97 | loginlist.add(LoginFragment.newInstance(i + 1)); |
98 | } else { | 98 | } else { |
99 | loginlist.add(RegisterFragment.newInstance(i + 1)); | 99 | loginlist.add(RegisterFragment.newInstance(i + 1)); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | //设置Tab上的标题 | 104 | //设置Tab上的标题 |
105 | tableLayout.setData(title); | 105 | tableLayout.setData(title); |
106 | //设置关联的ViewPager | 106 | //设置关联的ViewPager |
107 | tableLayout.setViewPager(viewPager, 0); | 107 | tableLayout.setViewPager(viewPager, 0); |
108 | logindapter = new LoginAndRegisterAdapter(loginlist, getSupportFragmentManager()); | 108 | logindapter = new LoginAndRegisterAdapter(loginlist, getSupportFragmentManager()); |
109 | //给ViewPager设置适配器 | 109 | //给ViewPager设置适配器 |
110 | viewPager.setAdapter(logindapter); | 110 | viewPager.setAdapter(logindapter); |
111 | //设置滑动时数据不丢失 | 111 | //设置滑动时数据不丢失 |
112 | viewPager.setOffscreenPageLimit(1); | 112 | viewPager.setOffscreenPageLimit(0); |
113 | //将TabLayout和ViewPager关联起来。 | 113 | //将TabLayout和ViewPager关联起来。 |
114 | } | 114 | } |
115 | 115 | ||
116 | private void setLister() { | 116 | private void setLister() { |
117 | 117 | ||
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | } | 121 | } |
122 | 122 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.os.Handler; | 9 | import android.os.Handler; |
10 | import android.os.Message; | 10 | import android.os.Message; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.support.annotation.NonNull; | 12 | import android.support.annotation.NonNull; |
13 | import android.support.v4.content.FileProvider; | 13 | import android.support.v4.content.FileProvider; |
14 | import android.support.v7.app.AppCompatActivity; | 14 | import android.support.v7.app.AppCompatActivity; |
15 | import android.support.v7.widget.LinearLayoutManager; | 15 | import android.support.v7.widget.LinearLayoutManager; |
16 | import android.support.v7.widget.RecyclerView; | 16 | import android.support.v7.widget.RecyclerView; |
17 | import android.util.Log; | ||
18 | import android.view.KeyEvent; | 17 | import android.view.KeyEvent; |
19 | import android.view.View; | 18 | import android.view.View; |
20 | import android.widget.ImageView; | 19 | import android.widget.ImageView; |
21 | import android.widget.LinearLayout; | 20 | import android.widget.LinearLayout; |
22 | import android.widget.TextView; | 21 | import android.widget.TextView; |
23 | import android.widget.Toast; | 22 | import android.widget.Toast; |
24 | 23 | ||
25 | import com.facebook.drawee.backends.pipeline.Fresco; | 24 | import com.facebook.drawee.backends.pipeline.Fresco; |
26 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 25 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
27 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 26 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
28 | import com.facebook.drawee.generic.RoundingParams; | 27 | import com.facebook.drawee.generic.RoundingParams; |
29 | import com.facebook.drawee.interfaces.DraweeController; | 28 | import com.facebook.drawee.interfaces.DraweeController; |
30 | import com.facebook.drawee.view.SimpleDraweeView; | 29 | import com.facebook.drawee.view.SimpleDraweeView; |
31 | import com.hjx.personalcenter.R; | 30 | import com.hjx.personalcenter.R; |
32 | import com.hjx.personalcenter.adapter.GalleryAdapter; | 31 | import com.hjx.personalcenter.adapter.GalleryAdapter; |
33 | import com.hjx.personalcenter.adapter.VideoAdapter; | 32 | import com.hjx.personalcenter.adapter.VideoAdapter; |
34 | import com.hjx.personalcenter.customdialog.HeadDialog; | 33 | import com.hjx.personalcenter.customdialog.HeadDialog; |
35 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; | 34 | import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem; |
36 | import com.hjx.personalcenter.db.SaveParam; | 35 | import com.hjx.personalcenter.db.SaveParam; |
37 | import com.hjx.personalcenter.http.HttpCode; | 36 | import com.hjx.personalcenter.http.HttpCode; |
38 | import com.hjx.personalcenter.http.HttpManager; | 37 | import com.hjx.personalcenter.http.HttpManager; |
39 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 38 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
40 | import com.hjx.personalcenter.model.DefautPublishInfo; | 39 | import com.hjx.personalcenter.model.DefautPublishInfo; |
41 | import com.hjx.personalcenter.model.PesonalInfo; | 40 | import com.hjx.personalcenter.model.PesonalInfo; |
42 | import com.hjx.personalcenter.model.SignInfo; | 41 | import com.hjx.personalcenter.model.SignInfo; |
43 | import com.hjx.personalcenter.model.VideoInfo; | 42 | import com.hjx.personalcenter.model.VideoInfo; |
44 | import com.hjx.personalcenter.update.UpdateChecker; | 43 | import com.hjx.personalcenter.update.UpdateChecker; |
45 | import com.hjx.personalcenter.util.AlertUtils; | 44 | import com.hjx.personalcenter.util.AlertUtils; |
46 | import com.hjx.personalcenter.util.CropUtils; | 45 | import com.hjx.personalcenter.util.CropUtils; |
47 | import com.hjx.personalcenter.util.DialogPermission; | 46 | import com.hjx.personalcenter.util.DialogPermission; |
48 | import com.hjx.personalcenter.util.FileUtil; | 47 | import com.hjx.personalcenter.util.FileUtil; |
49 | import com.hjx.personalcenter.util.GetDevicesUtil; | 48 | import com.hjx.personalcenter.util.GetDevicesUtil; |
50 | import com.hjx.personalcenter.util.PermissionUtil; | 49 | import com.hjx.personalcenter.util.PermissionUtil; |
51 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 50 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
52 | import com.mylhyl.circledialog.CircleDialog; | 51 | import com.mylhyl.circledialog.CircleDialog; |
53 | import com.mylhyl.circledialog.callback.ConfigInput; | 52 | import com.mylhyl.circledialog.callback.ConfigInput; |
54 | import com.mylhyl.circledialog.params.InputParams; | 53 | import com.mylhyl.circledialog.params.InputParams; |
55 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 54 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
56 | import com.zaaach.toprightmenu.MenuItem; | 55 | import com.zaaach.toprightmenu.MenuItem; |
57 | import com.zaaach.toprightmenu.TopRightMenu; | 56 | import com.zaaach.toprightmenu.TopRightMenu; |
58 | 57 | ||
58 | import org.json.JSONException; | ||
59 | import org.json.JSONObject; | ||
60 | |||
59 | import java.io.File; | 61 | import java.io.File; |
60 | import java.io.UnsupportedEncodingException; | 62 | import java.io.UnsupportedEncodingException; |
61 | import java.util.ArrayList; | 63 | import java.util.ArrayList; |
62 | import java.util.List; | 64 | import java.util.List; |
63 | 65 | ||
64 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 66 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
65 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; | 67 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; |
66 | private TextView tv_edit_presoninfo, tv_sign, | 68 | private TextView tv_edit_presoninfo, tv_sign, |
67 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 69 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
68 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; | 70 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender, tv_yangji; |
69 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; | 71 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; |
70 | private TopRightMenu mTopRightMenu; | 72 | private TopRightMenu mTopRightMenu; |
71 | //水平滑动 | 73 | //水平滑动 |
72 | private RecyclerView mRecyclerView; | 74 | private RecyclerView mRecyclerView; |
73 | private RecyclerView mRecyclerViewpublish; | 75 | private RecyclerView mRecyclerViewpublish; |
74 | private VideoAdapter RecyclerViewadapter; | 76 | private VideoAdapter RecyclerViewadapter; |
75 | private GalleryAdapter RecyclerViewadapterpublish; | 77 | private GalleryAdapter RecyclerViewadapterpublish; |
76 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); | 78 | private ArrayList<DefautPublishInfo.DataBean> defautPublishInfos = new ArrayList<>(); |
77 | 79 | ||
78 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); | 80 | private ArrayList<VideoInfo.DataBean> videoinfo = new ArrayList<>(); |
79 | private boolean showIcon = true; | 81 | private boolean showIcon = true; |
80 | private boolean dimBg = true; | 82 | private boolean dimBg = true; |
81 | private boolean needAnim = true; | 83 | private boolean needAnim = true; |
82 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 84 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
83 | private static final int REQUEST_CODE_ALBUM = 2; | 85 | private static final int REQUEST_CODE_ALBUM = 2; |
84 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 86 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
85 | SimpleDraweeView mSimpleDraweeView; | 87 | SimpleDraweeView mSimpleDraweeView; |
86 | private File file; | 88 | private File file; |
87 | private Uri uri; | 89 | private Uri uri; |
88 | Handler handler = new Handler(){ | 90 | Handler handler = new Handler() { |
89 | @Override | 91 | @Override |
90 | public void handleMessage(Message msg) { | 92 | public void handleMessage(Message msg) { |
91 | super.handleMessage(msg); | 93 | super.handleMessage(msg); |
92 | switch (msg.what){ | 94 | switch (msg.what) { |
93 | case HttpCode.GETINFO: | 95 | case HttpCode.GETINFO: |
94 | PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj; | 96 | PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj; |
95 | tv_username.setText(cardinfoBean.getNickName()); | 97 | tv_username.setText(cardinfoBean.getNickName()); |
96 | tv_username1.setText(cardinfoBean.getNickName()); | 98 | tv_username1.setText(cardinfoBean.getNickName()); |
97 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); | 99 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); |
98 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); | 100 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); |
99 | tv_useinfo_qq.setText(cardinfoBean.getQq()); | 101 | tv_useinfo_qq.setText(cardinfoBean.getQq()); |
100 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); | 102 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); |
101 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); | 103 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); |
102 | String sex = cardinfoBean.getGender(); | 104 | String sex = cardinfoBean.getGender(); |
103 | if ("0".equals(sex)){ | 105 | if ("0".equals(sex)) { |
104 | tv_sex.setText("男"); | 106 | tv_sex.setText("男"); |
105 | iv_sex.setImageResource(R.mipmap.men); | 107 | iv_sex.setImageResource(R.mipmap.men); |
106 | }else { | 108 | } else { |
107 | tv_sex.setText("女"); | 109 | tv_sex.setText("女"); |
108 | iv_sex.setImageResource(R.mipmap.women); | 110 | iv_sex.setImageResource(R.mipmap.women); |
109 | } | 111 | } |
110 | mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); | 112 | mSimpleDraweeView.setImageURI(cardinfoBean.getPortrait()); |
111 | String graderID =cardinfoBean.getGrade().getGradeId(); | 113 | String graderID = cardinfoBean.getGrade().getGradeId(); |
112 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); | 114 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
113 | //账户类型 | 115 | //账户类型 |
114 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.ACCOUNT); | 116 | String accounts = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
115 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.CHILDSID); | 117 | String childID = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.CHILDSID); |
116 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.GRADENS, ""+graderID); | 118 | SaveParam.getInstance().saveCustomizeParam(MainActivity.this, SaveParam.GRADENS, "" + graderID); |
117 | try { | 119 | try { |
118 | Object auserID; | 120 | Object auserID; |
119 | int type; | 121 | int type; |
120 | int graderIDs =Integer.parseInt(graderID); | 122 | int graderIDs = Integer.parseInt(graderID); |
121 | if ("2".equals(accounts)){ | 123 | if ("2".equals(accounts)) { |
122 | type=Integer.parseInt(accounts); | 124 | type = Integer.parseInt(accounts); |
123 | auserID =childID; | 125 | auserID = childID; |
124 | }else { | 126 | } else { |
125 | type =Integer.parseInt(accounts); | 127 | type = Integer.parseInt(accounts); |
126 | auserID =Long.parseLong(userID); | 128 | auserID = Long.parseLong(userID); |
127 | } | 129 | } |
128 | //获取版本信息 | 130 | //获取版本信息 |
129 | HttpManager.getInstance().getpublishinfo(MainActivity.this,auserID,graderIDs,type,handler); | 131 | HttpManager.getInstance().getpublishinfo(MainActivity.this, auserID, graderIDs, type, handler); |
130 | 132 | ||
131 | } catch (NumberFormatException e) { | 133 | } catch (NumberFormatException e) { |
132 | e.printStackTrace(); | 134 | e.printStackTrace(); |
133 | } | 135 | } |
134 | 136 | ||
135 | break; | 137 | break; |
136 | case HttpCode.SIGN: | 138 | case HttpCode.SIGN: |
137 | SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; | 139 | SignInfo.DataBean dataBean = (SignInfo.DataBean) msg.obj; |
138 | if (dataBean.getSignature()==null){ | 140 | if (dataBean.getSignature() == null) { |
139 | tv_sign.setText("你还未设置个性签名"); | 141 | tv_sign.setText("你还未设置个性签名"); |
140 | }else { | 142 | } else { |
141 | tv_sign.setText(dataBean.getSignature()); | 143 | tv_sign.setText(dataBean.getSignature()); |
142 | } | 144 | } |
143 | 145 | ||
144 | break; | 146 | break; |
145 | case HttpCode.PUBLISH_SUCESS: | 147 | case HttpCode.PUBLISH_SUCESS: |
146 | defautPublishInfos.clear(); | 148 | defautPublishInfos.clear(); |
147 | defautPublishInfos.addAll( (List<DefautPublishInfo.DataBean>)msg.obj); | 149 | defautPublishInfos.addAll((List<DefautPublishInfo.DataBean>) msg.obj); |
148 | RecyclerViewadapterpublish.notifyDataSetChanged(); | 150 | RecyclerViewadapterpublish.notifyDataSetChanged(); |
149 | break; | 151 | break; |
150 | case HttpCode.GETVIDIO_SUCESS: | 152 | case HttpCode.GETVIDIO_SUCESS: |
151 | videoinfo.clear(); | 153 | videoinfo.clear(); |
152 | videoinfo.addAll( (List<VideoInfo.DataBean>)msg.obj); | 154 | videoinfo.addAll((List<VideoInfo.DataBean>) msg.obj); |
153 | RecyclerViewadapter.notifyDataSetChanged(); | 155 | RecyclerViewadapter.notifyDataSetChanged(); |
154 | break; | 156 | break; |
157 | case HttpCode.SUCHCARDINFOONE: | ||
158 | JSONObject jsonObject; | ||
159 | String status; | ||
160 | try { | ||
161 | jsonObject = new JSONObject((String) msg.obj); | ||
162 | status = jsonObject.getString("status"); | ||
163 | if (status.equals("1")) { | ||
164 | tv_yangji.setVisibility(View.GONE); | ||
165 | iv_look_card.setVisibility(View.VISIBLE); | ||
166 | } else if (status.equals("2001")) { | ||
167 | tv_yangji.setVisibility(View.GONE); | ||
168 | iv_look_card.setVisibility(View.VISIBLE); | ||
169 | AlertUtils.showToast(MainActivity.this, "您的机器还没有保卡信息,请重新登录"); | ||
170 | SaveParam.getInstance().clearData(MainActivity.this); | ||
171 | Intent settingintent = new Intent(); | ||
172 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | ||
173 | startActivity(settingintent); | ||
174 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | ||
175 | finish(); | ||
176 | } else if (status.equals("2002")) { | ||
177 | iv_look_card.setVisibility(View.GONE); | ||
178 | tv_yangji.setVisibility(View.VISIBLE); | ||
179 | |||
180 | } else { | ||
181 | AlertUtils.showToast(MainActivity.this, "服务器连接失败"); | ||
182 | } | ||
183 | } catch (JSONException e) { | ||
184 | e.printStackTrace(); | ||
185 | } | ||
186 | |||
187 | |||
155 | } | 188 | } |
156 | } | 189 | } |
157 | }; | 190 | }; |
158 | 191 | ||
159 | @Override | 192 | @Override |
160 | protected void onCreate(Bundle savedInstanceState) { | 193 | protected void onCreate(Bundle savedInstanceState) { |
161 | super.onCreate(savedInstanceState); | 194 | super.onCreate(savedInstanceState); |
162 | Fresco.initialize(this); | 195 | Fresco.initialize(this); |
163 | setContentView(R.layout.activity_main); | 196 | setContentView(R.layout.activity_main); |
164 | SysApplication.getInstance().addActivity(this); | ||
165 | initView(); | 197 | initView(); |
166 | initData(); | 198 | initData(); |
167 | initLister(); | 199 | initLister(); |
168 | updateVersion(); | 200 | updateVersion(); |
169 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | ||
170 | String model = GetDevicesUtil.getDevicesInfo(this).getDeviceModel(); | ||
171 | Log.e("test","......."+devicenumber+model); | ||
172 | } | 201 | } |
173 | //////版本更新 | 202 | |
203 | //////版本更新 | ||
174 | private void updateVersion() { | 204 | private void updateVersion() { |
175 | UpdateChecker updateChecker = new UpdateChecker(this); | 205 | UpdateChecker updateChecker = new UpdateChecker(this); |
176 | updateChecker.checkForUpdates(); | 206 | updateChecker.checkForUpdates(); |
177 | 207 | ||
178 | 208 | ||
179 | } | 209 | } |
180 | 210 | ||
181 | private void initView() { | 211 | private void initView() { |
182 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 212 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
183 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); | 213 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); |
184 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); | 214 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); |
185 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 215 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
186 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 216 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
187 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 217 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
188 | //头像 | 218 | //头像 |
189 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); | 219 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); |
190 | //初始化个人信息 | 220 | //初始化个人信息 |
191 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 221 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
192 | tv_username = (TextView) findViewById(R.id.tv_username); | 222 | tv_username = (TextView) findViewById(R.id.tv_username); |
193 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 223 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
194 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 224 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
195 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 225 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
196 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 226 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
197 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 227 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
198 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 228 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
199 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 229 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
200 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 230 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
231 | tv_yangji = (TextView) findViewById(R.id.tv_yangji); | ||
201 | //跳转其他应用 | 232 | //跳转其他应用 |
202 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); | 233 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); |
203 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); | 234 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); |
204 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); | 235 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); |
205 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); | 236 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); |
206 | // | 237 | // |
207 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 238 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
208 | mRecyclerViewpublish =(RecyclerView) findViewById(R.id.id_recyclerview_pubish); | 239 | mRecyclerViewpublish = (RecyclerView) findViewById(R.id.id_recyclerview_pubish); |
209 | 240 | ||
210 | } | 241 | } |
211 | 242 | ||
212 | 243 | ||
213 | private void initData() { | 244 | private void initData() { |
214 | //设置布局管理器 | 245 | //设置布局管理器 |
215 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 246 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
216 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); | 247 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
217 | 248 | ||
218 | LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); | 249 | LinearLayoutManager linearLayoutManagerpublish = new LinearLayoutManager(this); |
219 | linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); | 250 | linearLayoutManagerpublish.setOrientation(LinearLayoutManager.HORIZONTAL); |
220 | 251 | ||
221 | mRecyclerView.setLayoutManager(linearLayoutManager); | 252 | mRecyclerView.setLayoutManager(linearLayoutManager); |
222 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); | 253 | mRecyclerView.addItemDecoration(new RecyclerViewSpaceItem(10)); |
223 | 254 | ||
224 | mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); | 255 | mRecyclerViewpublish.setLayoutManager(linearLayoutManagerpublish); |
225 | mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); | 256 | mRecyclerViewpublish.addItemDecoration(new RecyclerViewSpaceItem(10)); |
226 | 257 | ||
227 | //设置视频适配器 | 258 | //设置视频适配器 |
228 | RecyclerViewadapter = new VideoAdapter(this,videoinfo); | 259 | RecyclerViewadapter = new VideoAdapter(this, videoinfo); |
229 | RecyclerViewadapterpublish= new GalleryAdapter(this,defautPublishInfos); | 260 | RecyclerViewadapterpublish = new GalleryAdapter(this, defautPublishInfos); |
230 | 261 | ||
231 | //版本信息适配器 | 262 | //版本信息适配器 |
232 | mRecyclerView.setAdapter(RecyclerViewadapter); | 263 | mRecyclerView.setAdapter(RecyclerViewadapter); |
233 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); | 264 | mRecyclerViewpublish.setAdapter(RecyclerViewadapterpublish); |
234 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 265 | //判断保卡信息是否为样机 |
266 | String yangji = SaveParam.getInstance().getLoginParam(this, SaveParam.YANGJI); | ||
267 | String deviceNumber = GetDevicesUtil.getDevicesInfo(MainActivity.this).getDeviceNumber(); | ||
268 | if ("1".equals(yangji)) { | ||
269 | iv_look_card.setVisibility(View.GONE); | ||
270 | tv_yangji.setVisibility(View.VISIBLE); | ||
271 | } else { | ||
272 | HttpManager.getInstance().getcardinfo1(this, deviceNumber, handler); | ||
273 | |||
274 | } | ||
275 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | ||
235 | //获取个性签名 | 276 | //获取个性签名 |
236 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 277 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
237 | try { | 278 | try { |
238 | long auserID = Long.parseLong(userID); | 279 | long auserID = Long.parseLong(userID); |
239 | int typeaccount1=Integer.parseInt(typeaccount); | 280 | int typeaccount1 = Integer.parseInt(typeaccount); |
240 | HttpManager.getInstance().getsignatures(MainActivity.this,auserID,typeaccount1,handler); | 281 | HttpManager.getInstance().getsignatures(MainActivity.this, auserID, typeaccount1, handler); |
241 | 282 | ||
242 | } catch (NumberFormatException e) { | 283 | } catch (NumberFormatException e) { |
243 | e.printStackTrace(); | 284 | e.printStackTrace(); |
244 | } | 285 | } |
245 | 286 | ||
246 | //初始化图片 | 287 | //初始化图片 |
247 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 288 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
248 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 289 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
249 | uri = Uri.fromFile(file); | 290 | uri = Uri.fromFile(file); |
250 | } else { | 291 | } else { |
251 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 292 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
252 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 293 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
253 | } | 294 | } |
254 | 295 | ||
255 | } | 296 | } |
256 | 297 | ||
257 | private void initLister() { | 298 | private void initLister() { |
258 | iv_imformatioan.setOnClickListener(this); | 299 | iv_imformatioan.setOnClickListener(this); |
259 | iv_look_card.setOnClickListener(this); | 300 | iv_look_card.setOnClickListener(this); |
260 | tv_edit_presoninfo.setOnClickListener(this); | 301 | tv_edit_presoninfo.setOnClickListener(this); |
261 | iv_setting.setOnClickListener(this); | 302 | iv_setting.setOnClickListener(this); |
262 | iv_sign.setOnClickListener(this); | 303 | iv_sign.setOnClickListener(this); |
263 | mSimpleDraweeView.setOnClickListener(this); | 304 | mSimpleDraweeView.setOnClickListener(this); |
264 | linel_mycuoti.setOnClickListener(this); | 305 | linel_mycuoti.setOnClickListener(this); |
265 | linel_mynote.setOnClickListener(this); | 306 | linel_mynote.setOnClickListener(this); |
266 | linel_mycollege.setOnClickListener(this); | 307 | linel_mycollege.setOnClickListener(this); |
267 | linel_myclass.setOnClickListener(this); | 308 | linel_myclass.setOnClickListener(this); |
268 | 309 | ||
269 | } | 310 | } |
270 | 311 | ||
271 | @Override | 312 | @Override |
272 | public void onClick(View v) { | 313 | public void onClick(View v) { |
273 | switch (v.getId()) { | 314 | switch (v.getId()) { |
274 | case R.id.iv_imformatioan: | 315 | case R.id.iv_imformatioan: |
275 | Intent intent = new Intent(); | 316 | Intent intent = new Intent(); |
276 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 317 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
277 | startActivity(intent); | 318 | startActivity(intent); |
278 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 319 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
279 | break; | 320 | break; |
280 | case R.id.iv_look_card: | 321 | case R.id.iv_look_card: |
281 | Intent lookintent = new Intent(); | 322 | Intent lookintent = new Intent(); |
282 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 323 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
283 | startActivity(lookintent); | 324 | startActivity(lookintent); |
284 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 325 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
285 | break; | 326 | break; |
286 | case R.id.tv_edit_presoninfo: | 327 | case R.id.tv_edit_presoninfo: |
287 | Intent editintent = new Intent(); | 328 | Intent editintent = new Intent(); |
288 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 329 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
289 | startActivity(editintent); | 330 | startActivity(editintent); |
290 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 331 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
291 | break; | 332 | break; |
292 | case R.id.iv_head: | 333 | case R.id.iv_head: |
293 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 334 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
294 | break; | 335 | break; |
295 | case R.id.iv_setting: | 336 | case R.id.iv_setting: |
296 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 337 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
297 | List<MenuItem> menuItems = new ArrayList<>(); | 338 | List<MenuItem> menuItems = new ArrayList<>(); |
298 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); | 339 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); |
299 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); | 340 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); |
300 | mTopRightMenu | 341 | mTopRightMenu |
301 | .setHeight(150) //默认高度480 | 342 | .setHeight(150) //默认高度480 |
302 | .setWidth(320) //默认宽度wrap_content | 343 | .setWidth(320) //默认宽度wrap_content |
303 | .showIcon(showIcon) //显示菜单图标,默认为true | 344 | .showIcon(showIcon) //显示菜单图标,默认为true |
304 | .dimBackground(dimBg) //背景变暗,默认为true | 345 | .dimBackground(dimBg) //背景变暗,默认为true |
305 | .needAnimationStyle(needAnim) //显示动画,默认为true | 346 | .needAnimationStyle(needAnim) //显示动画,默认为true |
306 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 347 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
307 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 348 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
308 | @Override | 349 | @Override |
309 | public void onMenuItemClick(int position) { | 350 | public void onMenuItemClick(int position) { |
310 | switch (position) { | 351 | switch (position) { |
311 | case 0: | 352 | case 0: |
312 | new CircleDialog.Builder(MainActivity.this) | 353 | new CircleDialog.Builder(MainActivity.this) |
313 | .setCanceledOnTouchOutside(false) | 354 | .setCanceledOnTouchOutside(false) |
314 | .setWidth(0.4f) | 355 | .setWidth(0.4f) |
315 | .setCancelable(false) | 356 | .setCancelable(false) |
316 | .setText("您确定要退出,更换其他账号登录吗?") | 357 | .setText("您确定要退出,更换其他账号登录吗?") |
317 | .setNegative("取消", null) | 358 | .setNegative("取消", null) |
318 | .setPositive("确定", new View.OnClickListener() { | 359 | .setPositive("确定", new View.OnClickListener() { |
319 | @Override | 360 | @Override |
320 | public void onClick(View v) { | 361 | public void onClick(View v) { |
321 | //清除数据 | 362 | //清除数据 |
322 | SaveParam.getInstance().clearData(MainActivity.this); | 363 | SaveParam.getInstance().clearData(MainActivity.this); |
323 | Intent settingintent = new Intent(); | 364 | Intent settingintent = new Intent(); |
324 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 365 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
325 | startActivity(settingintent); | 366 | startActivity(settingintent); |
326 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 367 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
327 | finish(); | 368 | finish(); |
328 | } | 369 | } |
329 | }) | 370 | }) |
330 | .show(); | 371 | .show(); |
331 | break; | 372 | break; |
332 | case 1: | 373 | case 1: |
333 | Intent accontMintent = new Intent(); | 374 | Intent accontMintent = new Intent(); |
334 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 375 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
335 | startActivity(accontMintent); | 376 | startActivity(accontMintent); |
336 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 377 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
337 | break; | 378 | break; |
338 | } | 379 | } |
339 | } | 380 | } |
340 | }) | 381 | }) |
341 | .addMenuList(menuItems) | 382 | .addMenuList(menuItems) |
342 | .showAsDropDown(iv_setting, -250, 0); | 383 | .showAsDropDown(iv_setting, -250, 0); |
343 | break; | 384 | break; |
344 | case R.id.iv_sign: | 385 | case R.id.iv_sign: |
345 | new CircleDialog.Builder(this) | 386 | new CircleDialog.Builder(this) |
346 | .setCanceledOnTouchOutside(false) | 387 | .setCanceledOnTouchOutside(false) |
347 | .setCancelable(true) | 388 | .setCancelable(true) |
348 | .setTitle("个性签名") | 389 | .setTitle("个性签名") |
349 | .setInputHint("请输入个性签名") | 390 | .setInputHint("请输入个性签名") |
350 | .setWidth(0.5f) | 391 | .setWidth(0.5f) |
351 | .configInput(new ConfigInput() { | 392 | .configInput(new ConfigInput() { |
352 | @Override | 393 | @Override |
353 | public void onConfig(InputParams params) { | 394 | public void onConfig(InputParams params) { |
354 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 395 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
355 | } | 396 | } |
356 | }) | 397 | }) |
357 | .setNegative("取消", null) | 398 | .setNegative("取消", null) |
358 | .setPositiveInput("确定", new OnInputClickListener() { | 399 | .setPositiveInput("确定", new OnInputClickListener() { |
359 | @Override | 400 | @Override |
360 | public void onClick(String text, View v) { | 401 | public void onClick(String text, View v) { |
361 | if (text.equals("")) { | 402 | if (text.equals("")) { |
362 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 403 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
363 | } else { | 404 | } else { |
364 | try { | 405 | try { |
365 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this,SaveParam.ACCOUNT); | 406 | String typeaccount = SaveParam.getInstance().getCustomizeParam(MainActivity.this, SaveParam.ACCOUNT); |
366 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); | 407 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this, "userId"); |
367 | long auserID = Long.parseLong(userID); | 408 | long auserID = Long.parseLong(userID); |
368 | int typeaccount1=Integer.parseInt(typeaccount); | 409 | int typeaccount1 = Integer.parseInt(typeaccount); |
369 | HttpManager.getInstance().changsignature(MainActivity.this,auserID,typeaccount1,text); | 410 | HttpManager.getInstance().changsignature(MainActivity.this, auserID, typeaccount1, text); |
370 | } catch (NumberFormatException e) { | 411 | } catch (NumberFormatException e) { |
371 | e.printStackTrace(); | 412 | e.printStackTrace(); |
372 | } | 413 | } |
373 | 414 | ||
374 | tv_sign.setText(text); | 415 | tv_sign.setText(text); |
375 | } | 416 | } |
376 | 417 | ||
377 | } | 418 | } |
378 | }) | 419 | }) |
379 | .show(); | 420 | .show(); |
380 | break; | 421 | break; |
381 | case R.id.linel_mycuoti: | 422 | case R.id.linel_mycuoti: |
382 | AlertUtils.showToast(this, "hhahahah "); | 423 | AlertUtils.showToast(this, "我的错题 "); |
383 | break; | 424 | break; |
384 | case R.id.linel_mynote: | 425 | case R.id.linel_mynote: |
385 | AlertUtils.showToast(this, "hhahahah "); | 426 | AlertUtils.showToast(this, "我的笔记 "); |
386 | break; | 427 | break; |
387 | case R.id.linel_mycollege: | 428 | case R.id.linel_mycollege: |
388 | AlertUtils.showToast(this, "hhahahah "); | 429 | AlertUtils.showToast(this, "我的收藏 "); |
389 | break; | 430 | break; |
390 | case R.id.linel_myclass: | 431 | case R.id.linel_myclass: |
391 | AlertUtils.showToast(this, "hhahahah "); | 432 | AlertUtils.showToast(this, "我的班级 "); |
392 | break; | 433 | break; |
393 | } | 434 | } |
394 | 435 | ||
395 | } | 436 | } |
396 | 437 | ||
397 | @Override | 438 | @Override |
439 | protected void onPause() { | ||
440 | super.onPause(); | ||
441 | } | ||
442 | |||
443 | @Override | ||
398 | protected void onResume() { | 444 | protected void onResume() { |
399 | super.onResume(); | 445 | super.onResume(); |
400 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 446 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
401 | //账户类型 | 447 | //账户类型 |
402 | String accounts = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 448 | String accounts = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
403 | //加载个人信息 | 449 | //加载个人信息 |
404 | String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION); | 450 | String xiongzuo = SaveParam.getInstance().getLoginParam(this, SaveParam.CONSTELLATION); |
405 | if (xiongzuo==null){ | 451 | if (xiongzuo == null) { |
406 | tv_mygad.setText(""); | 452 | tv_mygad.setText(""); |
407 | }else { | 453 | } else { |
408 | tv_mygad.setText(xiongzuo); | 454 | tv_mygad.setText(xiongzuo); |
409 | } | 455 | } |
410 | try { | 456 | try { |
411 | int graderID; | 457 | int graderID; |
412 | long auserID = Long.parseLong(userID); | 458 | long auserID = Long.parseLong(userID); |
413 | int typeaccount1=Integer.parseInt(accounts); | 459 | int typeaccount1 = Integer.parseInt(accounts); |
414 | //获取最近播放视频 | 460 | //获取最近播放视频 |
415 | HttpManager.getInstance().getstuyvidioinfo(this,auserID,handler); | 461 | HttpManager.getInstance().getstuyvidioinfo(this, auserID, handler); |
416 | //获取个人信息 | 462 | //获取个人信息 |
417 | HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,typeaccount1,handler); | 463 | HttpManager.getInstance().getpresonalinfo(MainActivity.this, auserID, typeaccount1, handler); |
418 | |||
419 | 464 | ||
420 | 465 | ||
421 | } catch (NumberFormatException e) { | 466 | } catch (NumberFormatException e) { |
422 | e.printStackTrace(); | 467 | e.printStackTrace(); |
423 | } | 468 | } |
424 | 469 | ||
425 | } | 470 | } |
426 | 471 | ||
427 | //回调头像监听 | 472 | //回调头像监听 |
428 | @Override | 473 | @Override |
429 | public void heard(Context context, View v,int headpitiaon) { | 474 | public void heard(Context context, View v, int headpitiaon) { |
430 | String picUrl = ""; | 475 | String picUrl = ""; |
431 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 476 | String userID; |
432 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 477 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
433 | switch (v.getId()){ | 478 | if ("2".equals(typeaccount)) { |
479 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | ||
480 | } else { | ||
481 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | ||
482 | } | ||
483 | switch (v.getId()) { | ||
434 | //选择默认图片 | 484 | //选择默认图片 |
435 | case R.id.oktakephone: | 485 | case R.id.oktakephone: |
436 | if (headpitiaon==1){ | 486 | if (headpitiaon == 1) { |
437 | mSimpleDraweeView.setImageDrawable(null); | 487 | mSimpleDraweeView.setImageDrawable(null); |
438 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); | 488 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
439 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; | 489 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; |
440 | try { | 490 | try { |
441 | HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | 491 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
442 | } catch (UnsupportedEncodingException e) { | 492 | } catch (UnsupportedEncodingException e) { |
443 | e.printStackTrace(); | 493 | e.printStackTrace(); |
444 | } | 494 | } |
445 | }else if (headpitiaon==2){ | 495 | } else if (headpitiaon == 2) { |
446 | mSimpleDraweeView.setImageDrawable(null); | 496 | mSimpleDraweeView.setImageDrawable(null); |
447 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); | 497 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
448 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; | 498 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; |
449 | try { | 499 | try { |
450 | HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | 500 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
451 | } catch (UnsupportedEncodingException e) { | 501 | } catch (UnsupportedEncodingException e) { |
452 | e.printStackTrace(); | 502 | e.printStackTrace(); |
453 | } | 503 | } |
454 | }else if (headpitiaon==3){ | 504 | } else if (headpitiaon == 3) { |
455 | mSimpleDraweeView.setImageDrawable(null); | 505 | mSimpleDraweeView.setImageDrawable(null); |
456 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); | 506 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
457 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; | 507 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; |
458 | try { | 508 | try { |
459 | HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | 509 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
460 | } catch (UnsupportedEncodingException e) { | 510 | } catch (UnsupportedEncodingException e) { |
461 | e.printStackTrace(); | 511 | e.printStackTrace(); |
462 | } | 512 | } |
463 | }else if (headpitiaon==4){ | 513 | } else if (headpitiaon == 4) { |
464 | mSimpleDraweeView.setImageDrawable(null); | 514 | mSimpleDraweeView.setImageDrawable(null); |
465 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); | 515 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
466 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png"; | 516 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png"; |
467 | try { | 517 | try { |
468 | HttpManager.getInstance().headerdeft(this, userID,typeaccount,picUrl); | 518 | HttpManager.getInstance().headerdeft(this, userID, typeaccount, picUrl); |
469 | } catch (UnsupportedEncodingException e) { | 519 | } catch (UnsupportedEncodingException e) { |
470 | e.printStackTrace(); | 520 | e.printStackTrace(); |
471 | } | 521 | } |
472 | }else{ | 522 | } else { |
473 | mSimpleDraweeView.setImageDrawable(null); | 523 | mSimpleDraweeView.setImageDrawable(null); |
474 | mSimpleDraweeView.setImageResource(R.mipmap.header_default);; | 524 | mSimpleDraweeView.setImageResource(R.mipmap.header_default); |
525 | ; | ||
475 | } | 526 | } |
476 | 527 | ||
477 | break; | 528 | break; |
478 | case R.id.canceltakephone: | 529 | case R.id.canceltakephone: |
479 | 530 | ||
480 | break; | 531 | break; |
481 | //拍摄和相册 | 532 | //拍摄和相册 |
482 | case R.id.take_pic: | 533 | case R.id.take_pic: |
534 | android.util.Log.e("TAG", "....."); | ||
483 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 535 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
484 | uploadAvatarFromPhotoRequest(); | 536 | uploadAvatarFromPhotoRequest(); |
485 | } | 537 | } |
486 | |||
487 | break; | 538 | break; |
488 | case R.id.xiangce: | 539 | case R.id.xiangce: |
489 | uploadAvatarFromAlbumRequest(); | 540 | uploadAvatarFromAlbumRequest(); |
490 | break; | 541 | break; |
491 | 542 | ||
492 | } | 543 | } |
493 | 544 | ||
494 | } | 545 | } |
495 | 546 | ||
496 | //照相 | 547 | //照相 |
497 | private void uploadAvatarFromPhotoRequest() { | 548 | private void uploadAvatarFromPhotoRequest() { |
498 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 549 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
499 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 550 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
500 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 551 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
501 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 552 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
502 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 553 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
503 | } | 554 | } |
504 | 555 | ||
505 | //选择图库 | 556 | //选择图库 |
506 | private void uploadAvatarFromAlbumRequest() { | 557 | private void uploadAvatarFromAlbumRequest() { |
507 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 558 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
508 | photoPickerIntent.setType("image/*"); | 559 | photoPickerIntent.setType("image/*"); |
509 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 560 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
510 | } | 561 | } |
562 | |||
511 | //回掉 | 563 | //回掉 |
512 | @Override | 564 | @Override |
513 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 565 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
514 | super.onActivityResult(requestCode, resultCode, data); | 566 | super.onActivityResult(requestCode, resultCode, data); |
515 | if (resultCode != -1) { | 567 | if (resultCode != -1) { |
516 | return; | 568 | return; |
517 | } | 569 | } |
518 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 570 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
519 | Uri newUri; | 571 | Uri newUri; |
520 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 572 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
521 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 573 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
522 | } else { | 574 | } else { |
523 | newUri = data.getData(); | 575 | newUri = data.getData(); |
524 | } | 576 | } |
525 | if (newUri != null) { | 577 | if (newUri != null) { |
526 | startPhotoZoom(newUri); | 578 | startPhotoZoom(newUri); |
527 | } else { | 579 | } else { |
528 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 580 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
529 | } | 581 | } |
530 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 582 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
531 | startPhotoZoom(uri); | 583 | startPhotoZoom(uri); |
532 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 584 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
533 | uploadAvatarFromPhoto(); | 585 | uploadAvatarFromPhoto(); |
534 | } | 586 | } |
535 | } | 587 | } |
536 | 588 | ||
537 | private void uploadAvatarFromPhoto() { | 589 | private void uploadAvatarFromPhoto() { |
538 | compressAndUploadAvatar(file.getPath()); | 590 | compressAndUploadAvatar(file.getPath()); |
539 | 591 | ||
540 | } | 592 | } |
593 | |||
541 | private void compressAndUploadAvatar(String fileSrc) { | 594 | private void compressAndUploadAvatar(String fileSrc) { |
542 | 595 | ||
543 | 596 | ||
544 | //上传到服务器 | 597 | //上传到服务器 |
545 | 598 | ||
546 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 599 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
547 | String mimeType = "image/*"; | 600 | String mimeType = "image/*"; |
548 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 601 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
549 | //String fileName = cover.getName(); | 602 | //String fileName = cover.getName(); |
550 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 603 | String userID; |
551 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this,SaveParam.ACCOUNT); | 604 | String typeaccount = SaveParam.getInstance().getCustomizeParam(this, SaveParam.ACCOUNT); |
605 | if ("2".equals(typeaccount)) { | ||
606 | userID = SaveParam.getInstance().getCustomizeParam(this, SaveParam.CHILDSID); | ||
607 | } else { | ||
608 | userID = SaveParam.getInstance().getLoginParam(this, "userId"); | ||
609 | } | ||
552 | 610 | ||
553 | //上传头像 | 611 | //上传头像 |
554 | 612 | ||
555 | try { | 613 | try { |
556 | HttpManager.getInstance().header(this, userID,typeaccount,file.getPath()); | 614 | HttpManager.getInstance().header(this, userID, typeaccount, file.getPath()); |
557 | } catch (UnsupportedEncodingException e) { | 615 | } catch (UnsupportedEncodingException e) { |
558 | e.printStackTrace(); | 616 | e.printStackTrace(); |
559 | } | 617 | } |
560 | 618 | ||
561 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 619 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
562 | //Fresco设置圆形头像 | 620 | //Fresco设置圆形头像 |
563 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 621 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
564 | GenericDraweeHierarchy hierarchy = builder | 622 | GenericDraweeHierarchy hierarchy = builder |
565 | .setDesiredAspectRatio(1f) | 623 | .setDesiredAspectRatio(1f) |
566 | .setFailureImage(R.mipmap.blank) | 624 | .setFailureImage(R.mipmap.blank) |
567 | //圆形头像 | 625 | //圆形头像 |
568 | .setRoundingParams(RoundingParams.asCircle()) | 626 | .setRoundingParams(RoundingParams.asCircle()) |
569 | .build(); | 627 | .build(); |
570 | 628 | ||
571 | //加载本地图片 | 629 | //加载本地图片 |
572 | Uri uri = Uri.fromFile(cover); | 630 | Uri uri = Uri.fromFile(cover); |
573 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 631 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
574 | .setOldController(mSimpleDraweeView.getController()) | 632 | .setOldController(mSimpleDraweeView.getController()) |
575 | .setUri(uri) | 633 | .setUri(uri) |
576 | .build(); | 634 | .build(); |
577 | mSimpleDraweeView.setHierarchy(hierarchy); | 635 | mSimpleDraweeView.setHierarchy(hierarchy); |
578 | mSimpleDraweeView.setController(controller); | 636 | mSimpleDraweeView.setController(controller); |
579 | 637 | ||
580 | } | 638 | } |
581 | 639 | ||
582 | public void startPhotoZoom(Uri uri) { | 640 | public void startPhotoZoom(Uri uri) { |
583 | Intent intent = new Intent("com.android.camera.action.CROP"); | 641 | Intent intent = new Intent("com.android.camera.action.CROP"); |
584 | intent.setDataAndType(uri, "image/*"); | 642 | intent.setDataAndType(uri, "image/*"); |
585 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 643 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
586 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 644 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
587 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 645 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
588 | intent.putExtra("aspectY", 1);// x:y=1:1 | 646 | intent.putExtra("aspectY", 1);// x:y=1:1 |
589 | // intent.putExtra("outputX", 400);//图片输出大小 | 647 | // intent.putExtra("outputX", 400);//图片输出大小 |
590 | // intent.putExtra("outputY", 400); | 648 | // intent.putExtra("outputY", 400); |
591 | intent.putExtra("output", Uri.fromFile(file)); | 649 | intent.putExtra("output", Uri.fromFile(file)); |
592 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 650 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
593 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 651 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
594 | } | 652 | } |
595 | 653 | ||
596 | @Override | 654 | @Override |
597 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 655 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
598 | switch (requestCode) { | 656 | switch (requestCode) { |
599 | 657 | ||
600 | case PermissionUtil.REQUEST_SHOWCAMERA: | 658 | case PermissionUtil.REQUEST_SHOWCAMERA: |
601 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 659 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
602 | // Permission Granted | 660 | // Permission Granted |
603 | uploadAvatarFromPhotoRequest(); | 661 | uploadAvatarFromPhotoRequest(); |
604 | 662 | ||
605 | } else { | 663 | } else { |
606 | if (!SharedPreferenceMark.getHasShowCamera()) { | 664 | if (!SharedPreferenceMark.getHasShowCamera()) { |
607 | SharedPreferenceMark.setHasShowCamera(true); | 665 | SharedPreferenceMark.setHasShowCamera(true); |
608 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 666 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
609 | 667 | ||
610 | } else { | 668 | } else { |
611 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 669 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
612 | .show(); | 670 | .show(); |
613 | } | 671 | } |
614 | } | 672 | } |
615 | break; | 673 | break; |
616 | default: | 674 | default: |
617 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 675 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
618 | } | 676 | } |
619 | } | 677 | } |
678 | |||
620 | private long exitTime = 0; | 679 | private long exitTime = 0; |
680 | |||
621 | @Override | 681 | @Override |
622 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 682 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
623 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 683 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
624 | if ((System.currentTimeMillis() - exitTime) > 2000) { | 684 | if ((System.currentTimeMillis() - exitTime) > 2000) { |
625 | Toast.makeText(getApplicationContext(), "再按一次退出程序", | 685 | Toast.makeText(getApplicationContext(), "再按一次退出程序", |
626 | Toast.LENGTH_SHORT).show(); | 686 | Toast.LENGTH_SHORT).show(); |
627 | exitTime = System.currentTimeMillis(); | 687 | exitTime = System.currentTimeMillis(); |
628 | } else { | 688 | } else { |
629 | SysApplication.getInstance().exit(); | 689 | moveTaskToBack(false);//应用退到后台 |
690 | System.exit(0); |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
6 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
7 | import android.view.KeyEvent; | 7 | import android.view.KeyEvent; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.widget.Button; | 9 | import android.widget.Button; |
10 | import android.widget.EditText; | 10 | import android.widget.EditText; |
11 | import android.widget.TextView; | 11 | import android.widget.TextView; |
12 | 12 | ||
13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 14 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
15 | import com.hjx.personalcenter.customdialog.CountryDialog; | 15 | import com.hjx.personalcenter.customdialog.CountryDialog; |
16 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 16 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
17 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 17 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
18 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 18 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
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.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
23 | import com.hjx.personalcenter.model.CityInfo; | 23 | import com.hjx.personalcenter.model.CityInfo; |
24 | import com.hjx.personalcenter.model.CountyInfo; | 24 | import com.hjx.personalcenter.model.CountyInfo; |
25 | import com.hjx.personalcenter.model.GradeInfo; | 25 | import com.hjx.personalcenter.model.GradeInfo; |
26 | import com.hjx.personalcenter.model.ProvinceInfo; | 26 | import com.hjx.personalcenter.model.ProvinceInfo; |
27 | import com.hjx.personalcenter.model.SchoolInfo; | 27 | import com.hjx.personalcenter.model.SchoolInfo; |
28 | import com.hjx.personalcenter.util.AlertUtils; | 28 | import com.hjx.personalcenter.util.AlertUtils; |
29 | import com.hjx.personalcenter.util.GetDevicesUtil; | 29 | import com.hjx.personalcenter.util.GetDevicesUtil; |
30 | 30 | ||
31 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * 填写注册信息 熊巍 | 34 | * 填写注册信息 熊巍 |
35 | * Created by h on 2017/8/9. | 35 | * Created by h on 2017/8/9. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack | 38 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack |
39 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { | 39 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { |
40 | private EditText et_username; | 40 | private EditText et_username; |
41 | private TextView et_region, et_grade, et_school; | 41 | private TextView et_region, et_grade, et_school; |
42 | private Button btn_ok; | 42 | private Button btn_ok; |
43 | 43 | ||
44 | @Override | 44 | @Override |
45 | protected void onCreate(Bundle savedInstanceState) { | 45 | protected void onCreate(Bundle savedInstanceState) { |
46 | super.onCreate(savedInstanceState); | 46 | super.onCreate(savedInstanceState); |
47 | setContentView(R.layout.activity_registerinfo); | 47 | setContentView(R.layout.activity_registerinfo); |
48 | SysApplication.getInstance().addActivity(this); | 48 | SysApplication.getInstance().addActivity(this); |
49 | 49 | ||
50 | initView(); | 50 | initView(); |
51 | initData(); | 51 | initData(); |
52 | initLister(); | 52 | initLister(); |
53 | } | 53 | } |
54 | 54 | ||
55 | private void initView() { | 55 | private void initView() { |
56 | et_username = (EditText) findViewById(R.id.et_username); | 56 | et_username = (EditText) findViewById(R.id.et_username); |
57 | et_region = (TextView) findViewById(R.id.et_region); | 57 | et_region = (TextView) findViewById(R.id.et_region); |
58 | et_grade = (TextView) findViewById(R.id.et_grade); | 58 | et_grade = (TextView) findViewById(R.id.et_grade); |
59 | et_school = (TextView) findViewById(R.id.et_school); | 59 | et_school = (TextView) findViewById(R.id.et_school); |
60 | btn_ok = (Button) findViewById(R.id.btn_ok); | 60 | btn_ok = (Button) findViewById(R.id.btn_ok); |
61 | 61 | ||
62 | 62 | ||
63 | } | 63 | } |
64 | 64 | ||
65 | private void initData() { | 65 | private void initData() { |
66 | if (Content.accountflag == 2) { | 66 | if (Content.accountflag == 2) { |
67 | btn_ok.setText("提交"); | 67 | btn_ok.setText("提交"); |
68 | 68 | ||
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | private void initLister() { | 73 | private void initLister() { |
74 | et_region.setOnClickListener(this); | 74 | et_region.setOnClickListener(this); |
75 | et_grade.setOnClickListener(this); | 75 | et_grade.setOnClickListener(this); |
76 | et_school.setOnClickListener(this); | 76 | et_school.setOnClickListener(this); |
77 | btn_ok.setOnClickListener(this); | 77 | btn_ok.setOnClickListener(this); |
78 | 78 | ||
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | @Override | 82 | @Override |
83 | public void onClick(View v) { | 83 | public void onClick(View v) { |
84 | String register1 = et_username.getText().toString().trim(); | 84 | String register1 = et_username.getText().toString().trim(); |
85 | String register2 = et_region.getText().toString().trim(); | 85 | String register2 = et_region.getText().toString().trim(); |
86 | String register3 = et_grade.getText().toString().trim(); | 86 | String register3 = et_grade.getText().toString().trim(); |
87 | String register4 = et_school.getText().toString().trim(); | 87 | String register4 = et_school.getText().toString().trim(); |
88 | switch (v.getId()) { | 88 | switch (v.getId()) { |
89 | case R.id.et_region: | 89 | case R.id.et_region: |
90 | et_school.setText(""); | 90 | et_school.setText(""); |
91 | choiseregion(); | 91 | choiseregion(); |
92 | break; | 92 | break; |
93 | case R.id.et_grade: | 93 | case R.id.et_grade: |
94 | et_school.setText(""); | 94 | et_school.setText(""); |
95 | choisegrade(); | 95 | choisegrade(); |
96 | break; | 96 | break; |
97 | case R.id.et_school: | 97 | case R.id.et_school: |
98 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { | 98 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { |
99 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); | 99 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); |
100 | return; | 100 | return; |
101 | } else { | 101 | } else { |
102 | choiseschool(); | 102 | choiseschool(); |
103 | } | 103 | } |
104 | 104 | ||
105 | break; | 105 | break; |
106 | case R.id.btn_ok: | 106 | case R.id.btn_ok: |
107 | if (TextUtils.isEmpty(register1) || | 107 | if (TextUtils.isEmpty(register1) || |
108 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { | 108 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)) { |
109 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); | 109 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); |
110 | return; | 110 | return; |
111 | } else { | 111 | } else { |
112 | String register5 = et_username.getText().toString().trim(); | 112 | String register5 = et_username.getText().toString().trim(); |
113 | String register6 = et_region.getText().toString().trim(); | 113 | String register6 = et_region.getText().toString().trim(); |
114 | String register7 = et_grade.getText().toString().trim(); | 114 | String register7 = et_grade.getText().toString().trim(); |
115 | String register8 = et_school.getText().toString().trim(); | 115 | String register8 = et_school.getText().toString().trim(); |
116 | if (Content.accountflag == 2) { | 116 | if (Content.accountflag == 2) { |
117 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 117 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
118 | String grade = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS); | 118 | String grade = SaveParam.getInstance().getCustomizeParam(this, SaveParam.GRADENS); |
119 | String School = SaveParam.getInstance().getLoginParam(this, SaveParam.SCHOOOlID); | 119 | String School = SaveParam.getInstance().getLoginParam(this, SaveParam.SCHOOOlID); |
120 | String regionId = SaveParam.getInstance().getLoginParam(this, SaveParam.COUNTRY); | 120 | String regionId = SaveParam.getInstance().getsaveCityParam(this, SaveParam.COUNTRY); |
121 | String regionId1 = SaveParam.getInstance().getLoginParam(this, SaveParam.CITYS); | 121 | String regionId1 = SaveParam.getInstance().getsaveCityParam(this, SaveParam.CITYS); |
122 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); | 122 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
123 | if (regionId == null) { | 123 | if (regionId == null) { |
124 | regionId = regionId1; | 124 | regionId = regionId1; |
125 | } | 125 | } |
126 | 126 | ||
127 | try { | 127 | try { |
128 | Object schoolss; | 128 | Object schoolss; |
129 | long auserID = Long.parseLong(userID); | 129 | long auserID = Long.parseLong(userID); |
130 | long grades = Long.parseLong(grade); | 130 | long grades = Long.parseLong(grade); |
131 | if (TextUtils.isEmpty(register8)) { | 131 | if (TextUtils.isEmpty(register8)) { |
132 | schoolss = null; | 132 | schoolss = null; |
133 | } else { | 133 | } else { |
134 | schoolss = Long.parseLong(School); | 134 | schoolss = Long.parseLong(School); |
135 | } | 135 | } |
136 | long regionIds = Long.parseLong(regionId); | 136 | long regionIds = Long.parseLong(regionId); |
137 | HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this, auserID, "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", | 137 | HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this, auserID, "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", |
138 | register5, grades, schoolss, regionIds, devicenumber, register6); | 138 | register5, grades, schoolss, regionIds, devicenumber, register6); |
139 | 139 | ||
140 | } catch (NumberFormatException e) { | 140 | } catch (NumberFormatException e) { |
141 | e.printStackTrace(); | 141 | e.printStackTrace(); |
142 | } | 142 | } |
143 | 143 | ||
144 | } else { | 144 | } else { |
145 | savedata(); | 145 | savedata(); |
146 | Intent intent = new Intent(); | 146 | Intent intent = new Intent(); |
147 | intent.setClass(RegisterInfoActivity.this, ChoiseTextBookActivity.class); | 147 | intent.setClass(RegisterInfoActivity.this, ChoiseTextBookActivity.class); |
148 | startActivity(intent); | 148 | startActivity(intent); |
149 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 149 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
150 | } | 150 | } |
151 | 151 | ||
152 | } | 152 | } |
153 | 153 | ||
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | 156 | ||
157 | } | 157 | } |
158 | 158 | ||
159 | private void savedata() { | 159 | private void savedata() { |
160 | String register9 = et_username.getText().toString().trim(); | 160 | String register9 = et_username.getText().toString().trim(); |
161 | String register10 = et_region.getText().toString().trim(); | 161 | String register10 = et_region.getText().toString().trim(); |
162 | String register11 = et_grade.getText().toString().trim(); | 162 | String register11 = et_grade.getText().toString().trim(); |
163 | String register12 = et_school.getText().toString().trim(); | 163 | String register12 = et_school.getText().toString().trim(); |
164 | SaveParam.getInstance().saveLoginParam(this,SaveParam.USERNAME,register9); | 164 | SaveParam.getInstance().saveLoginParam(this,SaveParam.USERNAME,register9); |
165 | SaveParam.getInstance().saveLoginParam(this,SaveParam.ADRESS,register10); | 165 | SaveParam.getInstance().saveLoginParam(this,SaveParam.ADRESS,register10); |
166 | SaveParam.getInstance().saveLoginParam(this,SaveParam.GRADES,register11); | 166 | SaveParam.getInstance().saveLoginParam(this,SaveParam.GRADES,register11); |
167 | SaveParam.getInstance().saveLoginParam(this,SaveParam.SCHOOL,register12); | 167 | SaveParam.getInstance().saveLoginParam(this,SaveParam.SCHOOL,register12); |
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | @Override | 171 | @Override |
172 | protected void onResume() { | 172 | protected void onResume() { |
173 | super.onResume(); | 173 | super.onResume(); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | //选择地区 | 177 | //选择地区 |
178 | private void choiseregion() { | 178 | private void choiseregion() { |
179 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); | 179 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
180 | 180 | ||
181 | } | 181 | } |
182 | 182 | ||
183 | //选择年级 | 183 | //选择年级 |
184 | private void choisegrade() { | 184 | private void choisegrade() { |
185 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); | 185 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); |
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | //选择学校 | 189 | //选择学校 |
190 | private void choiseschool() { | 190 | private void choiseschool() { |
191 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); | 191 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); |
192 | 192 | ||
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | @Override | 196 | @Override |
197 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { | 197 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
198 | String regionName = data.get(position).getRegionName(); | 198 | String regionName = data.get(position).getRegionName(); |
199 | SaveParam.getInstance().saveLoginParam(this, "sheng", regionName); | 199 | SaveParam.getInstance().saveLoginParam(this, "sheng", regionName); |
200 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); | 200 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); |
201 | et_region.setText(""); | 201 | et_region.setText(""); |
202 | et_region.setText(regionName); | 202 | et_region.setText(regionName); |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | @Override | 206 | @Override |
207 | public boolean onKeyUp(int keyCode, KeyEvent event) { | 207 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
208 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 208 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
209 | finish(); | 209 | finish(); |
210 | 210 | ||
211 | } | 211 | } |
212 | return super.onKeyUp(keyCode, event); | 212 | return super.onKeyUp(keyCode, event); |
213 | } | 213 | } |
214 | 214 | ||
215 | @Override | 215 | @Override |
216 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | 216 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { |
217 | String regionName = data.get(position).getName(); | 217 | String regionName = data.get(position).getName(); |
218 | et_grade.setText(regionName); | 218 | et_grade.setText(regionName); |
219 | 219 | ||
220 | } | 220 | } |
221 | 221 | ||
222 | @Override | 222 | @Override |
223 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | 223 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { |
224 | String regionName = data.get(position).getRegionName(); | 224 | String regionName = data.get(position).getRegionName(); |
225 | String provice = SaveParam.getInstance().getLoginParam(this, "sheng"); | 225 | String provice = SaveParam.getInstance().getLoginParam(this, "sheng"); |
226 | SaveParam.getInstance().saveLoginParam(this, "shi", regionName); | 226 | SaveParam.getInstance().saveLoginParam(this, "shi", regionName); |
227 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); | 227 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); |
228 | et_region.setText(""); | 228 | et_region.setText(""); |
229 | et_region.setText(provice + regionName); | 229 | et_region.setText(provice + regionName); |
230 | 230 | ||
231 | } | 231 | } |
232 | 232 | ||
233 | @Override | 233 | @Override |
234 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { | 234 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { |
235 | String regionName = data.get(position).getRegionName(); | 235 | String regionName = data.get(position).getRegionName(); |
236 | String provices = SaveParam.getInstance().getLoginParam(this, "sheng"); | 236 | String provices = SaveParam.getInstance().getLoginParam(this, "sheng"); |
237 | String citys = SaveParam.getInstance().getLoginParam(this, "shi"); | 237 | String citys = SaveParam.getInstance().getLoginParam(this, "shi"); |
238 | et_region.setText(""); | 238 | et_region.setText(""); |
239 | et_region.setText(provices + citys + regionName); | 239 | et_region.setText(provices + citys + regionName); |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | @Override | 243 | @Override |
244 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { | 244 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { |
245 | String regionName = data.get(position).getSchoolName(); | 245 | String regionName = data.get(position).getSchoolName(); |
246 | et_school.setText(regionName); | 246 | et_school.setText(regionName); |
247 | 247 | ||
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/TheStartPageActivity.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.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
6 | import android.view.View; | 6 | import android.view.View; |
7 | import android.widget.Button; | 7 | import android.widget.Button; |
8 | 8 | ||
9 | import com.hjx.personalcenter.R; | 9 | import com.hjx.personalcenter.R; |
10 | import com.hjx.personalcenter.db.SaveParam; | 10 | import com.hjx.personalcenter.db.SaveParam; |
11 | 11 | ||
12 | /** | 12 | /** |
13 | * Created by h on 2017/8/10. | 13 | * Created by h on 2017/8/10. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | public class TheStartPageActivity extends AppCompatActivity implements View.OnClickListener { | 16 | public class TheStartPageActivity extends AppCompatActivity implements View.OnClickListener { |
17 | private Button btn_start; | 17 | private Button btn_start; |
18 | @Override | 18 | @Override |
19 | protected void onCreate(Bundle savedInstanceState) { | 19 | protected void onCreate(Bundle savedInstanceState) { |
20 | super.onCreate(savedInstanceState); | 20 | super.onCreate(savedInstanceState); |
21 | setContentView(R.layout.activity_start_page); | 21 | setContentView(R.layout.activity_start_page); |
22 | SysApplication.getInstance().addActivity(this); | 22 | SysApplication.getInstance().addActivity(this); |
23 | initView(); | 23 | initView(); |
24 | initData(); | 24 | initData(); |
25 | initLister(); | 25 | initLister(); |
26 | } | 26 | } |
27 | private void initView() { | 27 | private void initView() { |
28 | btn_start = (Button) findViewById(R.id.btn_start); | 28 | btn_start = (Button) findViewById(R.id.btn_start); |
29 | } | 29 | } |
30 | 30 | ||
31 | private void initData() { | 31 | private void initData() { |
32 | 32 | ||
33 | } | 33 | } |
34 | 34 | ||
35 | private void initLister() { | 35 | private void initLister() { |
36 | btn_start.setOnClickListener(this); | 36 | btn_start.setOnClickListener(this); |
37 | } | 37 | } |
38 | 38 | ||
39 | @Override | 39 | @Override |
40 | public void onClick(View v) { | 40 | public void onClick(View v) { |
41 | switch (v.getId()){ | 41 | switch (v.getId()){ |
42 | case R.id.btn_start: | 42 | case R.id.btn_start: |
43 | SaveParam.getInstance().saveLoginParam(this, "login", "true"); | 43 | SaveParam.getInstance().saveLoginParam(this, "login", "true"); |
44 | Intent intent = new Intent(); | 44 | Intent intent = new Intent(); |
45 | intent.setClass(TheStartPageActivity.this,MainActivity.class); | 45 | intent.setClass(TheStartPageActivity.this,MainActivity.class); |
46 | startActivity(intent); | 46 | startActivity(intent); |
47 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 47 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
48 | finish(); | 48 | SysApplication.getInstance().exit(); |
49 | break; | 49 | break; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/CitysListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.util.Log; | ||
9 | import android.view.Gravity; | 10 | import android.view.Gravity; |
10 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
11 | import android.view.View; | 12 | import android.view.View; |
12 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
13 | import android.widget.AdapterView; | 14 | import android.widget.AdapterView; |
14 | import android.widget.ImageView; | 15 | import android.widget.ImageView; |
15 | import android.widget.ListView; | 16 | import android.widget.ListView; |
16 | 17 | ||
17 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.adapter.CitysAdapter; | 19 | import com.hjx.personalcenter.adapter.CitysAdapter; |
19 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
20 | import com.hjx.personalcenter.http.HttpCode; | 21 | import com.hjx.personalcenter.http.HttpCode; |
21 | import com.hjx.personalcenter.http.HttpManager; | 22 | import com.hjx.personalcenter.http.HttpManager; |
22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 23 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
23 | import com.hjx.personalcenter.model.CityInfo; | 24 | import com.hjx.personalcenter.model.CityInfo; |
24 | import com.mylhyl.circledialog.BaseCircleDialog; | 25 | import com.mylhyl.circledialog.BaseCircleDialog; |
25 | import com.mylhyl.circledialog.res.values.CircleDimen; | 26 | import com.mylhyl.circledialog.res.values.CircleDimen; |
26 | 27 | ||
27 | import java.util.ArrayList; | 28 | import java.util.ArrayList; |
28 | import java.util.List; | 29 | import java.util.List; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * 自定义市级列表对话框 | 32 | * 自定义市级列表对话框 |
32 | * Created by h on 2017/8/10. | 33 | * Created by h on 2017/8/10. |
33 | */ | 34 | */ |
34 | @SuppressLint("ValidFragment") | 35 | @SuppressLint("ValidFragment") |
35 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 36 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
36 | private CitysAdapter listadapter; | 37 | private CitysAdapter listadapter; |
37 | private ListView listView; | 38 | private ListView listView; |
38 | private ImageView cance; | 39 | private ImageView cance; |
39 | private Context context; | 40 | private Context context; |
40 | private DialogCallBack.CitysCallBack mCallBack; | 41 | private DialogCallBack.CitysCallBack mCallBack; |
41 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); | 42 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); |
42 | public CitysListDialog() { | 43 | public CitysListDialog() { |
43 | context= getActivity(); | 44 | context= getActivity(); |
44 | } | 45 | } |
45 | public CitysListDialog(DialogCallBack.CitysCallBack callBack) { | 46 | public CitysListDialog(DialogCallBack.CitysCallBack callBack) { |
46 | this.mCallBack = callBack; | 47 | this.mCallBack = callBack; |
47 | } | 48 | } |
48 | 49 | ||
49 | 50 | ||
50 | public static CitysListDialog getInstance(DialogCallBack.CitysCallBack callBack) { | 51 | public static CitysListDialog getInstance(DialogCallBack.CitysCallBack callBack) { |
51 | CitysListDialog dialogFragment = new CitysListDialog(callBack); | 52 | CitysListDialog dialogFragment = new CitysListDialog(callBack); |
52 | dialogFragment.setCanceledBack(true); | 53 | dialogFragment.setCanceledBack(true); |
53 | dialogFragment.setCanceledOnTouchOutside(false); | 54 | dialogFragment.setCanceledOnTouchOutside(false); |
54 | dialogFragment.setRadius(CircleDimen.RADIUS); | 55 | dialogFragment.setRadius(CircleDimen.RADIUS); |
55 | dialogFragment.setWidth(0.5f); | 56 | dialogFragment.setWidth(0.5f); |
56 | dialogFragment.setGravity(Gravity.CENTER); | 57 | dialogFragment.setGravity(Gravity.CENTER); |
57 | dialogFragment.setBackgroundColor(Color.WHITE); | 58 | dialogFragment.setBackgroundColor(Color.WHITE); |
58 | return dialogFragment; | 59 | return dialogFragment; |
59 | } | 60 | } |
60 | Handler handler = new Handler(){ | 61 | Handler handler = new Handler(){ |
61 | @Override | 62 | @Override |
62 | public void handleMessage(Message msg) { | 63 | public void handleMessage(Message msg) { |
63 | super.handleMessage(msg); | 64 | super.handleMessage(msg); |
64 | switch (msg.what){ | 65 | switch (msg.what){ |
65 | case HttpCode.CITYS: | 66 | case HttpCode.CITYS: |
66 | data.clear(); | 67 | data.clear(); |
67 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); | 68 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); |
68 | if (data==null){ | 69 | if (data==null){ |
69 | dismiss(); | 70 | dismiss(); |
70 | } | 71 | } |
71 | listadapter.notifyDataSetChanged(); | 72 | listadapter.notifyDataSetChanged(); |
72 | break; | 73 | break; |
73 | } | 74 | } |
74 | } | 75 | } |
75 | }; | 76 | }; |
76 | 77 | ||
77 | @Override | 78 | @Override |
78 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 79 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
79 | return inflater.inflate(R.layout.custom_adilog_cityslist, container, false); | 80 | return inflater.inflate(R.layout.custom_adilog_cityslist, container, false); |
80 | } | 81 | } |
81 | 82 | ||
82 | @Override | 83 | @Override |
83 | public void onActivityCreated(Bundle savedInstanceState) { | 84 | public void onActivityCreated(Bundle savedInstanceState) { |
84 | super.onActivityCreated(savedInstanceState); | 85 | super.onActivityCreated(savedInstanceState); |
85 | listView = (ListView) getView().findViewById(R.id.listadapter); | 86 | listView = (ListView) getView().findViewById(R.id.listadapter); |
86 | cance = (ImageView) getView().findViewById(R.id.cancel); | 87 | cance = (ImageView) getView().findViewById(R.id.cancel); |
87 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); | 88 | String citys = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.PROVINCES); |
88 | listadapter = new CitysAdapter(data,getActivity()); | 89 | listadapter = new CitysAdapter(data,getActivity()); |
89 | listView.setAdapter(listadapter); | 90 | listView.setAdapter(listadapter); |
90 | listView.setOnItemClickListener(this); | 91 | listView.setOnItemClickListener(this); |
91 | cance.setOnClickListener(new View.OnClickListener() { | 92 | cance.setOnClickListener(new View.OnClickListener() { |
92 | @Override | 93 | @Override |
93 | public void onClick(View v) { | 94 | public void onClick(View v) { |
94 | dismiss(); | 95 | dismiss(); |
95 | } | 96 | } |
96 | }); | 97 | }); |
97 | try { | 98 | try { |
98 | long a = Long.parseLong(citys); | 99 | long a = Long.parseLong(citys); |
99 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); | 100 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); |
100 | } catch (NumberFormatException e) { | 101 | } catch (NumberFormatException e) { |
101 | e.printStackTrace(); | 102 | e.printStackTrace(); |
102 | } | 103 | } |
103 | 104 | ||
104 | 105 | ||
105 | } | 106 | } |
106 | 107 | ||
107 | @Override | 108 | @Override |
108 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 109 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
109 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); | 110 | SaveParam.getInstance().saveCityParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); |
111 | Log.e("test","CITYS"+data.get(position).getRegionId()); | ||
110 | mCallBack.province1OnItemClick(data,position,2); | 112 | mCallBack.province1OnItemClick(data,position,2); |
111 | dismiss(); | 113 | dismiss(); |
112 | 114 | ||
113 | } | 115 | } |
114 | } | 116 | } |
115 | 117 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/CountryDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
15 | import android.widget.ListView; | 15 | import android.widget.ListView; |
16 | 16 | ||
17 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.adapter.CountryAdapter; | 18 | import com.hjx.personalcenter.adapter.CountryAdapter; |
19 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
20 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
21 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
23 | import com.hjx.personalcenter.model.CountyInfo; | 23 | import com.hjx.personalcenter.model.CountyInfo; |
24 | import com.mylhyl.circledialog.BaseCircleDialog; | 24 | import com.mylhyl.circledialog.BaseCircleDialog; |
25 | import com.mylhyl.circledialog.res.values.CircleDimen; | 25 | import com.mylhyl.circledialog.res.values.CircleDimen; |
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 | * Created by wei on 2017/8/21. | 31 | * Created by wei on 2017/8/21. |
32 | */ | 32 | */ |
33 | @SuppressLint("ValidFragment") | 33 | @SuppressLint("ValidFragment") |
34 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 34 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
35 | private CountryAdapter listadapter; | 35 | private CountryAdapter listadapter; |
36 | private ListView listView; | 36 | private ListView listView; |
37 | private ImageView cance; | 37 | private ImageView cance; |
38 | private DialogCallBack.CountryCallBack mCallBack; | 38 | private DialogCallBack.CountryCallBack mCallBack; |
39 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); | 39 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); |
40 | public CountryDialog(DialogCallBack.CountryCallBack callBack) { | 40 | public CountryDialog(DialogCallBack.CountryCallBack callBack) { |
41 | this.mCallBack = callBack; | 41 | this.mCallBack = callBack; |
42 | } | 42 | } |
43 | public static CountryDialog getInstance(DialogCallBack.CountryCallBack callBack) { | 43 | public static CountryDialog getInstance(DialogCallBack.CountryCallBack callBack) { |
44 | CountryDialog dialogFragment = new CountryDialog(callBack); | 44 | CountryDialog dialogFragment = new CountryDialog(callBack); |
45 | dialogFragment.setCanceledBack(true); | 45 | dialogFragment.setCanceledBack(true); |
46 | dialogFragment.setCanceledOnTouchOutside(true); | 46 | dialogFragment.setCanceledOnTouchOutside(true); |
47 | dialogFragment.setRadius(CircleDimen.RADIUS); | 47 | dialogFragment.setRadius(CircleDimen.RADIUS); |
48 | dialogFragment.setWidth(0.5f); | 48 | dialogFragment.setWidth(0.5f); |
49 | dialogFragment.setGravity(Gravity.CENTER); | 49 | dialogFragment.setGravity(Gravity.CENTER); |
50 | dialogFragment.setBackgroundColor(Color.WHITE); | 50 | dialogFragment.setBackgroundColor(Color.WHITE); |
51 | return dialogFragment; | 51 | return dialogFragment; |
52 | } | 52 | } |
53 | Handler handler = new Handler(){ | 53 | Handler handler = new Handler(){ |
54 | @Override | 54 | @Override |
55 | public void handleMessage(Message msg) { | 55 | public void handleMessage(Message msg) { |
56 | super.handleMessage(msg); | 56 | super.handleMessage(msg); |
57 | switch (msg.what){ | 57 | switch (msg.what){ |
58 | case HttpCode.COUNTRY: | 58 | case HttpCode.COUNTRY: |
59 | 59 | ||
60 | data.clear(); | 60 | data.clear(); |
61 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); | 61 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); |
62 | if (data==null){ | 62 | if (data==null){ |
63 | dismiss(); | 63 | dismiss(); |
64 | } | 64 | } |
65 | listadapter.notifyDataSetChanged(); | 65 | listadapter.notifyDataSetChanged(); |
66 | break; | 66 | break; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | @Override | 71 | @Override |
72 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 72 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
73 | return inflater.inflate(R.layout.custom_adilog_countrylist, container, false); | 73 | return inflater.inflate(R.layout.custom_adilog_countrylist, container, false); |
74 | } | 74 | } |
75 | 75 | ||
76 | @Override | 76 | @Override |
77 | public void onActivityCreated(Bundle savedInstanceState) { | 77 | public void onActivityCreated(Bundle savedInstanceState) { |
78 | super.onActivityCreated(savedInstanceState); | 78 | super.onActivityCreated(savedInstanceState); |
79 | listView = (ListView) getView().findViewById(R.id.listadapter); | 79 | listView = (ListView) getView().findViewById(R.id.listadapter); |
80 | cance = (ImageView) getView().findViewById(R.id.cancel); | 80 | cance = (ImageView) getView().findViewById(R.id.cancel); |
81 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 81 | String citys = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.CITYS); |
82 | listadapter = new CountryAdapter(data,getActivity()); | 82 | listadapter = new CountryAdapter(data,getActivity()); |
83 | listView.setAdapter(listadapter); | 83 | listView.setAdapter(listadapter); |
84 | listView.setOnItemClickListener(this); | 84 | listView.setOnItemClickListener(this); |
85 | cance.setOnClickListener(new View.OnClickListener() { | 85 | cance.setOnClickListener(new View.OnClickListener() { |
86 | @Override | 86 | @Override |
87 | public void onClick(View v) { | 87 | public void onClick(View v) { |
88 | dismiss(); | 88 | dismiss(); |
89 | } | 89 | } |
90 | }); | 90 | }); |
91 | try { | 91 | try { |
92 | int a = Integer.parseInt(citys); | 92 | int a = Integer.parseInt(citys); |
93 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); | 93 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); |
94 | } catch (NumberFormatException e) { | 94 | } catch (NumberFormatException e) { |
95 | e.printStackTrace(); | 95 | e.printStackTrace(); |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | } | 99 | } |
100 | 100 | ||
101 | @Override | 101 | @Override |
102 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 102 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
103 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.COUNTRY, ""+data.get(position).getRegionId()); | 103 | SaveParam.getInstance().saveCityParam(getActivity(), SaveParam.COUNTRY, ""+data.get(position).getRegionId()); |
104 | mCallBack.province2OnItemClick(data,position,3); | 104 | mCallBack.province2OnItemClick(data,position,3); |
105 | dismiss(); | 105 | dismiss(); |
106 | 106 | ||
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
15 | import android.widget.ListView; | 15 | import android.widget.ListView; |
16 | 16 | ||
17 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.adapter.ProvincesAdapter; | 18 | import com.hjx.personalcenter.adapter.ProvincesAdapter; |
19 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
20 | import com.hjx.personalcenter.http.HttpCode; | 20 | import com.hjx.personalcenter.http.HttpCode; |
21 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
23 | import com.hjx.personalcenter.model.ProvinceInfo; | 23 | import com.hjx.personalcenter.model.ProvinceInfo; |
24 | import com.mylhyl.circledialog.BaseCircleDialog; | 24 | import com.mylhyl.circledialog.BaseCircleDialog; |
25 | import com.mylhyl.circledialog.res.values.CircleDimen; | 25 | import com.mylhyl.circledialog.res.values.CircleDimen; |
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/10. | 32 | * Created by h on 2017/8/10. |
33 | */ | 33 | */ |
34 | @SuppressLint("ValidFragment") | 34 | @SuppressLint("ValidFragment") |
35 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 35 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
36 | private ProvincesAdapter listadapter; | 36 | private ProvincesAdapter listadapter; |
37 | private ImageView cance; | 37 | private ImageView cance; |
38 | private ListView listView; | 38 | private ListView listView; |
39 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); | 39 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); |
40 | 40 | ||
41 | private DialogCallBack.ProvincesCallBack mCallBack; | 41 | private DialogCallBack.ProvincesCallBack mCallBack; |
42 | 42 | ||
43 | Handler handler = new Handler(){ | 43 | Handler handler = new Handler(){ |
44 | @Override | 44 | @Override |
45 | public void handleMessage(Message msg) { | 45 | public void handleMessage(Message msg) { |
46 | super.handleMessage(msg); | 46 | super.handleMessage(msg); |
47 | switch (msg.what){ | 47 | switch (msg.what){ |
48 | case HttpCode.PROVICES: | 48 | case HttpCode.PROVICES: |
49 | data.clear(); | 49 | data.clear(); |
50 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); | 50 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); |
51 | listadapter.notifyDataSetChanged(); | 51 | listadapter.notifyDataSetChanged(); |
52 | 52 | ||
53 | break; | 53 | break; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | }; | 56 | }; |
57 | public ProvinceListDialog(DialogCallBack.ProvincesCallBack callBack) { | 57 | public ProvinceListDialog(DialogCallBack.ProvincesCallBack callBack) { |
58 | this.mCallBack = callBack; | 58 | this.mCallBack = callBack; |
59 | } | 59 | } |
60 | 60 | ||
61 | public static ProvinceListDialog getInstance(DialogCallBack.ProvincesCallBack callBack) { | 61 | public static ProvinceListDialog getInstance(DialogCallBack.ProvincesCallBack callBack) { |
62 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); | 62 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); |
63 | dialogFragment.setCanceledBack(true); | 63 | dialogFragment.setCanceledBack(true); |
64 | dialogFragment.setCanceledOnTouchOutside(true); | 64 | dialogFragment.setCanceledOnTouchOutside(true); |
65 | dialogFragment.setRadius(CircleDimen.RADIUS); | 65 | dialogFragment.setRadius(CircleDimen.RADIUS); |
66 | dialogFragment.setWidth(0.5f); | 66 | dialogFragment.setWidth(0.5f); |
67 | dialogFragment.setGravity(Gravity.CENTER); | 67 | dialogFragment.setGravity(Gravity.CENTER); |
68 | dialogFragment.setBackgroundColor(Color.WHITE); | 68 | dialogFragment.setBackgroundColor(Color.WHITE); |
69 | return dialogFragment; | 69 | return dialogFragment; |
70 | } | 70 | } |
71 | 71 | ||
72 | @Override | 72 | @Override |
73 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 73 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
74 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 74 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
75 | } | 75 | } |
76 | 76 | ||
77 | @Override | 77 | @Override |
78 | public void onActivityCreated(Bundle savedInstanceState) { | 78 | public void onActivityCreated(Bundle savedInstanceState) { |
79 | super.onActivityCreated(savedInstanceState); | 79 | super.onActivityCreated(savedInstanceState); |
80 | listView = (ListView) getView().findViewById(R.id.listadapter); | 80 | listView = (ListView) getView().findViewById(R.id.listadapter); |
81 | cance = (ImageView) getView().findViewById(R.id.cancel); | 81 | cance = (ImageView) getView().findViewById(R.id.cancel); |
82 | listadapter = new ProvincesAdapter(data,getActivity()); | 82 | listadapter = new ProvincesAdapter(data,getActivity()); |
83 | listView.setAdapter(listadapter); | 83 | listView.setAdapter(listadapter); |
84 | listView.setOnItemClickListener(this); | 84 | listView.setOnItemClickListener(this); |
85 | cance.setOnClickListener(new View.OnClickListener() { | 85 | cance.setOnClickListener(new View.OnClickListener() { |
86 | @Override | 86 | @Override |
87 | public void onClick(View v) { | 87 | public void onClick(View v) { |
88 | dismiss(); | 88 | dismiss(); |
89 | } | 89 | } |
90 | }); | 90 | }); |
91 | HttpManager.getInstance().provices(getActivity(),handler); | 91 | HttpManager.getInstance().provices(getActivity(),handler); |
92 | 92 | ||
93 | } | 93 | } |
94 | 94 | ||
95 | @Override | 95 | @Override |
96 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 96 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
97 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); | 97 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); |
98 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); | 98 | SaveParam.getInstance().clearsaveCityParam(getActivity()); |
99 | SaveParam.getInstance().saveCityParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); | ||
99 | mCallBack.provinceOnItemClick(data,position,1); | 100 | mCallBack.provinceOnItemClick(data,position,1); |
100 | dismiss(); | 101 | dismiss(); |
101 | 102 | ||
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/SchoolListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.text.Editable; | 9 | import android.text.Editable; |
10 | import android.text.TextWatcher; | 10 | import android.text.TextWatcher; |
11 | import android.util.Log; | ||
11 | import android.view.Gravity; | 12 | import android.view.Gravity; |
12 | import android.view.LayoutInflater; | 13 | import android.view.LayoutInflater; |
13 | import android.view.View; | 14 | import android.view.View; |
14 | import android.view.ViewGroup; | 15 | import android.view.ViewGroup; |
15 | import android.widget.AdapterView; | 16 | import android.widget.AdapterView; |
16 | import android.widget.EditText; | 17 | import android.widget.EditText; |
17 | import android.widget.ImageView; | 18 | import android.widget.ImageView; |
18 | import android.widget.ListView; | 19 | import android.widget.ListView; |
19 | 20 | ||
20 | import com.hjx.personalcenter.R; | 21 | import com.hjx.personalcenter.R; |
21 | import com.hjx.personalcenter.adapter.SchoolAdapter; | 22 | import com.hjx.personalcenter.adapter.SchoolAdapter; |
22 | import com.hjx.personalcenter.db.SaveParam; | 23 | import com.hjx.personalcenter.db.SaveParam; |
23 | import com.hjx.personalcenter.http.HttpCode; | 24 | import com.hjx.personalcenter.http.HttpCode; |
24 | import com.hjx.personalcenter.http.HttpManager; | 25 | import com.hjx.personalcenter.http.HttpManager; |
25 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 26 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
26 | import com.hjx.personalcenter.model.SchoolInfo; | 27 | import com.hjx.personalcenter.model.SchoolInfo; |
27 | import com.mylhyl.circledialog.BaseCircleDialog; | 28 | import com.mylhyl.circledialog.BaseCircleDialog; |
28 | import com.mylhyl.circledialog.res.values.CircleDimen; | 29 | import com.mylhyl.circledialog.res.values.CircleDimen; |
29 | 30 | ||
30 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
31 | import java.util.List; | 32 | import java.util.List; |
32 | 33 | ||
33 | /** | 34 | /** |
34 | * Created by h on 2017/8/21. | 35 | * Created by h on 2017/8/21. |
35 | */ | 36 | */ |
36 | @SuppressLint("ValidFragment") | 37 | @SuppressLint("ValidFragment") |
37 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 38 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
38 | private ListView school_list; | 39 | private ListView school_list; |
39 | private EditText school_sech; | 40 | private EditText school_sech; |
40 | private SchoolAdapter listadapter; | 41 | private SchoolAdapter listadapter; |
41 | private ImageView cance; | 42 | private ImageView cance; |
42 | private View mView; | 43 | private View mView; |
43 | boolean isFilter; | 44 | boolean isFilter; |
44 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); | 45 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); |
45 | private DialogCallBack.SchoolCallBack mCallBack; | 46 | private DialogCallBack.SchoolCallBack mCallBack; |
46 | 47 | ||
47 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { | 48 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { |
48 | // this.mCallBack = callBack; | 49 | // this.mCallBack = callBack; |
49 | // } | 50 | // } |
50 | public SchoolListDialog(DialogCallBack.SchoolCallBack callBack) { | 51 | public SchoolListDialog(DialogCallBack.SchoolCallBack callBack) { |
51 | this.mCallBack = callBack; | 52 | this.mCallBack = callBack; |
52 | } | 53 | } |
53 | 54 | ||
54 | public static SchoolListDialog getInstance(DialogCallBack.SchoolCallBack mCallBack) { | 55 | public static SchoolListDialog getInstance(DialogCallBack.SchoolCallBack mCallBack) { |
55 | SchoolListDialog dialogFragment = new SchoolListDialog(mCallBack); | 56 | SchoolListDialog dialogFragment = new SchoolListDialog(mCallBack); |
56 | dialogFragment.setCanceledBack(true); | 57 | dialogFragment.setCanceledBack(true); |
57 | dialogFragment.setCanceledOnTouchOutside(true); | 58 | dialogFragment.setCanceledOnTouchOutside(true); |
58 | dialogFragment.setRadius(CircleDimen.RADIUS); | 59 | dialogFragment.setRadius(CircleDimen.RADIUS); |
59 | dialogFragment.setWidth(0.5f); | 60 | dialogFragment.setWidth(0.5f); |
60 | dialogFragment.setGravity(Gravity.CENTER); | 61 | dialogFragment.setGravity(Gravity.CENTER); |
61 | dialogFragment.setBackgroundColor(Color.WHITE); | 62 | dialogFragment.setBackgroundColor(Color.WHITE); |
62 | return dialogFragment; | 63 | return dialogFragment; |
63 | } | 64 | } |
64 | 65 | ||
65 | Handler handler = new Handler(){ | 66 | Handler handler = new Handler(){ |
66 | @Override | 67 | @Override |
67 | public void handleMessage(Message msg) { | 68 | public void handleMessage(Message msg) { |
68 | super.handleMessage(msg); | 69 | super.handleMessage(msg); |
69 | switch (msg.what){ | 70 | switch (msg.what){ |
70 | case HttpCode.SCHOOL: | 71 | case HttpCode.SCHOOL: |
71 | data.clear(); | 72 | data.clear(); |
72 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); | 73 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); |
73 | listadapter.notifyDataSetChanged(); | 74 | listadapter.notifyDataSetChanged(); |
74 | break; | 75 | break; |
75 | } | 76 | } |
76 | } | 77 | } |
77 | }; | 78 | }; |
78 | 79 | ||
79 | 80 | ||
80 | @Override | 81 | @Override |
81 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 82 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
82 | 83 | ||
83 | if (mView == null) { | 84 | if (mView == null) { |
84 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); | 85 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); |
85 | //mCallBack.provinceOnItemClick(context, inflater, container); | 86 | //mCallBack.provinceOnItemClick(context, inflater, container); |
86 | } | 87 | } |
87 | return mView; | 88 | return mView; |
88 | } | 89 | } |
89 | 90 | ||
90 | @Override | 91 | @Override |
91 | public void onActivityCreated(Bundle savedInstanceState) { | 92 | public void onActivityCreated(Bundle savedInstanceState) { |
92 | super.onActivityCreated(savedInstanceState); | 93 | super.onActivityCreated(savedInstanceState); |
93 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); | 94 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); |
94 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); | 95 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); |
95 | cance = (ImageView) getView().findViewById(R.id.cancel); | 96 | cance = (ImageView) getView().findViewById(R.id.cancel); |
96 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 97 | String citys = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.CITYS); |
98 | String country = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.COUNTRY); | ||
99 | if (country==null){ | ||
100 | country =citys; | ||
101 | } | ||
97 | String grade = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.GRADENS); | 102 | String grade = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.GRADENS); |
98 | listadapter = new SchoolAdapter(data, getActivity()); | 103 | listadapter = new SchoolAdapter(data, getActivity()); |
99 | school_list.setAdapter(listadapter); | 104 | school_list.setAdapter(listadapter); |
100 | school_list.setOnItemClickListener(this); | 105 | school_list.setOnItemClickListener(this); |
101 | cance.setOnClickListener(new View.OnClickListener() { | 106 | cance.setOnClickListener(new View.OnClickListener() { |
102 | @Override | 107 | @Override |
103 | public void onClick(View v) { | 108 | public void onClick(View v) { |
104 | dismiss(); | 109 | dismiss(); |
105 | } | 110 | } |
106 | }); | 111 | }); |
107 | try { | 112 | try { |
108 | int a = Integer.parseInt(citys); | 113 | int a = Integer.parseInt(country); |
109 | int b = Integer.parseInt(grade); | 114 | int b = Integer.parseInt(grade); |
115 | Log.e("test","地区ID"+country+"年级ID"+grade); | ||
110 | HttpManager.getInstance().getschool(getActivity(),a,b,handler); | 116 | HttpManager.getInstance().getschool(getActivity(),a,b,handler); |
111 | } catch (NumberFormatException e) { | 117 | } catch (NumberFormatException e) { |
112 | e.printStackTrace(); | 118 | e.printStackTrace(); |
113 | } | 119 | } |
114 | intiEditView(); | 120 | intiEditView(); |
115 | 121 | ||
116 | 122 | ||
117 | } | 123 | } |
118 | private void intiEditView() { | 124 | private void intiEditView() { |
119 | school_sech.addTextChangedListener(new TextWatcher() { | 125 | school_sech.addTextChangedListener(new TextWatcher() { |
120 | @Override | 126 | @Override |
121 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | 127 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
122 | 128 | ||
123 | } | 129 | } |
124 | 130 | ||
125 | @Override | 131 | @Override |
126 | public void onTextChanged(CharSequence s, int start, int before, int count) { | 132 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
127 | // mAdapter.getFilter().filter(s); | 133 | // mAdapter.getFilter().filter(s); |
128 | 134 | ||
129 | listadapter.getFilter().filter(s); | 135 | listadapter.getFilter().filter(s); |
130 | } | 136 | } |
131 | 137 | ||
132 | @Override | 138 | @Override |
133 | public void afterTextChanged(Editable s) { | 139 | public void afterTextChanged(Editable s) { |
134 | 140 | ||
135 | } | 141 | } |
136 | }); | 142 | }); |
137 | } | 143 | } |
138 | 144 | ||
139 | @Override | 145 | @Override |
140 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 146 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
141 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.SCHOOOlID, ""+data.get(position).getSchoolId()); | 147 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.SCHOOOlID, ""+data.get(position).getSchoolId()); |
142 | mCallBack.provinceO4nItemClick(data,position,4); | 148 | mCallBack.provinceO4nItemClick(data,position,4); |
143 | dismiss(); | 149 | dismiss(); |
144 | 150 | ||
145 | } | 151 | } |
146 | } | 152 | } |
147 | 153 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
1 | package com.hjx.personalcenter.db; | 1 | package com.hjx.personalcenter.db; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.content.SharedPreferences; | 5 | import android.content.SharedPreferences; |
6 | 6 | ||
7 | public class SaveParam { | 7 | public class SaveParam { |
8 | 8 | ||
9 | private static SaveParam instance; | 9 | private static SaveParam instance; |
10 | public static SaveParam getInstance(){ | 10 | public static SaveParam getInstance(){ |
11 | if (instance==null){ | 11 | if (instance==null){ |
12 | instance = new SaveParam(); | 12 | instance = new SaveParam(); |
13 | } | 13 | } |
14 | return instance; | 14 | return instance; |
15 | } | 15 | } |
16 | public static String CHILDSID = "childID";//子账号id | 16 | public static String CHILDSID = "childID";//子账号id |
17 | public static String CHILDSGRADENS = "childs";//子账号年级id | 17 | public static String CHILDSGRADENS = "childs";//子账号年级id |
18 | public static String GRADENS = "gradens";//年级id | 18 | public static String GRADENS = "gradens";//年级id |
19 | public static String SCHOOOlID = "schoolid";//学校id | 19 | public static String SCHOOOlID = "schoolid";//学校id |
20 | //个人信息 | 20 | //个人信息 |
21 | public static String USERNAME = "usernames";//昵称 | 21 | public static String USERNAME = "usernames";//昵称 |
22 | public static String ADRESS = "adress";//地址 | 22 | public static String ADRESS = "adress";//地址 |
23 | public static String GRADES = "gadens";//年级 | 23 | public static String GRADES = "gadens";//年级 |
24 | public static String SCHOOL = "school";//学校 | 24 | public static String SCHOOL = "school";//学校 |
25 | public static String CONSTELLATION = "constellations";//星座 | 25 | public static String CONSTELLATION = "constellations";//星座 |
26 | public static String HEADURL = "headurl";//星座 | 26 | public static String HEADURL = "headurl";//星座 |
27 | 27 | ||
28 | //电子保卡信息 | 28 | //电子保卡信息 |
29 | public static String CARDPHONE = "cardphone";//保卡手机号 | 29 | public static String CARDPHONE = "cardphone";//保卡手机号 |
30 | public static String CUNSTEMNAME = "cunstemname";//客户姓名 | 30 | public static String CUNSTEMNAME = "cunstemname";//客户姓名 |
31 | public static String ADRESSCUNSTEM = "adresscunstem";//客户地址 | 31 | public static String ADRESSCUNSTEM = "adresscunstem";//客户地址 |
32 | public static String SHOPTIME = "shoptime";//购买时间 | 32 | public static String SHOPTIME = "shoptime";//购买时间 |
33 | public static String SHOPADRESS = "shopadress";//购买地址 | 33 | public static String SHOPADRESS = "shopadress";//购买地址 |
34 | public static String SHOPTLEPHONE = "shoptlephone";//售后电话 | 34 | public static String SHOPTLEPHONE = "shoptlephone";//售后电话 |
35 | 35 | ||
36 | //省市区参数、 | 36 | //省市区参数、 |
37 | public static String PROVINCES = "provinces";//省 | 37 | public static String PROVINCES = "provinces";//省 |
38 | public static String CITYS = "citys";//市 | 38 | public static String CITYS = "citys";//市 |
39 | public static String COUNTRY = "country";//区 | 39 | public static String COUNTRY = "country";//区 |
40 | 40 | ||
41 | //账户管理 | 41 | //账户管理 |
42 | public static String ACCOUNT = "account";//账户类型 | 42 | public static String ACCOUNT = "account";//账户类型 |
43 | //科目信息 | 43 | //科目信息 |
44 | public static String SUBJECT = "subject"; | 44 | public static String SUBJECT = "subject"; |
45 | //科目出版社 | 45 | //样机 |
46 | public static String YANGJI = "yangji"; | ||
46 | //图片URL | 47 | //图片URL |
47 | public static String IMGURL = "imgurl"; | 48 | public static String IMGURL = "imgurl"; |
48 | //版本名称 | 49 | //版本名称 |
49 | public static String VERSION = "version"; | 50 | public static String VERSION = "version"; |
50 | 51 | ||
51 | 52 | ||
52 | public void saveLoginParam(Context context,String spname, String spstr) { | 53 | public void saveLoginParam(Context context,String spname, String spstr) { |
53 | SharedPreferences sp = context.getSharedPreferences("loginparam", | 54 | SharedPreferences sp = context.getSharedPreferences("loginparam", |
54 | Activity.MODE_PRIVATE); | 55 | Activity.MODE_PRIVATE); |
55 | 56 | ||
56 | sp.edit().putString(spname, spstr).commit(); | 57 | sp.edit().putString(spname, spstr).commit(); |
57 | } | 58 | } |
58 | 59 | ||
59 | 60 | ||
60 | public String getLoginParam(Context context,String spname) { | 61 | public String getLoginParam(Context context,String spname) { |
61 | SharedPreferences sp = context.getSharedPreferences("loginparam", | 62 | SharedPreferences sp = context.getSharedPreferences("loginparam", |
62 | Activity.MODE_PRIVATE); | 63 | Activity.MODE_PRIVATE); |
63 | String param = sp.getString(spname, null); | 64 | String param = sp.getString(spname, null); |
64 | return param; | 65 | return param; |
65 | } | 66 | } |
66 | public void clearData(Context context) { | 67 | public void clearData(Context context) { |
67 | SharedPreferences sp = context.getSharedPreferences("loginparam", | 68 | SharedPreferences sp = context.getSharedPreferences("loginparam", |
68 | Activity.MODE_PRIVATE); | 69 | Activity.MODE_PRIVATE); |
69 | sp.edit().clear().commit(); | 70 | sp.edit().clear().commit(); |
70 | } | 71 | } |
71 | 72 | ||
72 | public void saveCustomizeParam(Context context,String spname, String spstr) { | 73 | public void saveCustomizeParam(Context context,String spname, String spstr) { |
73 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | 74 | SharedPreferences sp = context.getSharedPreferences("presoninfo", |
74 | Activity.MODE_PRIVATE); | 75 | Activity.MODE_PRIVATE); |
75 | 76 | ||
76 | sp.edit().putString(spname, spstr).commit(); | 77 | sp.edit().putString(spname, spstr).commit(); |
77 | 78 | ||
78 | } | 79 | } |
79 | 80 | ||
80 | public String getCustomizeParam(Context context,String spname) { | 81 | public String getCustomizeParam(Context context,String spname) { |
81 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | 82 | SharedPreferences sp = context.getSharedPreferences("presoninfo", |
82 | Activity.MODE_PRIVATE); | 83 | Activity.MODE_PRIVATE); |
83 | String param = sp.getString(spname, null); | 84 | String param = sp.getString(spname, null); |
84 | return param; | 85 | return param; |
85 | } | 86 | } |
86 | 87 | ||
87 | public void clearCustomizeParam(Context context ){ | 88 | public void clearCustomizeParam(Context context ){ |
88 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | 89 | SharedPreferences sp = context.getSharedPreferences("presoninfo", |
89 | Activity.MODE_PRIVATE); | 90 | Activity.MODE_PRIVATE); |
90 | sp.edit().clear().commit(); | 91 | sp.edit().clear().commit(); |
91 | } | 92 | } |
93 | public void saveCityParam(Context context,String spname, String spstr) { | ||
94 | SharedPreferences sp = context.getSharedPreferences("saveCityParam", | ||
95 | Activity.MODE_PRIVATE); | ||
96 | |||
97 | sp.edit().putString(spname, spstr).commit(); | ||
98 | |||
99 | } | ||
100 | |||
101 | public String getsaveCityParam(Context context,String spname) { | ||
102 | SharedPreferences sp = context.getSharedPreferences("saveCityParam", | ||
103 | Activity.MODE_PRIVATE); | ||
104 | String param = sp.getString(spname, null); | ||
105 | return param; | ||
106 | } | ||
107 | |||
108 | public void clearsaveCityParam(Context context ){ | ||
109 | SharedPreferences sp = context.getSharedPreferences("saveCityParam", | ||
110 | Activity.MODE_PRIVATE); | ||
111 | sp.edit().clear().commit(); | ||
112 | } | ||
92 | } | 113 | } |
93 | 114 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/LoginFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
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.annotation.Nullable; | 7 | import android.support.annotation.Nullable; |
8 | import android.support.v4.app.Fragment; | 8 | import android.support.v4.app.Fragment; |
9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.Button; | 13 | import android.widget.Button; |
14 | import android.widget.EditText; | 14 | import android.widget.EditText; |
15 | import android.widget.TextView; | 15 | import android.widget.TextView; |
16 | import android.widget.Toast; | 16 | import android.widget.Toast; |
17 | 17 | ||
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; | 19 | import com.hjx.personalcenter.activity.ForgotPasswordActivity; |
20 | import com.hjx.personalcenter.activity.MainActivity; | 20 | import com.hjx.personalcenter.activity.MainActivity; |
21 | import com.hjx.personalcenter.activity.RegisterInfoActivity; | 21 | import com.hjx.personalcenter.activity.RegisterInfoActivity; |
22 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; | 22 | import com.hjx.personalcenter.customdialog.ElectronicCardDialog; |
23 | import com.hjx.personalcenter.db.Content; | 23 | import com.hjx.personalcenter.db.Content; |
24 | import com.hjx.personalcenter.db.SaveParam; | 24 | import com.hjx.personalcenter.db.SaveParam; |
25 | import com.hjx.personalcenter.http.HttpCode; | 25 | import com.hjx.personalcenter.http.HttpCode; |
26 | import com.hjx.personalcenter.http.HttpManager; | 26 | import com.hjx.personalcenter.http.HttpManager; |
27 | import com.hjx.personalcenter.util.AlertUtils; | 27 | import com.hjx.personalcenter.util.AlertUtils; |
28 | import com.hjx.personalcenter.util.GetDevicesUtil; | 28 | import com.hjx.personalcenter.util.GetDevicesUtil; |
29 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; | 29 | import com.hjx.personalcenter.util.PhoneNumCheckUtils; |
30 | 30 | ||
31 | import org.json.JSONException; | 31 | import org.json.JSONException; |
32 | import org.json.JSONObject; | 32 | import org.json.JSONObject; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * 登录 | 35 | * 登录 |
36 | * Created by h on 2017/8/8. | 36 | * Created by h on 2017/8/8. |
37 | */ | 37 | */ |
38 | 38 | ||
39 | public class LoginFragment extends Fragment implements View.OnClickListener { | 39 | public class LoginFragment extends Fragment implements View.OnClickListener { |
40 | private View mView; | 40 | private View mView; |
41 | private int type; | 41 | private int type; |
42 | private TextView tv_forget_pwd; | 42 | private TextView tv_forget_pwd; |
43 | private Button btn_login; | 43 | private Button btn_login; |
44 | private EditText phonenumber, login_pwwd; | 44 | private EditText phonenumber, login_pwwd; |
45 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 45 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
46 | Intent intent = new Intent(); | 46 | Intent intent = new Intent(); |
47 | 47 | ||
48 | public static LoginFragment newInstance(int type) { | 48 | public static LoginFragment newInstance(int type) { |
49 | LoginFragment fragment = new LoginFragment(); | 49 | LoginFragment fragment = new LoginFragment(); |
50 | Bundle bundle = new Bundle(); | 50 | Bundle bundle = new Bundle(); |
51 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 51 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
52 | fragment.setArguments(bundle); | 52 | fragment.setArguments(bundle); |
53 | return fragment; | 53 | return fragment; |
54 | 54 | ||
55 | } | 55 | } |
56 | 56 | ||
57 | Handler handler = new Handler() { | 57 | Handler handler = new Handler() { |
58 | @Override | 58 | @Override |
59 | public void handleMessage(Message msg) { | 59 | public void handleMessage(Message msg) { |
60 | super.handleMessage(msg); | 60 | super.handleMessage(msg); |
61 | 61 | ||
62 | switch (msg.what) { | 62 | switch (msg.what) { |
63 | case HttpCode.LOGIN_SUCESS: | 63 | case HttpCode.LOGIN_SUCESS: |
64 | JSONObject jsonObject; | 64 | JSONObject jsonObject; |
65 | String status; | 65 | String status; |
66 | try { | 66 | try { |
67 | jsonObject = new JSONObject((String) msg.obj); | 67 | jsonObject = new JSONObject((String) msg.obj); |
68 | status = jsonObject.getString("status"); | 68 | status = jsonObject.getString("status"); |
69 | if (status.equals("100")) { | 69 | if (status.equals("100")) { |
70 | String access_token = jsonObject.getString("access_token"); | 70 | String access_token = jsonObject.getString("access_token"); |
71 | String userId = jsonObject.getString("userId"); | 71 | String userId = jsonObject.getString("userId"); |
72 | final String name = phonenumber.getText().toString().trim(); | 72 | final String name = phonenumber.getText().toString().trim(); |
73 | final String pwd = login_pwwd.getText().toString().trim(); | 73 | final String pwd = login_pwwd.getText().toString().trim(); |
74 | // | 74 | // |
75 | try { | 75 | try { |
76 | long auserID = Long.parseLong(userId); | 76 | long auserID = Long.parseLong(userId); |
77 | //检测注册信息是否完整 | 77 | //检测注册信息是否完整 |
78 | HttpManager.getInstance().registerinfocheck(getActivity(), auserID, handler); | 78 | HttpManager.getInstance().registerinfocheck(getActivity(), auserID, handler); |
79 | //登录成功,保存登录数据并且获取个人信息 | 79 | //登录成功,保存登录数据并且获取个人信息 |
80 | HttpManager.getInstance().saveLoginInfo(getActivity(), name, pwd, access_token, userId); | 80 | HttpManager.getInstance().saveLoginInfo(getActivity(), name, pwd, access_token, userId); |
81 | 81 | ||
82 | 82 | ||
83 | } catch (NumberFormatException e) { | 83 | } catch (NumberFormatException e) { |
84 | e.printStackTrace(); | 84 | e.printStackTrace(); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | } else if (status.equals("200")) { | 88 | } else if (status.equals("200")) { |
89 | Toast.makeText(getActivity(), "用户名不存在!", Toast.LENGTH_LONG).show(); | 89 | Toast.makeText(getActivity(), "用户名不存在!", Toast.LENGTH_LONG).show(); |
90 | return; | 90 | return; |
91 | } else if (status.equals("204")) { | 91 | } else if (status.equals("204")) { |
92 | Toast.makeText(getActivity(), "密码错误!", Toast.LENGTH_LONG).show(); | 92 | Toast.makeText(getActivity(), "密码错误!", Toast.LENGTH_LONG).show(); |
93 | } else { | 93 | } else { |
94 | Toast.makeText(getActivity(), "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 94 | Toast.makeText(getActivity(), "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
95 | 95 | ||
96 | 96 | ||
97 | } | 97 | } |
98 | } catch (JSONException e) { | 98 | } catch (JSONException e) { |
99 | e.printStackTrace(); | 99 | e.printStackTrace(); |
100 | } | 100 | } |
101 | break; | 101 | break; |
102 | case HttpCode.REGISTER_SUCESS: | 102 | case HttpCode.REGISTER_SUCESS: |
103 | try { | 103 | try { |
104 | jsonObject = new JSONObject((String) msg.obj); | 104 | jsonObject = new JSONObject((String) msg.obj); |
105 | status = jsonObject.optString("status"); | 105 | status = jsonObject.optString("status"); |
106 | JSONObject isregisterinfo = (JSONObject) jsonObject.opt("data"); | 106 | JSONObject isregisterinfo = (JSONObject) jsonObject.opt("data"); |
107 | boolean isRegisterInfoComplete = isregisterinfo.optBoolean("isRegisterInfoComplete"); | 107 | boolean isRegisterInfoComplete = isregisterinfo.optBoolean("isRegisterInfoComplete"); |
108 | if (status.equals("1")) { | 108 | if (status.equals("1")) { |
109 | if (!isRegisterInfoComplete) { | 109 | if (!isRegisterInfoComplete) { |
110 | Content.accountflag = 1; | 110 | Content.accountflag = 1; |
111 | Intent intent = new Intent(); | 111 | Intent intent = new Intent(); |
112 | intent.setClass(getActivity(), RegisterInfoActivity.class); | 112 | intent.setClass(getActivity(), RegisterInfoActivity.class); |
113 | getActivity().startActivity(intent); | 113 | getActivity().startActivity(intent); |
114 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 114 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
115 | } else { | 115 | } else { |
116 | String deviceNumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); | 116 | String deviceNumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); |
117 | //是否填写保卡 | 117 | //是否填写保卡 |
118 | HttpManager.getInstance().cardinfocheck(getActivity(), deviceNumber, handler); | 118 | HttpManager.getInstance().cardinfocheck(getActivity(), deviceNumber, handler); |
119 | 119 | ||
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | } else { | 123 | } else { |
124 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); | 124 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); |
125 | } | 125 | } |
126 | 126 | ||
127 | } catch (JSONException e) { | 127 | } catch (JSONException e) { |
128 | e.printStackTrace(); | 128 | e.printStackTrace(); |
129 | } | 129 | } |
130 | 130 | ||
131 | break; | 131 | break; |
132 | case HttpCode.CHECKCARD: | 132 | case HttpCode.CHECKCARD: |
133 | try { | 133 | try { |
134 | jsonObject = new JSONObject((String) msg.obj); | 134 | jsonObject = new JSONObject((String) msg.obj); |
135 | status = jsonObject.optString("status"); | 135 | status = jsonObject.optString("status"); |
136 | if (status.equals("1")) { | 136 | if (status.equals("1")) { |
137 | SaveParam.getInstance().saveLoginParam(getActivity(), "login", "true"); | 137 | SaveParam.getInstance().saveLoginParam(getActivity(), "login", "true"); |
138 | Intent intent = new Intent(); | 138 | Intent intent = new Intent(); |
139 | intent.setClass(getActivity(), MainActivity.class); | 139 | intent.setClass(getActivity(), MainActivity.class); |
140 | getActivity().startActivity(intent); | 140 | getActivity().startActivity(intent); |
141 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 141 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
142 | 142 | ||
143 | } else if (status.equals("2002")) { | ||
144 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.YANGJI, "1"); | ||
145 | SaveParam.getInstance().saveLoginParam(getActivity(), "login", "true"); | ||
146 | Intent intent = new Intent(); | ||
147 | intent.setClass(getActivity(), MainActivity.class); | ||
148 | getActivity().startActivity(intent); | ||
149 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | ||
143 | } else if (status.equals("2001")) { | 150 | } else if (status.equals("2001")) { |
144 | ElectronicCardDialog.getInstance().show(getChildFragmentManager(), "ElectronicCardDialog"); | 151 | ElectronicCardDialog.getInstance().show(getChildFragmentManager(), "ElectronicCardDialog"); |
145 | } else { | 152 | } else { |
146 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); | 153 | Toast.makeText(getActivity(), "请检查网络", Toast.LENGTH_LONG).show(); |
147 | } | 154 | } |
148 | 155 | ||
149 | } catch (JSONException e) { | 156 | } catch (JSONException e) { |
150 | e.printStackTrace(); | 157 | e.printStackTrace(); |
151 | } | 158 | } |
152 | 159 | ||
153 | break; | 160 | break; |
154 | } | 161 | } |
155 | } | 162 | } |
156 | }; | 163 | }; |
157 | 164 | ||
158 | @Override | 165 | @Override |
159 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 166 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
160 | if (mView == null) { | 167 | if (mView == null) { |
161 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); | 168 | mView = inflater.inflate(R.layout.fragment_loginandregister_login, container, false); |
162 | initView(mView); | 169 | initView(mView); |
163 | initData(); | 170 | initData(); |
164 | setLister(); | 171 | setLister(); |
165 | 172 | ||
166 | 173 | ||
167 | } | 174 | } |
168 | return mView; | 175 | return mView; |
169 | } | 176 | } |
170 | 177 | ||
171 | //初始化 | 178 | //初始化 |
172 | private void initView(View mView) { | 179 | private void initView(View mView) { |
173 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); | 180 | tv_forget_pwd = (TextView) mView.findViewById(R.id.tv_forget_pwd); |
174 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); | 181 | phonenumber = (EditText) mView.findViewById(R.id.et_phonenumber); |
175 | login_pwwd = (EditText) mView.findViewById(R.id.et_password); | 182 | login_pwwd = (EditText) mView.findViewById(R.id.et_password); |
176 | btn_login = (Button) mView.findViewById(R.id.btn_login); | 183 | btn_login = (Button) mView.findViewById(R.id.btn_login); |
177 | 184 | ||
178 | } | 185 | } |
179 | 186 | ||
180 | private void initData() { | 187 | private void initData() { |
181 | } | 188 | } |
182 | 189 | ||
183 | private void setLister() { | 190 | private void setLister() { |
184 | tv_forget_pwd.setOnClickListener(this); | 191 | tv_forget_pwd.setOnClickListener(this); |
185 | btn_login.setOnClickListener(this); | 192 | btn_login.setOnClickListener(this); |
186 | } | 193 | } |
187 | 194 | ||
188 | 195 | ||
189 | @Override | 196 | @Override |
190 | public void onClick(View v) { | 197 | public void onClick(View v) { |
191 | switch (v.getId()) { | 198 | switch (v.getId()) { |
192 | case R.id.tv_forget_pwd: | 199 | case R.id.tv_forget_pwd: |
193 | intent.setClass(getActivity(), ForgotPasswordActivity.class); | 200 | intent.setClass(getActivity(), ForgotPasswordActivity.class); |
194 | startActivity(intent); | 201 | startActivity(intent); |
195 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); | 202 | getActivity().overridePendingTransition(R.anim.rightin, R.anim.rightout); |
196 | break; | 203 | break; |
197 | case R.id.btn_login: | 204 | case R.id.btn_login: |
198 | login(); | 205 | login(); |
199 | break; | 206 | break; |
200 | } | 207 | } |
201 | 208 | ||
202 | } | 209 | } |
203 | 210 | ||
204 | private void login() { | 211 | private void login() { |
205 | final String name = phonenumber.getText().toString().trim(); | 212 | final String name = phonenumber.getText().toString().trim(); |
206 | final String pwd = login_pwwd.getText().toString().trim(); | 213 | final String pwd = login_pwwd.getText().toString().trim(); |
207 | if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { | 214 | if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd)) { |
208 | AlertUtils.showToast(getActivity(), "请输入手机号和密码"); | 215 | AlertUtils.showToast(getActivity(), "请输入手机号和密码"); |
209 | return; | 216 | return; |
210 | } else if (!PhoneNumCheckUtils.isPhone(name)) { | 217 | } else if (!PhoneNumCheckUtils.isPhone(name)) { |
211 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); | 218 | AlertUtils.showToast(getActivity(), "请输入正确的手机号"); |
212 | } else { | 219 | } else { |
213 | //登录接口 | 220 | //登录接口 |
214 | HttpManager.getInstance().login(name, pwd, getActivity(), handler); | 221 | HttpManager.getInstance().login(name, pwd, getActivity(), handler); |
215 | } | 222 | } |
216 | 223 | ||
217 | 224 | ||
218 | } | 225 | } |
219 | } | 226 | } |
220 | 227 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/PresonInfoFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.graphics.Color; | 3 | import android.graphics.Color; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.annotation.Nullable; | 5 | import android.support.annotation.Nullable; |
6 | import android.support.v4.app.Fragment; | 6 | import android.support.v4.app.Fragment; |
7 | import android.support.v4.view.ViewPager; | 7 | import android.support.v4.view.ViewPager; |
8 | import android.util.Log; | 8 | import android.util.Log; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.EditText; | 14 | import android.widget.EditText; |
15 | import android.widget.ImageView; | 15 | import android.widget.ImageView; |
16 | import android.widget.LinearLayout; | 16 | import android.widget.LinearLayout; |
17 | import android.widget.TextView; | 17 | import android.widget.TextView; |
18 | 18 | ||
19 | import com.bigkoo.pickerview.TimePickerView; | 19 | import com.bigkoo.pickerview.TimePickerView; |
20 | import com.hjx.personalcenter.R; | 20 | import com.hjx.personalcenter.R; |
21 | import com.hjx.personalcenter.activity.ChangePresonalInfoActivity; | 21 | import com.hjx.personalcenter.activity.ChangePresonalInfoActivity; |
22 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 22 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
23 | import com.hjx.personalcenter.customdialog.CountryDialog; | 23 | import com.hjx.personalcenter.customdialog.CountryDialog; |
24 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 24 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
25 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 25 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
26 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 26 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
27 | import com.hjx.personalcenter.db.SaveParam; | 27 | import com.hjx.personalcenter.db.SaveParam; |
28 | import com.hjx.personalcenter.http.HttpManager; | 28 | import com.hjx.personalcenter.http.HttpManager; |
29 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 29 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
30 | import com.hjx.personalcenter.model.CityInfo; | 30 | import com.hjx.personalcenter.model.CityInfo; |
31 | import com.hjx.personalcenter.model.CountyInfo; | 31 | import com.hjx.personalcenter.model.CountyInfo; |
32 | import com.hjx.personalcenter.model.GradeInfo; | 32 | import com.hjx.personalcenter.model.GradeInfo; |
33 | import com.hjx.personalcenter.model.ProvinceInfo; | 33 | import com.hjx.personalcenter.model.ProvinceInfo; |
34 | import com.hjx.personalcenter.model.SchoolInfo; | 34 | import com.hjx.personalcenter.model.SchoolInfo; |
35 | import com.hjx.personalcenter.util.AlertUtils; | 35 | import com.hjx.personalcenter.util.AlertUtils; |
36 | import com.hjx.personalcenter.util.BrithdayStar; | 36 | import com.hjx.personalcenter.util.BrithdayStar; |
37 | import com.hjx.personalcenter.util.GetDevicesUtil; | 37 | import com.hjx.personalcenter.util.GetDevicesUtil; |
38 | import com.mylhyl.circledialog.CircleDialog; | 38 | import com.mylhyl.circledialog.CircleDialog; |
39 | import com.mylhyl.circledialog.callback.ConfigDialog; | 39 | import com.mylhyl.circledialog.callback.ConfigDialog; |
40 | import com.mylhyl.circledialog.params.DialogParams; | 40 | import com.mylhyl.circledialog.params.DialogParams; |
41 | 41 | ||
42 | import org.apache.http.util.TextUtils; | 42 | import org.apache.http.util.TextUtils; |
43 | 43 | ||
44 | import java.text.SimpleDateFormat; | 44 | import java.text.SimpleDateFormat; |
45 | import java.util.ArrayList; | 45 | import java.util.ArrayList; |
46 | import java.util.Date; | 46 | import java.util.Date; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Created by h on 2017/8/12. | 49 | * Created by h on 2017/8/12. |
50 | */ | 50 | */ |
51 | 51 | ||
52 | public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack | 52 | public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack |
53 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { | 53 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { |
54 | private View mView; | 54 | private View mView; |
55 | private int type; | 55 | private int type; |
56 | private TimePickerView pvTime; | 56 | private TimePickerView pvTime; |
57 | private LinearLayout tv_version; | 57 | private LinearLayout tv_version; |
58 | 58 | ||
59 | private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; | 59 | private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; |
60 | private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender, sub; | 60 | private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender, sub; |
61 | public static String TABLAYOUT_FRAGMENT = "presonfragment"; | 61 | public static String TABLAYOUT_FRAGMENT = "presonfragment"; |
62 | private ImageView my_adress, my_sex, my_bthday, my_grade, my_school, ccancel; | 62 | private ImageView my_adress, my_sex, my_bthday, my_grade, my_school, ccancel; |
63 | 63 | ||
64 | 64 | ||
65 | public static PresonInfoFragment newInstance(int type) { | 65 | public static PresonInfoFragment newInstance(int type) { |
66 | PresonInfoFragment fragment = new PresonInfoFragment(); | 66 | PresonInfoFragment fragment = new PresonInfoFragment(); |
67 | Bundle bundle = new Bundle(); | 67 | Bundle bundle = new Bundle(); |
68 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 68 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
69 | fragment.setArguments(bundle); | 69 | fragment.setArguments(bundle); |
70 | return fragment; | 70 | return fragment; |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | @Override | 74 | @Override |
75 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 75 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
76 | if (mView == null) { | 76 | if (mView == null) { |
77 | mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); | 77 | mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); |
78 | initView(mView); | 78 | initView(mView); |
79 | initData(); | 79 | initData(); |
80 | setLister(); | 80 | setLister(); |
81 | initTimePicker(); | 81 | initTimePicker(); |
82 | 82 | ||
83 | 83 | ||
84 | } | 84 | } |
85 | return mView; | 85 | return mView; |
86 | } | 86 | } |
87 | 87 | ||
88 | //初始化 | 88 | //初始化 |
89 | private void initView(View mView) { | 89 | private void initView(View mView) { |
90 | tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); | 90 | tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); |
91 | tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); | 91 | tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); |
92 | tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); | 92 | tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); |
93 | tv_sex = (TextView) mView.findViewById(R.id.tv_sex); | 93 | tv_sex = (TextView) mView.findViewById(R.id.tv_sex); |
94 | tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); | 94 | tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); |
95 | tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); | 95 | tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); |
96 | tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); | 96 | tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); |
97 | tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); | 97 | tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); |
98 | my_adress = (ImageView) mView.findViewById(R.id.my_adress); | 98 | my_adress = (ImageView) mView.findViewById(R.id.my_adress); |
99 | my_sex = (ImageView) mView.findViewById(R.id.my_sex); | 99 | my_sex = (ImageView) mView.findViewById(R.id.my_sex); |
100 | my_bthday = (ImageView) mView.findViewById(R.id.my_bthday); | 100 | my_bthday = (ImageView) mView.findViewById(R.id.my_bthday); |
101 | my_grade = (ImageView) mView.findViewById(R.id.my_grade); | 101 | my_grade = (ImageView) mView.findViewById(R.id.my_grade); |
102 | my_school = (ImageView) mView.findViewById(R.id.my_school); | 102 | my_school = (ImageView) mView.findViewById(R.id.my_school); |
103 | sub = (TextView) mView.findViewById(R.id.presonal_sub); | 103 | sub = (TextView) mView.findViewById(R.id.presonal_sub); |
104 | ccancel = (ImageView) mView.findViewById(R.id.cancel); | 104 | ccancel = (ImageView) mView.findViewById(R.id.cancel); |
105 | tv_version = (LinearLayout) mView.findViewById(R.id.tv_version); | 105 | tv_version = (LinearLayout) mView.findViewById(R.id.tv_version); |
106 | 106 | ||
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | private void initData() { | 110 | private void initData() { |
111 | 111 | ||
112 | } | 112 | } |
113 | 113 | ||
114 | private void setLister() { | 114 | private void setLister() { |
115 | tv_sex.setOnClickListener(this); | 115 | tv_sex.setOnClickListener(this); |
116 | tv_useinfo_adress.setOnClickListener(this); | 116 | tv_useinfo_adress.setOnClickListener(this); |
117 | tv_useinfo_birthday.setOnClickListener(this); | 117 | tv_useinfo_birthday.setOnClickListener(this); |
118 | tv_useinfo_school.setOnClickListener(this); | 118 | tv_useinfo_school.setOnClickListener(this); |
119 | tv_useinfo_gender.setOnClickListener(this); | 119 | tv_useinfo_gender.setOnClickListener(this); |
120 | my_adress.setOnClickListener(this); | 120 | my_adress.setOnClickListener(this); |
121 | my_sex.setOnClickListener(this); | 121 | my_sex.setOnClickListener(this); |
122 | my_bthday.setOnClickListener(this); | 122 | my_bthday.setOnClickListener(this); |
123 | my_grade.setOnClickListener(this); | 123 | my_grade.setOnClickListener(this); |
124 | my_school.setOnClickListener(this); | 124 | my_school.setOnClickListener(this); |
125 | sub.setOnClickListener(this); | 125 | sub.setOnClickListener(this); |
126 | tv_version.setOnClickListener(this); | 126 | tv_version.setOnClickListener(this); |
127 | } | 127 | } |
128 | 128 | ||
129 | @Override | 129 | @Override |
130 | public void onClick(View v) { | 130 | public void onClick(View v) { |
131 | String presonal1 = tv_username1.getText().toString().trim(); | 131 | String presonal1 = tv_username1.getText().toString().trim(); |
132 | String presonal2 = tv_useinfo_adress1.getText().toString().trim(); | 132 | String presonal2 = tv_useinfo_adress1.getText().toString().trim(); |
133 | String presonal3 = tv_sex.getText().toString().trim(); | 133 | String presonal3 = tv_sex.getText().toString().trim(); |
134 | String presonal4 = tv_useinfo_adress.getText().toString().trim(); | 134 | String presonal4 = tv_useinfo_adress.getText().toString().trim(); |
135 | String presonal5 = tv_useinfo_birthday.getText().toString().trim(); | 135 | String presonal5 = tv_useinfo_birthday.getText().toString().trim(); |
136 | String presonal6 = tv_useinfo_school.getText().toString().trim(); | 136 | String presonal6 = tv_useinfo_school.getText().toString().trim(); |
137 | String presonal7 = tv_useinfo_gender.getText().toString().trim(); | 137 | String presonal7 = tv_useinfo_gender.getText().toString().trim(); |
138 | String presonal8 = tv_useinfo_qq.getText().toString().trim(); | 138 | String presonal8 = tv_useinfo_qq.getText().toString().trim(); |
139 | switch (v.getId()) { | 139 | switch (v.getId()) { |
140 | case R.id.tv_sex: | 140 | case R.id.tv_sex: |
141 | case R.id.my_sex: | 141 | case R.id.my_sex: |
142 | final String[] items = {"男", "女"}; | 142 | final String[] items = {"男", "女"}; |
143 | new CircleDialog.Builder(getActivity()) | 143 | new CircleDialog.Builder(getActivity()) |
144 | .configDialog(new ConfigDialog() { | 144 | .configDialog(new ConfigDialog() { |
145 | @Override | 145 | @Override |
146 | public void onConfig(DialogParams params) { | 146 | public void onConfig(DialogParams params) { |
147 | //增加弹出动画 | 147 | //增加弹出动画 |
148 | params.gravity = Gravity.CENTER; | 148 | params.gravity = Gravity.CENTER; |
149 | } | 149 | } |
150 | }) | 150 | }) |
151 | .setTitle("请选择性别") | 151 | .setTitle("请选择性别") |
152 | .setWidth(0.5f) | 152 | .setWidth(0.5f) |
153 | .setItems(items, new AdapterView.OnItemClickListener() { | 153 | .setItems(items, new AdapterView.OnItemClickListener() { |
154 | @Override | 154 | @Override |
155 | public void onItemClick(AdapterView<?> parent, View view, int | 155 | public void onItemClick(AdapterView<?> parent, View view, int |
156 | position, long id) { | 156 | position, long id) { |
157 | switch (position) { | 157 | switch (position) { |
158 | case 0: | 158 | case 0: |
159 | tv_sex.setText("男"); | 159 | tv_sex.setText("男"); |
160 | break; | 160 | break; |
161 | case 1: | 161 | case 1: |
162 | tv_sex.setText("女"); | 162 | tv_sex.setText("女"); |
163 | break; | 163 | break; |
164 | } | 164 | } |
165 | 165 | ||
166 | } | 166 | } |
167 | }) | 167 | }) |
168 | .show(); | 168 | .show(); |
169 | break; | 169 | break; |
170 | case R.id.tv_useinfo_adress: | 170 | case R.id.tv_useinfo_adress: |
171 | case R.id.my_adress: | 171 | case R.id.my_adress: |
172 | tv_useinfo_school.setText(""); | 172 | tv_useinfo_school.setText(""); |
173 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); | 173 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); |
174 | break; | 174 | break; |
175 | case R.id.tv_useinfo_birthday: | 175 | case R.id.tv_useinfo_birthday: |
176 | case R.id.my_bthday: | 176 | case R.id.my_bthday: |
177 | pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view | 177 | pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view |
178 | break; | 178 | break; |
179 | case R.id.tv_useinfo_school: | 179 | case R.id.tv_useinfo_school: |
180 | case R.id.my_school: | 180 | case R.id.my_school: |
181 | if (TextUtils.isEmpty(presonal4) || | 181 | if (TextUtils.isEmpty(presonal4) || |
182 | TextUtils.isEmpty(presonal7)) { | 182 | TextUtils.isEmpty(presonal7)) { |
183 | AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); | 183 | AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); |
184 | return; | 184 | return; |
185 | } else { | 185 | } else { |
186 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); | 186 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | break; | 190 | break; |
191 | case R.id.tv_useinfo_gender: | 191 | case R.id.tv_useinfo_gender: |
192 | case R.id.my_grade: | 192 | case R.id.my_grade: |
193 | tv_useinfo_school.setText(""); | 193 | tv_useinfo_school.setText(""); |
194 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); | 194 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); |
195 | break; | 195 | break; |
196 | case R.id.cancel: | 196 | case R.id.cancel: |
197 | getActivity().finish(); | 197 | getActivity().finish(); |
198 | break; | 198 | break; |
199 | case R.id.tv_version: | 199 | case R.id.tv_version: |
200 | final ChangePresonalInfoActivity mainActivity = (ChangePresonalInfoActivity) getActivity(); | 200 | final ChangePresonalInfoActivity mainActivity = (ChangePresonalInfoActivity) getActivity(); |
201 | mainActivity.setFragment2Fragment(new ChangePresonalInfoActivity.Fragment2Fragment() { | 201 | mainActivity.setFragment2Fragment(new ChangePresonalInfoActivity.Fragment2Fragment() { |
202 | @Override | 202 | @Override |
203 | public void gotoFragment(ViewPager viewPager) { | 203 | public void gotoFragment(ViewPager viewPager) { |
204 | //fragment传递数据 | 204 | //fragment传递数据 |
205 | viewPager.setCurrentItem(1); | 205 | viewPager.setCurrentItem(1); |
206 | } | 206 | } |
207 | }); | 207 | }); |
208 | mainActivity.forSkip(); | 208 | mainActivity.forSkip(); |
209 | break; | 209 | break; |
210 | case R.id.presonal_sub: | 210 | case R.id.presonal_sub: |
211 | Log.e("test", "你提交个人信息"); | 211 | Log.e("test", "你提交个人信息"); |
212 | if (TextUtils.isEmpty(presonal1) || | 212 | if (TextUtils.isEmpty(presonal1) || |
213 | TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || | 213 | TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || |
214 | TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || | 214 | TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || |
215 | TextUtils.isEmpty(presonal8)) { | 215 | TextUtils.isEmpty(presonal8)) { |
216 | AlertUtils.showToast(getActivity(), "请将信息填写完整!"); | 216 | AlertUtils.showToast(getActivity(), "请将信息填写完整!"); |
217 | return; | 217 | return; |
218 | } else { | 218 | } else { |
219 | 219 | ||
220 | int a = 0, b = 0; | 220 | int a = 0, b = 0; |
221 | int d = 1; | 221 | int d = 1; |
222 | Object schoolids; | 222 | Object schoolids; |
223 | Long f = null; | 223 | Long f = null; |
224 | //保存星座 | 224 | //保存星座 |
225 | BrithdayStar brithdayStar = new BrithdayStar(); | 225 | BrithdayStar brithdayStar = new BrithdayStar(); |
226 | String s = brithdayStar.getConstellations(tv_useinfo_birthday.getText().toString()); | 226 | String s = brithdayStar.getConstellations(tv_useinfo_birthday.getText().toString()); |
227 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CONSTELLATION, s); | 227 | SaveParam.getInstance().saveCustomizeParam(getActivity(), SaveParam.CONSTELLATION, s); |
228 | 228 | ||
229 | String regionId = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.COUNTRY); | 229 | String regionId = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.COUNTRY); |
230 | String regionId1 = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 230 | String regionId1 = SaveParam.getInstance().getsaveCityParam(getActivity(), SaveParam.CITYS); |
231 | if (regionId == null) { | 231 | if (regionId == null) { |
232 | regionId = regionId1; | 232 | regionId = regionId1; |
233 | } | 233 | } |
234 | String grade = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.GRADENS); | 234 | String grade = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.GRADENS); |
235 | String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOOlID); | 235 | String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOOlID); |
236 | String type = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); | 236 | String type = SaveParam.getInstance().getCustomizeParam(getActivity(), SaveParam.ACCOUNT); |
237 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 237 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
238 | String devicenumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); | 238 | String devicenumber = GetDevicesUtil.getDevicesInfo(getActivity()).getDeviceNumber(); |
239 | String changeinfo = null; | 239 | String changeinfo = null; |
240 | if ("男".equals(presonal3)) { | 240 | if ("男".equals(presonal3)) { |
241 | changeinfo = "male"; | 241 | changeinfo = "male"; |
242 | } else { | 242 | } else { |
243 | changeinfo = "female"; | 243 | changeinfo = "female"; |
244 | } | 244 | } |
245 | try { | 245 | try { |
246 | a = Integer.parseInt(regionId); | 246 | a = Integer.parseInt(regionId); |
247 | b = Integer.parseInt(grade); | 247 | b = Integer.parseInt(grade); |
248 | if (TextUtils.isEmpty(presonal6)) { | 248 | if (TextUtils.isEmpty(presonal6)) { |
249 | schoolids = null; | 249 | schoolids = null; |
250 | } else { | 250 | } else { |
251 | schoolids = Long.parseLong(schoolid); | 251 | schoolids = Long.parseLong(schoolid); |
252 | } | 252 | } |
253 | d = Integer.parseInt(type); | 253 | d = Integer.parseInt(type); |
254 | f = Long.parseLong(userID); | 254 | f = Long.parseLong(userID); |
255 | //提交个人信息 | 255 | //提交个人信息 |
256 | HttpManager.getInstance().changepresonalinfo(getActivity(), | 256 | HttpManager.getInstance().changepresonalinfo(getActivity(), |
257 | f, d, presonal1, presonal5, b, a, schoolids, presonal8, changeinfo, presonal4 + presonal2, devicenumber); | 257 | f, d, presonal1, presonal5, b, a, schoolids, presonal8, changeinfo, presonal4 + presonal2, devicenumber); |
258 | 258 | ||
259 | } catch (Exception e) { | 259 | } catch (Exception e) { |
260 | e.printStackTrace(); | 260 | e.printStackTrace(); |
261 | } | 261 | } |
262 | 262 | ||
263 | break; | 263 | break; |
264 | 264 | ||
265 | } | 265 | } |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | //自定义时间选择器 | 269 | //自定义时间选择器 |
270 | private void initTimePicker() { | 270 | private void initTimePicker() { |
271 | //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) | 271 | //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) |
272 | //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | 272 | //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 |
273 | // Calendar selectedDate = Calendar.getInstance(); | 273 | // Calendar selectedDate = Calendar.getInstance(); |
274 | // Calendar startDate = Calendar.getInstance(); | 274 | // Calendar startDate = Calendar.getInstance(); |
275 | // startDate.set(1900, 1, 1); | 275 | // startDate.set(1900, 1, 1); |
276 | // Calendar endDate = Calendar.getInstance(); | 276 | // Calendar endDate = Calendar.getInstance(); |
277 | // endDate.set(2100, 1, 1); | 277 | // endDate.set(2100, 1, 1); |
278 | //时间选择器 | 278 | //时间选择器 |
279 | pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { | 279 | pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { |
280 | @Override | 280 | @Override |
281 | public void onTimeSelect(Date date, View v) {//选中事件回调 | 281 | public void onTimeSelect(Date date, View v) {//选中事件回调 |
282 | // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null | 282 | // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null |
283 | /*btn_Time.setText(getTime(date));*/ | 283 | /*btn_Time.setText(getTime(date));*/ |
284 | TextView btn = (TextView) v; | 284 | TextView btn = (TextView) v; |
285 | btn.setText(getTime(date)); | 285 | btn.setText(getTime(date)); |
286 | } | 286 | } |
287 | }) | 287 | }) |
288 | //年月日时分秒 的显示与否,不设置则默认全部显示 | 288 | //年月日时分秒 的显示与否,不设置则默认全部显示 |
289 | .setType(new boolean[]{true, true, true, false, false, false}) | 289 | .setType(new boolean[]{true, true, true, false, false, false}) |
290 | .setLabel("", "", "", "", "", "") | 290 | .setLabel("", "", "", "", "", "") |
291 | .isCenterLabel(false) | 291 | .isCenterLabel(false) |
292 | .setDividerColor(Color.DKGRAY) | 292 | .setDividerColor(Color.DKGRAY) |
293 | .setContentSize(21) | 293 | .setContentSize(21) |
294 | // .setDate(selectedDate) | 294 | // .setDate(selectedDate) |
295 | // .setRangDate(startDate, endDate) | 295 | // .setRangDate(startDate, endDate) |
296 | .setBackgroundId(0x80000000) //设置外部遮罩颜色 | 296 | .setBackgroundId(0x80000000) //设置外部遮罩颜色 |
297 | .setDecorView(null) | 297 | .setDecorView(null) |
298 | .setTitleText("出生日期") | 298 | .setTitleText("出生日期") |
299 | .setTitleSize(22) | 299 | .setTitleSize(22) |
300 | .setCancelColor(Color.GRAY) | 300 | .setCancelColor(Color.GRAY) |
301 | .setSubCalSize(22) | 301 | .setSubCalSize(22) |
302 | .setDividerColor(Color.GRAY) | 302 | .setDividerColor(Color.GRAY) |
303 | .setSubmitColor(Color.GRAY) | 303 | .setSubmitColor(Color.GRAY) |
304 | .build(); | 304 | .build(); |
305 | } | 305 | } |
306 | 306 | ||
307 | private String getTime(Date date) {//可根据需要自行截取数据显示 | 307 | private String getTime(Date date) {//可根据需要自行截取数据显示 |
308 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | 308 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
309 | return format.format(date); | 309 | return format.format(date); |
310 | } | 310 | } |
311 | 311 | ||
312 | @Override | 312 | @Override |
313 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | 313 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { |
314 | String regionName = data.get(position).getRegionName(); | 314 | String regionName = data.get(position).getRegionName(); |
315 | String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); | 315 | String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); |
316 | SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); | 316 | SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); |
317 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); | 317 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); |
318 | tv_useinfo_adress.setText(""); | 318 | tv_useinfo_adress.setText(""); |
319 | tv_useinfo_adress.setText(provice + regionName); | 319 | tv_useinfo_adress.setText(provice + regionName); |
320 | 320 | ||
321 | 321 | ||
322 | } | 322 | } |
323 | 323 | ||
324 | @Override | 324 | @Override |
325 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { | 325 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { |
326 | String regionName = data.get(position).getRegionName(); | 326 | String regionName = data.get(position).getRegionName(); |
327 | String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); | 327 | String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); |
328 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); | 328 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); |
329 | tv_useinfo_adress.setText(""); | 329 | tv_useinfo_adress.setText(""); |
330 | tv_useinfo_adress.setText(provices + citys + regionName); | 330 | tv_useinfo_adress.setText(provices + citys + regionName); |
331 | 331 | ||
332 | } | 332 | } |
333 | 333 | ||
334 | @Override | 334 | @Override |
335 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | 335 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { |
336 | String regionName = data.get(position).getName(); | 336 | String regionName = data.get(position).getName(); |
337 | tv_useinfo_gender.setText(regionName); | 337 | tv_useinfo_gender.setText(regionName); |
338 | } | 338 | } |
339 | 339 | ||
340 | @Override | 340 | @Override |
341 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { | 341 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
342 | String regionName = data.get(position).getRegionName(); | 342 | String regionName = data.get(position).getRegionName(); |
343 | SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); | 343 | SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); |
344 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); | 344 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); |
345 | tv_useinfo_adress.setText(""); | 345 | tv_useinfo_adress.setText(""); |
346 | tv_useinfo_adress.setText(regionName); | 346 | tv_useinfo_adress.setText(regionName); |
347 | } | 347 | } |
348 | 348 | ||
349 | @Override | 349 | @Override |
350 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { | 350 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { |
351 | String regionName = data.get(position).getSchoolName(); | 351 | String regionName = data.get(position).getSchoolName(); |
352 | tv_useinfo_school.setText(regionName); | 352 | tv_useinfo_school.setText(regionName); |
353 | 353 | ||
354 | 354 | ||
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by wei on 2017/6/21. | 4 | * Created by wei on 2017/6/21. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpCode { | 7 | public class HttpCode { |
8 | //查询保卡信息 | 8 | //查询保卡信息 |
9 | public static final int SUCHCARDINFO = 0; | 9 | public static final int SUCHCARDINFO = 0; |
10 | //是否填写保卡信息 | 10 | //是否填写保卡信息 |
11 | public static final int CHECKCARD = 1; | 11 | public static final int CHECKCARD = 1; |
12 | //注册 | 12 | //注册 |
13 | public static final int REGISTERED_SUCESS = 2; | 13 | public static final int REGISTERED_SUCESS = 2; |
14 | public static final int REGISTERED_FAIL = 3; | 14 | public static final int REGISTERED_FAIL = 3; |
15 | //注册验证码 | 15 | //注册验证码 |
16 | public static final int AUTHCODE_SUCESS = 4; | 16 | public static final int AUTHCODE_SUCESS = 4; |
17 | public static final int AUTHCODE_FAIL = 5; | 17 | public static final int AUTHCODE_FAIL = 5; |
18 | //忘记密码验证码 | 18 | //忘记密码验证码 |
19 | public static final int AUTHCODE_SUCESS1 = 6; | 19 | public static final int AUTHCODE_SUCESS1 = 6; |
20 | public static final int AUTHCODE_FAIL1 = 7; | 20 | public static final int AUTHCODE_FAIL1 = 7; |
21 | //是否已经注册 | 21 | //是否已经注册 |
22 | public static final int IS_REFISTER = 8; | 22 | public static final int IS_REFISTER = 8; |
23 | //忘记密码 | 23 | //忘记密码 |
24 | public static final int PASSWORD_SUCESS = 9; | 24 | public static final int PASSWORD_SUCESS = 9; |
25 | public static final int PASSWORD_FAIL = 10; | 25 | public static final int PASSWORD_FAIL = 10; |
26 | //s省 | 26 | //s省 |
27 | public static final int PROVICES = 11; | 27 | public static final int PROVICES = 11; |
28 | //市 | 28 | //市 |
29 | public static final int CITYS = 12; | 29 | public static final int CITYS = 12; |
30 | //区 | 30 | //区 |
31 | public static final int COUNTRY = 13; | 31 | public static final int COUNTRY = 13; |
32 | //学校 | 32 | //学校 |
33 | public static final int SCHOOL = 14; | 33 | public static final int SCHOOL = 14; |
34 | //年级 | 34 | //年级 |
35 | public static final int GRADER = 15; | 35 | public static final int GRADER = 15; |
36 | //获取个人信息 | 36 | //获取个人信息 |
37 | public static final int GETINFO = 16; | 37 | public static final int GETINFO = 16; |
38 | //获取个性签名 | 38 | //获取个性签名 |
39 | public static final int SIGN = 17; | 39 | public static final int SIGN = 17; |
40 | //登录 | 40 | //登录 |
41 | public static final int LOGIN_SUCESS = 18; | 41 | public static final int LOGIN_SUCESS = 18; |
42 | //获取子账户信息 | 42 | //获取子账户信息 |
43 | public static final int CHILDS_SUCESS = 19; | 43 | public static final int CHILDS_SUCESS = 19; |
44 | //版本升级 | 44 | //版本升级 |
45 | public static final int APPUPDATE_SUCESS = 20; | 45 | public static final int APPUPDATE_SUCESS = 20; |
46 | //获取出版社 | 46 | //获取出版社 |
47 | public static final int VERSION_SUCESS = 22; | 47 | public static final int VERSION_SUCESS = 22; |
48 | //注册信息是否完整 | 48 | //注册信息是否完整 |
49 | public static final int REGISTER_SUCESS = 23; | 49 | public static final int REGISTER_SUCESS = 23; |
50 | //获取默认版本信息 | 50 | //获取默认版本信息 |
51 | public static final int PUBLISH_SUCESS = 24; | 51 | public static final int PUBLISH_SUCESS = 24; |
52 | //注册信息提交 | 52 | //注册信息提交 |
53 | public static final int REGISTERINFO_SUCESS = 25; | 53 | public static final int REGISTERINFO_SUCESS = 25; |
54 | //获取视频信息 | 54 | //获取视频信息 |
55 | public static final int GETVIDIO_SUCESS = 26; | 55 | public static final int GETVIDIO_SUCESS = 26; |
56 | //查询保卡信息1 | ||
57 | public static final int SUCHCARDINFOONE = 27; | ||
56 | 58 | ||
57 | 59 | ||
58 | 60 | ||
59 | 61 | ||
60 | 62 | ||
61 | } | 63 | } |
62 | 64 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
5 | import android.content.Context; | 5 | import android.content.Context; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | import android.os.Message; | 8 | import android.os.Message; |
9 | import android.util.Log; | 9 | import android.util.Log; |
10 | import android.view.KeyEvent; | 10 | import android.view.KeyEvent; |
11 | import android.widget.Toast; | 11 | import android.widget.Toast; |
12 | 12 | ||
13 | import com.google.gson.Gson; | 13 | import com.google.gson.Gson; |
14 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
15 | import com.hjx.personalcenter.activity.BangDingCode; | 15 | import com.hjx.personalcenter.activity.BangDingCode; |
16 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 16 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
17 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 17 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
18 | import com.hjx.personalcenter.db.Content; | 18 | import com.hjx.personalcenter.db.Content; |
19 | import com.hjx.personalcenter.db.SaveParam; | 19 | import com.hjx.personalcenter.db.SaveParam; |
20 | import com.hjx.personalcenter.gson.GsonTool; | 20 | import com.hjx.personalcenter.gson.GsonTool; |
21 | import com.hjx.personalcenter.model.AppVersion; | 21 | import com.hjx.personalcenter.model.AppVersion; |
22 | import com.hjx.personalcenter.model.CardInfo; | 22 | import com.hjx.personalcenter.model.CardInfo; |
23 | import com.hjx.personalcenter.model.ChildsInfo; | 23 | import com.hjx.personalcenter.model.ChildsInfo; |
24 | import com.hjx.personalcenter.model.CityInfo; | 24 | import com.hjx.personalcenter.model.CityInfo; |
25 | import com.hjx.personalcenter.model.CountyInfo; | 25 | import com.hjx.personalcenter.model.CountyInfo; |
26 | import com.hjx.personalcenter.model.DefautPublishInfo; | 26 | import com.hjx.personalcenter.model.DefautPublishInfo; |
27 | import com.hjx.personalcenter.model.GradeInfo; | 27 | import com.hjx.personalcenter.model.GradeInfo; |
28 | import com.hjx.personalcenter.model.PesonalInfo; | 28 | import com.hjx.personalcenter.model.PesonalInfo; |
29 | import com.hjx.personalcenter.model.ProvinceInfo; | 29 | import com.hjx.personalcenter.model.ProvinceInfo; |
30 | import com.hjx.personalcenter.model.SchoolInfo; | 30 | import com.hjx.personalcenter.model.SchoolInfo; |
31 | import com.hjx.personalcenter.model.SignInfo; | 31 | import com.hjx.personalcenter.model.SignInfo; |
32 | import com.hjx.personalcenter.model.VersionInfo; | 32 | import com.hjx.personalcenter.model.VersionInfo; |
33 | import com.hjx.personalcenter.model.VideoInfo; | 33 | import com.hjx.personalcenter.model.VideoInfo; |
34 | import com.hjx.personalcenter.util.AlertUtils; | 34 | import com.hjx.personalcenter.util.AlertUtils; |
35 | import com.hjx.personalcenter.util.DialogPermission; | 35 | import com.hjx.personalcenter.util.DialogPermission; |
36 | import com.loopj.android.http.AsyncHttpResponseHandler; | 36 | import com.loopj.android.http.AsyncHttpResponseHandler; |
37 | import com.loopj.android.http.JsonHttpResponseHandler; | 37 | import com.loopj.android.http.JsonHttpResponseHandler; |
38 | import com.loopj.android.http.RequestParams; | 38 | import com.loopj.android.http.RequestParams; |
39 | 39 | ||
40 | import org.apache.http.Header; | 40 | import org.apache.http.Header; |
41 | import org.apache.http.entity.ByteArrayEntity; | 41 | import org.apache.http.entity.ByteArrayEntity; |
42 | import org.apache.http.message.BasicHeader; | 42 | import org.apache.http.message.BasicHeader; |
43 | import org.apache.http.protocol.HTTP; | 43 | import org.apache.http.protocol.HTTP; |
44 | import org.json.JSONException; | 44 | import org.json.JSONException; |
45 | import org.json.JSONObject; | 45 | import org.json.JSONObject; |
46 | 46 | ||
47 | import java.io.File; | 47 | import java.io.File; |
48 | import java.io.FileNotFoundException; | 48 | import java.io.FileNotFoundException; |
49 | import java.io.UnsupportedEncodingException; | 49 | import java.io.UnsupportedEncodingException; |
50 | import java.util.ArrayList; | 50 | import java.util.ArrayList; |
51 | import java.util.List; | 51 | import java.util.List; |
52 | 52 | ||
53 | public class HttpManager { | 53 | public class HttpManager { |
54 | private static HttpManager instance; | 54 | private static HttpManager instance; |
55 | private ProgressDialog mProgress = null; | 55 | private ProgressDialog mProgress = null; |
56 | 56 | ||
57 | public static HttpManager getInstance() { | 57 | public static HttpManager getInstance() { |
58 | if (instance == null) { | 58 | if (instance == null) { |
59 | instance = new HttpManager(); | 59 | instance = new HttpManager(); |
60 | } | 60 | } |
61 | return instance; | 61 | return instance; |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | //登录接口 | 65 | //登录接口 |
66 | 66 | ||
67 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 67 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
68 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 68 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
69 | true, true, null); | 69 | true, true, null); |
70 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 70 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
71 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 71 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
72 | @Override | 72 | @Override |
73 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 73 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
74 | closeProgress(); | 74 | closeProgress(); |
75 | Message msg = Message.obtain(); | 75 | Message msg = Message.obtain(); |
76 | msg.what = HttpCode.LOGIN_SUCESS; | 76 | msg.what = HttpCode.LOGIN_SUCESS; |
77 | msg.obj = new String(arg2); | 77 | msg.obj = new String(arg2); |
78 | handler.sendMessage(msg); | 78 | handler.sendMessage(msg); |
79 | 79 | ||
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | @Override | 83 | @Override |
84 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 84 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
85 | closeProgress(); | 85 | closeProgress(); |
86 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 86 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
87 | } | 87 | } |
88 | }); | 88 | }); |
89 | } | 89 | } |
90 | 90 | ||
91 | //注册接口 | 91 | //注册接口 |
92 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 92 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
93 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 93 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
94 | false, true, null); | 94 | false, true, null); |
95 | JSONObject jsonObject = new JSONObject(); | 95 | JSONObject jsonObject = new JSONObject(); |
96 | ByteArrayEntity entity = null; | 96 | ByteArrayEntity entity = null; |
97 | try { | 97 | try { |
98 | jsonObject.put(HttpKey.USERNAME, username); | 98 | jsonObject.put(HttpKey.USERNAME, username); |
99 | jsonObject.put(HttpKey.PASSWORD, password); | 99 | jsonObject.put(HttpKey.PASSWORD, password); |
100 | jsonObject.put(HttpKey.SMSCODE, smscode); | 100 | jsonObject.put(HttpKey.SMSCODE, smscode); |
101 | jsonObject.put(HttpKey.SOURCE, source); | 101 | jsonObject.put(HttpKey.SOURCE, source); |
102 | Log.e("test", "jsonObject" + jsonObject); | 102 | Log.e("test", "jsonObject" + jsonObject); |
103 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 103 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
104 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 104 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
105 | } catch (JSONException e) { | 105 | } catch (JSONException e) { |
106 | e.printStackTrace(); | 106 | e.printStackTrace(); |
107 | } catch (UnsupportedEncodingException e) { | 107 | } catch (UnsupportedEncodingException e) { |
108 | e.printStackTrace(); | 108 | e.printStackTrace(); |
109 | } | 109 | } |
110 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 110 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
111 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 111 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
112 | @Override | 112 | @Override |
113 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 113 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
114 | super.onSuccess(statusCode, headers, response); | 114 | super.onSuccess(statusCode, headers, response); |
115 | closeProgress(); | 115 | closeProgress(); |
116 | Log.e("test", "onSuccess" + response); | 116 | Log.e("test", "onSuccess" + response); |
117 | Message msg = Message.obtain(); | 117 | Message msg = Message.obtain(); |
118 | msg.what = HttpCode.REGISTERED_SUCESS; | 118 | msg.what = HttpCode.REGISTERED_SUCESS; |
119 | msg.obj = response; | 119 | msg.obj = response; |
120 | handler.sendMessage(msg); | 120 | handler.sendMessage(msg); |
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | @Override | 124 | @Override |
125 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 125 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
126 | super.onFailure(statusCode, headers, throwable, errorResponse); | 126 | super.onFailure(statusCode, headers, throwable, errorResponse); |
127 | closeProgress(); | 127 | closeProgress(); |
128 | Log.e("test", "onFailure" + errorResponse); | 128 | Log.e("test", "onFailure" + errorResponse); |
129 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 129 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
130 | } | 130 | } |
131 | 131 | ||
132 | }); | 132 | }); |
133 | } | 133 | } |
134 | 134 | ||
135 | //注册验证码 | 135 | //注册验证码 |
136 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 136 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
137 | RequestParams params = new RequestParams(); | 137 | RequestParams params = new RequestParams(); |
138 | params.put(HttpKey.TYPE, type); | 138 | params.put(HttpKey.TYPE, type); |
139 | params.put(HttpKey.MOBIL, mobile); | 139 | params.put(HttpKey.MOBIL, mobile); |
140 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 140 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
141 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 141 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
142 | 142 | ||
143 | @Override | 143 | @Override |
144 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 144 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
145 | Log.e("test", "onSuccess-----" + response); | 145 | Log.e("test", "onSuccess-----" + response); |
146 | Message msg = Message.obtain(); | 146 | Message msg = Message.obtain(); |
147 | msg.what = HttpCode.AUTHCODE_SUCESS; | 147 | msg.what = HttpCode.AUTHCODE_SUCESS; |
148 | msg.obj = response; | 148 | msg.obj = response; |
149 | handler.sendMessage(msg); | 149 | handler.sendMessage(msg); |
150 | } | 150 | } |
151 | 151 | ||
152 | @Override | 152 | @Override |
153 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 153 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
154 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 154 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
155 | } | 155 | } |
156 | }); | 156 | }); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | //手机号是否注册 | 160 | //手机号是否注册 |
161 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 161 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
162 | RequestParams params = new RequestParams(); | 162 | RequestParams params = new RequestParams(); |
163 | params.put(HttpKey.USERNAME, mobile); | 163 | params.put(HttpKey.USERNAME, mobile); |
164 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 164 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
165 | @Override | 165 | @Override |
166 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 166 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
167 | Log.e("test", "isregistered" + response.toString()); | 167 | Log.e("test", "isregistered" + response.toString()); |
168 | Message msg = Message.obtain(); | 168 | Message msg = Message.obtain(); |
169 | msg.what = HttpCode.IS_REFISTER; | 169 | msg.what = HttpCode.IS_REFISTER; |
170 | msg.obj = response; | 170 | msg.obj = response; |
171 | handler.sendMessage(msg); | 171 | handler.sendMessage(msg); |
172 | 172 | ||
173 | } | 173 | } |
174 | 174 | ||
175 | @Override | 175 | @Override |
176 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 176 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
177 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 177 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
178 | 178 | ||
179 | } | 179 | } |
180 | }); | 180 | }); |
181 | } | 181 | } |
182 | 182 | ||
183 | //修改密码 | 183 | //修改密码 |
184 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 184 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
185 | RequestParams params = new RequestParams(); | 185 | RequestParams params = new RequestParams(); |
186 | params.put(HttpKey.USERNAME, username); | 186 | params.put(HttpKey.USERNAME, username); |
187 | params.put(HttpKey.OLDPASS, old_pwd1); | 187 | params.put(HttpKey.OLDPASS, old_pwd1); |
188 | params.put(HttpKey.NEWPASS, newpassword3); | 188 | params.put(HttpKey.NEWPASS, newpassword3); |
189 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 189 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
190 | HttpClient.getInstance().setTimeout(10 * 1000); | 190 | HttpClient.getInstance().setTimeout(10 * 1000); |
191 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 191 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
192 | @Override | 192 | @Override |
193 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 193 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
194 | try { | 194 | try { |
195 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 195 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
196 | String status = jsonObject.optString("status"); | 196 | String status = jsonObject.optString("status"); |
197 | if (status.equals("100")) { | 197 | if (status.equals("100")) { |
198 | Log.e("test", "onSuccess" + new String(bytes)); | 198 | Log.e("test", "onSuccess" + new String(bytes)); |
199 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 199 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
200 | SaveParam.getInstance().clearData((Activity) context); | 200 | SaveParam.getInstance().clearData((Activity) context); |
201 | Intent intent = new Intent(); | 201 | Intent intent = new Intent(); |
202 | intent.setClass(context, LoginAndRegisterActivity.class); | 202 | intent.setClass(context, LoginAndRegisterActivity.class); |
203 | ((Activity) context).startActivity(intent); | 203 | ((Activity) context).startActivity(intent); |
204 | ((Activity) context).finish(); | 204 | ((Activity) context).finish(); |
205 | } else { | 205 | } else { |
206 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 206 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
207 | } | 207 | } |
208 | } catch (JSONException e) { | 208 | } catch (JSONException e) { |
209 | e.printStackTrace(); | 209 | e.printStackTrace(); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | @Override | 213 | @Override |
214 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 214 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
215 | Log.e("test", "onFailure" + new String(bytes)); | 215 | Log.e("test", "onFailure" + new String(bytes)); |
216 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 216 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
217 | } | 217 | } |
218 | }); | 218 | }); |
219 | 219 | ||
220 | } | 220 | } |
221 | 221 | ||
222 | //忘记密码 | 222 | //忘记密码 |
223 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 223 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
224 | RequestParams params = new RequestParams(); | 224 | RequestParams params = new RequestParams(); |
225 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 225 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
226 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 226 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
227 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 227 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
228 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 228 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
229 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 229 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
230 | @Override | 230 | @Override |
231 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 231 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
232 | try { | 232 | try { |
233 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 233 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
234 | String status = jsonObject.optString("status"); | 234 | String status = jsonObject.optString("status"); |
235 | if (status.equals("100")) { | 235 | if (status.equals("100")) { |
236 | Log.e("test", "onSuccess" + new String(bytes)); | 236 | Log.e("test", "onSuccess" + new String(bytes)); |
237 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 237 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
238 | ((Activity) context).finish(); | 238 | ((Activity) context).finish(); |
239 | } else { | 239 | } else { |
240 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); | 240 | Toast.makeText(context, "密码修改失败!", Toast.LENGTH_LONG).show(); |
241 | } | 241 | } |
242 | } catch (JSONException e) { | 242 | } catch (JSONException e) { |
243 | e.printStackTrace(); | 243 | e.printStackTrace(); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | @Override | 247 | @Override |
248 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 248 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
249 | Log.e("test", "onFailure" + new String(bytes)); | 249 | Log.e("test", "onFailure" + new String(bytes)); |
250 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 250 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
251 | } | 251 | } |
252 | }); | 252 | }); |
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||
256 | //保存用户登录信息 | 256 | //保存用户登录信息 |
257 | public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) { | 257 | public void saveLoginInfo(Context context, String username, String password, String access_token, String userId) { |
258 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 258 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
259 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 259 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
260 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 260 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
261 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 261 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
262 | 262 | ||
263 | 263 | ||
264 | } | 264 | } |
265 | 265 | ||
266 | //提交保卡信息 | 266 | //提交保卡信息 |
267 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 267 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
268 | String buyAddress, String buyTime, String alterSaleCall, | 268 | String buyAddress, String buyTime, String alterSaleCall, |
269 | String productModel, String deviceNumber, String macAddress, | 269 | String productModel, String deviceNumber, String macAddress, |
270 | String mobilePhone) { | 270 | String mobilePhone) { |
271 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 271 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
272 | false, true, null); | 272 | false, true, null); |
273 | RequestParams params = new RequestParams(); | 273 | RequestParams params = new RequestParams(); |
274 | 274 | ||
275 | params.put(HttpKey.USEID, userId); | 275 | params.put(HttpKey.USEID, userId); |
276 | params.put(HttpKey.CUSTOMENAME, customerName); | 276 | params.put(HttpKey.CUSTOMENAME, customerName); |
277 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 277 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
278 | params.put(HttpKey.BUYADREES, buyAddress); | 278 | params.put(HttpKey.BUYADREES, buyAddress); |
279 | params.put(HttpKey.BUYTIME, buyTime); | 279 | params.put(HttpKey.BUYTIME, buyTime); |
280 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 280 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
281 | params.put(HttpKey.PRODUCTMODEL, productModel); | 281 | params.put(HttpKey.PRODUCTMODEL, productModel); |
282 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 282 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
283 | params.put(HttpKey.MACADRESS, macAddress); | 283 | params.put(HttpKey.MACADRESS, macAddress); |
284 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 284 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
285 | 285 | ||
286 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 286 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
287 | 287 | ||
288 | Log.e("test", "params" + params); | 288 | Log.e("test", "params" + params); |
289 | HttpClient.getInstance().setTimeout(5 * 1000); | 289 | HttpClient.getInstance().setTimeout(5 * 1000); |
290 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 290 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
291 | @Override | 291 | @Override |
292 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 292 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
293 | JSONObject jsonObject = null; | 293 | JSONObject jsonObject = null; |
294 | closeProgress(); | 294 | closeProgress(); |
295 | try { | 295 | try { |
296 | jsonObject = new JSONObject(new String(bytes)); | 296 | jsonObject = new JSONObject(new String(bytes)); |
297 | String status = jsonObject.optString("status"); | 297 | String status = jsonObject.optString("status"); |
298 | if (status.equals("1")) { | 298 | if (status.equals("1")) { |
299 | Log.e("test", "onSuccess" + jsonObject); | 299 | Log.e("test", "onSuccess" + jsonObject); |
300 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 300 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
301 | if (Content.cardintentflag ==1){ | 301 | if (Content.cardintentflag == 1) { |
302 | Intent intent = new Intent(); | 302 | Intent intent = new Intent(); |
303 | intent.setClass((Activity) context, TheStartPageActivity.class); | 303 | intent.setClass((Activity) context, TheStartPageActivity.class); |
304 | ((Activity) context).startActivity(intent); | 304 | ((Activity) context).startActivity(intent); |
305 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 305 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
306 | ((Activity) context).finish(); | 306 | ((Activity) context).finish(); |
307 | }else if (Content.cardintentflag ==2){ | 307 | } else if (Content.cardintentflag == 2) { |
308 | Intent intent = new Intent(); | 308 | Intent intent = new Intent(); |
309 | intent.setClass((Activity) context, BangDingCode.class); | 309 | intent.setClass((Activity) context, BangDingCode.class); |
310 | ((Activity) context).startActivity(intent); | 310 | ((Activity) context).startActivity(intent); |
311 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 311 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
312 | ((Activity) context).finish(); | 312 | ((Activity) context).finish(); |
313 | 313 | ||
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | } else { | 317 | } else { |
318 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); | 318 | Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show(); |
319 | } | 319 | } |
320 | } catch (JSONException e) { | 320 | } catch (JSONException e) { |
321 | e.printStackTrace(); | 321 | e.printStackTrace(); |
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | } | 325 | } |
326 | 326 | ||
327 | @Override | 327 | @Override |
328 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 328 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
329 | Log.e("test", "onFailure" + (throwable)); | 329 | Log.e("test", "onFailure" + (throwable)); |
330 | closeProgress(); | 330 | closeProgress(); |
331 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); | 331 | AlertUtils.showToast(context, "无法链接到服务器,请检查您的网络或稍后重试!"); |
332 | 332 | ||
333 | } | 333 | } |
334 | }); | 334 | }); |
335 | 335 | ||
336 | } | 336 | } |
337 | 337 | ||
338 | //获取保卡信息 | 338 | //获取保卡信息 |
339 | public void getcardinfo(final Context mContext, String deviceNumber, final Handler handler) { | 339 | public void getcardinfo(final Context mContext, String deviceNumber, final Handler handler) { |
340 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 340 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
341 | false, true, null); | 341 | false, true, null); |
342 | HttpClient.getInstance().setTimeout(5 * 1000); | 342 | HttpClient.getInstance().setTimeout(5 * 1000); |
343 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 343 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
344 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 344 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
345 | @Override | 345 | @Override |
346 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 346 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
347 | closeProgress(); | 347 | closeProgress(); |
348 | Log.e("test", "保卡信息" + new String(arg2)); | 348 | Log.e("test", "保卡信息" + new String(arg2)); |
349 | try { | 349 | try { |
350 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 350 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
351 | int status = jsonObject.optInt("status"); | 351 | int status = jsonObject.optInt("status"); |
352 | if (status == 1) { | 352 | if (status == 1) { |
353 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 353 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
354 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 354 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
355 | Message msg = Message.obtain(); | 355 | Message msg = Message.obtain(); |
356 | msg.what = HttpCode.SUCHCARDINFO; | 356 | msg.what = HttpCode.SUCHCARDINFO; |
357 | msg.obj = schoolInfoBeanList; | 357 | msg.obj = schoolInfoBeanList; |
358 | handler.sendMessage(msg); | 358 | handler.sendMessage(msg); |
359 | 359 | ||
360 | 360 | ||
361 | } else { | 361 | } else { |
362 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 362 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
363 | 363 | ||
364 | } | 364 | } |
365 | } catch (JSONException e) { | 365 | } catch (JSONException e) { |
366 | e.printStackTrace(); | 366 | e.printStackTrace(); |
367 | } | 367 | } |
368 | 368 | ||
369 | } | 369 | } |
370 | 370 | ||
371 | @Override | 371 | @Override |
372 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 372 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
373 | closeProgress(); | 373 | closeProgress(); |
374 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 374 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
375 | } | 375 | } |
376 | }); | 376 | }); |
377 | } | 377 | } |
378 | 378 | ||
379 | //获取是否为样机信息 | ||
380 | public void getcardinfo1(final Context mContext, String deviceNumber, final Handler handler) { | ||
381 | HttpClient.getInstance().setTimeout(5 * 1000); | ||
382 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||
383 | HttpClient.getInstance().get(HttpUrl.getcardinfo + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | ||
384 | @Override | ||
385 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
386 | closeProgress(); | ||
387 | Log.e("test", "保卡信息" + new String(arg2)); | ||
388 | Message msg = Message.obtain(); | ||
389 | msg.what = HttpCode.SUCHCARDINFOONE; | ||
390 | msg.obj = new String(arg2); | ||
391 | handler.sendMessage(msg); | ||
392 | |||
393 | } | ||
394 | |||
395 | @Override | ||
396 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
397 | closeProgress(); | ||
398 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | ||
399 | } | ||
400 | }); | ||
401 | } | ||
402 | |||
403 | //修改账户电话 | ||
404 | public void changeaccountphone(final Context mContext, long userId, final String username, String authCode) { | ||
405 | RequestParams params = new RequestParams(); | ||
406 | params.put("userId", userId); | ||
407 | params.put("username", username); | ||
408 | params.put("authCode", authCode); | ||
409 | HttpClient.getInstance().addHeader("Accept", "*/*"); | ||
410 | HttpClient.getInstance().post(HttpUrl.chageaccountphoneURL, params, new AsyncHttpResponseHandler() { | ||
411 | @Override | ||
412 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | ||
413 | try { | ||
414 | Log.e("test", "保卡信息" + new String(bytes)); | ||
415 | JSONObject jsonObject = new JSONObject(new String(bytes)); | ||
416 | String status = jsonObject.optString("status"); | ||
417 | if (status.equals("1")) { | ||
418 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | ||
419 | SaveParam.getInstance().saveLoginParam(mContext, "username", username); | ||
420 | ((Activity) mContext).finish(); | ||
421 | } else if (status.equals("1001")) { | ||
422 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | ||
423 | } | ||
424 | else if (status.equals("1006")) { | ||
425 | AlertUtils.showToast(mContext, "该手机号已存在,请使用其他手机号重新绑定!"); | ||
426 | } else { | ||
427 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | ||
428 | } | ||
429 | } catch (JSONException e) { | ||
430 | e.printStackTrace(); | ||
431 | } | ||
432 | } | ||
433 | |||
434 | @Override | ||
435 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | ||
436 | Log.e("test", "onFailure" + new String(bytes)); | ||
437 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | ||
438 | } | ||
439 | }); | ||
440 | } | ||
441 | |||
379 | //修改保卡信息电话 | 442 | //修改保卡信息电话 |
380 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 443 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
381 | RequestParams params = new RequestParams(); | 444 | RequestParams params = new RequestParams(); |
382 | params.put("userId", userId); | 445 | params.put("userId", userId); |
383 | params.put("customerPhone", customerPhone); | 446 | params.put("customerPhone", customerPhone); |
384 | params.put("authCode", authCode); | 447 | params.put("authCode", authCode); |
385 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 448 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
386 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 449 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
387 | @Override | 450 | @Override |
388 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 451 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
389 | try { | 452 | try { |
390 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 453 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
391 | String status = jsonObject.optString("status"); | 454 | String status = jsonObject.optString("status"); |
392 | if (status.equals("1")) { | 455 | if (status.equals("1")) { |
393 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 456 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
394 | if (Content.authcodeflag==2){ | 457 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); |
395 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | ||
396 | }else if (Content.authcodeflag==1){ | ||
397 | SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); | ||
398 | }else { | ||
399 | AlertUtils.showToast(mContext, "修改未知的手机号"); | ||
400 | } | ||
401 | ((Activity) mContext).finish(); | 458 | ((Activity) mContext).finish(); |
402 | } else if (status.equals("1001")) { | 459 | } else if (status.equals("1001")) { |
403 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 460 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
404 | } else { | 461 | } else { |
405 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 462 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
406 | } | 463 | } |
407 | } catch (JSONException e) { | 464 | } catch (JSONException e) { |
408 | e.printStackTrace(); | 465 | e.printStackTrace(); |
409 | } | 466 | } |
410 | } | 467 | } |
411 | 468 | ||
412 | @Override | 469 | @Override |
413 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 470 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
414 | Log.e("test", "onFailure" + new String(bytes)); | 471 | Log.e("test", "onFailure" + new String(bytes)); |
415 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 472 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
416 | } | 473 | } |
417 | }); | 474 | }); |
418 | } | 475 | } |
419 | 476 | ||
420 | //修改保卡信息地址 | 477 | //修改保卡信息地址 |
421 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 478 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
422 | RequestParams params = new RequestParams(); | 479 | RequestParams params = new RequestParams(); |
423 | params.put("userId", userId); | 480 | params.put("userId", userId); |
424 | params.put("customerPhone", customerPhone); | 481 | params.put("customerPhone", customerPhone); |
425 | params.put("authCode", authCode); | 482 | params.put("authCode", authCode); |
426 | params.put("customerAddress", customerAddress); | 483 | params.put("customerAddress", customerAddress); |
427 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 484 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
428 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 485 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
429 | @Override | 486 | @Override |
430 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 487 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
431 | try { | 488 | try { |
432 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 489 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
433 | String status = jsonObject.optString("status"); | 490 | String status = jsonObject.optString("status"); |
434 | if (status.equals("1")) { | 491 | if (status.equals("1")) { |
435 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); | 492 | Toast.makeText(mContext, "修改成功", Toast.LENGTH_LONG).show(); |
436 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); | 493 | SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.ADRESSCUNSTEM, customerAddress); |
437 | ((Activity) mContext).finish(); | 494 | ((Activity) mContext).finish(); |
438 | } else { | 495 | } else { |
439 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 496 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
440 | } | 497 | } |
441 | } catch (JSONException e) { | 498 | } catch (JSONException e) { |
442 | e.printStackTrace(); | 499 | e.printStackTrace(); |
443 | } | 500 | } |
444 | } | 501 | } |
445 | 502 | ||
446 | @Override | 503 | @Override |
447 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 504 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
448 | Log.e("test", "onFailure" + new String(bytes)); | 505 | Log.e("test", "onFailure" + new String(bytes)); |
449 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 506 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
450 | } | 507 | } |
451 | }); | 508 | }); |
452 | } | 509 | } |
453 | 510 | ||
454 | //验证是否保卡信息 | 511 | //验证是否保卡信息 |
455 | public void cardinfocheck(final Context mContext, String deviceNumber, final Handler handler) { | 512 | public void cardinfocheck(final Context mContext, String deviceNumber, final Handler handler) { |
456 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 513 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
457 | false, true, null); | 514 | false, true, null); |
458 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 515 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
459 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 516 | HttpClient.getInstance().get(HttpUrl.cardcheck + "?deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
460 | @Override | 517 | @Override |
461 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 518 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
462 | Log.e("test", "---" + new String(arg2)); | 519 | Log.e("test", "验证保卡" + new String(arg2)); |
463 | closeProgress(); | 520 | closeProgress(); |
464 | Message msg = Message.obtain(); | 521 | Message msg = Message.obtain(); |
465 | msg.what = HttpCode.CHECKCARD; | 522 | msg.what = HttpCode.CHECKCARD; |
466 | msg.obj = new String(arg2); | 523 | msg.obj = new String(arg2); |
467 | handler.sendMessage(msg); | 524 | handler.sendMessage(msg); |
468 | 525 | ||
469 | 526 | ||
470 | } | 527 | } |
471 | 528 | ||
472 | @Override | 529 | @Override |
473 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 530 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
474 | closeProgress(); | 531 | closeProgress(); |
475 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 532 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
476 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 533 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
477 | } | 534 | } |
478 | }); | 535 | }); |
479 | } | 536 | } |
480 | 537 | ||
481 | ///获取年级 | 538 | ///获取年级 |
482 | public void getgrade(final Context mContext, final Handler handler) { | 539 | public void getgrade(final Context mContext, final Handler handler) { |
483 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 540 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
484 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 541 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
485 | @Override | 542 | @Override |
486 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 543 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
487 | Log.e("test", "年级" + new String(arg2)); | 544 | Log.e("test", "年级" + new String(arg2)); |
488 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 545 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
489 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 546 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
490 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { | 547 | for (int i = 0; i < gradeInfo.getData().size() - 2; i++) { |
491 | String name = gradeInfo.getData().get(i).getName(); | 548 | String name = gradeInfo.getData().get(i).getName(); |
492 | int id = gradeInfo.getData().get(i).getId(); | 549 | int id = gradeInfo.getData().get(i).getId(); |
493 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 550 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
494 | for (int j = 0; j < gradeinfoList.size(); j++) { | 551 | for (int j = 0; j < gradeinfoList.size(); j++) { |
495 | String secondname = gradeinfoList.get(j).getName(); | 552 | String secondname = gradeinfoList.get(j).getName(); |
496 | int secondid = gradeinfoList.get(j).getId(); | 553 | int secondid = gradeinfoList.get(j).getId(); |
497 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 554 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
498 | dataBean.setName(secondname); | 555 | dataBean.setName(secondname); |
499 | dataBean.setId(secondid); | 556 | dataBean.setId(secondid); |
500 | gradeInfoLists.add(dataBean); | 557 | gradeInfoLists.add(dataBean); |
501 | } | 558 | } |
502 | 559 | ||
503 | } | 560 | } |
504 | 561 | ||
505 | Message message = Message.obtain(); | 562 | Message message = Message.obtain(); |
506 | message.what = HttpCode.GRADER; | 563 | message.what = HttpCode.GRADER; |
507 | message.obj = gradeInfoLists; | 564 | message.obj = gradeInfoLists; |
508 | handler.sendMessage(message); | 565 | handler.sendMessage(message); |
509 | 566 | ||
510 | 567 | ||
511 | } | 568 | } |
512 | 569 | ||
513 | @Override | 570 | @Override |
514 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 571 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
515 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 572 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
516 | } | 573 | } |
517 | }); | 574 | }); |
518 | } | 575 | } |
519 | 576 | ||
520 | /** | 577 | /** |
521 | * 获取学校 | 578 | * 获取学校 |
522 | * | 579 | * |
523 | * @param mContext | 580 | * @param mContext |
524 | * @param regionId | 581 | * @param regionId |
525 | * @param gradeId | 582 | * @param gradeId |
526 | * @param handler | 583 | * @param handler |
527 | */ | 584 | */ |
528 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 585 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
529 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 586 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
530 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 587 | HttpClient.getInstance().get(HttpUrl.schoolUrl + "?regionId=" + regionId + "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
531 | @Override | 588 | @Override |
532 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 589 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
533 | Log.e("test", "学校" + new String(arg2)); | 590 | Log.e("test", "学校" + new String(arg2)); |
534 | try { | 591 | try { |
535 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 592 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
536 | int status = jsonObject.optInt("status"); | 593 | int status = jsonObject.optInt("status"); |
537 | if (status == 1) { | 594 | if (status == 1) { |
538 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 595 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
539 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 596 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
540 | Message message = Message.obtain(); | 597 | Message message = Message.obtain(); |
541 | message.what = HttpCode.SCHOOL; | 598 | message.what = HttpCode.SCHOOL; |
542 | message.obj = schoolInfoBeanList; | 599 | message.obj = schoolInfoBeanList; |
543 | handler.sendMessage(message); | 600 | handler.sendMessage(message); |
544 | 601 | ||
545 | 602 | ||
546 | } else { | 603 | } else { |
547 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 604 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
548 | 605 | ||
549 | } | 606 | } |
550 | } catch (JSONException e) { | 607 | } catch (JSONException e) { |
551 | e.printStackTrace(); | 608 | e.printStackTrace(); |
552 | } | 609 | } |
553 | 610 | ||
554 | } | 611 | } |
555 | 612 | ||
556 | @Override | 613 | @Override |
557 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 614 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
558 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 615 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
559 | } | 616 | } |
560 | }); | 617 | }); |
561 | } | 618 | } |
562 | 619 | ||
563 | 620 | ||
564 | /** | 621 | /** |
565 | * 获取个人信息 | 622 | * 获取个人信息 |
566 | * | 623 | * |
567 | * @param mContext | 624 | * @param mContext |
568 | * @param userId | 625 | * @param userId |
569 | * @param handler | 626 | * @param handler |
570 | */ | 627 | */ |
571 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { | 628 | public void getpresonalinfo(final Context mContext, long userId, int type, final Handler handler) { |
572 | // mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 629 | // mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
573 | // false, true, null); | 630 | // false, true, null); |
574 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 631 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
575 | HttpClient.getInstance().setConnectTimeout(5 * 1000); | 632 | HttpClient.getInstance().setConnectTimeout(5 * 1000); |
576 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 633 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
577 | @Override | 634 | @Override |
578 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 635 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
579 | closeProgress(); | 636 | closeProgress(); |
580 | Log.e("test", "个人信息" + new String(arg2)); | 637 | Log.e("test", "个人信息" + new String(arg2)); |
581 | try { | 638 | try { |
582 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 639 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
583 | int status = jsonObject.optInt("status"); | 640 | int status = jsonObject.optInt("status"); |
584 | if (status == 1) { | 641 | if (status == 1) { |
585 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 642 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
586 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 643 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
587 | Message message = Message.obtain(); | 644 | Message message = Message.obtain(); |
588 | message.what = HttpCode.GETINFO; | 645 | message.what = HttpCode.GETINFO; |
589 | message.obj = pesonalInfoBeanList; | 646 | message.obj = pesonalInfoBeanList; |
590 | handler.sendMessage(message); | 647 | handler.sendMessage(message); |
591 | 648 | ||
592 | 649 | ||
593 | } else { | 650 | } else { |
594 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 651 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
595 | 652 | ||
596 | } | 653 | } |
597 | } catch (JSONException e) { | 654 | } catch (JSONException e) { |
598 | e.printStackTrace(); | 655 | e.printStackTrace(); |
599 | } | 656 | } |
600 | 657 | ||
601 | 658 | ||
602 | } | 659 | } |
603 | 660 | ||
604 | @Override | 661 | @Override |
605 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 662 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
606 | closeProgress(); | 663 | closeProgress(); |
607 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 664 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
608 | } | 665 | } |
609 | }); | 666 | }); |
610 | } | 667 | } |
611 | 668 | ||
612 | //修改个人信息 | 669 | //修改个人信息 |
613 | public void changepresonalinfo(final Context mContext, Long id, int type | 670 | public void changepresonalinfo(final Context mContext, Long id, int type |
614 | , String name, String birthday, int gradeId, long regionId, | 671 | , String name, String birthday, int gradeId, long regionId, |
615 | Object schoolId, String qq, String gender | 672 | Object schoolId, String qq, String gender |
616 | , String regionName, String devicenumber) throws UnsupportedEncodingException { | 673 | , String regionName, String devicenumber) throws UnsupportedEncodingException { |
617 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 674 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
618 | false, true, null); | 675 | false, true, null); |
619 | RequestParams params = new RequestParams(); | 676 | RequestParams params = new RequestParams(); |
620 | 677 | ||
621 | params.put(HttpKey.USEID, id); | 678 | params.put(HttpKey.USEID, id); |
622 | params.put(HttpKey.TYPE, type); | 679 | params.put(HttpKey.TYPE, type); |
623 | params.put(HttpKey.NAME, name); | 680 | params.put(HttpKey.NAME, name); |
624 | params.put(HttpKey.BIRDays, birthday); | 681 | params.put(HttpKey.BIRDays, birthday); |
625 | params.put(HttpKey.GRADE, gradeId); | 682 | params.put(HttpKey.GRADE, gradeId); |
626 | params.put(HttpKey.REGION, regionId); | 683 | params.put(HttpKey.REGION, regionId); |
627 | params.put(HttpKey.SCHOOL, schoolId); | 684 | params.put(HttpKey.SCHOOL, schoolId); |
628 | params.put(HttpKey.QQ, qq); | 685 | params.put(HttpKey.QQ, qq); |
629 | params.put(HttpKey.GENDER, gender); | 686 | params.put(HttpKey.GENDER, gender); |
630 | params.put(HttpKey.REGIONNAME, regionName); | 687 | params.put(HttpKey.REGIONNAME, regionName); |
631 | params.put(HttpKey.DEVINUMBER, devicenumber); | 688 | params.put(HttpKey.DEVINUMBER, devicenumber); |
632 | Log.e("test", "个人信息" + params); | 689 | Log.e("test", "个人信息" + params); |
633 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 690 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
634 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { | 691 | HttpClient.getInstance().post(mContext, HttpUrl.changepresonalinfo, params, new JsonHttpResponseHandler() { |
635 | @Override | 692 | @Override |
636 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 693 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
637 | super.onSuccess(statusCode, headers, response); | 694 | super.onSuccess(statusCode, headers, response); |
638 | closeProgress(); | 695 | closeProgress(); |
639 | String status = response.optString("status"); | 696 | String status = response.optString("status"); |
640 | if (status.equals("1")) { | 697 | if (status.equals("1")) { |
641 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 698 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
642 | ((Activity) mContext).finish(); | 699 | ((Activity) mContext).finish(); |
643 | } else { | 700 | } else { |
644 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); | 701 | AlertUtils.showToast(mContext, "您好,服务器异常,请稍后重试"); |
645 | } | 702 | } |
646 | 703 | ||
647 | } | 704 | } |
648 | 705 | ||
649 | @Override | 706 | @Override |
650 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 707 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
651 | super.onFailure(statusCode, headers, throwable, errorResponse); | 708 | super.onFailure(statusCode, headers, throwable, errorResponse); |
652 | closeProgress(); | 709 | closeProgress(); |
653 | Log.e("test", "onFailure" + errorResponse); | 710 | Log.e("test", "onFailure" + errorResponse); |
654 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 711 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
655 | } | 712 | } |
656 | 713 | ||
657 | }); | 714 | }); |
658 | } | 715 | } |
716 | |||
659 | //提交注册信息 | 717 | //提交注册信息 |
660 | public void subregisterinfo(final Context mContext, Long userId | 718 | public void subregisterinfo(final Context mContext, Long userId |
661 | , String name, int gradeId, long regionId, String regionName, Object schoolId, | 719 | , String name, int gradeId, long regionId, String regionName, Object schoolId, String chinese, |
662 | String math, String english, String physics, String chinese, String chemistry, | 720 | String math, String english, String physics, String chemistry, |
663 | String history, String geography, String political, String biology, String science, final Handler handler){ | 721 | String history, String geography, String political, String biology, String science, final Handler handler) { |
664 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 722 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
665 | false, true, null); | 723 | false, true, null); |
666 | RequestParams params = new RequestParams(); | 724 | RequestParams params = new RequestParams(); |
667 | 725 | ||
668 | params.put(HttpKey.USEID, userId); | 726 | params.put(HttpKey.USEID, userId); |
669 | params.put(HttpKey.NAME, name); | 727 | params.put(HttpKey.NAME, name); |
670 | params.put(HttpKey.GRADE, gradeId); | 728 | params.put(HttpKey.GRADE, gradeId); |
671 | params.put(HttpKey.REGION, regionId); | 729 | params.put(HttpKey.REGION, regionId); |
672 | params.put(HttpKey.SCHOOL, schoolId); | 730 | params.put(HttpKey.SCHOOL, schoolId); |
673 | params.put(HttpKey.REGIONNAME, regionName); | 731 | params.put(HttpKey.REGIONNAME, regionName); |
674 | params.put(HttpKey.MATH, math); | 732 | params.put(HttpKey.MATH, math); |
675 | params.put(HttpKey.ENGLISH, english); | 733 | params.put(HttpKey.ENGLISH, english); |
676 | params.put(HttpKey.PHYSICES, physics); | 734 | params.put(HttpKey.PHYSICES, physics); |
677 | params.put(HttpKey.CHINESE, chinese); | ||
678 | params.put(HttpKey.CHEMISTRY, chemistry); | 735 | params.put(HttpKey.CHEMISTRY, chemistry); |
679 | params.put(HttpKey.HISTIRY, history); | 736 | params.put(HttpKey.HISTIRY, history); |
680 | params.put(HttpKey.GEOGRAPHY, geography); | 737 | params.put(HttpKey.GEOGRAPHY, geography); |
681 | params.put(HttpKey.POLITICAL, political); | 738 | params.put(HttpKey.POLITICAL, political); |
682 | params.put(HttpKey.BIOLOGY, biology); | 739 | params.put(HttpKey.BIOLOGY, biology); |
683 | params.put(HttpKey.SCIENCE, science); | 740 | params.put(HttpKey.SCIENCE, science); |
684 | 741 | ||
685 | Log.e("test", "注册信息" + params); | 742 | Log.e("test", "注册信息" + params); |
686 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 743 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
687 | HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { | 744 | HttpClient.getInstance().post(mContext, HttpUrl.submitregisterURL, params, new JsonHttpResponseHandler() { |
688 | @Override | 745 | @Override |
689 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 746 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
690 | super.onSuccess(statusCode, headers, response); | 747 | super.onSuccess(statusCode, headers, response); |
691 | closeProgress(); | 748 | closeProgress(); |
692 | Message message = Message.obtain(); | 749 | Message message = Message.obtain(); |
693 | message.what = HttpCode.REGISTERINFO_SUCESS; | 750 | message.what = HttpCode.REGISTERINFO_SUCESS; |
694 | message.obj = new String(String.valueOf(response)); | 751 | message.obj = new String(String.valueOf(response)); |
695 | handler.sendMessage(message); | 752 | handler.sendMessage(message); |
696 | 753 | ||
697 | } | 754 | } |
698 | 755 | ||
699 | @Override | 756 | @Override |
700 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 757 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
701 | super.onFailure(statusCode, headers, throwable, errorResponse); | 758 | super.onFailure(statusCode, headers, throwable, errorResponse); |
702 | closeProgress(); | 759 | closeProgress(); |
703 | Log.e("test", "onFailure" + errorResponse); | 760 | Log.e("test", "onFailure" + errorResponse); |
704 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 761 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
705 | } | 762 | } |
706 | 763 | ||
707 | }); | 764 | }); |
708 | } | 765 | } |
766 | |||
709 | //修改版本信息 | 767 | //修改版本信息 |
710 | public void changepublishinfo(final Context mContext, String userId, String chinese, | 768 | public void changepublishinfo(final Context mContext, String userId, String chinese, |
711 | String math, String english, String physics, String chemistry, | 769 | String math, String english, String physics, String chemistry, |
712 | String history, String geography, String political, String biology, String science){ | 770 | String history, String geography, String political, String biology, String science) { |
713 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 771 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
714 | false, true, null); | 772 | false, true, null); |
715 | RequestParams params = new RequestParams(); | 773 | RequestParams params = new RequestParams(); |
716 | params.put(HttpKey.USEID, userId); | 774 | params.put(HttpKey.USEID, userId); |
717 | params.put(HttpKey.CHINESE, chinese); | 775 | params.put(HttpKey.CHINESE, chinese); |
718 | params.put(HttpKey.MATH, math); | 776 | params.put(HttpKey.MATH, math); |
719 | params.put(HttpKey.ENGLISH, english); | 777 | params.put(HttpKey.ENGLISH, english); |
720 | params.put(HttpKey.PHYSICES, physics); | 778 | params.put(HttpKey.PHYSICES, physics); |
721 | params.put(HttpKey.CHEMISTRY, chemistry); | 779 | params.put(HttpKey.CHEMISTRY, chemistry); |
722 | params.put(HttpKey.HISTIRY, history); | 780 | params.put(HttpKey.HISTIRY, history); |
723 | params.put(HttpKey.GEOGRAPHY, geography); | 781 | params.put(HttpKey.GEOGRAPHY, geography); |
724 | params.put(HttpKey.POLITICAL, political); | 782 | params.put(HttpKey.POLITICAL, political); |
725 | params.put(HttpKey.BIOLOGY, biology); | 783 | params.put(HttpKey.BIOLOGY, biology); |
726 | params.put(HttpKey.SCIENCE, science); | 784 | params.put(HttpKey.SCIENCE, science); |
727 | 785 | ||
728 | Log.e("test", "版本信息信息" + params); | 786 | Log.e("test", "版本信息信息" + params); |
729 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 787 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
730 | HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { | 788 | HttpClient.getInstance().post(mContext, HttpUrl.chagepublishURL, params, new JsonHttpResponseHandler() { |
731 | @Override | 789 | @Override |
732 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 790 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
733 | super.onSuccess(statusCode, headers, response); | 791 | super.onSuccess(statusCode, headers, response); |
734 | closeProgress(); | 792 | closeProgress(); |
735 | String status = response.optString("status"); | 793 | String status = response.optString("status"); |
736 | if (status.equals("1")) { | 794 | if (status.equals("1")) { |
737 | Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); | 795 | Toast.makeText(mContext, "版本信息修改成功", Toast.LENGTH_LONG).show(); |
738 | ((Activity) mContext).finish(); | 796 | ((Activity) mContext).finish(); |
739 | } else { | 797 | } else { |
740 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 798 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
741 | } | 799 | } |
742 | 800 | ||
743 | } | 801 | } |
744 | 802 | ||
745 | @Override | 803 | @Override |
746 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 804 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
747 | super.onFailure(statusCode, headers, throwable, errorResponse); | 805 | super.onFailure(statusCode, headers, throwable, errorResponse); |
748 | closeProgress(); | 806 | closeProgress(); |
749 | Log.e("test", "onFailure" + errorResponse); | 807 | Log.e("test", "onFailure" + errorResponse); |
750 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 808 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
751 | } | 809 | } |
752 | 810 | ||
753 | }); | 811 | }); |
754 | } | 812 | } |
755 | 813 | ||
756 | //修改个性签名 | 814 | //修改个性签名 |
757 | public void changsignature(final Context mContext, long userId, int type, final String signature) { | 815 | public void changsignature(final Context mContext, long userId, int type, final String signature) { |
758 | RequestParams params = new RequestParams(); | 816 | RequestParams params = new RequestParams(); |
759 | params.put("userId", userId); | 817 | params.put("userId", userId); |
760 | params.put("type", type); | 818 | params.put("type", type); |
761 | params.put("signature", signature); | 819 | params.put("signature", signature); |
762 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 820 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
763 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 821 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
764 | @Override | 822 | @Override |
765 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 823 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
766 | try { | 824 | try { |
767 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 825 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
768 | String status = jsonObject.optString("status"); | 826 | String status = jsonObject.optString("status"); |
769 | if (status.equals("1")) { | 827 | if (status.equals("1")) { |
770 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 828 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
771 | } else { | 829 | } else { |
772 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 830 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
773 | } | 831 | } |
774 | } catch (JSONException e) { | 832 | } catch (JSONException e) { |
775 | e.printStackTrace(); | 833 | e.printStackTrace(); |
776 | } | 834 | } |
777 | } | 835 | } |
778 | 836 | ||
779 | @Override | 837 | @Override |
780 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 838 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
781 | Log.e("test", "onFailure" + new String(bytes)); | 839 | //Log.e("test", "onFailure" + new String(bytes)); |
782 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 840 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
783 | } | 841 | } |
784 | }); | 842 | }); |
785 | } | 843 | } |
786 | 844 | ||
787 | /** | 845 | /** |
788 | * 获取个性签名 | 846 | * 获取个性签名 |
789 | * | 847 | * |
790 | * @param mContext | 848 | * @param mContext |
791 | * @param userId | 849 | * @param userId |
792 | * @param handler | 850 | * @param handler |
793 | */ | 851 | */ |
794 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { | 852 | public void getsignatures(final Context mContext, long userId, int type, final Handler handler) { |
795 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 853 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
796 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { | 854 | HttpClient.getInstance().get(HttpUrl.getsignature + "?userId=" + userId + "&type=" + type, new AsyncHttpResponseHandler() { |
797 | @Override | 855 | @Override |
798 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 856 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
799 | Log.e("test", "个性签名" + new String(arg2)); | 857 | Log.e("test", "个性签名" + new String(arg2)); |
800 | try { | 858 | try { |
801 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 859 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
802 | int status = jsonObject.optInt("status"); | 860 | int status = jsonObject.optInt("status"); |
803 | if (status == 1) { | 861 | if (status == 1) { |
804 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 862 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
805 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 863 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
806 | Message message = Message.obtain(); | 864 | Message message = Message.obtain(); |
807 | message.what = HttpCode.SIGN; | 865 | message.what = HttpCode.SIGN; |
808 | message.obj = signInfoBeanList; | 866 | message.obj = signInfoBeanList; |
809 | handler.sendMessage(message); | 867 | handler.sendMessage(message); |
810 | 868 | ||
811 | 869 | ||
812 | } else if (status == 1000) { | 870 | } else if (status == 1000) { |
813 | //AlertUtils.showToast(mContext, "您还没有签名哦"); | 871 | //AlertUtils.showToast(mContext, "您还没有签名哦"); |
814 | 872 | ||
815 | } else { | 873 | } else { |
816 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 874 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
817 | } | 875 | } |
818 | } catch (JSONException e) { | 876 | } catch (JSONException e) { |
819 | e.printStackTrace(); | 877 | e.printStackTrace(); |
820 | } | 878 | } |
821 | 879 | ||
822 | 880 | ||
823 | } | 881 | } |
824 | 882 | ||
825 | @Override | 883 | @Override |
826 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 884 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
827 | Log.e("test", "失败原因" + arg3); | 885 | //Log.e("test", "失败原因" + arg3); |
828 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 886 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
829 | } | 887 | } |
830 | }); | 888 | }); |
831 | } | 889 | } |
832 | 890 | ||
833 | /** | 891 | /** |
834 | * 用户反馈 | 892 | * 用户反馈 |
835 | * | 893 | * |
836 | * @param mContext | 894 | * @param mContext |
837 | * @param userId | 895 | * @param userId |
838 | * @param content | 896 | * @param content |
839 | * @param contact | 897 | * @param contact |
840 | * @param imgs | 898 | * @param imgs |
841 | * @param feedtype | 899 | * @param feedtype |
842 | * @throws UnsupportedEncodingException | 900 | * @throws UnsupportedEncodingException |
843 | */ | 901 | */ |
844 | public void feedback(final Context mContext, String userId, String content, | 902 | public void feedback(final Context mContext, String userId, String content, |
845 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { | 903 | String contact, String imgs, String feedtype) throws UnsupportedEncodingException { |
846 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 904 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
847 | false, true, null); | 905 | false, true, null); |
848 | File file = new File(imgs); | 906 | File file = new File(imgs); |
849 | if (file.exists() && file.length() > 0) { | 907 | RequestParams params = new RequestParams(); |
850 | RequestParams params = new RequestParams(); | 908 | try { |
851 | try { | 909 | params.put("userId", userId); |
852 | params.put("userId", userId); | 910 | params.put("content", content); |
853 | params.put("content", content); | 911 | params.put("contact", contact); |
854 | params.put("contact", contact); | 912 | if (file.exists() && file.length() > 0) { |
855 | params.put("imgs", file); | 913 | params.put("imgs", file); |
856 | params.put("feedtype", feedtype); | ||
857 | } catch (FileNotFoundException e) { | ||
858 | e.printStackTrace(); | ||
859 | } | 914 | } |
860 | Log.e("test", "onSuccess" + params); | 915 | params.put("feedtype", feedtype); |
861 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { | 916 | } catch (FileNotFoundException e) { |
862 | @Override | 917 | e.printStackTrace(); |
863 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 918 | } |
864 | closeProgress(); | 919 | Log.e("test", "onSuccess" + params); |
865 | Log.e("test", "onSuccess" + new String(bytes)); | 920 | HttpClient.getInstance().post(HttpUrl.feedbackURL, params, new AsyncHttpResponseHandler() { |
866 | try { | 921 | @Override |
867 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 922 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
868 | String status = jsonObject.optString("status"); | 923 | closeProgress(); |
869 | if (status.equals("1")) { | 924 | Log.e("test", "onSuccess" + new String(bytes)); |
870 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); | 925 | try { |
871 | ((Activity) mContext).finish(); | 926 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
872 | } else { | 927 | String status = jsonObject.optString("status"); |
873 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 928 | if (status.equals("1")) { |
874 | } | 929 | Toast.makeText(mContext, "您的宝贵意见已经提交成功。", Toast.LENGTH_LONG).show(); |
875 | } catch (JSONException e) { | 930 | ((Activity) mContext).finish(); |
876 | e.printStackTrace(); | 931 | } else { |
932 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | ||
877 | } | 933 | } |
934 | } catch (JSONException e) { | ||
935 | e.printStackTrace(); | ||
878 | } | 936 | } |
937 | } | ||
879 | 938 | ||
880 | @Override | 939 | @Override |
881 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 940 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
882 | closeProgress(); | 941 | closeProgress(); |
883 | Log.e("test", "错误信息" + new String(bytes)); | 942 | //Log.e("test", "错误信息" + new String(bytes)); |
884 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 943 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
944 | |||
945 | } | ||
946 | }); | ||
885 | 947 | ||
886 | } | ||
887 | }); | ||
888 | } else { | ||
889 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | ||
890 | } | ||
891 | } | 948 | } |
892 | 949 | ||
893 | /** | 950 | /** |
894 | * 查询子账户信息 | 951 | * 查询子账户信息 |
895 | * | 952 | * |
896 | * @param mContext | 953 | * @param mContext |
897 | * @param userId | 954 | * @param userId |
898 | * @param handler | 955 | * @param handler |
899 | */ | 956 | */ |
900 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { | 957 | public void getchildAccountinfo(final Context mContext, long userId, String deviceNumber, final Handler handler) { |
901 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...", | 958 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取子账户信息...", |
902 | false, true, null); | 959 | false, true, null); |
903 | 960 | ||
904 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); | 961 | Log.e("test", "ID" + userId + "deviceNumber" + deviceNumber); |
905 | HttpClient.getInstance().setTimeout(5 * 1000); | 962 | HttpClient.getInstance().setTimeout(5 * 1000); |
906 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 963 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
907 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { | 964 | HttpClient.getInstance().get(HttpUrl.childUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber, new AsyncHttpResponseHandler() { |
908 | @Override | 965 | @Override |
909 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 966 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
910 | closeProgress(); | 967 | closeProgress(); |
911 | Log.e("test", "子账户信息" + new String(arg2)); | 968 | Log.e("test", "子账户信息" + new String(arg2)); |
912 | try { | 969 | try { |
913 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 970 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
914 | int status = jsonObject.optInt("status"); | 971 | int status = jsonObject.optInt("status"); |
915 | if (status == 1) { | 972 | if (status == 1) { |
916 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 973 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
917 | Log.e("test", "子账户信息" + childsInfo); | 974 | Log.e("test", "子账户信息" + childsInfo); |
918 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 975 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
919 | Log.e("test", "子账户信息" + schoolInfoBeanList); | 976 | Log.e("test", "子账户信息" + schoolInfoBeanList); |
920 | Message msg = Message.obtain(); | 977 | Message msg = Message.obtain(); |
921 | msg.what = HttpCode.CHILDS_SUCESS; | 978 | msg.what = HttpCode.CHILDS_SUCESS; |
922 | msg.obj = schoolInfoBeanList; | 979 | msg.obj = schoolInfoBeanList; |
923 | handler.sendMessage(msg); | 980 | handler.sendMessage(msg); |
924 | 981 | ||
925 | }else { | 982 | } else { |
926 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 983 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
927 | 984 | ||
928 | } | 985 | } |
929 | } catch (JSONException e) { | 986 | } catch (JSONException e) { |
930 | e.printStackTrace(); | 987 | e.printStackTrace(); |
931 | 988 | ||
932 | } | 989 | } |
933 | 990 | ||
934 | } | 991 | } |
935 | 992 | ||
936 | @Override | 993 | @Override |
937 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 994 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
938 | closeProgress(); | 995 | closeProgress(); |
939 | // Log.e("test", "错误信息" + new String(arg2)); | 996 | // Log.e("test", "错误信息" + new String(arg2)); |
940 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 997 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
941 | } | 998 | } |
942 | }); | 999 | }); |
943 | 1000 | ||
944 | } | 1001 | } |
945 | 1002 | ||
946 | /** | 1003 | /** |
947 | * 删除子账户信息 | 1004 | * 删除子账户信息 |
948 | * | 1005 | * |
949 | * @param mContext | 1006 | * @param mContext |
950 | * @param subAccountId | 1007 | * @param subAccountId |
951 | */ | 1008 | */ |
952 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { | 1009 | public void deletechildAccountinfo(final Context mContext, String subAccountId) { |
953 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 1010 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
954 | false, true, null); | 1011 | false, true, null); |
955 | HttpClient.getInstance().setTimeout(5 * 1000); | 1012 | HttpClient.getInstance().setTimeout(5 * 1000); |
956 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1013 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
957 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { | 1014 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL + "?subAccountId=" + subAccountId, new AsyncHttpResponseHandler() { |
958 | @Override | 1015 | @Override |
959 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1016 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
960 | closeProgress(); | 1017 | closeProgress(); |
961 | Log.e("test", "子账户信息" + new String(arg2)); | 1018 | Log.e("test", "子账户信息" + new String(arg2)); |
962 | try { | 1019 | try { |
963 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1020 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
964 | int status = jsonObject.optInt("status"); | 1021 | int status = jsonObject.optInt("status"); |
965 | if (status == 1) { | 1022 | if (status == 1) { |
966 | AlertUtils.showToast(mContext, "子账号删除成功!"); | 1023 | AlertUtils.showToast(mContext, "子账号删除成功!"); |
967 | ((Activity) mContext).finish(); | 1024 | ((Activity) mContext).finish(); |
968 | } else { | 1025 | } else { |
969 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); | 1026 | AlertUtils.showToast(mContext, "你好,子账号删除失败!"); |
970 | 1027 | ||
971 | } | 1028 | } |
972 | } catch (JSONException e) { | 1029 | } catch (JSONException e) { |
973 | e.printStackTrace(); | 1030 | e.printStackTrace(); |
974 | } | 1031 | } |
975 | 1032 | ||
976 | } | 1033 | } |
977 | 1034 | ||
978 | @Override | 1035 | @Override |
979 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1036 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
980 | closeProgress(); | 1037 | closeProgress(); |
981 | Log.e("test", "错误信息" + new String(arg2)); | 1038 | Log.e("test", "错误信息" + new String(arg2)); |
982 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1039 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
983 | } | 1040 | } |
984 | }); | 1041 | }); |
985 | 1042 | ||
986 | } | 1043 | } |
987 | 1044 | ||
988 | /** | 1045 | /** |
989 | * 添加子账户信息 | 1046 | * 添加子账户信息 |
990 | */ | 1047 | */ |
991 | public void addchildAccountinfo(final Context mContext, long parentId, String image, | 1048 | public void addchildAccountinfo(final Context mContext, long parentId, String image, |
992 | String name, final Long grade, Object school, Long region | 1049 | String name, final Long grade, Object school, Long region |
993 | , String deviceNumber, String regionName) { | 1050 | , String deviceNumber, String regionName) { |
994 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 1051 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
995 | false, true, null); | 1052 | false, true, null); |
996 | RequestParams params = new RequestParams(); | 1053 | RequestParams params = new RequestParams(); |
997 | 1054 | ||
998 | params.put(HttpKey.PARENTID, parentId); | 1055 | params.put(HttpKey.PARENTID, parentId); |
999 | params.put(HttpKey.IMAGE, image); | 1056 | params.put(HttpKey.IMAGE, image); |
1000 | params.put(HttpKey.NAME, name); | 1057 | params.put(HttpKey.NAME, name); |
1001 | params.put(HttpKey.GRADE, grade); | 1058 | params.put(HttpKey.GRADE, grade); |
1002 | params.put(HttpKey.SCHOOL, school); | 1059 | params.put(HttpKey.SCHOOL, school); |
1003 | params.put(HttpKey.REGION, region); | 1060 | params.put(HttpKey.REGION, region); |
1004 | params.put(HttpKey.DEVINUMBER, deviceNumber); | 1061 | params.put(HttpKey.DEVINUMBER, deviceNumber); |
1005 | params.put(HttpKey.REGIONNAME, regionName); | 1062 | params.put(HttpKey.REGIONNAME, regionName); |
1006 | 1063 | ||
1007 | Log.e("test", "子账户信息" + params); | 1064 | Log.e("test", "子账户信息" + params); |
1008 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 1065 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
1009 | HttpClient.getInstance().setTimeout(5 * 1000); | 1066 | HttpClient.getInstance().setTimeout(5 * 1000); |
1010 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1067 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1011 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { | 1068 | HttpClient.getInstance().post(HttpUrl.addchildUserURL, params, new AsyncHttpResponseHandler() { |
1012 | @Override | 1069 | @Override |
1013 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1070 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1014 | closeProgress(); | 1071 | closeProgress(); |
1015 | 1072 | ||
1016 | Log.e("test", "子账户信息" + new String(arg2)); | 1073 | Log.e("test", "子账户信息" + new String(arg2)); |
1017 | try { | 1074 | try { |
1018 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1075 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1019 | int status = jsonObject.optInt("status"); | 1076 | int status = jsonObject.optInt("status"); |
1020 | if (status == 1) { | 1077 | if (status == 1) { |
1021 | AlertUtils.showToast(mContext, "子账号添加成功!"); | 1078 | AlertUtils.showToast(mContext, "子账号添加成功!"); |
1022 | ((Activity) mContext).finish(); | 1079 | ((Activity) mContext).finish(); |
1023 | } else { | 1080 | } else { |
1024 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); | 1081 | AlertUtils.showToast(mContext, "你好,子账号添加失败!"); |
1025 | 1082 | ||
1026 | } | 1083 | } |
1027 | } catch (JSONException e) { | 1084 | } catch (JSONException e) { |
1028 | e.printStackTrace(); | 1085 | e.printStackTrace(); |
1029 | } | 1086 | } |
1030 | 1087 | ||
1031 | } | 1088 | } |
1032 | 1089 | ||
1033 | @Override | 1090 | @Override |
1034 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1091 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1035 | closeProgress(); | 1092 | closeProgress(); |
1036 | Log.e("test", "错误信息" + new String(arg2)); | 1093 | Log.e("test", "错误信息" + new String(arg2)); |
1037 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1094 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1038 | } | 1095 | } |
1039 | }); | 1096 | }); |
1040 | 1097 | ||
1041 | } | 1098 | } |
1042 | 1099 | ||
1043 | /** | 1100 | /** |
1044 | * 切换子账户信息 | 1101 | * 切换子账户信息 |
1045 | * | 1102 | * |
1046 | * @param mContext | 1103 | * @param mContext |
1047 | * @param subAccountId | 1104 | * @param subAccountId |
1048 | */ | 1105 | */ |
1049 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId | 1106 | public void changechildAccountinfo(final Context mContext, String subAccountId, long userId |
1050 | , String deviceNumber, int type) { | 1107 | , String deviceNumber, int type) { |
1051 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1108 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
1052 | false, true, null); | 1109 | false, true, null); |
1053 | HttpClient.getInstance().setTimeout(5 * 1000); | 1110 | HttpClient.getInstance().setTimeout(5 * 1000); |
1054 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1111 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1055 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId | 1112 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?subAccountId=" + subAccountId + "&userId=" + userId |
1056 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { | 1113 | + "&deviceNumber=" + deviceNumber + "&type=" + type, new AsyncHttpResponseHandler() { |
1057 | @Override | 1114 | @Override |
1058 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1115 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1059 | closeProgress(); | 1116 | closeProgress(); |
1060 | Log.e("test", "子账户信息" + new String(arg2)); | 1117 | Log.e("test", "子账户信息" + new String(arg2)); |
1061 | try { | 1118 | try { |
1062 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1119 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1063 | int status = jsonObject.optInt("status"); | 1120 | int status = jsonObject.optInt("status"); |
1064 | if (status == 1) { | 1121 | if (status == 1) { |
1065 | AlertUtils.showToast(mContext, "子账号切换成功!"); | 1122 | AlertUtils.showToast(mContext, "子账号切换成功!"); |
1066 | ((Activity) mContext).finish(); | 1123 | ((Activity) mContext).finish(); |
1067 | 1124 | ||
1068 | } else { | 1125 | } else { |
1069 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); | 1126 | AlertUtils.showToast(mContext, "你好,子账号切换失败!"); |
1070 | 1127 | ||
1071 | } | 1128 | } |
1072 | } catch (JSONException e) { | 1129 | } catch (JSONException e) { |
1073 | e.printStackTrace(); | 1130 | e.printStackTrace(); |
1074 | } | 1131 | } |
1075 | 1132 | ||
1076 | } | 1133 | } |
1077 | 1134 | ||
1078 | @Override | 1135 | @Override |
1079 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1136 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1080 | closeProgress(); | 1137 | closeProgress(); |
1081 | Log.e("test", "错误信息" + new String(arg2)); | 1138 | Log.e("test", "错误信息" + new String(arg2)); |
1082 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1139 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1083 | } | 1140 | } |
1084 | }); | 1141 | }); |
1085 | 1142 | ||
1086 | } | 1143 | } |
1087 | 1144 | ||
1088 | /** | 1145 | /** |
1089 | * 切换主账户信息 | 1146 | * 切换主账户信息 |
1090 | * | 1147 | * |
1091 | * @param mContext | 1148 | * @param mContext |
1092 | * @param type | 1149 | * @param type |
1093 | */ | 1150 | */ |
1094 | public void Accountinfo(final Context mContext, long userId | 1151 | public void Accountinfo(final Context mContext, long userId |
1095 | , String deviceNumber, int type) { | 1152 | , String deviceNumber, int type) { |
1096 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", | 1153 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换主账户...", |
1097 | false, true, null); | 1154 | false, true, null); |
1098 | HttpClient.getInstance().setTimeout(5 * 1000); | 1155 | HttpClient.getInstance().setTimeout(5 * 1000); |
1099 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1156 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1100 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber | 1157 | HttpClient.getInstance().get(HttpUrl.changechildUserURL + "?userId=" + userId + "&deviceNumber=" + deviceNumber |
1101 | + "&type=" + type, new AsyncHttpResponseHandler() { | 1158 | + "&type=" + type, new AsyncHttpResponseHandler() { |
1102 | @Override | 1159 | @Override |
1103 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1160 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1104 | closeProgress(); | 1161 | closeProgress(); |
1105 | Log.e("test", "子账户信息" + new String(arg2)); | 1162 | Log.e("test", "子账户信息" + new String(arg2)); |
1106 | try { | 1163 | try { |
1107 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1164 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1108 | int status = jsonObject.optInt("status"); | 1165 | int status = jsonObject.optInt("status"); |
1109 | if (status == 1) { | 1166 | if (status == 1) { |
1110 | AlertUtils.showToast(mContext, "主账号切换成功!"); | 1167 | AlertUtils.showToast(mContext, "主账号切换成功!"); |
1111 | ((Activity) mContext).finish(); | 1168 | ((Activity) mContext).finish(); |
1112 | 1169 | ||
1113 | } else { | 1170 | } else { |
1114 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); | 1171 | AlertUtils.showToast(mContext, "你好,主账号切换失败!"); |
1115 | 1172 | ||
1116 | } | 1173 | } |
1117 | } catch (JSONException e) { | 1174 | } catch (JSONException e) { |
1118 | e.printStackTrace(); | 1175 | e.printStackTrace(); |
1119 | } | 1176 | } |
1120 | 1177 | ||
1121 | } | 1178 | } |
1122 | 1179 | ||
1123 | @Override | 1180 | @Override |
1124 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1181 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1125 | closeProgress(); | 1182 | closeProgress(); |
1126 | Log.e("test", "错误信息" + new String(arg2)); | 1183 | Log.e("test", "错误信息" + new String(arg2)); |
1127 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1184 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1128 | } | 1185 | } |
1129 | }); | 1186 | }); |
1130 | 1187 | ||
1131 | } | 1188 | } |
1132 | 1189 | ||
1133 | /** | 1190 | /** |
1134 | * 头像拍张 | 1191 | * 头像拍张 |
1135 | * | 1192 | * |
1136 | * @param mContext | 1193 | * @param mContext |
1137 | * @param userId | 1194 | * @param userId |
1138 | * @param img | 1195 | * @param img |
1139 | * @throws UnsupportedEncodingException | 1196 | * @throws UnsupportedEncodingException |
1140 | */ | 1197 | */ |
1141 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { | 1198 | public void header(final Context mContext, String userId, String type, String img) throws UnsupportedEncodingException { |
1142 | File file = new File(img); | 1199 | File file = new File(img); |
1143 | if (file.exists() && file.length() > 0) { | 1200 | if (file.exists() && file.length() > 0) { |
1144 | RequestParams params = new RequestParams(); | 1201 | RequestParams params = new RequestParams(); |
1145 | try { | 1202 | try { |
1146 | params.put("userId", userId); | 1203 | params.put("userId", userId); |
1147 | params.put("type", type); | 1204 | params.put("type", type); |
1148 | params.put("img", file); | 1205 | params.put("img", file); |
1149 | } catch (FileNotFoundException e) { | 1206 | } catch (FileNotFoundException e) { |
1150 | e.printStackTrace(); | 1207 | e.printStackTrace(); |
1151 | } | 1208 | } |
1152 | Log.e("test", "params" + params); | 1209 | Log.e("test", "params" + params); |
1153 | HttpClient.getInstance().setTimeout(5 * 1000); | 1210 | HttpClient.getInstance().setTimeout(5 * 1000); |
1154 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { | 1211 | HttpClient.getInstance().post(HttpUrl.headerURL, params, new AsyncHttpResponseHandler() { |
1155 | @Override | 1212 | @Override |
1156 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1213 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1157 | Log.e("test", "onSuccess" + new String(bytes)); | 1214 | Log.e("test", "onSuccess" + new String(bytes)); |
1158 | try { | 1215 | try { |
1159 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1216 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1160 | String status = jsonObject.optString("status"); | 1217 | String status = jsonObject.optString("status"); |
1161 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1218 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); |
1162 | String imagUrl = jsonObject1.optString("imgUrl"); | 1219 | String imagUrl = jsonObject1.optString("imgUrl"); |
1163 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1220 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); |
1164 | if (status.equals("1")) { | 1221 | if (status.equals("1")) { |
1165 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1222 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1166 | } else { | 1223 | } else { |
1167 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1224 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1168 | } | 1225 | } |
1169 | } catch (JSONException e) { | 1226 | } catch (JSONException e) { |
1170 | e.printStackTrace(); | 1227 | e.printStackTrace(); |
1171 | } | 1228 | } |
1172 | } | 1229 | } |
1173 | 1230 | ||
1174 | @Override | 1231 | @Override |
1175 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1232 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1176 | closeProgress(); | 1233 | closeProgress(); |
1177 | Log.e("test", "错误信息" + new String(bytes)); | 1234 | Log.e("test", "错误信息" + new String(bytes)); |
1178 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1235 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1179 | 1236 | ||
1180 | } | 1237 | } |
1181 | }); | 1238 | }); |
1182 | } else { | 1239 | } else { |
1183 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); | 1240 | Toast.makeText(mContext, "文件不存在", Toast.LENGTH_LONG).show(); |
1184 | } | 1241 | } |
1185 | } | 1242 | } |
1243 | |||
1186 | /** | 1244 | /** |
1187 | * 头像默认 | 1245 | * 头像默认 |
1188 | * | 1246 | * |
1189 | * @param mContext | 1247 | * @param mContext |
1190 | * @param userId | 1248 | * @param userId |
1191 | * @param | 1249 | * @param |
1192 | * @throws UnsupportedEncodingException | 1250 | * @throws UnsupportedEncodingException |
1193 | */ | 1251 | */ |
1194 | public void headerdeft(final Context mContext, String userId, String type,String defaultImg) throws UnsupportedEncodingException { | 1252 | public void headerdeft(final Context mContext, String userId, String type, String defaultImg) throws UnsupportedEncodingException { |
1195 | RequestParams params = new RequestParams(); | 1253 | RequestParams params = new RequestParams(); |
1196 | params.put("userId", userId); | 1254 | params.put("userId", userId); |
1197 | params.put("type", type); | 1255 | params.put("type", type); |
1198 | params.put("defaultImg", defaultImg); | 1256 | params.put("defaultImg", defaultImg); |
1199 | Log.e("test", "params" + params); | 1257 | Log.e("test", "params" + params); |
1200 | HttpClient.getInstance().setTimeout(5 * 1000); | 1258 | HttpClient.getInstance().setTimeout(5 * 1000); |
1201 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { | 1259 | HttpClient.getInstance().post(HttpUrl.headerdefaultURL, params, new AsyncHttpResponseHandler() { |
1202 | @Override | 1260 | @Override |
1203 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 1261 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
1204 | Log.e("test", "onSuccess" + new String(bytes)); | 1262 | Log.e("test", "onSuccess" + new String(bytes)); |
1205 | try { | 1263 | try { |
1206 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 1264 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
1207 | String status = jsonObject.optString("status"); | 1265 | String status = jsonObject.optString("status"); |
1208 | JSONObject jsonObject1 =jsonObject.getJSONObject("data"); | 1266 | JSONObject jsonObject1 = jsonObject.getJSONObject("data"); |
1209 | String imagUrl = jsonObject1.optString("imgUrl"); | 1267 | String imagUrl = jsonObject1.optString("imgUrl"); |
1210 | SaveParam.getInstance().saveLoginParam(mContext,SaveParam.HEADURL,imagUrl); | 1268 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.HEADURL, imagUrl); |
1211 | if (status.equals("1")) { | 1269 | if (status.equals("1")) { |
1212 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); | 1270 | Toast.makeText(mContext, "头像上传成功。", Toast.LENGTH_LONG).show(); |
1213 | } else { | 1271 | } else { |
1214 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); | 1272 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试"); |
1215 | } | ||
1216 | } catch (JSONException e) { | ||
1217 | e.printStackTrace(); | ||
1218 | } | 1273 | } |
1274 | } catch (JSONException e) { | ||
1275 | e.printStackTrace(); | ||
1219 | } | 1276 | } |
1277 | } | ||
1220 | 1278 | ||
1221 | @Override | 1279 | @Override |
1222 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 1280 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
1223 | closeProgress(); | 1281 | closeProgress(); |
1224 | Log.e("test", "错误信息" + new String(bytes)); | 1282 | Log.e("test", "错误信息" + new String(bytes)); |
1225 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1283 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1226 | 1284 | ||
1227 | } | 1285 | } |
1228 | }); | 1286 | }); |
1229 | } | 1287 | } |
1230 | 1288 | ||
1231 | /** | 1289 | /** |
1232 | * 检查注册信息是否完整 | 1290 | * 检查注册信息是否完整 |
1291 | * | ||
1233 | * @param mContext | 1292 | * @param mContext |
1234 | * @param userId | 1293 | * @param userId |
1235 | */ | 1294 | */ |
1236 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { | 1295 | public void registerinfocheck(final Context mContext, long userId, final Handler handler) { |
1237 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", | 1296 | mProgress = DialogPermission.showProgress(mContext, null, "正在检查注册信息是否完整...", |
1238 | false, true, null); | 1297 | false, true, null); |
1239 | HttpClient.getInstance().setTimeout(5 * 1000); | 1298 | HttpClient.getInstance().setTimeout(5 * 1000); |
1240 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1299 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1241 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId , new AsyncHttpResponseHandler() { | 1300 | HttpClient.getInstance().get(HttpUrl.isRegisterInfoCompleteURL + "?userId=" + userId, new AsyncHttpResponseHandler() { |
1242 | @Override | 1301 | @Override |
1243 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1302 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1244 | closeProgress(); | 1303 | closeProgress(); |
1245 | Log.e("test", "注册信息" + new String(arg2)); | 1304 | Log.e("test", "注册信息" + new String(arg2)); |
1246 | Message msg = Message.obtain(); | 1305 | Message msg = Message.obtain(); |
1247 | msg.what = HttpCode.REGISTER_SUCESS; | 1306 | msg.what = HttpCode.REGISTER_SUCESS; |
1248 | msg.obj = new String(arg2); | 1307 | msg.obj = new String(arg2); |
1249 | handler.sendMessage(msg); | 1308 | handler.sendMessage(msg); |
1250 | 1309 | ||
1251 | } | 1310 | } |
1252 | 1311 | ||
1253 | @Override | 1312 | @Override |
1254 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1313 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1255 | closeProgress(); | 1314 | closeProgress(); |
1256 | // Log.e("test", "错误信息" + new String(arg2)); | 1315 | // Log.e("test", "错误信息" + new String(arg2)); |
1257 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1316 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1258 | 1317 | ||
1259 | } | 1318 | } |
1260 | }); | 1319 | }); |
1261 | 1320 | ||
1262 | } | 1321 | } |
1322 | |||
1263 | /** | 1323 | /** |
1264 | * 获取最近学习视频 | 1324 | * 获取最近学习视频 |
1325 | * | ||
1265 | * @param mContext | 1326 | * @param mContext |
1266 | * @param userId | 1327 | * @param userId |
1267 | */ | 1328 | */ |
1268 | public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { | 1329 | public void getstuyvidioinfo(final Context mContext, long userId, final Handler handler) { |
1269 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", | 1330 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取最近学习视频...", |
1270 | false, true, null); | 1331 | false, true, null); |
1271 | HttpClient.getInstance().setTimeout(5 * 1000); | 1332 | HttpClient.getInstance().setTimeout(5 * 1000); |
1272 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1333 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1273 | HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId , new AsyncHttpResponseHandler() { | 1334 | HttpClient.getInstance().get(HttpUrl.getvidioURL + "?userId=" + userId, new AsyncHttpResponseHandler() { |
1274 | @Override | 1335 | @Override |
1275 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1336 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1276 | closeProgress(); | 1337 | closeProgress(); |
1277 | Log.e("test", "近学习视频" + new String(arg2)); | 1338 | Log.e("test", "近学习视频" + new String(arg2)); |
1278 | try { | 1339 | try { |
1279 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1340 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1280 | int status = jsonObject.optInt("status"); | 1341 | int status = jsonObject.optInt("status"); |
1281 | if (status == 1) { | 1342 | if (status == 1) { |
1282 | VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 | 1343 | VideoInfo videoInfo = GsonTool.getPerson(new String(arg2), VideoInfo.class);//解析json数据 |
1283 | List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); | 1344 | List<VideoInfo.DataBean> schoolInfoBeanList = videoInfo.getData(); |
1284 | Message msg = Message.obtain(); | 1345 | Message msg = Message.obtain(); |
1285 | msg.what = HttpCode.GETVIDIO_SUCESS; | 1346 | msg.what = HttpCode.GETVIDIO_SUCESS; |
1286 | msg.obj = schoolInfoBeanList; | 1347 | msg.obj = schoolInfoBeanList; |
1287 | handler.sendMessage(msg); | 1348 | handler.sendMessage(msg); |
1288 | 1349 | ||
1289 | }else { | 1350 | } else { |
1290 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); | 1351 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后再试!"); |
1291 | 1352 | ||
1292 | } | 1353 | } |
1293 | } catch (JSONException e) { | 1354 | } catch (JSONException e) { |
1294 | e.printStackTrace(); | 1355 | e.printStackTrace(); |
1295 | 1356 | ||
1296 | } | 1357 | } |
1297 | 1358 | ||
1298 | } | 1359 | } |
1299 | 1360 | ||
1300 | @Override | 1361 | @Override |
1301 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1362 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1302 | closeProgress(); | 1363 | closeProgress(); |
1303 | // Log.e("test", "错误信息" + new String(arg2)); | 1364 | // Log.e("test", "错误信息" + new String(arg2)); |
1304 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1365 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1305 | 1366 | ||
1306 | } | 1367 | } |
1307 | }); | 1368 | }); |
1308 | 1369 | ||
1309 | } | 1370 | } |
1310 | 1371 | ||
1311 | 1372 | ||
1312 | /** | 1373 | /** |
1313 | * 系统升级 | 1374 | * 系统升级 |
1314 | * | 1375 | * |
1315 | * @param mContext | 1376 | * @param mContext |
1316 | * @param pid appName | 1377 | * @param pid appName |
1317 | */ | 1378 | */ |
1318 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { | 1379 | public void updateAPP(final Context mContext, String pid, String appName, final Handler handler) { |
1319 | mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", | 1380 | mProgress = DialogPermission.showProgress(mContext, null, "正在检测是否升级版本...", |
1320 | false, true, null); | 1381 | false, true, null); |
1321 | HttpClient.getInstance().setTimeout(5 * 1000); | 1382 | HttpClient.getInstance().setTimeout(5 * 1000); |
1322 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1383 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1323 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { | 1384 | HttpClient.getInstance().get(HttpUrl.updateappURL + "?pid=" + pid + "&appName=" + appName, new AsyncHttpResponseHandler() { |
1324 | @Override | 1385 | @Override |
1325 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1386 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1326 | closeProgress(); | 1387 | closeProgress(); |
1327 | Log.e("test", "版本升级信息" + new String(arg2)); | 1388 | Log.e("test", "版本升级信息" + new String(arg2)); |
1328 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | 1389 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 |
1329 | Message msg = Message.obtain(); | 1390 | Message msg = Message.obtain(); |
1330 | msg.what = HttpCode.APPUPDATE_SUCESS; | 1391 | msg.what = HttpCode.APPUPDATE_SUCESS; |
1331 | msg.obj = appVersion; | 1392 | msg.obj = appVersion; |
1332 | handler.sendMessage(msg); | 1393 | handler.sendMessage(msg); |
1333 | 1394 | ||
1334 | 1395 | ||
1335 | } | 1396 | } |
1336 | 1397 | ||
1337 | @Override | 1398 | @Override |
1338 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1399 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1339 | closeProgress(); | 1400 | closeProgress(); |
1340 | Log.e("test", "错误信息" + new String(arg2)); | 1401 | Log.e("test", "错误信息" + new String(arg2)); |
1341 | } | 1402 | } |
1342 | }); | 1403 | }); |
1343 | 1404 | ||
1344 | } | 1405 | } |
1406 | |||
1345 | //版本信息 | 1407 | //版本信息 |
1346 | public void versioninfo(final Context mContext,String subjectName, final Handler handler) { | 1408 | public void versioninfo(final Context mContext, String subjectName, final Handler handler) { |
1347 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1409 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1348 | HttpClient.getInstance().get(HttpUrl.getversionURL+"?subjectName="+subjectName, new AsyncHttpResponseHandler() { | 1410 | HttpClient.getInstance().get(HttpUrl.getversionURL + "?subjectName=" + subjectName, new AsyncHttpResponseHandler() { |
1349 | @Override | 1411 | @Override |
1350 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1412 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1351 | Log.e("test", "版本信息" + new String(arg2)); | 1413 | Log.e("test", "版本信息" + new String(arg2)); |
1352 | try { | 1414 | try { |
1353 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1415 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1354 | int status = jsonObject.optInt("status"); | 1416 | int status = jsonObject.optInt("status"); |
1355 | if (status == 1) { | 1417 | if (status == 1) { |
1356 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 | 1418 | VersionInfo versionInfo = GsonTool.getPerson(new String(arg2), VersionInfo.class);//解析json数据 |
1357 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); | 1419 | List<VersionInfo.DataBean> versionInfoList = versionInfo.getData(); |
1358 | Message message = Message.obtain(); | 1420 | Message message = Message.obtain(); |
1359 | message.what = HttpCode.VERSION_SUCESS; | 1421 | message.what = HttpCode.VERSION_SUCESS; |
1360 | message.obj = versionInfoList; | 1422 | message.obj = versionInfoList; |
1361 | handler.sendMessage(message); | 1423 | handler.sendMessage(message); |
1362 | 1424 | ||
1363 | } else if(status == 1000){ | 1425 | } else if (status == 1000) { |
1364 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); | 1426 | AlertUtils.showToast(mContext, "你好,该科目没有版本信息"); |
1365 | 1427 | ||
1366 | }else { | 1428 | } else { |
1367 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1429 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1368 | } | 1430 | } |
1369 | } catch (JSONException e) { | 1431 | } catch (JSONException e) { |
1370 | e.printStackTrace(); | 1432 | e.printStackTrace(); |
1371 | } | 1433 | } |
1372 | 1434 | ||
1373 | 1435 | ||
1374 | } | 1436 | } |
1375 | 1437 | ||
1376 | @Override | 1438 | @Override |
1377 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1439 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1378 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1440 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1379 | } | 1441 | } |
1380 | }); | 1442 | }); |
1381 | } | 1443 | } |
1382 | 1444 | ||
1383 | 1445 | ||
1384 | |||
1385 | |||
1386 | |||
1387 | |||
1388 | ///省级接口 | 1446 | ///省级接口 |
1389 | public void provices(final Context mContext, final Handler handler) { | 1447 | public void provices(final Context mContext, final Handler handler) { |
1390 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1448 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1391 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1449 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
1392 | @Override | 1450 | @Override |
1393 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1451 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1394 | Log.e("test", "省" + new String(arg2)); | 1452 | Log.e("test", "省" + new String(arg2)); |
1395 | try { | 1453 | try { |
1396 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1454 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1397 | int status = jsonObject.optInt("status"); | 1455 | int status = jsonObject.optInt("status"); |
1398 | if (status == 100) { | 1456 | if (status == 100) { |
1399 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1457 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
1400 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1458 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
1401 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1459 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
1402 | Message message = Message.obtain(); | 1460 | Message message = Message.obtain(); |
1403 | message.what = HttpCode.PROVICES; | 1461 | message.what = HttpCode.PROVICES; |
1404 | message.obj = provincesBeanList; | 1462 | message.obj = provincesBeanList; |
1405 | handler.sendMessage(message); | 1463 | handler.sendMessage(message); |
1406 | 1464 | ||
1407 | 1465 | ||
1408 | } else { | 1466 | } else { |
1409 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1467 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1410 | 1468 | ||
1411 | } | 1469 | } |
1412 | } catch (JSONException e) { | 1470 | } catch (JSONException e) { |
1413 | e.printStackTrace(); | 1471 | e.printStackTrace(); |
1414 | } | 1472 | } |
1415 | 1473 | ||
1416 | 1474 | ||
1417 | } | 1475 | } |
1418 | 1476 | ||
1419 | @Override | 1477 | @Override |
1420 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1478 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1421 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1479 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1422 | } | 1480 | } |
1423 | }); | 1481 | }); |
1424 | } | 1482 | } |
1483 | |||
1425 | //获取版本信息接口 | 1484 | //获取版本信息接口 |
1426 | public void getpublishinfo(final Context mContext, Object userId,int gradeId, int type,final Handler handler) { | 1485 | public void getpublishinfo(final Context mContext, Object userId, int gradeId, int type, final Handler handler) { |
1427 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1486 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1428 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId+ "&gradeId=" + gradeId+ "&type=" + type, new AsyncHttpResponseHandler() { | 1487 | HttpClient.getInstance().get(HttpUrl.getpublishURL + "?userId=" + userId + "&gradeId=" + gradeId + "&type=" + type, new AsyncHttpResponseHandler() { |
1429 | @Override | 1488 | @Override |
1430 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1489 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1431 | Log.e("test", "获取版本信息接口" + new String(arg2)); | 1490 | Log.e("test", "获取版本信息接口" + new String(arg2)); |
1432 | try { | 1491 | try { |
1433 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1492 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1434 | int status = jsonObject.optInt("status"); | 1493 | int status = jsonObject.optInt("status"); |
1435 | if (status == 1) { | 1494 | if (status == 1) { |
1436 | Gson gson = new Gson(); | 1495 | Gson gson = new Gson(); |
1437 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); | 1496 | DefautPublishInfo defautPublishInfo = gson.fromJson(new String(arg2), DefautPublishInfo.class); |
1438 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); | 1497 | List<DefautPublishInfo.DataBean> defautPublishInfoBeanList = defautPublishInfo.getData(); |
1439 | Message message = Message.obtain(); | 1498 | Message message = Message.obtain(); |
1440 | message.what = HttpCode.PUBLISH_SUCESS; | 1499 | message.what = HttpCode.PUBLISH_SUCESS; |
1441 | message.obj = defautPublishInfoBeanList; | 1500 | message.obj = defautPublishInfoBeanList; |
1442 | handler.sendMessage(message); | 1501 | handler.sendMessage(message); |
1443 | 1502 | ||
1444 | } else { | 1503 | } else { |
1445 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1504 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1446 | 1505 | ||
1447 | } | 1506 | } |
1448 | } catch (JSONException e) { | 1507 | } catch (JSONException e) { |
1449 | e.printStackTrace(); | 1508 | e.printStackTrace(); |
1450 | } | 1509 | } |
1451 | 1510 | ||
1452 | 1511 | ||
1453 | } | 1512 | } |
1454 | 1513 | ||
1455 | @Override | 1514 | @Override |
1456 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1515 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1457 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1516 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1458 | } | 1517 | } |
1459 | }); | 1518 | }); |
1460 | } | 1519 | } |
1461 | 1520 | ||
1462 | 1521 | ||
1463 | //市级接口 | 1522 | //市级接口 |
1464 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { | 1523 | public void cityinfo(final Context mContext, long regionId, final Handler handler) { |
1465 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1524 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1466 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1525 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
1467 | @Override | 1526 | @Override |
1468 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1527 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1469 | Log.e("test", "市" + new String(arg2)); | 1528 | Log.e("test", "市" + new String(arg2)); |
1470 | try { | 1529 | try { |
1471 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1530 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1472 | int status = jsonObject.optInt("status"); | 1531 | int status = jsonObject.optInt("status"); |
1473 | if (status == 100) { | 1532 | if (status == 100) { |
1474 | Gson gson = new Gson(); | 1533 | Gson gson = new Gson(); |
1475 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1534 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
1476 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1535 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
1477 | Message message = Message.obtain(); | 1536 | Message message = Message.obtain(); |
1478 | message.what = HttpCode.CITYS; | 1537 | message.what = HttpCode.CITYS; |
1479 | message.obj = cityInfoBeanList; | 1538 | message.obj = cityInfoBeanList; |
1480 | handler.sendMessage(message); | 1539 | handler.sendMessage(message); |
1481 | 1540 | ||
1482 | } else { | 1541 | } else { |
1483 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1542 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1484 | 1543 | ||
1485 | } | 1544 | } |
1486 | } catch (JSONException e) { | 1545 | } catch (JSONException e) { |
1487 | e.printStackTrace(); | 1546 | e.printStackTrace(); |
1488 | } | 1547 | } |
1489 | 1548 | ||
1490 | 1549 | ||
1491 | } | 1550 | } |
1492 | 1551 | ||
1493 | @Override | 1552 | @Override |
1494 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1553 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1495 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1554 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1496 | } | 1555 | } |
1497 | }); | 1556 | }); |
1498 | } | 1557 | } |
1499 | 1558 | ||
1500 | //区县级接口 | 1559 | //区县级接口 |
1501 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1560 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
1502 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1561 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1503 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1562 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
1504 | @Override | 1563 | @Override |
1505 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1564 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1506 | Log.e("test", "区" + new String(arg2)); | 1565 | Log.e("test", "区" + new String(arg2)); |
1507 | try { | 1566 | try { |
1508 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1567 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1509 | int status = jsonObject.optInt("status"); | 1568 | int status = jsonObject.optInt("status"); |
1510 | if (status == 100) { | 1569 | if (status == 100) { |
1511 | Gson gson = new Gson(); | 1570 | Gson gson = new Gson(); |
1512 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1571 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
1513 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1572 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
1514 | Message message = Message.obtain(); | 1573 | Message message = Message.obtain(); |
1515 | message.what = HttpCode.COUNTRY; | 1574 | message.what = HttpCode.COUNTRY; |
1516 | message.obj = countyInfoInfoBeanList; | 1575 | message.obj = countyInfoInfoBeanList; |
1517 | handler.sendMessage(message); | 1576 | handler.sendMessage(message); |
1518 | } else { | 1577 | } else { |
1519 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); | 1578 | AlertUtils.showToast(mContext, "你好,服务器异常,请稍后重试!"); |
1520 | 1579 | ||
1521 | } | 1580 | } |
1522 | } catch (JSONException e) { | 1581 | } catch (JSONException e) { |
1523 | e.printStackTrace(); | 1582 | e.printStackTrace(); |
1524 | } | 1583 | } |
1525 | 1584 | ||
1526 | 1585 | ||
1527 | } | 1586 | } |
1528 | 1587 | ||
1529 | @Override | 1588 | @Override |
1530 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1589 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1531 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); | 1590 | AlertUtils.showToast(mContext, "无法链接到服务器,请检查您的网络或稍后重试!"); |
1532 | } | 1591 | } |
1533 | }); | 1592 | }); |
1534 | } | 1593 | } |
1535 | 1594 | ||
1536 | 1595 | ||
1537 | private void closeProgress() { | 1596 | private void closeProgress() { |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by h on 2017/8/15. | 4 | * Created by h on 2017/8/15. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpUrl { | 7 | public class HttpUrl { |
8 | private final static String Enviroment = "DEVELOPMENT"; | 8 | private final static String Enviroment = "DEVELOPMENT"; |
9 | 9 | ||
10 | public static String GetDomain(){ | 10 | public static String GetDomain(){ |
11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; | 11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; |
12 | } | 12 | } |
13 | 13 | ||
14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 | 14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 |
15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 | 15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 |
16 | public static String gradesUrl = GetDomain()+"/grades";//年级 | 16 | public static String gradesUrl = GetDomain()+"/grades";//年级 |
17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | 17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 |
18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 | 18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 |
19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 | 19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 |
20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | 20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ |
21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | 21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 |
22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | 22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 |
23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | 23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 |
24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | 24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 |
25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 | 25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 |
26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 | 26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 |
27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 | 27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 |
28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 | 28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 |
29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 | 29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 |
30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 | 30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 |
31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 | 31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 |
32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 | 32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 |
33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 | 33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 |
34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 | 34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 |
35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 | 35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 |
36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 | 36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 |
37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 | 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 |
38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 | 38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 |
39 | public static String headerURL=GetDomain()+"/profile/picture/update";//头像上传 | 39 | public static String headerURL=GetDomain()+"/profile/picture/update";//头像上传 |
40 | public static String headerdefaultURL=GetDomain()+"/profile/picture/default";//默认头像上传 | 40 | public static String headerdefaultURL=GetDomain()+"/profile/picture/default";//默认头像上传 |
41 | public static String getversionURL=GetDomain()+"/press/list";//获取版本信息 | 41 | public static String getversionURL=GetDomain()+"/press/list";//获取版本信息 |
42 | public static String isRegisterInfoCompleteURL=GetDomain()+"/register/extrainfo/check";//注册信息是否完整 | 42 | public static String isRegisterInfoCompleteURL=GetDomain()+"/register/extrainfo/check";//注册信息是否完整 |
43 | public static String getpublishURL=GetDomain()+"/userPress/info";//获取版本信息 | 43 | public static String getpublishURL=GetDomain()+"/userPress/info";//获取版本信息 |
44 | public static String getvidioURL=GetDomain()+"/personal/video/recent";//获取最近学习视频 | 44 | public static String getvidioURL=GetDomain()+"/personal/video/recent";//获取最近学习视频 |
45 | public static String submitregisterURL=GetDomain()+"/register/extrainfo/submit";//提交注册信息 | 45 | public static String submitregisterURL=GetDomain()+"/register/extrainfo/submit";//提交注册信息 |
46 | public static String chagepublishURL=GetDomain()+"/userPress/update";//修改版本信息 | 46 | public static String chagepublishURL=GetDomain()+"/userPress/update";//修改版本信息 |
47 | public static String chageaccountphoneURL=GetDomain()+"/electronicCard/updateUserNameByUserId";//修改账户绑定 | ||
47 | 48 | ||
48 | 49 | ||
49 | 50 | ||
50 | 51 | ||
51 | 52 | ||
52 | 53 | ||
53 | } | 54 | } |
54 | 55 |
PersonalCenter/app/src/main/res/layout/activity_account_management.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:fresco="http://schemas.android.com/apk/res-auto" | 3 | xmlns:fresco="http://schemas.android.com/apk/res-auto" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <RelativeLayout | 8 | <RelativeLayout |
9 | android:id="@+id/title" | 9 | android:id="@+id/title" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
12 | android:background="@color/login_text_blue" | 12 | android:background="@color/login_text_blue" |
13 | android:minHeight="50dp"> | 13 | android:minHeight="50dp"> |
14 | 14 | ||
15 | <ImageView | 15 | <ImageView |
16 | android:id="@+id/cancel" | 16 | android:id="@+id/cancel" |
17 | android:layout_width="wrap_content" | 17 | android:layout_width="wrap_content" |
18 | android:layout_height="wrap_content" | 18 | android:layout_height="wrap_content" |
19 | android:layout_centerVertical="true" | 19 | android:layout_centerVertical="true" |
20 | android:paddingLeft="20dp" | 20 | android:paddingLeft="20dp" |
21 | android:paddingRight="20dp" | 21 | android:paddingRight="20dp" |
22 | android:src="@mipmap/title_back" /> | 22 | android:src="@mipmap/title_back" /> |
23 | 23 | ||
24 | <TextView | 24 | <TextView |
25 | android:id="@+id/menu_title" | 25 | android:id="@+id/menu_title" |
26 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
27 | android:layout_height="wrap_content" | 27 | android:layout_height="wrap_content" |
28 | android:layout_centerInParent="true" | 28 | android:layout_centerInParent="true" |
29 | android:text="@string/account_management" | 29 | android:text="@string/account_management" |
30 | android:textColor="@android:color/white" | 30 | android:textColor="@android:color/white" |
31 | android:textSize="22sp" /> | 31 | android:textSize="22sp" /> |
32 | </RelativeLayout> | 32 | </RelativeLayout> |
33 | 33 | ||
34 | <LinearLayout | 34 | <LinearLayout |
35 | android:layout_width="wrap_content" | 35 | android:layout_width="wrap_content" |
36 | android:layout_height="wrap_content" | 36 | android:layout_height="wrap_content" |
37 | android:layout_margin="20dp" | 37 | android:layout_margin="20dp" |
38 | android:gravity="center_vertical" | 38 | android:gravity="center_vertical" |
39 | android:orientation="horizontal"> | 39 | android:orientation="horizontal"> |
40 | 40 | ||
41 | <View | 41 | <View |
42 | android:layout_width="5dp" | 42 | android:layout_width="5dp" |
43 | android:layout_height="20dp" | 43 | android:layout_height="20dp" |
44 | android:background="@color/login_text_blue"> | 44 | android:background="@color/login_text_blue"> |
45 | 45 | ||
46 | </View> | 46 | </View> |
47 | 47 | ||
48 | <TextView | 48 | <TextView |
49 | android:layout_width="wrap_content" | 49 | android:layout_width="wrap_content" |
50 | android:layout_height="wrap_content" | 50 | android:layout_height="wrap_content" |
51 | android:layout_marginLeft="5dp" | 51 | android:layout_marginLeft="5dp" |
52 | android:text="账户安全" | 52 | android:text="账户安全" |
53 | android:textSize="22sp" /> | 53 | android:textSize="22sp" /> |
54 | 54 | ||
55 | </LinearLayout> | 55 | </LinearLayout> |
56 | 56 | ||
57 | <LinearLayout | 57 | <LinearLayout |
58 | android:layout_width="match_parent" | 58 | android:layout_width="match_parent" |
59 | android:layout_height="wrap_content" | 59 | android:layout_height="wrap_content" |
60 | android:layout_marginLeft="60dp" | 60 | android:layout_marginLeft="60dp" |
61 | android:orientation="vertical"> | 61 | android:orientation="vertical"> |
62 | 62 | ||
63 | <LinearLayout | 63 | <LinearLayout |
64 | android:layout_width="match_parent" | 64 | android:layout_width="match_parent" |
65 | android:layout_height="wrap_content"> | 65 | android:layout_height="wrap_content"> |
66 | 66 | ||
67 | 67 | ||
68 | <TextView | 68 | <TextView |
69 | android:layout_width="0dp" | 69 | android:layout_width="0dp" |
70 | android:layout_height="wrap_content" | 70 | android:layout_height="wrap_content" |
71 | android:layout_weight="1.5" | 71 | android:layout_weight="1.5" |
72 | android:text="当前绑定手机号" | 72 | android:text="当前绑定手机号" |
73 | android:textSize="22sp" /> | 73 | android:textSize="22sp" /> |
74 | 74 | ||
75 | <TextView | 75 | <TextView |
76 | android:id="@+id/cunt_username" | 76 | android:id="@+id/cunt_username" |
77 | android:layout_width="0dp" | 77 | android:layout_width="0dp" |
78 | android:layout_height="wrap_content" | 78 | android:layout_height="wrap_content" |
79 | android:layout_marginLeft="50dp" | 79 | android:layout_marginLeft="50dp" |
80 | android:layout_weight="6" | 80 | android:layout_weight="6" |
81 | android:text="" | 81 | android:text="" |
82 | android:textSize="22sp" /> | 82 | android:textSize="22sp" /> |
83 | 83 | ||
84 | <TextView | 84 | <TextView |
85 | android:id="@+id/changBangding" | 85 | android:id="@+id/changBangding" |
86 | android:layout_width="0dp" | 86 | android:layout_width="0dp" |
87 | android:layout_height="wrap_content" | 87 | android:layout_height="wrap_content" |
88 | android:layout_weight="1" | 88 | android:layout_weight="1" |
89 | android:text="更换绑定" | 89 | android:text="更换绑定" |
90 | android:textSize="22sp" /> | 90 | android:textSize="22sp" /> |
91 | 91 | ||
92 | <ImageView | 92 | <ImageView |
93 | android:layout_width="wrap_content" | 93 | android:layout_width="wrap_content" |
94 | android:layout_height="wrap_content" | 94 | android:layout_height="wrap_content" |
95 | android:layout_weight="0.1" | 95 | android:layout_weight="0.1" |
96 | android:padding="10dp" | 96 | android:padding="10dp" |
97 | android:src="@mipmap/youjiantou" /> | 97 | android:src="@mipmap/youjiantou" /> |
98 | </LinearLayout> | 98 | </LinearLayout> |
99 | 99 | ||
100 | <LinearLayout | 100 | <LinearLayout |
101 | android:layout_width="match_parent" | 101 | android:layout_width="match_parent" |
102 | android:layout_height="wrap_content" | 102 | android:layout_height="wrap_content" |
103 | android:layout_marginTop="30dp"> | 103 | android:layout_marginTop="30dp"> |
104 | 104 | ||
105 | 105 | ||
106 | <TextView | 106 | <TextView |
107 | android:layout_width="0dp" | 107 | android:layout_width="0dp" |
108 | android:layout_height="wrap_content" | 108 | android:layout_height="wrap_content" |
109 | android:layout_weight="1.5" | 109 | android:layout_weight="1.5" |
110 | android:text="登录密码" | 110 | android:text="登录密码" |
111 | android:textSize="22sp" /> | 111 | android:textSize="22sp" /> |
112 | 112 | ||
113 | <TextView | 113 | <TextView |
114 | android:layout_width="0dp" | 114 | android:layout_width="0dp" |
115 | android:layout_height="wrap_content" | 115 | android:layout_height="wrap_content" |
116 | android:layout_marginLeft="50dp" | 116 | android:layout_marginLeft="50dp" |
117 | android:layout_weight="6" | 117 | android:layout_weight="6" |
118 | android:text="已设置" | 118 | android:text="已设置" |
119 | android:textSize="22sp" /> | 119 | android:textSize="22sp" /> |
120 | 120 | ||
121 | <TextView | 121 | <TextView |
122 | android:id="@+id/changpassword" | 122 | android:id="@+id/changpassword" |
123 | android:layout_width="0dp" | 123 | android:layout_width="0dp" |
124 | android:layout_height="wrap_content" | 124 | android:layout_height="wrap_content" |
125 | android:layout_weight="1" | 125 | android:layout_weight="1" |
126 | android:text="修改密码" | 126 | android:text="修改密码" |
127 | android:textSize="22sp" /> | 127 | android:textSize="22sp" /> |
128 | 128 | ||
129 | <ImageView | 129 | <ImageView |
130 | android:layout_width="wrap_content" | 130 | android:layout_width="wrap_content" |
131 | android:layout_height="wrap_content" | 131 | android:layout_height="wrap_content" |
132 | android:layout_weight="0.1" | 132 | android:layout_weight="0.1" |
133 | android:padding="10dp" | 133 | android:padding="10dp" |
134 | android:src="@mipmap/youjiantou" /> | 134 | android:src="@mipmap/youjiantou" /> |
135 | </LinearLayout> | 135 | </LinearLayout> |
136 | 136 | ||
137 | </LinearLayout> | 137 | </LinearLayout> |
138 | 138 | ||
139 | <View | 139 | <View |
140 | android:layout_width="match_parent" | 140 | android:layout_width="match_parent" |
141 | android:layout_height="0.7dp" | 141 | android:layout_height="0.7dp" |
142 | android:layout_margin="20dp" | 142 | android:layout_margin="20dp" |
143 | android:background="#FF909090" /> | 143 | android:background="#FF909090" /> |
144 | 144 | ||
145 | <LinearLayout | 145 | <LinearLayout |
146 | android:layout_width="wrap_content" | 146 | android:layout_width="wrap_content" |
147 | android:layout_height="wrap_content" | 147 | android:layout_height="wrap_content" |
148 | android:layout_margin="20dp" | 148 | android:layout_margin="20dp" |
149 | android:gravity="center_vertical" | 149 | android:gravity="center_vertical" |
150 | android:orientation="horizontal"> | 150 | android:orientation="horizontal"> |
151 | 151 | ||
152 | <View | 152 | <View |
153 | android:layout_width="5dp" | 153 | android:layout_width="5dp" |
154 | android:layout_height="20dp" | 154 | android:layout_height="20dp" |
155 | android:background="@color/login_text_blue"> | 155 | android:background="@color/login_text_blue"> |
156 | 156 | ||
157 | </View> | 157 | </View> |
158 | 158 | ||
159 | <TextView | 159 | <TextView |
160 | android:layout_width="wrap_content" | 160 | android:layout_width="wrap_content" |
161 | android:layout_height="wrap_content" | 161 | android:layout_height="wrap_content" |
162 | android:layout_marginLeft="5dp" | 162 | android:layout_marginLeft="5dp" |
163 | android:text="子账户管理" | 163 | android:text="子账户管理" |
164 | android:textSize="22sp" /> | 164 | android:textSize="22sp" /> |
165 | 165 | ||
166 | </LinearLayout> | 166 | </LinearLayout> |
167 | 167 | ||
168 | <LinearLayout | 168 | <LinearLayout |
169 | android:layout_width="match_parent" | 169 | android:layout_width="match_parent" |
170 | android:layout_height="match_parent" | 170 | android:layout_height="match_parent" |
171 | android:layout_marginLeft="30dp" | 171 | android:layout_marginLeft="30dp" |
172 | android:orientation="vertical"> | 172 | android:orientation="vertical"> |
173 | 173 | ||
174 | <LinearLayout | 174 | <LinearLayout |
175 | android:layout_width="match_parent" | 175 | android:layout_width="match_parent" |
176 | android:layout_height="wrap_content"> | 176 | android:layout_height="wrap_content"> |
177 | 177 | ||
178 | <LinearLayout | 178 | <LinearLayout |
179 | android:layout_width="0dp" | 179 | android:layout_width="0dp" |
180 | android:layout_height="wrap_content" | 180 | android:layout_height="wrap_content" |
181 | android:layout_weight="1"> | 181 | android:layout_weight="1"> |
182 | 182 | ||
183 | <LinearLayout | 183 | <LinearLayout |
184 | android:id="@+id/ll_zhu_backgrangd" | 184 | android:id="@+id/ll_zhu_backgrangd" |
185 | android:layout_width="wrap_content" | 185 | android:layout_width="400dp" |
186 | android:layout_height="wrap_content" | 186 | android:layout_height="wrap_content" |
187 | android:layout_marginLeft="5dp" | ||
187 | android:background="@drawable/corcle_blue_bg" | 188 | android:background="@drawable/corcle_blue_bg" |
188 | android:orientation="vertical"> | 189 | android:orientation="vertical"> |
189 | 190 | ||
190 | <LinearLayout | 191 | <LinearLayout |
191 | android:layout_width="match_parent" | 192 | android:layout_width="match_parent" |
192 | android:layout_height="wrap_content" | 193 | android:layout_height="wrap_content" |
193 | android:orientation="horizontal"> | 194 | android:orientation="horizontal"> |
194 | 195 | ||
195 | <com.facebook.drawee.view.SimpleDraweeView | 196 | <com.facebook.drawee.view.SimpleDraweeView |
196 | android:id="@+id/tv_account_head" | 197 | android:id="@+id/tv_account_head" |
197 | android:layout_width="60dp" | 198 | android:layout_width="60dp" |
198 | android:layout_height="60dp" | 199 | android:layout_height="60dp" |
199 | android:layout_margin="10dp" | 200 | android:layout_margin="10dp" |
200 | fresco:placeholderImage="@mipmap/header_default" | 201 | fresco:placeholderImage="@mipmap/header_default" |
201 | fresco:placeholderImageScaleType="fitCenter" | 202 | fresco:placeholderImageScaleType="fitCenter" |
202 | fresco:roundAsCircle="true" /> | 203 | fresco:roundAsCircle="true" /> |
203 | 204 | ||
204 | <LinearLayout | 205 | <LinearLayout |
205 | android:layout_width="0dp" | 206 | android:layout_width="0dp" |
206 | android:layout_height="wrap_content" | 207 | android:layout_height="wrap_content" |
207 | android:layout_marginLeft="10dp" | 208 | android:layout_marginLeft="10dp" |
208 | android:layout_marginTop="10dp" | 209 | android:layout_marginTop="10dp" |
209 | android:layout_weight="1" | 210 | android:layout_weight="1" |
210 | android:orientation="vertical"> | 211 | android:orientation="vertical"> |
211 | 212 | ||
212 | <TextView | 213 | <TextView |
213 | android:id="@+id/tv_account_name" | 214 | android:id="@+id/tv_account_name" |
214 | android:layout_width="wrap_content" | 215 | android:layout_width="wrap_content" |
215 | android:layout_height="wrap_content" | 216 | android:layout_height="wrap_content" |
216 | android:text="" | 217 | android:text="" |
217 | android:textSize="18sp" /> | 218 | android:textSize="18sp" /> |
218 | 219 | ||
219 | <TextView | 220 | <TextView |
220 | android:id="@+id/tv_account_grade" | 221 | android:id="@+id/tv_account_grade" |
221 | android:layout_width="wrap_content" | 222 | android:layout_width="wrap_content" |
222 | android:layout_height="wrap_content" | 223 | android:layout_height="wrap_content" |
223 | android:text="" | 224 | android:text="" |
224 | android:textSize="18sp" /> | 225 | android:textSize="18sp" /> |
225 | 226 | ||
226 | <TextView | 227 | <TextView |
227 | android:id="@+id/tv_account_school" | 228 | android:id="@+id/tv_account_school" |
228 | android:layout_width="wrap_content" | 229 | android:layout_width="wrap_content" |
229 | android:layout_height="wrap_content" | 230 | android:layout_height="wrap_content" |
230 | android:text="" | 231 | android:text="" |
231 | android:textSize="18sp" /> | 232 | android:textSize="18sp" /> |
232 | 233 | ||
233 | <TextView | 234 | <TextView |
234 | android:id="@+id/tv_account_adress" | 235 | android:id="@+id/tv_account_adress" |
235 | android:layout_width="wrap_content" | 236 | android:layout_width="wrap_content" |
236 | android:layout_height="wrap_content" | 237 | android:layout_height="wrap_content" |
237 | android:text="" | 238 | android:text="" |
238 | android:textSize="18sp" /> | 239 | android:textSize="18sp" /> |
239 | 240 | ||
240 | 241 | ||
241 | </LinearLayout> | 242 | </LinearLayout> |
242 | 243 | ||
243 | <ImageView | 244 | <ImageView |
244 | android:id="@+id/iv_shiyongzhong" | 245 | android:id="@+id/iv_shiyongzhong" |
245 | android:layout_width="wrap_content" | 246 | android:layout_width="wrap_content" |
246 | android:layout_height="wrap_content" | 247 | android:layout_height="wrap_content" |
247 | android:layout_gravity="right" | 248 | android:layout_gravity="right" |
248 | android:layout_marginLeft="60dp" | 249 | android:layout_marginLeft="60dp" |
249 | android:src="@mipmap/shiyongzhong" | 250 | android:src="@mipmap/shiyongzhong" |
250 | android:visibility="gone" /> | 251 | android:visibility="gone" /> |
251 | 252 | ||
252 | </LinearLayout> | 253 | </LinearLayout> |
253 | 254 | ||
254 | <View | 255 | <View |
255 | android:layout_width="match_parent" | 256 | android:layout_width="match_parent" |
256 | android:layout_height="0.7dp" | 257 | android:layout_height="0.7dp" |
257 | android:layout_margin="10dp" | 258 | android:layout_margin="10dp" |
258 | android:background="@color/cutoff_line"> | 259 | android:background="@color/cutoff_line"> |
259 | 260 | ||
260 | </View> | 261 | </View> |
261 | 262 | ||
262 | <LinearLayout | 263 | <LinearLayout |
263 | android:layout_width="match_parent" | 264 | android:layout_width="match_parent" |
264 | android:layout_height="wrap_content" | 265 | android:layout_height="wrap_content" |
265 | android:layout_marginBottom="10dp" | 266 | android:layout_marginBottom="10dp" |
266 | android:orientation="horizontal"> | 267 | android:orientation="horizontal"> |
267 | 268 | ||
268 | <TextView | 269 | <TextView |
269 | android:id="@+id/change_zhu_account" | 270 | android:id="@+id/change_zhu_account" |
270 | android:layout_width="0dp" | 271 | android:layout_width="0dp" |
271 | android:layout_height="wrap_content" | 272 | android:layout_height="wrap_content" |
272 | android:layout_weight="1" | 273 | android:layout_weight="1" |
273 | android:gravity="center" | 274 | android:gravity="center" |
274 | android:text="切换主账户" | 275 | android:text="切换主账户" |
275 | android:textSize="18sp" /> | 276 | android:textSize="18sp" /> |
276 | 277 | ||
277 | 278 | ||
278 | </LinearLayout> | 279 | </LinearLayout> |
279 | 280 | ||
280 | </LinearLayout> | 281 | </LinearLayout> |
281 | 282 | ||
282 | 283 | ||
283 | </LinearLayout> | 284 | </LinearLayout> |
284 | 285 | ||
285 | <LinearLayout | 286 | <LinearLayout |
286 | android:layout_width="0dp" | 287 | android:layout_width="0dp" |
287 | android:layout_height="wrap_content" | 288 | android:layout_height="wrap_content" |
288 | android:layout_weight="1"> | 289 | android:layout_weight="1"> |
289 | 290 | ||
290 | </LinearLayout> | 291 | </LinearLayout> |
291 | 292 | ||
292 | <LinearLayout | 293 | <LinearLayout |
293 | android:layout_width="0dp" | 294 | android:layout_width="0dp" |
294 | android:layout_height="wrap_content" | 295 | android:layout_height="wrap_content" |
295 | android:layout_weight="1"> | 296 | android:layout_weight="1"> |
296 | 297 | ||
297 | </LinearLayout> | 298 | </LinearLayout> |
298 | </LinearLayout> | 299 | </LinearLayout> |
299 | 300 | ||
300 | <RelativeLayout | 301 | <RelativeLayout |
301 | android:layout_width="match_parent" | 302 | android:layout_width="match_parent" |
302 | android:layout_height="wrap_content" | 303 | android:layout_height="wrap_content" |
303 | android:layout_marginTop="20dp" | 304 | android:layout_marginTop="20dp" |
304 | android:orientation="horizontal"> | 305 | android:orientation="horizontal"> |
305 | 306 | ||
306 | <android.support.v7.widget.RecyclerView | 307 | <android.support.v7.widget.RecyclerView |
307 | android:id="@+id/id_recyclerview_horizontal" | 308 | android:id="@+id/id_recyclerview_horizontal" |
308 | android:layout_width="wrap_content" | 309 | android:layout_width="wrap_content" |
309 | android:layout_height="wrap_content" | 310 | android:layout_height="wrap_content" |
310 | android:layout_centerVertical="true" | 311 | android:layout_centerVertical="true" |
311 | android:scrollbars="none"> | 312 | android:scrollbars="none"> |
312 | 313 | ||
313 | </android.support.v7.widget.RecyclerView> | 314 | </android.support.v7.widget.RecyclerView> |
314 | 315 | ||
315 | 316 | ||
316 | 317 | ||
317 | </RelativeLayout> | 318 | </RelativeLayout> |
318 | 319 | ||
319 | </LinearLayout> | 320 | </LinearLayout> |
320 | 321 | ||
321 | 322 | ||
322 | </LinearLayout> | 323 | </LinearLayout> |
PersonalCenter/app/src/main/res/layout/activity_main.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | xmlns:fresco="http://schemas.android.com/apk/res-auto" | 5 | xmlns:fresco="http://schemas.android.com/apk/res-auto" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <RelativeLayout | 8 | <RelativeLayout |
9 | android:id="@+id/title" | 9 | android:id="@+id/title" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="50dp" | 11 | android:layout_height="50dp" |
12 | android:background="@color/login_text_blue"> | 12 | android:background="@color/login_text_blue"> |
13 | 13 | ||
14 | <ImageView | 14 | <ImageView |
15 | android:id="@+id/cancel" | 15 | android:id="@+id/cancel" |
16 | android:layout_width="wrap_content" | 16 | android:layout_width="wrap_content" |
17 | android:layout_height="match_parent" | 17 | android:layout_height="match_parent" |
18 | android:paddingLeft="20dp" | 18 | android:paddingLeft="20dp" |
19 | android:paddingRight="20dp" | 19 | android:paddingRight="20dp" |
20 | android:visibility="gone" | 20 | android:visibility="gone" |
21 | android:src="@mipmap/title_back" /> | 21 | android:src="@mipmap/title_back" /> |
22 | 22 | ||
23 | <TextView | 23 | <TextView |
24 | android:id="@+id/menu_title" | 24 | android:id="@+id/menu_title" |
25 | android:layout_width="wrap_content" | 25 | android:layout_width="wrap_content" |
26 | android:layout_height="match_parent" | 26 | android:layout_height="match_parent" |
27 | android:layout_centerInParent="true" | 27 | android:layout_centerInParent="true" |
28 | android:gravity="center_vertical" | 28 | android:gravity="center_vertical" |
29 | android:text="@string/titel_preson" | 29 | android:text="@string/titel_preson" |
30 | android:textColor="@android:color/white" | 30 | android:textColor="@android:color/white" |
31 | android:textSize="22sp" /> | 31 | android:textSize="22sp" /> |
32 | 32 | ||
33 | <ImageView | 33 | <ImageView |
34 | android:id="@+id/iv_setting" | 34 | android:id="@+id/iv_setting" |
35 | android:layout_width="wrap_content" | 35 | android:layout_width="wrap_content" |
36 | android:layout_height="match_parent" | 36 | android:layout_height="match_parent" |
37 | android:layout_marginRight="10dp" | 37 | android:layout_marginRight="10dp" |
38 | android:layout_toLeftOf="@+id/iv_skin" | 38 | android:layout_toLeftOf="@+id/iv_skin" |
39 | android:gravity="center_vertical" | 39 | android:gravity="center_vertical" |
40 | android:padding="10dp" | 40 | android:padding="10dp" |
41 | android:src="@mipmap/shezhi" | 41 | android:src="@mipmap/shezhi" |
42 | android:textColor="@android:color/white" | 42 | android:textColor="@android:color/white" |
43 | android:textSize="22sp" /> | 43 | android:textSize="22sp" /> |
44 | 44 | ||
45 | <ImageView | 45 | <ImageView |
46 | android:id="@+id/iv_skin" | 46 | android:id="@+id/iv_skin" |
47 | android:layout_width="wrap_content" | 47 | android:layout_width="wrap_content" |
48 | android:layout_height="match_parent" | 48 | android:layout_height="match_parent" |
49 | android:layout_marginRight="10dp" | 49 | android:layout_marginRight="10dp" |
50 | android:layout_toLeftOf="@+id/iv_imformatioan" | 50 | android:layout_toLeftOf="@+id/iv_imformatioan" |
51 | android:gravity="center_vertical" | 51 | android:gravity="center_vertical" |
52 | android:padding="10dp" | 52 | android:padding="10dp" |
53 | android:src="@mipmap/pifu" | 53 | android:src="@mipmap/pifu" |
54 | android:textColor="@android:color/white" | 54 | android:textColor="@android:color/white" |
55 | android:textSize="22sp" /> | 55 | android:textSize="22sp" /> |
56 | 56 | ||
57 | <ImageView | 57 | <ImageView |
58 | android:id="@+id/iv_imformatioan" | 58 | android:id="@+id/iv_imformatioan" |
59 | android:layout_width="wrap_content" | 59 | android:layout_width="wrap_content" |
60 | android:layout_height="match_parent" | 60 | android:layout_height="match_parent" |
61 | android:layout_alignParentRight="true" | 61 | android:layout_alignParentRight="true" |
62 | android:layout_marginRight="10dp" | 62 | android:layout_marginRight="10dp" |
63 | android:gravity="center_vertical" | 63 | android:gravity="center_vertical" |
64 | android:padding="10dp" | 64 | android:padding="10dp" |
65 | android:src="@mipmap/fankui" | 65 | android:src="@mipmap/fankui" |
66 | android:textColor="@android:color/white" | 66 | android:textColor="@android:color/white" |
67 | android:textSize="22sp" /> | 67 | android:textSize="22sp" /> |
68 | 68 | ||
69 | 69 | ||
70 | </RelativeLayout> | 70 | </RelativeLayout> |
71 | 71 | ||
72 | <LinearLayout | 72 | <LinearLayout |
73 | android:layout_width="match_parent" | 73 | android:layout_width="match_parent" |
74 | android:layout_height="match_parent"> | 74 | android:layout_height="match_parent"> |
75 | 75 | ||
76 | <LinearLayout | 76 | <LinearLayout |
77 | android:layout_width="0dp" | 77 | android:layout_width="0dp" |
78 | android:layout_height="match_parent" | 78 | android:layout_height="match_parent" |
79 | android:layout_weight="1" | 79 | android:layout_weight="1" |
80 | android:orientation="vertical"> | 80 | android:orientation="vertical"> |
81 | 81 | ||
82 | <LinearLayout | 82 | <LinearLayout |
83 | android:layout_width="match_parent" | 83 | android:layout_width="match_parent" |
84 | android:layout_height="wrap_content" | 84 | android:layout_height="wrap_content" |
85 | android:layout_marginTop="20dp" | 85 | android:layout_marginTop="20dp" |
86 | android:orientation="horizontal"> | 86 | android:orientation="horizontal"> |
87 | <ImageView | 87 | <ImageView |
88 | android:id="@+id/iv_look_card" | 88 | android:id="@+id/iv_look_card" |
89 | android:layout_width="wrap_content" | 89 | android:layout_width="wrap_content" |
90 | android:layout_height="wrap_content" | 90 | android:layout_height="wrap_content" |
91 | android:padding="10dp" | 91 | android:padding="10dp" |
92 | android:layout_marginLeft="20dp" | 92 | android:layout_marginLeft="20dp" |
93 | android:src="@mipmap/card_icoc" /> | 93 | android:src="@mipmap/card_icoc" /> |
94 | <com.facebook.drawee.view.SimpleDraweeView | 94 | <com.facebook.drawee.view.SimpleDraweeView |
95 | android:id="@+id/iv_head" | 95 | android:id="@+id/iv_head" |
96 | android:layout_width="60dp" | 96 | android:layout_width="60dp" |
97 | android:layout_height="60dp" | 97 | android:layout_height="60dp" |
98 | android:layout_marginLeft="60dp" | 98 | android:layout_marginLeft="60dp" |
99 | android:layout_gravity="center" | 99 | android:layout_gravity="center" |
100 | fresco:placeholderImage="@mipmap/header_default" | 100 | fresco:placeholderImage="@mipmap/header_default" |
101 | fresco:roundAsCircle="true" | 101 | fresco:roundAsCircle="true" |
102 | fresco:placeholderImageScaleType="fitCenter" /> | 102 | fresco:placeholderImageScaleType="fitCenter" /> |
103 | 103 | ||
104 | <TextView | 104 | <TextView |
105 | android:layout_width="wrap_content" | 105 | android:layout_width="wrap_content" |
106 | android:layout_height="wrap_content" | 106 | android:layout_height="wrap_content" |
107 | android:layout_marginLeft="18dp" | 107 | android:layout_marginLeft="18dp" |
108 | android:layout_marginTop="20dp" | 108 | android:layout_marginTop="20dp" |
109 | android:background="@drawable/corcle_blue_bg" | 109 | android:background="@drawable/corcle_blue_bg" |
110 | android:paddingLeft="5dp" | 110 | android:paddingLeft="5dp" |
111 | android:paddingRight="5dp" | 111 | android:paddingRight="5dp" |
112 | android:gravity="center_vertical" | 112 | android:gravity="center_vertical" |
113 | android:text="签到" | 113 | android:text="签到" |
114 | android:textColor="@color/login_text_blue" | 114 | android:textColor="@color/login_text_blue" |
115 | android:textSize="18sp" /> | 115 | android:textSize="18sp" /> |
116 | 116 | ||
117 | </LinearLayout> | 117 | </LinearLayout> |
118 | 118 | ||
119 | <LinearLayout | 119 | <LinearLayout |
120 | android:layout_width="match_parent" | 120 | android:layout_width="match_parent" |
121 | android:layout_height="wrap_content" | 121 | android:layout_height="wrap_content" |
122 | android:layout_marginLeft="20dp" | 122 | android:layout_marginLeft="20dp" |
123 | android:layout_marginTop="20dp" | 123 | android:layout_marginTop="20dp" |
124 | android:orientation="horizontal"> | 124 | android:orientation="horizontal"> |
125 | 125 | ||
126 | <TextView | 126 | <TextView |
127 | android:id="@+id/tv_username" | 127 | android:id="@+id/tv_username" |
128 | android:layout_width="wrap_content" | 128 | android:layout_width="wrap_content" |
129 | android:layout_height="wrap_content" | 129 | android:layout_height="wrap_content" |
130 | android:text="姓名" | 130 | android:text="" |
131 | android:textSize="20dp" /> | 131 | android:textSize="20dp" /> |
132 | <TextView | ||
133 | android:id="@+id/tv_yangji" | ||
134 | android:layout_marginLeft="5dp" | ||
135 | android:layout_width="wrap_content" | ||
136 | android:layout_height="wrap_content" | ||
137 | android:text="(样机)" | ||
138 | android:textSize="20dp" | ||
139 | android:visibility="gone"/> | ||
132 | 140 | ||
133 | <ImageView | 141 | <ImageView |
134 | android:id="@+id/iv_sex" | 142 | android:id="@+id/iv_sex" |
135 | android:layout_width="wrap_content" | 143 | android:layout_width="wrap_content" |
136 | android:layout_height="wrap_content" | 144 | android:layout_height="wrap_content" |
137 | android:layout_gravity="center_vertical" | 145 | android:layout_gravity="center_vertical" |
138 | android:layout_marginLeft="50dp" | 146 | android:layout_marginLeft="50dp" |
139 | android:src="@mipmap/men" /> | 147 | android:src="@mipmap/men" /> |
140 | 148 | ||
141 | </LinearLayout> | 149 | </LinearLayout> |
142 | 150 | ||
143 | <LinearLayout | 151 | <LinearLayout |
144 | android:layout_width="match_parent" | 152 | android:layout_width="match_parent" |
145 | android:layout_height="wrap_content" | 153 | android:layout_height="wrap_content" |
146 | android:layout_marginLeft="20dp" | 154 | android:layout_marginLeft="20dp" |
147 | android:layout_marginTop="20dp" | 155 | android:layout_marginTop="20dp" |
148 | android:gravity="center" | 156 | android:gravity="center" |
149 | android:orientation="horizontal"> | 157 | android:orientation="horizontal"> |
150 | 158 | ||
151 | <TextView | 159 | <TextView |
152 | android:id="@+id/tv_sign" | 160 | android:id="@+id/tv_sign" |
153 | android:layout_width="0dp" | 161 | android:layout_width="0dp" |
154 | android:layout_height="wrap_content" | 162 | android:layout_height="wrap_content" |
155 | android:layout_weight="5" | 163 | android:layout_weight="5" |
156 | android:text="请输入个性签名" | 164 | android:hint="请输入个性签名" |
165 | android:maxLines="3" | ||
166 | android:ellipsize="end" | ||
157 | android:textSize="18sp" /> | 167 | android:textSize="18sp" /> |
158 | 168 | ||
159 | <ImageView | 169 | <ImageView |
160 | android:id="@+id/iv_sign" | 170 | android:id="@+id/iv_sign" |
161 | android:layout_width="0dp" | 171 | android:layout_width="0dp" |
162 | android:layout_height="wrap_content" | 172 | android:layout_height="wrap_content" |
163 | android:layout_weight="1" | 173 | android:layout_weight="1" |
164 | android:padding="10dp" | 174 | android:padding="10dp" |
165 | android:src="@mipmap/pencil" /> | 175 | android:src="@mipmap/pencil" /> |
166 | 176 | ||
167 | 177 | ||
168 | </LinearLayout> | 178 | </LinearLayout> |
169 | 179 | ||
170 | <View | 180 | <View |
171 | android:layout_width="match_parent" | 181 | android:layout_width="match_parent" |
172 | android:layout_height="0.7dp" | 182 | android:layout_height="0.7dp" |
173 | android:layout_marginTop="20dp" | 183 | android:layout_marginTop="20dp" |
174 | android:background="@color/cutoff_line"> | 184 | android:background="@color/cutoff_line"> |
175 | 185 | ||
176 | </View> | 186 | </View> |
177 | 187 | ||
178 | <LinearLayout | 188 | <LinearLayout |
179 | android:id="@+id/linel_mycuoti" | 189 | android:id="@+id/linel_mycuoti" |
180 | android:layout_width="match_parent" | 190 | android:layout_width="match_parent" |
181 | android:layout_height="wrap_content" | 191 | android:layout_height="wrap_content" |
182 | android:layout_marginTop="30dp" | 192 | android:layout_marginTop="30dp" |
183 | android:orientation="vertical"> | 193 | android:orientation="vertical"> |
184 | 194 | ||
185 | <LinearLayout | 195 | <LinearLayout |
186 | android:layout_width="match_parent" | 196 | android:layout_width="match_parent" |
187 | android:layout_height="wrap_content" | 197 | android:layout_height="wrap_content" |
188 | android:gravity="center_vertical" | 198 | android:gravity="center_vertical" |
189 | android:orientation="horizontal"> | 199 | android:orientation="horizontal"> |
190 | 200 | ||
191 | <ImageView | 201 | <ImageView |
192 | android:layout_width="0dp" | 202 | android:layout_width="0dp" |
193 | android:layout_height="wrap_content" | 203 | android:layout_height="wrap_content" |
194 | android:layout_weight="1" | 204 | android:layout_weight="1" |
195 | android:src="@mipmap/wodecuoti" /> | 205 | android:src="@mipmap/wodecuoti" /> |
196 | 206 | ||
197 | <TextView | 207 | <TextView |
198 | android:layout_width="0dp" | 208 | android:layout_width="0dp" |
199 | android:layout_height="wrap_content" | 209 | android:layout_height="wrap_content" |
200 | android:layout_weight="5" | 210 | android:layout_weight="5" |
201 | android:text="我的错题" | 211 | android:text="我的错题" |
202 | android:textSize="20sp" /> | 212 | android:textSize="20sp" /> |
203 | 213 | ||
204 | <ImageView | 214 | <ImageView |
205 | android:layout_width="0dp" | 215 | android:layout_width="0dp" |
206 | android:layout_height="wrap_content" | 216 | android:layout_height="wrap_content" |
207 | android:layout_weight="1" | 217 | android:layout_weight="1" |
208 | android:src="@mipmap/youjiantou" /> | 218 | android:src="@mipmap/youjiantou" /> |
209 | 219 | ||
210 | </LinearLayout> | 220 | </LinearLayout> |
211 | 221 | ||
212 | <LinearLayout | 222 | <LinearLayout |
213 | android:id="@+id/linel_mynote" | 223 | android:id="@+id/linel_mynote" |
214 | android:layout_width="match_parent" | 224 | android:layout_width="match_parent" |
215 | android:layout_height="wrap_content" | 225 | android:layout_height="wrap_content" |
216 | android:layout_marginTop="35dp" | 226 | android:layout_marginTop="35dp" |
217 | android:gravity="center_vertical" | 227 | android:gravity="center_vertical" |
218 | android:orientation="horizontal"> | 228 | android:orientation="horizontal"> |
219 | 229 | ||
220 | <ImageView | 230 | <ImageView |
221 | android:layout_width="0dp" | 231 | android:layout_width="0dp" |
222 | android:layout_height="wrap_content" | 232 | android:layout_height="wrap_content" |
223 | android:layout_weight="1" | 233 | android:layout_weight="1" |
224 | android:src="@mipmap/wodebiji" /> | 234 | android:src="@mipmap/wodebiji" /> |
225 | 235 | ||
226 | <TextView | 236 | <TextView |
227 | android:layout_width="0dp" | 237 | android:layout_width="0dp" |
228 | android:layout_height="wrap_content" | 238 | android:layout_height="wrap_content" |
229 | android:layout_weight="5" | 239 | android:layout_weight="5" |
230 | android:text="我的笔记" | 240 | android:text="我的笔记" |
231 | android:textSize="20sp" /> | 241 | android:textSize="20sp" /> |
232 | 242 | ||
233 | <ImageView | 243 | <ImageView |
234 | android:layout_width="0dp" | 244 | android:layout_width="0dp" |
235 | android:layout_height="wrap_content" | 245 | android:layout_height="wrap_content" |
236 | android:layout_weight="1" | 246 | android:layout_weight="1" |
237 | android:src="@mipmap/youjiantou" /> | 247 | android:src="@mipmap/youjiantou" /> |
238 | 248 | ||
239 | </LinearLayout> | 249 | </LinearLayout> |
240 | 250 | ||
241 | <LinearLayout | 251 | <LinearLayout |
242 | android:id="@+id/linel_mycollege" | 252 | android:id="@+id/linel_mycollege" |
243 | android:layout_width="match_parent" | 253 | android:layout_width="match_parent" |
244 | android:layout_height="wrap_content" | 254 | android:layout_height="wrap_content" |
245 | android:layout_marginTop="35dp" | 255 | android:layout_marginTop="35dp" |
246 | android:gravity="center_vertical" | 256 | android:gravity="center_vertical" |
247 | android:orientation="horizontal"> | 257 | android:orientation="horizontal"> |
248 | 258 | ||
249 | <ImageView | 259 | <ImageView |
250 | android:layout_width="0dp" | 260 | android:layout_width="0dp" |
251 | android:layout_height="wrap_content" | 261 | android:layout_height="wrap_content" |
252 | android:layout_weight="1" | 262 | android:layout_weight="1" |
253 | android:src="@mipmap/wodeshoucang" /> | 263 | android:src="@mipmap/wodeshoucang" /> |
254 | 264 | ||
255 | <TextView | 265 | <TextView |
256 | android:layout_width="0dp" | 266 | android:layout_width="0dp" |
257 | android:layout_height="wrap_content" | 267 | android:layout_height="wrap_content" |
258 | android:layout_weight="5" | 268 | android:layout_weight="5" |
259 | android:text="我的收藏" | 269 | android:text="我的收藏" |
260 | android:textSize="20sp" /> | 270 | android:textSize="20sp" /> |
261 | 271 | ||
262 | <ImageView | 272 | <ImageView |
263 | android:layout_width="0dp" | 273 | android:layout_width="0dp" |
264 | android:layout_height="wrap_content" | 274 | android:layout_height="wrap_content" |
265 | android:layout_weight="1" | 275 | android:layout_weight="1" |
266 | android:src="@mipmap/youjiantou" /> | 276 | android:src="@mipmap/youjiantou" /> |
267 | 277 | ||
268 | </LinearLayout> | 278 | </LinearLayout> |
269 | 279 | ||
270 | <LinearLayout | 280 | <LinearLayout |
271 | android:id="@+id/linel_myclass" | 281 | android:id="@+id/linel_myclass" |
272 | android:layout_width="match_parent" | 282 | android:layout_width="match_parent" |
273 | android:layout_height="wrap_content" | 283 | android:layout_height="wrap_content" |
274 | android:layout_marginTop="35dp" | 284 | android:layout_marginTop="35dp" |
275 | android:gravity="center_vertical" | 285 | android:gravity="center_vertical" |
276 | android:orientation="horizontal"> | 286 | android:orientation="horizontal"> |
277 | 287 | ||
278 | <ImageView | 288 | <ImageView |
279 | android:layout_width="0dp" | 289 | android:layout_width="0dp" |
280 | android:layout_height="wrap_content" | 290 | android:layout_height="wrap_content" |
281 | android:layout_weight="1" | 291 | android:layout_weight="1" |
282 | android:src="@mipmap/wodebanji" /> | 292 | android:src="@mipmap/wodebanji" /> |
283 | 293 | ||
284 | <TextView | 294 | <TextView |
285 | android:layout_width="0dp" | 295 | android:layout_width="0dp" |
286 | android:layout_height="wrap_content" | 296 | android:layout_height="wrap_content" |
287 | android:layout_weight="5" | 297 | android:layout_weight="5" |
288 | android:text="我的班级" | 298 | android:text="我的班级" |
289 | android:textSize="20sp" /> | 299 | android:textSize="20sp" /> |
290 | 300 | ||
291 | <ImageView | 301 | <ImageView |
292 | android:layout_width="0dp" | 302 | android:layout_width="0dp" |
293 | android:layout_height="wrap_content" | 303 | android:layout_height="wrap_content" |
294 | android:layout_weight="1" | 304 | android:layout_weight="1" |
295 | android:src="@mipmap/youjiantou" /> | 305 | android:src="@mipmap/youjiantou" /> |
296 | 306 | ||
297 | </LinearLayout> | 307 | </LinearLayout> |
298 | 308 | ||
299 | 309 | ||
300 | </LinearLayout> | 310 | </LinearLayout> |
301 | 311 | ||
302 | <LinearLayout | 312 | <LinearLayout |
303 | android:layout_width="match_parent" | 313 | android:layout_width="match_parent" |
304 | android:layout_height="match_parent" | 314 | android:layout_height="match_parent" |
305 | android:layout_marginTop="120dp" | 315 | android:layout_marginTop="120dp" |
306 | android:background="@mipmap/xiaoguanggao"> | 316 | android:background="@mipmap/xiaoguanggao"> |
307 | 317 | ||
308 | </LinearLayout> | 318 | </LinearLayout> |
309 | 319 | ||
310 | 320 | ||
311 | </LinearLayout> | 321 | </LinearLayout> |
312 | 322 | ||
313 | 323 | ||
314 | <View | 324 | <View |
315 | android:layout_width="0.7dp" | 325 | android:layout_width="0.7dp" |
316 | android:layout_height="match_parent" | 326 | android:layout_height="match_parent" |
317 | android:background="@color/cutoff_line"> | 327 | android:background="@color/cutoff_line"> |
318 | 328 | ||
319 | </View> | 329 | </View> |
320 | 330 | ||
321 | <LinearLayout | 331 | <LinearLayout |
322 | android:layout_width="0dp" | 332 | android:layout_width="0dp" |
323 | android:layout_height="match_parent" | 333 | android:layout_height="match_parent" |
324 | android:layout_weight="2.5" | 334 | android:layout_weight="2.5" |
325 | android:orientation="vertical"> | 335 | android:orientation="vertical"> |
326 | 336 | ||
327 | <LinearLayout | 337 | <LinearLayout |
328 | android:layout_width="match_parent" | 338 | android:layout_width="match_parent" |
329 | android:layout_height="wrap_content" | 339 | android:layout_height="wrap_content" |
330 | android:layout_margin="20dp" | 340 | android:layout_margin="20dp" |
331 | android:gravity="center_vertical" | 341 | android:gravity="center_vertical" |
332 | android:orientation="horizontal"> | 342 | android:orientation="horizontal"> |
333 | 343 | ||
334 | <View | 344 | <View |
335 | android:layout_width="5dp" | 345 | android:layout_width="5dp" |
336 | android:layout_height="20dp" | 346 | android:layout_height="20dp" |
337 | android:background="@color/login_text_blue"> | 347 | android:background="@color/login_text_blue"> |
338 | 348 | ||
339 | </View> | 349 | </View> |
340 | 350 | ||
341 | <TextView | 351 | <TextView |
342 | android:layout_width="wrap_content" | 352 | android:layout_width="wrap_content" |
343 | android:layout_height="wrap_content" | 353 | android:layout_height="wrap_content" |
344 | android:layout_marginLeft="5dp" | 354 | android:layout_marginLeft="5dp" |
345 | android:text="最近学习" | 355 | android:text="最近学习" |
346 | android:textSize="22sp" /> | 356 | android:textSize="22sp" /> |
347 | 357 | ||
348 | </LinearLayout> | 358 | </LinearLayout> |
349 | 359 | ||
350 | <LinearLayout | 360 | <LinearLayout |
351 | android:layout_width="wrap_content" | 361 | android:layout_width="wrap_content" |
352 | android:layout_height="wrap_content"> | 362 | android:layout_height="wrap_content"> |
353 | 363 | ||
354 | <android.support.v7.widget.RecyclerView | 364 | <android.support.v7.widget.RecyclerView |
355 | android:id="@+id/id_recyclerview_horizontal" | 365 | android:id="@+id/id_recyclerview_horizontal" |
356 | android:layout_width="wrap_content" | 366 | android:layout_width="wrap_content" |
357 | android:layout_height="wrap_content" | 367 | android:layout_height="wrap_content" |
358 | android:layout_centerVertical="true" | 368 | android:layout_centerVertical="true" |
359 | android:scrollbars="none" /> | 369 | android:scrollbars="none" /> |
360 | </LinearLayout> | 370 | </LinearLayout> |
361 | 371 | ||
362 | <View | 372 | <View |
363 | android:layout_width="match_parent" | 373 | android:layout_width="match_parent" |
364 | android:layout_height="0.7dp" | 374 | android:layout_height="0.7dp" |
365 | android:layout_marginTop="10dp" | 375 | android:layout_marginTop="10dp" |
366 | android:background="@color/cutoff_line"> | 376 | android:background="@color/cutoff_line"> |
367 | 377 | ||
368 | </View> | 378 | </View> |
369 | 379 | ||
370 | <LinearLayout | 380 | <LinearLayout |
371 | android:layout_width="match_parent" | 381 | android:layout_width="match_parent" |
372 | android:layout_height="wrap_content" | 382 | android:layout_height="wrap_content" |
373 | android:layout_margin="10dp" | 383 | android:layout_margin="10dp" |
374 | android:gravity="center_vertical" | 384 | android:gravity="center_vertical" |
375 | android:orientation="horizontal"> | 385 | android:orientation="horizontal"> |
376 | 386 | ||
377 | <View | 387 | <View |
378 | android:layout_width="5dp" | 388 | android:layout_width="5dp" |
379 | android:layout_height="20dp" | 389 | android:layout_height="20dp" |
380 | android:background="@color/login_text_blue"> | 390 | android:background="@color/login_text_blue"> |
381 | 391 | ||
382 | </View> | 392 | </View> |
383 | 393 | ||
384 | <TextView | 394 | <TextView |
385 | android:layout_width="0dp" | 395 | android:layout_width="0dp" |
386 | android:layout_height="wrap_content" | 396 | android:layout_height="wrap_content" |
387 | android:layout_marginLeft="5dp" | 397 | android:layout_marginLeft="5dp" |
388 | android:layout_weight="5" | 398 | android:layout_weight="5" |
389 | android:text="个人信息" | 399 | android:text="个人信息" |
390 | android:textSize="22sp" /> | 400 | android:textSize="22sp" /> |
391 | 401 | ||
392 | <TextView | 402 | <TextView |
393 | android:id="@+id/tv_edit_presoninfo" | 403 | android:id="@+id/tv_edit_presoninfo" |
394 | android:padding="5dp" | 404 | android:padding="5dp" |
395 | android:layout_width="0dp" | 405 | android:layout_width="0dp" |
396 | android:layout_height="wrap_content" | 406 | android:layout_height="wrap_content" |
397 | android:layout_marginLeft="10dp" | 407 | android:layout_marginLeft="10dp" |
398 | android:layout_weight="0.4" | 408 | android:layout_weight="0.4" |
399 | android:text="编辑" | 409 | android:text="编辑" |
400 | android:textSize="18sp" /> | 410 | android:textSize="18sp" /> |
401 | 411 | ||
402 | <ImageView | 412 | <ImageView |
403 | android:layout_width="0dp" | 413 | android:layout_width="0dp" |
404 | android:layout_height="wrap_content" | 414 | android:layout_height="wrap_content" |
405 | android:layout_weight="0.1" | 415 | android:layout_weight="0.1" |
406 | android:src="@mipmap/youjiantou" /> | 416 | android:src="@mipmap/youjiantou" /> |
407 | 417 | ||
408 | 418 | ||
409 | </LinearLayout> | 419 | </LinearLayout> |
410 | 420 | ||
411 | <LinearLayout | 421 | <LinearLayout |
412 | android:layout_width="match_parent" | 422 | android:layout_width="match_parent" |
413 | android:layout_height="wrap_content" | 423 | android:layout_height="wrap_content" |
414 | android:layout_marginLeft="50dp" | 424 | android:layout_marginLeft="50dp" |
415 | android:orientation="vertical"> | 425 | android:orientation="vertical"> |
416 | 426 | ||
417 | <LinearLayout | 427 | <LinearLayout |
418 | android:layout_width="match_parent" | 428 | android:layout_width="match_parent" |
419 | android:layout_height="wrap_content" | 429 | android:layout_height="wrap_content" |
420 | android:gravity="center_vertical" | 430 | android:gravity="center_vertical" |
421 | android:orientation="horizontal"> | 431 | android:orientation="horizontal"> |
422 | 432 | ||
423 | <TextView | 433 | <TextView |
424 | android:layout_width="0dp" | 434 | android:layout_width="0dp" |
425 | android:layout_height="wrap_content" | 435 | android:layout_height="wrap_content" |
426 | android:layout_weight="1" | 436 | android:layout_weight="1" |
427 | android:text="昵称" | 437 | android:text="昵称" |
428 | android:textSize="20sp" /> | 438 | android:textSize="20sp" /> |
429 | 439 | ||
430 | <TextView | 440 | <TextView |
431 | android:id="@+id/tv_username1" | 441 | android:id="@+id/tv_username1" |
432 | android:layout_width="0dp" | 442 | android:layout_width="0dp" |
433 | android:layout_height="wrap_content" | 443 | android:layout_height="wrap_content" |
434 | android:layout_weight="2" | 444 | android:layout_weight="2" |
435 | android:hint="未填写" | 445 | android:hint="未填写" |
436 | android:textSize="20sp" /> | 446 | android:textSize="20sp" /> |
437 | 447 | ||
438 | <TextView | 448 | <TextView |
439 | android:layout_width="1dp" | 449 | android:layout_width="1dp" |
440 | android:layout_height="wrap_content" | 450 | android:layout_height="wrap_content" |
441 | android:layout_weight="1" | 451 | android:layout_weight="1" |
442 | android:text="星座" | 452 | android:text="星座" |
443 | android:textSize="20sp" /> | 453 | android:textSize="20sp" /> |
444 | 454 | ||
445 | <TextView | 455 | <TextView |
446 | android:id="@+id/tv_mygad" | 456 | android:id="@+id/tv_mygad" |
447 | android:layout_width="0dp" | 457 | android:layout_width="0dp" |
448 | android:layout_height="wrap_content" | 458 | android:layout_height="wrap_content" |
449 | android:layout_weight="2" | 459 | android:layout_weight="2" |
450 | android:hint="未填写" | 460 | android:hint="未填写" |
451 | android:textSize="20sp" /> | 461 | android:textSize="20sp" /> |
452 | </LinearLayout> | 462 | </LinearLayout> |
453 | 463 | ||
454 | <LinearLayout | 464 | <LinearLayout |
455 | android:layout_width="match_parent" | 465 | android:layout_width="match_parent" |
456 | android:layout_height="wrap_content" | 466 | android:layout_height="wrap_content" |
457 | android:layout_marginTop="15dp" | 467 | android:layout_marginTop="15dp" |
458 | android:gravity="center_vertical" | 468 | android:gravity="center_vertical" |
459 | android:orientation="horizontal"> | 469 | android:orientation="horizontal"> |
460 | 470 | ||
461 | <TextView | 471 | <TextView |
462 | android:layout_width="0dp" | 472 | android:layout_width="0dp" |
463 | android:layout_height="wrap_content" | 473 | android:layout_height="wrap_content" |
464 | android:layout_weight="1" | 474 | android:layout_weight="1" |
465 | android:text="性别" | 475 | android:text="性别" |
466 | android:textSize="20sp" /> | 476 | android:textSize="20sp" /> |
467 | 477 | ||
468 | <TextView | 478 | <TextView |
469 | android:id="@+id/tv_sex" | 479 | android:id="@+id/tv_sex" |
470 | android:layout_width="0dp" | 480 | android:layout_width="0dp" |
471 | android:layout_height="wrap_content" | 481 | android:layout_height="wrap_content" |
472 | android:layout_weight="2" | 482 | android:layout_weight="2" |
473 | android:hint="未填写" | 483 | android:hint="未填写" |
474 | android:textSize="20sp" /> | 484 | android:textSize="20sp" /> |
475 | 485 | ||
476 | <TextView | 486 | <TextView |
477 | android:layout_width="1dp" | 487 | android:layout_width="1dp" |
478 | android:layout_height="wrap_content" | 488 | android:layout_height="wrap_content" |
479 | android:layout_weight="1" | 489 | android:layout_weight="1" |
480 | android:text="地区" | 490 | android:text="地区" |
481 | android:textSize="20sp" /> | 491 | android:textSize="20sp" /> |
482 | 492 | ||
483 | <TextView | 493 | <TextView |
484 | android:id="@+id/tv_useinfo_adress" | 494 | android:id="@+id/tv_useinfo_adress" |
485 | android:layout_width="0dp" | 495 | android:layout_width="0dp" |
486 | android:layout_height="wrap_content" | 496 | android:layout_height="wrap_content" |
487 | android:layout_weight="2" | 497 | android:layout_weight="2" |
488 | android:hint="未填写" | 498 | android:hint="未填写" |
489 | android:textSize="20sp" /> | 499 | android:textSize="20sp" /> |
490 | </LinearLayout> | 500 | </LinearLayout> |
491 | 501 | ||
492 | <LinearLayout | 502 | <LinearLayout |
493 | android:layout_width="match_parent" | 503 | android:layout_width="match_parent" |
494 | android:layout_height="wrap_content" | 504 | android:layout_height="wrap_content" |
495 | android:layout_marginTop="15dp" | 505 | android:layout_marginTop="15dp" |
496 | android:gravity="center_vertical" | 506 | android:gravity="center_vertical" |
497 | android:orientation="horizontal"> | 507 | android:orientation="horizontal"> |
498 | 508 | ||
499 | <TextView | 509 | <TextView |
500 | android:layout_width="0dp" | 510 | android:layout_width="0dp" |
501 | android:layout_height="wrap_content" | 511 | android:layout_height="wrap_content" |
502 | android:layout_weight="1" | 512 | android:layout_weight="1" |
503 | android:text="生日" | 513 | android:text="生日" |
504 | android:textSize="20sp" /> | 514 | android:textSize="20sp" /> |
505 | 515 | ||
506 | <TextView | 516 | <TextView |
507 | android:id="@+id/tv_useinfo_birthday" | 517 | android:id="@+id/tv_useinfo_birthday" |
508 | android:layout_width="0dp" | 518 | android:layout_width="0dp" |
509 | android:layout_height="wrap_content" | 519 | android:layout_height="wrap_content" |
510 | android:layout_weight="2" | 520 | android:layout_weight="2" |
511 | android:hint="未填写" | 521 | android:hint="未填写" |
512 | android:textSize="20sp" /> | 522 | android:textSize="20sp" /> |
513 | 523 | ||
514 | <TextView | 524 | <TextView |
515 | android:layout_width="1dp" | 525 | android:layout_width="1dp" |
516 | android:layout_height="wrap_content" | 526 | android:layout_height="wrap_content" |
517 | android:layout_weight="1" | 527 | android:layout_weight="1" |
518 | android:text="学校" | 528 | android:text="学校" |
519 | android:textSize="20sp" /> | 529 | android:textSize="20sp" /> |
520 | 530 | ||
521 | <TextView | 531 | <TextView |
522 | android:id="@+id/tv_useinfo_school" | 532 | android:id="@+id/tv_useinfo_school" |
523 | android:layout_width="0dp" | 533 | android:layout_width="0dp" |
524 | android:layout_height="wrap_content" | 534 | android:layout_height="wrap_content" |
525 | android:layout_weight="2" | 535 | android:layout_weight="2" |
526 | android:hint="未填写" | 536 | android:hint="未填写" |
527 | android:textSize="20sp" /> | 537 | android:textSize="20sp" /> |
528 | </LinearLayout> | 538 | </LinearLayout> |
529 | 539 | ||
530 | <LinearLayout | 540 | <LinearLayout |
531 | android:layout_width="match_parent" | 541 | android:layout_width="match_parent" |
532 | android:layout_height="wrap_content" | 542 | android:layout_height="wrap_content" |
533 | android:layout_marginTop="15dp" | 543 | android:layout_marginTop="15dp" |
534 | android:gravity="center_vertical" | 544 | android:gravity="center_vertical" |
535 | android:orientation="horizontal"> | 545 | android:orientation="horizontal"> |
536 | 546 | ||
537 | <TextView | 547 | <TextView |
538 | android:layout_width="0dp" | 548 | android:layout_width="0dp" |
539 | android:layout_height="wrap_content" | 549 | android:layout_height="wrap_content" |
540 | android:layout_weight="1" | 550 | android:layout_weight="1" |
541 | android:text=" Q Q" | 551 | android:text=" Q Q" |
542 | android:textSize="20sp" /> | 552 | android:textSize="20sp" /> |
543 | 553 | ||
544 | <TextView | 554 | <TextView |
545 | android:id="@+id/tv_useinfo_qq" | 555 | android:id="@+id/tv_useinfo_qq" |
546 | android:layout_width="0dp" | 556 | android:layout_width="0dp" |
547 | android:layout_height="wrap_content" | 557 | android:layout_height="wrap_content" |
548 | android:layout_weight="2" | 558 | android:layout_weight="2" |
549 | android:hint="未填写" | 559 | android:hint="未填写" |
550 | android:textSize="20sp" /> | 560 | android:textSize="20sp" /> |
551 | 561 | ||
552 | <TextView | 562 | <TextView |
553 | android:layout_width="1dp" | 563 | android:layout_width="1dp" |
554 | android:layout_height="wrap_content" | 564 | android:layout_height="wrap_content" |
555 | android:layout_weight="1" | 565 | android:layout_weight="1" |
556 | android:text="年级" | 566 | android:text="年级" |
557 | android:textSize="20sp" /> | 567 | android:textSize="20sp" /> |
558 | 568 | ||
559 | <TextView | 569 | <TextView |
560 | android:id="@+id/tv_useinfo_gender" | 570 | android:id="@+id/tv_useinfo_gender" |
561 | android:layout_width="0dp" | 571 | android:layout_width="0dp" |
562 | android:layout_height="wrap_content" | 572 | android:layout_height="wrap_content" |
563 | android:layout_weight="2" | 573 | android:layout_weight="2" |
564 | android:hint="未填写" | 574 | android:hint="未填写" |
565 | android:textSize="20sp" /> | 575 | android:textSize="20sp" /> |
566 | </LinearLayout> | 576 | </LinearLayout> |
567 | 577 | ||
568 | 578 | ||
569 | </LinearLayout> | 579 | </LinearLayout> |
570 | <View | 580 | <View |
571 | android:layout_width="match_parent" | 581 | android:layout_width="match_parent" |
572 | android:layout_height="0.7dp" | 582 | android:layout_height="0.7dp" |
573 | android:layout_marginTop="20dp" | 583 | android:layout_marginTop="20dp" |
574 | android:background="@color/cutoff_line"> | 584 | android:background="@color/cutoff_line"> |
575 | 585 | ||
576 | </View> | 586 | </View> |
577 | <LinearLayout | 587 | <LinearLayout |
578 | android:layout_width="match_parent" | 588 | android:layout_width="match_parent" |
579 | android:layout_height="wrap_content" | 589 | android:layout_height="wrap_content" |
580 | android:layout_margin="10dp" | 590 | android:layout_margin="10dp" |
581 | android:gravity="center_vertical" | 591 | android:gravity="center_vertical" |
582 | android:orientation="horizontal"> | 592 | android:orientation="horizontal"> |
583 | 593 | ||
584 | <View | 594 | <View |
585 | android:layout_width="5dp" | 595 | android:layout_width="5dp" |
586 | android:layout_height="20dp" | 596 | android:layout_height="20dp" |
587 | android:background="@color/login_text_blue"> | 597 | android:background="@color/login_text_blue"> |
588 | 598 | ||
589 | </View> | 599 | </View> |
590 | 600 | ||
591 | <TextView | 601 | <TextView |
592 | android:layout_width="wrap_content" | 602 | android:layout_width="wrap_content" |
593 | android:layout_height="wrap_content" | 603 | android:layout_height="wrap_content" |
594 | android:layout_marginLeft="5dp" | 604 | android:layout_marginLeft="5dp" |
595 | android:text="版本信息" | 605 | android:text="版本信息" |
596 | android:textSize="22sp" /> | 606 | android:textSize="22sp" /> |
597 | 607 | ||
598 | </LinearLayout> | 608 | </LinearLayout> |
599 | 609 | ||
600 | <LinearLayout | 610 | <LinearLayout |
601 | android:layout_width="match_parent" | 611 | android:layout_width="match_parent" |
602 | android:layout_height="wrap_content" | 612 | android:layout_height="wrap_content" |
603 | android:layout_marginTop="10dp"> | 613 | android:layout_marginTop="10dp"> |
604 | <android.support.v7.widget.RecyclerView | 614 | <android.support.v7.widget.RecyclerView |
605 | android:id="@+id/id_recyclerview_pubish" | 615 | android:id="@+id/id_recyclerview_pubish" |
606 | android:layout_width="match_parent" | 616 | android:layout_width="match_parent" |
607 | android:layout_height="match_parent" | 617 | android:layout_height="match_parent" |
608 | android:layout_centerVertical="true" | 618 | android:layout_centerVertical="true" |
609 | android:scrollbars="none" /> | 619 | android:scrollbars="none" /> |
610 | 620 | ||
611 | 621 | ||
612 | </LinearLayout> | 622 | </LinearLayout> |
613 | 623 | ||
614 | 624 | ||
615 | </LinearLayout> | 625 | </LinearLayout> |
616 | 626 | ||
617 | 627 | ||
618 | </LinearLayout> | 628 | </LinearLayout> |
619 | 629 | ||
620 | 630 | ||
621 | </LinearLayout> | 631 | </LinearLayout> |
622 | 632 |
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/values/CircleColor.java
1 | package com.mylhyl.circledialog.res.values; | 1 | package com.mylhyl.circledialog.res.values; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by hupei on 2017/3/29. | 4 | * Created by hupei on 2017/3/29. |
5 | */ | 5 | */ |
6 | public class CircleColor { | 6 | public class CircleColor { |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * 对话框背景色 | 9 | * 对话框背景色 |
10 | */ | 10 | */ |
11 | public static final int bgDialog = 0xFFf8f8f8; | 11 | public static final int bgDialog = 0xFFf8f8f8; |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * 标题颜色 | 14 | * 标题颜色 |
15 | */ | 15 | */ |
16 | public static final int title = 0xFF000000; | 16 | public static final int title = 0xFF000000; |
17 | /** | 17 | /** |
18 | * 消息内容颜色 | 18 | * 消息内容颜色 |
19 | */ | 19 | */ |
20 | public static final int content = 0xFF8F8F8F; | 20 | public static final int content = 0xFF8F8F8F; |
21 | /** | 21 | /** |
22 | * 按钮颜色 | 22 | * 按钮颜色 |
23 | */ | 23 | */ |
24 | public static final int button = 0xFF007AFF; | 24 | public static final int button = 0xFF8F8F8F; |
25 | /** | 25 | /** |
26 | * 线条颜色 | 26 | * 线条颜色 |
27 | */ | 27 | */ |
28 | public static final int divider = 0xFFD7D7DB; | 28 | public static final int divider = 0x808080; |
29 | /** | 29 | /** |
30 | * 按钮点击颜色 | 30 | * 按钮点击颜色 |
31 | */ | 31 | */ |
32 | public static final int buttonPress = 0xFFEAEAEA; | 32 | public static final int buttonPress = 0xFF8F8F8F; |
33 | /** | 33 | /** |
34 | * 输入框边框颜色 | 34 | * 输入框边框颜色 |
35 | */ | 35 | */ |
36 | public static final int inputStroke = 0xFF808080; | 36 | public static final int inputStroke = 0xFFFFFF; |
37 | } | 37 | } |
38 | 38 |
PersonalCenter/circledialog/src/main/java/com/mylhyl/circledialog/res/values/CircleDimen.java
1 | package com.mylhyl.circledialog.res.values; | 1 | package com.mylhyl.circledialog.res.values; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by hupei on 2017/3/29. | 4 | * Created by hupei on 2017/3/29. |
5 | */ | 5 | */ |
6 | public class CircleDimen { | 6 | public class CircleDimen { |
7 | /** | 7 | /** |
8 | * 所有的圆角 | 8 | * 所有的圆角 |
9 | */ | 9 | */ |
10 | public static final int RADIUS = 30; | 10 | public static final int RADIUS = 30; |
11 | /** | 11 | /** |
12 | * 标题高 | 12 | * 标题高 |
13 | */ | 13 | */ |
14 | public static final int TITLE_HEIGHT = 170; | 14 | public static final int TITLE_HEIGHT = 150; |
15 | /** | 15 | /** |
16 | * 标题字体大小 | 16 | * 标题字体大小 |
17 | */ | 17 | */ |
18 | public static final int TITLE_TEXT_SIZE = 60; | 18 | public static final int TITLE_TEXT_SIZE = 44; |
19 | /** | 19 | /** |
20 | * 文字消息字体大小 | 20 | * 文字消息字体大小 |
21 | */ | 21 | */ |
22 | public static final int CONTENT_TEXT_SIZE = 50; | 22 | public static final int CONTENT_TEXT_SIZE = 30; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * 列表每行高度 | 25 | * 列表每行高度 |
26 | */ | 26 | */ |
27 | public static final int ITEM_HEIGHT = 170; | 27 | public static final int ITEM_HEIGHT = 170; |
28 | /** | 28 | /** |
29 | * 底部按钮高度 | 29 | * 底部按钮高度 |
30 | */ | 30 | */ |
31 | public static final int FOOTER_HEIGHT = 150; | 31 | public static final int FOOTER_HEIGHT = 100; |
32 | /** | 32 | /** |
33 | * 底部按钮字体大小 | 33 | * 底部按钮字体大小 |
34 | */ | 34 | */ |
35 | public static final int FOOTER_TEXT_SIZE = 40; | 35 | public static final int FOOTER_TEXT_SIZE = 35; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * 列表模式底部按钮与列表的距离 | 38 | * 列表模式底部按钮与列表的距离 |
39 | */ | 39 | */ |
40 | public static final int BUTTON_ITEMS_MARGIN = 15; | 40 | public static final int BUTTON_ITEMS_MARGIN = 15; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * 输入框的高 | 43 | * 输入框的高 |
44 | */ | 44 | */ |
45 | public static final int INPUT_HEIGHT = 340; | 45 | public static final int INPUT_HEIGHT = 300; |
46 | /** | 46 | /** |
47 | * 水平进度条高度 | 47 | * 水平进度条高度 |
48 | */ | 48 | */ |
49 | public static final int PROGRESS_HEIGHT_HORIZONTAL = 10; | 49 | public static final int PROGRESS_HEIGHT_HORIZONTAL = 10; |
50 | /** | 50 | /** |
51 | * 转换进度条高度 | 51 | * 转换进度条高度 |
52 | */ | 52 | */ |
53 | public static final int PROGRESS_HEIGHT_SPINNER = 80; | 53 | public static final int PROGRESS_HEIGHT_SPINNER = 80; |
54 | } | 54 | } |
55 | 55 |