Commit 865951b7d0d0dc283d699f891f3cc89b40490434
1 parent
e93f210b0a
Exists in
master
解决listview滑动时位置会改变的问题
Showing
9 changed files
with
126 additions
and
68 deletions
Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.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.view.View; | 13 | import android.view.View; |
14 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
15 | import android.widget.LinearLayout; | 15 | import android.widget.LinearLayout; |
16 | import android.widget.TextView; | 16 | import android.widget.TextView; |
17 | import android.widget.Toast; | 17 | import android.widget.Toast; |
18 | 18 | ||
19 | import com.facebook.drawee.backends.pipeline.Fresco; | 19 | import com.facebook.drawee.backends.pipeline.Fresco; |
20 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 20 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
21 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 21 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
22 | import com.facebook.drawee.generic.RoundingParams; | 22 | import com.facebook.drawee.generic.RoundingParams; |
23 | import com.facebook.drawee.interfaces.DraweeController; | 23 | import com.facebook.drawee.interfaces.DraweeController; |
24 | import com.facebook.drawee.view.SimpleDraweeView; | 24 | import com.facebook.drawee.view.SimpleDraweeView; |
25 | import com.hjx.personalcenter.R; | 25 | import com.hjx.personalcenter.R; |
26 | import com.hjx.personalcenter.customdialog.HeadDialog; | 26 | import com.hjx.personalcenter.customdialog.HeadDialog; |
27 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 27 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
28 | import com.hjx.personalcenter.util.AlertUtils; | 28 | import com.hjx.personalcenter.util.AlertUtils; |
29 | import com.hjx.personalcenter.util.CropUtils; | 29 | import com.hjx.personalcenter.util.CropUtils; |
30 | import com.hjx.personalcenter.util.DialogPermission; | 30 | import com.hjx.personalcenter.util.DialogPermission; |
31 | import com.hjx.personalcenter.util.FileUtil; | 31 | import com.hjx.personalcenter.util.FileUtil; |
32 | import com.hjx.personalcenter.util.PermissionUtil; | 32 | import com.hjx.personalcenter.util.PermissionUtil; |
33 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 33 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
34 | import com.mylhyl.circledialog.CircleDialog; | 34 | import com.mylhyl.circledialog.CircleDialog; |
35 | import com.mylhyl.circledialog.callback.ConfigInput; | 35 | import com.mylhyl.circledialog.callback.ConfigInput; |
36 | import com.mylhyl.circledialog.params.InputParams; | 36 | import com.mylhyl.circledialog.params.InputParams; |
37 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 37 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
38 | import com.zaaach.toprightmenu.MenuItem; | 38 | import com.zaaach.toprightmenu.MenuItem; |
39 | import com.zaaach.toprightmenu.TopRightMenu; | 39 | import com.zaaach.toprightmenu.TopRightMenu; |
40 | 40 | ||
41 | import java.io.File; | 41 | import java.io.File; |
42 | import java.util.ArrayList; | 42 | import java.util.ArrayList; |
43 | import java.util.List; | 43 | import java.util.List; |
44 | 44 | ||
45 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 45 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
46 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; | 46 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; |
47 | private TextView tv_edit_presoninfo, tv_sign, | 47 | private TextView tv_edit_presoninfo, tv_sign, |
48 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 48 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
49 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; | 49 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; |
50 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; | 50 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; |
51 | private TopRightMenu mTopRightMenu; | 51 | private TopRightMenu mTopRightMenu; |
52 | private boolean showIcon = true; | 52 | private boolean showIcon = true; |
53 | private boolean dimBg = true; | 53 | private boolean dimBg = true; |
54 | private boolean needAnim = true; | 54 | private boolean needAnim = true; |
55 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 55 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
56 | private static final int REQUEST_CODE_ALBUM = 2; | 56 | private static final int REQUEST_CODE_ALBUM = 2; |
57 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 57 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
58 | SimpleDraweeView mSimpleDraweeView; | 58 | SimpleDraweeView mSimpleDraweeView; |
59 | private File file; | 59 | private File file; |
60 | private Uri uri; | 60 | private Uri uri; |
61 | 61 | ||
62 | @Override | 62 | @Override |
63 | protected void onCreate(Bundle savedInstanceState) { | 63 | protected void onCreate(Bundle savedInstanceState) { |
64 | super.onCreate(savedInstanceState); | 64 | super.onCreate(savedInstanceState); |
65 | Fresco.initialize(this); | 65 | Fresco.initialize(this); |
66 | setContentView(R.layout.activity_main); | 66 | setContentView(R.layout.activity_main); |
67 | initView(); | 67 | initView(); |
68 | initData(); | 68 | initData(); |
69 | initLister(); | 69 | initLister(); |
70 | } | 70 | } |
71 | 71 | ||
72 | private void initView() { | 72 | private void initView() { |
73 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 73 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
74 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); | 74 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); |
75 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); | 75 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); |
76 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 76 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
77 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 77 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
78 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 78 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
79 | //头像 | 79 | //头像 |
80 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); | 80 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); |
81 | //初始化个人信息 | 81 | //初始化个人信息 |
82 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 82 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
83 | tv_username = (TextView) findViewById(R.id.tv_username); | 83 | tv_username = (TextView) findViewById(R.id.tv_username); |
84 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 84 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
85 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 85 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
86 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 86 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
87 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 87 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
88 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 88 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
89 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 89 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
90 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 90 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
91 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 91 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
92 | //跳转其他应用 | 92 | //跳转其他应用 |
93 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); | 93 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); |
94 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); | 94 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); |
95 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); | 95 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); |
96 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); | 96 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); |
97 | 97 | ||
98 | } | 98 | } |
99 | 99 | ||
100 | private void initData() { | 100 | private void initData() { |
101 | //加载个人信息 | 101 | //加载个人信息 |
102 | 102 | ||
103 | //初始化图片 | 103 | // //初始化图片 |
104 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 104 | // file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
105 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 105 | // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
106 | uri = Uri.fromFile(file); | 106 | // uri = Uri.fromFile(file); |
107 | } else { | 107 | // } else { |
108 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 108 | // //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
109 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 109 | // uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
110 | } | 110 | // } |
111 | 111 | ||
112 | } | 112 | } |
113 | 113 | ||
114 | private void initLister() { | 114 | private void initLister() { |
115 | iv_imformatioan.setOnClickListener(this); | 115 | iv_imformatioan.setOnClickListener(this); |
116 | iv_look_card.setOnClickListener(this); | 116 | iv_look_card.setOnClickListener(this); |
117 | tv_edit_presoninfo.setOnClickListener(this); | 117 | tv_edit_presoninfo.setOnClickListener(this); |
118 | iv_setting.setOnClickListener(this); | 118 | iv_setting.setOnClickListener(this); |
119 | iv_sign.setOnClickListener(this); | 119 | iv_sign.setOnClickListener(this); |
120 | mSimpleDraweeView.setOnClickListener(this); | 120 | mSimpleDraweeView.setOnClickListener(this); |
121 | linel_mycuoti.setOnClickListener(this); | 121 | linel_mycuoti.setOnClickListener(this); |
122 | linel_mynote.setOnClickListener(this); | 122 | linel_mynote.setOnClickListener(this); |
123 | linel_mycollege.setOnClickListener(this); | 123 | linel_mycollege.setOnClickListener(this); |
124 | linel_myclass.setOnClickListener(this); | 124 | linel_myclass.setOnClickListener(this); |
125 | 125 | ||
126 | } | 126 | } |
127 | 127 | ||
128 | @Override | 128 | @Override |
129 | public void onClick(View v) { | 129 | public void onClick(View v) { |
130 | switch (v.getId()) { | 130 | switch (v.getId()) { |
131 | case R.id.iv_imformatioan: | 131 | case R.id.iv_imformatioan: |
132 | Intent intent = new Intent(); | 132 | Intent intent = new Intent(); |
133 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 133 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
134 | startActivity(intent); | 134 | startActivity(intent); |
135 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 135 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
136 | break; | 136 | break; |
137 | case R.id.iv_look_card: | 137 | case R.id.iv_look_card: |
138 | Intent lookintent = new Intent(); | 138 | Intent lookintent = new Intent(); |
139 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 139 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
140 | startActivity(lookintent); | 140 | startActivity(lookintent); |
141 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 141 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
142 | break; | 142 | break; |
143 | case R.id.tv_edit_presoninfo: | 143 | case R.id.tv_edit_presoninfo: |
144 | Intent editintent = new Intent(); | 144 | Intent editintent = new Intent(); |
145 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 145 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
146 | startActivity(editintent); | 146 | startActivity(editintent); |
147 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 147 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
148 | break; | 148 | break; |
149 | case R.id.iv_head: | 149 | case R.id.iv_head: |
150 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 150 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
151 | break; | 151 | break; |
152 | case R.id.iv_setting: | 152 | case R.id.iv_setting: |
153 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 153 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
154 | List<MenuItem> menuItems = new ArrayList<>(); | 154 | List<MenuItem> menuItems = new ArrayList<>(); |
155 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); | 155 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); |
156 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); | 156 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); |
157 | mTopRightMenu | 157 | mTopRightMenu |
158 | .setHeight(150) //默认高度480 | 158 | .setHeight(150) //默认高度480 |
159 | .setWidth(320) //默认宽度wrap_content | 159 | .setWidth(320) //默认宽度wrap_content |
160 | .showIcon(showIcon) //显示菜单图标,默认为true | 160 | .showIcon(showIcon) //显示菜单图标,默认为true |
161 | .dimBackground(dimBg) //背景变暗,默认为true | 161 | .dimBackground(dimBg) //背景变暗,默认为true |
162 | .needAnimationStyle(needAnim) //显示动画,默认为true | 162 | .needAnimationStyle(needAnim) //显示动画,默认为true |
163 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 163 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
164 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 164 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
165 | @Override | 165 | @Override |
166 | public void onMenuItemClick(int position) { | 166 | public void onMenuItemClick(int position) { |
167 | switch (position) { | 167 | switch (position) { |
168 | case 0: | 168 | case 0: |
169 | //清除数据 | 169 | //清除数据 |
170 | Intent settingintent = new Intent(); | 170 | Intent settingintent = new Intent(); |
171 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 171 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
172 | startActivity(settingintent); | 172 | startActivity(settingintent); |
173 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 173 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
174 | break; | 174 | break; |
175 | case 1: | 175 | case 1: |
176 | Intent accontMintent = new Intent(); | 176 | Intent accontMintent = new Intent(); |
177 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 177 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
178 | startActivity(accontMintent); | 178 | startActivity(accontMintent); |
179 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 179 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | }) | 183 | }) |
184 | .addMenuList(menuItems) | 184 | .addMenuList(menuItems) |
185 | .showAsDropDown(iv_setting, -250, 0); | 185 | .showAsDropDown(iv_setting, -250, 0); |
186 | break; | 186 | break; |
187 | case R.id.iv_sign: | 187 | case R.id.iv_sign: |
188 | new CircleDialog.Builder(this) | 188 | new CircleDialog.Builder(this) |
189 | .setCanceledOnTouchOutside(false) | 189 | .setCanceledOnTouchOutside(false) |
190 | .setCancelable(true) | 190 | .setCancelable(true) |
191 | .setTitle("个性签名") | 191 | .setTitle("个性签名") |
192 | .setInputHint("请输入个性签名") | 192 | .setInputHint("请输入个性签名") |
193 | .setWidth(0.5f) | 193 | .setWidth(0.5f) |
194 | .configInput(new ConfigInput() { | 194 | .configInput(new ConfigInput() { |
195 | @Override | 195 | @Override |
196 | public void onConfig(InputParams params) { | 196 | public void onConfig(InputParams params) { |
197 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 197 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
198 | } | 198 | } |
199 | }) | 199 | }) |
200 | .setNegative("取消", null) | 200 | .setNegative("取消", null) |
201 | .setPositiveInput("确定", new OnInputClickListener() { | 201 | .setPositiveInput("确定", new OnInputClickListener() { |
202 | @Override | 202 | @Override |
203 | public void onClick(String text, View v) { | 203 | public void onClick(String text, View v) { |
204 | if (text.equals("")) { | 204 | if (text.equals("")) { |
205 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 205 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
206 | } else { | 206 | } else { |
207 | tv_sign.setText(text); | 207 | tv_sign.setText(text); |
208 | } | 208 | } |
209 | 209 | ||
210 | } | 210 | } |
211 | }) | 211 | }) |
212 | .show(); | 212 | .show(); |
213 | break; | 213 | break; |
214 | case R.id.linel_mycuoti: | 214 | case R.id.linel_mycuoti: |
215 | AlertUtils.showToast(this, "hhahahah "); | 215 | AlertUtils.showToast(this, "hhahahah "); |
216 | break; | 216 | break; |
217 | case R.id.linel_mynote: | 217 | case R.id.linel_mynote: |
218 | AlertUtils.showToast(this, "hhahahah "); | 218 | AlertUtils.showToast(this, "hhahahah "); |
219 | break; | 219 | break; |
220 | case R.id.linel_mycollege: | 220 | case R.id.linel_mycollege: |
221 | AlertUtils.showToast(this, "hhahahah "); | 221 | AlertUtils.showToast(this, "hhahahah "); |
222 | break; | 222 | break; |
223 | case R.id.linel_myclass: | 223 | case R.id.linel_myclass: |
224 | AlertUtils.showToast(this, "hhahahah "); | 224 | AlertUtils.showToast(this, "hhahahah "); |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | } | 228 | } |
229 | //回调头像监听 | 229 | //回调头像监听 |
230 | @Override | 230 | @Override |
231 | public void heard(Context context, View v) { | 231 | public void heard(Context context, View v) { |
232 | switch (v.getId()){ | 232 | switch (v.getId()){ |
233 | //选择默认图片 | 233 | //选择默认图片 |
234 | case R.id.oktakephone: | 234 | case R.id.oktakephone: |
235 | AlertUtils.showToast(this, "您选择了默认图片 "); | 235 | AlertUtils.showToast(this, "您选择了默认图片 "); |
236 | break; | 236 | break; |
237 | case R.id.canceltakephone: | 237 | case R.id.canceltakephone: |
238 | 238 | ||
239 | break; | 239 | break; |
240 | //拍摄和相册 | 240 | //拍摄和相册 |
241 | case R.id.take_pic: | 241 | case R.id.take_pic: |
242 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 242 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
243 | uploadAvatarFromPhotoRequest(); | 243 | uploadAvatarFromPhotoRequest(); |
244 | } | 244 | } |
245 | 245 | ||
246 | break; | 246 | break; |
247 | case R.id.xiangce: | 247 | case R.id.xiangce: |
248 | uploadAvatarFromAlbumRequest(); | 248 | uploadAvatarFromAlbumRequest(); |
249 | break; | 249 | break; |
250 | 250 | ||
251 | } | 251 | } |
252 | 252 | ||
253 | } | 253 | } |
254 | 254 | ||
255 | //照相 | 255 | //照相 |
256 | private void uploadAvatarFromPhotoRequest() { | 256 | private void uploadAvatarFromPhotoRequest() { |
257 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 257 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
258 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 258 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
259 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 259 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
260 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 260 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
261 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 261 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
262 | } | 262 | } |
263 | 263 | ||
264 | //选择图库 | 264 | //选择图库 |
265 | private void uploadAvatarFromAlbumRequest() { | 265 | private void uploadAvatarFromAlbumRequest() { |
266 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 266 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
267 | photoPickerIntent.setType("image/*"); | 267 | photoPickerIntent.setType("image/*"); |
268 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 268 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
269 | } | 269 | } |
270 | //回掉 | 270 | //回掉 |
271 | @Override | 271 | @Override |
272 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 272 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
273 | super.onActivityResult(requestCode, resultCode, data); | 273 | super.onActivityResult(requestCode, resultCode, data); |
274 | if (resultCode != -1) { | 274 | if (resultCode != -1) { |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 277 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
278 | Uri newUri; | 278 | Uri newUri; |
279 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 279 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
280 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 280 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
281 | } else { | 281 | } else { |
282 | newUri = data.getData(); | 282 | newUri = data.getData(); |
283 | } | 283 | } |
284 | if (newUri != null) { | 284 | if (newUri != null) { |
285 | startPhotoZoom(newUri); | 285 | startPhotoZoom(newUri); |
286 | } else { | 286 | } else { |
287 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 287 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
288 | } | 288 | } |
289 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 289 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
290 | startPhotoZoom(uri); | 290 | startPhotoZoom(uri); |
291 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 291 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
292 | uploadAvatarFromPhoto(); | 292 | uploadAvatarFromPhoto(); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | private void uploadAvatarFromPhoto() { | 296 | private void uploadAvatarFromPhoto() { |
297 | compressAndUploadAvatar(file.getPath()); | 297 | compressAndUploadAvatar(file.getPath()); |
298 | 298 | ||
299 | } | 299 | } |
300 | private void compressAndUploadAvatar(String fileSrc) { | 300 | private void compressAndUploadAvatar(String fileSrc) { |
301 | 301 | ||
302 | 302 | ||
303 | //上传到服务器 | 303 | //上传到服务器 |
304 | 304 | ||
305 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 305 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
306 | String mimeType = "image/*"; | 306 | String mimeType = "image/*"; |
307 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 307 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
308 | //String fileName = cover.getName(); | 308 | //String fileName = cover.getName(); |
309 | //HttpManager.getInstance().header(this, fileSrc); | 309 | //HttpManager.getInstance().header(this, fileSrc); |
310 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 310 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
311 | //Fresco设置圆形头像 | 311 | //Fresco设置圆形头像 |
312 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 312 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
313 | GenericDraweeHierarchy hierarchy = builder | 313 | GenericDraweeHierarchy hierarchy = builder |
314 | .setDesiredAspectRatio(1f) | 314 | .setDesiredAspectRatio(1f) |
315 | .setFailureImage(R.mipmap.blank) | 315 | .setFailureImage(R.mipmap.blank) |
316 | //圆形头像 | 316 | //圆形头像 |
317 | .setRoundingParams(RoundingParams.asCircle()) | 317 | .setRoundingParams(RoundingParams.asCircle()) |
318 | .build(); | 318 | .build(); |
319 | 319 | ||
320 | //加载本地图片 | 320 | //加载本地图片 |
321 | Uri uri = Uri.fromFile(cover); | 321 | Uri uri = Uri.fromFile(cover); |
322 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 322 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
323 | .setOldController(mSimpleDraweeView.getController()) | 323 | .setOldController(mSimpleDraweeView.getController()) |
324 | .setUri(uri) | 324 | .setUri(uri) |
325 | .build(); | 325 | .build(); |
326 | mSimpleDraweeView.setHierarchy(hierarchy); | 326 | mSimpleDraweeView.setHierarchy(hierarchy); |
327 | mSimpleDraweeView.setController(controller); | 327 | mSimpleDraweeView.setController(controller); |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | public void startPhotoZoom(Uri uri) { | 331 | public void startPhotoZoom(Uri uri) { |
332 | Intent intent = new Intent("com.android.camera.action.CROP"); | 332 | Intent intent = new Intent("com.android.camera.action.CROP"); |
333 | intent.setDataAndType(uri, "image/*"); | 333 | intent.setDataAndType(uri, "image/*"); |
334 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 334 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
335 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 335 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
336 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 336 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
337 | intent.putExtra("aspectY", 1);// x:y=1:1 | 337 | intent.putExtra("aspectY", 1);// x:y=1:1 |
338 | // intent.putExtra("outputX", 400);//图片输出大小 | 338 | // intent.putExtra("outputX", 400);//图片输出大小 |
339 | // intent.putExtra("outputY", 400); | 339 | // intent.putExtra("outputY", 400); |
340 | intent.putExtra("output", Uri.fromFile(file)); | 340 | intent.putExtra("output", Uri.fromFile(file)); |
341 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 341 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
342 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 342 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
343 | } | 343 | } |
344 | 344 | ||
345 | @Override | 345 | @Override |
346 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 346 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
347 | switch (requestCode) { | 347 | switch (requestCode) { |
348 | 348 | ||
349 | case PermissionUtil.REQUEST_SHOWCAMERA: | 349 | case PermissionUtil.REQUEST_SHOWCAMERA: |
350 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 350 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
351 | // Permission Granted | 351 | // Permission Granted |
352 | uploadAvatarFromPhotoRequest(); | 352 | uploadAvatarFromPhotoRequest(); |
353 | 353 | ||
354 | } else { | 354 | } else { |
355 | if (!SharedPreferenceMark.getHasShowCamera()) { | 355 | if (!SharedPreferenceMark.getHasShowCamera()) { |
356 | SharedPreferenceMark.setHasShowCamera(true); | 356 | SharedPreferenceMark.setHasShowCamera(true); |
357 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 357 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
358 | 358 | ||
359 | } else { | 359 | } else { |
360 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 360 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
361 | .show(); | 361 | .show(); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | break; | 364 | break; |
365 | default: | 365 | default: |
366 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 366 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 |
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.AdapterView; | 9 | import android.widget.AdapterView; |
10 | import android.widget.Button; | 10 | import android.widget.Button; |
11 | import android.widget.EditText; | 11 | import android.widget.EditText; |
12 | import android.widget.TextView; | 12 | import android.widget.TextView; |
13 | 13 | ||
14 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
15 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 15 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
16 | import com.hjx.personalcenter.customdialog.CountryDialog; | 16 | import com.hjx.personalcenter.customdialog.CountryDialog; |
17 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 17 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
18 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 18 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
19 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 19 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
20 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
21 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 21 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
22 | import com.hjx.personalcenter.model.CityInfo; | ||
23 | import com.hjx.personalcenter.model.CountyInfo; | ||
24 | import com.hjx.personalcenter.model.GradeInfo; | ||
25 | import com.hjx.personalcenter.model.ProvinceInfo; | ||
26 | import com.hjx.personalcenter.model.SchoolInfo; | ||
22 | import com.hjx.personalcenter.util.AlertUtils; | 27 | import com.hjx.personalcenter.util.AlertUtils; |
23 | 28 | ||
29 | import java.util.ArrayList; | ||
30 | |||
24 | /**填写注册信息 熊巍 | 31 | /**填写注册信息 熊巍 |
25 | * Created by h on 2017/8/9. | 32 | * Created by h on 2017/8/9. |
26 | */ | 33 | */ |
27 | 34 | ||
28 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.CallBack { | 35 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.GradeCallBack,DialogCallBack.ProvincesCallBack |
36 | ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack,DialogCallBack.SchoolCallBack{ | ||
29 | private EditText et_username; | 37 | private EditText et_username; |
30 | private TextView et_region,et_grade,et_school; | 38 | private TextView et_region,et_grade,et_school; |
31 | private Button btn_ok; | 39 | private Button btn_ok; |
32 | 40 | ||
33 | @Override | 41 | @Override |
34 | protected void onCreate(Bundle savedInstanceState) { | 42 | protected void onCreate(Bundle savedInstanceState) { |
35 | super.onCreate(savedInstanceState); | 43 | super.onCreate(savedInstanceState); |
36 | setContentView(R.layout.activity_registerinfo); | 44 | setContentView(R.layout.activity_registerinfo); |
37 | initView(); | 45 | initView(); |
38 | initData(); | 46 | initData(); |
39 | initLister(); | 47 | initLister(); |
40 | } | 48 | } |
41 | 49 | ||
42 | private void initView() { | 50 | private void initView() { |
43 | et_username = (EditText) findViewById(R.id.et_username); | 51 | et_username = (EditText) findViewById(R.id.et_username); |
44 | et_region = (TextView) findViewById(R.id.et_region); | 52 | et_region = (TextView) findViewById(R.id.et_region); |
45 | et_grade = (TextView) findViewById(R.id.et_grade); | 53 | et_grade = (TextView) findViewById(R.id.et_grade); |
46 | et_school = (TextView) findViewById(R.id.et_school); | 54 | et_school = (TextView) findViewById(R.id.et_school); |
47 | btn_ok = (Button) findViewById(R.id.btn_ok); | 55 | btn_ok = (Button) findViewById(R.id.btn_ok); |
48 | 56 | ||
49 | 57 | ||
50 | } | 58 | } |
51 | 59 | ||
52 | private void initData() { | 60 | private void initData() { |
53 | 61 | ||
54 | } | 62 | } |
55 | 63 | ||
56 | private void initLister() { | 64 | private void initLister() { |
57 | et_region.setOnClickListener(this); | 65 | et_region.setOnClickListener(this); |
58 | et_grade.setOnClickListener(this); | 66 | et_grade.setOnClickListener(this); |
59 | et_school.setOnClickListener(this); | 67 | et_school.setOnClickListener(this); |
60 | btn_ok.setOnClickListener(this); | 68 | btn_ok.setOnClickListener(this); |
61 | 69 | ||
62 | 70 | ||
63 | } | 71 | } |
64 | 72 | ||
65 | @Override | 73 | @Override |
66 | public void onClick(View v) { | 74 | public void onClick(View v) { |
67 | String register1 = et_username.getText().toString().trim(); | 75 | String register1 = et_username.getText().toString().trim(); |
68 | String register2 = et_region.getText().toString().trim(); | 76 | String register2 = et_region.getText().toString().trim(); |
69 | String register3 = et_grade.getText().toString().trim(); | 77 | String register3 = et_grade.getText().toString().trim(); |
70 | String register4 = et_school.getText().toString().trim(); | 78 | String register4 = et_school.getText().toString().trim(); |
71 | switch (v.getId()){ | 79 | switch (v.getId()){ |
72 | case R.id.et_region: | 80 | case R.id.et_region: |
73 | choiseregion(); | 81 | choiseregion(); |
74 | break; | 82 | break; |
75 | case R.id.et_grade: | 83 | case R.id.et_grade: |
76 | choisegrade(); | 84 | choisegrade(); |
77 | break; | 85 | break; |
78 | case R.id.et_school: | 86 | case R.id.et_school: |
79 | // if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | 87 | // if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
80 | // AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); | 88 | // AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); |
81 | // return; | 89 | // return; |
82 | // }else { | 90 | // }else { |
83 | choiseschool(); | 91 | choiseschool(); |
84 | // } | 92 | // } |
85 | 93 | ||
86 | break; | 94 | break; |
87 | case R.id.btn_ok: | 95 | case R.id.btn_ok: |
88 | if (TextUtils.isEmpty(register1)||TextUtils.isEmpty(register4) || | 96 | if (TextUtils.isEmpty(register1)||TextUtils.isEmpty(register4) || |
89 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | 97 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
90 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); | 98 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); |
91 | return; | 99 | return; |
92 | }else{ | 100 | }else{ |
93 | Intent intent = new Intent(); | 101 | Intent intent = new Intent(); |
94 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 102 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); |
95 | startActivity(intent); | 103 | startActivity(intent); |
96 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 104 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
97 | } | 105 | } |
98 | 106 | ||
99 | break; | 107 | break; |
100 | } | 108 | } |
101 | 109 | ||
102 | } | 110 | } |
103 | 111 | ||
104 | //选择地区 | 112 | //选择地区 |
105 | private void choiseregion() { | 113 | private void choiseregion() { |
106 | ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog"); | 114 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
107 | 115 | ||
108 | } | 116 | } |
109 | //选择年级 | 117 | //选择年级 |
110 | private void choisegrade() { | 118 | private void choisegrade() { |
111 | GradeListDialog.getInstance(this).show(getSupportFragmentManager(), "GradeListDialog"); | 119 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); |
112 | 120 | ||
113 | } | 121 | } |
114 | //选择学校 | 122 | //选择学校 |
115 | private void choiseschool() { | 123 | private void choiseschool() { |
116 | SchoolListDialog.getInstance(this).show(getSupportFragmentManager(), "SchoolListDialog"); | 124 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); |
117 | 125 | ||
118 | } | 126 | } |
119 | 127 | ||
120 | 128 | ||
121 | @Override | 129 | @Override |
122 | public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id,int type) { | 130 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
123 | View View = parent.getChildAt(position); | 131 | String regionName = data.get(position).getRegionName(); |
124 | TextView Tv = (TextView)View.findViewById(R.id.list_items); | 132 | SaveParam.getInstance().saveLoginParam(this,"sheng",regionName); |
125 | switch (type){ | 133 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); |
126 | 134 | ||
127 | case 1: | ||
128 | SaveParam.getInstance().saveLoginParam(this,"sheng",Tv.getText().toString()); | ||
129 | CitysListDialog.getInstance(this).show(getSupportFragmentManager(), "CitysListDialog"); | ||
130 | break; | ||
131 | case 2: | ||
132 | String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); | ||
133 | SaveParam.getInstance().saveLoginParam(this,"shi",Tv.getText().toString()); | ||
134 | CountryDialog.getInstance(this).show(getSupportFragmentManager(), "CountryDialog"); | ||
135 | et_region.setText(""); | ||
136 | et_region.setText(provice+Tv.getText().toString()); | ||
137 | break; | ||
138 | case 3: | ||
139 | String provices = SaveParam.getInstance().getLoginParam(this,"sheng"); | ||
140 | String citys = SaveParam.getInstance().getLoginParam(this,"shi"); | ||
141 | et_region.setText(""); | ||
142 | et_region.setText(provices+citys+Tv.getText().toString()); | ||
143 | break; | ||
144 | case 4: | ||
145 | et_school.setText(Tv.getText().toString()); | ||
146 | break; | ||
147 | case 5: | ||
148 | et_grade.setText(Tv.getText().toString()); | ||
149 | break; | ||
150 | } | ||
151 | 135 | ||
152 | } | 136 | } |
153 | @Override | 137 | @Override |
154 | public boolean onKeyUp(int keyCode, KeyEvent event) { | 138 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
155 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 139 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
156 | finish(); | 140 | finish(); |
157 | 141 | ||
158 | } | 142 | } |
159 | return super.onKeyUp(keyCode, event); | 143 | return super.onKeyUp(keyCode, event); |
160 | } | 144 | } |
145 | |||
146 | @Override | ||
147 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | ||
148 | String regionName = data.get(position).getName(); | ||
149 | et_grade.setText(regionName); | ||
150 | |||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | ||
155 | String regionName = data.get(position).getRegionName(); | ||
156 | String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); | ||
157 | SaveParam.getInstance().saveLoginParam(this,"shi",regionName); |
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.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | 6 | import android.os.Handler; |
7 | import android.os.Message; | 7 | import android.os.Message; |
8 | import android.view.Gravity; | 8 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
13 | import android.widget.ListView; | 13 | import android.widget.ListView; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.adapter.CitysAdapter; | 16 | import com.hjx.personalcenter.adapter.CitysAdapter; |
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.interfaces.DialogCallBack; | 20 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
21 | import com.hjx.personalcenter.model.CityInfo; | 21 | import com.hjx.personalcenter.model.CityInfo; |
22 | import com.mylhyl.circledialog.BaseCircleDialog; | 22 | import com.mylhyl.circledialog.BaseCircleDialog; |
23 | import com.mylhyl.circledialog.res.values.CircleDimen; | 23 | import com.mylhyl.circledialog.res.values.CircleDimen; |
24 | 24 | ||
25 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
26 | import java.util.List; | 26 | import java.util.List; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * 自定义市级列表对话框 | 29 | * 自定义市级列表对话框 |
30 | * Created by h on 2017/8/10. | 30 | * Created by h on 2017/8/10. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 33 | public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
34 | private CitysAdapter listadapter; | 34 | private CitysAdapter listadapter; |
35 | private ListView listView; | 35 | private ListView listView; |
36 | private DialogCallBack.CallBack mCallBack; | 36 | private DialogCallBack.CitysCallBack mCallBack; |
37 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); | 37 | private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>(); |
38 | public CitysListDialog(DialogCallBack.CallBack callBack) { | 38 | public CitysListDialog(DialogCallBack.CitysCallBack callBack) { |
39 | this.mCallBack = callBack; | 39 | this.mCallBack = callBack; |
40 | } | 40 | } |
41 | public static CitysListDialog getInstance(DialogCallBack.CallBack callBack) { | 41 | public static CitysListDialog getInstance(DialogCallBack.CitysCallBack callBack) { |
42 | CitysListDialog dialogFragment = new CitysListDialog(callBack); | 42 | CitysListDialog dialogFragment = new CitysListDialog(callBack); |
43 | dialogFragment.setCanceledBack(true); | 43 | dialogFragment.setCanceledBack(true); |
44 | dialogFragment.setCanceledOnTouchOutside(true); | 44 | dialogFragment.setCanceledOnTouchOutside(true); |
45 | dialogFragment.setRadius(CircleDimen.RADIUS); | 45 | dialogFragment.setRadius(CircleDimen.RADIUS); |
46 | dialogFragment.setWidth(0.5f); | 46 | dialogFragment.setWidth(0.5f); |
47 | dialogFragment.setGravity(Gravity.CENTER); | 47 | dialogFragment.setGravity(Gravity.CENTER); |
48 | dialogFragment.setBackgroundColor(Color.WHITE); | 48 | dialogFragment.setBackgroundColor(Color.WHITE); |
49 | return dialogFragment; | 49 | return dialogFragment; |
50 | } | 50 | } |
51 | Handler handler = new Handler(){ | 51 | Handler handler = new Handler(){ |
52 | @Override | 52 | @Override |
53 | public void handleMessage(Message msg) { | 53 | public void handleMessage(Message msg) { |
54 | super.handleMessage(msg); | 54 | super.handleMessage(msg); |
55 | switch (msg.what){ | 55 | switch (msg.what){ |
56 | case HttpCode.CITYS: | 56 | case HttpCode.CITYS: |
57 | data.clear(); | 57 | data.clear(); |
58 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); | 58 | data.addAll( (List<CityInfo.CitiesBean>)msg.obj); |
59 | listadapter.notifyDataSetChanged(); | 59 | listadapter.notifyDataSetChanged(); |
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | }; | 63 | }; |
64 | 64 | ||
65 | @Override | 65 | @Override |
66 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 66 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
67 | return inflater.inflate(R.layout.custom_adilog_cityslist, container, false); | 67 | return inflater.inflate(R.layout.custom_adilog_cityslist, container, false); |
68 | } | 68 | } |
69 | 69 | ||
70 | @Override | 70 | @Override |
71 | public void onActivityCreated(Bundle savedInstanceState) { | 71 | public void onActivityCreated(Bundle savedInstanceState) { |
72 | super.onActivityCreated(savedInstanceState); | 72 | super.onActivityCreated(savedInstanceState); |
73 | listView = (ListView) getView().findViewById(R.id.listadapter); | 73 | listView = (ListView) getView().findViewById(R.id.listadapter); |
74 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); | 74 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); |
75 | listadapter = new CitysAdapter(data,getActivity()); | 75 | listadapter = new CitysAdapter(data,getActivity()); |
76 | listView.setAdapter(listadapter); | 76 | listView.setAdapter(listadapter); |
77 | listView.setOnItemClickListener(this); | 77 | listView.setOnItemClickListener(this); |
78 | try { | 78 | try { |
79 | long a = Long.parseLong(citys); | 79 | long a = Long.parseLong(citys); |
80 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); | 80 | HttpManager.getInstance().cityinfo(getActivity(),a,handler); |
81 | } catch (NumberFormatException e) { | 81 | } catch (NumberFormatException e) { |
82 | e.printStackTrace(); | 82 | e.printStackTrace(); |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | } | 86 | } |
87 | 87 | ||
88 | @Override | 88 | @Override |
89 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 89 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
90 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); | 90 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); |
91 | mCallBack.provinceOnItemClick(parent,view,position,id,2); | 91 | mCallBack.province1OnItemClick(data,position,2); |
92 | dismiss(); | 92 | dismiss(); |
93 | 93 | ||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 |
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.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | 6 | import android.os.Handler; |
7 | import android.os.Message; | 7 | import android.os.Message; |
8 | import android.view.Gravity; | 8 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
13 | import android.widget.ListView; | 13 | import android.widget.ListView; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.adapter.CountryAdapter; | 16 | import com.hjx.personalcenter.adapter.CountryAdapter; |
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.interfaces.DialogCallBack; | 20 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
21 | import com.hjx.personalcenter.model.CountyInfo; | 21 | import com.hjx.personalcenter.model.CountyInfo; |
22 | import com.mylhyl.circledialog.BaseCircleDialog; | 22 | import com.mylhyl.circledialog.BaseCircleDialog; |
23 | import com.mylhyl.circledialog.res.values.CircleDimen; | 23 | import com.mylhyl.circledialog.res.values.CircleDimen; |
24 | 24 | ||
25 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
26 | import java.util.List; | 26 | import java.util.List; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Created by wei on 2017/8/21. | 29 | * Created by wei on 2017/8/21. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 32 | public class CountryDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
33 | private CountryAdapter listadapter; | 33 | private CountryAdapter listadapter; |
34 | private ListView listView; | 34 | private ListView listView; |
35 | private DialogCallBack.CallBack mCallBack; | 35 | private DialogCallBack.CountryCallBack mCallBack; |
36 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); | 36 | private ArrayList<CountyInfo.CountiesBean> data = new ArrayList<>(); |
37 | public CountryDialog(DialogCallBack.CallBack callBack) { | 37 | public CountryDialog(DialogCallBack.CountryCallBack callBack) { |
38 | this.mCallBack = callBack; | 38 | this.mCallBack = callBack; |
39 | } | 39 | } |
40 | public static CountryDialog getInstance(DialogCallBack.CallBack callBack) { | 40 | public static CountryDialog getInstance(DialogCallBack.CountryCallBack callBack) { |
41 | CountryDialog dialogFragment = new CountryDialog(callBack); | 41 | CountryDialog dialogFragment = new CountryDialog(callBack); |
42 | dialogFragment.setCanceledBack(true); | 42 | dialogFragment.setCanceledBack(true); |
43 | dialogFragment.setCanceledOnTouchOutside(true); | 43 | dialogFragment.setCanceledOnTouchOutside(true); |
44 | dialogFragment.setRadius(CircleDimen.RADIUS); | 44 | dialogFragment.setRadius(CircleDimen.RADIUS); |
45 | dialogFragment.setWidth(0.5f); | 45 | dialogFragment.setWidth(0.5f); |
46 | dialogFragment.setGravity(Gravity.CENTER); | 46 | dialogFragment.setGravity(Gravity.CENTER); |
47 | dialogFragment.setBackgroundColor(Color.WHITE); | 47 | dialogFragment.setBackgroundColor(Color.WHITE); |
48 | return dialogFragment; | 48 | return dialogFragment; |
49 | } | 49 | } |
50 | Handler handler = new Handler(){ | 50 | Handler handler = new Handler(){ |
51 | @Override | 51 | @Override |
52 | public void handleMessage(Message msg) { | 52 | public void handleMessage(Message msg) { |
53 | super.handleMessage(msg); | 53 | super.handleMessage(msg); |
54 | switch (msg.what){ | 54 | switch (msg.what){ |
55 | case HttpCode.COUNTRY: | 55 | case HttpCode.COUNTRY: |
56 | 56 | ||
57 | data.clear(); | 57 | data.clear(); |
58 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); | 58 | data.addAll( (List<CountyInfo.CountiesBean>)msg.obj); |
59 | listadapter.notifyDataSetChanged(); | 59 | listadapter.notifyDataSetChanged(); |
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | }; | 63 | }; |
64 | 64 | ||
65 | @Override | 65 | @Override |
66 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 66 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
67 | return inflater.inflate(R.layout.custom_adilog_countrylist, container, false); | 67 | return inflater.inflate(R.layout.custom_adilog_countrylist, container, false); |
68 | } | 68 | } |
69 | 69 | ||
70 | @Override | 70 | @Override |
71 | public void onActivityCreated(Bundle savedInstanceState) { | 71 | public void onActivityCreated(Bundle savedInstanceState) { |
72 | super.onActivityCreated(savedInstanceState); | 72 | super.onActivityCreated(savedInstanceState); |
73 | listView = (ListView) getView().findViewById(R.id.listadapter); | 73 | listView = (ListView) getView().findViewById(R.id.listadapter); |
74 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 74 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); |
75 | listadapter = new CountryAdapter(data,getActivity()); | 75 | listadapter = new CountryAdapter(data,getActivity()); |
76 | listView.setAdapter(listadapter); | 76 | listView.setAdapter(listadapter); |
77 | listView.setOnItemClickListener(this); | 77 | listView.setOnItemClickListener(this); |
78 | try { | 78 | try { |
79 | int a = Integer.parseInt(citys); | 79 | int a = Integer.parseInt(citys); |
80 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); | 80 | HttpManager.getInstance().countyinfo(getActivity(),a,handler); |
81 | } catch (NumberFormatException e) { | 81 | } catch (NumberFormatException e) { |
82 | e.printStackTrace(); | 82 | e.printStackTrace(); |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | } | 86 | } |
87 | 87 | ||
88 | @Override | 88 | @Override |
89 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 89 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
90 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); | 90 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CITYS, ""+data.get(position).getRegionId()); |
91 | mCallBack.provinceOnItemClick(parent,view,position,id,3); | 91 | mCallBack.province2OnItemClick(data,position,3); |
92 | dismiss(); | 92 | dismiss(); |
93 | 93 | ||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | 6 | import android.os.Handler; |
7 | import android.os.Message; | 7 | import android.os.Message; |
8 | import android.view.Gravity; | 8 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
13 | import android.widget.ListView; | 13 | import android.widget.ListView; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.adapter.GrandeAdapter; | 16 | import com.hjx.personalcenter.adapter.GrandeAdapter; |
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.interfaces.DialogCallBack; | 20 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
21 | import com.hjx.personalcenter.model.GradeInfo; | 21 | import com.hjx.personalcenter.model.GradeInfo; |
22 | import com.mylhyl.circledialog.BaseCircleDialog; | 22 | import com.mylhyl.circledialog.BaseCircleDialog; |
23 | import com.mylhyl.circledialog.res.values.CircleDimen; | 23 | import com.mylhyl.circledialog.res.values.CircleDimen; |
24 | 24 | ||
25 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
26 | import java.util.List; | 26 | import java.util.List; |
27 | 27 | ||
28 | /**自定义年级列表对话框 | 28 | /**自定义年级列表对话框 |
29 | * Created by h on 2017/8/10. | 29 | * Created by h on 2017/8/10. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 32 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
33 | private GrandeAdapter listadapter; | 33 | private GrandeAdapter listadapter; |
34 | private ListView listView; | 34 | private ListView listView; |
35 | ArrayList<GradeInfo.DataBean.ChildrenBean> data = new ArrayList<>(); | 35 | ArrayList<GradeInfo.DataBean.ChildrenBean> data = new ArrayList<>(); |
36 | private DialogCallBack.CallBack mCallBack; | 36 | private DialogCallBack.GradeCallBack mCallBack; |
37 | public GradeListDialog(DialogCallBack.CallBack callBack) { | 37 | public GradeListDialog(DialogCallBack.GradeCallBack callBack) { |
38 | this.mCallBack = callBack; | 38 | this.mCallBack = callBack; |
39 | } | 39 | } |
40 | public static GradeListDialog getInstance(DialogCallBack.CallBack callBack) { | 40 | public static GradeListDialog getInstance(DialogCallBack.GradeCallBack callBack) { |
41 | GradeListDialog dialogFragment = new GradeListDialog(callBack); | 41 | GradeListDialog dialogFragment = new GradeListDialog(callBack); |
42 | dialogFragment.setCanceledBack(true); | 42 | dialogFragment.setCanceledBack(true); |
43 | dialogFragment.setCanceledOnTouchOutside(true); | 43 | dialogFragment.setCanceledOnTouchOutside(true); |
44 | dialogFragment.setRadius(CircleDimen.RADIUS); | 44 | dialogFragment.setRadius(CircleDimen.RADIUS); |
45 | dialogFragment.setWidth(0.5f); | 45 | dialogFragment.setWidth(0.5f); |
46 | dialogFragment.setGravity(Gravity.CENTER); | 46 | dialogFragment.setGravity(Gravity.CENTER); |
47 | dialogFragment.setBackgroundColor(Color.WHITE); | 47 | dialogFragment.setBackgroundColor(Color.WHITE); |
48 | return dialogFragment; | 48 | return dialogFragment; |
49 | } | 49 | } |
50 | Handler handler = new Handler(){ | 50 | Handler handler = new Handler(){ |
51 | @Override | 51 | @Override |
52 | public void handleMessage(Message msg) { | 52 | public void handleMessage(Message msg) { |
53 | super.handleMessage(msg); | 53 | super.handleMessage(msg); |
54 | switch (msg.what){ | 54 | switch (msg.what){ |
55 | case HttpCode.GRADER: | 55 | case HttpCode.GRADER: |
56 | data.clear(); | 56 | data.clear(); |
57 | data.addAll( (List<GradeInfo.DataBean.ChildrenBean>)msg.obj); | 57 | data.addAll( (List<GradeInfo.DataBean.ChildrenBean>)msg.obj); |
58 | listadapter.notifyDataSetChanged(); | 58 | listadapter.notifyDataSetChanged(); |
59 | break; | 59 | break; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | }; | 62 | }; |
63 | @Override | 63 | @Override |
64 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 64 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
65 | 65 | ||
66 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); | 66 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); |
67 | } | 67 | } |
68 | @Override | 68 | @Override |
69 | public void onActivityCreated(Bundle savedInstanceState) { | 69 | public void onActivityCreated(Bundle savedInstanceState) { |
70 | super.onActivityCreated(savedInstanceState); | 70 | super.onActivityCreated(savedInstanceState); |
71 | listView = (ListView) getView().findViewById(R.id.listadapter); | 71 | listView = (ListView) getView().findViewById(R.id.listadapter); |
72 | listadapter = new GrandeAdapter(data,getActivity()); | 72 | listadapter = new GrandeAdapter(data,getActivity()); |
73 | listView.setAdapter(listadapter); | 73 | listView.setAdapter(listadapter); |
74 | listView.setOnItemClickListener(this); | 74 | listView.setOnItemClickListener(this); |
75 | HttpManager.getInstance().getgrade(getActivity(),handler); | 75 | HttpManager.getInstance().getgrade(getActivity(),handler); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | @Override | 79 | @Override |
80 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 80 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
81 | 81 | ||
82 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.GRADENS, ""+data.get(position).getId()); | 82 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.GRADENS, ""+data.get(position).getId()); |
83 | mCallBack.provinceOnItemClick(parent,view,position,id,5); | 83 | mCallBack.province3OnItemClick(data,position,5); |
84 | dismiss(); | 84 | dismiss(); |
85 | 85 | ||
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 |
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.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | 6 | import android.os.Handler; |
7 | import android.os.Message; | 7 | import android.os.Message; |
8 | import android.view.Gravity; | 8 | import android.view.Gravity; |
9 | import android.view.LayoutInflater; | 9 | import android.view.LayoutInflater; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
12 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
13 | import android.widget.ListView; | 13 | import android.widget.ListView; |
14 | 14 | ||
15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
16 | import com.hjx.personalcenter.adapter.ProvincesAdapter; | 16 | import com.hjx.personalcenter.adapter.ProvincesAdapter; |
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.interfaces.DialogCallBack; | 20 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
21 | import com.hjx.personalcenter.model.ProvinceInfo; | 21 | import com.hjx.personalcenter.model.ProvinceInfo; |
22 | import com.mylhyl.circledialog.BaseCircleDialog; | 22 | import com.mylhyl.circledialog.BaseCircleDialog; |
23 | import com.mylhyl.circledialog.res.values.CircleDimen; | 23 | import com.mylhyl.circledialog.res.values.CircleDimen; |
24 | 24 | ||
25 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
26 | import java.util.List; | 26 | import java.util.List; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * 自定义年级列表对话框 | 29 | * 自定义年级列表对话框 |
30 | * Created by h on 2017/8/10. | 30 | * Created by h on 2017/8/10. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 33 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
34 | private ProvincesAdapter listadapter; | 34 | private ProvincesAdapter listadapter; |
35 | private ListView listView; | 35 | private ListView listView; |
36 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); | 36 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); |
37 | 37 | ||
38 | private DialogCallBack.CallBack mCallBack; | 38 | private DialogCallBack.ProvincesCallBack mCallBack; |
39 | 39 | ||
40 | Handler handler = new Handler(){ | 40 | Handler handler = new Handler(){ |
41 | @Override | 41 | @Override |
42 | public void handleMessage(Message msg) { | 42 | public void handleMessage(Message msg) { |
43 | super.handleMessage(msg); | 43 | super.handleMessage(msg); |
44 | switch (msg.what){ | 44 | switch (msg.what){ |
45 | case HttpCode.PROVICES: | 45 | case HttpCode.PROVICES: |
46 | data.clear(); | 46 | data.clear(); |
47 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); | 47 | data.addAll( (List<ProvinceInfo.ProvincesBean>)msg.obj); |
48 | listadapter.notifyDataSetChanged(); | 48 | listadapter.notifyDataSetChanged(); |
49 | 49 | ||
50 | break; | 50 | break; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | }; | 53 | }; |
54 | public ProvinceListDialog(DialogCallBack.CallBack callBack) { | 54 | public ProvinceListDialog(DialogCallBack.ProvincesCallBack callBack) { |
55 | this.mCallBack = callBack; | 55 | this.mCallBack = callBack; |
56 | } | 56 | } |
57 | 57 | ||
58 | public static ProvinceListDialog getInstance(DialogCallBack.CallBack callBack) { | 58 | public static ProvinceListDialog getInstance(DialogCallBack.ProvincesCallBack callBack) { |
59 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); | 59 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); |
60 | dialogFragment.setCanceledBack(true); | 60 | dialogFragment.setCanceledBack(true); |
61 | dialogFragment.setCanceledOnTouchOutside(true); | 61 | dialogFragment.setCanceledOnTouchOutside(true); |
62 | dialogFragment.setRadius(CircleDimen.RADIUS); | 62 | dialogFragment.setRadius(CircleDimen.RADIUS); |
63 | dialogFragment.setWidth(0.5f); | 63 | dialogFragment.setWidth(0.5f); |
64 | dialogFragment.setGravity(Gravity.CENTER); | 64 | dialogFragment.setGravity(Gravity.CENTER); |
65 | dialogFragment.setBackgroundColor(Color.WHITE); | 65 | dialogFragment.setBackgroundColor(Color.WHITE); |
66 | return dialogFragment; | 66 | return dialogFragment; |
67 | } | 67 | } |
68 | 68 | ||
69 | @Override | 69 | @Override |
70 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 70 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
71 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 71 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
72 | } | 72 | } |
73 | 73 | ||
74 | @Override | 74 | @Override |
75 | public void onActivityCreated(Bundle savedInstanceState) { | 75 | public void onActivityCreated(Bundle savedInstanceState) { |
76 | super.onActivityCreated(savedInstanceState); | 76 | super.onActivityCreated(savedInstanceState); |
77 | listView = (ListView) getView().findViewById(R.id.listadapter); | 77 | listView = (ListView) getView().findViewById(R.id.listadapter); |
78 | listadapter = new ProvincesAdapter(data,getActivity()); | 78 | listadapter = new ProvincesAdapter(data,getActivity()); |
79 | listView.setAdapter(listadapter); | 79 | listView.setAdapter(listadapter); |
80 | listView.setOnItemClickListener(this); | 80 | listView.setOnItemClickListener(this); |
81 | HttpManager.getInstance().provices(getActivity(),handler); | 81 | HttpManager.getInstance().provices(getActivity(),handler); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | @Override | 85 | @Override |
86 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 86 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
87 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); | 87 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); |
88 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); | 88 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.PROVINCES, ""+data.get(position).getRegionId()); |
89 | mCallBack.provinceOnItemClick(parent,view,position,id,1); | 89 | mCallBack.provinceOnItemClick(data,position,1); |
90 | dismiss(); | 90 | dismiss(); |
91 | 91 | ||
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 |
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.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | 6 | import android.os.Handler; |
7 | import android.os.Message; | 7 | import android.os.Message; |
8 | import android.text.Editable; | 8 | import android.text.Editable; |
9 | import android.text.TextWatcher; | 9 | import android.text.TextWatcher; |
10 | import android.view.Gravity; | 10 | import android.view.Gravity; |
11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
12 | import android.view.View; | 12 | import android.view.View; |
13 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
14 | import android.widget.AdapterView; | 14 | import android.widget.AdapterView; |
15 | import android.widget.EditText; | 15 | import android.widget.EditText; |
16 | import android.widget.ListView; | 16 | import android.widget.ListView; |
17 | 17 | ||
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.adapter.SchoolAdapter; | 19 | import com.hjx.personalcenter.adapter.SchoolAdapter; |
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.interfaces.DialogCallBack; | 23 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
24 | import com.hjx.personalcenter.model.SchoolInfo; | 24 | import com.hjx.personalcenter.model.SchoolInfo; |
25 | import com.mylhyl.circledialog.BaseCircleDialog; | 25 | import com.mylhyl.circledialog.BaseCircleDialog; |
26 | import com.mylhyl.circledialog.res.values.CircleDimen; | 26 | import com.mylhyl.circledialog.res.values.CircleDimen; |
27 | 27 | ||
28 | import java.util.ArrayList; | 28 | import java.util.ArrayList; |
29 | import java.util.List; | 29 | import java.util.List; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Created by h on 2017/8/21. | 32 | * Created by h on 2017/8/21. |
33 | */ | 33 | */ |
34 | 34 | ||
35 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 35 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
36 | private ListView school_list; | 36 | private ListView school_list; |
37 | private EditText school_sech; | 37 | private EditText school_sech; |
38 | private SchoolAdapter listadapter; | 38 | private SchoolAdapter listadapter; |
39 | private View mView; | 39 | private View mView; |
40 | boolean isFilter; | 40 | boolean isFilter; |
41 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); | 41 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); |
42 | private DialogCallBack.CallBack mCallBack; | 42 | private DialogCallBack.SchoolCallBack mCallBack; |
43 | 43 | ||
44 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { | 44 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { |
45 | // this.mCallBack = callBack; | 45 | // this.mCallBack = callBack; |
46 | // } | 46 | // } |
47 | public SchoolListDialog(DialogCallBack.CallBack callBack) { | 47 | public SchoolListDialog(DialogCallBack.SchoolCallBack callBack) { |
48 | this.mCallBack = callBack; | 48 | this.mCallBack = callBack; |
49 | } | 49 | } |
50 | 50 | ||
51 | public static SchoolListDialog getInstance(DialogCallBack.CallBack mCallBack) { | 51 | public static SchoolListDialog getInstance(DialogCallBack.SchoolCallBack mCallBack) { |
52 | SchoolListDialog dialogFragment = new SchoolListDialog(mCallBack); | 52 | SchoolListDialog dialogFragment = new SchoolListDialog(mCallBack); |
53 | dialogFragment.setCanceledBack(true); | 53 | dialogFragment.setCanceledBack(true); |
54 | dialogFragment.setCanceledOnTouchOutside(true); | 54 | dialogFragment.setCanceledOnTouchOutside(true); |
55 | dialogFragment.setRadius(CircleDimen.RADIUS); | 55 | dialogFragment.setRadius(CircleDimen.RADIUS); |
56 | dialogFragment.setWidth(0.5f); | 56 | dialogFragment.setWidth(0.5f); |
57 | dialogFragment.setGravity(Gravity.CENTER); | 57 | dialogFragment.setGravity(Gravity.CENTER); |
58 | dialogFragment.setBackgroundColor(Color.WHITE); | 58 | dialogFragment.setBackgroundColor(Color.WHITE); |
59 | return dialogFragment; | 59 | return dialogFragment; |
60 | } | 60 | } |
61 | 61 | ||
62 | Handler handler = new Handler(){ | 62 | Handler handler = new Handler(){ |
63 | @Override | 63 | @Override |
64 | public void handleMessage(Message msg) { | 64 | public void handleMessage(Message msg) { |
65 | super.handleMessage(msg); | 65 | super.handleMessage(msg); |
66 | switch (msg.what){ | 66 | switch (msg.what){ |
67 | case HttpCode.SCHOOL: | 67 | case HttpCode.SCHOOL: |
68 | data.clear(); | 68 | data.clear(); |
69 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); | 69 | data.addAll( (List<SchoolInfo.DataBean>)msg.obj); |
70 | listadapter.notifyDataSetChanged(); | 70 | listadapter.notifyDataSetChanged(); |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | @Override | 77 | @Override |
78 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 78 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
79 | 79 | ||
80 | if (mView == null) { | 80 | if (mView == null) { |
81 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); | 81 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); |
82 | //mCallBack.provinceOnItemClick(context, inflater, container); | 82 | //mCallBack.provinceOnItemClick(context, inflater, container); |
83 | } | 83 | } |
84 | return mView; | 84 | return mView; |
85 | } | 85 | } |
86 | 86 | ||
87 | @Override | 87 | @Override |
88 | public void onActivityCreated(Bundle savedInstanceState) { | 88 | public void onActivityCreated(Bundle savedInstanceState) { |
89 | super.onActivityCreated(savedInstanceState); | 89 | super.onActivityCreated(savedInstanceState); |
90 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); | 90 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); |
91 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); | 91 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); |
92 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 92 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); |
93 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 93 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
94 | listadapter = new SchoolAdapter(data, getActivity()); | 94 | listadapter = new SchoolAdapter(data, getActivity()); |
95 | school_list.setAdapter(listadapter); | 95 | school_list.setAdapter(listadapter); |
96 | school_list.setOnItemClickListener(this); | 96 | school_list.setOnItemClickListener(this); |
97 | try { | 97 | try { |
98 | int a = Integer.parseInt(citys); | 98 | int a = Integer.parseInt(citys); |
99 | int b = Integer.parseInt(grade); | 99 | int b = Integer.parseInt(grade); |
100 | HttpManager.getInstance().getschool(getActivity(),130102,14,handler); | 100 | HttpManager.getInstance().getschool(getActivity(),130102,14,handler); |
101 | } catch (NumberFormatException e) { | 101 | } catch (NumberFormatException e) { |
102 | e.printStackTrace(); | 102 | e.printStackTrace(); |
103 | } | 103 | } |
104 | intiEditView(); | 104 | intiEditView(); |
105 | 105 | ||
106 | 106 | ||
107 | } | 107 | } |
108 | private void intiEditView() { | 108 | private void intiEditView() { |
109 | school_sech.addTextChangedListener(new TextWatcher() { | 109 | school_sech.addTextChangedListener(new TextWatcher() { |
110 | @Override | 110 | @Override |
111 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | 111 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | @Override | 115 | @Override |
116 | public void onTextChanged(CharSequence s, int start, int before, int count) { | 116 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
117 | // mAdapter.getFilter().filter(s); | 117 | // mAdapter.getFilter().filter(s); |
118 | 118 | ||
119 | listadapter.getFilter().filter(s); | 119 | listadapter.getFilter().filter(s); |
120 | } | 120 | } |
121 | 121 | ||
122 | @Override | 122 | @Override |
123 | public void afterTextChanged(Editable s) { | 123 | public void afterTextChanged(Editable s) { |
124 | 124 | ||
125 | } | 125 | } |
126 | }); | 126 | }); |
127 | } | 127 | } |
128 | 128 | ||
129 | @Override | 129 | @Override |
130 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 130 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
131 | mCallBack.provinceOnItemClick(parent,view,position,id,4); | 131 | mCallBack.provinceO4nItemClick(data,position,4); |
132 | dismiss(); | 132 | dismiss(); |
133 | 133 | ||
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 |
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.ComponentName; | 5 | import android.content.ComponentName; |
6 | import android.content.Context; | 6 | import android.content.Context; |
7 | import android.content.Intent; | 7 | import android.content.Intent; |
8 | import android.os.Handler; | 8 | import android.os.Handler; |
9 | import android.os.Message; | 9 | import android.os.Message; |
10 | import android.provider.Settings; | 10 | import android.provider.Settings; |
11 | import android.support.v4.app.FragmentActivity; | 11 | import android.support.v4.app.FragmentActivity; |
12 | import android.util.Log; | 12 | import android.util.Log; |
13 | import android.view.Gravity; | 13 | import android.view.Gravity; |
14 | import android.view.View; | 14 | import android.view.View; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import com.google.gson.Gson; | 17 | import com.google.gson.Gson; |
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
20 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 20 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
21 | import com.hjx.personalcenter.db.SaveParam; | 21 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.gson.GsonTool; | 22 | import com.hjx.personalcenter.gson.GsonTool; |
23 | import com.hjx.personalcenter.model.CardInfo; | 23 | import com.hjx.personalcenter.model.CardInfo; |
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.GradeInfo; | 26 | import com.hjx.personalcenter.model.GradeInfo; |
27 | import com.hjx.personalcenter.model.ProvinceInfo; | 27 | import com.hjx.personalcenter.model.ProvinceInfo; |
28 | import com.hjx.personalcenter.model.SchoolInfo; | 28 | import com.hjx.personalcenter.model.SchoolInfo; |
29 | import com.hjx.personalcenter.util.DialogPermission; | 29 | import com.hjx.personalcenter.util.DialogPermission; |
30 | import com.loopj.android.http.AsyncHttpResponseHandler; | 30 | import com.loopj.android.http.AsyncHttpResponseHandler; |
31 | import com.loopj.android.http.JsonHttpResponseHandler; | 31 | import com.loopj.android.http.JsonHttpResponseHandler; |
32 | import com.loopj.android.http.RequestParams; | 32 | import com.loopj.android.http.RequestParams; |
33 | import com.mylhyl.circledialog.CircleDialog; | 33 | import com.mylhyl.circledialog.CircleDialog; |
34 | import com.mylhyl.circledialog.callback.ConfigText; | 34 | import com.mylhyl.circledialog.callback.ConfigText; |
35 | import com.mylhyl.circledialog.params.TextParams; | 35 | import com.mylhyl.circledialog.params.TextParams; |
36 | 36 | ||
37 | import org.apache.http.Header; | 37 | import org.apache.http.Header; |
38 | import org.apache.http.entity.ByteArrayEntity; | 38 | import org.apache.http.entity.ByteArrayEntity; |
39 | import org.apache.http.message.BasicHeader; | 39 | import org.apache.http.message.BasicHeader; |
40 | import org.apache.http.protocol.HTTP; | 40 | import org.apache.http.protocol.HTTP; |
41 | import org.json.JSONException; | 41 | import org.json.JSONException; |
42 | import org.json.JSONObject; | 42 | import org.json.JSONObject; |
43 | 43 | ||
44 | import java.io.UnsupportedEncodingException; | 44 | import java.io.UnsupportedEncodingException; |
45 | import java.util.ArrayList; | ||
45 | import java.util.List; | 46 | import java.util.List; |
46 | 47 | ||
47 | public class HttpManager { | 48 | public class HttpManager { |
48 | private static HttpManager instance; | 49 | private static HttpManager instance; |
49 | private ProgressDialog mProgress = null; | 50 | private ProgressDialog mProgress = null; |
50 | 51 | ||
51 | public static HttpManager getInstance() { | 52 | public static HttpManager getInstance() { |
52 | if (instance == null) { | 53 | if (instance == null) { |
53 | instance = new HttpManager(); | 54 | instance = new HttpManager(); |
54 | } | 55 | } |
55 | return instance; | 56 | return instance; |
56 | } | 57 | } |
57 | 58 | ||
58 | 59 | ||
59 | //登录接口 | 60 | //登录接口 |
60 | 61 | ||
61 | public void login(final String username, final String password, final Context mContext) { | 62 | public void login(final String username, final String password, final Context mContext) { |
62 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 63 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
63 | false, true, null); | 64 | false, true, null); |
64 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 65 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
65 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 66 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
66 | @Override | 67 | @Override |
67 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 68 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
68 | 69 | ||
69 | String str = new String(arg2); | 70 | String str = new String(arg2); |
70 | JSONObject jsonObject = null; | 71 | JSONObject jsonObject = null; |
71 | try { | 72 | try { |
72 | jsonObject = new JSONObject(new String(arg2)); | 73 | jsonObject = new JSONObject(new String(arg2)); |
73 | String status = jsonObject.getString("status"); | 74 | String status = jsonObject.getString("status"); |
74 | if (status.equals("100")) { | 75 | if (status.equals("100")) { |
75 | String access_token = jsonObject.getString("access_token"); | 76 | String access_token = jsonObject.getString("access_token"); |
76 | String userId = jsonObject.getString("userId"); | 77 | String userId = jsonObject.getString("userId"); |
77 | // //登录成功,保存登录数据并且获取个人信息 | 78 | // //登录成功,保存登录数据并且获取个人信息 |
78 | saveLoginInfo(mContext, username, password, access_token, "true", userId); | 79 | saveLoginInfo(mContext, username, password, access_token, "true", userId); |
79 | //HttpManager.getInstance().getuserinfo(username,mContext); | 80 | //HttpManager.getInstance().getuserinfo(username,mContext); |
80 | 81 | ||
81 | } else if (status.equals("200")) { | 82 | } else if (status.equals("200")) { |
82 | closeProgress(); | 83 | closeProgress(); |
83 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); | 84 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); |
84 | return; | 85 | return; |
85 | } else if (status.equals("204")) { | 86 | } else if (status.equals("204")) { |
86 | closeProgress(); | 87 | closeProgress(); |
87 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); | 88 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); |
88 | } else { | 89 | } else { |
89 | closeProgress(); | 90 | closeProgress(); |
90 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 91 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
91 | 92 | ||
92 | 93 | ||
93 | } | 94 | } |
94 | } catch (JSONException e) { | 95 | } catch (JSONException e) { |
95 | e.printStackTrace(); | 96 | e.printStackTrace(); |
96 | } | 97 | } |
97 | 98 | ||
98 | 99 | ||
99 | } | 100 | } |
100 | 101 | ||
101 | @Override | 102 | @Override |
102 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 103 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
103 | closeProgress(); | 104 | closeProgress(); |
104 | new CircleDialog.Builder((FragmentActivity) mContext) | 105 | new CircleDialog.Builder((FragmentActivity) mContext) |
105 | .setCanceledOnTouchOutside(false) | 106 | .setCanceledOnTouchOutside(false) |
106 | .setCancelable(false) | 107 | .setCancelable(false) |
107 | .setWidth(0.5f) | 108 | .setWidth(0.5f) |
108 | .configText(new ConfigText() { | 109 | .configText(new ConfigText() { |
109 | @Override | 110 | @Override |
110 | public void onConfig(TextParams params) { | 111 | public void onConfig(TextParams params) { |
111 | params.gravity = Gravity.CENTER; | 112 | params.gravity = Gravity.CENTER; |
112 | params.padding = new int[]{50, 50, 50, 50}; | 113 | params.padding = new int[]{50, 50, 50, 50}; |
113 | } | 114 | } |
114 | }) | 115 | }) |
115 | .setText("当前无网络,请检查网络设置") | 116 | .setText("当前无网络,请检查网络设置") |
116 | .setNegative("继续使用", null) | 117 | .setNegative("继续使用", null) |
117 | .setPositive("设置网络", new View.OnClickListener() { | 118 | .setPositive("设置网络", new View.OnClickListener() { |
118 | @Override | 119 | @Override |
119 | public void onClick(View v) { | 120 | public void onClick(View v) { |
120 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 121 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
121 | mContext.startActivity(intent); | 122 | mContext.startActivity(intent); |
122 | } | 123 | } |
123 | }) | 124 | }) |
124 | .show(); | 125 | .show(); |
125 | } | 126 | } |
126 | }); | 127 | }); |
127 | } | 128 | } |
128 | 129 | ||
129 | //注册接口 | 130 | //注册接口 |
130 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 131 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
131 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 132 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
132 | false, true, null); | 133 | false, true, null); |
133 | JSONObject jsonObject = new JSONObject(); | 134 | JSONObject jsonObject = new JSONObject(); |
134 | ByteArrayEntity entity = null; | 135 | ByteArrayEntity entity = null; |
135 | try { | 136 | try { |
136 | jsonObject.put(HttpKey.USERNAME, username); | 137 | jsonObject.put(HttpKey.USERNAME, username); |
137 | jsonObject.put(HttpKey.PASSWORD, password); | 138 | jsonObject.put(HttpKey.PASSWORD, password); |
138 | jsonObject.put(HttpKey.SMSCODE, smscode); | 139 | jsonObject.put(HttpKey.SMSCODE, smscode); |
139 | jsonObject.put(HttpKey.SOURCE, source); | 140 | jsonObject.put(HttpKey.SOURCE, source); |
140 | Log.e("test", "jsonObject" + jsonObject); | 141 | Log.e("test", "jsonObject" + jsonObject); |
141 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 142 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
142 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 143 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
143 | } catch (JSONException e) { | 144 | } catch (JSONException e) { |
144 | e.printStackTrace(); | 145 | e.printStackTrace(); |
145 | } catch (UnsupportedEncodingException e) { | 146 | } catch (UnsupportedEncodingException e) { |
146 | e.printStackTrace(); | 147 | e.printStackTrace(); |
147 | } | 148 | } |
148 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 149 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
149 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 150 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
150 | @Override | 151 | @Override |
151 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 152 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
152 | super.onSuccess(statusCode, headers, response); | 153 | super.onSuccess(statusCode, headers, response); |
153 | closeProgress(); | 154 | closeProgress(); |
154 | Log.e("test", "onSuccess" + response); | 155 | Log.e("test", "onSuccess" + response); |
155 | Message msg = Message.obtain(); | 156 | Message msg = Message.obtain(); |
156 | msg.what = HttpCode.REGISTERED_SUCESS; | 157 | msg.what = HttpCode.REGISTERED_SUCESS; |
157 | msg.obj = response; | 158 | msg.obj = response; |
158 | handler.sendMessage(msg); | 159 | handler.sendMessage(msg); |
159 | 160 | ||
160 | } | 161 | } |
161 | 162 | ||
162 | @Override | 163 | @Override |
163 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 164 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
164 | super.onFailure(statusCode, headers, throwable, errorResponse); | 165 | super.onFailure(statusCode, headers, throwable, errorResponse); |
165 | closeProgress(); | 166 | closeProgress(); |
166 | Log.e("test", "onFailure" + errorResponse); | 167 | Log.e("test", "onFailure" + errorResponse); |
167 | new CircleDialog.Builder((FragmentActivity) context) | 168 | new CircleDialog.Builder((FragmentActivity) context) |
168 | .setCanceledOnTouchOutside(false) | 169 | .setCanceledOnTouchOutside(false) |
169 | .setCancelable(false) | 170 | .setCancelable(false) |
170 | .setWidth(0.5f) | 171 | .setWidth(0.5f) |
171 | .configText(new ConfigText() { | 172 | .configText(new ConfigText() { |
172 | @Override | 173 | @Override |
173 | public void onConfig(TextParams params) { | 174 | public void onConfig(TextParams params) { |
174 | params.gravity = Gravity.CENTER; | 175 | params.gravity = Gravity.CENTER; |
175 | params.padding = new int[]{50, 50, 50, 50}; | 176 | params.padding = new int[]{50, 50, 50, 50}; |
176 | } | 177 | } |
177 | }) | 178 | }) |
178 | .setText("当前无网络,请检查网络设置") | 179 | .setText("当前无网络,请检查网络设置") |
179 | .setNegative("继续使用", null) | 180 | .setNegative("继续使用", null) |
180 | .setPositive("设置网络", new View.OnClickListener() { | 181 | .setPositive("设置网络", new View.OnClickListener() { |
181 | @Override | 182 | @Override |
182 | public void onClick(View v) { | 183 | public void onClick(View v) { |
183 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 184 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
184 | context.startActivity(intent); | 185 | context.startActivity(intent); |
185 | } | 186 | } |
186 | }) | 187 | }) |
187 | .show(); | 188 | .show(); |
188 | } | 189 | } |
189 | 190 | ||
190 | }); | 191 | }); |
191 | } | 192 | } |
192 | 193 | ||
193 | //注册验证码 | 194 | //注册验证码 |
194 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 195 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
195 | RequestParams params = new RequestParams(); | 196 | RequestParams params = new RequestParams(); |
196 | params.put(HttpKey.TYPE, type); | 197 | params.put(HttpKey.TYPE, type); |
197 | params.put(HttpKey.MOBIL, mobile); | 198 | params.put(HttpKey.MOBIL, mobile); |
198 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 199 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
199 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 200 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
200 | 201 | ||
201 | @Override | 202 | @Override |
202 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 203 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
203 | Log.e("test", "onSuccess-----" + response); | 204 | Log.e("test", "onSuccess-----" + response); |
204 | Message msg = Message.obtain(); | 205 | Message msg = Message.obtain(); |
205 | msg.what = HttpCode.AUTHCODE_SUCESS; | 206 | msg.what = HttpCode.AUTHCODE_SUCESS; |
206 | msg.obj = response; | 207 | msg.obj = response; |
207 | handler.sendMessage(msg); | 208 | handler.sendMessage(msg); |
208 | } | 209 | } |
209 | 210 | ||
210 | @Override | 211 | @Override |
211 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 212 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
212 | new CircleDialog.Builder((FragmentActivity) mContext) | 213 | new CircleDialog.Builder((FragmentActivity) mContext) |
213 | .setCanceledOnTouchOutside(false) | 214 | .setCanceledOnTouchOutside(false) |
214 | .setCancelable(false) | 215 | .setCancelable(false) |
215 | .setWidth(0.5f) | 216 | .setWidth(0.5f) |
216 | .configText(new ConfigText() { | 217 | .configText(new ConfigText() { |
217 | @Override | 218 | @Override |
218 | public void onConfig(TextParams params) { | 219 | public void onConfig(TextParams params) { |
219 | params.gravity = Gravity.CENTER; | 220 | params.gravity = Gravity.CENTER; |
220 | params.padding = new int[]{50, 50, 50, 50}; | 221 | params.padding = new int[]{50, 50, 50, 50}; |
221 | } | 222 | } |
222 | }) | 223 | }) |
223 | .setText("当前无网络,请检查网络设置") | 224 | .setText("当前无网络,请检查网络设置") |
224 | .setNegative("继续使用", null) | 225 | .setNegative("继续使用", null) |
225 | .setPositive("设置网络", new View.OnClickListener() { | 226 | .setPositive("设置网络", new View.OnClickListener() { |
226 | @Override | 227 | @Override |
227 | public void onClick(View v) { | 228 | public void onClick(View v) { |
228 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 229 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
229 | mContext.startActivity(intent); | 230 | mContext.startActivity(intent); |
230 | } | 231 | } |
231 | }) | 232 | }) |
232 | .show(); | 233 | .show(); |
233 | } | 234 | } |
234 | }); | 235 | }); |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | //手机号是否注册 | 239 | //手机号是否注册 |
239 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 240 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
240 | RequestParams params = new RequestParams(); | 241 | RequestParams params = new RequestParams(); |
241 | params.put(HttpKey.USERNAME, mobile); | 242 | params.put(HttpKey.USERNAME, mobile); |
242 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 243 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
243 | @Override | 244 | @Override |
244 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 245 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
245 | Log.e("test", "isregistered" + response.toString()); | 246 | Log.e("test", "isregistered" + response.toString()); |
246 | Message msg = Message.obtain(); | 247 | Message msg = Message.obtain(); |
247 | msg.what = HttpCode.IS_REFISTER; | 248 | msg.what = HttpCode.IS_REFISTER; |
248 | msg.obj = response; | 249 | msg.obj = response; |
249 | handler.sendMessage(msg); | 250 | handler.sendMessage(msg); |
250 | 251 | ||
251 | } | 252 | } |
252 | 253 | ||
253 | @Override | 254 | @Override |
254 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 255 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
255 | new CircleDialog.Builder((FragmentActivity) mContext) | 256 | new CircleDialog.Builder((FragmentActivity) mContext) |
256 | .setCanceledOnTouchOutside(false) | 257 | .setCanceledOnTouchOutside(false) |
257 | .setCancelable(false) | 258 | .setCancelable(false) |
258 | .setWidth(0.5f) | 259 | .setWidth(0.5f) |
259 | .configText(new ConfigText() { | 260 | .configText(new ConfigText() { |
260 | @Override | 261 | @Override |
261 | public void onConfig(TextParams params) { | 262 | public void onConfig(TextParams params) { |
262 | params.gravity = Gravity.CENTER; | 263 | params.gravity = Gravity.CENTER; |
263 | params.padding = new int[]{50, 50, 50, 50}; | 264 | params.padding = new int[]{50, 50, 50, 50}; |
264 | } | 265 | } |
265 | }) | 266 | }) |
266 | .setText("当前无网络,请检查网络设置") | 267 | .setText("当前无网络,请检查网络设置") |
267 | .setNegative("继续使用", null) | 268 | .setNegative("继续使用", null) |
268 | .setPositive("设置网络", new View.OnClickListener() { | 269 | .setPositive("设置网络", new View.OnClickListener() { |
269 | @Override | 270 | @Override |
270 | public void onClick(View v) { | 271 | public void onClick(View v) { |
271 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 272 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
272 | mContext.startActivity(intent); | 273 | mContext.startActivity(intent); |
273 | } | 274 | } |
274 | }) | 275 | }) |
275 | .show(); | 276 | .show(); |
276 | 277 | ||
277 | } | 278 | } |
278 | }); | 279 | }); |
279 | } | 280 | } |
280 | 281 | ||
281 | //修改密码 | 282 | //修改密码 |
282 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 283 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
283 | RequestParams params = new RequestParams(); | 284 | RequestParams params = new RequestParams(); |
284 | params.put(HttpKey.USERNAME, username); | 285 | params.put(HttpKey.USERNAME, username); |
285 | params.put(HttpKey.OLDPASS, old_pwd1); | 286 | params.put(HttpKey.OLDPASS, old_pwd1); |
286 | params.put(HttpKey.NEWPASS, newpassword3); | 287 | params.put(HttpKey.NEWPASS, newpassword3); |
287 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 288 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
288 | HttpClient.getInstance().setTimeout(10 * 1000); | 289 | HttpClient.getInstance().setTimeout(10 * 1000); |
289 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 290 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
290 | @Override | 291 | @Override |
291 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 292 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
292 | try { | 293 | try { |
293 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 294 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
294 | String status = jsonObject.optString("status"); | 295 | String status = jsonObject.optString("status"); |
295 | if (status.equals("100")) { | 296 | if (status.equals("100")) { |
296 | Log.e("test", "onSuccess" + new String(bytes)); | 297 | Log.e("test", "onSuccess" + new String(bytes)); |
297 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 298 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
298 | SaveParam.getInstance().clearData((Activity) context); | 299 | SaveParam.getInstance().clearData((Activity) context); |
299 | Intent intent = new Intent(); | 300 | Intent intent = new Intent(); |
300 | intent.setClass(context, LoginAndRegisterActivity.class); | 301 | intent.setClass(context, LoginAndRegisterActivity.class); |
301 | ((Activity) context).startActivity(intent); | 302 | ((Activity) context).startActivity(intent); |
302 | ((Activity) context).finish(); | 303 | ((Activity) context).finish(); |
303 | } | 304 | } |
304 | } catch (JSONException e) { | 305 | } catch (JSONException e) { |
305 | e.printStackTrace(); | 306 | e.printStackTrace(); |
306 | } | 307 | } |
307 | } | 308 | } |
308 | 309 | ||
309 | @Override | 310 | @Override |
310 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 311 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
311 | Log.e("test", "onFailure" + new String(bytes)); | 312 | Log.e("test", "onFailure" + new String(bytes)); |
312 | new CircleDialog.Builder((FragmentActivity) context) | 313 | new CircleDialog.Builder((FragmentActivity) context) |
313 | .setCanceledOnTouchOutside(false) | 314 | .setCanceledOnTouchOutside(false) |
314 | .setCancelable(false) | 315 | .setCancelable(false) |
315 | .setWidth(0.5f) | 316 | .setWidth(0.5f) |
316 | .configText(new ConfigText() { | 317 | .configText(new ConfigText() { |
317 | @Override | 318 | @Override |
318 | public void onConfig(TextParams params) { | 319 | public void onConfig(TextParams params) { |
319 | params.gravity = Gravity.CENTER; | 320 | params.gravity = Gravity.CENTER; |
320 | params.padding = new int[]{50, 50, 50, 50}; | 321 | params.padding = new int[]{50, 50, 50, 50}; |
321 | } | 322 | } |
322 | }) | 323 | }) |
323 | .setText("当前无网络,请检查网络设置") | 324 | .setText("当前无网络,请检查网络设置") |
324 | .setNegative("继续使用", null) | 325 | .setNegative("继续使用", null) |
325 | .setPositive("设置网络", new View.OnClickListener() { | 326 | .setPositive("设置网络", new View.OnClickListener() { |
326 | @Override | 327 | @Override |
327 | public void onClick(View v) { | 328 | public void onClick(View v) { |
328 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 329 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
329 | context.startActivity(intent); | 330 | context.startActivity(intent); |
330 | } | 331 | } |
331 | }) | 332 | }) |
332 | .show(); | 333 | .show(); |
333 | } | 334 | } |
334 | }); | 335 | }); |
335 | 336 | ||
336 | } | 337 | } |
337 | 338 | ||
338 | //忘记密码 | 339 | //忘记密码 |
339 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 340 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
340 | RequestParams params = new RequestParams(); | 341 | RequestParams params = new RequestParams(); |
341 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 342 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
342 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 343 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
343 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 344 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
344 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 345 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
345 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 346 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
346 | @Override | 347 | @Override |
347 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 348 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
348 | try { | 349 | try { |
349 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 350 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
350 | String status = jsonObject.optString("status"); | 351 | String status = jsonObject.optString("status"); |
351 | if (status.equals("100")) { | 352 | if (status.equals("100")) { |
352 | Log.e("test", "onSuccess" + new String(bytes)); | 353 | Log.e("test", "onSuccess" + new String(bytes)); |
353 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 354 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
354 | ((Activity) context).finish(); | 355 | ((Activity) context).finish(); |
355 | } | 356 | } |
356 | } catch (JSONException e) { | 357 | } catch (JSONException e) { |
357 | e.printStackTrace(); | 358 | e.printStackTrace(); |
358 | } | 359 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | @Override | 362 | @Override |
362 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 363 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
363 | Log.e("test", "onFailure" + new String(bytes)); | 364 | Log.e("test", "onFailure" + new String(bytes)); |
364 | new CircleDialog.Builder((FragmentActivity) context) | 365 | new CircleDialog.Builder((FragmentActivity) context) |
365 | .setCanceledOnTouchOutside(false) | 366 | .setCanceledOnTouchOutside(false) |
366 | .setCancelable(false) | 367 | .setCancelable(false) |
367 | .setWidth(0.5f) | 368 | .setWidth(0.5f) |
368 | .configText(new ConfigText() { | 369 | .configText(new ConfigText() { |
369 | @Override | 370 | @Override |
370 | public void onConfig(TextParams params) { | 371 | public void onConfig(TextParams params) { |
371 | params.gravity = Gravity.CENTER; | 372 | params.gravity = Gravity.CENTER; |
372 | params.padding = new int[]{50, 50, 50, 50}; | 373 | params.padding = new int[]{50, 50, 50, 50}; |
373 | } | 374 | } |
374 | }) | 375 | }) |
375 | .setText("当前无网络,请检查网络设置") | 376 | .setText("当前无网络,请检查网络设置") |
376 | .setNegative("继续使用", null) | 377 | .setNegative("继续使用", null) |
377 | .setPositive("设置网络", new View.OnClickListener() { | 378 | .setPositive("设置网络", new View.OnClickListener() { |
378 | @Override | 379 | @Override |
379 | public void onClick(View v) { | 380 | public void onClick(View v) { |
380 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 381 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
381 | context.startActivity(intent); | 382 | context.startActivity(intent); |
382 | } | 383 | } |
383 | }) | 384 | }) |
384 | .show(); | 385 | .show(); |
385 | } | 386 | } |
386 | }); | 387 | }); |
387 | 388 | ||
388 | } | 389 | } |
389 | 390 | ||
390 | //保存用户登录信息 | 391 | //保存用户登录信息 |
391 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 392 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
392 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 393 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
393 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 394 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
394 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 395 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
395 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 396 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
396 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 397 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
397 | 398 | ||
398 | 399 | ||
399 | } | 400 | } |
400 | 401 | ||
401 | //保存用户个人信息 | 402 | //保存用户个人信息 |
402 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { | 403 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { |
403 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); | 404 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); |
404 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); | 405 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); |
405 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); | 406 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); |
406 | } | 407 | } |
407 | 408 | ||
408 | //提交保卡信息 | 409 | //提交保卡信息 |
409 | public void subcardinfo(final Context context, int userId, String customerName, String customerAddress, | 410 | public void subcardinfo(final Context context, int userId, String customerName, String customerAddress, |
410 | String buyAddress, String buyTime, String alterSaleCall, | 411 | String buyAddress, String buyTime, String alterSaleCall, |
411 | String productModel, String deviceNumber, String macAddress, | 412 | String productModel, String deviceNumber, String macAddress, |
412 | String mobilePhone) { | 413 | String mobilePhone) { |
413 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 414 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
414 | false, true, null); | 415 | false, true, null); |
415 | RequestParams params = new RequestParams(); | 416 | RequestParams params = new RequestParams(); |
416 | 417 | ||
417 | params.put(HttpKey.USEID, userId); | 418 | params.put(HttpKey.USEID, userId); |
418 | params.put(HttpKey.CUSTOMENAME, customerName); | 419 | params.put(HttpKey.CUSTOMENAME, customerName); |
419 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 420 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
420 | params.put(HttpKey.BUYADREES, buyAddress); | 421 | params.put(HttpKey.BUYADREES, buyAddress); |
421 | params.put(HttpKey.BUYTIME, buyTime); | 422 | params.put(HttpKey.BUYTIME, buyTime); |
422 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 423 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
423 | params.put(HttpKey.PRODUCTMODEL, productModel); | 424 | params.put(HttpKey.PRODUCTMODEL, productModel); |
424 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 425 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
425 | params.put(HttpKey.MACADRESS, macAddress); | 426 | params.put(HttpKey.MACADRESS, macAddress); |
426 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 427 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
427 | 428 | ||
428 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 429 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
429 | 430 | ||
430 | Log.e("test", "params" + params); | 431 | Log.e("test", "params" + params); |
431 | HttpClient.getInstance().setTimeout(5 * 1000); | 432 | HttpClient.getInstance().setTimeout(5 * 1000); |
432 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 433 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
433 | @Override | 434 | @Override |
434 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 435 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
435 | JSONObject jsonObject = null; | 436 | JSONObject jsonObject = null; |
436 | closeProgress(); | 437 | closeProgress(); |
437 | try { | 438 | try { |
438 | jsonObject = new JSONObject(new String(bytes)); | 439 | jsonObject = new JSONObject(new String(bytes)); |
439 | String status = jsonObject.optString("status"); | 440 | String status = jsonObject.optString("status"); |
440 | if (status.equals("1")) { | 441 | if (status.equals("1")) { |
441 | Log.e("test", "onSuccess" + jsonObject); | 442 | Log.e("test", "onSuccess" + jsonObject); |
442 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 443 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
443 | Intent intent = new Intent(); | 444 | Intent intent = new Intent(); |
444 | intent.setClass((Activity) context, TheStartPageActivity.class); | 445 | intent.setClass((Activity) context, TheStartPageActivity.class); |
445 | ((Activity) context).startActivity(intent); | 446 | ((Activity) context).startActivity(intent); |
446 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 447 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
447 | ((Activity) context).finish(); | 448 | ((Activity) context).finish(); |
448 | } | 449 | } |
449 | } catch (JSONException e) { | 450 | } catch (JSONException e) { |
450 | e.printStackTrace(); | 451 | e.printStackTrace(); |
451 | } | 452 | } |
452 | 453 | ||
453 | 454 | ||
454 | } | 455 | } |
455 | 456 | ||
456 | @Override | 457 | @Override |
457 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 458 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
458 | Log.e("test", "onFailure" + (throwable)); | 459 | Log.e("test", "onFailure" + (throwable)); |
459 | closeProgress(); | 460 | closeProgress(); |
460 | new CircleDialog.Builder((FragmentActivity) context) | 461 | new CircleDialog.Builder((FragmentActivity) context) |
461 | .setCanceledOnTouchOutside(false) | 462 | .setCanceledOnTouchOutside(false) |
462 | .setCancelable(false) | 463 | .setCancelable(false) |
463 | .setWidth(0.5f) | 464 | .setWidth(0.5f) |
464 | .configText(new ConfigText() { | 465 | .configText(new ConfigText() { |
465 | @Override | 466 | @Override |
466 | public void onConfig(TextParams params) { | 467 | public void onConfig(TextParams params) { |
467 | params.gravity = Gravity.CENTER; | 468 | params.gravity = Gravity.CENTER; |
468 | params.padding = new int[]{50, 50, 50, 50}; | 469 | params.padding = new int[]{50, 50, 50, 50}; |
469 | } | 470 | } |
470 | }) | 471 | }) |
471 | .setText("当前无网络,请检查网络设置") | 472 | .setText("当前无网络,请检查网络设置") |
472 | .setNegative("继续使用", null) | 473 | .setNegative("继续使用", null) |
473 | .setPositive("设置网络", new View.OnClickListener() { | 474 | .setPositive("设置网络", new View.OnClickListener() { |
474 | @Override | 475 | @Override |
475 | public void onClick(View v) { | 476 | public void onClick(View v) { |
476 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 477 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
477 | context.startActivity(intent); | 478 | context.startActivity(intent); |
478 | } | 479 | } |
479 | }) | 480 | }) |
480 | .show(); | 481 | .show(); |
481 | 482 | ||
482 | } | 483 | } |
483 | }); | 484 | }); |
484 | 485 | ||
485 | } | 486 | } |
486 | //获取保卡信息 | 487 | //获取保卡信息 |
487 | public void getcardinfo(final Context mContext, int userId , final Handler handler) { | 488 | public void getcardinfo(final Context mContext, int userId , final Handler handler) { |
488 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 489 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
489 | false, true, null); | 490 | false, true, null); |
490 | HttpClient.getInstance().setTimeout(5 * 1000); | 491 | HttpClient.getInstance().setTimeout(5 * 1000); |
491 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 492 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
492 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { | 493 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { |
493 | @Override | 494 | @Override |
494 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 495 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
495 | closeProgress(); | 496 | closeProgress(); |
496 | Log.e("test", "保卡信息" + new String(arg2)); | 497 | Log.e("test", "保卡信息" + new String(arg2)); |
497 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 498 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
498 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 499 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
499 | Message msg = Message.obtain(); | 500 | Message msg = Message.obtain(); |
500 | msg.what = HttpCode.SUCHCARDINFO; | 501 | msg.what = HttpCode.SUCHCARDINFO; |
501 | msg.obj = schoolInfoBeanList; | 502 | msg.obj = schoolInfoBeanList; |
502 | handler.sendMessage(msg); | 503 | handler.sendMessage(msg); |
503 | } | 504 | } |
504 | 505 | ||
505 | @Override | 506 | @Override |
506 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 507 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
507 | closeProgress(); | 508 | closeProgress(); |
508 | new CircleDialog.Builder((FragmentActivity) mContext) | 509 | new CircleDialog.Builder((FragmentActivity) mContext) |
509 | .setCanceledOnTouchOutside(false) | 510 | .setCanceledOnTouchOutside(false) |
510 | .setCancelable(false) | 511 | .setCancelable(false) |
511 | .setWidth(0.5f) | 512 | .setWidth(0.5f) |
512 | .configText(new ConfigText() { | 513 | .configText(new ConfigText() { |
513 | @Override | 514 | @Override |
514 | public void onConfig(TextParams params) { | 515 | public void onConfig(TextParams params) { |
515 | params.gravity = Gravity.CENTER; | 516 | params.gravity = Gravity.CENTER; |
516 | params.padding = new int[]{50, 50, 50, 50}; | 517 | params.padding = new int[]{50, 50, 50, 50}; |
517 | } | 518 | } |
518 | }) | 519 | }) |
519 | .setText("当前无网络,请检查网络设置") | 520 | .setText("当前无网络,请检查网络设置") |
520 | .setNegative("继续使用", null) | 521 | .setNegative("继续使用", null) |
521 | .setPositive("设置网络", new View.OnClickListener() { | 522 | .setPositive("设置网络", new View.OnClickListener() { |
522 | @Override | 523 | @Override |
523 | public void onClick(View v) { | 524 | public void onClick(View v) { |
524 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 525 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
525 | mContext.startActivity(intent); | 526 | mContext.startActivity(intent); |
526 | } | 527 | } |
527 | }) | 528 | }) |
528 | .show(); | 529 | .show(); |
529 | } | 530 | } |
530 | }); | 531 | }); |
531 | } | 532 | } |
532 | //修改保卡信息电话 | 533 | //修改保卡信息电话 |
533 | public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) { | 534 | public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) { |
534 | RequestParams params = new RequestParams(); | 535 | RequestParams params = new RequestParams(); |
535 | params.put("userId", userId); | 536 | params.put("userId", userId); |
536 | params.put("customerPhone", customerPhone); | 537 | params.put("customerPhone", customerPhone); |
537 | params.put("authCode", authCode); | 538 | params.put("authCode", authCode); |
538 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 539 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
539 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 540 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
540 | @Override | 541 | @Override |
541 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 542 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
542 | try { | 543 | try { |
543 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 544 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
544 | String status = jsonObject.optString("status"); | 545 | String status = jsonObject.optString("status"); |
545 | if (status.equals("1")) { | 546 | if (status.equals("1")) { |
546 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 547 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
547 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); | 548 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); |
548 | ((Activity) mContext).finish(); | 549 | ((Activity) mContext).finish(); |
549 | }else if (status.equals("1001")){ | 550 | }else if (status.equals("1001")){ |
550 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 551 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
551 | } | 552 | } |
552 | } catch (JSONException e) { | 553 | } catch (JSONException e) { |
553 | e.printStackTrace(); | 554 | e.printStackTrace(); |
554 | } | 555 | } |
555 | } | 556 | } |
556 | 557 | ||
557 | @Override | 558 | @Override |
558 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 559 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
559 | Log.e("test", "onFailure" + new String(bytes)); | 560 | Log.e("test", "onFailure" + new String(bytes)); |
560 | new CircleDialog.Builder((FragmentActivity) mContext) | 561 | new CircleDialog.Builder((FragmentActivity) mContext) |
561 | .setCanceledOnTouchOutside(false) | 562 | .setCanceledOnTouchOutside(false) |
562 | .setCancelable(false) | 563 | .setCancelable(false) |
563 | .setWidth(0.5f) | 564 | .setWidth(0.5f) |
564 | .configText(new ConfigText() { | 565 | .configText(new ConfigText() { |
565 | @Override | 566 | @Override |
566 | public void onConfig(TextParams params) { | 567 | public void onConfig(TextParams params) { |
567 | params.gravity = Gravity.CENTER; | 568 | params.gravity = Gravity.CENTER; |
568 | params.padding = new int[]{50, 50, 50, 50}; | 569 | params.padding = new int[]{50, 50, 50, 50}; |
569 | } | 570 | } |
570 | }) | 571 | }) |
571 | .setText("当前无网络,请检查网络设置") | 572 | .setText("当前无网络,请检查网络设置") |
572 | .setNegative("继续使用", null) | 573 | .setNegative("继续使用", null) |
573 | .setPositive("设置网络", new View.OnClickListener() { | 574 | .setPositive("设置网络", new View.OnClickListener() { |
574 | @Override | 575 | @Override |
575 | public void onClick(View v) { | 576 | public void onClick(View v) { |
576 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 577 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
577 | mContext.startActivity(intent); | 578 | mContext.startActivity(intent); |
578 | } | 579 | } |
579 | }) | 580 | }) |
580 | .show(); | 581 | .show(); |
581 | } | 582 | } |
582 | }); | 583 | }); |
583 | } | 584 | } |
584 | //修改保卡信息地址 | 585 | //修改保卡信息地址 |
585 | public void changecardadressinfo(final Context mContext, int userId, final String customerPhone, String authCode, final String customerAddress) { | 586 | public void changecardadressinfo(final Context mContext, int userId, final String customerPhone, String authCode, final String customerAddress) { |
586 | RequestParams params = new RequestParams(); | 587 | RequestParams params = new RequestParams(); |
587 | params.put("userId", userId); | 588 | params.put("userId", userId); |
588 | params.put("customerPhone", customerPhone); | 589 | params.put("customerPhone", customerPhone); |
589 | params.put("authCode", authCode); | 590 | params.put("authCode", authCode); |
590 | params.put("customerAddress", customerAddress); | 591 | params.put("customerAddress", customerAddress); |
591 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 592 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
592 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 593 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
593 | @Override | 594 | @Override |
594 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 595 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
595 | try { | 596 | try { |
596 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 597 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
597 | String status = jsonObject.optString("status"); | 598 | String status = jsonObject.optString("status"); |
598 | if (status.equals("1")) { | 599 | if (status.equals("1")) { |
599 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 600 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
600 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); | 601 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); |
601 | ((Activity) mContext).finish(); | 602 | ((Activity) mContext).finish(); |
602 | } | 603 | } |
603 | } catch (JSONException e) { | 604 | } catch (JSONException e) { |
604 | e.printStackTrace(); | 605 | e.printStackTrace(); |
605 | } | 606 | } |
606 | } | 607 | } |
607 | 608 | ||
608 | @Override | 609 | @Override |
609 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 610 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
610 | Log.e("test", "onFailure" + new String(bytes)); | 611 | Log.e("test", "onFailure" + new String(bytes)); |
611 | new CircleDialog.Builder((FragmentActivity) mContext) | 612 | new CircleDialog.Builder((FragmentActivity) mContext) |
612 | .setCanceledOnTouchOutside(false) | 613 | .setCanceledOnTouchOutside(false) |
613 | .setCancelable(false) | 614 | .setCancelable(false) |
614 | .setWidth(0.5f) | 615 | .setWidth(0.5f) |
615 | .configText(new ConfigText() { | 616 | .configText(new ConfigText() { |
616 | @Override | 617 | @Override |
617 | public void onConfig(TextParams params) { | 618 | public void onConfig(TextParams params) { |
618 | params.gravity = Gravity.CENTER; | 619 | params.gravity = Gravity.CENTER; |
619 | params.padding = new int[]{50, 50, 50, 50}; | 620 | params.padding = new int[]{50, 50, 50, 50}; |
620 | } | 621 | } |
621 | }) | 622 | }) |
622 | .setText("当前无网络,请检查网络设置") | 623 | .setText("当前无网络,请检查网络设置") |
623 | .setNegative("继续使用", null) | 624 | .setNegative("继续使用", null) |
624 | .setPositive("设置网络", new View.OnClickListener() { | 625 | .setPositive("设置网络", new View.OnClickListener() { |
625 | @Override | 626 | @Override |
626 | public void onClick(View v) { | 627 | public void onClick(View v) { |
627 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 628 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
628 | mContext.startActivity(intent); | 629 | mContext.startActivity(intent); |
629 | } | 630 | } |
630 | }) | 631 | }) |
631 | .show(); | 632 | .show(); |
632 | } | 633 | } |
633 | }); | 634 | }); |
634 | } | 635 | } |
635 | //验证是否保卡信息 | 636 | //验证是否保卡信息 |
636 | public void cardinfocheck(final Context mContext, int userId, final Handler handler) { | 637 | public void cardinfocheck(final Context mContext, int userId, final Handler handler) { |
637 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 638 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
638 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { | 639 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { |
639 | @Override | 640 | @Override |
640 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 641 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
641 | Log.e("test", "---" + new String(arg2)); | 642 | Log.e("test", "---" + new String(arg2)); |
642 | Message msg = Message.obtain(); | 643 | Message msg = Message.obtain(); |
643 | msg.what = HttpCode.CHECKCARD; | 644 | msg.what = HttpCode.CHECKCARD; |
644 | msg.obj = new String(arg2); | 645 | msg.obj = new String(arg2); |
645 | handler.sendMessage(msg); | 646 | handler.sendMessage(msg); |
646 | } | 647 | } |
647 | 648 | ||
648 | @Override | 649 | @Override |
649 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 650 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
650 | new CircleDialog.Builder((FragmentActivity) mContext) | 651 | new CircleDialog.Builder((FragmentActivity) mContext) |
651 | .setCanceledOnTouchOutside(false) | 652 | .setCanceledOnTouchOutside(false) |
652 | .setCancelable(false) | 653 | .setCancelable(false) |
653 | .configText(new ConfigText() { | 654 | .configText(new ConfigText() { |
654 | @Override | 655 | @Override |
655 | public void onConfig(TextParams params) { | 656 | public void onConfig(TextParams params) { |
656 | params.gravity = Gravity.CENTER; | 657 | params.gravity = Gravity.CENTER; |
657 | params.padding = new int[]{250, 50, 250, 50}; | 658 | params.padding = new int[]{250, 50, 250, 50}; |
658 | } | 659 | } |
659 | }) | 660 | }) |
660 | .setText("当前无网络,请检查网络设置") | 661 | .setText("当前无网络,请检查网络设置") |
661 | .setNegative("取消", null) | 662 | .setNegative("取消", null) |
662 | .setPositive("确定", new View.OnClickListener() { | 663 | .setPositive("确定", new View.OnClickListener() { |
663 | @Override | 664 | @Override |
664 | public void onClick(View v) { | 665 | public void onClick(View v) { |
665 | Intent intent = new Intent("/"); | 666 | Intent intent = new Intent("/"); |
666 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); | 667 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); |
667 | intent.setComponent(cm); | 668 | intent.setComponent(cm); |
668 | intent.setAction("android.intent.action.VIEW"); | 669 | intent.setAction("android.intent.action.VIEW"); |
669 | ((Activity) mContext).startActivityForResult( intent , 0); | 670 | ((Activity) mContext).startActivityForResult( intent , 0); |
670 | } | 671 | } |
671 | }) | 672 | }) |
672 | .show(); | 673 | .show(); |
673 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 674 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
674 | } | 675 | } |
675 | }); | 676 | }); |
676 | } | 677 | } |
677 | 678 | ||
678 | ///获取年级 | 679 | ///获取年级 |
679 | public void getgrade(final Context mContext, final Handler handler) { | 680 | public void getgrade(final Context mContext, final Handler handler) { |
680 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 681 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
681 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 682 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
682 | @Override | 683 | @Override |
683 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 684 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
684 | Log.e("test", "年级" + new String(arg2)); | 685 | Log.e("test", "年级" + new String(arg2)); |
685 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 686 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
686 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoBeanList = null; | 687 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
687 | for (int i = 0 ;i<3;i++) { | 688 | for (int i = 0 ;i<gradeInfo.getData().size()-2;i++) { |
688 | gradeInfoBeanList=(gradeInfo.getData().get(i).getChildren()); | 689 | String name = gradeInfo.getData().get(i).getName(); |
690 | int id = gradeInfo.getData().get(i).getId(); | ||
691 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | ||
692 | for (int j = 0; j < gradeinfoList.size(); j++) { | ||
693 | String secondname = gradeinfoList.get(j).getName(); | ||
694 | int secondid = gradeinfoList.get(j).getId(); | ||
695 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | ||
696 | dataBean.setName(secondname); | ||
697 | dataBean.setId(secondid); | ||
698 | gradeInfoLists.add(dataBean); | ||
699 | } | ||
700 | |||
689 | } | 701 | } |
690 | 702 | ||
691 | Message message = Message.obtain(); | 703 | Message message = Message.obtain(); |
692 | message.what = HttpCode.GRADER; | 704 | message.what = HttpCode.GRADER; |
693 | message.obj = gradeInfoBeanList; | 705 | message.obj = gradeInfoLists; |
694 | handler.sendMessage(message); | 706 | handler.sendMessage(message); |
695 | 707 | ||
696 | 708 | ||
697 | } | 709 | } |
698 | 710 | ||
699 | @Override | 711 | @Override |
700 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 712 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
701 | new CircleDialog.Builder((FragmentActivity) mContext) | 713 | new CircleDialog.Builder((FragmentActivity) mContext) |
702 | .setCanceledOnTouchOutside(false) | 714 | .setCanceledOnTouchOutside(false) |
703 | .setCancelable(false) | 715 | .setCancelable(false) |
704 | .setWidth(0.5f) | 716 | .setWidth(0.5f) |
705 | .configText(new ConfigText() { | 717 | .configText(new ConfigText() { |
706 | @Override | 718 | @Override |
707 | public void onConfig(TextParams params) { | 719 | public void onConfig(TextParams params) { |
708 | params.gravity = Gravity.CENTER; | 720 | params.gravity = Gravity.CENTER; |
709 | params.padding = new int[]{50, 50, 50, 50}; | 721 | params.padding = new int[]{50, 50, 50, 50}; |
710 | } | 722 | } |
711 | }) | 723 | }) |
712 | .setText("当前无网络,请检查网络设置") | 724 | .setText("当前无网络,请检查网络设置") |
713 | .setNegative("继续使用", null) | 725 | .setNegative("继续使用", null) |
714 | .setPositive("设置网络", new View.OnClickListener() { | 726 | .setPositive("设置网络", new View.OnClickListener() { |
715 | @Override | 727 | @Override |
716 | public void onClick(View v) { | 728 | public void onClick(View v) { |
717 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 729 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
718 | mContext.startActivity(intent); | 730 | mContext.startActivity(intent); |
719 | } | 731 | } |
720 | }) | 732 | }) |
721 | .show(); | 733 | .show(); |
722 | } | 734 | } |
723 | }); | 735 | }); |
724 | } | 736 | } |
725 | ///获取学校 | 737 | |
738 | /** | ||
739 | * 获取学校 | ||
740 | * @param mContext | ||
741 | * @param regionId | ||
742 | * @param gradeId | ||
743 | * @param handler | ||
744 | */ | ||
726 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 745 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
727 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 746 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
728 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 747 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
729 | @Override | 748 | @Override |
730 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 749 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
731 | Log.e("test", "学校" + new String(arg2)); | 750 | Log.e("test", "学校" + new String(arg2)); |
732 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 751 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
733 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 752 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
734 | Message message = Message.obtain(); | 753 | Message message = Message.obtain(); |
735 | message.what = HttpCode.SCHOOL; | 754 | message.what = HttpCode.SCHOOL; |
736 | message.obj = schoolInfoBeanList; | 755 | message.obj = schoolInfoBeanList; |
737 | handler.sendMessage(message); | 756 | handler.sendMessage(message); |
738 | 757 | ||
739 | } | 758 | } |
740 | 759 | ||
741 | @Override | 760 | @Override |
742 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 761 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
743 | new CircleDialog.Builder((FragmentActivity) mContext) | 762 | new CircleDialog.Builder((FragmentActivity) mContext) |
744 | .setCanceledOnTouchOutside(false) | 763 | .setCanceledOnTouchOutside(false) |
745 | .setCancelable(false) | 764 | .setCancelable(false) |
746 | .setWidth(0.5f) | 765 | .setWidth(0.5f) |
747 | .configText(new ConfigText() { | 766 | .configText(new ConfigText() { |
748 | @Override | 767 | @Override |
749 | public void onConfig(TextParams params) { | 768 | public void onConfig(TextParams params) { |
750 | params.gravity = Gravity.CENTER; | 769 | params.gravity = Gravity.CENTER; |
751 | params.padding = new int[]{50, 50, 50, 50}; | 770 | params.padding = new int[]{50, 50, 50, 50}; |
752 | } | 771 | } |
753 | }) | 772 | }) |
754 | .setText("当前无网络,请检查网络设置") | 773 | .setText("当前无网络,请检查网络设置") |
755 | .setNegative("继续使用", null) | 774 | .setNegative("继续使用", null) |
756 | .setPositive("设置网络", new View.OnClickListener() { | 775 | .setPositive("设置网络", new View.OnClickListener() { |
757 | @Override | 776 | @Override |
758 | public void onClick(View v) { | 777 | public void onClick(View v) { |
759 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 778 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
760 | mContext.startActivity(intent); | 779 | mContext.startActivity(intent); |
761 | } | 780 | } |
762 | }) | 781 | }) |
763 | .show(); | 782 | .show(); |
764 | } | 783 | } |
765 | }); | 784 | }); |
766 | } | 785 | } |
767 | 786 | ||
768 | 787 | ||
769 | 788 | ||
770 | 789 | ||
771 | 790 | ||
772 | ///省级接口 | 791 | ///省级接口 |
773 | public void provices(final Context mContext, final Handler handler) { | 792 | public void provices(final Context mContext, final Handler handler) { |
774 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 793 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
775 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 794 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
776 | @Override | 795 | @Override |
777 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 796 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
778 | Log.e("test", "省" + new String(arg2)); | 797 | Log.e("test", "省" + new String(arg2)); |
779 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 798 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
780 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 799 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
781 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 800 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
782 | Message message = Message.obtain(); | 801 | Message message = Message.obtain(); |
783 | message.what = HttpCode.PROVICES; | 802 | message.what = HttpCode.PROVICES; |
784 | message.obj = provincesBeanList; | 803 | message.obj = provincesBeanList; |
785 | handler.sendMessage(message); | 804 | handler.sendMessage(message); |
786 | 805 | ||
787 | } | 806 | } |
788 | 807 | ||
789 | @Override | 808 | @Override |
790 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 809 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
791 | new CircleDialog.Builder((FragmentActivity) mContext) | 810 | new CircleDialog.Builder((FragmentActivity) mContext) |
792 | .setCanceledOnTouchOutside(false) | 811 | .setCanceledOnTouchOutside(false) |
793 | .setCancelable(false) | 812 | .setCancelable(false) |
794 | .setWidth(0.5f) | 813 | .setWidth(0.5f) |
795 | .configText(new ConfigText() { | 814 | .configText(new ConfigText() { |
796 | @Override | 815 | @Override |
797 | public void onConfig(TextParams params) { | 816 | public void onConfig(TextParams params) { |
798 | params.gravity = Gravity.CENTER; | 817 | params.gravity = Gravity.CENTER; |
799 | params.padding = new int[]{50, 50, 50, 50}; | 818 | params.padding = new int[]{50, 50, 50, 50}; |
800 | } | 819 | } |
801 | }) | 820 | }) |
802 | .setText("当前无网络,请检查网络设置") | 821 | .setText("当前无网络,请检查网络设置") |
803 | .setNegative("继续使用", null) | 822 | .setNegative("继续使用", null) |
804 | .setPositive("设置网络", new View.OnClickListener() { | 823 | .setPositive("设置网络", new View.OnClickListener() { |
805 | @Override | 824 | @Override |
806 | public void onClick(View v) { | 825 | public void onClick(View v) { |
807 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 826 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
808 | mContext.startActivity(intent); | 827 | mContext.startActivity(intent); |
809 | } | 828 | } |
810 | }) | 829 | }) |
811 | .show(); | 830 | .show(); |
812 | } | 831 | } |
813 | }); | 832 | }); |
814 | } | 833 | } |
815 | 834 | ||
816 | //市级接口 | 835 | //市级接口 |
817 | public void cityinfo(final Context mContext, long regionId , final Handler handler) { | 836 | public void cityinfo(final Context mContext, long regionId , final Handler handler) { |
818 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 837 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
819 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 838 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
820 | @Override | 839 | @Override |
821 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 840 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
822 | Log.e("test", "市" + new String(arg2)); | 841 | Log.e("test", "市" + new String(arg2)); |
823 | Gson gson = new Gson(); | 842 | Gson gson = new Gson(); |
824 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 843 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
825 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 844 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
826 | Message message = Message.obtain(); | 845 | Message message = Message.obtain(); |
827 | message.what = HttpCode.CITYS; | 846 | message.what = HttpCode.CITYS; |
828 | message.obj = cityInfoBeanList; | 847 | message.obj = cityInfoBeanList; |
829 | handler.sendMessage(message); | 848 | handler.sendMessage(message); |
830 | 849 | ||
831 | 850 | ||
832 | } | 851 | } |
833 | 852 | ||
834 | @Override | 853 | @Override |
835 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 854 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
836 | new CircleDialog.Builder((FragmentActivity) mContext) | 855 | new CircleDialog.Builder((FragmentActivity) mContext) |
837 | .setCanceledOnTouchOutside(false) | 856 | .setCanceledOnTouchOutside(false) |
838 | .setCancelable(false) | 857 | .setCancelable(false) |
839 | .setWidth(0.5f) | 858 | .setWidth(0.5f) |
840 | .configText(new ConfigText() { | 859 | .configText(new ConfigText() { |
841 | @Override | 860 | @Override |
842 | public void onConfig(TextParams params) { | 861 | public void onConfig(TextParams params) { |
843 | params.gravity = Gravity.CENTER; | 862 | params.gravity = Gravity.CENTER; |
844 | params.padding = new int[]{50, 50, 50, 50}; | 863 | params.padding = new int[]{50, 50, 50, 50}; |
845 | } | 864 | } |
846 | }) | 865 | }) |
847 | .setText("当前无网络,请检查网络设置") | 866 | .setText("当前无网络,请检查网络设置") |
848 | .setNegative("继续使用", null) | 867 | .setNegative("继续使用", null) |
849 | .setPositive("设置网络", new View.OnClickListener() { | 868 | .setPositive("设置网络", new View.OnClickListener() { |
850 | @Override | 869 | @Override |
851 | public void onClick(View v) { | 870 | public void onClick(View v) { |
852 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 871 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
853 | mContext.startActivity(intent); | 872 | mContext.startActivity(intent); |
854 | } | 873 | } |
855 | }) | 874 | }) |
856 | .show(); | 875 | .show(); |
857 | } | 876 | } |
858 | }); | 877 | }); |
859 | } | 878 | } |
860 | 879 | ||
861 | //区县级接口 | 880 | //区县级接口 |
862 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 881 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
863 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 882 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
864 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 883 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
865 | @Override | 884 | @Override |
866 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 885 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
867 | Log.e("test", "区" + new String(arg2)); | 886 | Log.e("test", "区" + new String(arg2)); |
868 | Gson gson = new Gson(); | 887 | Gson gson = new Gson(); |
869 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 888 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
870 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 889 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
871 | Message message = Message.obtain(); | 890 | Message message = Message.obtain(); |
872 | message.what = HttpCode.COUNTRY; | 891 | message.what = HttpCode.COUNTRY; |
873 | message.obj = countyInfoInfoBeanList; | 892 | message.obj = countyInfoInfoBeanList; |
874 | handler.sendMessage(message); | 893 | handler.sendMessage(message); |
875 | 894 | ||
876 | 895 | ||
877 | } | 896 | } |
878 | 897 | ||
879 | @Override | 898 | @Override |
880 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 899 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
881 | new CircleDialog.Builder((FragmentActivity) mContext) | 900 | new CircleDialog.Builder((FragmentActivity) mContext) |
882 | .setCanceledOnTouchOutside(false) | 901 | .setCanceledOnTouchOutside(false) |
883 | .setCancelable(false) | 902 | .setCancelable(false) |
884 | .setWidth(0.5f) | 903 | .setWidth(0.5f) |
885 | .configText(new ConfigText() { | 904 | .configText(new ConfigText() { |
886 | @Override | 905 | @Override |
887 | public void onConfig(TextParams params) { | 906 | public void onConfig(TextParams params) { |
888 | params.gravity = Gravity.CENTER; | 907 | params.gravity = Gravity.CENTER; |
889 | params.padding = new int[]{50, 50, 50, 50}; | 908 | params.padding = new int[]{50, 50, 50, 50}; |
890 | } | 909 | } |
891 | }) | 910 | }) |
892 | .setText("当前无网络,请检查网络设置") | 911 | .setText("当前无网络,请检查网络设置") |
893 | .setNegative("继续使用", null) | 912 | .setNegative("继续使用", null) |
894 | .setPositive("设置网络", new View.OnClickListener() { | 913 | .setPositive("设置网络", new View.OnClickListener() { |
895 | @Override | 914 | @Override |
896 | public void onClick(View v) { | 915 | public void onClick(View v) { |
897 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 916 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
898 | mContext.startActivity(intent); | 917 | mContext.startActivity(intent); |
899 | } | 918 | } |
900 | }) | 919 | }) |
901 | .show(); | 920 | .show(); |
902 | } | 921 | } |
903 | }); | 922 | }); |
904 | } | 923 | } |
905 | 924 | ||
906 | 925 | ||
907 | private void closeProgress() { | 926 | private void closeProgress() { |
908 | try { | 927 | try { |
909 | if (mProgress != null) { | 928 | if (mProgress != null) { |
910 | mProgress.dismiss(); | 929 | mProgress.dismiss(); |
911 | mProgress = null; | 930 | mProgress = null; |
912 | } | 931 | } |
913 | } catch (Exception e) { | 932 | } catch (Exception e) { |
914 | e.printStackTrace(); | 933 | e.printStackTrace(); |
915 | } | 934 | } |
916 | } | 935 | } |
917 | 936 | ||
918 | } | 937 | } |
919 | 938 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/interfaces/DialogCallBack.java
1 | package com.hjx.personalcenter.interfaces; | 1 | package com.hjx.personalcenter.interfaces; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.view.View; | 4 | import android.view.View; |
5 | import android.widget.AdapterView; | 5 | import android.widget.AdapterView; |
6 | 6 | ||
7 | import com.hjx.personalcenter.model.CityInfo; | ||
8 | import com.hjx.personalcenter.model.CountyInfo; | ||
9 | import com.hjx.personalcenter.model.GradeInfo; | ||
10 | import com.hjx.personalcenter.model.ProvinceInfo; | ||
11 | import com.hjx.personalcenter.model.SchoolInfo; | ||
12 | |||
13 | import java.util.ArrayList; | ||
14 | |||
7 | /** | 15 | /** |
8 | * Created by wei on 2017/8/17. | 16 | * Created by wei on 2017/8/17. |
9 | */ | 17 | */ |
10 | 18 | ||
11 | public class DialogCallBack { | 19 | public class DialogCallBack { |
12 | //对话框回调 | 20 | //对话框回调 |
13 | public interface CallBack{ | 21 | public interface ProvincesCallBack{ |
14 | void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id,int type); | 22 | void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type); |
23 | } | ||
24 | public interface CitysCallBack{ | ||
25 | void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type); | ||
26 | } | ||
27 | public interface CountryCallBack{ | ||
28 | void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type); | ||
29 | } | ||
30 | public interface GradeCallBack{ | ||
31 | void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type); | ||
32 | } | ||
33 | public interface SchoolCallBack{ | ||
34 | void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type); | ||
15 | } | 35 | } |
16 | //头像回调 | 36 | //头像回调 |
17 | public interface CallBackView{ | 37 | public interface CallBackView{ |
18 | void heard(Context context,View v); | 38 | void heard(Context context,View v); |
19 | } | 39 | } |
20 | } | 40 | } |
21 | 41 |