Commit c7ea65ea71770a8879597f76fb1d3475bfa36017
1 parent
9cbee19cbb
Exists in
master
版本跟新接口
Showing
18 changed files
with
532 additions
and
62 deletions
Show diff stats
PersonalCenter/app/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | 2 | ||
3 | android { | 3 | android { |
4 | compileSdkVersion 25 | 4 | compileSdkVersion 25 |
5 | buildToolsVersion "25.0.3" | 5 | buildToolsVersion "25.0.3" |
6 | defaultConfig { | 6 | defaultConfig { |
7 | applicationId "com.hjx.personalcenter" | 7 | applicationId "com.hjx.personalcenter" |
8 | minSdkVersion 15 | 8 | minSdkVersion 15 |
9 | targetSdkVersion 25 | 9 | targetSdkVersion 25 |
10 | versionCode 1 | 10 | versionCode 1 |
11 | versionName "1.0" | 11 | versionName "1.0.0" |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
13 | } | 13 | } |
14 | buildTypes { | 14 | buildTypes { |
15 | release { | 15 | release { |
16 | minifyEnabled false | 16 | minifyEnabled false |
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
18 | } | 18 | } |
19 | } | 19 | } |
20 | useLibrary 'org.apache.http.legacy' | 20 | useLibrary 'org.apache.http.legacy' |
21 | sourceSets { | 21 | sourceSets { |
22 | main { | 22 | main { |
23 | jniLibs.srcDirs = ['libs'] | 23 | jniLibs.srcDirs = ['libs'] |
24 | } | 24 | } |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | dependencies { | 28 | dependencies { |
29 | compile fileTree(include: ['*.jar'], dir: 'libs') | 29 | compile fileTree(include: ['*.jar'], dir: 'libs') |
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
31 | exclude group: 'com.android.support', module: 'support-annotations' | 31 | exclude group: 'com.android.support', module: 'support-annotations' |
32 | }) | 32 | }) |
33 | compile 'com.tencent.bugly:crashreport:latest.release' | 33 | compile 'com.tencent.bugly:crashreport:latest.release' |
34 | compile 'org.apache.httpcomponents:httpcore:4.4.1' | 34 | compile 'org.apache.httpcomponents:httpcore:4.4.1' |
35 | compile 'org.apache.httpcomponents:httpclient:4.5' | 35 | compile 'org.apache.httpcomponents:httpclient:4.5' |
36 | compile 'com.android.support:appcompat-v7:25.3.1' | 36 | compile 'com.android.support:appcompat-v7:25.3.1' |
37 | testCompile 'junit:junit:4.12' | 37 | testCompile 'junit:junit:4.12' |
38 | compile project(':circledialog') | 38 | compile project(':circledialog') |
39 | compile project(':pickerview') | 39 | compile project(':pickerview') |
40 | compile files('libs/android-async-http-1.4.8.jar') | 40 | compile files('libs/android-async-http-1.4.8.jar') |
41 | compile 'com.google.code.gson:gson:2.7' | 41 | compile 'com.google.code.gson:gson:2.7' |
42 | compile 'com.zaaach:toprightmenu:1.0' | 42 | compile 'com.zaaach:toprightmenu:1.0' |
43 | compile 'com.facebook.fresco:fresco:1.1.0' | 43 | compile 'com.facebook.fresco:fresco:1.1.0' |
44 | compile'com.android.support:recyclerview-v7:25.+' | 44 | compile'com.android.support:recyclerview-v7:25.+' |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.content.pm.PackageManager; | 4 | import android.content.pm.PackageManager; |
5 | import android.graphics.Color; | 5 | import android.graphics.Color; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.provider.MediaStore; | 9 | import android.provider.MediaStore; |
10 | import android.support.annotation.NonNull; | 10 | import android.support.annotation.NonNull; |
11 | import android.support.v4.content.FileProvider; | 11 | import android.support.v4.content.FileProvider; |
12 | import android.support.v7.app.AppCompatActivity; | 12 | import android.support.v7.app.AppCompatActivity; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.util.Log; | 14 | import android.util.Log; |
15 | import android.view.Gravity; | 15 | import android.view.Gravity; |
16 | import android.view.View; | 16 | import android.view.View; |
17 | import android.widget.AdapterView; | 17 | import android.widget.AdapterView; |
18 | import android.widget.EditText; | 18 | import android.widget.EditText; |
19 | import android.widget.ImageView; | 19 | import android.widget.ImageView; |
20 | import android.widget.TextView; | 20 | import android.widget.TextView; |
21 | import android.widget.Toast; | 21 | import android.widget.Toast; |
22 | 22 | ||
23 | import com.facebook.drawee.backends.pipeline.Fresco; | 23 | import com.facebook.drawee.backends.pipeline.Fresco; |
24 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 24 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
25 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 25 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
26 | import com.facebook.drawee.generic.RoundingParams; | 26 | import com.facebook.drawee.generic.RoundingParams; |
27 | import com.facebook.drawee.interfaces.DraweeController; | 27 | import com.facebook.drawee.interfaces.DraweeController; |
28 | import com.facebook.drawee.view.SimpleDraweeView; | 28 | import com.facebook.drawee.view.SimpleDraweeView; |
29 | import com.hjx.personalcenter.R; | 29 | import com.hjx.personalcenter.R; |
30 | import com.hjx.personalcenter.db.SaveParam; | 30 | import com.hjx.personalcenter.db.SaveParam; |
31 | import com.hjx.personalcenter.http.HttpManager; | 31 | import com.hjx.personalcenter.http.HttpManager; |
32 | import com.hjx.personalcenter.model.FeedBackInfo; | 32 | import com.hjx.personalcenter.model.FeedBackInfo; |
33 | import com.hjx.personalcenter.util.AlertUtils; | 33 | import com.hjx.personalcenter.util.AlertUtils; |
34 | import com.hjx.personalcenter.util.CropUtils; | 34 | import com.hjx.personalcenter.util.CropUtils; |
35 | import com.hjx.personalcenter.util.DialogPermission; | 35 | import com.hjx.personalcenter.util.DialogPermission; |
36 | import com.hjx.personalcenter.util.FileUtil; | 36 | import com.hjx.personalcenter.util.FileUtil; |
37 | import com.hjx.personalcenter.util.GetDate; | 37 | import com.hjx.personalcenter.util.GetDate; |
38 | import com.hjx.personalcenter.util.PermissionUtil; | 38 | import com.hjx.personalcenter.util.PermissionUtil; |
39 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 39 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
40 | import com.mylhyl.circledialog.CircleDialog; | 40 | import com.mylhyl.circledialog.CircleDialog; |
41 | import com.mylhyl.circledialog.callback.ConfigButton; | 41 | import com.mylhyl.circledialog.callback.ConfigButton; |
42 | import com.mylhyl.circledialog.callback.ConfigDialog; | 42 | import com.mylhyl.circledialog.callback.ConfigDialog; |
43 | import com.mylhyl.circledialog.params.ButtonParams; | 43 | import com.mylhyl.circledialog.params.ButtonParams; |
44 | import com.mylhyl.circledialog.params.DialogParams; | 44 | import com.mylhyl.circledialog.params.DialogParams; |
45 | 45 | ||
46 | import java.io.File; | 46 | import java.io.File; |
47 | import java.util.ArrayList; | 47 | import java.util.ArrayList; |
48 | import java.util.List; | 48 | import java.util.List; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Created by h on 2017/8/11. | 51 | * Created by h on 2017/8/11. |
52 | */ | 52 | */ |
53 | 53 | ||
54 | public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener { | 54 | public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener { |
55 | private ImageView iv_cance, iv_show, iv_take; | 55 | private ImageView iv_cance, iv_show, iv_take; |
56 | private EditText content, phone; | 56 | private EditText content, phone; |
57 | private TextView tv_sub; | 57 | private TextView tv_sub; |
58 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 58 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
59 | private static final int REQUEST_CODE_ALBUM = 2; | 59 | private static final int REQUEST_CODE_ALBUM = 2; |
60 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 60 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
61 | SimpleDraweeView mSimpleDraweeView; | 61 | SimpleDraweeView mSimpleDraweeView; |
62 | private File file; | 62 | private File file; |
63 | private Uri uri; | 63 | private Uri uri; |
64 | 64 | ||
65 | @Override | 65 | @Override |
66 | protected void onCreate(Bundle savedInstanceState) { | 66 | protected void onCreate(Bundle savedInstanceState) { |
67 | super.onCreate(savedInstanceState); | 67 | super.onCreate(savedInstanceState); |
68 | Fresco.initialize(this); | 68 | Fresco.initialize(this); |
69 | setContentView(R.layout.activity_feedback); | 69 | setContentView(R.layout.activity_feedback); |
70 | initView(); | 70 | initView(); |
71 | initData(); | 71 | initData(); |
72 | initLister(); | 72 | initLister(); |
73 | } | 73 | } |
74 | 74 | ||
75 | private void initView() { | 75 | private void initView() { |
76 | iv_cance = (ImageView) findViewById(R.id.cancel); | 76 | iv_cance = (ImageView) findViewById(R.id.cancel); |
77 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv); | 77 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv); |
78 | iv_take = (ImageView) findViewById(R.id.iv_take); | 78 | iv_take = (ImageView) findViewById(R.id.iv_take); |
79 | content = (EditText) findViewById(R.id.feedback_content); | 79 | content = (EditText) findViewById(R.id.feedback_content); |
80 | phone = (EditText) findViewById(R.id.feedback_phone); | 80 | phone = (EditText) findViewById(R.id.feedback_phone); |
81 | tv_sub = (TextView) findViewById(R.id.feedback_sub); | 81 | tv_sub = (TextView) findViewById(R.id.feedback_sub); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | private void initData() { | 85 | private void initData() { |
86 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 86 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
87 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 87 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
88 | uri = Uri.fromFile(file); | 88 | uri = Uri.fromFile(file); |
89 | } else { | 89 | } else { |
90 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 90 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
91 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 91 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
92 | } | 92 | } |
93 | 93 | ||
94 | } | 94 | } |
95 | 95 | ||
96 | private void initLister() { | 96 | private void initLister() { |
97 | iv_cance.setOnClickListener(this); | 97 | iv_cance.setOnClickListener(this); |
98 | iv_take.setOnClickListener(this); | 98 | iv_take.setOnClickListener(this); |
99 | tv_sub.setOnClickListener(this); | 99 | tv_sub.setOnClickListener(this); |
100 | mSimpleDraweeView.setOnClickListener(this); | 100 | mSimpleDraweeView.setOnClickListener(this); |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | @Override | 104 | @Override |
105 | public void onClick(View v) { | 105 | public void onClick(View v) { |
106 | String contents = content.getText().toString().trim(); | 106 | String contents = content.getText().toString().trim(); |
107 | String contants = phone.getText().toString().trim(); | 107 | String contants = phone.getText().toString().trim(); |
108 | switch (v.getId()) { | 108 | switch (v.getId()) { |
109 | case R.id.cancel: | 109 | case R.id.cancel: |
110 | finish(); | 110 | finish(); |
111 | break; | 111 | break; |
112 | case R.id.iv_take: | 112 | case R.id.iv_take: |
113 | choiceAvatar(); | 113 | choiceAvatar(); |
114 | break; | 114 | break; |
115 | case R.id.feedback_sub: | 115 | case R.id.feedback_sub: |
116 | //提交用户反馈 | 116 | //提交用户反馈 |
117 | if (TextUtils.isEmpty(contents)) { | 117 | if (TextUtils.isEmpty(contents)) { |
118 | AlertUtils.showToast(FeedBackActivity.this, "请将必填项填写完整"); | 118 | AlertUtils.showToast(FeedBackActivity.this, "请将必填项填写完整"); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | long auserID = 0; | 121 | long auserID = 0; |
122 | GetDate date = new GetDate(); | 122 | GetDate date = new GetDate(); |
123 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | 123 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
124 | try { | 124 | try { |
125 | auserID = Long.parseLong(userID); | 125 | auserID = Long.parseLong(userID); |
126 | 126 | ||
127 | FeedBackInfo feedBackInfo = new FeedBackInfo(); | 127 | FeedBackInfo feedBackInfo = new FeedBackInfo(); |
128 | feedBackInfo.setUserId(auserID); | 128 | feedBackInfo.setUserId(auserID); |
129 | feedBackInfo.setContact(contants); | 129 | feedBackInfo.setContact(contants); |
130 | feedBackInfo.setContent(contents); | 130 | feedBackInfo.setContent(contents); |
131 | feedBackInfo.setFeedBackDate(date.getYMD().toString()); | 131 | feedBackInfo.setFeedBackDate(date.getYMD().toString()); |
132 | feedBackInfo.setFeedtype("个人中心"); | 132 | feedBackInfo.setFeedtype("个人中心"); |
133 | List<FeedBackInfo.ImgUrlBean> feedbackBean = new ArrayList<>(); | 133 | List<FeedBackInfo.ImgUrlBean> feedbackBean = new ArrayList<>(); |
134 | FeedBackInfo.ImgUrlBean imgurl = new FeedBackInfo.ImgUrlBean(); | 134 | FeedBackInfo.ImgUrlBean imgurl = new FeedBackInfo.ImgUrlBean(); |
135 | imgurl.setImgUrl(file.getPath()); | 135 | imgurl.setImgUrl(file.getPath()); |
136 | feedbackBean.add(imgurl); | 136 | feedbackBean.add(imgurl); |
137 | feedBackInfo.setImgUrl(feedbackBean); | 137 | feedBackInfo.setImgUrl(feedbackBean); |
138 | Log.e("test", feedBackInfo.toString()); | 138 | Log.e("test", feedBackInfo.toString()); |
139 | HttpManager.getInstance().feedback(FeedBackActivity.this, feedBackInfo); | 139 | HttpManager.getInstance().feedback(FeedBackActivity.this, feedBackInfo); |
140 | } catch (Exception e) { | 140 | } catch (Exception e) { |
141 | e.printStackTrace(); | 141 | e.printStackTrace(); |
142 | } | 142 | } |
143 | break; | 143 | break; |
144 | case R.id.show_iv: | 144 | case R.id.show_iv: |
145 | 145 | ||
146 | |||
146 | break; | 147 | break; |
147 | } | 148 | } |
148 | } | 149 | } |
149 | 150 | ||
150 | //拍摄头像 | 151 | //拍摄头像 |
151 | private void choiceAvatar() { | 152 | private void choiceAvatar() { |
152 | final String[] items = {"拍照", "从相册选择"}; | 153 | final String[] items = {"拍照", "从相册选择"}; |
153 | new CircleDialog.Builder(this) | 154 | new CircleDialog.Builder(this) |
154 | .configDialog(new ConfigDialog() { | 155 | .configDialog(new ConfigDialog() { |
155 | @Override | 156 | @Override |
156 | public void onConfig(DialogParams params) { | 157 | public void onConfig(DialogParams params) { |
157 | //增加弹出动画 | 158 | //增加弹出动画 |
158 | params.gravity = Gravity.CENTER; | 159 | params.gravity = Gravity.CENTER; |
159 | } | 160 | } |
160 | }) | 161 | }) |
161 | .setTitle("请选择图片来源") | 162 | .setTitle("请选择图片来源") |
162 | .setWidth(0.5f) | 163 | .setWidth(0.5f) |
163 | .setItems(items, new AdapterView.OnItemClickListener() { | 164 | .setItems(items, new AdapterView.OnItemClickListener() { |
164 | @Override | 165 | @Override |
165 | public void onItemClick(AdapterView<?> parent, View view, int | 166 | public void onItemClick(AdapterView<?> parent, View view, int |
166 | position, long id) { | 167 | position, long id) { |
167 | switch (position) { | 168 | switch (position) { |
168 | case 0: | 169 | case 0: |
169 | if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) { | 170 | if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) { |
170 | uploadAvatarFromPhotoRequest(); | 171 | uploadAvatarFromPhotoRequest(); |
171 | } | 172 | } |
172 | break; | 173 | break; |
173 | case 1: | 174 | case 1: |
174 | uploadAvatarFromAlbumRequest(); | 175 | uploadAvatarFromAlbumRequest(); |
175 | break; | 176 | break; |
176 | } | 177 | } |
177 | 178 | ||
178 | } | 179 | } |
179 | }) | 180 | }) |
180 | .setNegative("取消", null) | 181 | .setNegative("取消", null) |
181 | .configNegative(new ConfigButton() { | 182 | .configNegative(new ConfigButton() { |
182 | @Override | 183 | @Override |
183 | public void onConfig(ButtonParams params) { | 184 | public void onConfig(ButtonParams params) { |
184 | //取消按钮字体颜色 | 185 | //取消按钮字体颜色 |
185 | params.textColor = Color.RED; | 186 | params.textColor = Color.RED; |
186 | } | 187 | } |
187 | }) | 188 | }) |
188 | .show(); | 189 | .show(); |
189 | 190 | ||
190 | 191 | ||
191 | } | 192 | } |
192 | 193 | ||
193 | //照相 | 194 | //照相 |
194 | private void uploadAvatarFromPhotoRequest() { | 195 | private void uploadAvatarFromPhotoRequest() { |
195 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 196 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
196 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 197 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
197 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 198 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
198 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 199 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
199 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 200 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
200 | } | 201 | } |
201 | 202 | ||
202 | //选择图库 | 203 | //选择图库 |
203 | private void uploadAvatarFromAlbumRequest() { | 204 | private void uploadAvatarFromAlbumRequest() { |
204 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 205 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
205 | photoPickerIntent.setType("image/*"); | 206 | photoPickerIntent.setType("image/*"); |
206 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 207 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
207 | } | 208 | } |
208 | 209 | ||
209 | //回掉 | 210 | //回掉 |
210 | @Override | 211 | @Override |
211 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 212 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
212 | super.onActivityResult(requestCode, resultCode, data); | 213 | super.onActivityResult(requestCode, resultCode, data); |
213 | if (resultCode != -1) { | 214 | if (resultCode != -1) { |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 217 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
217 | Uri newUri; | 218 | Uri newUri; |
218 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 219 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
219 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 220 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
220 | } else { | 221 | } else { |
221 | newUri = data.getData(); | 222 | newUri = data.getData(); |
222 | } | 223 | } |
223 | if (newUri != null) { | 224 | if (newUri != null) { |
224 | uploadAvatarFromPhoto(); | 225 | uploadAvatarFromPhoto(); |
225 | //裁剪图片 | 226 | //裁剪图片 |
226 | //startPhotoZoom(newUri); | 227 | //startPhotoZoom(newUri); |
227 | } else { | 228 | } else { |
228 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 229 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
229 | } | 230 | } |
230 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 231 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
231 | uploadAvatarFromPhoto(); | 232 | uploadAvatarFromPhoto(); |
232 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 233 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
233 | uploadAvatarFromPhoto(); | 234 | uploadAvatarFromPhoto(); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
237 | private void uploadAvatarFromPhoto() { | 238 | private void uploadAvatarFromPhoto() { |
238 | compressAndUploadAvatar(file.getPath()); | 239 | compressAndUploadAvatar(file.getPath()); |
239 | 240 | ||
240 | } | 241 | } |
241 | 242 | ||
242 | private void compressAndUploadAvatar(String fileSrc) { | 243 | private void compressAndUploadAvatar(String fileSrc) { |
243 | 244 | ||
244 | 245 | ||
245 | //上传到服务器 | 246 | //上传到服务器 |
246 | 247 | ||
247 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 248 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
248 | String mimeType = "image/*"; | 249 | String mimeType = "image/*"; |
249 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 250 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
250 | //String fileName = cover.getName(); | 251 | //String fileName = cover.getName(); |
251 | //HttpManager.getInstance().header(this, fileSrc); | 252 | //HttpManager.getInstance().header(this, fileSrc); |
252 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 253 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
253 | //Fresco设置圆形头像 | 254 | //Fresco设置圆形头像 |
254 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 255 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
255 | GenericDraweeHierarchy hierarchy = builder | 256 | GenericDraweeHierarchy hierarchy = builder |
256 | .setDesiredAspectRatio(1f) | 257 | .setDesiredAspectRatio(1f) |
257 | .setFailureImage(R.mipmap.blank) | 258 | .setFailureImage(R.mipmap.blank) |
258 | //圆形头像 | 259 | //圆形头像 |
259 | .setRoundingParams(RoundingParams.fromCornersRadius(0.7f)) | 260 | .setRoundingParams(RoundingParams.fromCornersRadius(0.7f)) |
260 | .build(); | 261 | .build(); |
261 | 262 | ||
262 | //加载本地图片 | 263 | //加载本地图片 |
263 | Uri uri = Uri.fromFile(cover); | 264 | Uri uri = Uri.fromFile(cover); |
264 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 265 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
265 | .setOldController(mSimpleDraweeView.getController()) | 266 | .setOldController(mSimpleDraweeView.getController()) |
266 | .setUri(uri) | 267 | .setUri(uri) |
267 | .build(); | 268 | .build(); |
268 | mSimpleDraweeView.setHierarchy(hierarchy); | 269 | mSimpleDraweeView.setHierarchy(hierarchy); |
269 | mSimpleDraweeView.setController(controller); | 270 | mSimpleDraweeView.setController(controller); |
270 | 271 | ||
271 | } | 272 | } |
272 | 273 | ||
273 | public void startPhotoZoom(Uri uri) { | 274 | public void startPhotoZoom(Uri uri) { |
274 | Intent intent = new Intent("com.android.camera.action.CROP"); | 275 | Intent intent = new Intent("com.android.camera.action.CROP"); |
275 | intent.setDataAndType(uri, "image/*"); | 276 | intent.setDataAndType(uri, "image/*"); |
276 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 277 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
277 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 278 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
278 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 279 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
279 | intent.putExtra("aspectY", 1);// x:y=1:1 | 280 | intent.putExtra("aspectY", 1);// x:y=1:1 |
280 | // intent.putExtra("outputX", 400);//图片输出大小 | 281 | // intent.putExtra("outputX", 400);//图片输出大小 |
281 | // intent.putExtra("outputY", 400); | 282 | // intent.putExtra("outputY", 400); |
282 | intent.putExtra("output", Uri.fromFile(file)); | 283 | intent.putExtra("output", Uri.fromFile(file)); |
283 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 284 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
284 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 285 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
285 | } | 286 | } |
286 | 287 | ||
287 | @Override | 288 | @Override |
288 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 289 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
289 | switch (requestCode) { | 290 | switch (requestCode) { |
290 | 291 | ||
291 | case PermissionUtil.REQUEST_SHOWCAMERA: | 292 | case PermissionUtil.REQUEST_SHOWCAMERA: |
292 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 293 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
293 | // Permission Granted | 294 | // Permission Granted |
294 | uploadAvatarFromPhotoRequest(); | 295 | uploadAvatarFromPhotoRequest(); |
295 | 296 | ||
296 | } else { | 297 | } else { |
297 | if (!SharedPreferenceMark.getHasShowCamera()) { | 298 | if (!SharedPreferenceMark.getHasShowCamera()) { |
298 | SharedPreferenceMark.setHasShowCamera(true); | 299 | SharedPreferenceMark.setHasShowCamera(true); |
299 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 300 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
300 | 301 | ||
301 | } else { | 302 | } else { |
302 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 303 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
303 | .show(); | 304 | .show(); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | break; | 307 | break; |
307 | default: | 308 | default: |
308 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 309 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
309 | } | 310 | } |
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Build; | 7 | import android.os.Build; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.os.Handler; | 9 | import android.os.Handler; |
10 | import android.os.Message; | 10 | import android.os.Message; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.support.annotation.NonNull; | 12 | import android.support.annotation.NonNull; |
13 | import android.support.v4.content.FileProvider; | 13 | import android.support.v4.content.FileProvider; |
14 | import android.support.v7.app.AppCompatActivity; | 14 | import android.support.v7.app.AppCompatActivity; |
15 | import android.support.v7.widget.LinearLayoutManager; | 15 | import android.support.v7.widget.LinearLayoutManager; |
16 | import android.support.v7.widget.RecyclerView; | 16 | import android.support.v7.widget.RecyclerView; |
17 | import android.view.KeyEvent; | 17 | import android.view.KeyEvent; |
18 | import android.view.View; | 18 | import android.view.View; |
19 | import android.widget.ImageView; | 19 | import android.widget.ImageView; |
20 | import android.widget.LinearLayout; | 20 | import android.widget.LinearLayout; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import com.facebook.drawee.backends.pipeline.Fresco; | 24 | import com.facebook.drawee.backends.pipeline.Fresco; |
25 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | 25 | import com.facebook.drawee.generic.GenericDraweeHierarchy; |
26 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | 26 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; |
27 | import com.facebook.drawee.generic.RoundingParams; | 27 | import com.facebook.drawee.generic.RoundingParams; |
28 | import com.facebook.drawee.interfaces.DraweeController; | 28 | import com.facebook.drawee.interfaces.DraweeController; |
29 | import com.facebook.drawee.view.SimpleDraweeView; | 29 | import com.facebook.drawee.view.SimpleDraweeView; |
30 | import com.hjx.personalcenter.R; | 30 | import com.hjx.personalcenter.R; |
31 | import com.hjx.personalcenter.adapter.GalleryAdapter; | 31 | import com.hjx.personalcenter.adapter.GalleryAdapter; |
32 | import com.hjx.personalcenter.customdialog.HeadDialog; | 32 | import com.hjx.personalcenter.customdialog.HeadDialog; |
33 | import com.hjx.personalcenter.db.SaveParam; | 33 | import com.hjx.personalcenter.db.SaveParam; |
34 | import com.hjx.personalcenter.http.HttpCode; | 34 | import com.hjx.personalcenter.http.HttpCode; |
35 | import com.hjx.personalcenter.http.HttpManager; | 35 | import com.hjx.personalcenter.http.HttpManager; |
36 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 36 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
37 | import com.hjx.personalcenter.model.PesonalInfo; | 37 | import com.hjx.personalcenter.model.PesonalInfo; |
38 | import com.hjx.personalcenter.model.SignInfo; | 38 | import com.hjx.personalcenter.model.SignInfo; |
39 | import com.hjx.personalcenter.update.UpdateChecker; | ||
39 | import com.hjx.personalcenter.util.AlertUtils; | 40 | import com.hjx.personalcenter.util.AlertUtils; |
40 | import com.hjx.personalcenter.util.CropUtils; | 41 | import com.hjx.personalcenter.util.CropUtils; |
41 | import com.hjx.personalcenter.util.DialogPermission; | 42 | import com.hjx.personalcenter.util.DialogPermission; |
42 | import com.hjx.personalcenter.util.FileUtil; | 43 | import com.hjx.personalcenter.util.FileUtil; |
43 | import com.hjx.personalcenter.util.PermissionUtil; | 44 | import com.hjx.personalcenter.util.PermissionUtil; |
44 | import com.hjx.personalcenter.util.SharedPreferenceMark; | 45 | import com.hjx.personalcenter.util.SharedPreferenceMark; |
45 | import com.mylhyl.circledialog.CircleDialog; | 46 | import com.mylhyl.circledialog.CircleDialog; |
46 | import com.mylhyl.circledialog.callback.ConfigInput; | 47 | import com.mylhyl.circledialog.callback.ConfigInput; |
47 | import com.mylhyl.circledialog.params.InputParams; | 48 | import com.mylhyl.circledialog.params.InputParams; |
48 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; | 49 | import com.mylhyl.circledialog.view.listener.OnInputClickListener; |
49 | import com.zaaach.toprightmenu.MenuItem; | 50 | import com.zaaach.toprightmenu.MenuItem; |
50 | import com.zaaach.toprightmenu.TopRightMenu; | 51 | import com.zaaach.toprightmenu.TopRightMenu; |
51 | 52 | ||
52 | import java.io.File; | 53 | import java.io.File; |
53 | import java.util.ArrayList; | 54 | import java.util.ArrayList; |
54 | import java.util.Arrays; | 55 | import java.util.Arrays; |
55 | import java.util.List; | 56 | import java.util.List; |
56 | 57 | ||
57 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { | 58 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView { |
58 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; | 59 | private ImageView iv_imformatioan, iv_look_card, iv_setting, iv_sign, iv_sex; |
59 | private TextView tv_edit_presoninfo, tv_sign, | 60 | private TextView tv_edit_presoninfo, tv_sign, |
60 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, | 61 | tv_username, tv_username1, tv_mygad, tv_sex, tv_useinfo_adress, tv_useinfo_birthday, |
61 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; | 62 | tv_useinfo_qq, tv_useinfo_school, tv_useinfo_gender; |
62 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; | 63 | private LinearLayout linel_mycuoti, linel_mynote, linel_mycollege, linel_myclass; |
63 | private TopRightMenu mTopRightMenu; | 64 | private TopRightMenu mTopRightMenu; |
64 | //水平滑动 | 65 | //水平滑动 |
65 | private RecyclerView mRecyclerView; | 66 | private RecyclerView mRecyclerView; |
66 | private GalleryAdapter RecyclerViewadapter; | 67 | private GalleryAdapter RecyclerViewadapter; |
67 | private List<Integer> mDatas = new ArrayList<Integer>(Arrays.asList(R.mipmap.default_avatar2, | 68 | private List<Integer> mDatas = new ArrayList<Integer>(Arrays.asList(R.mipmap.default_avatar2, |
68 | R.mipmap.default_avatar2, R.mipmap.default_avatar2, R.mipmap.default_avatar2)); | 69 | R.mipmap.default_avatar2, R.mipmap.default_avatar2, R.mipmap.default_avatar2)); |
69 | private boolean showIcon = true; | 70 | private boolean showIcon = true; |
70 | private boolean dimBg = true; | 71 | private boolean dimBg = true; |
71 | private boolean needAnim = true; | 72 | private boolean needAnim = true; |
72 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | 73 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
73 | private static final int REQUEST_CODE_ALBUM = 2; | 74 | private static final int REQUEST_CODE_ALBUM = 2; |
74 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | 75 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
75 | SimpleDraweeView mSimpleDraweeView; | 76 | SimpleDraweeView mSimpleDraweeView; |
76 | private File file; | 77 | private File file; |
77 | private Uri uri; | 78 | private Uri uri; |
78 | Handler handler = new Handler(){ | 79 | Handler handler = new Handler(){ |
79 | @Override | 80 | @Override |
80 | public void handleMessage(Message msg) { | 81 | public void handleMessage(Message msg) { |
81 | super.handleMessage(msg); | 82 | super.handleMessage(msg); |
82 | switch (msg.what){ | 83 | switch (msg.what){ |
83 | case HttpCode.GETINFO: | 84 | case HttpCode.GETINFO: |
84 | PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj; | 85 | PesonalInfo.DataBean cardinfoBean =(PesonalInfo.DataBean)msg.obj; |
85 | tv_username.setText(cardinfoBean.getNickName()); | 86 | tv_username.setText(cardinfoBean.getNickName()); |
86 | tv_username1.setText(cardinfoBean.getNickName()); | 87 | tv_username1.setText(cardinfoBean.getNickName()); |
87 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); | 88 | tv_useinfo_adress.setText(cardinfoBean.getRegion().getRegionName()); |
88 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); | 89 | tv_useinfo_birthday.setText(cardinfoBean.getBirthday()); |
89 | tv_useinfo_qq.setText(cardinfoBean.getQq()); | 90 | tv_useinfo_qq.setText(cardinfoBean.getQq()); |
90 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); | 91 | tv_useinfo_school.setText(cardinfoBean.getSchool().getSchoolName()); |
91 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); | 92 | tv_useinfo_gender.setText(cardinfoBean.getGrade().getGradeName()); |
92 | String sex = cardinfoBean.getGender(); | 93 | String sex = cardinfoBean.getGender(); |
93 | if ("0".equals(sex)){ | 94 | if ("0".equals(sex)){ |
94 | tv_sex.setText("男"); | 95 | tv_sex.setText("男"); |
95 | iv_sex.setImageResource(R.mipmap.men); | 96 | iv_sex.setImageResource(R.mipmap.men); |
96 | }else { | 97 | }else { |
97 | tv_sex.setText("女"); | 98 | tv_sex.setText("女"); |
98 | iv_sex.setImageResource(R.mipmap.women); | 99 | iv_sex.setImageResource(R.mipmap.women); |
99 | } | 100 | } |
100 | break; | 101 | break; |
101 | case HttpCode.SIGN: | 102 | case HttpCode.SIGN: |
102 | SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; | 103 | SignInfo.DataBean dataBean = (SignInfo.DataBean)msg.obj; |
103 | if (dataBean.getSignature()==null){ | 104 | if (dataBean.getSignature()==null){ |
104 | tv_sign.setText("你还未设置个性签名"); | 105 | tv_sign.setText("你还未设置个性签名"); |
105 | }else { | 106 | }else { |
106 | tv_sign.setText(dataBean.getSignature()); | 107 | tv_sign.setText(dataBean.getSignature()); |
107 | } | 108 | } |
108 | 109 | ||
109 | break; | 110 | break; |
110 | } | 111 | } |
111 | } | 112 | } |
112 | }; | 113 | }; |
113 | 114 | ||
114 | @Override | 115 | @Override |
115 | protected void onCreate(Bundle savedInstanceState) { | 116 | protected void onCreate(Bundle savedInstanceState) { |
116 | super.onCreate(savedInstanceState); | 117 | super.onCreate(savedInstanceState); |
117 | Fresco.initialize(this); | 118 | Fresco.initialize(this); |
118 | setContentView(R.layout.activity_main); | 119 | setContentView(R.layout.activity_main); |
119 | initView(); | 120 | initView(); |
120 | initData(); | 121 | initData(); |
121 | initLister(); | 122 | initLister(); |
123 | updateVersion(); | ||
124 | } | ||
125 | //////版本更新 | ||
126 | private void updateVersion() { | ||
127 | UpdateChecker updateChecker = new UpdateChecker(this); | ||
128 | updateChecker.checkForUpdates(); | ||
129 | |||
130 | |||
122 | } | 131 | } |
123 | 132 | ||
124 | private void initView() { | 133 | private void initView() { |
125 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); | 134 | iv_imformatioan = (ImageView) findViewById(R.id.iv_imformatioan); |
126 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); | 135 | iv_look_card = (ImageView) findViewById(R.id.iv_look_card); |
127 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); | 136 | tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo); |
128 | iv_setting = (ImageView) findViewById(R.id.iv_setting); | 137 | iv_setting = (ImageView) findViewById(R.id.iv_setting); |
129 | iv_sign = (ImageView) findViewById(R.id.iv_sign); | 138 | iv_sign = (ImageView) findViewById(R.id.iv_sign); |
130 | tv_sign = (TextView) findViewById(R.id.tv_sign); | 139 | tv_sign = (TextView) findViewById(R.id.tv_sign); |
131 | //头像 | 140 | //头像 |
132 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); | 141 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.iv_head); |
133 | //初始化个人信息 | 142 | //初始化个人信息 |
134 | iv_sex = (ImageView) findViewById(R.id.iv_sex); | 143 | iv_sex = (ImageView) findViewById(R.id.iv_sex); |
135 | tv_username = (TextView) findViewById(R.id.tv_username); | 144 | tv_username = (TextView) findViewById(R.id.tv_username); |
136 | tv_username1 = (TextView) findViewById(R.id.tv_username1); | 145 | tv_username1 = (TextView) findViewById(R.id.tv_username1); |
137 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); | 146 | tv_mygad = (TextView) findViewById(R.id.tv_mygad); |
138 | tv_sex = (TextView) findViewById(R.id.tv_sex); | 147 | tv_sex = (TextView) findViewById(R.id.tv_sex); |
139 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); | 148 | tv_useinfo_adress = (TextView) findViewById(R.id.tv_useinfo_adress); |
140 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); | 149 | tv_useinfo_birthday = (TextView) findViewById(R.id.tv_useinfo_birthday); |
141 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); | 150 | tv_useinfo_qq = (TextView) findViewById(R.id.tv_useinfo_qq); |
142 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); | 151 | tv_useinfo_school = (TextView) findViewById(R.id.tv_useinfo_school); |
143 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); | 152 | tv_useinfo_gender = (TextView) findViewById(R.id.tv_useinfo_gender); |
144 | //跳转其他应用 | 153 | //跳转其他应用 |
145 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); | 154 | linel_mycuoti = (LinearLayout) findViewById(R.id.linel_mycuoti); |
146 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); | 155 | linel_mynote = (LinearLayout) findViewById(R.id.linel_mynote); |
147 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); | 156 | linel_mycollege = (LinearLayout) findViewById(R.id.linel_mycollege); |
148 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); | 157 | linel_myclass = (LinearLayout) findViewById(R.id.linel_myclass); |
149 | // | 158 | // |
150 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); | 159 | mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal); |
151 | 160 | ||
152 | } | 161 | } |
153 | 162 | ||
154 | 163 | ||
155 | private void initData() { | 164 | private void initData() { |
156 | //加载最近学习视频 | 165 | //加载最近学习视频 |
157 | 166 | ||
158 | 167 | ||
159 | //设置布局管理器 | 168 | //设置布局管理器 |
160 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | 169 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); |
161 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); | 170 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
162 | mRecyclerView.setLayoutManager(linearLayoutManager); | 171 | mRecyclerView.setLayoutManager(linearLayoutManager); |
163 | //设置适配器 | 172 | //设置适配器 |
164 | RecyclerViewadapter = new GalleryAdapter(this, mDatas); | 173 | RecyclerViewadapter = new GalleryAdapter(this, mDatas); |
165 | mRecyclerView.setAdapter(RecyclerViewadapter); | 174 | mRecyclerView.setAdapter(RecyclerViewadapter); |
166 | 175 | ||
167 | //加载个人信息 | 176 | //加载个人信息 |
168 | String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION); | 177 | String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION); |
169 | if (xiongzuo==null){ | 178 | if (xiongzuo==null){ |
170 | tv_mygad.setText(""); | 179 | tv_mygad.setText(""); |
171 | }else { | 180 | }else { |
172 | tv_mygad.setText(xiongzuo); | 181 | tv_mygad.setText(xiongzuo); |
173 | } | 182 | } |
174 | //加载版本信息 | 183 | //加载版本信息 |
175 | 184 | ||
176 | 185 | ||
177 | //获取个性签名 | 186 | //获取个性签名 |
178 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 187 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
179 | try { | 188 | try { |
180 | long auserID = Long.parseLong(userID); | 189 | long auserID = Long.parseLong(userID); |
181 | HttpManager.getInstance().getsignatures(MainActivity.this,auserID,handler); | 190 | HttpManager.getInstance().getsignatures(MainActivity.this,auserID,handler); |
182 | 191 | ||
183 | } catch (NumberFormatException e) { | 192 | } catch (NumberFormatException e) { |
184 | e.printStackTrace(); | 193 | e.printStackTrace(); |
185 | } | 194 | } |
186 | 195 | ||
187 | 196 | ||
188 | 197 | ||
189 | //初始化图片 | 198 | //初始化图片 |
190 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | 199 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); |
191 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 200 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
192 | uri = Uri.fromFile(file); | 201 | uri = Uri.fromFile(file); |
193 | } else { | 202 | } else { |
194 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | 203 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) |
195 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | 204 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); |
196 | } | 205 | } |
197 | 206 | ||
198 | } | 207 | } |
199 | 208 | ||
200 | private void initLister() { | 209 | private void initLister() { |
201 | iv_imformatioan.setOnClickListener(this); | 210 | iv_imformatioan.setOnClickListener(this); |
202 | iv_look_card.setOnClickListener(this); | 211 | iv_look_card.setOnClickListener(this); |
203 | tv_edit_presoninfo.setOnClickListener(this); | 212 | tv_edit_presoninfo.setOnClickListener(this); |
204 | iv_setting.setOnClickListener(this); | 213 | iv_setting.setOnClickListener(this); |
205 | iv_sign.setOnClickListener(this); | 214 | iv_sign.setOnClickListener(this); |
206 | mSimpleDraweeView.setOnClickListener(this); | 215 | mSimpleDraweeView.setOnClickListener(this); |
207 | linel_mycuoti.setOnClickListener(this); | 216 | linel_mycuoti.setOnClickListener(this); |
208 | linel_mynote.setOnClickListener(this); | 217 | linel_mynote.setOnClickListener(this); |
209 | linel_mycollege.setOnClickListener(this); | 218 | linel_mycollege.setOnClickListener(this); |
210 | linel_myclass.setOnClickListener(this); | 219 | linel_myclass.setOnClickListener(this); |
211 | 220 | ||
212 | } | 221 | } |
213 | 222 | ||
214 | @Override | 223 | @Override |
215 | public void onClick(View v) { | 224 | public void onClick(View v) { |
216 | switch (v.getId()) { | 225 | switch (v.getId()) { |
217 | case R.id.iv_imformatioan: | 226 | case R.id.iv_imformatioan: |
218 | Intent intent = new Intent(); | 227 | Intent intent = new Intent(); |
219 | intent.setClass(MainActivity.this, FeedBackActivity.class); | 228 | intent.setClass(MainActivity.this, FeedBackActivity.class); |
220 | startActivity(intent); | 229 | startActivity(intent); |
221 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 230 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
222 | break; | 231 | break; |
223 | case R.id.iv_look_card: | 232 | case R.id.iv_look_card: |
224 | Intent lookintent = new Intent(); | 233 | Intent lookintent = new Intent(); |
225 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); | 234 | lookintent.setClass(MainActivity.this, ElectronicCardLookInfoActivity.class); |
226 | startActivity(lookintent); | 235 | startActivity(lookintent); |
227 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 236 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
228 | break; | 237 | break; |
229 | case R.id.tv_edit_presoninfo: | 238 | case R.id.tv_edit_presoninfo: |
230 | Intent editintent = new Intent(); | 239 | Intent editintent = new Intent(); |
231 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); | 240 | editintent.setClass(MainActivity.this, ChangePresonalInfoActivity.class); |
232 | startActivity(editintent); | 241 | startActivity(editintent); |
233 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 242 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
234 | break; | 243 | break; |
235 | case R.id.iv_head: | 244 | case R.id.iv_head: |
236 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); | 245 | HeadDialog.getInstance(this).show(getSupportFragmentManager(), "HeadDialog"); |
237 | break; | 246 | break; |
238 | case R.id.iv_setting: | 247 | case R.id.iv_setting: |
239 | mTopRightMenu = new TopRightMenu(MainActivity.this); | 248 | mTopRightMenu = new TopRightMenu(MainActivity.this); |
240 | List<MenuItem> menuItems = new ArrayList<>(); | 249 | List<MenuItem> menuItems = new ArrayList<>(); |
241 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); | 250 | menuItems.add(new MenuItem(R.mipmap.blank, "切换账户")); |
242 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); | 251 | menuItems.add(new MenuItem(R.mipmap.blank, "账户管理")); |
243 | mTopRightMenu | 252 | mTopRightMenu |
244 | .setHeight(150) //默认高度480 | 253 | .setHeight(150) //默认高度480 |
245 | .setWidth(320) //默认宽度wrap_content | 254 | .setWidth(320) //默认宽度wrap_content |
246 | .showIcon(showIcon) //显示菜单图标,默认为true | 255 | .showIcon(showIcon) //显示菜单图标,默认为true |
247 | .dimBackground(dimBg) //背景变暗,默认为true | 256 | .dimBackground(dimBg) //背景变暗,默认为true |
248 | .needAnimationStyle(needAnim) //显示动画,默认为true | 257 | .needAnimationStyle(needAnim) //显示动画,默认为true |
249 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE | 258 | .setAnimationStyle(R.style.TRM_ANIM_STYLE) //默认为R.style.TRM_ANIM_STYLE |
250 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { | 259 | .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() { |
251 | @Override | 260 | @Override |
252 | public void onMenuItemClick(int position) { | 261 | public void onMenuItemClick(int position) { |
253 | switch (position) { | 262 | switch (position) { |
254 | case 0: | 263 | case 0: |
255 | //清除数据 | 264 | //清除数据 |
256 | SaveParam.getInstance().clearData(MainActivity.this); | 265 | SaveParam.getInstance().clearData(MainActivity.this); |
257 | Intent settingintent = new Intent(); | 266 | Intent settingintent = new Intent(); |
258 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); | 267 | settingintent.setClass(MainActivity.this, LoginAndRegisterActivity.class); |
259 | startActivity(settingintent); | 268 | startActivity(settingintent); |
260 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 269 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
261 | break; | 270 | break; |
262 | case 1: | 271 | case 1: |
263 | Intent accontMintent = new Intent(); | 272 | Intent accontMintent = new Intent(); |
264 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); | 273 | accontMintent.setClass(MainActivity.this, AccountManagementActivity.class); |
265 | startActivity(accontMintent); | 274 | startActivity(accontMintent); |
266 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 275 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
267 | break; | 276 | break; |
268 | } | 277 | } |
269 | } | 278 | } |
270 | }) | 279 | }) |
271 | .addMenuList(menuItems) | 280 | .addMenuList(menuItems) |
272 | .showAsDropDown(iv_setting, -250, 0); | 281 | .showAsDropDown(iv_setting, -250, 0); |
273 | break; | 282 | break; |
274 | case R.id.iv_sign: | 283 | case R.id.iv_sign: |
275 | new CircleDialog.Builder(this) | 284 | new CircleDialog.Builder(this) |
276 | .setCanceledOnTouchOutside(false) | 285 | .setCanceledOnTouchOutside(false) |
277 | .setCancelable(true) | 286 | .setCancelable(true) |
278 | .setTitle("个性签名") | 287 | .setTitle("个性签名") |
279 | .setInputHint("请输入个性签名") | 288 | .setInputHint("请输入个性签名") |
280 | .setWidth(0.5f) | 289 | .setWidth(0.5f) |
281 | .configInput(new ConfigInput() { | 290 | .configInput(new ConfigInput() { |
282 | @Override | 291 | @Override |
283 | public void onConfig(InputParams params) { | 292 | public void onConfig(InputParams params) { |
284 | // params.inputBackgroundResourceId = R.drawable.bg_input; | 293 | // params.inputBackgroundResourceId = R.drawable.bg_input; |
285 | } | 294 | } |
286 | }) | 295 | }) |
287 | .setNegative("取消", null) | 296 | .setNegative("取消", null) |
288 | .setPositiveInput("确定", new OnInputClickListener() { | 297 | .setPositiveInput("确定", new OnInputClickListener() { |
289 | @Override | 298 | @Override |
290 | public void onClick(String text, View v) { | 299 | public void onClick(String text, View v) { |
291 | if (text.equals("")) { | 300 | if (text.equals("")) { |
292 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); | 301 | AlertUtils.showToast(MainActivity.this, "请输入个性签名"); |
293 | } else { | 302 | } else { |
294 | try { | 303 | try { |
295 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); | 304 | String userID = SaveParam.getInstance().getLoginParam(MainActivity.this,"userId"); |
296 | long auserID = Long.parseLong(userID); | 305 | long auserID = Long.parseLong(userID); |
297 | HttpManager.getInstance().changsignature(MainActivity.this,auserID,text); | 306 | HttpManager.getInstance().changsignature(MainActivity.this,auserID,text); |
298 | } catch (NumberFormatException e) { | 307 | } catch (NumberFormatException e) { |
299 | e.printStackTrace(); | 308 | e.printStackTrace(); |
300 | } | 309 | } |
301 | 310 | ||
302 | tv_sign.setText(text); | 311 | tv_sign.setText(text); |
303 | } | 312 | } |
304 | 313 | ||
305 | } | 314 | } |
306 | }) | 315 | }) |
307 | .show(); | 316 | .show(); |
308 | break; | 317 | break; |
309 | case R.id.linel_mycuoti: | 318 | case R.id.linel_mycuoti: |
310 | AlertUtils.showToast(this, "hhahahah "); | 319 | AlertUtils.showToast(this, "hhahahah "); |
311 | break; | 320 | break; |
312 | case R.id.linel_mynote: | 321 | case R.id.linel_mynote: |
313 | AlertUtils.showToast(this, "hhahahah "); | 322 | AlertUtils.showToast(this, "hhahahah "); |
314 | break; | 323 | break; |
315 | case R.id.linel_mycollege: | 324 | case R.id.linel_mycollege: |
316 | AlertUtils.showToast(this, "hhahahah "); | 325 | AlertUtils.showToast(this, "hhahahah "); |
317 | break; | 326 | break; |
318 | case R.id.linel_myclass: | 327 | case R.id.linel_myclass: |
319 | AlertUtils.showToast(this, "hhahahah "); | 328 | AlertUtils.showToast(this, "hhahahah "); |
320 | break; | 329 | break; |
321 | } | 330 | } |
322 | 331 | ||
323 | } | 332 | } |
324 | 333 | ||
325 | @Override | 334 | @Override |
326 | protected void onResume() { | 335 | protected void onResume() { |
327 | super.onResume(); | 336 | super.onResume(); |
328 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 337 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
329 | try { | 338 | try { |
330 | long auserID = Long.parseLong(userID); | 339 | long auserID = Long.parseLong(userID); |
331 | //获取个人信息 | 340 | //获取个人信息 |
332 | HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,handler); | 341 | HttpManager.getInstance().getpresonalinfo(MainActivity.this,auserID,handler); |
333 | 342 | ||
334 | } catch (NumberFormatException e) { | 343 | } catch (NumberFormatException e) { |
335 | e.printStackTrace(); | 344 | e.printStackTrace(); |
336 | } | 345 | } |
337 | 346 | ||
338 | } | 347 | } |
339 | 348 | ||
340 | //回调头像监听 | 349 | //回调头像监听 |
341 | @Override | 350 | @Override |
342 | public void heard(Context context, View v,int headpitiaon) { | 351 | public void heard(Context context, View v,int headpitiaon) { |
352 | String picUrl; | ||
343 | switch (v.getId()){ | 353 | switch (v.getId()){ |
344 | //选择默认图片 | 354 | //选择默认图片 |
345 | case R.id.oktakephone: | 355 | case R.id.oktakephone: |
346 | if (headpitiaon==1){ | 356 | if (headpitiaon==1){ |
347 | mSimpleDraweeView.setImageDrawable(null); | 357 | mSimpleDraweeView.setImageDrawable(null); |
348 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); | 358 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar1); |
359 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/61e8d8cf-651f-49c9-beb2-ff1387af390a.png"; | ||
349 | }else if (headpitiaon==2){ | 360 | }else if (headpitiaon==2){ |
350 | mSimpleDraweeView.setImageDrawable(null); | 361 | mSimpleDraweeView.setImageDrawable(null); |
351 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); | 362 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar2); |
363 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/8480ff7b-42f1-4d64-b848-c8f4f3afd385.png"; | ||
352 | }else if (headpitiaon==3){ | 364 | }else if (headpitiaon==3){ |
353 | mSimpleDraweeView.setImageDrawable(null); | 365 | mSimpleDraweeView.setImageDrawable(null); |
354 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); | 366 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar3); |
367 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/184112f4-bfe0-4db8-bc1e-6212755b241c.png"; | ||
355 | }else if (headpitiaon==4){ | 368 | }else if (headpitiaon==4){ |
356 | mSimpleDraweeView.setImageDrawable(null); | 369 | mSimpleDraweeView.setImageDrawable(null); |
357 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); | 370 | mSimpleDraweeView.setImageResource(R.mipmap.default_avatar4); |
371 | picUrl = "http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/e31c9e11-9276-4bf4-a162-b66272fdc351.png "; | ||
358 | }else if (headpitiaon==0){ | 372 | }else if (headpitiaon==0){ |
359 | AlertUtils.showToast(this, "你还没有设置头像 "); | 373 | AlertUtils.showToast(this, "你还没有设置头像 "); |
360 | } | 374 | } |
361 | break; | 375 | break; |
362 | case R.id.canceltakephone: | 376 | case R.id.canceltakephone: |
363 | 377 | ||
364 | break; | 378 | break; |
365 | //拍摄和相册 | 379 | //拍摄和相册 |
366 | case R.id.take_pic: | 380 | case R.id.take_pic: |
367 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { | 381 | if (PermissionUtil.hasCameraPermission(MainActivity.this)) { |
368 | uploadAvatarFromPhotoRequest(); | 382 | uploadAvatarFromPhotoRequest(); |
369 | } | 383 | } |
370 | 384 | ||
371 | break; | 385 | break; |
372 | case R.id.xiangce: | 386 | case R.id.xiangce: |
373 | uploadAvatarFromAlbumRequest(); | 387 | uploadAvatarFromAlbumRequest(); |
374 | break; | 388 | break; |
375 | 389 | ||
376 | } | 390 | } |
377 | 391 | ||
378 | } | 392 | } |
379 | 393 | ||
380 | //照相 | 394 | //照相 |
381 | private void uploadAvatarFromPhotoRequest() { | 395 | private void uploadAvatarFromPhotoRequest() { |
382 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 396 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
383 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 397 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
384 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | 398 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); |
385 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | 399 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
386 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | 400 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
387 | } | 401 | } |
388 | 402 | ||
389 | //选择图库 | 403 | //选择图库 |
390 | private void uploadAvatarFromAlbumRequest() { | 404 | private void uploadAvatarFromAlbumRequest() { |
391 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 405 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
392 | photoPickerIntent.setType("image/*"); | 406 | photoPickerIntent.setType("image/*"); |
393 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | 407 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); |
394 | } | 408 | } |
395 | //回掉 | 409 | //回掉 |
396 | @Override | 410 | @Override |
397 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 411 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
398 | super.onActivityResult(requestCode, resultCode, data); | 412 | super.onActivityResult(requestCode, resultCode, data); |
399 | if (resultCode != -1) { | 413 | if (resultCode != -1) { |
400 | return; | 414 | return; |
401 | } | 415 | } |
402 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | 416 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { |
403 | Uri newUri; | 417 | Uri newUri; |
404 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 418 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
405 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | 419 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); |
406 | } else { | 420 | } else { |
407 | newUri = data.getData(); | 421 | newUri = data.getData(); |
408 | } | 422 | } |
409 | if (newUri != null) { | 423 | if (newUri != null) { |
410 | startPhotoZoom(newUri); | 424 | startPhotoZoom(newUri); |
411 | } else { | 425 | } else { |
412 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | 426 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
413 | } | 427 | } |
414 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | 428 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
415 | startPhotoZoom(uri); | 429 | startPhotoZoom(uri); |
416 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | 430 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
417 | uploadAvatarFromPhoto(); | 431 | uploadAvatarFromPhoto(); |
418 | } | 432 | } |
419 | } | 433 | } |
420 | 434 | ||
421 | private void uploadAvatarFromPhoto() { | 435 | private void uploadAvatarFromPhoto() { |
422 | compressAndUploadAvatar(file.getPath()); | 436 | compressAndUploadAvatar(file.getPath()); |
423 | 437 | ||
424 | } | 438 | } |
425 | private void compressAndUploadAvatar(String fileSrc) { | 439 | private void compressAndUploadAvatar(String fileSrc) { |
426 | 440 | ||
427 | 441 | ||
428 | //上传到服务器 | 442 | //上传到服务器 |
429 | 443 | ||
430 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | 444 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); |
431 | String mimeType = "image/*"; | 445 | String mimeType = "image/*"; |
432 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | 446 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); |
433 | //String fileName = cover.getName(); | 447 | //String fileName = cover.getName(); |
434 | //HttpManager.getInstance().header(this, fileSrc); | 448 | //HttpManager.getInstance().header(this, fileSrc); |
435 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | 449 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); |
436 | //Fresco设置圆形头像 | 450 | //Fresco设置圆形头像 |
437 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | 451 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
438 | GenericDraweeHierarchy hierarchy = builder | 452 | GenericDraweeHierarchy hierarchy = builder |
439 | .setDesiredAspectRatio(1f) | 453 | .setDesiredAspectRatio(1f) |
440 | .setFailureImage(R.mipmap.blank) | 454 | .setFailureImage(R.mipmap.blank) |
441 | //圆形头像 | 455 | //圆形头像 |
442 | .setRoundingParams(RoundingParams.asCircle()) | 456 | .setRoundingParams(RoundingParams.asCircle()) |
443 | .build(); | 457 | .build(); |
444 | 458 | ||
445 | //加载本地图片 | 459 | //加载本地图片 |
446 | Uri uri = Uri.fromFile(cover); | 460 | Uri uri = Uri.fromFile(cover); |
447 | DraweeController controller = Fresco.newDraweeControllerBuilder() | 461 | DraweeController controller = Fresco.newDraweeControllerBuilder() |
448 | .setOldController(mSimpleDraweeView.getController()) | 462 | .setOldController(mSimpleDraweeView.getController()) |
449 | .setUri(uri) | 463 | .setUri(uri) |
450 | .build(); | 464 | .build(); |
451 | mSimpleDraweeView.setHierarchy(hierarchy); | 465 | mSimpleDraweeView.setHierarchy(hierarchy); |
452 | mSimpleDraweeView.setController(controller); | 466 | mSimpleDraweeView.setController(controller); |
453 | 467 | ||
454 | } | 468 | } |
455 | 469 | ||
456 | public void startPhotoZoom(Uri uri) { | 470 | public void startPhotoZoom(Uri uri) { |
457 | Intent intent = new Intent("com.android.camera.action.CROP"); | 471 | Intent intent = new Intent("com.android.camera.action.CROP"); |
458 | intent.setDataAndType(uri, "image/*"); | 472 | intent.setDataAndType(uri, "image/*"); |
459 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 473 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
460 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | 474 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. |
461 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | 475 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. |
462 | intent.putExtra("aspectY", 1);// x:y=1:1 | 476 | intent.putExtra("aspectY", 1);// x:y=1:1 |
463 | // intent.putExtra("outputX", 400);//图片输出大小 | 477 | // intent.putExtra("outputX", 400);//图片输出大小 |
464 | // intent.putExtra("outputY", 400); | 478 | // intent.putExtra("outputY", 400); |
465 | intent.putExtra("output", Uri.fromFile(file)); | 479 | intent.putExtra("output", Uri.fromFile(file)); |
466 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | 480 | intent.putExtra("outputFormat", "JPEG");// 返回格式 |
467 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | 481 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); |
468 | } | 482 | } |
469 | 483 | ||
470 | @Override | 484 | @Override |
471 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 485 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
472 | switch (requestCode) { | 486 | switch (requestCode) { |
473 | 487 | ||
474 | case PermissionUtil.REQUEST_SHOWCAMERA: | 488 | case PermissionUtil.REQUEST_SHOWCAMERA: |
475 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 489 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
476 | // Permission Granted | 490 | // Permission Granted |
477 | uploadAvatarFromPhotoRequest(); | 491 | uploadAvatarFromPhotoRequest(); |
478 | 492 | ||
479 | } else { | 493 | } else { |
480 | if (!SharedPreferenceMark.getHasShowCamera()) { | 494 | if (!SharedPreferenceMark.getHasShowCamera()) { |
481 | SharedPreferenceMark.setHasShowCamera(true); | 495 | SharedPreferenceMark.setHasShowCamera(true); |
482 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | 496 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); |
483 | 497 | ||
484 | } else { | 498 | } else { |
485 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | 499 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) |
486 | .show(); | 500 | .show(); |
487 | } | 501 | } |
488 | } | 502 | } |
489 | break; | 503 | break; |
490 | default: | 504 | default: |
491 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 505 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
492 | } | 506 | } |
493 | } | 507 | } |
494 | private long exitTime = 0; | 508 | private long exitTime = 0; |
495 | @Override | 509 | @Override |
496 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 510 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
497 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 511 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
498 | if ((System.currentTimeMillis() - exitTime) > 2000) { | 512 | if ((System.currentTimeMillis() - exitTime) > 2000) { |
499 | Toast.makeText(getApplicationContext(), "再按一次退出程序", | 513 | Toast.makeText(getApplicationContext(), "再按一次退出程序", |
500 | Toast.LENGTH_SHORT).show(); | 514 | Toast.LENGTH_SHORT).show(); |
501 | exitTime = System.currentTimeMillis(); | 515 | exitTime = System.currentTimeMillis(); |
502 | } else { | 516 | } else { |
503 | finish(); | 517 | finish(); |
504 | System.exit(0); | 518 | System.exit(0); |
505 | } | 519 | } |
506 | return false; | 520 | return false; |
507 | } | 521 | } |
508 | return super.onKeyDown(keyCode, event); | 522 | return super.onKeyDown(keyCode, event); |
509 | } | 523 | } |
510 | } | 524 | } |
511 | 525 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
6 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
7 | import android.view.KeyEvent; | 7 | import android.view.KeyEvent; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.widget.Button; | 9 | import android.widget.Button; |
10 | import android.widget.EditText; | 10 | import android.widget.EditText; |
11 | import android.widget.TextView; | 11 | import android.widget.TextView; |
12 | 12 | ||
13 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
14 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 14 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
15 | import com.hjx.personalcenter.customdialog.CountryDialog; | 15 | import com.hjx.personalcenter.customdialog.CountryDialog; |
16 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 16 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
17 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 17 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
18 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 18 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
19 | import com.hjx.personalcenter.db.Content; | 19 | import com.hjx.personalcenter.db.Content; |
20 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
21 | import com.hjx.personalcenter.http.HttpManager; | 21 | import com.hjx.personalcenter.http.HttpManager; |
22 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 22 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
23 | import com.hjx.personalcenter.model.CityInfo; | 23 | import com.hjx.personalcenter.model.CityInfo; |
24 | import com.hjx.personalcenter.model.CountyInfo; | 24 | import com.hjx.personalcenter.model.CountyInfo; |
25 | import com.hjx.personalcenter.model.GradeInfo; | 25 | import com.hjx.personalcenter.model.GradeInfo; |
26 | import com.hjx.personalcenter.model.ProvinceInfo; | 26 | import com.hjx.personalcenter.model.ProvinceInfo; |
27 | import com.hjx.personalcenter.model.SchoolInfo; | 27 | import com.hjx.personalcenter.model.SchoolInfo; |
28 | import com.hjx.personalcenter.util.AlertUtils; | 28 | import com.hjx.personalcenter.util.AlertUtils; |
29 | 29 | ||
30 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
31 | 31 | ||
32 | /**填写注册信息 熊巍 | 32 | /**填写注册信息 熊巍 |
33 | * Created by h on 2017/8/9. | 33 | * Created by h on 2017/8/9. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.GradeCallBack,DialogCallBack.ProvincesCallBack | 36 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.GradeCallBack,DialogCallBack.ProvincesCallBack |
37 | ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack,DialogCallBack.SchoolCallBack{ | 37 | ,DialogCallBack.CitysCallBack,DialogCallBack.CountryCallBack,DialogCallBack.SchoolCallBack{ |
38 | private EditText et_username; | 38 | private EditText et_username; |
39 | private TextView et_region,et_grade,et_school; | 39 | private TextView et_region,et_grade,et_school; |
40 | private Button btn_ok; | 40 | private Button btn_ok; |
41 | 41 | ||
42 | @Override | 42 | @Override |
43 | protected void onCreate(Bundle savedInstanceState) { | 43 | protected void onCreate(Bundle savedInstanceState) { |
44 | super.onCreate(savedInstanceState); | 44 | super.onCreate(savedInstanceState); |
45 | setContentView(R.layout.activity_registerinfo); | 45 | setContentView(R.layout.activity_registerinfo); |
46 | initView(); | 46 | initView(); |
47 | initData(); | 47 | initData(); |
48 | initLister(); | 48 | initLister(); |
49 | } | 49 | } |
50 | 50 | ||
51 | private void initView() { | 51 | private void initView() { |
52 | et_username = (EditText) findViewById(R.id.et_username); | 52 | et_username = (EditText) findViewById(R.id.et_username); |
53 | et_region = (TextView) findViewById(R.id.et_region); | 53 | et_region = (TextView) findViewById(R.id.et_region); |
54 | et_grade = (TextView) findViewById(R.id.et_grade); | 54 | et_grade = (TextView) findViewById(R.id.et_grade); |
55 | et_school = (TextView) findViewById(R.id.et_school); | 55 | et_school = (TextView) findViewById(R.id.et_school); |
56 | btn_ok = (Button) findViewById(R.id.btn_ok); | 56 | btn_ok = (Button) findViewById(R.id.btn_ok); |
57 | 57 | ||
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | private void initData() { | 61 | private void initData() { |
62 | if (Content.accountflag ==2){ | 62 | if (Content.accountflag ==2){ |
63 | btn_ok.setText("提交"); | 63 | btn_ok.setText("提交"); |
64 | 64 | ||
65 | } | 65 | } |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | private void initLister() { | 69 | private void initLister() { |
70 | et_region.setOnClickListener(this); | 70 | et_region.setOnClickListener(this); |
71 | et_grade.setOnClickListener(this); | 71 | et_grade.setOnClickListener(this); |
72 | et_school.setOnClickListener(this); | 72 | et_school.setOnClickListener(this); |
73 | btn_ok.setOnClickListener(this); | 73 | btn_ok.setOnClickListener(this); |
74 | 74 | ||
75 | 75 | ||
76 | } | 76 | } |
77 | 77 | ||
78 | @Override | 78 | @Override |
79 | public void onClick(View v) { | 79 | public void onClick(View v) { |
80 | String register1 = et_username.getText().toString().trim(); | 80 | String register1 = et_username.getText().toString().trim(); |
81 | String register2 = et_region.getText().toString().trim(); | 81 | String register2 = et_region.getText().toString().trim(); |
82 | String register3 = et_grade.getText().toString().trim(); | 82 | String register3 = et_grade.getText().toString().trim(); |
83 | String register4 = et_school.getText().toString().trim(); | 83 | String register4 = et_school.getText().toString().trim(); |
84 | switch (v.getId()){ | 84 | switch (v.getId()){ |
85 | case R.id.et_region: | 85 | case R.id.et_region: |
86 | choiseregion(); | 86 | choiseregion(); |
87 | break; | 87 | break; |
88 | case R.id.et_grade: | 88 | case R.id.et_grade: |
89 | choisegrade(); | 89 | choisegrade(); |
90 | break; | 90 | break; |
91 | case R.id.et_school: | 91 | case R.id.et_school: |
92 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | 92 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
93 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); | 93 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); |
94 | return; | 94 | return; |
95 | }else { | 95 | }else { |
96 | choiseschool(); | 96 | choiseschool(); |
97 | } | 97 | } |
98 | 98 | ||
99 | break; | 99 | break; |
100 | case R.id.btn_ok: | 100 | case R.id.btn_ok: |
101 | if (TextUtils.isEmpty(register1) || | 101 | if (TextUtils.isEmpty(register1) || |
102 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | 102 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
103 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); | 103 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); |
104 | return; | 104 | return; |
105 | }else{ | 105 | }else{ |
106 | if (Content.accountflag ==2){ | 106 | if (Content.accountflag ==2){ |
107 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | 107 | String userID = SaveParam.getInstance().getLoginParam(this,"userId"); |
108 | String register5 = et_username.getText().toString().trim(); | 108 | String register5 = et_username.getText().toString().trim(); |
109 | String register6 = et_region.getText().toString().trim(); | 109 | String register6 = et_region.getText().toString().trim(); |
110 | String register7 = et_grade.getText().toString().trim(); | 110 | String register7 = et_grade.getText().toString().trim(); |
111 | String register8 = et_school.getText().toString().trim(); | 111 | String register8 = et_school.getText().toString().trim(); |
112 | try { | 112 | try { |
113 | long auserID = Long.parseLong(userID); | 113 | long auserID = Long.parseLong(userID); |
114 | HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this,auserID,"", | 114 | HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this,auserID,"http://hjxprodbucket.oss.aliyuncs.com/static/upload/boss_api/announcement/2017-08-29/a00de899-2f6d-43fb-9e30-71883842540e.png", |
115 | register5,register7,register8,register6); | 115 | register5,register7,register8,register6); |
116 | 116 | ||
117 | } catch (NumberFormatException e) { | 117 | } catch (NumberFormatException e) { |
118 | e.printStackTrace(); | 118 | e.printStackTrace(); |
119 | } | 119 | } |
120 | 120 | ||
121 | }else { | 121 | }else { |
122 | saveinfo(); | 122 | saveinfo(); |
123 | Intent intent = new Intent(); | 123 | Intent intent = new Intent(); |
124 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 124 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); |
125 | startActivity(intent); | 125 | startActivity(intent); |
126 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 126 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
127 | } | 127 | } |
128 | 128 | ||
129 | } | 129 | } |
130 | 130 | ||
131 | break; | 131 | break; |
132 | } | 132 | } |
133 | 133 | ||
134 | } | 134 | } |
135 | //保存个人信息 | 135 | //保存个人信息 |
136 | private void saveinfo() { | 136 | private void saveinfo() { |
137 | String register1 = et_username.getText().toString().trim(); | 137 | String register1 = et_username.getText().toString().trim(); |
138 | String register2 = et_region.getText().toString().trim(); | 138 | String register2 = et_region.getText().toString().trim(); |
139 | String register3 = et_grade.getText().toString().trim(); | 139 | String register3 = et_grade.getText().toString().trim(); |
140 | String register4 = et_school.getText().toString().trim(); | 140 | String register4 = et_school.getText().toString().trim(); |
141 | SaveParam.getInstance().saveLoginParam(this,SaveParam.USERNAME,register1); | 141 | SaveParam.getInstance().saveLoginParam(this,SaveParam.USERNAME,register1); |
142 | SaveParam.getInstance().saveLoginParam(this,SaveParam.ADRESS,register2); | 142 | SaveParam.getInstance().saveLoginParam(this,SaveParam.ADRESS,register2); |
143 | SaveParam.getInstance().saveLoginParam(this,SaveParam.GRADES,register3); | 143 | SaveParam.getInstance().saveLoginParam(this,SaveParam.GRADES,register3); |
144 | SaveParam.getInstance().saveLoginParam(this,SaveParam.SCHOOL,register4); | 144 | SaveParam.getInstance().saveLoginParam(this,SaveParam.SCHOOL,register4); |
145 | 145 | ||
146 | } | 146 | } |
147 | 147 | ||
148 | //选择地区 | 148 | //选择地区 |
149 | private void choiseregion() { | 149 | private void choiseregion() { |
150 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); | 150 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) RegisterInfoActivity.this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
151 | 151 | ||
152 | } | 152 | } |
153 | //选择年级 | 153 | //选择年级 |
154 | private void choisegrade() { | 154 | private void choisegrade() { |
155 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); | 155 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) this).show(getSupportFragmentManager(), "GradeListDialog"); |
156 | 156 | ||
157 | } | 157 | } |
158 | //选择学校 | 158 | //选择学校 |
159 | private void choiseschool() { | 159 | private void choiseschool() { |
160 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); | 160 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) this).show(getSupportFragmentManager(), "SchoolListDialog"); |
161 | 161 | ||
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | @Override | 165 | @Override |
166 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { | 166 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
167 | String regionName = data.get(position).getRegionName(); | 167 | String regionName = data.get(position).getRegionName(); |
168 | SaveParam.getInstance().saveLoginParam(this,"sheng",regionName); | 168 | SaveParam.getInstance().saveLoginParam(this,"sheng",regionName); |
169 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); | 169 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog"); |
170 | 170 | ||
171 | 171 | ||
172 | } | 172 | } |
173 | @Override | 173 | @Override |
174 | public boolean onKeyUp(int keyCode, KeyEvent event) { | 174 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
175 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 175 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
176 | finish(); | 176 | finish(); |
177 | 177 | ||
178 | } | 178 | } |
179 | return super.onKeyUp(keyCode, event); | 179 | return super.onKeyUp(keyCode, event); |
180 | } | 180 | } |
181 | 181 | ||
182 | @Override | 182 | @Override |
183 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | 183 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { |
184 | String regionName = data.get(position).getName(); | 184 | String regionName = data.get(position).getName(); |
185 | et_grade.setText(regionName); | 185 | et_grade.setText(regionName); |
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | @Override | 189 | @Override |
190 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | 190 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { |
191 | String regionName = data.get(position).getRegionName(); | 191 | String regionName = data.get(position).getRegionName(); |
192 | String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); | 192 | String provice = SaveParam.getInstance().getLoginParam(this,"sheng"); |
193 | SaveParam.getInstance().saveLoginParam(this,"shi",regionName); | 193 | SaveParam.getInstance().saveLoginParam(this,"shi",regionName); |
194 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); | 194 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog"); |
195 | et_region.setText(""); | 195 | et_region.setText(""); |
196 | et_region.setText(provice+regionName); | 196 | et_region.setText(provice+regionName); |
197 | 197 | ||
198 | } | 198 | } |
199 | 199 | ||
200 | @Override | 200 | @Override |
201 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { | 201 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { |
202 | String regionName = data.get(position).getRegionName(); | 202 | String regionName = data.get(position).getRegionName(); |
203 | String provices = SaveParam.getInstance().getLoginParam(this,"sheng"); | 203 | String provices = SaveParam.getInstance().getLoginParam(this,"sheng"); |
204 | String citys = SaveParam.getInstance().getLoginParam(this,"shi"); | 204 | String citys = SaveParam.getInstance().getLoginParam(this,"shi"); |
205 | et_region.setText(""); | 205 | et_region.setText(""); |
206 | et_region.setText(provices+citys+regionName); | 206 | et_region.setText(provices+citys+regionName); |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | @Override | 210 | @Override |
211 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { | 211 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { |
212 | String regionName = data.get(position).getSchoolName(); | 212 | String regionName = data.get(position).getSchoolName(); |
213 | et_school.setText(regionName); | 213 | et_school.setText(regionName); |
214 | 214 | ||
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/AccountChildsAdapter.java
1 | package com.hjx.personalcenter.adapter; | 1 | package com.hjx.personalcenter.adapter; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.support.v4.app.FragmentActivity; | 4 | import android.support.v4.app.FragmentActivity; |
5 | import android.support.v7.widget.RecyclerView; | 5 | import android.support.v7.widget.RecyclerView; |
6 | import android.view.LayoutInflater; | 6 | import android.view.LayoutInflater; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.view.ViewGroup; | 8 | import android.view.ViewGroup; |
9 | import android.widget.ImageView; | ||
10 | import android.widget.TextView; | 9 | import android.widget.TextView; |
11 | 10 | ||
11 | import com.facebook.drawee.view.SimpleDraweeView; | ||
12 | import com.hjx.personalcenter.R; | 12 | import com.hjx.personalcenter.R; |
13 | import com.hjx.personalcenter.http.HttpManager; | 13 | import com.hjx.personalcenter.http.HttpManager; |
14 | import com.hjx.personalcenter.model.ChildsInfo; | 14 | import com.hjx.personalcenter.model.ChildsInfo; |
15 | import com.mylhyl.circledialog.CircleDialog; | 15 | import com.mylhyl.circledialog.CircleDialog; |
16 | 16 | ||
17 | import java.util.ArrayList; | 17 | import java.util.ArrayList; |
18 | import java.util.List; | 18 | import java.util.List; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Created by h on 2017/8/26. | 21 | * Created by h on 2017/8/26. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | public class AccountChildsAdapter extends RecyclerView.Adapter<AccountChildsAdapter.AccountChildsHolder> { | 24 | public class AccountChildsAdapter extends RecyclerView.Adapter<AccountChildsAdapter.AccountChildsHolder> { |
25 | private List<ChildsInfo.DataBean> specailList; | 25 | private List<ChildsInfo.DataBean> specailList; |
26 | private LayoutInflater mInflater; | 26 | private LayoutInflater mInflater; |
27 | private Context mContext ; | 27 | private Context mContext ; |
28 | 28 | ||
29 | public AccountChildsAdapter(ArrayList<ChildsInfo.DataBean> specailList,Context context) { | 29 | public AccountChildsAdapter(ArrayList<ChildsInfo.DataBean> specailList,Context context) { |
30 | this.mContext = context; | 30 | this.mContext = context; |
31 | this.specailList = specailList; | 31 | this.specailList = specailList; |
32 | mInflater = LayoutInflater.from(context); | 32 | mInflater = LayoutInflater.from(context); |
33 | } | 33 | } |
34 | 34 | ||
35 | public OnItemClickListener mOnItemClickListener; | 35 | public OnItemClickListener mOnItemClickListener; |
36 | 36 | ||
37 | public interface OnItemClickListener { | 37 | public interface OnItemClickListener { |
38 | void onItemClick(View view, int position); | 38 | void onItemClick(View view, int position); |
39 | } | 39 | } |
40 | 40 | ||
41 | public void setOnItemClickListener(OnItemClickListener mOnItemClickLitener) { | 41 | public void setOnItemClickListener(OnItemClickListener mOnItemClickLitener) { |
42 | this.mOnItemClickListener = mOnItemClickLitener; | 42 | this.mOnItemClickListener = mOnItemClickLitener; |
43 | } | 43 | } |
44 | 44 | ||
45 | public void setList(List<ChildsInfo.DataBean> list) { | 45 | public void setList(List<ChildsInfo.DataBean> list) { |
46 | this.specailList = list; | 46 | this.specailList = list; |
47 | notifyDataSetChanged(); | 47 | notifyDataSetChanged(); |
48 | } | 48 | } |
49 | 49 | ||
50 | @Override | 50 | @Override |
51 | public AccountChildsHolder onCreateViewHolder(ViewGroup parent, int viewType) { | 51 | public AccountChildsHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
52 | View view = mInflater.inflate(R.layout.recycler_childaccunt_item_view, parent, false); | 52 | View view = mInflater.inflate(R.layout.recycler_childaccunt_item_view, parent, false); |
53 | 53 | ||
54 | AccountChildsHolder holder = new AccountChildsHolder(view); | 54 | AccountChildsHolder holder = new AccountChildsHolder(view); |
55 | return holder; | 55 | return holder; |
56 | } | 56 | } |
57 | 57 | ||
58 | @Override | 58 | @Override |
59 | public void onBindViewHolder(AccountChildsHolder holder, int position) { | 59 | public void onBindViewHolder(AccountChildsHolder holder, int position) { |
60 | final ChildsInfo.DataBean bean = specailList.get(position); | 60 | final ChildsInfo.DataBean bean = specailList.get(position); |
61 | if (bean != null) { | 61 | if (bean != null) { |
62 | holder.iv_child_head.setImageResource(R.mipmap.header_default); | 62 | holder.mSimpleDraweeView.setImageURI(bean.getImage()); |
63 | holder.iv_child_name.setText(bean.getName()); | 63 | holder.iv_child_name.setText(bean.getName()); |
64 | holder.iv_child_grade.setText(bean.getGrade()); | 64 | holder.iv_child_grade.setText(bean.getGrade()); |
65 | holder.iv_child_school.setText(bean.getSchool()); | 65 | holder.iv_child_school.setText(bean.getSchool()); |
66 | holder.iv_child_adress.setText(bean.getRegion()); | 66 | holder.iv_child_adress.setText(bean.getRegion()); |
67 | holder.delete_account.setOnClickListener(new View.OnClickListener() { | 67 | holder.delete_account.setOnClickListener(new View.OnClickListener() { |
68 | @Override | 68 | @Override |
69 | public void onClick(View v) { | 69 | public void onClick(View v) { |
70 | new CircleDialog.Builder((FragmentActivity)mContext) | 70 | new CircleDialog.Builder((FragmentActivity)mContext) |
71 | .setCanceledOnTouchOutside(false) | 71 | .setCanceledOnTouchOutside(false) |
72 | .setWidth(0.4f) | 72 | .setWidth(0.4f) |
73 | .setCancelable(false) | 73 | .setCancelable(false) |
74 | .setText("您确定删除该子账户?") | 74 | .setText("您确定删除该子账户?") |
75 | .setNegative("取消", null) | 75 | .setNegative("取消", null) |
76 | .setPositive("确定", new View.OnClickListener() { | 76 | .setPositive("确定", new View.OnClickListener() { |
77 | @Override | 77 | @Override |
78 | public void onClick(View v) { | 78 | public void onClick(View v) { |
79 | HttpManager.getInstance().deletechildAccountinfo(mContext,bean.getSubAccountId()); | 79 | HttpManager.getInstance().deletechildAccountinfo(mContext,bean.getSubAccountId()); |
80 | } | 80 | } |
81 | }) | 81 | }) |
82 | .show(); | 82 | .show(); |
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | } | 86 | } |
87 | }); | 87 | }); |
88 | holder.chang_account.setOnClickListener(new View.OnClickListener() { | 88 | holder.chang_account.setOnClickListener(new View.OnClickListener() { |
89 | @Override | 89 | @Override |
90 | public void onClick(View v) { | 90 | public void onClick(View v) { |
91 | new CircleDialog.Builder((FragmentActivity)mContext) | 91 | new CircleDialog.Builder((FragmentActivity)mContext) |
92 | .setCanceledOnTouchOutside(false) | 92 | .setCanceledOnTouchOutside(false) |
93 | .setWidth(0.4f) | 93 | .setWidth(0.4f) |
94 | .setCancelable(false) | 94 | .setCancelable(false) |
95 | .setText("您确定切换为该子账户?") | 95 | .setText("您确定切换为该子账户?") |
96 | .setNegative("取消", null) | 96 | .setNegative("取消", null) |
97 | .setPositive("确定", new View.OnClickListener() { | 97 | .setPositive("确定", new View.OnClickListener() { |
98 | @Override | 98 | @Override |
99 | public void onClick(View v) { | 99 | public void onClick(View v) { |
100 | HttpManager.getInstance().changechildAccountinfo(mContext,bean.getSubAccountId(),bean.getParentId()); | 100 | HttpManager.getInstance().changechildAccountinfo(mContext,bean.getSubAccountId(),bean.getParentId()); |
101 | } | 101 | } |
102 | }) | 102 | }) |
103 | .show(); | 103 | .show(); |
104 | 104 | ||
105 | } | 105 | } |
106 | }); | 106 | }); |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | @Override | 113 | @Override |
114 | public int getItemCount() { | 114 | public int getItemCount() { |
115 | return specailList.size(); | 115 | return specailList.size(); |
116 | } | 116 | } |
117 | 117 | ||
118 | class AccountChildsHolder extends RecyclerView.ViewHolder { | 118 | class AccountChildsHolder extends RecyclerView.ViewHolder { |
119 | ImageView iv_child_head; | 119 | SimpleDraweeView mSimpleDraweeView; |
120 | TextView iv_child_name, iv_child_grade, iv_child_school, iv_child_adress, | 120 | TextView iv_child_name, iv_child_grade, iv_child_school, iv_child_adress, |
121 | delete_account,chang_account; | 121 | delete_account,chang_account; |
122 | public AccountChildsHolder(View itemView) { | 122 | public AccountChildsHolder(View itemView) { |
123 | super(itemView); | 123 | super(itemView); |
124 | iv_child_head = (ImageView) itemView.findViewById(R.id.iv_child_head); | 124 | mSimpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.iv_child_head); |
125 | iv_child_name = (TextView) itemView.findViewById(R.id.iv_child_name); | 125 | iv_child_name = (TextView) itemView.findViewById(R.id.iv_child_name); |
126 | iv_child_grade = (TextView) itemView.findViewById(R.id.iv_child_grade); | 126 | iv_child_grade = (TextView) itemView.findViewById(R.id.iv_child_grade); |
127 | iv_child_school = (TextView) itemView.findViewById(R.id.iv_child_school); | 127 | iv_child_school = (TextView) itemView.findViewById(R.id.iv_child_school); |
128 | iv_child_adress = (TextView) itemView.findViewById(R.id.iv_child_adress); | 128 | iv_child_adress = (TextView) itemView.findViewById(R.id.iv_child_adress); |
129 | delete_account = (TextView) itemView.findViewById(R.id.delete_child_account); | 129 | delete_account = (TextView) itemView.findViewById(R.id.delete_child_account); |
130 | chang_account = (TextView) itemView.findViewById(R.id.chang_account); | 130 | chang_account = (TextView) itemView.findViewById(R.id.chang_account); |
131 | 131 | ||
132 | } | 132 | } |
133 | } | 133 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GalleryAdapter.java
1 | package com.hjx.personalcenter.adapter; | 1 | package com.hjx.personalcenter.adapter; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.support.v7.widget.RecyclerView; | 4 | import android.support.v7.widget.RecyclerView; |
5 | import android.view.LayoutInflater; | 5 | import android.view.LayoutInflater; |
6 | import android.view.View; | 6 | import android.view.View; |
7 | import android.view.ViewGroup; | 7 | import android.view.ViewGroup; |
8 | import android.widget.ImageView; | ||
9 | import android.widget.TextView; | 8 | import android.widget.TextView; |
10 | 9 | ||
10 | import com.facebook.drawee.view.SimpleDraweeView; | ||
11 | import com.hjx.personalcenter.R; | 11 | import com.hjx.personalcenter.R; |
12 | 12 | ||
13 | import java.util.List; | 13 | import java.util.List; |
14 | 14 | ||
15 | public class GalleryAdapter extends | 15 | public class GalleryAdapter extends |
16 | RecyclerView.Adapter<GalleryAdapter.ViewHolder> | 16 | RecyclerView.Adapter<GalleryAdapter.ViewHolder> |
17 | { | 17 | { |
18 | 18 | ||
19 | private LayoutInflater mInflater; | 19 | private LayoutInflater mInflater; |
20 | private List<Integer> mDatas; | 20 | private List<Integer> mDatas; |
21 | 21 | ||
22 | public GalleryAdapter(Context context, List<Integer> datats) | 22 | public GalleryAdapter(Context context, List<Integer> datats) |
23 | { | 23 | { |
24 | mInflater = LayoutInflater.from(context); | 24 | mInflater = LayoutInflater.from(context); |
25 | mDatas = datats; | 25 | mDatas = datats; |
26 | } | 26 | } |
27 | 27 | ||
28 | public static class ViewHolder extends RecyclerView.ViewHolder | 28 | public static class ViewHolder extends RecyclerView.ViewHolder |
29 | { | 29 | { |
30 | public ViewHolder(View arg0) | 30 | public ViewHolder(View arg0) |
31 | { | 31 | { |
32 | super(arg0); | 32 | super(arg0); |
33 | } | 33 | } |
34 | 34 | ||
35 | ImageView mImg; | 35 | SimpleDraweeView mSimpleDraweeView; |
36 | TextView mTxt; | 36 | TextView mTxt; |
37 | } | 37 | } |
38 | 38 | ||
39 | @Override | 39 | @Override |
40 | public int getItemCount() | 40 | public int getItemCount() |
41 | { | 41 | { |
42 | return mDatas.size(); | 42 | return mDatas.size(); |
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * 创建ViewHolder | 46 | * 创建ViewHolder |
47 | */ | 47 | */ |
48 | @Override | 48 | @Override |
49 | public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) | 49 | public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) |
50 | { | 50 | { |
51 | View view = mInflater.inflate(R.layout.recycler_study_tem_view, | 51 | View view = mInflater.inflate(R.layout.recycler_study_tem_view, |
52 | viewGroup, false); | 52 | viewGroup, false); |
53 | ViewHolder viewHolder = new ViewHolder(view); | 53 | ViewHolder viewHolder = new ViewHolder(view); |
54 | 54 | ||
55 | viewHolder.mImg = (ImageView) view | 55 | viewHolder.mSimpleDraweeView = (SimpleDraweeView) view |
56 | .findViewById(R.id.id_index_gallery_item_image); | 56 | .findViewById(R.id.id_index_gallery_item_image); |
57 | return viewHolder; | 57 | return viewHolder; |
58 | } | 58 | } |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * 设置值 | 61 | * 设置值 |
62 | */ | 62 | */ |
63 | @Override | 63 | @Override |
64 | public void onBindViewHolder(final ViewHolder viewHolder, final int i) | 64 | public void onBindViewHolder(final ViewHolder viewHolder, final int i) |
65 | { | 65 | { |
66 | viewHolder.mImg.setImageResource(mDatas.get(i)); | 66 | viewHolder.mSimpleDraweeView.setImageResource(mDatas.get(i)); |
67 | } | 67 | } |
68 | 68 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/fragment/PresonInfoFragment.java
1 | package com.hjx.personalcenter.fragment; | 1 | package com.hjx.personalcenter.fragment; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
7 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
8 | import android.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.EditText; | 13 | import android.widget.EditText; |
14 | import android.widget.TextView; | 14 | import android.widget.TextView; |
15 | 15 | ||
16 | import com.bigkoo.pickerview.TimePickerView; | 16 | import com.bigkoo.pickerview.TimePickerView; |
17 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
18 | import com.hjx.personalcenter.customdialog.CitysListDialog; | 18 | import com.hjx.personalcenter.customdialog.CitysListDialog; |
19 | import com.hjx.personalcenter.customdialog.CountryDialog; | 19 | import com.hjx.personalcenter.customdialog.CountryDialog; |
20 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 20 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
21 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 21 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
22 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | 22 | import com.hjx.personalcenter.customdialog.SchoolListDialog; |
23 | import com.hjx.personalcenter.db.SaveParam; | 23 | import com.hjx.personalcenter.db.SaveParam; |
24 | import com.hjx.personalcenter.http.HttpManager; | 24 | import com.hjx.personalcenter.http.HttpManager; |
25 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 25 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
26 | import com.hjx.personalcenter.model.ChangeInfo; | 26 | import com.hjx.personalcenter.model.ChangeInfo; |
27 | import com.hjx.personalcenter.model.CityInfo; | 27 | import com.hjx.personalcenter.model.CityInfo; |
28 | import com.hjx.personalcenter.model.CountyInfo; | 28 | import com.hjx.personalcenter.model.CountyInfo; |
29 | import com.hjx.personalcenter.model.GradeInfo; | 29 | import com.hjx.personalcenter.model.GradeInfo; |
30 | import com.hjx.personalcenter.model.ProvinceInfo; | 30 | import com.hjx.personalcenter.model.ProvinceInfo; |
31 | import com.hjx.personalcenter.model.SchoolInfo; | 31 | import com.hjx.personalcenter.model.SchoolInfo; |
32 | import com.hjx.personalcenter.util.AlertUtils; | 32 | import com.hjx.personalcenter.util.AlertUtils; |
33 | import com.hjx.personalcenter.util.BrithdayStar; | 33 | import com.hjx.personalcenter.util.BrithdayStar; |
34 | import com.mylhyl.circledialog.CircleDialog; | 34 | import com.mylhyl.circledialog.CircleDialog; |
35 | import com.mylhyl.circledialog.callback.ConfigButton; | ||
36 | import com.mylhyl.circledialog.callback.ConfigDialog; | 35 | import com.mylhyl.circledialog.callback.ConfigDialog; |
37 | import com.mylhyl.circledialog.params.ButtonParams; | ||
38 | import com.mylhyl.circledialog.params.DialogParams; | 36 | import com.mylhyl.circledialog.params.DialogParams; |
39 | 37 | ||
40 | import org.apache.http.util.TextUtils; | 38 | import org.apache.http.util.TextUtils; |
41 | 39 | ||
42 | import java.io.UnsupportedEncodingException; | 40 | import java.io.UnsupportedEncodingException; |
43 | import java.text.SimpleDateFormat; | 41 | import java.text.SimpleDateFormat; |
44 | import java.util.ArrayList; | 42 | import java.util.ArrayList; |
45 | import java.util.Date; | 43 | import java.util.Date; |
46 | 44 | ||
47 | /** | 45 | /** |
48 | * Created by h on 2017/8/12. | 46 | * Created by h on 2017/8/12. |
49 | */ | 47 | */ |
50 | 48 | ||
51 | public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack | 49 | public class PresonInfoFragment extends Fragment implements View.OnClickListener, DialogCallBack.GradeCallBack, DialogCallBack.ProvincesCallBack |
52 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { | 50 | , DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack, DialogCallBack.SchoolCallBack { |
53 | private View mView; | 51 | private View mView; |
54 | private int type; | 52 | private int type; |
55 | private TimePickerView pvTime; | 53 | private TimePickerView pvTime; |
56 | private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; | 54 | private EditText tv_username1, tv_useinfo_adress1, tv_useinfo_qq; |
57 | private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender; | 55 | private TextView tv_sex, tv_useinfo_adress, tv_useinfo_birthday, tv_useinfo_school, tv_useinfo_gender; |
58 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; | 56 | public static String TABLAYOUT_FRAGMENT = "tab_fragment"; |
59 | 57 | ||
60 | public static PresonInfoFragment newInstance(int type) { | 58 | public static PresonInfoFragment newInstance(int type) { |
61 | PresonInfoFragment fragment = new PresonInfoFragment(); | 59 | PresonInfoFragment fragment = new PresonInfoFragment(); |
62 | Bundle bundle = new Bundle(); | 60 | Bundle bundle = new Bundle(); |
63 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); | 61 | bundle.putSerializable(TABLAYOUT_FRAGMENT, type); |
64 | fragment.setArguments(bundle); | 62 | fragment.setArguments(bundle); |
65 | return fragment; | 63 | return fragment; |
66 | 64 | ||
67 | } | 65 | } |
68 | 66 | ||
69 | @Override | 67 | @Override |
70 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 68 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
71 | if (mView == null) { | 69 | if (mView == null) { |
72 | mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); | 70 | mView = inflater.inflate(R.layout.fragment_changge_presonal_info, container, false); |
73 | initView(mView); | 71 | initView(mView); |
74 | initData(); | 72 | initData(); |
75 | setLister(); | 73 | setLister(); |
76 | initTimePicker(); | 74 | initTimePicker(); |
77 | 75 | ||
78 | 76 | ||
79 | } | 77 | } |
80 | return mView; | 78 | return mView; |
81 | } | 79 | } |
82 | 80 | ||
83 | //初始化 | 81 | //初始化 |
84 | private void initView(View mView) { | 82 | private void initView(View mView) { |
85 | tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); | 83 | tv_username1 = (EditText) mView.findViewById(R.id.tv_username1); |
86 | tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); | 84 | tv_useinfo_adress1 = (EditText) mView.findViewById(R.id.tv_useinfo_adress1); |
87 | tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); | 85 | tv_useinfo_qq = (EditText) mView.findViewById(R.id.tv_useinfo_qq); |
88 | tv_sex = (TextView) mView.findViewById(R.id.tv_sex); | 86 | tv_sex = (TextView) mView.findViewById(R.id.tv_sex); |
89 | tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); | 87 | tv_useinfo_adress = (TextView) mView.findViewById(R.id.tv_useinfo_adress); |
90 | tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); | 88 | tv_useinfo_birthday = (TextView) mView.findViewById(R.id.tv_useinfo_birthday); |
91 | tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); | 89 | tv_useinfo_school = (TextView) mView.findViewById(R.id.tv_useinfo_school); |
92 | tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); | 90 | tv_useinfo_gender = (TextView) mView.findViewById(R.id.tv_useinfo_gender); |
93 | 91 | ||
94 | 92 | ||
95 | } | 93 | } |
96 | 94 | ||
97 | private void initData() { | 95 | private void initData() { |
98 | } | 96 | } |
99 | 97 | ||
100 | private void setLister() { | 98 | private void setLister() { |
101 | tv_sex.setOnClickListener(this); | 99 | tv_sex.setOnClickListener(this); |
102 | tv_useinfo_adress.setOnClickListener(this); | 100 | tv_useinfo_adress.setOnClickListener(this); |
103 | tv_useinfo_birthday.setOnClickListener(this); | 101 | tv_useinfo_birthday.setOnClickListener(this); |
104 | tv_useinfo_school.setOnClickListener(this); | 102 | tv_useinfo_school.setOnClickListener(this); |
105 | tv_useinfo_gender.setOnClickListener(this); | 103 | tv_useinfo_gender.setOnClickListener(this); |
106 | } | 104 | } |
107 | 105 | ||
108 | @Override | 106 | @Override |
109 | public void onClick(View v) { | 107 | public void onClick(View v) { |
110 | String presonal1 = tv_username1.getText().toString().trim(); | 108 | String presonal1 = tv_username1.getText().toString().trim(); |
111 | String presonal2 = tv_useinfo_adress1.getText().toString().trim(); | 109 | String presonal2 = tv_useinfo_adress1.getText().toString().trim(); |
112 | String presonal3 = tv_sex.getText().toString().trim(); | 110 | String presonal3 = tv_sex.getText().toString().trim(); |
113 | String presonal4 = tv_useinfo_adress.getText().toString().trim(); | 111 | String presonal4 = tv_useinfo_adress.getText().toString().trim(); |
114 | String presonal5 = tv_useinfo_birthday.getText().toString().trim(); | 112 | String presonal5 = tv_useinfo_birthday.getText().toString().trim(); |
115 | String presonal6 = tv_useinfo_school.getText().toString().trim(); | 113 | String presonal6 = tv_useinfo_school.getText().toString().trim(); |
116 | String presonal7 = tv_useinfo_gender.getText().toString().trim(); | 114 | String presonal7 = tv_useinfo_gender.getText().toString().trim(); |
117 | String presonal8 = tv_useinfo_qq.getText().toString().trim(); | 115 | String presonal8 = tv_useinfo_qq.getText().toString().trim(); |
118 | switch (v.getId()) { | 116 | switch (v.getId()) { |
119 | case R.id.tv_sex: | 117 | case R.id.tv_sex: |
120 | final String[] items = {"男", "女"}; | 118 | final String[] items = {"男", "女"}; |
121 | new CircleDialog.Builder(getActivity()) | 119 | new CircleDialog.Builder(getActivity()) |
122 | .configDialog(new ConfigDialog() { | 120 | .configDialog(new ConfigDialog() { |
123 | @Override | 121 | @Override |
124 | public void onConfig(DialogParams params) { | 122 | public void onConfig(DialogParams params) { |
125 | //增加弹出动画 | 123 | //增加弹出动画 |
126 | params.gravity = Gravity.CENTER; | 124 | params.gravity = Gravity.CENTER; |
127 | } | 125 | } |
128 | }) | 126 | }) |
129 | .setTitle("请选择性别") | 127 | .setTitle("请选择性别") |
130 | .setWidth(0.5f) | 128 | .setWidth(0.5f) |
131 | .setItems(items, new AdapterView.OnItemClickListener() { | 129 | .setItems(items, new AdapterView.OnItemClickListener() { |
132 | @Override | 130 | @Override |
133 | public void onItemClick(AdapterView<?> parent, View view, int | 131 | public void onItemClick(AdapterView<?> parent, View view, int |
134 | position, long id) { | 132 | position, long id) { |
135 | switch (position) { | 133 | switch (position) { |
136 | case 0: | 134 | case 0: |
137 | tv_sex.setText("男"); | 135 | tv_sex.setText("男"); |
138 | break; | 136 | break; |
139 | case 1: | 137 | case 1: |
140 | tv_sex.setText("女"); | 138 | tv_sex.setText("女"); |
141 | break; | 139 | break; |
142 | } | 140 | } |
143 | 141 | ||
144 | } | 142 | } |
145 | }) | 143 | }) |
146 | .setNegative("取消", null) | ||
147 | .configNegative(new ConfigButton() { | ||
148 | @Override | ||
149 | public void onConfig(ButtonParams params) { | ||
150 | //取消按钮字体颜色 | ||
151 | params.textColor = Color.RED; | ||
152 | } | ||
153 | }) | ||
154 | .show(); | 144 | .show(); |
155 | break; | 145 | break; |
156 | case R.id.tv_useinfo_adress: | 146 | case R.id.tv_useinfo_adress: |
157 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); | 147 | ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "ProvinceListDialog"); |
158 | break; | 148 | break; |
159 | case R.id.tv_useinfo_birthday: | 149 | case R.id.tv_useinfo_birthday: |
160 | pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view | 150 | pvTime.show(tv_useinfo_birthday);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view |
161 | break; | 151 | break; |
162 | case R.id.tv_useinfo_school: | 152 | case R.id.tv_useinfo_school: |
163 | if (TextUtils.isEmpty(presonal4) || | 153 | if (TextUtils.isEmpty(presonal4) || |
164 | TextUtils.isEmpty(presonal7)) { | 154 | TextUtils.isEmpty(presonal7)) { |
165 | AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); | 155 | AlertUtils.showToast(getActivity(), "请先选择地区和年级!"); |
166 | return; | 156 | return; |
167 | } else { | 157 | } else { |
168 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); | 158 | SchoolListDialog.getInstance((DialogCallBack.SchoolCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "SchoolListDialog"); |
169 | } | 159 | } |
170 | 160 | ||
171 | 161 | ||
172 | break; | 162 | break; |
173 | case R.id.tv_useinfo_gender: | 163 | case R.id.tv_useinfo_gender: |
174 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); | 164 | GradeListDialog.getInstance((DialogCallBack.GradeCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "GradeListDialog"); |
175 | break; | 165 | break; |
176 | case R.id.presonal_sub: | 166 | case R.id.presonal_sub: |
177 | if (TextUtils.isEmpty(presonal1) || | 167 | if (TextUtils.isEmpty(presonal1) || |
178 | TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || | 168 | TextUtils.isEmpty(presonal2) || TextUtils.isEmpty(presonal3) || TextUtils.isEmpty(presonal4) || |
179 | TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || | 169 | TextUtils.isEmpty(presonal5) || TextUtils.isEmpty(presonal7) || |
180 | TextUtils.isEmpty(presonal8)) { | 170 | TextUtils.isEmpty(presonal8)) { |
181 | AlertUtils.showToast(getActivity(), "请将信息填写完整!"); | 171 | AlertUtils.showToast(getActivity(), "请将信息填写完整!"); |
182 | return; | 172 | return; |
183 | } else { | 173 | } else { |
184 | 174 | ||
185 | int a = 0, b = 0; | 175 | int a = 0, b = 0; |
186 | long c = 0; | 176 | long c = 0; |
187 | //保存星座 | 177 | //保存星座 |
188 | BrithdayStar brithdayStar = new BrithdayStar(); | 178 | BrithdayStar brithdayStar = new BrithdayStar(); |
189 | String s = brithdayStar.getConstellations(tv_useinfo_birthday.getText().toString()); | 179 | String s = brithdayStar.getConstellations(tv_useinfo_birthday.getText().toString()); |
190 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CONSTELLATION, s); | 180 | SaveParam.getInstance().saveLoginParam(getActivity(), SaveParam.CONSTELLATION, s); |
191 | 181 | ||
192 | ChangeInfo changeinfo = new ChangeInfo(); | 182 | ChangeInfo changeinfo = new ChangeInfo(); |
193 | String regionId = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.COUNTRY); | 183 | String regionId = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.COUNTRY); |
194 | String regionId1 = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); | 184 | String regionId1 = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS); |
195 | if (regionId == null) { | 185 | if (regionId == null) { |
196 | regionId = regionId1; | 186 | regionId = regionId1; |
197 | } | 187 | } |
198 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 188 | String grade = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
199 | String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); | 189 | String schoolid = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
200 | ChangeInfo.SchoolBean changeinfo2 = new ChangeInfo.SchoolBean(); | 190 | ChangeInfo.SchoolBean changeinfo2 = new ChangeInfo.SchoolBean(); |
201 | try { | 191 | try { |
202 | a = Integer.parseInt(regionId); | 192 | a = Integer.parseInt(regionId); |
203 | b = Integer.parseInt(grade); | 193 | b = Integer.parseInt(grade); |
204 | c = Long.parseLong(schoolid); | 194 | c = Long.parseLong(schoolid); |
205 | } catch (NumberFormatException e) { | 195 | } catch (NumberFormatException e) { |
206 | e.printStackTrace(); | 196 | e.printStackTrace(); |
207 | } | 197 | } |
208 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); | 198 | String userID = SaveParam.getInstance().getLoginParam(getActivity(), "userId"); |
209 | 199 | ||
210 | changeinfo.setId(userID); | 200 | changeinfo.setId(userID); |
211 | changeinfo.setNickname(presonal1); | 201 | changeinfo.setNickname(presonal1); |
212 | changeinfo.setRegionId(a); | 202 | changeinfo.setRegionId(a); |
213 | changeinfo.setGradeId(b); | 203 | changeinfo.setGradeId(b); |
214 | changeinfo2.setSchoolId(c); | 204 | changeinfo2.setSchoolId(c); |
215 | if ("男".equals(presonal3)) { | 205 | if ("男".equals(presonal3)) { |
216 | changeinfo.setGender("0"); | 206 | changeinfo.setGender("0"); |
217 | } else { | 207 | } else { |
218 | changeinfo.setGender("1"); | 208 | changeinfo.setGender("1"); |
219 | } | 209 | } |
220 | changeinfo.setBirthday(presonal5); | 210 | changeinfo.setBirthday(presonal5); |
221 | ChangeInfo.ContactBean changeinfo1 = new ChangeInfo.ContactBean(); | 211 | ChangeInfo.ContactBean changeinfo1 = new ChangeInfo.ContactBean(); |
222 | changeinfo1.setQq(presonal8); | 212 | changeinfo1.setQq(presonal8); |
223 | changeinfo.setRegionName(presonal4 + presonal2); | 213 | changeinfo.setRegionName(presonal4 + presonal2); |
224 | changeinfo.setSchool(changeinfo2); | 214 | changeinfo.setSchool(changeinfo2); |
225 | changeinfo.setContact(changeinfo1); | 215 | changeinfo.setContact(changeinfo1); |
226 | 216 | ||
227 | try { | 217 | try { |
228 | //提交个人信息 | 218 | //提交个人信息 |
229 | HttpManager.getInstance().changepresonalinfo(getActivity(), changeinfo); | 219 | HttpManager.getInstance().changepresonalinfo(getActivity(), changeinfo); |
230 | } catch (UnsupportedEncodingException e) { | 220 | } catch (UnsupportedEncodingException e) { |
231 | e.printStackTrace(); | 221 | e.printStackTrace(); |
232 | } | 222 | } |
233 | 223 | ||
234 | 224 | ||
235 | break; | 225 | break; |
236 | } | 226 | } |
237 | } | 227 | } |
238 | } | 228 | } |
239 | 229 | ||
240 | //自定义时间选择器 | 230 | //自定义时间选择器 |
241 | private void initTimePicker() { | 231 | private void initTimePicker() { |
242 | //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) | 232 | //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) |
243 | //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | 233 | //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 |
244 | // Calendar selectedDate = Calendar.getInstance(); | 234 | // Calendar selectedDate = Calendar.getInstance(); |
245 | // Calendar startDate = Calendar.getInstance(); | 235 | // Calendar startDate = Calendar.getInstance(); |
246 | // startDate.set(1900, 1, 1); | 236 | // startDate.set(1900, 1, 1); |
247 | // Calendar endDate = Calendar.getInstance(); | 237 | // Calendar endDate = Calendar.getInstance(); |
248 | // endDate.set(2100, 1, 1); | 238 | // endDate.set(2100, 1, 1); |
249 | //时间选择器 | 239 | //时间选择器 |
250 | pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { | 240 | pvTime = new TimePickerView.Builder(getActivity(), new TimePickerView.OnTimeSelectListener() { |
251 | @Override | 241 | @Override |
252 | public void onTimeSelect(Date date, View v) {//选中事件回调 | 242 | public void onTimeSelect(Date date, View v) {//选中事件回调 |
253 | // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null | 243 | // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null |
254 | /*btn_Time.setText(getTime(date));*/ | 244 | /*btn_Time.setText(getTime(date));*/ |
255 | TextView btn = (TextView) v; | 245 | TextView btn = (TextView) v; |
256 | btn.setText(getTime(date)); | 246 | btn.setText(getTime(date)); |
257 | } | 247 | } |
258 | }) | 248 | }) |
259 | //年月日时分秒 的显示与否,不设置则默认全部显示 | 249 | //年月日时分秒 的显示与否,不设置则默认全部显示 |
260 | .setType(new boolean[]{true, true, true, false, false, false}) | 250 | .setType(new boolean[]{true, true, true, false, false, false}) |
261 | .setLabel("", "", "", "", "", "") | 251 | .setLabel("", "", "", "", "", "") |
262 | .isCenterLabel(false) | 252 | .isCenterLabel(false) |
263 | .setDividerColor(Color.DKGRAY) | 253 | .setDividerColor(Color.DKGRAY) |
264 | .setContentSize(21) | 254 | .setContentSize(21) |
265 | // .setDate(selectedDate) | 255 | // .setDate(selectedDate) |
266 | // .setRangDate(startDate, endDate) | 256 | // .setRangDate(startDate, endDate) |
267 | .setBackgroundId(0x80000000) //设置外部遮罩颜色 | 257 | .setBackgroundId(0x80000000) //设置外部遮罩颜色 |
268 | .setDecorView(null) | 258 | .setDecorView(null) |
269 | .setTitleText("购买日期") | 259 | .setTitleText("购买日期") |
270 | .setTitleSize(22) | 260 | .setTitleSize(22) |
271 | .setCancelColor(Color.GRAY) | 261 | .setCancelColor(Color.GRAY) |
272 | .setSubCalSize(22) | 262 | .setSubCalSize(22) |
273 | .setDividerColor(Color.GRAY) | 263 | .setDividerColor(Color.GRAY) |
274 | .setSubmitColor(Color.GRAY) | 264 | .setSubmitColor(Color.GRAY) |
275 | .build(); | 265 | .build(); |
276 | } | 266 | } |
277 | 267 | ||
278 | private String getTime(Date date) {//可根据需要自行截取数据显示 | 268 | private String getTime(Date date) {//可根据需要自行截取数据显示 |
279 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | 269 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
280 | return format.format(date); | 270 | return format.format(date); |
281 | } | 271 | } |
282 | 272 | ||
283 | @Override | 273 | @Override |
284 | public void onAttach(Activity activity) { | 274 | public void onAttach(Activity activity) { |
285 | super.onAttach(activity); | 275 | super.onAttach(activity); |
286 | View rootView = activity.getWindow().getDecorView(); | 276 | View rootView = activity.getWindow().getDecorView(); |
287 | TextView sub = (TextView) rootView.findViewById(R.id.presonal_sub); | 277 | TextView sub = (TextView) rootView.findViewById(R.id.presonal_sub); |
288 | sub.setOnClickListener(this); | 278 | sub.setOnClickListener(this); |
289 | } | 279 | } |
290 | 280 | ||
291 | @Override | 281 | @Override |
292 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { | 282 | public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) { |
293 | String regionName = data.get(position).getRegionName(); | 283 | String regionName = data.get(position).getRegionName(); |
294 | String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); | 284 | String provice = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); |
295 | SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); | 285 | SaveParam.getInstance().saveLoginParam(getActivity(), "shi", regionName); |
296 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); | 286 | CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getChildFragmentManager(), "CountryDialog"); |
297 | tv_useinfo_adress.setText(""); | 287 | tv_useinfo_adress.setText(""); |
298 | tv_useinfo_adress.setText(provice + regionName); | 288 | tv_useinfo_adress.setText(provice + regionName); |
299 | 289 | ||
300 | 290 | ||
301 | } | 291 | } |
302 | 292 | ||
303 | @Override | 293 | @Override |
304 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { | 294 | public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) { |
305 | String regionName = data.get(position).getRegionName(); | 295 | String regionName = data.get(position).getRegionName(); |
306 | String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); | 296 | String provices = SaveParam.getInstance().getLoginParam(getActivity(), "sheng"); |
307 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); | 297 | String citys = SaveParam.getInstance().getLoginParam(getActivity(), "shi"); |
308 | tv_useinfo_adress.setText(""); | 298 | tv_useinfo_adress.setText(""); |
309 | tv_useinfo_adress.setText(provices + citys + regionName); | 299 | tv_useinfo_adress.setText(provices + citys + regionName); |
310 | 300 | ||
311 | } | 301 | } |
312 | 302 | ||
313 | @Override | 303 | @Override |
314 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { | 304 | public void province3OnItemClick(ArrayList<GradeInfo.DataBean.ChildrenBean> data, int position, int type) { |
315 | String regionName = data.get(position).getName(); | 305 | String regionName = data.get(position).getName(); |
316 | tv_useinfo_gender.setText(regionName); | 306 | tv_useinfo_gender.setText(regionName); |
317 | } | 307 | } |
318 | 308 | ||
319 | @Override | 309 | @Override |
320 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { | 310 | public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) { |
321 | String regionName = data.get(position).getRegionName(); | 311 | String regionName = data.get(position).getRegionName(); |
322 | SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); | 312 | SaveParam.getInstance().saveLoginParam(getActivity(), "sheng", regionName); |
323 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); | 313 | CitysListDialog.getInstance((DialogCallBack.CitysCallBack) PresonInfoFragment.this).show(getChildFragmentManager(), "CitysListDialog"); |
324 | 314 | ||
325 | } | 315 | } |
326 | 316 | ||
327 | @Override | 317 | @Override |
328 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { | 318 | public void provinceO4nItemClick(ArrayList<SchoolInfo.DataBean> data, int position, int type) { |
329 | String regionName = data.get(position).getSchoolName(); | 319 | String regionName = data.get(position).getSchoolName(); |
330 | tv_useinfo_school.setText(regionName); | 320 | tv_useinfo_school.setText(regionName); |
331 | 321 | ||
332 | 322 | ||
333 | } | 323 | } |
334 | } | 324 | } |
335 | 325 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by wei on 2017/6/21. | 4 | * Created by wei on 2017/6/21. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpCode { | 7 | public class HttpCode { |
8 | //查询保卡信息 | 8 | //查询保卡信息 |
9 | public static final int SUCHCARDINFO = 0; | 9 | public static final int SUCHCARDINFO = 0; |
10 | //是否填写保卡信息 | 10 | //是否填写保卡信息 |
11 | public static final int CHECKCARD = 1; | 11 | public static final int CHECKCARD = 1; |
12 | //注册 | 12 | //注册 |
13 | public static final int REGISTERED_SUCESS = 2; | 13 | public static final int REGISTERED_SUCESS = 2; |
14 | public static final int REGISTERED_FAIL = 3; | 14 | public static final int REGISTERED_FAIL = 3; |
15 | //注册验证码 | 15 | //注册验证码 |
16 | public static final int AUTHCODE_SUCESS = 4; | 16 | public static final int AUTHCODE_SUCESS = 4; |
17 | public static final int AUTHCODE_FAIL = 5; | 17 | public static final int AUTHCODE_FAIL = 5; |
18 | //忘记密码验证码 | 18 | //忘记密码验证码 |
19 | public static final int AUTHCODE_SUCESS1 = 6; | 19 | public static final int AUTHCODE_SUCESS1 = 6; |
20 | public static final int AUTHCODE_FAIL1 = 7; | 20 | public static final int AUTHCODE_FAIL1 = 7; |
21 | //是否已经注册 | 21 | //是否已经注册 |
22 | public static final int IS_REFISTER = 8; | 22 | public static final int IS_REFISTER = 8; |
23 | //忘记密码 | 23 | //忘记密码 |
24 | public static final int PASSWORD_SUCESS = 9; | 24 | public static final int PASSWORD_SUCESS = 9; |
25 | public static final int PASSWORD_FAIL = 10; | 25 | public static final int PASSWORD_FAIL = 10; |
26 | //s省 | 26 | //s省 |
27 | public static final int PROVICES = 11; | 27 | public static final int PROVICES = 11; |
28 | //市 | 28 | //市 |
29 | public static final int CITYS = 12; | 29 | public static final int CITYS = 12; |
30 | //区 | 30 | //区 |
31 | public static final int COUNTRY = 13; | 31 | public static final int COUNTRY = 13; |
32 | //学校 | 32 | //学校 |
33 | public static final int SCHOOL = 14; | 33 | public static final int SCHOOL = 14; |
34 | //年级 | 34 | //年级 |
35 | public static final int GRADER = 15; | 35 | public static final int GRADER = 15; |
36 | //获取个人信息 | 36 | //获取个人信息 |
37 | public static final int GETINFO = 16; | 37 | public static final int GETINFO = 16; |
38 | //获取个性签名 | 38 | //获取个性签名 |
39 | public static final int SIGN = 17; | 39 | public static final int SIGN = 17; |
40 | //登录 | 40 | //登录 |
41 | public static final int LOGIN_SUCESS = 18; | 41 | public static final int LOGIN_SUCESS = 18; |
42 | //获取子账户信息 | 42 | //获取子账户信息 |
43 | public static final int CHILDS_SUCESS = 19; | 43 | public static final int CHILDS_SUCESS = 19; |
44 | //版本升级 | ||
45 | public static final int APPUPDATE_SUCESS = 20; | ||
46 | |||
44 | 47 | ||
45 | 48 | ||
46 | 49 | ||
47 | } | 50 | } |
48 | 51 |
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; | ||
6 | import android.content.Context; | 5 | import android.content.Context; |
7 | import android.content.Intent; | 6 | import android.content.Intent; |
8 | import android.os.Handler; | 7 | import android.os.Handler; |
9 | import android.os.Message; | 8 | import android.os.Message; |
10 | import android.provider.Settings; | 9 | import android.provider.Settings; |
11 | import android.support.v4.app.FragmentActivity; | 10 | import android.support.v4.app.FragmentActivity; |
12 | import android.util.Log; | 11 | import android.util.Log; |
13 | import android.view.Gravity; | 12 | import android.view.Gravity; |
14 | import android.view.View; | 13 | import android.view.View; |
15 | import android.widget.Toast; | 14 | import android.widget.Toast; |
16 | 15 | ||
17 | import com.google.gson.Gson; | 16 | import com.google.gson.Gson; |
18 | import com.hjx.personalcenter.R; | 17 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
20 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 19 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
21 | import com.hjx.personalcenter.db.SaveParam; | 20 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.gson.GsonTool; | 21 | import com.hjx.personalcenter.gson.GsonTool; |
22 | import com.hjx.personalcenter.model.AppVersion; | ||
23 | import com.hjx.personalcenter.model.CardInfo; | 23 | import com.hjx.personalcenter.model.CardInfo; |
24 | import com.hjx.personalcenter.model.ChildsInfo; | 24 | import com.hjx.personalcenter.model.ChildsInfo; |
25 | import com.hjx.personalcenter.model.CityInfo; | 25 | import com.hjx.personalcenter.model.CityInfo; |
26 | import com.hjx.personalcenter.model.CountyInfo; | 26 | import com.hjx.personalcenter.model.CountyInfo; |
27 | import com.hjx.personalcenter.model.GradeInfo; | 27 | import com.hjx.personalcenter.model.GradeInfo; |
28 | import com.hjx.personalcenter.model.PesonalInfo; | 28 | import com.hjx.personalcenter.model.PesonalInfo; |
29 | import com.hjx.personalcenter.model.ProvinceInfo; | 29 | import com.hjx.personalcenter.model.ProvinceInfo; |
30 | import com.hjx.personalcenter.model.SchoolInfo; | 30 | import com.hjx.personalcenter.model.SchoolInfo; |
31 | import com.hjx.personalcenter.model.SignInfo; | 31 | import com.hjx.personalcenter.model.SignInfo; |
32 | import com.hjx.personalcenter.util.AlertUtils; | 32 | import com.hjx.personalcenter.util.AlertUtils; |
33 | import com.hjx.personalcenter.util.DialogPermission; | 33 | import com.hjx.personalcenter.util.DialogPermission; |
34 | import com.loopj.android.http.AsyncHttpResponseHandler; | 34 | import com.loopj.android.http.AsyncHttpResponseHandler; |
35 | import com.loopj.android.http.JsonHttpResponseHandler; | 35 | import com.loopj.android.http.JsonHttpResponseHandler; |
36 | import com.loopj.android.http.RequestParams; | 36 | import com.loopj.android.http.RequestParams; |
37 | import com.mylhyl.circledialog.CircleDialog; | 37 | import com.mylhyl.circledialog.CircleDialog; |
38 | import com.mylhyl.circledialog.callback.ConfigText; | 38 | import com.mylhyl.circledialog.callback.ConfigText; |
39 | import com.mylhyl.circledialog.params.TextParams; | 39 | import com.mylhyl.circledialog.params.TextParams; |
40 | 40 | ||
41 | import org.apache.http.Header; | 41 | import org.apache.http.Header; |
42 | import org.apache.http.entity.ByteArrayEntity; | 42 | import org.apache.http.entity.ByteArrayEntity; |
43 | import org.apache.http.message.BasicHeader; | 43 | import org.apache.http.message.BasicHeader; |
44 | import org.apache.http.protocol.HTTP; | 44 | import org.apache.http.protocol.HTTP; |
45 | import org.json.JSONException; | 45 | import org.json.JSONException; |
46 | import org.json.JSONObject; | 46 | import org.json.JSONObject; |
47 | 47 | ||
48 | import java.io.UnsupportedEncodingException; | 48 | import java.io.UnsupportedEncodingException; |
49 | import java.util.ArrayList; | 49 | import java.util.ArrayList; |
50 | import java.util.List; | 50 | import java.util.List; |
51 | 51 | ||
52 | public class HttpManager { | 52 | public class HttpManager { |
53 | private static HttpManager instance; | 53 | private static HttpManager instance; |
54 | private ProgressDialog mProgress = null; | 54 | private ProgressDialog mProgress = null; |
55 | 55 | ||
56 | public static HttpManager getInstance() { | 56 | public static HttpManager getInstance() { |
57 | if (instance == null) { | 57 | if (instance == null) { |
58 | instance = new HttpManager(); | 58 | instance = new HttpManager(); |
59 | } | 59 | } |
60 | return instance; | 60 | return instance; |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | //登录接口 | 64 | //登录接口 |
65 | 65 | ||
66 | public void login(final String username, final String password, final Context mContext, final Handler handler) { | 66 | public void login(final String username, final String password, final Context mContext, final Handler handler) { |
67 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 67 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
68 | false, true, null); | 68 | false, true, null); |
69 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 69 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
70 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 70 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
71 | @Override | 71 | @Override |
72 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 72 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
73 | closeProgress(); | 73 | closeProgress(); |
74 | Message msg = Message.obtain(); | 74 | Message msg = Message.obtain(); |
75 | msg.what = HttpCode.LOGIN_SUCESS; | 75 | msg.what = HttpCode.LOGIN_SUCESS; |
76 | msg.obj = new String(arg2); | 76 | msg.obj = new String(arg2); |
77 | handler.sendMessage(msg); | 77 | handler.sendMessage(msg); |
78 | 78 | ||
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | @Override | 82 | @Override |
83 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 83 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
84 | closeProgress(); | 84 | closeProgress(); |
85 | new CircleDialog.Builder((FragmentActivity) mContext) | 85 | new CircleDialog.Builder((FragmentActivity) mContext) |
86 | .setCanceledOnTouchOutside(false) | 86 | .setCanceledOnTouchOutside(false) |
87 | .setCancelable(false) | 87 | .setCancelable(false) |
88 | .setWidth(0.5f) | 88 | .setWidth(0.5f) |
89 | .configText(new ConfigText() { | 89 | .configText(new ConfigText() { |
90 | @Override | 90 | @Override |
91 | public void onConfig(TextParams params) { | 91 | public void onConfig(TextParams params) { |
92 | params.gravity = Gravity.CENTER; | 92 | params.gravity = Gravity.CENTER; |
93 | params.padding = new int[]{50, 50, 50, 50}; | 93 | params.padding = new int[]{50, 50, 50, 50}; |
94 | } | 94 | } |
95 | }) | 95 | }) |
96 | .setText("当前无网络,请检查网络设置") | 96 | .setText("当前无网络,请检查网络设置") |
97 | .setNegative("继续使用", null) | 97 | .setNegative("继续使用", null) |
98 | .setPositive("设置网络", new View.OnClickListener() { | 98 | .setPositive("设置网络", new View.OnClickListener() { |
99 | @Override | 99 | @Override |
100 | public void onClick(View v) { | 100 | public void onClick(View v) { |
101 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 101 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
102 | mContext.startActivity(intent); | 102 | mContext.startActivity(intent); |
103 | } | 103 | } |
104 | }) | 104 | }) |
105 | .show(); | 105 | .show(); |
106 | } | 106 | } |
107 | }); | 107 | }); |
108 | } | 108 | } |
109 | 109 | ||
110 | //注册接口 | 110 | //注册接口 |
111 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 111 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
112 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 112 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
113 | false, true, null); | 113 | false, true, null); |
114 | JSONObject jsonObject = new JSONObject(); | 114 | JSONObject jsonObject = new JSONObject(); |
115 | ByteArrayEntity entity = null; | 115 | ByteArrayEntity entity = null; |
116 | try { | 116 | try { |
117 | jsonObject.put(HttpKey.USERNAME, username); | 117 | jsonObject.put(HttpKey.USERNAME, username); |
118 | jsonObject.put(HttpKey.PASSWORD, password); | 118 | jsonObject.put(HttpKey.PASSWORD, password); |
119 | jsonObject.put(HttpKey.SMSCODE, smscode); | 119 | jsonObject.put(HttpKey.SMSCODE, smscode); |
120 | jsonObject.put(HttpKey.SOURCE, source); | 120 | jsonObject.put(HttpKey.SOURCE, source); |
121 | Log.e("test", "jsonObject" + jsonObject); | 121 | Log.e("test", "jsonObject" + jsonObject); |
122 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 122 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
123 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 123 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
124 | } catch (JSONException e) { | 124 | } catch (JSONException e) { |
125 | e.printStackTrace(); | 125 | e.printStackTrace(); |
126 | } catch (UnsupportedEncodingException e) { | 126 | } catch (UnsupportedEncodingException e) { |
127 | e.printStackTrace(); | 127 | e.printStackTrace(); |
128 | } | 128 | } |
129 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 129 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
130 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 130 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
131 | @Override | 131 | @Override |
132 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 132 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
133 | super.onSuccess(statusCode, headers, response); | 133 | super.onSuccess(statusCode, headers, response); |
134 | closeProgress(); | 134 | closeProgress(); |
135 | Log.e("test", "onSuccess" + response); | 135 | Log.e("test", "onSuccess" + response); |
136 | Message msg = Message.obtain(); | 136 | Message msg = Message.obtain(); |
137 | msg.what = HttpCode.REGISTERED_SUCESS; | 137 | msg.what = HttpCode.REGISTERED_SUCESS; |
138 | msg.obj = response; | 138 | msg.obj = response; |
139 | handler.sendMessage(msg); | 139 | handler.sendMessage(msg); |
140 | 140 | ||
141 | } | 141 | } |
142 | 142 | ||
143 | @Override | 143 | @Override |
144 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 144 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
145 | super.onFailure(statusCode, headers, throwable, errorResponse); | 145 | super.onFailure(statusCode, headers, throwable, errorResponse); |
146 | closeProgress(); | 146 | closeProgress(); |
147 | Log.e("test", "onFailure" + errorResponse); | 147 | Log.e("test", "onFailure" + errorResponse); |
148 | new CircleDialog.Builder((FragmentActivity) context) | 148 | new CircleDialog.Builder((FragmentActivity) context) |
149 | .setCanceledOnTouchOutside(false) | 149 | .setCanceledOnTouchOutside(false) |
150 | .setCancelable(false) | 150 | .setCancelable(false) |
151 | .setWidth(0.5f) | 151 | .setWidth(0.5f) |
152 | .configText(new ConfigText() { | 152 | .configText(new ConfigText() { |
153 | @Override | 153 | @Override |
154 | public void onConfig(TextParams params) { | 154 | public void onConfig(TextParams params) { |
155 | params.gravity = Gravity.CENTER; | 155 | params.gravity = Gravity.CENTER; |
156 | params.padding = new int[]{50, 50, 50, 50}; | 156 | params.padding = new int[]{50, 50, 50, 50}; |
157 | } | 157 | } |
158 | }) | 158 | }) |
159 | .setText("当前无网络,请检查网络设置") | 159 | .setText("当前无网络,请检查网络设置") |
160 | .setNegative("继续使用", null) | 160 | .setNegative("继续使用", null) |
161 | .setPositive("设置网络", new View.OnClickListener() { | 161 | .setPositive("设置网络", new View.OnClickListener() { |
162 | @Override | 162 | @Override |
163 | public void onClick(View v) { | 163 | public void onClick(View v) { |
164 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 164 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
165 | context.startActivity(intent); | 165 | context.startActivity(intent); |
166 | } | 166 | } |
167 | }) | 167 | }) |
168 | .show(); | 168 | .show(); |
169 | } | 169 | } |
170 | 170 | ||
171 | }); | 171 | }); |
172 | } | 172 | } |
173 | 173 | ||
174 | //注册验证码 | 174 | //注册验证码 |
175 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 175 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
176 | RequestParams params = new RequestParams(); | 176 | RequestParams params = new RequestParams(); |
177 | params.put(HttpKey.TYPE, type); | 177 | params.put(HttpKey.TYPE, type); |
178 | params.put(HttpKey.MOBIL, mobile); | 178 | params.put(HttpKey.MOBIL, mobile); |
179 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 179 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
180 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 180 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
181 | 181 | ||
182 | @Override | 182 | @Override |
183 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 183 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
184 | Log.e("test", "onSuccess-----" + response); | 184 | Log.e("test", "onSuccess-----" + response); |
185 | Message msg = Message.obtain(); | 185 | Message msg = Message.obtain(); |
186 | msg.what = HttpCode.AUTHCODE_SUCESS; | 186 | msg.what = HttpCode.AUTHCODE_SUCESS; |
187 | msg.obj = response; | 187 | msg.obj = response; |
188 | handler.sendMessage(msg); | 188 | handler.sendMessage(msg); |
189 | } | 189 | } |
190 | 190 | ||
191 | @Override | 191 | @Override |
192 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 192 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
193 | new CircleDialog.Builder((FragmentActivity) mContext) | 193 | new CircleDialog.Builder((FragmentActivity) mContext) |
194 | .setCanceledOnTouchOutside(false) | 194 | .setCanceledOnTouchOutside(false) |
195 | .setCancelable(false) | 195 | .setCancelable(false) |
196 | .setWidth(0.5f) | 196 | .setWidth(0.5f) |
197 | .configText(new ConfigText() { | 197 | .configText(new ConfigText() { |
198 | @Override | 198 | @Override |
199 | public void onConfig(TextParams params) { | 199 | public void onConfig(TextParams params) { |
200 | params.gravity = Gravity.CENTER; | 200 | params.gravity = Gravity.CENTER; |
201 | params.padding = new int[]{50, 50, 50, 50}; | 201 | params.padding = new int[]{50, 50, 50, 50}; |
202 | } | 202 | } |
203 | }) | 203 | }) |
204 | .setText("当前无网络,请检查网络设置") | 204 | .setText("当前无网络,请检查网络设置") |
205 | .setNegative("继续使用", null) | 205 | .setNegative("继续使用", null) |
206 | .setPositive("设置网络", new View.OnClickListener() { | 206 | .setPositive("设置网络", new View.OnClickListener() { |
207 | @Override | 207 | @Override |
208 | public void onClick(View v) { | 208 | public void onClick(View v) { |
209 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 209 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
210 | mContext.startActivity(intent); | 210 | mContext.startActivity(intent); |
211 | } | 211 | } |
212 | }) | 212 | }) |
213 | .show(); | 213 | .show(); |
214 | } | 214 | } |
215 | }); | 215 | }); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | //手机号是否注册 | 219 | //手机号是否注册 |
220 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 220 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
221 | RequestParams params = new RequestParams(); | 221 | RequestParams params = new RequestParams(); |
222 | params.put(HttpKey.USERNAME, mobile); | 222 | params.put(HttpKey.USERNAME, mobile); |
223 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 223 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
224 | @Override | 224 | @Override |
225 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 225 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
226 | Log.e("test", "isregistered" + response.toString()); | 226 | Log.e("test", "isregistered" + response.toString()); |
227 | Message msg = Message.obtain(); | 227 | Message msg = Message.obtain(); |
228 | msg.what = HttpCode.IS_REFISTER; | 228 | msg.what = HttpCode.IS_REFISTER; |
229 | msg.obj = response; | 229 | msg.obj = response; |
230 | handler.sendMessage(msg); | 230 | handler.sendMessage(msg); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | @Override | 234 | @Override |
235 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 235 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
236 | new CircleDialog.Builder((FragmentActivity) mContext) | 236 | new CircleDialog.Builder((FragmentActivity) mContext) |
237 | .setCanceledOnTouchOutside(false) | 237 | .setCanceledOnTouchOutside(false) |
238 | .setCancelable(false) | 238 | .setCancelable(false) |
239 | .setWidth(0.5f) | 239 | .setWidth(0.5f) |
240 | .configText(new ConfigText() { | 240 | .configText(new ConfigText() { |
241 | @Override | 241 | @Override |
242 | public void onConfig(TextParams params) { | 242 | public void onConfig(TextParams params) { |
243 | params.gravity = Gravity.CENTER; | 243 | params.gravity = Gravity.CENTER; |
244 | params.padding = new int[]{50, 50, 50, 50}; | 244 | params.padding = new int[]{50, 50, 50, 50}; |
245 | } | 245 | } |
246 | }) | 246 | }) |
247 | .setText("当前无网络,请检查网络设置") | 247 | .setText("当前无网络,请检查网络设置") |
248 | .setNegative("继续使用", null) | 248 | .setNegative("继续使用", null) |
249 | .setPositive("设置网络", new View.OnClickListener() { | 249 | .setPositive("设置网络", new View.OnClickListener() { |
250 | @Override | 250 | @Override |
251 | public void onClick(View v) { | 251 | public void onClick(View v) { |
252 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 252 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
253 | mContext.startActivity(intent); | 253 | mContext.startActivity(intent); |
254 | } | 254 | } |
255 | }) | 255 | }) |
256 | .show(); | 256 | .show(); |
257 | 257 | ||
258 | } | 258 | } |
259 | }); | 259 | }); |
260 | } | 260 | } |
261 | 261 | ||
262 | //修改密码 | 262 | //修改密码 |
263 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 263 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
264 | RequestParams params = new RequestParams(); | 264 | RequestParams params = new RequestParams(); |
265 | params.put(HttpKey.USERNAME, username); | 265 | params.put(HttpKey.USERNAME, username); |
266 | params.put(HttpKey.OLDPASS, old_pwd1); | 266 | params.put(HttpKey.OLDPASS, old_pwd1); |
267 | params.put(HttpKey.NEWPASS, newpassword3); | 267 | params.put(HttpKey.NEWPASS, newpassword3); |
268 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 268 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
269 | HttpClient.getInstance().setTimeout(10 * 1000); | 269 | HttpClient.getInstance().setTimeout(10 * 1000); |
270 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 270 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
271 | @Override | 271 | @Override |
272 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 272 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
273 | try { | 273 | try { |
274 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 274 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
275 | String status = jsonObject.optString("status"); | 275 | String status = jsonObject.optString("status"); |
276 | if (status.equals("100")) { | 276 | if (status.equals("100")) { |
277 | Log.e("test", "onSuccess" + new String(bytes)); | 277 | Log.e("test", "onSuccess" + new String(bytes)); |
278 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 278 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
279 | SaveParam.getInstance().clearData((Activity) context); | 279 | SaveParam.getInstance().clearData((Activity) context); |
280 | Intent intent = new Intent(); | 280 | Intent intent = new Intent(); |
281 | intent.setClass(context, LoginAndRegisterActivity.class); | 281 | intent.setClass(context, LoginAndRegisterActivity.class); |
282 | ((Activity) context).startActivity(intent); | 282 | ((Activity) context).startActivity(intent); |
283 | ((Activity) context).finish(); | 283 | ((Activity) context).finish(); |
284 | } | 284 | } |
285 | } catch (JSONException e) { | 285 | } catch (JSONException e) { |
286 | e.printStackTrace(); | 286 | e.printStackTrace(); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | @Override | 290 | @Override |
291 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 291 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
292 | Log.e("test", "onFailure" + new String(bytes)); | 292 | Log.e("test", "onFailure" + new String(bytes)); |
293 | new CircleDialog.Builder((FragmentActivity) context) | 293 | new CircleDialog.Builder((FragmentActivity) context) |
294 | .setCanceledOnTouchOutside(false) | 294 | .setCanceledOnTouchOutside(false) |
295 | .setCancelable(false) | 295 | .setCancelable(false) |
296 | .setWidth(0.5f) | 296 | .setWidth(0.5f) |
297 | .configText(new ConfigText() { | 297 | .configText(new ConfigText() { |
298 | @Override | 298 | @Override |
299 | public void onConfig(TextParams params) { | 299 | public void onConfig(TextParams params) { |
300 | params.gravity = Gravity.CENTER; | 300 | params.gravity = Gravity.CENTER; |
301 | params.padding = new int[]{50, 50, 50, 50}; | 301 | params.padding = new int[]{50, 50, 50, 50}; |
302 | } | 302 | } |
303 | }) | 303 | }) |
304 | .setText("当前无网络,请检查网络设置") | 304 | .setText("当前无网络,请检查网络设置") |
305 | .setNegative("继续使用", null) | 305 | .setNegative("继续使用", null) |
306 | .setPositive("设置网络", new View.OnClickListener() { | 306 | .setPositive("设置网络", new View.OnClickListener() { |
307 | @Override | 307 | @Override |
308 | public void onClick(View v) { | 308 | public void onClick(View v) { |
309 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 309 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
310 | context.startActivity(intent); | 310 | context.startActivity(intent); |
311 | } | 311 | } |
312 | }) | 312 | }) |
313 | .show(); | 313 | .show(); |
314 | } | 314 | } |
315 | }); | 315 | }); |
316 | 316 | ||
317 | } | 317 | } |
318 | 318 | ||
319 | //忘记密码 | 319 | //忘记密码 |
320 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 320 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
321 | RequestParams params = new RequestParams(); | 321 | RequestParams params = new RequestParams(); |
322 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 322 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
323 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 323 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
324 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 324 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
325 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 325 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
326 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 326 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
327 | @Override | 327 | @Override |
328 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 328 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
329 | try { | 329 | try { |
330 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 330 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
331 | String status = jsonObject.optString("status"); | 331 | String status = jsonObject.optString("status"); |
332 | if (status.equals("100")) { | 332 | if (status.equals("100")) { |
333 | Log.e("test", "onSuccess" + new String(bytes)); | 333 | Log.e("test", "onSuccess" + new String(bytes)); |
334 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 334 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
335 | ((Activity) context).finish(); | 335 | ((Activity) context).finish(); |
336 | } | 336 | } |
337 | } catch (JSONException e) { | 337 | } catch (JSONException e) { |
338 | e.printStackTrace(); | 338 | e.printStackTrace(); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | @Override | 342 | @Override |
343 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 343 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
344 | Log.e("test", "onFailure" + new String(bytes)); | 344 | Log.e("test", "onFailure" + new String(bytes)); |
345 | new CircleDialog.Builder((FragmentActivity) context) | 345 | new CircleDialog.Builder((FragmentActivity) context) |
346 | .setCanceledOnTouchOutside(false) | 346 | .setCanceledOnTouchOutside(false) |
347 | .setCancelable(false) | 347 | .setCancelable(false) |
348 | .setWidth(0.5f) | 348 | .setWidth(0.5f) |
349 | .configText(new ConfigText() { | 349 | .configText(new ConfigText() { |
350 | @Override | 350 | @Override |
351 | public void onConfig(TextParams params) { | 351 | public void onConfig(TextParams params) { |
352 | params.gravity = Gravity.CENTER; | 352 | params.gravity = Gravity.CENTER; |
353 | params.padding = new int[]{50, 50, 50, 50}; | 353 | params.padding = new int[]{50, 50, 50, 50}; |
354 | } | 354 | } |
355 | }) | 355 | }) |
356 | .setText("当前无网络,请检查网络设置") | 356 | .setText("当前无网络,请检查网络设置") |
357 | .setNegative("继续使用", null) | 357 | .setNegative("继续使用", null) |
358 | .setPositive("设置网络", new View.OnClickListener() { | 358 | .setPositive("设置网络", new View.OnClickListener() { |
359 | @Override | 359 | @Override |
360 | public void onClick(View v) { | 360 | public void onClick(View v) { |
361 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 361 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
362 | context.startActivity(intent); | 362 | context.startActivity(intent); |
363 | } | 363 | } |
364 | }) | 364 | }) |
365 | .show(); | 365 | .show(); |
366 | } | 366 | } |
367 | }); | 367 | }); |
368 | 368 | ||
369 | } | 369 | } |
370 | 370 | ||
371 | //保存用户登录信息 | 371 | //保存用户登录信息 |
372 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 372 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
373 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 373 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
374 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 374 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
375 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 375 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
376 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 376 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
377 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 377 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
378 | 378 | ||
379 | 379 | ||
380 | } | 380 | } |
381 | 381 | ||
382 | //保存用户登录信息 | 382 | //保存用户登录信息 |
383 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { | 383 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { |
384 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); | 384 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); |
385 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); | 385 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); |
386 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); | 386 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); |
387 | } | 387 | } |
388 | 388 | ||
389 | //提交保卡信息 | 389 | //提交保卡信息 |
390 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, | 390 | public void subcardinfo(final Context context, long userId, String customerName, String customerAddress, |
391 | String buyAddress, String buyTime, String alterSaleCall, | 391 | String buyAddress, String buyTime, String alterSaleCall, |
392 | String productModel, String deviceNumber, String macAddress, | 392 | String productModel, String deviceNumber, String macAddress, |
393 | String mobilePhone) { | 393 | String mobilePhone) { |
394 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 394 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
395 | false, true, null); | 395 | false, true, null); |
396 | RequestParams params = new RequestParams(); | 396 | RequestParams params = new RequestParams(); |
397 | 397 | ||
398 | params.put(HttpKey.USEID, userId); | 398 | params.put(HttpKey.USEID, userId); |
399 | params.put(HttpKey.CUSTOMENAME, customerName); | 399 | params.put(HttpKey.CUSTOMENAME, customerName); |
400 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 400 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
401 | params.put(HttpKey.BUYADREES, buyAddress); | 401 | params.put(HttpKey.BUYADREES, buyAddress); |
402 | params.put(HttpKey.BUYTIME, buyTime); | 402 | params.put(HttpKey.BUYTIME, buyTime); |
403 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 403 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
404 | params.put(HttpKey.PRODUCTMODEL, productModel); | 404 | params.put(HttpKey.PRODUCTMODEL, productModel); |
405 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 405 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
406 | params.put(HttpKey.MACADRESS, macAddress); | 406 | params.put(HttpKey.MACADRESS, macAddress); |
407 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 407 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
408 | 408 | ||
409 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 409 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
410 | 410 | ||
411 | Log.e("test", "params" + params); | 411 | Log.e("test", "params" + params); |
412 | HttpClient.getInstance().setTimeout(5 * 1000); | 412 | HttpClient.getInstance().setTimeout(5 * 1000); |
413 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 413 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
414 | @Override | 414 | @Override |
415 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 415 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
416 | JSONObject jsonObject = null; | 416 | JSONObject jsonObject = null; |
417 | closeProgress(); | 417 | closeProgress(); |
418 | try { | 418 | try { |
419 | jsonObject = new JSONObject(new String(bytes)); | 419 | jsonObject = new JSONObject(new String(bytes)); |
420 | String status = jsonObject.optString("status"); | 420 | String status = jsonObject.optString("status"); |
421 | if (status.equals("1")) { | 421 | if (status.equals("1")) { |
422 | Log.e("test", "onSuccess" + jsonObject); | 422 | Log.e("test", "onSuccess" + jsonObject); |
423 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 423 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
424 | Intent intent = new Intent(); | 424 | Intent intent = new Intent(); |
425 | intent.setClass((Activity) context, TheStartPageActivity.class); | 425 | intent.setClass((Activity) context, TheStartPageActivity.class); |
426 | ((Activity) context).startActivity(intent); | 426 | ((Activity) context).startActivity(intent); |
427 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 427 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
428 | ((Activity) context).finish(); | 428 | ((Activity) context).finish(); |
429 | } | 429 | } |
430 | } catch (JSONException e) { | 430 | } catch (JSONException e) { |
431 | e.printStackTrace(); | 431 | e.printStackTrace(); |
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | } | 435 | } |
436 | 436 | ||
437 | @Override | 437 | @Override |
438 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 438 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
439 | Log.e("test", "onFailure" + (throwable)); | 439 | Log.e("test", "onFailure" + (throwable)); |
440 | closeProgress(); | 440 | closeProgress(); |
441 | new CircleDialog.Builder((FragmentActivity) context) | 441 | new CircleDialog.Builder((FragmentActivity) context) |
442 | .setCanceledOnTouchOutside(false) | 442 | .setCanceledOnTouchOutside(false) |
443 | .setCancelable(false) | 443 | .setCancelable(false) |
444 | .setWidth(0.5f) | 444 | .setWidth(0.5f) |
445 | .configText(new ConfigText() { | 445 | .configText(new ConfigText() { |
446 | @Override | 446 | @Override |
447 | public void onConfig(TextParams params) { | 447 | public void onConfig(TextParams params) { |
448 | params.gravity = Gravity.CENTER; | 448 | params.gravity = Gravity.CENTER; |
449 | params.padding = new int[]{50, 50, 50, 50}; | 449 | params.padding = new int[]{50, 50, 50, 50}; |
450 | } | 450 | } |
451 | }) | 451 | }) |
452 | .setText("当前无网络,请检查网络设置") | 452 | .setText("当前无网络,请检查网络设置") |
453 | .setNegative("继续使用", null) | 453 | .setNegative("继续使用", null) |
454 | .setPositive("设置网络", new View.OnClickListener() { | 454 | .setPositive("设置网络", new View.OnClickListener() { |
455 | @Override | 455 | @Override |
456 | public void onClick(View v) { | 456 | public void onClick(View v) { |
457 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 457 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
458 | context.startActivity(intent); | 458 | context.startActivity(intent); |
459 | } | 459 | } |
460 | }) | 460 | }) |
461 | .show(); | 461 | .show(); |
462 | 462 | ||
463 | } | 463 | } |
464 | }); | 464 | }); |
465 | 465 | ||
466 | } | 466 | } |
467 | //获取保卡信息 | 467 | //获取保卡信息 |
468 | public void getcardinfo(final Context mContext, long userId , final Handler handler) { | 468 | public void getcardinfo(final Context mContext, long userId , final Handler handler) { |
469 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 469 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
470 | false, true, null); | 470 | false, true, null); |
471 | HttpClient.getInstance().setTimeout(5 * 1000); | 471 | HttpClient.getInstance().setTimeout(5 * 1000); |
472 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 472 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
473 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { | 473 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { |
474 | @Override | 474 | @Override |
475 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 475 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
476 | closeProgress(); | 476 | closeProgress(); |
477 | Log.e("test", "保卡信息" + new String(arg2)); | 477 | Log.e("test", "保卡信息" + new String(arg2)); |
478 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 | 478 | CardInfo cardInfo = GsonTool.getPerson(new String(arg2), CardInfo.class);//解析json数据 |
479 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); | 479 | CardInfo.DataBean schoolInfoBeanList = cardInfo.getData(); |
480 | Message msg = Message.obtain(); | 480 | Message msg = Message.obtain(); |
481 | msg.what = HttpCode.SUCHCARDINFO; | 481 | msg.what = HttpCode.SUCHCARDINFO; |
482 | msg.obj = schoolInfoBeanList; | 482 | msg.obj = schoolInfoBeanList; |
483 | handler.sendMessage(msg); | 483 | handler.sendMessage(msg); |
484 | } | 484 | } |
485 | 485 | ||
486 | @Override | 486 | @Override |
487 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 487 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
488 | closeProgress(); | 488 | closeProgress(); |
489 | new CircleDialog.Builder((FragmentActivity) mContext) | 489 | new CircleDialog.Builder((FragmentActivity) mContext) |
490 | .setCanceledOnTouchOutside(false) | 490 | .setCanceledOnTouchOutside(false) |
491 | .setCancelable(false) | 491 | .setCancelable(false) |
492 | .setWidth(0.5f) | 492 | .setWidth(0.5f) |
493 | .configText(new ConfigText() { | 493 | .configText(new ConfigText() { |
494 | @Override | 494 | @Override |
495 | public void onConfig(TextParams params) { | 495 | public void onConfig(TextParams params) { |
496 | params.gravity = Gravity.CENTER; | 496 | params.gravity = Gravity.CENTER; |
497 | params.padding = new int[]{50, 50, 50, 50}; | 497 | params.padding = new int[]{50, 50, 50, 50}; |
498 | } | 498 | } |
499 | }) | 499 | }) |
500 | .setText("当前无网络,请检查网络设置") | 500 | .setText("当前无网络,请检查网络设置") |
501 | .setNegative("继续使用", null) | 501 | .setNegative("继续使用", null) |
502 | .setPositive("设置网络", new View.OnClickListener() { | 502 | .setPositive("设置网络", new View.OnClickListener() { |
503 | @Override | 503 | @Override |
504 | public void onClick(View v) { | 504 | public void onClick(View v) { |
505 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 505 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
506 | mContext.startActivity(intent); | 506 | mContext.startActivity(intent); |
507 | } | 507 | } |
508 | }) | 508 | }) |
509 | .show(); | 509 | .show(); |
510 | } | 510 | } |
511 | }); | 511 | }); |
512 | } | 512 | } |
513 | //修改保卡信息电话 | 513 | //修改保卡信息电话 |
514 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { | 514 | public void changecardinfophone(final Context mContext, long userId, final String customerPhone, String authCode) { |
515 | RequestParams params = new RequestParams(); | 515 | RequestParams params = new RequestParams(); |
516 | params.put("userId", userId); | 516 | params.put("userId", userId); |
517 | params.put("customerPhone", customerPhone); | 517 | params.put("customerPhone", customerPhone); |
518 | params.put("authCode", authCode); | 518 | params.put("authCode", authCode); |
519 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 519 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
520 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 520 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
521 | @Override | 521 | @Override |
522 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 522 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
523 | try { | 523 | try { |
524 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 524 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
525 | String status = jsonObject.optString("status"); | 525 | String status = jsonObject.optString("status"); |
526 | if (status.equals("1")) { | 526 | if (status.equals("1")) { |
527 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 527 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
528 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); | 528 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); |
529 | ((Activity) mContext).finish(); | 529 | ((Activity) mContext).finish(); |
530 | }else if (status.equals("1001")){ | 530 | }else if (status.equals("1001")){ |
531 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 531 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
532 | } | 532 | } |
533 | } catch (JSONException e) { | 533 | } catch (JSONException e) { |
534 | e.printStackTrace(); | 534 | e.printStackTrace(); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | @Override | 538 | @Override |
539 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 539 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
540 | Log.e("test", "onFailure" + new String(bytes)); | 540 | Log.e("test", "onFailure" + new String(bytes)); |
541 | new CircleDialog.Builder((FragmentActivity) mContext) | 541 | new CircleDialog.Builder((FragmentActivity) mContext) |
542 | .setCanceledOnTouchOutside(false) | 542 | .setCanceledOnTouchOutside(false) |
543 | .setCancelable(false) | 543 | .setCancelable(false) |
544 | .setWidth(0.5f) | 544 | .setWidth(0.5f) |
545 | .configText(new ConfigText() { | 545 | .configText(new ConfigText() { |
546 | @Override | 546 | @Override |
547 | public void onConfig(TextParams params) { | 547 | public void onConfig(TextParams params) { |
548 | params.gravity = Gravity.CENTER; | 548 | params.gravity = Gravity.CENTER; |
549 | params.padding = new int[]{50, 50, 50, 50}; | 549 | params.padding = new int[]{50, 50, 50, 50}; |
550 | } | 550 | } |
551 | }) | 551 | }) |
552 | .setText("当前无网络,请检查网络设置") | 552 | .setText("当前无网络,请检查网络设置") |
553 | .setNegative("继续使用", null) | 553 | .setNegative("继续使用", null) |
554 | .setPositive("设置网络", new View.OnClickListener() { | 554 | .setPositive("设置网络", new View.OnClickListener() { |
555 | @Override | 555 | @Override |
556 | public void onClick(View v) { | 556 | public void onClick(View v) { |
557 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 557 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
558 | mContext.startActivity(intent); | 558 | mContext.startActivity(intent); |
559 | } | 559 | } |
560 | }) | 560 | }) |
561 | .show(); | 561 | .show(); |
562 | } | 562 | } |
563 | }); | 563 | }); |
564 | } | 564 | } |
565 | //修改保卡信息地址 | 565 | //修改保卡信息地址 |
566 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { | 566 | public void changecardadressinfo(final Context mContext, long userId, final String customerPhone, String authCode, final String customerAddress) { |
567 | RequestParams params = new RequestParams(); | 567 | RequestParams params = new RequestParams(); |
568 | params.put("userId", userId); | 568 | params.put("userId", userId); |
569 | params.put("customerPhone", customerPhone); | 569 | params.put("customerPhone", customerPhone); |
570 | params.put("authCode", authCode); | 570 | params.put("authCode", authCode); |
571 | params.put("customerAddress", customerAddress); | 571 | params.put("customerAddress", customerAddress); |
572 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 572 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
573 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 573 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
574 | @Override | 574 | @Override |
575 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 575 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
576 | try { | 576 | try { |
577 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 577 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
578 | String status = jsonObject.optString("status"); | 578 | String status = jsonObject.optString("status"); |
579 | if (status.equals("1")) { | 579 | if (status.equals("1")) { |
580 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 580 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
581 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); | 581 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); |
582 | ((Activity) mContext).finish(); | 582 | ((Activity) mContext).finish(); |
583 | } | 583 | } |
584 | } catch (JSONException e) { | 584 | } catch (JSONException e) { |
585 | e.printStackTrace(); | 585 | e.printStackTrace(); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | @Override | 589 | @Override |
590 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 590 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
591 | Log.e("test", "onFailure" + new String(bytes)); | 591 | Log.e("test", "onFailure" + new String(bytes)); |
592 | new CircleDialog.Builder((FragmentActivity) mContext) | 592 | new CircleDialog.Builder((FragmentActivity) mContext) |
593 | .setCanceledOnTouchOutside(false) | 593 | .setCanceledOnTouchOutside(false) |
594 | .setCancelable(false) | 594 | .setCancelable(false) |
595 | .setWidth(0.5f) | 595 | .setWidth(0.5f) |
596 | .configText(new ConfigText() { | 596 | .configText(new ConfigText() { |
597 | @Override | 597 | @Override |
598 | public void onConfig(TextParams params) { | 598 | public void onConfig(TextParams params) { |
599 | params.gravity = Gravity.CENTER; | 599 | params.gravity = Gravity.CENTER; |
600 | params.padding = new int[]{50, 50, 50, 50}; | 600 | params.padding = new int[]{50, 50, 50, 50}; |
601 | } | 601 | } |
602 | }) | 602 | }) |
603 | .setText("当前无网络,请检查网络设置") | 603 | .setText("当前无网络,请检查网络设置") |
604 | .setNegative("继续使用", null) | 604 | .setNegative("继续使用", null) |
605 | .setPositive("设置网络", new View.OnClickListener() { | 605 | .setPositive("设置网络", new View.OnClickListener() { |
606 | @Override | 606 | @Override |
607 | public void onClick(View v) { | 607 | public void onClick(View v) { |
608 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 608 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
609 | mContext.startActivity(intent); | 609 | mContext.startActivity(intent); |
610 | } | 610 | } |
611 | }) | 611 | }) |
612 | .show(); | 612 | .show(); |
613 | } | 613 | } |
614 | }); | 614 | }); |
615 | } | 615 | } |
616 | //验证是否保卡信息 | 616 | //验证是否保卡信息 |
617 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { | 617 | public void cardinfocheck(final Context mContext, long userId, final Handler handler) { |
618 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", | 618 | mProgress = DialogPermission.showProgress(mContext, null, "正在验证保卡信息...", |
619 | false, true, null); | 619 | false, true, null); |
620 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 620 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
621 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { | 621 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { |
622 | @Override | 622 | @Override |
623 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 623 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
624 | Log.e("test", "---" + new String(arg2)); | 624 | Log.e("test", "---" + new String(arg2)); |
625 | closeProgress(); | 625 | closeProgress(); |
626 | Message msg = Message.obtain(); | 626 | Message msg = Message.obtain(); |
627 | msg.what = HttpCode.CHECKCARD; | 627 | msg.what = HttpCode.CHECKCARD; |
628 | msg.obj = new String(arg2); | 628 | msg.obj = new String(arg2); |
629 | handler.sendMessage(msg); | 629 | handler.sendMessage(msg); |
630 | } | 630 | } |
631 | 631 | ||
632 | @Override | 632 | @Override |
633 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 633 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
634 | closeProgress(); | 634 | closeProgress(); |
635 | new CircleDialog.Builder((FragmentActivity) mContext) | 635 | new CircleDialog.Builder((FragmentActivity) mContext) |
636 | .setCanceledOnTouchOutside(false) | 636 | .setCanceledOnTouchOutside(false) |
637 | .setCancelable(false) | 637 | .setCancelable(false) |
638 | .setWidth(0.5f) | ||
638 | .configText(new ConfigText() { | 639 | .configText(new ConfigText() { |
639 | @Override | 640 | @Override |
640 | public void onConfig(TextParams params) { | 641 | public void onConfig(TextParams params) { |
641 | params.gravity = Gravity.CENTER; | 642 | params.gravity = Gravity.CENTER; |
642 | params.padding = new int[]{250, 50, 250, 50}; | 643 | params.padding = new int[]{50, 50, 50, 50}; |
643 | } | 644 | } |
644 | }) | 645 | }) |
645 | .setText("当前无网络,请检查网络设置") | 646 | .setText("当前无网络,请检查网络设置") |
646 | .setNegative("取消", null) | 647 | .setNegative("继续使用", null) |
647 | .setPositive("确定", new View.OnClickListener() { | 648 | .setPositive("设置网络", new View.OnClickListener() { |
648 | @Override | 649 | @Override |
649 | public void onClick(View v) { | 650 | public void onClick(View v) { |
650 | Intent intent = new Intent("/"); | 651 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
651 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); | 652 | mContext.startActivity(intent); |
652 | intent.setComponent(cm); | ||
653 | intent.setAction("android.intent.action.VIEW"); | ||
654 | ((Activity) mContext).startActivityForResult( intent , 0); | ||
655 | } | 653 | } |
656 | }) | 654 | }) |
657 | .show(); | 655 | .show(); |
658 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 656 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
659 | } | 657 | } |
660 | }); | 658 | }); |
661 | } | 659 | } |
662 | 660 | ||
663 | ///获取年级 | 661 | ///获取年级 |
664 | public void getgrade(final Context mContext, final Handler handler) { | 662 | public void getgrade(final Context mContext, final Handler handler) { |
665 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 663 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
666 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | 664 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { |
667 | @Override | 665 | @Override |
668 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 666 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
669 | Log.e("test", "年级" + new String(arg2)); | 667 | Log.e("test", "年级" + new String(arg2)); |
670 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | 668 | GradeInfo gradeInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 |
671 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); | 669 | List<GradeInfo.DataBean.ChildrenBean> gradeInfoLists = new ArrayList<GradeInfo.DataBean.ChildrenBean>(); |
672 | for (int i = 0 ;i<gradeInfo.getData().size()-2;i++) { | 670 | for (int i = 0 ;i<gradeInfo.getData().size()-2;i++) { |
673 | String name = gradeInfo.getData().get(i).getName(); | 671 | String name = gradeInfo.getData().get(i).getName(); |
674 | int id = gradeInfo.getData().get(i).getId(); | 672 | int id = gradeInfo.getData().get(i).getId(); |
675 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); | 673 | List<GradeInfo.DataBean.ChildrenBean> gradeinfoList = gradeInfo.getData().get(i).getChildren(); |
676 | for (int j = 0; j < gradeinfoList.size(); j++) { | 674 | for (int j = 0; j < gradeinfoList.size(); j++) { |
677 | String secondname = gradeinfoList.get(j).getName(); | 675 | String secondname = gradeinfoList.get(j).getName(); |
678 | int secondid = gradeinfoList.get(j).getId(); | 676 | int secondid = gradeinfoList.get(j).getId(); |
679 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); | 677 | GradeInfo.DataBean.ChildrenBean dataBean = new GradeInfo.DataBean.ChildrenBean(); |
680 | dataBean.setName(secondname); | 678 | dataBean.setName(secondname); |
681 | dataBean.setId(secondid); | 679 | dataBean.setId(secondid); |
682 | gradeInfoLists.add(dataBean); | 680 | gradeInfoLists.add(dataBean); |
683 | } | 681 | } |
684 | 682 | ||
685 | } | 683 | } |
686 | 684 | ||
687 | Message message = Message.obtain(); | 685 | Message message = Message.obtain(); |
688 | message.what = HttpCode.GRADER; | 686 | message.what = HttpCode.GRADER; |
689 | message.obj = gradeInfoLists; | 687 | message.obj = gradeInfoLists; |
690 | handler.sendMessage(message); | 688 | handler.sendMessage(message); |
691 | 689 | ||
692 | 690 | ||
693 | } | 691 | } |
694 | 692 | ||
695 | @Override | 693 | @Override |
696 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 694 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
697 | new CircleDialog.Builder((FragmentActivity) mContext) | 695 | new CircleDialog.Builder((FragmentActivity) mContext) |
698 | .setCanceledOnTouchOutside(false) | 696 | .setCanceledOnTouchOutside(false) |
699 | .setCancelable(false) | 697 | .setCancelable(false) |
700 | .setWidth(0.5f) | 698 | .setWidth(0.5f) |
701 | .configText(new ConfigText() { | 699 | .configText(new ConfigText() { |
702 | @Override | 700 | @Override |
703 | public void onConfig(TextParams params) { | 701 | public void onConfig(TextParams params) { |
704 | params.gravity = Gravity.CENTER; | 702 | params.gravity = Gravity.CENTER; |
705 | params.padding = new int[]{50, 50, 50, 50}; | 703 | params.padding = new int[]{50, 50, 50, 50}; |
706 | } | 704 | } |
707 | }) | 705 | }) |
708 | .setText("当前无网络,请检查网络设置") | 706 | .setText("当前无网络,请检查网络设置") |
709 | .setNegative("继续使用", null) | 707 | .setNegative("继续使用", null) |
710 | .setPositive("设置网络", new View.OnClickListener() { | 708 | .setPositive("设置网络", new View.OnClickListener() { |
711 | @Override | 709 | @Override |
712 | public void onClick(View v) { | 710 | public void onClick(View v) { |
713 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 711 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
714 | mContext.startActivity(intent); | 712 | mContext.startActivity(intent); |
715 | } | 713 | } |
716 | }) | 714 | }) |
717 | .show(); | 715 | .show(); |
718 | } | 716 | } |
719 | }); | 717 | }); |
720 | } | 718 | } |
721 | 719 | ||
722 | /** | 720 | /** |
723 | * 获取学校 | 721 | * 获取学校 |
724 | * @param mContext | 722 | * @param mContext |
725 | * @param regionId | 723 | * @param regionId |
726 | * @param gradeId | 724 | * @param gradeId |
727 | * @param handler | 725 | * @param handler |
728 | */ | 726 | */ |
729 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { | 727 | public void getschool(final Context mContext, int regionId, int gradeId, final Handler handler) { |
730 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 728 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
731 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | 729 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { |
732 | @Override | 730 | @Override |
733 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 731 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
734 | Log.e("test", "学校" + new String(arg2)); | 732 | Log.e("test", "学校" + new String(arg2)); |
735 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | 733 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 |
736 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); | 734 | List<SchoolInfo.DataBean> schoolInfoBeanList = schoolInfo.getData(); |
737 | Message message = Message.obtain(); | 735 | Message message = Message.obtain(); |
738 | message.what = HttpCode.SCHOOL; | 736 | message.what = HttpCode.SCHOOL; |
739 | message.obj = schoolInfoBeanList; | 737 | message.obj = schoolInfoBeanList; |
740 | handler.sendMessage(message); | 738 | handler.sendMessage(message); |
741 | 739 | ||
742 | } | 740 | } |
743 | 741 | ||
744 | @Override | 742 | @Override |
745 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 743 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
746 | new CircleDialog.Builder((FragmentActivity) mContext) | 744 | new CircleDialog.Builder((FragmentActivity) mContext) |
747 | .setCanceledOnTouchOutside(false) | 745 | .setCanceledOnTouchOutside(false) |
748 | .setCancelable(false) | 746 | .setCancelable(false) |
749 | .setWidth(0.5f) | 747 | .setWidth(0.5f) |
750 | .configText(new ConfigText() { | 748 | .configText(new ConfigText() { |
751 | @Override | 749 | @Override |
752 | public void onConfig(TextParams params) { | 750 | public void onConfig(TextParams params) { |
753 | params.gravity = Gravity.CENTER; | 751 | params.gravity = Gravity.CENTER; |
754 | params.padding = new int[]{50, 50, 50, 50}; | 752 | params.padding = new int[]{50, 50, 50, 50}; |
755 | } | 753 | } |
756 | }) | 754 | }) |
757 | .setText("当前无网络,请检查网络设置") | 755 | .setText("当前无网络,请检查网络设置") |
758 | .setNegative("继续使用", null) | 756 | .setNegative("继续使用", null) |
759 | .setPositive("设置网络", new View.OnClickListener() { | 757 | .setPositive("设置网络", new View.OnClickListener() { |
760 | @Override | 758 | @Override |
761 | public void onClick(View v) { | 759 | public void onClick(View v) { |
762 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 760 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
763 | mContext.startActivity(intent); | 761 | mContext.startActivity(intent); |
764 | } | 762 | } |
765 | }) | 763 | }) |
766 | .show(); | 764 | .show(); |
767 | } | 765 | } |
768 | }); | 766 | }); |
769 | } | 767 | } |
770 | 768 | ||
771 | 769 | ||
772 | 770 | ||
773 | /** | 771 | /** |
774 | * 获取个人信息 | 772 | * 获取个人信息 |
775 | * @param mContext | 773 | * @param mContext |
776 | * @param userId | 774 | * @param userId |
777 | * @param handler | 775 | * @param handler |
778 | */ | 776 | */ |
779 | public void getpresonalinfo(final Context mContext, long userId, final Handler handler) { | 777 | public void getpresonalinfo(final Context mContext, long userId, final Handler handler) { |
780 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", | 778 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取个人信息...", |
781 | false, true, null); | 779 | false, true, null); |
782 | HttpClient.getInstance().addHeader("Accept", "application/json"); | 780 | HttpClient.getInstance().addHeader("Accept", "application/json"); |
783 | HttpClient.getInstance().setConnectTimeout(5*1000); | 781 | HttpClient.getInstance().setConnectTimeout(5*1000); |
784 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo+ "?userId=" + userId, new AsyncHttpResponseHandler() { | 782 | HttpClient.getInstance().get(HttpUrl.getpresonalinfo+ "?userId=" + userId, new AsyncHttpResponseHandler() { |
785 | @Override | 783 | @Override |
786 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 784 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
787 | closeProgress(); | 785 | closeProgress(); |
788 | Log.e("test", "个人信息" + new String(arg2)); | 786 | Log.e("test", "个人信息" + new String(arg2)); |
789 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 | 787 | PesonalInfo pesonalInfo = GsonTool.getPerson(new String(arg2), PesonalInfo.class);//解析json数据 |
790 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); | 788 | PesonalInfo.DataBean pesonalInfoBeanList = pesonalInfo.getData(); |
791 | Message message = Message.obtain(); | 789 | Message message = Message.obtain(); |
792 | message.what = HttpCode.GETINFO; | 790 | message.what = HttpCode.GETINFO; |
793 | message.obj = pesonalInfoBeanList; | 791 | message.obj = pesonalInfoBeanList; |
794 | handler.sendMessage(message); | 792 | handler.sendMessage(message); |
795 | 793 | ||
796 | } | 794 | } |
797 | 795 | ||
798 | @Override | 796 | @Override |
799 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 797 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
800 | closeProgress(); | 798 | closeProgress(); |
801 | new CircleDialog.Builder((FragmentActivity) mContext) | 799 | new CircleDialog.Builder((FragmentActivity) mContext) |
802 | .setCanceledOnTouchOutside(false) | 800 | .setCanceledOnTouchOutside(false) |
803 | .setCancelable(false) | 801 | .setCancelable(false) |
804 | .setWidth(0.5f) | 802 | .setWidth(0.5f) |
805 | .configText(new ConfigText() { | 803 | .configText(new ConfigText() { |
806 | @Override | 804 | @Override |
807 | public void onConfig(TextParams params) { | 805 | public void onConfig(TextParams params) { |
808 | params.gravity = Gravity.CENTER; | 806 | params.gravity = Gravity.CENTER; |
809 | params.padding = new int[]{50, 50, 50, 50}; | 807 | params.padding = new int[]{50, 50, 50, 50}; |
810 | } | 808 | } |
811 | }) | 809 | }) |
812 | .setText("当前无网络,请检查网络设置") | 810 | .setText("当前无网络,请检查网络设置") |
813 | .setNegative("继续使用", null) | 811 | .setNegative("继续使用", null) |
814 | .setPositive("设置网络", new View.OnClickListener() { | 812 | .setPositive("设置网络", new View.OnClickListener() { |
815 | @Override | 813 | @Override |
816 | public void onClick(View v) { | 814 | public void onClick(View v) { |
817 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 815 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
818 | mContext.startActivity(intent); | 816 | mContext.startActivity(intent); |
819 | } | 817 | } |
820 | }) | 818 | }) |
821 | .show(); | 819 | .show(); |
822 | } | 820 | } |
823 | }); | 821 | }); |
824 | } | 822 | } |
825 | //修改个人信息 | 823 | //修改个人信息 |
826 | public void changepresonalinfo(final Context mContext, Object object) throws UnsupportedEncodingException { | 824 | public void changepresonalinfo(final Context mContext, Object object) throws UnsupportedEncodingException { |
827 | Gson gson = new Gson(); | 825 | Gson gson = new Gson(); |
828 | String jsonObject = gson.toJson(object); | 826 | String jsonObject = gson.toJson(object); |
829 | Log.e("test", "onSuccess" + jsonObject); | 827 | Log.e("test", "onSuccess" + jsonObject); |
830 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", | 828 | mProgress = DialogPermission.showProgress(mContext, null, "正在保存个人信息...", |
831 | false, true, null); | 829 | false, true, null); |
832 | ByteArrayEntity entity = null; | 830 | ByteArrayEntity entity = null; |
833 | entity = new ByteArrayEntity(jsonObject.getBytes("UTF-8")); | 831 | entity = new ByteArrayEntity(jsonObject.getBytes("UTF-8")); |
834 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 832 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
835 | 833 | ||
836 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 834 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
837 | HttpClient.getInstance().put(mContext, HttpUrl.changepresonalinfo, entity, "application/json", new JsonHttpResponseHandler() { | 835 | HttpClient.getInstance().put(mContext, HttpUrl.changepresonalinfo, entity, "application/json", new JsonHttpResponseHandler() { |
838 | @Override | 836 | @Override |
839 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 837 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
840 | super.onSuccess(statusCode, headers, response); | 838 | super.onSuccess(statusCode, headers, response); |
841 | closeProgress(); | 839 | closeProgress(); |
842 | String status = response.optString("status"); | 840 | String status = response.optString("status"); |
843 | if (status.equals("1")) { | 841 | if (status.equals("1")) { |
844 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); | 842 | Toast.makeText(mContext, "个人信息保存成功", Toast.LENGTH_LONG).show(); |
845 | ((Activity) mContext).finish(); | 843 | ((Activity) mContext).finish(); |
846 | } | 844 | } |
847 | Log.e("test", "onSuccess" + response); | 845 | Log.e("test", "onSuccess" + response); |
848 | 846 | ||
849 | } | 847 | } |
850 | 848 | ||
851 | @Override | 849 | @Override |
852 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 850 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
853 | super.onFailure(statusCode, headers, throwable, errorResponse); | 851 | super.onFailure(statusCode, headers, throwable, errorResponse); |
854 | closeProgress(); | 852 | closeProgress(); |
855 | Log.e("test", "onFailure" + errorResponse); | 853 | Log.e("test", "onFailure" + errorResponse); |
856 | new CircleDialog.Builder((FragmentActivity) mContext) | 854 | new CircleDialog.Builder((FragmentActivity) mContext) |
857 | .setCanceledOnTouchOutside(false) | 855 | .setCanceledOnTouchOutside(false) |
858 | .setCancelable(false) | 856 | .setCancelable(false) |
859 | .setWidth(0.5f) | 857 | .setWidth(0.5f) |
860 | .configText(new ConfigText() { | 858 | .configText(new ConfigText() { |
861 | @Override | 859 | @Override |
862 | public void onConfig(TextParams params) { | 860 | public void onConfig(TextParams params) { |
863 | params.gravity = Gravity.CENTER; | 861 | params.gravity = Gravity.CENTER; |
864 | params.padding = new int[]{50, 50, 50, 50}; | 862 | params.padding = new int[]{50, 50, 50, 50}; |
865 | } | 863 | } |
866 | }) | 864 | }) |
867 | .setText("当前无网络,请检查网络设置") | 865 | .setText("当前无网络,请检查网络设置") |
868 | .setNegative("继续使用", null) | 866 | .setNegative("继续使用", null) |
869 | .setPositive("设置网络", new View.OnClickListener() { | 867 | .setPositive("设置网络", new View.OnClickListener() { |
870 | @Override | 868 | @Override |
871 | public void onClick(View v) { | 869 | public void onClick(View v) { |
872 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 870 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
873 | mContext.startActivity(intent); | 871 | mContext.startActivity(intent); |
874 | } | 872 | } |
875 | }) | 873 | }) |
876 | .show(); | 874 | .show(); |
877 | } | 875 | } |
878 | 876 | ||
879 | }); | 877 | }); |
880 | } | 878 | } |
881 | //修改个性签名 | 879 | //修改个性签名 |
882 | public void changsignature(final Context mContext, long userId, final String signature) { | 880 | public void changsignature(final Context mContext, long userId, final String signature) { |
883 | RequestParams params = new RequestParams(); | 881 | RequestParams params = new RequestParams(); |
884 | params.put("userId", userId); | 882 | params.put("userId", userId); |
885 | params.put("signature", signature); | 883 | params.put("signature", signature); |
886 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 884 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
887 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { | 885 | HttpClient.getInstance().post(HttpUrl.signature, params, new AsyncHttpResponseHandler() { |
888 | @Override | 886 | @Override |
889 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 887 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
890 | try { | 888 | try { |
891 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 889 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
892 | String status = jsonObject.optString("status"); | 890 | String status = jsonObject.optString("status"); |
893 | if (status.equals("1")) { | 891 | if (status.equals("1")) { |
894 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); | 892 | Toast.makeText(mContext, "个性签名修改成功", Toast.LENGTH_LONG).show(); |
895 | } | 893 | } |
896 | } catch (JSONException e) { | 894 | } catch (JSONException e) { |
897 | e.printStackTrace(); | 895 | e.printStackTrace(); |
898 | } | 896 | } |
899 | } | 897 | } |
900 | 898 | ||
901 | @Override | 899 | @Override |
902 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 900 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
903 | Log.e("test", "onFailure" + new String(bytes)); | 901 | Log.e("test", "onFailure" + new String(bytes)); |
904 | new CircleDialog.Builder((FragmentActivity) mContext) | 902 | new CircleDialog.Builder((FragmentActivity) mContext) |
905 | .setCanceledOnTouchOutside(false) | 903 | .setCanceledOnTouchOutside(false) |
906 | .setCancelable(false) | 904 | .setCancelable(false) |
907 | .setWidth(0.5f) | 905 | .setWidth(0.5f) |
908 | .configText(new ConfigText() { | 906 | .configText(new ConfigText() { |
909 | @Override | 907 | @Override |
910 | public void onConfig(TextParams params) { | 908 | public void onConfig(TextParams params) { |
911 | params.gravity = Gravity.CENTER; | 909 | params.gravity = Gravity.CENTER; |
912 | params.padding = new int[]{50, 50, 50, 50}; | 910 | params.padding = new int[]{50, 50, 50, 50}; |
913 | } | 911 | } |
914 | }) | 912 | }) |
915 | .setText("当前无网络,请检查网络设置") | 913 | .setText("当前无网络,请检查网络设置") |
916 | .setNegative("继续使用", null) | 914 | .setNegative("继续使用", null) |
917 | .setPositive("设置网络", new View.OnClickListener() { | 915 | .setPositive("设置网络", new View.OnClickListener() { |
918 | @Override | 916 | @Override |
919 | public void onClick(View v) { | 917 | public void onClick(View v) { |
920 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 918 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
921 | mContext.startActivity(intent); | 919 | mContext.startActivity(intent); |
922 | } | 920 | } |
923 | }) | 921 | }) |
924 | .show(); | 922 | .show(); |
925 | } | 923 | } |
926 | }); | 924 | }); |
927 | } | 925 | } |
928 | 926 | ||
929 | /** | 927 | /** |
930 | * 获取个性签名 | 928 | * 获取个性签名 |
931 | * @param mContext | 929 | * @param mContext |
932 | * @param userId | 930 | * @param userId |
933 | * @param handler | 931 | * @param handler |
934 | */ | 932 | */ |
935 | public void getsignatures(final Context mContext,long userId , final Handler handler) { | 933 | public void getsignatures(final Context mContext,long userId , final Handler handler) { |
936 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 934 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
937 | HttpClient.getInstance().get(HttpUrl.getsignature+"?userId="+userId, new AsyncHttpResponseHandler() { | 935 | HttpClient.getInstance().get(HttpUrl.getsignature+"?userId="+userId, new AsyncHttpResponseHandler() { |
938 | @Override | 936 | @Override |
939 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 937 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
940 | Log.e("test", "个性签名" + new String(arg2)); | 938 | Log.e("test", "个性签名" + new String(arg2)); |
941 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 | 939 | SignInfo signInfo = GsonTool.getPerson(new String(arg2), SignInfo.class);//解析json数据 |
942 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); | 940 | SignInfo.DataBean signInfoBeanList = signInfo.getData(); |
943 | Message message = Message.obtain(); | 941 | Message message = Message.obtain(); |
944 | message.what = HttpCode.SIGN; | 942 | message.what = HttpCode.SIGN; |
945 | message.obj = signInfoBeanList; | 943 | message.obj = signInfoBeanList; |
946 | handler.sendMessage(message); | 944 | handler.sendMessage(message); |
947 | 945 | ||
948 | } | 946 | } |
949 | 947 | ||
950 | @Override | 948 | @Override |
951 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 949 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
952 | Log.e("test", "失败原因" + arg3); | 950 | Log.e("test", "失败原因" + arg3); |
953 | new CircleDialog.Builder((FragmentActivity) mContext) | 951 | new CircleDialog.Builder((FragmentActivity) mContext) |
954 | .setCanceledOnTouchOutside(false) | 952 | .setCanceledOnTouchOutside(false) |
955 | .setCancelable(false) | 953 | .setCancelable(false) |
956 | .setWidth(0.5f) | 954 | .setWidth(0.5f) |
957 | .configText(new ConfigText() { | 955 | .configText(new ConfigText() { |
958 | @Override | 956 | @Override |
959 | public void onConfig(TextParams params) { | 957 | public void onConfig(TextParams params) { |
960 | params.gravity = Gravity.CENTER; | 958 | params.gravity = Gravity.CENTER; |
961 | params.padding = new int[]{50, 50, 50, 50}; | 959 | params.padding = new int[]{50, 50, 50, 50}; |
962 | } | 960 | } |
963 | }) | 961 | }) |
964 | .setText("当前无网络,请检查网络设置") | 962 | .setText("当前无网络,请检查网络设置") |
965 | .setNegative("继续使用", null) | 963 | .setNegative("继续使用", null) |
966 | .setPositive("设置网络", new View.OnClickListener() { | 964 | .setPositive("设置网络", new View.OnClickListener() { |
967 | @Override | 965 | @Override |
968 | public void onClick(View v) { | 966 | public void onClick(View v) { |
969 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 967 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
970 | mContext.startActivity(intent); | 968 | mContext.startActivity(intent); |
971 | } | 969 | } |
972 | }) | 970 | }) |
973 | .show(); | 971 | .show(); |
974 | } | 972 | } |
975 | }); | 973 | }); |
976 | } | 974 | } |
977 | 975 | ||
978 | /** | 976 | /** |
979 | * 用户反馈 | 977 | * 用户反馈 |
980 | * @param mContext | 978 | * @param mContext |
981 | * @param object | 979 | * @param object |
982 | * @throws UnsupportedEncodingException | 980 | * @throws UnsupportedEncodingException |
983 | */ | 981 | */ |
984 | public void feedback(final Context mContext, Object object) throws UnsupportedEncodingException { | 982 | public void feedback(final Context mContext, Object object) throws UnsupportedEncodingException { |
985 | Gson gson = new Gson(); | 983 | Gson gson = new Gson(); |
986 | String jsonObject = gson.toJson(object); | 984 | String jsonObject = gson.toJson(object); |
987 | Log.e("test", "onSuccess" + jsonObject); | 985 | Log.e("test", "onSuccess" + jsonObject); |
988 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", | 986 | mProgress = DialogPermission.showProgress(mContext, null, "正在提交反馈内容...", |
989 | false, true, null); | 987 | false, true, null); |
990 | ByteArrayEntity entity = null; | 988 | ByteArrayEntity entity = null; |
991 | entity = new ByteArrayEntity(jsonObject.getBytes("UTF-8")); | 989 | entity = new ByteArrayEntity(jsonObject.getBytes("UTF-8")); |
992 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 990 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
993 | 991 | ||
994 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 992 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
995 | HttpClient.getInstance().post(mContext, HttpUrl.feedbackURL, entity, "application/json", new JsonHttpResponseHandler() { | 993 | HttpClient.getInstance().post(mContext, HttpUrl.feedbackURL, entity, "application/json", new JsonHttpResponseHandler() { |
996 | @Override | 994 | @Override |
997 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 995 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
998 | super.onSuccess(statusCode, headers, response); | 996 | super.onSuccess(statusCode, headers, response); |
999 | closeProgress(); | 997 | closeProgress(); |
1000 | String status = response.optString("status"); | 998 | String status = response.optString("status"); |
1001 | if (status.equals("1")) { | 999 | if (status.equals("1")) { |
1002 | Toast.makeText(mContext, "反馈成功,我们会尽快处理", Toast.LENGTH_LONG).show(); | 1000 | Toast.makeText(mContext, "反馈成功,我们会尽快处理", Toast.LENGTH_LONG).show(); |
1003 | ((Activity) mContext).finish(); | 1001 | ((Activity) mContext).finish(); |
1004 | } | 1002 | } |
1005 | Log.e("test", "onSuccess" + response); | 1003 | Log.e("test", "onSuccess" + response); |
1006 | 1004 | ||
1007 | } | 1005 | } |
1008 | 1006 | ||
1009 | @Override | 1007 | @Override |
1010 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 1008 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
1011 | super.onFailure(statusCode, headers, throwable, errorResponse); | 1009 | super.onFailure(statusCode, headers, throwable, errorResponse); |
1012 | closeProgress(); | 1010 | closeProgress(); |
1013 | Log.e("test", "onFailure" + errorResponse); | 1011 | Log.e("test", "onFailure" + errorResponse); |
1014 | new CircleDialog.Builder((FragmentActivity) mContext) | 1012 | new CircleDialog.Builder((FragmentActivity) mContext) |
1015 | .setCanceledOnTouchOutside(false) | 1013 | .setCanceledOnTouchOutside(false) |
1016 | .setCancelable(false) | 1014 | .setCancelable(false) |
1017 | .setWidth(0.5f) | 1015 | .setWidth(0.5f) |
1018 | .configText(new ConfigText() { | 1016 | .configText(new ConfigText() { |
1019 | @Override | 1017 | @Override |
1020 | public void onConfig(TextParams params) { | 1018 | public void onConfig(TextParams params) { |
1021 | params.gravity = Gravity.CENTER; | 1019 | params.gravity = Gravity.CENTER; |
1022 | params.padding = new int[]{50, 50, 50, 50}; | 1020 | params.padding = new int[]{50, 50, 50, 50}; |
1023 | } | 1021 | } |
1024 | }) | 1022 | }) |
1025 | .setText("当前无网络,请检查网络设置") | 1023 | .setText("当前无网络,请检查网络设置") |
1026 | .setNegative("继续使用", null) | 1024 | .setNegative("继续使用", null) |
1027 | .setPositive("设置网络", new View.OnClickListener() { | 1025 | .setPositive("设置网络", new View.OnClickListener() { |
1028 | @Override | 1026 | @Override |
1029 | public void onClick(View v) { | 1027 | public void onClick(View v) { |
1030 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1028 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1031 | mContext.startActivity(intent); | 1029 | mContext.startActivity(intent); |
1032 | } | 1030 | } |
1033 | }) | 1031 | }) |
1034 | .show(); | 1032 | .show(); |
1035 | } | 1033 | } |
1036 | 1034 | ||
1037 | }); | 1035 | }); |
1038 | } | 1036 | } |
1039 | 1037 | ||
1040 | /** | 1038 | /** |
1041 | * 查询子账户信息 | 1039 | * 查询子账户信息 |
1042 | * @param mContext | 1040 | * @param mContext |
1043 | * @param userId | 1041 | * @param userId |
1044 | * @param handler | 1042 | * @param handler |
1045 | */ | 1043 | */ |
1046 | public void getchildAccountinfo(final Context mContext, long userId , final Handler handler) { | 1044 | public void getchildAccountinfo(final Context mContext, long userId , final Handler handler) { |
1047 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", | 1045 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取信息...", |
1048 | false, true, null); | 1046 | false, true, null); |
1049 | HttpClient.getInstance().setTimeout(5 * 1000); | 1047 | HttpClient.getInstance().setTimeout(5 * 1000); |
1050 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1048 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1051 | HttpClient.getInstance().get(HttpUrl.childUserURL+ "?userId=" + userId , new AsyncHttpResponseHandler() { | 1049 | HttpClient.getInstance().get(HttpUrl.childUserURL+ "?userId=" + userId , new AsyncHttpResponseHandler() { |
1052 | @Override | 1050 | @Override |
1053 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1051 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1054 | closeProgress(); | 1052 | closeProgress(); |
1055 | Log.e("test", "子账户信息" + new String(arg2)); | 1053 | Log.e("test", "子账户信息" + new String(arg2)); |
1056 | try { | 1054 | try { |
1057 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1055 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1058 | int status = jsonObject.optInt("status"); | 1056 | int status = jsonObject.optInt("status"); |
1059 | if (status ==1000){ | 1057 | if (status ==1000){ |
1060 | AlertUtils.showToast(mContext,"你好,你还未添加子账号,子账号为空!"); | 1058 | AlertUtils.showToast(mContext,"你好,你还未添加子账号,子账号为空!"); |
1061 | }else { | 1059 | }else { |
1062 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 | 1060 | ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据 |
1063 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); | 1061 | List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData(); |
1064 | Message msg = Message.obtain(); | 1062 | Message msg = Message.obtain(); |
1065 | msg.what = HttpCode.CHILDS_SUCESS; | 1063 | msg.what = HttpCode.CHILDS_SUCESS; |
1066 | msg.obj = schoolInfoBeanList; | 1064 | msg.obj = schoolInfoBeanList; |
1067 | handler.sendMessage(msg); | 1065 | handler.sendMessage(msg); |
1068 | 1066 | ||
1069 | } | 1067 | } |
1070 | } catch (JSONException e) { | 1068 | } catch (JSONException e) { |
1071 | e.printStackTrace(); | 1069 | e.printStackTrace(); |
1072 | } | 1070 | } |
1073 | 1071 | ||
1074 | } | 1072 | } |
1075 | 1073 | ||
1076 | @Override | 1074 | @Override |
1077 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1075 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1078 | closeProgress(); | 1076 | closeProgress(); |
1079 | Log.e("test", "错误信息" + new String(arg2)); | 1077 | Log.e("test", "错误信息" + new String(arg2)); |
1080 | new CircleDialog.Builder((FragmentActivity) mContext) | 1078 | new CircleDialog.Builder((FragmentActivity) mContext) |
1081 | .setCanceledOnTouchOutside(false) | 1079 | .setCanceledOnTouchOutside(false) |
1082 | .setCancelable(false) | 1080 | .setCancelable(false) |
1083 | .setWidth(0.5f) | 1081 | .setWidth(0.5f) |
1084 | .configText(new ConfigText() { | 1082 | .configText(new ConfigText() { |
1085 | @Override | 1083 | @Override |
1086 | public void onConfig(TextParams params) { | 1084 | public void onConfig(TextParams params) { |
1087 | params.gravity = Gravity.CENTER; | 1085 | params.gravity = Gravity.CENTER; |
1088 | params.padding = new int[]{50, 50, 50, 50}; | 1086 | params.padding = new int[]{50, 50, 50, 50}; |
1089 | } | 1087 | } |
1090 | }) | 1088 | }) |
1091 | .setText("当前无网络,请检查网络设置") | 1089 | .setText("当前无网络,请检查网络设置") |
1092 | .setNegative("继续使用", null) | 1090 | .setNegative("继续使用", null) |
1093 | .setPositive("设置网络", new View.OnClickListener() { | 1091 | .setPositive("设置网络", new View.OnClickListener() { |
1094 | @Override | 1092 | @Override |
1095 | public void onClick(View v) { | 1093 | public void onClick(View v) { |
1096 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1094 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1097 | mContext.startActivity(intent); | 1095 | mContext.startActivity(intent); |
1098 | } | 1096 | } |
1099 | }) | 1097 | }) |
1100 | .show(); | 1098 | .show(); |
1101 | } | 1099 | } |
1102 | }); | 1100 | }); |
1103 | 1101 | ||
1104 | } | 1102 | } |
1105 | /** | 1103 | /** |
1106 | * 删除子账户信息 | 1104 | * 删除子账户信息 |
1107 | * @param mContext | 1105 | * @param mContext |
1108 | * @param subAccountId | 1106 | * @param subAccountId |
1109 | * | 1107 | * |
1110 | */ | 1108 | */ |
1111 | public void deletechildAccountinfo(final Context mContext, long subAccountId ) { | 1109 | public void deletechildAccountinfo(final Context mContext, long subAccountId ) { |
1112 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", | 1110 | mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...", |
1113 | false, true, null); | 1111 | false, true, null); |
1114 | HttpClient.getInstance().setTimeout(5 * 1000); | 1112 | HttpClient.getInstance().setTimeout(5 * 1000); |
1115 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1113 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1116 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL+ "?subAccountId=" + subAccountId , new AsyncHttpResponseHandler() { | 1114 | HttpClient.getInstance().get(HttpUrl.deletechildUserURL+ "?subAccountId=" + subAccountId , new AsyncHttpResponseHandler() { |
1117 | @Override | 1115 | @Override |
1118 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1116 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1119 | closeProgress(); | 1117 | closeProgress(); |
1120 | Log.e("test", "子账户信息" + new String(arg2)); | 1118 | Log.e("test", "子账户信息" + new String(arg2)); |
1121 | try { | 1119 | try { |
1122 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1120 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1123 | int status = jsonObject.optInt("status"); | 1121 | int status = jsonObject.optInt("status"); |
1124 | if (status ==1){ | 1122 | if (status ==1){ |
1125 | AlertUtils.showToast(mContext,"子账号删除成功!"); | 1123 | AlertUtils.showToast(mContext,"子账号删除成功!"); |
1126 | }else { | 1124 | }else { |
1127 | AlertUtils.showToast(mContext,"你好,子账号删除失败!"); | 1125 | AlertUtils.showToast(mContext,"你好,子账号删除失败!"); |
1128 | 1126 | ||
1129 | } | 1127 | } |
1130 | } catch (JSONException e) { | 1128 | } catch (JSONException e) { |
1131 | e.printStackTrace(); | 1129 | e.printStackTrace(); |
1132 | } | 1130 | } |
1133 | 1131 | ||
1134 | } | 1132 | } |
1135 | 1133 | ||
1136 | @Override | 1134 | @Override |
1137 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1135 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1138 | closeProgress(); | 1136 | closeProgress(); |
1139 | Log.e("test", "错误信息" + new String(arg2)); | 1137 | Log.e("test", "错误信息" + new String(arg2)); |
1140 | new CircleDialog.Builder((FragmentActivity) mContext) | 1138 | new CircleDialog.Builder((FragmentActivity) mContext) |
1141 | .setCanceledOnTouchOutside(false) | 1139 | .setCanceledOnTouchOutside(false) |
1142 | .setCancelable(false) | 1140 | .setCancelable(false) |
1143 | .setWidth(0.5f) | 1141 | .setWidth(0.5f) |
1144 | .configText(new ConfigText() { | 1142 | .configText(new ConfigText() { |
1145 | @Override | 1143 | @Override |
1146 | public void onConfig(TextParams params) { | 1144 | public void onConfig(TextParams params) { |
1147 | params.gravity = Gravity.CENTER; | 1145 | params.gravity = Gravity.CENTER; |
1148 | params.padding = new int[]{50, 50, 50, 50}; | 1146 | params.padding = new int[]{50, 50, 50, 50}; |
1149 | } | 1147 | } |
1150 | }) | 1148 | }) |
1151 | .setText("当前无网络,请检查网络设置") | 1149 | .setText("当前无网络,请检查网络设置") |
1152 | .setNegative("继续使用", null) | 1150 | .setNegative("继续使用", null) |
1153 | .setPositive("设置网络", new View.OnClickListener() { | 1151 | .setPositive("设置网络", new View.OnClickListener() { |
1154 | @Override | 1152 | @Override |
1155 | public void onClick(View v) { | 1153 | public void onClick(View v) { |
1156 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1154 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1157 | mContext.startActivity(intent); | 1155 | mContext.startActivity(intent); |
1158 | } | 1156 | } |
1159 | }) | 1157 | }) |
1160 | .show(); | 1158 | .show(); |
1161 | } | 1159 | } |
1162 | }); | 1160 | }); |
1163 | 1161 | ||
1164 | } | 1162 | } |
1165 | /** | 1163 | /** |
1166 | * 添加子账户信息 | 1164 | * 添加子账户信息 |
1167 | * | 1165 | * |
1168 | */ | 1166 | */ |
1169 | public void addchildAccountinfo(final Context mContext, long parentId,String image, | 1167 | public void addchildAccountinfo(final Context mContext, long parentId,String image, |
1170 | String name,String grade,String school,String region) { | 1168 | String name,String grade,String school,String region) { |
1171 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", | 1169 | mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...", |
1172 | false, true, null); | 1170 | false, true, null); |
1173 | RequestParams params = new RequestParams(); | 1171 | RequestParams params = new RequestParams(); |
1174 | 1172 | ||
1175 | params.put(HttpKey.PARENTID, parentId); | 1173 | params.put(HttpKey.PARENTID, parentId); |
1176 | params.put(HttpKey.IMAGE, image); | 1174 | params.put(HttpKey.IMAGE, image); |
1177 | params.put(HttpKey.NAME, name); | 1175 | params.put(HttpKey.NAME, name); |
1178 | params.put(HttpKey.GRADE, grade); | 1176 | params.put(HttpKey.GRADE, grade); |
1179 | params.put(HttpKey.SCHOOL, school); | 1177 | params.put(HttpKey.SCHOOL, school); |
1180 | params.put(HttpKey.REGION, region); | 1178 | params.put(HttpKey.REGION, region); |
1181 | 1179 | ||
1182 | 1180 | ||
1183 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 1181 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
1184 | HttpClient.getInstance().setTimeout(5 * 1000); | 1182 | HttpClient.getInstance().setTimeout(5 * 1000); |
1185 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1183 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1186 | HttpClient.getInstance().post(HttpUrl.addchildUserURL ,params, new AsyncHttpResponseHandler() { | 1184 | HttpClient.getInstance().post(HttpUrl.addchildUserURL ,params, new AsyncHttpResponseHandler() { |
1187 | @Override | 1185 | @Override |
1188 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1186 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1189 | closeProgress(); | 1187 | closeProgress(); |
1190 | 1188 | ||
1191 | Log.e("test", "子账户信息" + new String(arg2)); | 1189 | Log.e("test", "子账户信息" + new String(arg2)); |
1192 | try { | 1190 | try { |
1193 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1191 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1194 | int status = jsonObject.optInt("status"); | 1192 | int status = jsonObject.optInt("status"); |
1195 | if (status ==1){ | 1193 | if (status ==1){ |
1196 | AlertUtils.showToast(mContext,"子账号添加成功!"); | 1194 | AlertUtils.showToast(mContext,"子账号添加成功!"); |
1197 | ((Activity) mContext).finish(); | 1195 | ((Activity) mContext).finish(); |
1198 | }else { | 1196 | }else { |
1199 | AlertUtils.showToast(mContext,"你好,子账号添加失败!"); | 1197 | AlertUtils.showToast(mContext,"你好,子账号添加失败!"); |
1200 | 1198 | ||
1201 | } | 1199 | } |
1202 | } catch (JSONException e) { | 1200 | } catch (JSONException e) { |
1203 | e.printStackTrace(); | 1201 | e.printStackTrace(); |
1204 | } | 1202 | } |
1205 | 1203 | ||
1206 | } | 1204 | } |
1207 | 1205 | ||
1208 | @Override | 1206 | @Override |
1209 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1207 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1210 | closeProgress(); | 1208 | closeProgress(); |
1211 | Log.e("test", "错误信息" + new String(arg2)); | 1209 | Log.e("test", "错误信息" + new String(arg2)); |
1212 | new CircleDialog.Builder((FragmentActivity) mContext) | 1210 | new CircleDialog.Builder((FragmentActivity) mContext) |
1213 | .setCanceledOnTouchOutside(false) | 1211 | .setCanceledOnTouchOutside(false) |
1214 | .setCancelable(false) | 1212 | .setCancelable(false) |
1215 | .setWidth(0.5f) | 1213 | .setWidth(0.5f) |
1216 | .configText(new ConfigText() { | 1214 | .configText(new ConfigText() { |
1217 | @Override | 1215 | @Override |
1218 | public void onConfig(TextParams params) { | 1216 | public void onConfig(TextParams params) { |
1219 | params.gravity = Gravity.CENTER; | 1217 | params.gravity = Gravity.CENTER; |
1220 | params.padding = new int[]{50, 50, 50, 50}; | 1218 | params.padding = new int[]{50, 50, 50, 50}; |
1221 | } | 1219 | } |
1222 | }) | 1220 | }) |
1223 | .setText("当前无网络,请检查网络设置") | 1221 | .setText("当前无网络,请检查网络设置") |
1224 | .setNegative("继续使用", null) | 1222 | .setNegative("继续使用", null) |
1225 | .setPositive("设置网络", new View.OnClickListener() { | 1223 | .setPositive("设置网络", new View.OnClickListener() { |
1226 | @Override | 1224 | @Override |
1227 | public void onClick(View v) { | 1225 | public void onClick(View v) { |
1228 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1226 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1229 | mContext.startActivity(intent); | 1227 | mContext.startActivity(intent); |
1230 | } | 1228 | } |
1231 | }) | 1229 | }) |
1232 | .show(); | 1230 | .show(); |
1233 | } | 1231 | } |
1234 | }); | 1232 | }); |
1235 | 1233 | ||
1236 | } | 1234 | } |
1237 | 1235 | ||
1238 | /** | 1236 | /** |
1239 | * 切换子账户信息 | 1237 | * 切换子账户信息 |
1240 | * @param mContext | 1238 | * @param mContext |
1241 | * @param subAccountId | 1239 | * @param subAccountId |
1242 | * | 1240 | * |
1243 | */ | 1241 | */ |
1244 | public void changechildAccountinfo(final Context mContext, long subAccountId ,long userId) { | 1242 | public void changechildAccountinfo(final Context mContext, long subAccountId ,long userId) { |
1245 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | 1243 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", |
1246 | false, true, null); | 1244 | false, true, null); |
1247 | HttpClient.getInstance().setTimeout(5 * 1000); | 1245 | HttpClient.getInstance().setTimeout(5 * 1000); |
1248 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1246 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1249 | HttpClient.getInstance().get(HttpUrl.changechildUserURL+ "?subAccountId=" + subAccountId+"&userId="+ userId, new AsyncHttpResponseHandler() { | 1247 | HttpClient.getInstance().get(HttpUrl.changechildUserURL+ "?subAccountId=" + subAccountId+"&userId="+ userId, new AsyncHttpResponseHandler() { |
1250 | @Override | 1248 | @Override |
1251 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1249 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1252 | closeProgress(); | 1250 | closeProgress(); |
1253 | Log.e("test", "子账户信息" + new String(arg2)); | 1251 | Log.e("test", "子账户信息" + new String(arg2)); |
1254 | try { | 1252 | try { |
1255 | JSONObject jsonObject = new JSONObject(new String(arg2)); | 1253 | JSONObject jsonObject = new JSONObject(new String(arg2)); |
1256 | int status = jsonObject.optInt("status"); | 1254 | int status = jsonObject.optInt("status"); |
1257 | if (status ==1){ | 1255 | if (status ==1){ |
1258 | AlertUtils.showToast(mContext,"子账号切换成功!"); | 1256 | AlertUtils.showToast(mContext,"子账号切换成功!"); |
1259 | 1257 | ||
1260 | }else { | 1258 | }else { |
1261 | AlertUtils.showToast(mContext,"你好,子账号切换失败!"); | 1259 | AlertUtils.showToast(mContext,"你好,子账号切换失败!"); |
1262 | 1260 | ||
1263 | } | 1261 | } |
1264 | } catch (JSONException e) { | 1262 | } catch (JSONException e) { |
1265 | e.printStackTrace(); | 1263 | e.printStackTrace(); |
1266 | } | 1264 | } |
1267 | 1265 | ||
1268 | } | 1266 | } |
1269 | 1267 | ||
1270 | @Override | 1268 | @Override |
1271 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1269 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1272 | closeProgress(); | 1270 | closeProgress(); |
1273 | Log.e("test", "错误信息" + new String(arg2)); | 1271 | Log.e("test", "错误信息" + new String(arg2)); |
1274 | new CircleDialog.Builder((FragmentActivity) mContext) | 1272 | new CircleDialog.Builder((FragmentActivity) mContext) |
1275 | .setCanceledOnTouchOutside(false) | 1273 | .setCanceledOnTouchOutside(false) |
1276 | .setCancelable(false) | 1274 | .setCancelable(false) |
1277 | .setWidth(0.5f) | 1275 | .setWidth(0.5f) |
1278 | .configText(new ConfigText() { | 1276 | .configText(new ConfigText() { |
1279 | @Override | 1277 | @Override |
1280 | public void onConfig(TextParams params) { | 1278 | public void onConfig(TextParams params) { |
1281 | params.gravity = Gravity.CENTER; | 1279 | params.gravity = Gravity.CENTER; |
1282 | params.padding = new int[]{50, 50, 50, 50}; | 1280 | params.padding = new int[]{50, 50, 50, 50}; |
1283 | } | 1281 | } |
1284 | }) | 1282 | }) |
1285 | .setText("当前无网络,请检查网络设置") | 1283 | .setText("当前无网络,请检查网络设置") |
1286 | .setNegative("继续使用", null) | 1284 | .setNegative("继续使用", null) |
1287 | .setPositive("设置网络", new View.OnClickListener() { | 1285 | .setPositive("设置网络", new View.OnClickListener() { |
1288 | @Override | 1286 | @Override |
1289 | public void onClick(View v) { | 1287 | public void onClick(View v) { |
1290 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1288 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1291 | mContext.startActivity(intent); | 1289 | mContext.startActivity(intent); |
1292 | } | 1290 | } |
1293 | }) | 1291 | }) |
1294 | .show(); | 1292 | .show(); |
1295 | } | 1293 | } |
1296 | }); | 1294 | }); |
1297 | 1295 | ||
1298 | } | 1296 | } |
1297 | /** | ||
1298 | * 系统升级 | ||
1299 | * @param mContext | ||
1300 | * @param pid | ||
1301 | * appName | ||
1302 | * | ||
1303 | */ | ||
1304 | public void updateAPP(final Context mContext, String pid , String appName, final Handler handler) { | ||
1305 | mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...", | ||
1306 | false, true, null); | ||
1307 | HttpClient.getInstance().setTimeout(5 * 1000); | ||
1308 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||
1309 | HttpClient.getInstance().get(HttpUrl.updateappURL+ "?pid=" + pid+"&appName="+ appName, new AsyncHttpResponseHandler() { | ||
1310 | @Override | ||
1311 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
1312 | closeProgress(); | ||
1313 | Log.e("test", "版本升级信息" + new String(arg2)); | ||
1314 | AppVersion appVersion = GsonTool.getPerson(new String(arg2), AppVersion.class);//解析json数据 | ||
1315 | Message msg = Message.obtain(); | ||
1316 | msg.what = HttpCode.APPUPDATE_SUCESS; | ||
1317 | msg.obj = appVersion; | ||
1318 | handler.sendMessage(msg); | ||
1319 | |||
1320 | |||
1321 | } | ||
1322 | |||
1323 | @Override | ||
1324 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
1325 | closeProgress(); | ||
1326 | Log.e("test", "错误信息" + new String(arg2)); | ||
1327 | new CircleDialog.Builder((FragmentActivity) mContext) | ||
1328 | .setCanceledOnTouchOutside(false) | ||
1329 | .setCancelable(false) | ||
1330 | .setWidth(0.5f) | ||
1331 | .configText(new ConfigText() { | ||
1332 | @Override | ||
1333 | public void onConfig(TextParams params) { | ||
1334 | params.gravity = Gravity.CENTER; | ||
1335 | params.padding = new int[]{50, 50, 50, 50}; | ||
1336 | } | ||
1337 | }) | ||
1338 | .setText("当前无网络,请检查网络设置") | ||
1339 | .setNegative("继续使用", null) | ||
1340 | .setPositive("设置网络", new View.OnClickListener() { | ||
1341 | @Override | ||
1342 | public void onClick(View v) { | ||
1343 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
1344 | mContext.startActivity(intent); | ||
1345 | } | ||
1346 | }) | ||
1347 | .show(); | ||
1348 | } | ||
1349 | }); | ||
1350 | |||
1351 | } | ||
1299 | 1352 | ||
1300 | 1353 | ||
1301 | 1354 | ||
1302 | 1355 | ||
1303 | 1356 | ||
1304 | ///省级接口 | 1357 | ///省级接口 |
1305 | public void provices(final Context mContext, final Handler handler) { | 1358 | public void provices(final Context mContext, final Handler handler) { |
1306 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1359 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1307 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 1360 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
1308 | @Override | 1361 | @Override |
1309 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1362 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1310 | Log.e("test", "省" + new String(arg2)); | 1363 | Log.e("test", "省" + new String(arg2)); |
1311 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 1364 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
1312 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 1365 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
1313 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); | 1366 | List<ProvinceInfo.ProvincesBean> provincesBeanList = provinceInfo.getProvinces(); |
1314 | Message message = Message.obtain(); | 1367 | Message message = Message.obtain(); |
1315 | message.what = HttpCode.PROVICES; | 1368 | message.what = HttpCode.PROVICES; |
1316 | message.obj = provincesBeanList; | 1369 | message.obj = provincesBeanList; |
1317 | handler.sendMessage(message); | 1370 | handler.sendMessage(message); |
1318 | 1371 | ||
1319 | } | 1372 | } |
1320 | 1373 | ||
1321 | @Override | 1374 | @Override |
1322 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1375 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1323 | new CircleDialog.Builder((FragmentActivity) mContext) | 1376 | new CircleDialog.Builder((FragmentActivity) mContext) |
1324 | .setCanceledOnTouchOutside(false) | 1377 | .setCanceledOnTouchOutside(false) |
1325 | .setCancelable(false) | 1378 | .setCancelable(false) |
1326 | .setWidth(0.5f) | 1379 | .setWidth(0.5f) |
1327 | .configText(new ConfigText() { | 1380 | .configText(new ConfigText() { |
1328 | @Override | 1381 | @Override |
1329 | public void onConfig(TextParams params) { | 1382 | public void onConfig(TextParams params) { |
1330 | params.gravity = Gravity.CENTER; | 1383 | params.gravity = Gravity.CENTER; |
1331 | params.padding = new int[]{50, 50, 50, 50}; | 1384 | params.padding = new int[]{50, 50, 50, 50}; |
1332 | } | 1385 | } |
1333 | }) | 1386 | }) |
1334 | .setText("当前无网络,请检查网络设置") | 1387 | .setText("当前无网络,请检查网络设置") |
1335 | .setNegative("继续使用", null) | 1388 | .setNegative("继续使用", null) |
1336 | .setPositive("设置网络", new View.OnClickListener() { | 1389 | .setPositive("设置网络", new View.OnClickListener() { |
1337 | @Override | 1390 | @Override |
1338 | public void onClick(View v) { | 1391 | public void onClick(View v) { |
1339 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1392 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1340 | mContext.startActivity(intent); | 1393 | mContext.startActivity(intent); |
1341 | } | 1394 | } |
1342 | }) | 1395 | }) |
1343 | .show(); | 1396 | .show(); |
1344 | } | 1397 | } |
1345 | }); | 1398 | }); |
1346 | } | 1399 | } |
1347 | 1400 | ||
1348 | //市级接口 | 1401 | //市级接口 |
1349 | public void cityinfo(final Context mContext, long regionId , final Handler handler) { | 1402 | public void cityinfo(final Context mContext, long regionId , final Handler handler) { |
1350 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1403 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1351 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 1404 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
1352 | @Override | 1405 | @Override |
1353 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1406 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1354 | Log.e("test", "市" + new String(arg2)); | 1407 | Log.e("test", "市" + new String(arg2)); |
1355 | Gson gson = new Gson(); | 1408 | Gson gson = new Gson(); |
1356 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 1409 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
1357 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); | 1410 | List<CityInfo.CitiesBean> cityInfoBeanList = cityInfo.getCities(); |
1358 | Message message = Message.obtain(); | 1411 | Message message = Message.obtain(); |
1359 | message.what = HttpCode.CITYS; | 1412 | message.what = HttpCode.CITYS; |
1360 | message.obj = cityInfoBeanList; | 1413 | message.obj = cityInfoBeanList; |
1361 | handler.sendMessage(message); | 1414 | handler.sendMessage(message); |
1362 | 1415 | ||
1363 | 1416 | ||
1364 | } | 1417 | } |
1365 | 1418 | ||
1366 | @Override | 1419 | @Override |
1367 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1420 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1368 | new CircleDialog.Builder((FragmentActivity) mContext) | 1421 | new CircleDialog.Builder((FragmentActivity) mContext) |
1369 | .setCanceledOnTouchOutside(false) | 1422 | .setCanceledOnTouchOutside(false) |
1370 | .setCancelable(false) | 1423 | .setCancelable(false) |
1371 | .setWidth(0.5f) | 1424 | .setWidth(0.5f) |
1372 | .configText(new ConfigText() { | 1425 | .configText(new ConfigText() { |
1373 | @Override | 1426 | @Override |
1374 | public void onConfig(TextParams params) { | 1427 | public void onConfig(TextParams params) { |
1375 | params.gravity = Gravity.CENTER; | 1428 | params.gravity = Gravity.CENTER; |
1376 | params.padding = new int[]{50, 50, 50, 50}; | 1429 | params.padding = new int[]{50, 50, 50, 50}; |
1377 | } | 1430 | } |
1378 | }) | 1431 | }) |
1379 | .setText("当前无网络,请检查网络设置") | 1432 | .setText("当前无网络,请检查网络设置") |
1380 | .setNegative("继续使用", null) | 1433 | .setNegative("继续使用", null) |
1381 | .setPositive("设置网络", new View.OnClickListener() { | 1434 | .setPositive("设置网络", new View.OnClickListener() { |
1382 | @Override | 1435 | @Override |
1383 | public void onClick(View v) { | 1436 | public void onClick(View v) { |
1384 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1437 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1385 | mContext.startActivity(intent); | 1438 | mContext.startActivity(intent); |
1386 | } | 1439 | } |
1387 | }) | 1440 | }) |
1388 | .show(); | 1441 | .show(); |
1389 | } | 1442 | } |
1390 | }); | 1443 | }); |
1391 | } | 1444 | } |
1392 | 1445 | ||
1393 | //区县级接口 | 1446 | //区县级接口 |
1394 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { | 1447 | public void countyinfo(final Context mContext, int parentId, final Handler handler) { |
1395 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 1448 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
1396 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 1449 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
1397 | @Override | 1450 | @Override |
1398 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 1451 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
1399 | Log.e("test", "区" + new String(arg2)); | 1452 | Log.e("test", "区" + new String(arg2)); |
1400 | Gson gson = new Gson(); | 1453 | Gson gson = new Gson(); |
1401 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 1454 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
1402 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); | 1455 | List<CountyInfo.CountiesBean> countyInfoInfoBeanList = countyInfo.getCounties(); |
1403 | Message message = Message.obtain(); | 1456 | Message message = Message.obtain(); |
1404 | message.what = HttpCode.COUNTRY; | 1457 | message.what = HttpCode.COUNTRY; |
1405 | message.obj = countyInfoInfoBeanList; | 1458 | message.obj = countyInfoInfoBeanList; |
1406 | handler.sendMessage(message); | 1459 | handler.sendMessage(message); |
1407 | 1460 | ||
1408 | 1461 | ||
1409 | } | 1462 | } |
1410 | 1463 | ||
1411 | @Override | 1464 | @Override |
1412 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 1465 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1413 | new CircleDialog.Builder((FragmentActivity) mContext) | 1466 | new CircleDialog.Builder((FragmentActivity) mContext) |
1414 | .setCanceledOnTouchOutside(false) | 1467 | .setCanceledOnTouchOutside(false) |
1415 | .setCancelable(false) | 1468 | .setCancelable(false) |
1416 | .setWidth(0.5f) | 1469 | .setWidth(0.5f) |
1417 | .configText(new ConfigText() { | 1470 | .configText(new ConfigText() { |
1418 | @Override | 1471 | @Override |
1419 | public void onConfig(TextParams params) { | 1472 | public void onConfig(TextParams params) { |
1420 | params.gravity = Gravity.CENTER; | 1473 | params.gravity = Gravity.CENTER; |
1421 | params.padding = new int[]{50, 50, 50, 50}; | 1474 | params.padding = new int[]{50, 50, 50, 50}; |
1422 | } | 1475 | } |
1423 | }) | 1476 | }) |
1424 | .setText("当前无网络,请检查网络设置") | 1477 | .setText("当前无网络,请检查网络设置") |
1425 | .setNegative("继续使用", null) | 1478 | .setNegative("继续使用", null) |
1426 | .setPositive("设置网络", new View.OnClickListener() { | 1479 | .setPositive("设置网络", new View.OnClickListener() { |
1427 | @Override | 1480 | @Override |
1428 | public void onClick(View v) { | 1481 | public void onClick(View v) { |
1429 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 1482 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
1430 | mContext.startActivity(intent); | 1483 | mContext.startActivity(intent); |
1431 | } | 1484 | } |
1432 | }) | 1485 | }) |
1433 | .show(); | 1486 | .show(); |
1434 | } | 1487 | } |
1435 | }); | 1488 | }); |
1436 | } | 1489 | } |
1437 | 1490 | ||
1438 | 1491 | ||
1439 | private void closeProgress() { | 1492 | private void closeProgress() { |
1440 | try { | 1493 | try { |
1441 | if (mProgress != null) { | 1494 | if (mProgress != null) { |
1442 | mProgress.dismiss(); | 1495 | mProgress.dismiss(); |
1443 | mProgress = null; | 1496 | mProgress = null; |
1444 | } | 1497 | } |
1445 | } catch (Exception e) { | 1498 | } catch (Exception e) { |
1446 | e.printStackTrace(); | 1499 | e.printStackTrace(); |
1447 | } | 1500 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * Created by h on 2017/8/15. | 4 | * Created by h on 2017/8/15. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class HttpUrl { | 7 | public class HttpUrl { |
8 | private final static String Enviroment = "DEVELOPMENT"; | 8 | private final static String Enviroment = "DEVELOPMENT"; |
9 | 9 | ||
10 | public static String GetDomain(){ | 10 | public static String GetDomain(){ |
11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; | 11 | return Enviroment.equals("DEVELOPMENT") ? "http://boss.test.hjx.com" : "http://boss.hjx.com"; |
12 | } | 12 | } |
13 | 13 | ||
14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 | 14 | public static String loginUrl = GetDomain()+"/user/access_token";//登录 |
15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 | 15 | public static String schoolUrl = GetDomain()+"/school/get";//学校 |
16 | public static String gradesUrl = GetDomain()+"/grades";//年级 | 16 | public static String gradesUrl = GetDomain()+"/grades";//年级 |
17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | 17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 |
18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 | 18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 |
19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 | 19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 |
20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | 20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ |
21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | 21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 |
22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | 22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 |
23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | 23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 |
24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | 24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 |
25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 | 25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 |
26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 | 26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 |
27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 | 27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 |
28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 | 28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 |
29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 | 29 | public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息 |
30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 | 30 | public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息 |
31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 | 31 | public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名 |
32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 | 32 | public static String getsignature=GetDomain()+"/signature/info";//获取个性签名 |
33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 | 33 | public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈 |
34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 | 34 | public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息 |
35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 | 35 | public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户 |
36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 | 36 | public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户 |
37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 | 37 | public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户 |
38 | public static String updateappURL=GetDomain()+"/general/release/version";//系统升级 | ||
38 | 39 | ||
39 | 40 | ||
40 | 41 | ||
41 | 42 | ||
42 | 43 | ||
43 | } | 44 | } |
44 | 45 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/AppVersion.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.io.Serializable; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/8/29. | ||
7 | */ | ||
8 | |||
9 | public class AppVersion implements Serializable{ | ||
10 | |||
11 | /** | ||
12 | * version_name : 1.7.1.201608028708 | ||
13 | * versioncode : 176 | ||
14 | * pid : com.ozing.appstore | ||
15 | * downloads : | ||
16 | * app_name : 应用商城 | ||
17 | * msg : 919,929,939界面优化 | ||
18 | * url : http://hjxprodbucket.oss.aliyuncs.com/static/upload/app/pad/2016-08-18/AppStore-816.apk | ||
19 | * forceupdate : false | ||
20 | * size : 4805 | ||
21 | * encrypted : false | ||
22 | * encryptedUrl : | ||
23 | * order : | ||
24 | * visiable : true | ||
25 | * release_date : 1471449600000 | ||
26 | */ | ||
27 | |||
28 | private String version_name; | ||
29 | private int versioncode; | ||
30 | private String pid; | ||
31 | private String downloads; | ||
32 | private String app_name; | ||
33 | private String msg; | ||
34 | private String url; | ||
35 | private String forceupdate; | ||
36 | private int size; | ||
37 | private boolean encrypted; | ||
38 | private String encryptedUrl; | ||
39 | private String order; | ||
40 | private String visiable; | ||
41 | private long release_date; | ||
42 | |||
43 | public String getVersion_name() { | ||
44 | return version_name; | ||
45 | } | ||
46 | |||
47 | public void setVersion_name(String version_name) { | ||
48 | this.version_name = version_name; | ||
49 | } | ||
50 | |||
51 | public int getVersioncode() { | ||
52 | return versioncode; | ||
53 | } | ||
54 | |||
55 | public void setVersioncode(int versioncode) { | ||
56 | this.versioncode = versioncode; | ||
57 | } | ||
58 | |||
59 | public String getPid() { | ||
60 | return pid; | ||
61 | } | ||
62 | |||
63 | public void setPid(String pid) { | ||
64 | this.pid = pid; | ||
65 | } | ||
66 | |||
67 | public String getDownloads() { | ||
68 | return downloads; | ||
69 | } | ||
70 | |||
71 | public void setDownloads(String downloads) { | ||
72 | this.downloads = downloads; | ||
73 | } | ||
74 | |||
75 | public String getApp_name() { | ||
76 | return app_name; | ||
77 | } | ||
78 | |||
79 | public void setApp_name(String app_name) { | ||
80 | this.app_name = app_name; | ||
81 | } | ||
82 | |||
83 | public String getMsg() { | ||
84 | return msg; | ||
85 | } | ||
86 | |||
87 | public void setMsg(String msg) { | ||
88 | this.msg = msg; | ||
89 | } | ||
90 | |||
91 | public String getUrl() { | ||
92 | return url; | ||
93 | } | ||
94 | |||
95 | public void setUrl(String url) { | ||
96 | this.url = url; | ||
97 | } | ||
98 | |||
99 | public String getForceupdate() { | ||
100 | return forceupdate; | ||
101 | } | ||
102 | |||
103 | public void setForceupdate(String forceupdate) { | ||
104 | this.forceupdate = forceupdate; | ||
105 | } | ||
106 | |||
107 | public int getSize() { | ||
108 | return size; | ||
109 | } | ||
110 | |||
111 | public void setSize(int size) { | ||
112 | this.size = size; | ||
113 | } | ||
114 | |||
115 | public boolean isEncrypted() { | ||
116 | return encrypted; | ||
117 | } | ||
118 | |||
119 | public void setEncrypted(boolean encrypted) { | ||
120 | this.encrypted = encrypted; | ||
121 | } | ||
122 | |||
123 | public String getEncryptedUrl() { | ||
124 | return encryptedUrl; | ||
125 | } | ||
126 | |||
127 | public void setEncryptedUrl(String encryptedUrl) { | ||
128 | this.encryptedUrl = encryptedUrl; | ||
129 | } | ||
130 | |||
131 | public String getOrder() { | ||
132 | return order; | ||
133 | } | ||
134 | |||
135 | public void setOrder(String order) { | ||
136 | this.order = order; | ||
137 | } | ||
138 | |||
139 | public String getVisiable() { | ||
140 | return visiable; | ||
141 | } | ||
142 | |||
143 | public void setVisiable(String visiable) { | ||
144 | this.visiable = visiable; | ||
145 | } | ||
146 | |||
147 | public long getRelease_date() { | ||
148 | return release_date; | ||
149 | } | ||
150 | |||
151 | public void setRelease_date(long release_date) { | ||
152 | this.release_date = release_date; | ||
153 | } | ||
154 | } | ||
155 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/update/DownloadService.java
File was created | 1 | package com.hjx.personalcenter.update; | |
2 | |||
3 | /** | ||
4 | * Created by l on 2017/7/17. | ||
5 | */ | ||
6 | |||
7 | |||
8 | import android.app.IntentService; | ||
9 | import android.content.Intent; | ||
10 | import android.os.Bundle; | ||
11 | import android.os.ResultReceiver; | ||
12 | |||
13 | import java.io.BufferedInputStream; | ||
14 | import java.io.FileOutputStream; | ||
15 | import java.io.IOException; | ||
16 | import java.io.InputStream; | ||
17 | import java.io.OutputStream; | ||
18 | import java.net.URL; | ||
19 | import java.net.URLConnection; | ||
20 | |||
21 | public class DownloadService extends IntentService { | ||
22 | public static final int UPDATE_PROGRESS = 8344; | ||
23 | public DownloadService() { | ||
24 | super("DownloadService"); | ||
25 | } | ||
26 | @Override | ||
27 | protected void onHandleIntent(Intent intent) { | ||
28 | String urlToDownload = intent.getStringExtra("url"); | ||
29 | String fileDestination = intent.getStringExtra("dest"); | ||
30 | ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver"); | ||
31 | try { | ||
32 | URL url = new URL(urlToDownload); | ||
33 | URLConnection connection = url.openConnection(); | ||
34 | connection.connect(); | ||
35 | // this will be useful so that you can show a typical 0-100% progress bar | ||
36 | int fileLength = connection.getContentLength(); | ||
37 | // download the file | ||
38 | InputStream input = new BufferedInputStream(connection.getInputStream()); | ||
39 | OutputStream output = new FileOutputStream(fileDestination); | ||
40 | byte data[] = new byte[100]; | ||
41 | long total = 0; | ||
42 | int count; | ||
43 | while ((count = input.read(data)) != -1) { | ||
44 | total += count; | ||
45 | // publishing the progress.... | ||
46 | Bundle resultData = new Bundle(); | ||
47 | resultData.putInt("progress" ,(int) (total * 100 / fileLength)); | ||
48 | receiver.send(UPDATE_PROGRESS, resultData); | ||
49 | output.write(data, 0, count); | ||
50 | } | ||
51 | output.flush(); | ||
52 | output.close(); | ||
53 | input.close(); | ||
54 | } catch (IOException e) { | ||
55 | e.printStackTrace(); | ||
56 | } | ||
57 | Bundle resultData = new Bundle(); | ||
58 | resultData.putInt("progress" ,100); | ||
59 | receiver.send(UPDATE_PROGRESS, resultData); | ||
60 | } | ||
61 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/update/UpdateChecker.java
File was created | 1 | package com.hjx.personalcenter.update; | |
2 | |||
3 | /** | ||
4 | * Created by l on 2017/7/17. | ||
5 | */ | ||
6 | |||
7 | import android.app.Activity; | ||
8 | import android.app.ProgressDialog; | ||
9 | import android.content.Context; | ||
10 | import android.content.DialogInterface; | ||
11 | import android.content.Intent; | ||
12 | import android.content.pm.PackageManager; | ||
13 | import android.net.Uri; | ||
14 | import android.os.Bundle; | ||
15 | import android.os.Environment; | ||
16 | import android.os.Handler; | ||
17 | import android.os.Message; | ||
18 | import android.os.ResultReceiver; | ||
19 | import android.support.v4.app.FragmentActivity; | ||
20 | import android.view.View; | ||
21 | |||
22 | import com.hjx.personalcenter.http.HttpCode; | ||
23 | import com.hjx.personalcenter.http.HttpManager; | ||
24 | import com.hjx.personalcenter.model.AppVersion; | ||
25 | import com.mylhyl.circledialog.CircleDialog; | ||
26 | |||
27 | import java.io.File; | ||
28 | |||
29 | public class UpdateChecker{ | ||
30 | private static final String TAG = "UpdateChecker"; | ||
31 | private Context mContext; | ||
32 | //检查版本信息的线程 | ||
33 | private Thread mThread; | ||
34 | |||
35 | private AppVersion mAppVersion; | ||
36 | //下载apk的对话框 | ||
37 | private ProgressDialog mProgressDialog; | ||
38 | |||
39 | private File apkFile; | ||
40 | |||
41 | |||
42 | public UpdateChecker(Context context) { | ||
43 | mContext = context; | ||
44 | // instantiate it within the onCreate method | ||
45 | mProgressDialog = new ProgressDialog(context); | ||
46 | mProgressDialog.setMessage("正在下载"); | ||
47 | mProgressDialog.setIndeterminate(false); | ||
48 | mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | ||
49 | mProgressDialog.setCancelable(true); | ||
50 | mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { | ||
51 | @Override | ||
52 | public void onCancel(DialogInterface dialog) { | ||
53 | |||
54 | } | ||
55 | }); | ||
56 | mProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | ||
57 | @Override | ||
58 | public void onDismiss(DialogInterface dialog) { | ||
59 | // TODO Auto-generated method stub | ||
60 | |||
61 | } | ||
62 | }); | ||
63 | } | ||
64 | |||
65 | public void checkForUpdates() { | ||
66 | |||
67 | final Handler handler = new Handler(){ | ||
68 | public void handleMessage(Message msg) { | ||
69 | if (msg.what == HttpCode.APPUPDATE_SUCESS) { | ||
70 | mAppVersion = (AppVersion) msg.obj; | ||
71 | try{ | ||
72 | int versionCode = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode; | ||
73 | if (mAppVersion.getVersioncode() > versionCode) { | ||
74 | if(mAppVersion.isEncrypted()){ | ||
75 | showForceUpdateDialog(); | ||
76 | }else{ | ||
77 | showUpdateDialog(); | ||
78 | } | ||
79 | } else { | ||
80 | //Toast.makeText(mContext, "已经是最新版本", Toast.LENGTH_SHORT).show(); | ||
81 | } | ||
82 | }catch (PackageManager.NameNotFoundException ignored) { | ||
83 | // | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | }; | ||
88 | |||
89 | mThread = new Thread() { | ||
90 | @Override | ||
91 | public void run() { | ||
92 | try { | ||
93 | HttpManager.getInstance().updateAPP(mContext,"com.hjx.personalcenter","呼叫老师安卓Pad",handler); | ||
94 | }catch (Exception e){ | ||
95 | e.printStackTrace(); | ||
96 | } | ||
97 | |||
98 | } | ||
99 | }; | ||
100 | mThread.start(); | ||
101 | } | ||
102 | |||
103 | private void showForceUpdateDialog() { | ||
104 | new CircleDialog.Builder((FragmentActivity)mContext) | ||
105 | .setCanceledOnTouchOutside(false) | ||
106 | .setCancelable(false) | ||
107 | .setWidth(0.5f) | ||
108 | .setTitle("升级提示") | ||
109 | .setNegative("取消", new View.OnClickListener() { | ||
110 | @Override | ||
111 | public void onClick(View v) { | ||
112 | ((Activity)mContext).finish(); | ||
113 | |||
114 | } | ||
115 | }) | ||
116 | .setPositive("确定", new View.OnClickListener() { | ||
117 | @Override | ||
118 | public void onClick(View v) { | ||
119 | downLoadApk(); | ||
120 | } | ||
121 | }) | ||
122 | .show(); | ||
123 | } | ||
124 | |||
125 | private void showUpdateDialog() { | ||
126 | new CircleDialog.Builder((FragmentActivity)mContext) | ||
127 | .setCanceledOnTouchOutside(false) | ||
128 | .setCancelable(false) | ||
129 | .setWidth(0.5f) | ||
130 | .setTitle("升级提示") | ||
131 | .setNegative("取消", null) | ||
132 | .setPositive("确定", new View.OnClickListener() { | ||
133 | @Override | ||
134 | public void onClick(View v) { | ||
135 | downLoadApk(); | ||
136 | } | ||
137 | }) | ||
138 | .show(); | ||
139 | } | ||
140 | |||
141 | private void downLoadApk() { | ||
142 | String apkUrl = mAppVersion.getUrl(); | ||
143 | String dir = mContext.getExternalFilesDir( "apk").getAbsolutePath(); | ||
144 | File folder = Environment.getExternalStoragePublicDirectory(dir); | ||
145 | if(folder.exists() && folder.isDirectory()) { | ||
146 | //do nothing | ||
147 | }else { | ||
148 | folder.mkdirs(); | ||
149 | } | ||
150 | String filename = apkUrl.substring(apkUrl.lastIndexOf("/"),apkUrl.length()); | ||
151 | String destinationFilePath = dir + "/" + filename; | ||
152 | apkFile = new File(destinationFilePath); | ||
153 | if(mAppVersion.isEncrypted()){ | ||
154 | mProgressDialog.setCancelable(false); | ||
155 | } | ||
156 | mProgressDialog.show(); | ||
157 | Intent intent = new Intent(mContext, DownloadService.class); | ||
158 | intent.putExtra("url", apkUrl); | ||
159 | intent.putExtra("dest", destinationFilePath); | ||
160 | intent.putExtra("receiver", new DownloadReceiver(new Handler())); | ||
161 | mContext.startService(intent); | ||
162 | } | ||
163 | |||
164 | private class DownloadReceiver extends ResultReceiver{ | ||
165 | public DownloadReceiver(Handler handler) { | ||
166 | super(handler); | ||
167 | } | ||
168 | @Override | ||
169 | protected void onReceiveResult(int resultCode, Bundle resultData) { | ||
170 | super.onReceiveResult(resultCode, resultData); | ||
171 | if (resultCode == DownloadService.UPDATE_PROGRESS) { | ||
172 | int progress = resultData.getInt("progress"); | ||
173 | mProgressDialog.setProgress(progress); | ||
174 | if (progress == 100) { | ||
175 | mProgressDialog.dismiss(); | ||
176 | //如果没有设置SDCard写权限,或者没有sdcard,apk文件保存在内存中,需要授予权限才能安装 | ||
177 | String[] command = {"chmod","777",apkFile.toString()}; | ||
178 | try{ | ||
179 | ProcessBuilder builder = new ProcessBuilder(command); | ||
180 | builder.start(); | ||
181 | Intent intent = new Intent(Intent.ACTION_VIEW); | ||
182 | intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); | ||
183 | mContext.startActivity(intent); | ||
184 | }catch (Exception e){ | ||
185 | e.printStackTrace(); | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | } |
PersonalCenter/app/src/main/res/drawable/search_clear.xml
File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:drawable="@drawable/search_clear_normal" android:state_pressed="false"/> | ||
4 | <item android:drawable="@drawable/search_clear_pressed" android:state_pressed="true"/> | ||
5 | </selector> | ||
6 |
PersonalCenter/app/src/main/res/layout/activity_change_preson_info.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
4 | android:id="@android:id/tabhost" | 4 | android:id="@android:id/tabhost" |
5 | android:layout_width="fill_parent" | 5 | android:layout_width="fill_parent" |
6 | android:layout_height="fill_parent" | 6 | android:layout_height="fill_parent" |
7 | android:background="@color/white" | 7 | android:background="@color/white" |
8 | tools:context="com.hjx.personalcenter.activity.LoginAndRegisterActivity"> | 8 | tools:context="com.hjx.personalcenter.activity.LoginAndRegisterActivity"> |
9 | <RelativeLayout | 9 | <RelativeLayout |
10 | android:id="@+id/title" | 10 | android:id="@+id/title" |
11 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
12 | android:layout_height="50dp" | 12 | android:layout_height="50dp" |
13 | android:background="@color/login_text_blue"> | 13 | android:background="@color/login_text_blue"> |
14 | 14 | ||
15 | <ImageView | 15 | <ImageView |
16 | android:id="@+id/cancel" | 16 | android:id="@+id/cancel" |
17 | android:layout_width="wrap_content" | 17 | android:layout_width="wrap_content" |
18 | android:layout_height="match_parent" | 18 | android:layout_height="match_parent" |
19 | android:paddingLeft="20dp" | 19 | android:paddingLeft="20dp" |
20 | android:paddingRight="20dp" | 20 | android:paddingRight="20dp" |
21 | android:src="@mipmap/title_back" /> | 21 | android:src="@mipmap/title_back" /> |
22 | 22 | ||
23 | <TextView | 23 | <TextView |
24 | android:id="@+id/menu_title" | 24 | android:id="@+id/menu_title" |
25 | android:layout_width="wrap_content" | 25 | android:layout_width="wrap_content" |
26 | android:layout_height="match_parent" | 26 | android:layout_height="match_parent" |
27 | android:layout_centerInParent="true" | 27 | android:layout_centerInParent="true" |
28 | android:gravity="center_vertical" | 28 | android:gravity="center_vertical" |
29 | android:text="@string/changge_preson" | 29 | android:text="@string/changge_preson" |
30 | android:textColor="@android:color/white" | 30 | android:textColor="@android:color/white" |
31 | android:textSize="22sp" /> | 31 | android:textSize="22sp" /> |
32 | <TextView | 32 | <TextView |
33 | android:id="@+id/presonal_sub" | 33 | android:id="@+id/presonal_sub" |
34 | android:layout_width="wrap_content" | 34 | android:layout_width="wrap_content" |
35 | android:layout_height="match_parent" | 35 | android:layout_height="match_parent" |
36 | android:paddingLeft="20dp" | 36 | android:paddingLeft="20dp" |
37 | android:paddingRight="20dp" | 37 | android:paddingRight="20dp" |
38 | android:gravity="center_vertical" | 38 | android:gravity="center_vertical" |
39 | android:layout_alignParentRight="true" | 39 | android:layout_alignParentRight="true" |
40 | android:text="保存" | 40 | android:text="保存" |
41 | android:textColor="@android:color/white" | 41 | android:textColor="@android:color/white" |
42 | android:textSize="22sp" /> | 42 | android:textSize="22sp" /> |
43 | 43 | ||
44 | 44 | ||
45 | </RelativeLayout> | 45 | </RelativeLayout> |
46 | 46 | ||
47 | <LinearLayout | 47 | <LinearLayout |
48 | android:layout_width="wrap_content" | 48 | android:layout_width="wrap_content" |
49 | android:layout_height="wrap_content" | 49 | android:layout_height="wrap_content" |
50 | android:layout_marginTop="20dp" | 50 | android:layout_marginTop="30dp" |
51 | android:layout_below="@+id/title" | 51 | android:layout_below="@+id/title" |
52 | android:orientation="vertical"> | 52 | android:orientation="vertical"> |
53 | 53 | ||
54 | <com.hjx.personalcenter.thirdparty.SlidingTabLayout | 54 | <com.hjx.personalcenter.thirdparty.SlidingTabLayout |
55 | android:id="@+id/TabLayout_id" | 55 | android:id="@+id/TabLayout_id" |
56 | android:layout_gravity="center" | 56 | android:layout_gravity="center" |
57 | android:layout_width="wrap_content" | 57 | android:layout_width="wrap_content" |
58 | android:layout_height="50dp"> | 58 | android:layout_height="50dp"> |
59 | </com.hjx.personalcenter.thirdparty.SlidingTabLayout> | 59 | </com.hjx.personalcenter.thirdparty.SlidingTabLayout> |
60 | 60 | ||
61 | <android.support.v4.view.ViewPager | 61 | <android.support.v4.view.ViewPager |
62 | android:id="@+id/viewpager_login" | 62 | android:id="@+id/viewpager_login" |
63 | android:layout_width="match_parent" | 63 | android:layout_width="match_parent" |
64 | android:layout_height="match_parent" | 64 | android:layout_height="match_parent" |
65 | android:background="@color/white" /> | 65 | android:background="@color/white" /> |
66 | </LinearLayout> | 66 | </LinearLayout> |
67 | 67 | ||
68 | </RelativeLayout> | 68 | </RelativeLayout> |
PersonalCenter/app/src/main/res/layout/fragment_changge_presonal_info.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:id="@+id/card_view" | 3 | android:id="@+id/card_view" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | 8 | ||
9 | <LinearLayout | 9 | <LinearLayout |
10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" |
11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
12 | android:layout_marginTop="60dp" | 12 | android:layout_marginTop="80dp" |
13 | android:orientation="horizontal"> | 13 | android:orientation="horizontal"> |
14 | 14 | ||
15 | <View | 15 | <View |
16 | android:layout_width="450dp" | 16 | android:layout_width="450dp" |
17 | android:layout_height="0.7dp" | 17 | android:layout_height="0.7dp" |
18 | android:layout_marginLeft="150dp" | 18 | android:layout_marginLeft="150dp" |
19 | android:background="@color/electronic_text"> | 19 | android:background="@color/cutoff_line"> |
20 | 20 | ||
21 | </View> | 21 | </View> |
22 | 22 | ||
23 | <View | 23 | <View |
24 | android:layout_width="450dp" | 24 | android:layout_width="450dp" |
25 | android:layout_height="0.7dp" | 25 | android:layout_height="0.7dp" |
26 | android:layout_marginLeft="80dp" | 26 | android:layout_marginLeft="80dp" |
27 | android:background="@color/electronic_text"> | 27 | android:background="@color/cutoff_line"> |
28 | 28 | ||
29 | </View> | 29 | </View> |
30 | 30 | ||
31 | 31 | ||
32 | </LinearLayout> | 32 | </LinearLayout> |
33 | 33 | ||
34 | <LinearLayout | 34 | <LinearLayout |
35 | android:layout_width="match_parent" | 35 | android:layout_width="match_parent" |
36 | android:layout_height="wrap_content" | 36 | android:layout_height="wrap_content" |
37 | android:layout_marginLeft="200dp" | 37 | android:layout_marginLeft="200dp" |
38 | android:gravity="center_vertical" | 38 | android:gravity="center_vertical" |
39 | android:orientation="horizontal"> | 39 | android:orientation="horizontal"> |
40 | 40 | ||
41 | <LinearLayout | 41 | <LinearLayout |
42 | android:layout_width="0dp" | 42 | android:layout_width="0dp" |
43 | android:layout_height="80dp" | 43 | android:layout_height="80dp" |
44 | android:layout_weight="1" | 44 | android:layout_weight="1" |
45 | android:gravity="center_vertical"> | 45 | android:gravity="center_vertical"> |
46 | 46 | ||
47 | <TextView | 47 | <TextView |
48 | android:layout_width="wrap_content" | 48 | android:layout_width="wrap_content" |
49 | android:layout_height="wrap_content" | 49 | android:layout_height="wrap_content" |
50 | android:text="昵称" | 50 | android:text="昵称" |
51 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
52 | android:textSize="22sp" /> | 51 | android:textSize="22sp" /> |
53 | 52 | ||
54 | <EditText | 53 | <EditText |
55 | android:id="@+id/tv_username1" | 54 | android:id="@+id/tv_username1" |
56 | android:layout_width="wrap_content" | 55 | android:layout_width="wrap_content" |
57 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
58 | android:layout_marginLeft="50dp" | 57 | android:layout_marginLeft="50dp" |
59 | android:background="@null" | 58 | android:background="@null" |
60 | android:hint="请输入12个以内的中文或英文字符" | 59 | android:hint="请输入12个以内的中文或英文字符" |
61 | android:textColor="@color/electronic_text" | 60 | android:textColor="@color/electronic_text" |
62 | android:textSize="22sp" /> | 61 | android:textSize="22sp" /> |
63 | 62 | ||
64 | </LinearLayout> | 63 | </LinearLayout> |
65 | 64 | ||
66 | <LinearLayout | 65 | <LinearLayout |
67 | android:layout_width="0dp" | 66 | android:layout_width="0dp" |
68 | android:layout_height="80dp" | 67 | android:layout_height="80dp" |
69 | android:layout_weight="1" | 68 | android:layout_weight="1" |
70 | android:gravity="center_vertical"> | 69 | android:gravity="center_vertical"> |
71 | 70 | ||
72 | <TextView | 71 | <TextView |
73 | android:layout_width="wrap_content" | 72 | android:layout_width="wrap_content" |
74 | android:layout_height="wrap_content" | 73 | android:layout_height="wrap_content" |
75 | android:text="地区" | 74 | android:text="地区" |
76 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
77 | android:textSize="22sp" /> | 75 | android:textSize="22sp" /> |
78 | 76 | ||
79 | <TextView | 77 | <TextView |
80 | android:id="@+id/tv_useinfo_adress" | 78 | android:id="@+id/tv_useinfo_adress" |
81 | android:layout_width="wrap_content" | 79 | android:layout_width="wrap_content" |
82 | android:layout_height="wrap_content" | 80 | android:layout_height="wrap_content" |
83 | android:layout_marginLeft="50dp" | 81 | android:layout_marginLeft="50dp" |
84 | android:hint="请选择" | 82 | android:hint="请选择" |
85 | android:textColor="@color/btn_text_color" | 83 | android:textColor="@color/btn_text_color" |
86 | android:textSize="22sp" /> | 84 | android:textSize="22sp" /> |
87 | 85 | ||
88 | <ImageView | 86 | <ImageView |
89 | android:layout_width="wrap_content" | 87 | android:layout_width="wrap_content" |
90 | android:layout_height="wrap_content" | 88 | android:layout_height="wrap_content" |
91 | android:layout_marginLeft="150dp" | 89 | android:layout_marginLeft="150dp" |
92 | android:src="@mipmap/xiajiantou"> | 90 | android:src="@mipmap/xiajiantou"> |
93 | 91 | ||
94 | </ImageView> | 92 | </ImageView> |
95 | </LinearLayout> | 93 | </LinearLayout> |
96 | 94 | ||
97 | </LinearLayout> | 95 | </LinearLayout> |
98 | 96 | ||
99 | <LinearLayout | 97 | <LinearLayout |
100 | android:layout_width="wrap_content" | 98 | android:layout_width="wrap_content" |
101 | android:layout_height="wrap_content" | 99 | android:layout_height="wrap_content" |
102 | android:orientation="horizontal"> | 100 | android:orientation="horizontal"> |
103 | 101 | ||
104 | <View | 102 | <View |
105 | android:layout_width="450dp" | 103 | android:layout_width="450dp" |
106 | android:layout_height="0.7dp" | 104 | android:layout_height="0.7dp" |
107 | android:layout_marginLeft="150dp" | 105 | android:layout_marginLeft="150dp" |
108 | android:background="@color/electronic_text"> | 106 | android:background="@color/cutoff_line"> |
109 | 107 | ||
110 | </View> | 108 | </View> |
111 | 109 | ||
112 | <View | 110 | <View |
113 | android:layout_width="450dp" | 111 | android:layout_width="450dp" |
114 | android:layout_height="0.7dp" | 112 | android:layout_height="0.7dp" |
115 | android:layout_marginLeft="80dp" | 113 | android:layout_marginLeft="80dp" |
116 | android:background="@color/electronic_text"> | 114 | android:background="@color/cutoff_line"> |
117 | 115 | ||
118 | </View> | 116 | </View> |
119 | 117 | ||
120 | 118 | ||
121 | </LinearLayout> | 119 | </LinearLayout> |
122 | 120 | ||
123 | <LinearLayout | 121 | <LinearLayout |
124 | android:layout_width="match_parent" | 122 | android:layout_width="match_parent" |
125 | android:layout_height="wrap_content" | 123 | android:layout_height="wrap_content" |
126 | android:layout_marginLeft="200dp" | 124 | android:layout_marginLeft="200dp" |
127 | android:gravity="center_vertical" | 125 | android:gravity="center_vertical" |
128 | android:orientation="horizontal"> | 126 | android:orientation="horizontal"> |
129 | 127 | ||
130 | <LinearLayout | 128 | <LinearLayout |
131 | android:layout_width="0dp" | 129 | android:layout_width="0dp" |
132 | android:layout_height="80dp" | 130 | android:layout_height="80dp" |
133 | android:layout_weight="1" | 131 | android:layout_weight="1" |
134 | android:gravity="center_vertical"> | 132 | android:gravity="center_vertical"> |
135 | 133 | ||
136 | <TextView | 134 | <TextView |
137 | android:layout_width="wrap_content" | 135 | android:layout_width="wrap_content" |
138 | android:layout_height="wrap_content" | 136 | android:layout_height="wrap_content" |
139 | android:text="性别" | 137 | android:text="性别" |
140 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
141 | android:textSize="22sp" /> | 138 | android:textSize="22sp" /> |
142 | 139 | ||
143 | <TextView | 140 | <TextView |
144 | android:id="@+id/tv_sex" | 141 | android:id="@+id/tv_sex" |
145 | android:layout_width="wrap_content" | 142 | android:layout_width="wrap_content" |
146 | android:layout_height="wrap_content" | 143 | android:layout_height="wrap_content" |
147 | android:layout_marginLeft="50dp" | 144 | android:layout_marginLeft="50dp" |
148 | android:hint="请选择" | 145 | android:hint="请选择" |
149 | android:textSize="22sp" /> | 146 | android:textSize="22sp" /> |
150 | 147 | ||
151 | <ImageView | 148 | <ImageView |
152 | android:layout_width="wrap_content" | 149 | android:layout_width="wrap_content" |
153 | android:layout_height="wrap_content" | 150 | android:layout_height="wrap_content" |
154 | android:layout_marginLeft="150dp" | 151 | android:layout_marginLeft="150dp" |
155 | android:src="@mipmap/xiajiantou"> | 152 | android:src="@mipmap/xiajiantou"> |
156 | 153 | ||
157 | </ImageView> | 154 | </ImageView> |
158 | 155 | ||
159 | 156 | ||
160 | </LinearLayout> | 157 | </LinearLayout> |
161 | 158 | ||
162 | <LinearLayout | 159 | <LinearLayout |
163 | android:layout_width="0dp" | 160 | android:layout_width="0dp" |
164 | android:layout_height="80dp" | 161 | android:layout_height="80dp" |
165 | android:layout_weight="1" | 162 | android:layout_weight="1" |
166 | android:gravity="center_vertical"> | 163 | android:gravity="center_vertical"> |
167 | 164 | ||
168 | <TextView | 165 | <TextView |
169 | android:layout_width="wrap_content" | 166 | android:layout_width="wrap_content" |
170 | android:layout_height="wrap_content" | 167 | android:layout_height="wrap_content" |
171 | android:text=" " | 168 | android:text=" " |
172 | android:textColor="@color/white" | 169 | android:textColor="@color/white" |
173 | android:textSize="22sp" /> | 170 | android:textSize="22sp" /> |
174 | 171 | ||
175 | <EditText | 172 | <EditText |
176 | android:id="@+id/tv_useinfo_adress1" | 173 | android:id="@+id/tv_useinfo_adress1" |
177 | android:layout_width="wrap_content" | 174 | android:layout_width="wrap_content" |
178 | android:layout_height="wrap_content" | 175 | android:layout_height="wrap_content" |
179 | android:layout_marginLeft="50dp" | 176 | android:layout_marginLeft="50dp" |
180 | android:background="@null" | 177 | android:background="@null" |
181 | android:hint="请输入详细地址" | 178 | android:hint="请输入详细地址" |
182 | android:textSize="22sp" /> | 179 | android:textSize="22sp" /> |
183 | 180 | ||
184 | </LinearLayout> | 181 | </LinearLayout> |
185 | 182 | ||
186 | </LinearLayout> | 183 | </LinearLayout> |
187 | 184 | ||
188 | <LinearLayout | 185 | <LinearLayout |
189 | android:layout_width="wrap_content" | 186 | android:layout_width="wrap_content" |
190 | android:layout_height="wrap_content" | 187 | android:layout_height="wrap_content" |
191 | 188 | ||
192 | android:orientation="horizontal"> | 189 | android:orientation="horizontal"> |
193 | 190 | ||
194 | <View | 191 | <View |
195 | android:layout_width="450dp" | 192 | android:layout_width="450dp" |
196 | android:layout_height="0.7dp" | 193 | android:layout_height="0.7dp" |
197 | android:layout_marginLeft="150dp" | 194 | android:layout_marginLeft="150dp" |
198 | android:background="@color/electronic_text"> | 195 | android:background="@color/cutoff_line"> |
199 | 196 | ||
200 | </View> | 197 | </View> |
201 | 198 | ||
202 | <View | 199 | <View |
203 | android:layout_width="450dp" | 200 | android:layout_width="450dp" |
204 | android:layout_height="0.7dp" | 201 | android:layout_height="0.7dp" |
205 | android:layout_marginLeft="80dp" | 202 | android:layout_marginLeft="80dp" |
206 | android:background="@color/electronic_text"> | 203 | android:background="@color/cutoff_line"> |
207 | 204 | ||
208 | </View> | 205 | </View> |
209 | 206 | ||
210 | 207 | ||
211 | </LinearLayout> | 208 | </LinearLayout> |
212 | 209 | ||
213 | <LinearLayout | 210 | <LinearLayout |
214 | android:layout_width="match_parent" | 211 | android:layout_width="match_parent" |
215 | android:layout_height="wrap_content" | 212 | android:layout_height="wrap_content" |
216 | android:layout_marginLeft="200dp" | 213 | android:layout_marginLeft="200dp" |
217 | android:gravity="center_vertical" | 214 | android:gravity="center_vertical" |
218 | android:orientation="horizontal"> | 215 | android:orientation="horizontal"> |
219 | 216 | ||
220 | 217 | ||
221 | <LinearLayout | 218 | <LinearLayout |
222 | android:layout_width="0dp" | 219 | android:layout_width="0dp" |
223 | android:layout_height="80dp" | 220 | android:layout_height="80dp" |
224 | android:layout_weight="1" | 221 | android:layout_weight="1" |
225 | android:gravity="center_vertical"> | 222 | android:gravity="center_vertical"> |
226 | 223 | ||
227 | <TextView | 224 | <TextView |
228 | android:layout_width="wrap_content" | 225 | android:layout_width="wrap_content" |
229 | android:layout_height="wrap_content" | 226 | android:layout_height="wrap_content" |
230 | android:text="生日" | 227 | android:text="生日" |
231 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
232 | android:textSize="22sp" /> | 228 | android:textSize="22sp" /> |
233 | 229 | ||
234 | <TextView | 230 | <TextView |
235 | android:id="@+id/tv_useinfo_birthday" | 231 | android:id="@+id/tv_useinfo_birthday" |
236 | android:layout_width="wrap_content" | 232 | android:layout_width="wrap_content" |
237 | android:layout_height="wrap_content" | 233 | android:layout_height="wrap_content" |
238 | android:layout_marginLeft="50dp" | 234 | android:layout_marginLeft="50dp" |
239 | android:hint="请选择" | 235 | android:hint="请选择" |
240 | android:textSize="22sp" /> | 236 | android:textSize="22sp" /> |
241 | 237 | ||
242 | <ImageView | 238 | <ImageView |
243 | android:layout_width="wrap_content" | 239 | android:layout_width="wrap_content" |
244 | android:layout_height="wrap_content" | 240 | android:layout_height="wrap_content" |
245 | android:layout_marginLeft="150dp" | 241 | android:layout_marginLeft="150dp" |
246 | android:src="@mipmap/xiajiantou"/> | 242 | android:src="@mipmap/xiajiantou"/> |
247 | </LinearLayout> | 243 | </LinearLayout> |
248 | <LinearLayout | 244 | <LinearLayout |
249 | android:layout_width="0dp" | 245 | android:layout_width="0dp" |
250 | android:layout_height="80dp" | 246 | android:layout_height="80dp" |
251 | android:layout_weight="1" | 247 | android:layout_weight="1" |
252 | android:gravity="center_vertical"> | 248 | android:gravity="center_vertical"> |
253 | 249 | ||
254 | <TextView | 250 | <TextView |
255 | android:layout_width="wrap_content" | 251 | android:layout_width="wrap_content" |
256 | android:layout_height="wrap_content" | 252 | android:layout_height="wrap_content" |
257 | android:text="年级" | 253 | android:text="年级" |
258 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
259 | android:textSize="22sp" /> | 254 | android:textSize="22sp" /> |
260 | 255 | ||
261 | <TextView | 256 | <TextView |
262 | android:id="@+id/tv_useinfo_gender" | 257 | android:id="@+id/tv_useinfo_gender" |
263 | android:layout_width="wrap_content" | 258 | android:layout_width="wrap_content" |
264 | android:layout_height="wrap_content" | 259 | android:layout_height="wrap_content" |
265 | android:layout_marginLeft="50dp" | 260 | android:layout_marginLeft="50dp" |
266 | android:hint="请选择" | 261 | android:hint="请选择" |
267 | android:textSize="22sp" /> | 262 | android:textSize="22sp" /> |
268 | 263 | ||
269 | <ImageView | 264 | <ImageView |
270 | android:layout_width="wrap_content" | 265 | android:layout_width="wrap_content" |
271 | android:layout_height="wrap_content" | 266 | android:layout_height="wrap_content" |
272 | android:layout_marginLeft="150dp" | 267 | android:layout_marginLeft="150dp" |
273 | android:src="@mipmap/xiajiantou"/> | 268 | android:src="@mipmap/xiajiantou"/> |
274 | </LinearLayout> | 269 | </LinearLayout> |
275 | 270 | ||
276 | </LinearLayout> | 271 | </LinearLayout> |
277 | 272 | ||
278 | <LinearLayout | 273 | <LinearLayout |
279 | android:layout_width="wrap_content" | 274 | android:layout_width="wrap_content" |
280 | android:layout_height="wrap_content" | 275 | android:layout_height="wrap_content" |
281 | 276 | ||
282 | android:orientation="horizontal"> | 277 | android:orientation="horizontal"> |
283 | 278 | ||
284 | <View | 279 | <View |
285 | android:layout_width="450dp" | 280 | android:layout_width="450dp" |
286 | android:layout_height="0.7dp" | 281 | android:layout_height="0.7dp" |
287 | android:layout_marginLeft="150dp" | 282 | android:layout_marginLeft="150dp" |
288 | android:background="@color/electronic_text"> | 283 | android:background="@color/cutoff_line"> |
289 | 284 | ||
290 | </View> | 285 | </View> |
291 | 286 | ||
292 | <View | 287 | <View |
293 | android:layout_width="450dp" | 288 | android:layout_width="450dp" |
294 | android:layout_height="0.7dp" | 289 | android:layout_height="0.7dp" |
295 | android:layout_marginLeft="80dp" | 290 | android:layout_marginLeft="80dp" |
296 | android:background="@color/electronic_text"> | 291 | android:background="@color/cutoff_line"> |
297 | 292 | ||
298 | </View> | 293 | </View> |
299 | 294 | ||
300 | 295 | ||
301 | </LinearLayout> | 296 | </LinearLayout> |
302 | 297 | ||
303 | <LinearLayout | 298 | <LinearLayout |
304 | android:layout_width="match_parent" | 299 | android:layout_width="match_parent" |
305 | android:layout_height="wrap_content" | 300 | android:layout_height="wrap_content" |
306 | android:layout_marginLeft="200dp" | 301 | android:layout_marginLeft="200dp" |
307 | android:gravity="center_vertical" | 302 | android:gravity="center_vertical" |
308 | android:orientation="horizontal"> | 303 | android:orientation="horizontal"> |
309 | 304 | ||
310 | <LinearLayout | 305 | <LinearLayout |
311 | android:id="@+id/lineL_buy_time" | 306 | android:id="@+id/lineL_buy_time" |
312 | android:layout_width="0dp" | 307 | android:layout_width="0dp" |
313 | android:layout_height="80dp" | 308 | android:layout_height="80dp" |
314 | android:layout_weight="1" | 309 | android:layout_weight="1" |
315 | android:gravity="center_vertical"> | 310 | android:gravity="center_vertical"> |
316 | 311 | ||
317 | <TextView | 312 | <TextView |
318 | android:layout_width="wrap_content" | 313 | android:layout_width="wrap_content" |
319 | android:layout_height="wrap_content" | 314 | android:layout_height="wrap_content" |
320 | android:text="Q Q" | 315 | android:text="Q Q" |
321 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
322 | android:textSize="22sp" /> | 316 | android:textSize="22sp" /> |
323 | 317 | ||
324 | <EditText | 318 | <EditText |
325 | android:id="@+id/tv_useinfo_qq" | 319 | android:id="@+id/tv_useinfo_qq" |
326 | android:layout_width="wrap_content" | 320 | android:layout_width="wrap_content" |
327 | android:layout_height="wrap_content" | 321 | android:layout_height="wrap_content" |
328 | android:layout_marginLeft="50dp" | 322 | android:layout_marginLeft="50dp" |
329 | android:background="@null" | 323 | android:background="@null" |
330 | android:hint="请输入" | 324 | android:hint="请输入" |
331 | android:textSize="22sp" /> | 325 | android:textSize="22sp" /> |
332 | 326 | ||
333 | </LinearLayout> | 327 | </LinearLayout> |
334 | 328 | ||
335 | <LinearLayout | 329 | <LinearLayout |
336 | android:layout_width="0dp" | 330 | android:layout_width="0dp" |
337 | android:layout_height="80dp" | 331 | android:layout_height="80dp" |
338 | android:layout_weight="1" | 332 | android:layout_weight="1" |
339 | 333 | ||
340 | android:gravity="center_vertical"> | 334 | android:gravity="center_vertical"> |
341 | 335 | ||
342 | <TextView | 336 | <TextView |
343 | android:layout_width="wrap_content" | 337 | android:layout_width="wrap_content" |
344 | android:layout_height="wrap_content" | 338 | android:layout_height="wrap_content" |
345 | android:text="学校" | 339 | android:text="学校" |
346 | android:textColor="@color/pickerview_wheelview_textcolor_center" | ||
347 | android:textSize="22sp" /> | 340 | android:textSize="22sp" /> |
348 | 341 | ||
349 | <TextView | 342 | <TextView |
350 | android:id="@+id/tv_useinfo_school" | 343 | android:id="@+id/tv_useinfo_school" |
351 | android:layout_width="wrap_content" | 344 | android:layout_width="wrap_content" |
352 | android:layout_height="wrap_content" | 345 | android:layout_height="wrap_content" |
353 | android:layout_marginLeft="50dp" | 346 | android:layout_marginLeft="50dp" |
354 | android:hint="请选择" | 347 | android:hint="请选择" |
355 | android:textColor="@color/btn_text_color" | 348 | android:textColor="@color/btn_text_color" |
356 | android:textSize="22sp" /> | 349 | android:textSize="22sp" /> |
357 | 350 | ||
358 | <ImageView | 351 | <ImageView |
359 | android:layout_width="wrap_content" | 352 | android:layout_width="wrap_content" |
360 | android:layout_height="wrap_content" | 353 | android:layout_height="wrap_content" |
361 | android:layout_marginLeft="150dp" | 354 | android:layout_marginLeft="150dp" |
362 | android:src="@mipmap/xiajiantou"> | 355 | android:src="@mipmap/xiajiantou"> |
363 | 356 | ||
364 | </ImageView> | 357 | </ImageView> |
365 | </LinearLayout> | 358 | </LinearLayout> |
366 | 359 | ||
367 | </LinearLayout> | 360 | </LinearLayout> |
368 | 361 | ||
369 | <LinearLayout | 362 | <LinearLayout |
370 | android:layout_width="wrap_content" | 363 | android:layout_width="wrap_content" |
371 | android:layout_height="wrap_content" | 364 | android:layout_height="wrap_content" |
372 | android:orientation="horizontal"> | 365 | android:orientation="horizontal"> |
373 | 366 | ||
374 | <View | 367 | <View |
375 | android:layout_width="450dp" | 368 | android:layout_width="450dp" |
376 | android:layout_height="0.7dp" | 369 | android:layout_height="0.7dp" |
377 | android:layout_marginLeft="150dp" | 370 | android:layout_marginLeft="150dp" |
378 | android:background="@color/electronic_text"> | 371 | android:background="@color/cutoff_line"> |
379 | 372 | ||
380 | </View> | 373 | </View> |
381 | 374 | ||
382 | <View | 375 | <View |
383 | android:layout_width="450dp" | 376 | android:layout_width="450dp" |
384 | android:layout_height="0.7dp" | 377 | android:layout_height="0.7dp" |
385 | android:layout_marginLeft="80dp" | 378 | android:layout_marginLeft="80dp" |
386 | android:background="@color/electronic_text"> | 379 | android:background="@color/cutoff_line"> |
387 | 380 | ||
388 | </View> | 381 | </View> |
389 | 382 | ||
390 | 383 | ||
391 | </LinearLayout> | 384 | </LinearLayout> |
392 | 385 | ||
393 | </LinearLayout> | 386 | </LinearLayout> |
PersonalCenter/app/src/main/res/layout/recycler_childaccunt_item_view.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:orientation="vertical" android:layout_width="415dp" | 3 | xmlns:fresco="http://schemas.android.com/apk/res-auto" |
4 | android:orientation="vertical" | ||
5 | android:layout_width="415dp" | ||
4 | android:layout_height="match_parent"> | 6 | android:layout_height="match_parent"> |
5 | <LinearLayout | 7 | <LinearLayout |
6 | android:layout_width="wrap_content" | 8 | android:layout_width="wrap_content" |
7 | android:layout_height="wrap_content" | 9 | android:layout_height="wrap_content" |
8 | android:background="@drawable/corcle_black_bg" | 10 | android:background="@drawable/corcle_black_bg" |
9 | android:orientation="vertical"> | 11 | android:orientation="vertical"> |
10 | 12 | ||
11 | <LinearLayout | 13 | <LinearLayout |
12 | android:layout_width="wrap_content" | 14 | android:layout_width="wrap_content" |
13 | android:layout_height="wrap_content" | 15 | android:layout_height="wrap_content" |
14 | android:orientation="horizontal"> | 16 | android:orientation="horizontal"> |
15 | 17 | <com.facebook.drawee.view.SimpleDraweeView | |
16 | <ImageView | ||
17 | android:id="@+id/iv_child_head" | 18 | android:id="@+id/iv_child_head" |
18 | android:layout_width="wrap_content" | 19 | android:layout_width="60dp" |
19 | android:layout_height="wrap_content" | 20 | android:layout_height="60dp" |
20 | android:layout_margin="10dp" | 21 | android:layout_margin="10dp" |
21 | android:src="@mipmap/header_default" /> | 22 | fresco:placeholderImage="@mipmap/header_default" |
23 | fresco:roundAsCircle="true" | ||
24 | fresco:placeholderImageScaleType="fitCenter" /> | ||
25 | |||
22 | 26 | ||
23 | <LinearLayout | 27 | <LinearLayout |
24 | android:layout_width="0dp" | 28 | android:layout_width="0dp" |
25 | android:layout_height="wrap_content" | 29 | android:layout_height="wrap_content" |
26 | android:layout_marginLeft="10dp" | 30 | android:layout_marginLeft="10dp" |
27 | android:layout_marginTop="10dp" | 31 | android:layout_marginTop="10dp" |
28 | android:layout_weight="1" | 32 | android:layout_weight="1" |
29 | android:orientation="vertical"> | 33 | android:orientation="vertical"> |
30 | 34 | ||
31 | <TextView | 35 | <TextView |
32 | android:id="@+id/iv_child_name" | 36 | android:id="@+id/iv_child_name" |
33 | android:layout_width="wrap_content" | 37 | android:layout_width="wrap_content" |
34 | android:layout_height="wrap_content" | 38 | android:layout_height="wrap_content" |
35 | android:text="删除用户" | 39 | android:text="删除用户" |
36 | android:textSize="18sp" /> | 40 | android:textSize="18sp" /> |
37 | 41 | ||
38 | <TextView | 42 | <TextView |
39 | android:id="@+id/iv_child_grade" | 43 | android:id="@+id/iv_child_grade" |
40 | android:layout_width="wrap_content" | 44 | android:layout_width="wrap_content" |
41 | android:layout_height="wrap_content" | 45 | android:layout_height="wrap_content" |
42 | android:text="使用中" | 46 | android:text="使用中" |
43 | android:textSize="18sp" /> | 47 | android:textSize="18sp" /> |
44 | 48 | ||
45 | <TextView | 49 | <TextView |
46 | android:id="@+id/iv_child_school" | 50 | android:id="@+id/iv_child_school" |
47 | android:layout_width="wrap_content" | 51 | android:layout_width="wrap_content" |
48 | android:layout_height="wrap_content" | 52 | android:layout_height="wrap_content" |
49 | android:text="删除用户" | 53 | android:text="删除用户" |
50 | android:textSize="18sp" /> | 54 | android:textSize="18sp" /> |
51 | 55 | ||
52 | <TextView | 56 | <TextView |
53 | android:id="@+id/iv_child_adress" | 57 | android:id="@+id/iv_child_adress" |
54 | android:layout_width="wrap_content" | 58 | android:layout_width="wrap_content" |
55 | android:layout_height="wrap_content" | 59 | android:layout_height="wrap_content" |
56 | android:text="使用中" | 60 | android:text="使用中" |
57 | android:textSize="18sp" /> | 61 | android:textSize="18sp" /> |
58 | 62 | ||
59 | 63 | ||
60 | </LinearLayout> | 64 | </LinearLayout> |
61 | 65 | ||
62 | 66 | ||
63 | </LinearLayout> | 67 | </LinearLayout> |
64 | 68 | ||
65 | <View | 69 | <View |
66 | android:layout_width="wrap_content" | 70 | android:layout_width="wrap_content" |
67 | android:layout_height="0.7dp" | 71 | android:layout_height="0.7dp" |
68 | android:layout_margin="10dp" | 72 | android:layout_margin="10dp" |
69 | android:background="@color/cutoff_line"> | 73 | android:background="@color/cutoff_line"> |
70 | 74 | ||
71 | </View> | 75 | </View> |
72 | 76 | ||
73 | <LinearLayout | 77 | <LinearLayout |
74 | android:layout_width="match_parent" | 78 | android:layout_width="match_parent" |
75 | android:layout_height="wrap_content" | 79 | android:layout_height="wrap_content" |
76 | android:layout_marginBottom="10dp" | 80 | android:layout_marginBottom="10dp" |
77 | android:orientation="horizontal"> | 81 | android:orientation="horizontal"> |
78 | 82 | ||
79 | <TextView | 83 | <TextView |
80 | android:id="@+id/delete_child_account" | 84 | android:id="@+id/delete_child_account" |
81 | android:layout_width="0dp" | 85 | android:layout_width="0dp" |
82 | android:layout_height="wrap_content" | 86 | android:layout_height="wrap_content" |
83 | android:layout_weight="1" | 87 | android:layout_weight="1" |
84 | android:gravity="center" | 88 | android:gravity="center" |
85 | android:text="删除用户" | 89 | android:text="删除用户" |
86 | android:textSize="18sp" /> | 90 | android:textSize="18sp" /> |
87 | 91 | ||
88 | <TextView | 92 | <TextView |
89 | android:id="@+id/chang_account" | 93 | android:id="@+id/chang_account" |
90 | android:layout_width="0dp" | 94 | android:layout_width="0dp" |
91 | android:layout_height="wrap_content" | 95 | android:layout_height="wrap_content" |
92 | android:layout_weight="1" | 96 | android:layout_weight="1" |
93 | android:gravity="center" | 97 | android:gravity="center" |
94 | android:text="切换使用" | 98 | android:text="切换使用" |
95 | android:textSize="18sp" /> | 99 | android:textSize="18sp" /> |
96 | 100 | ||
97 | 101 | ||
98 | </LinearLayout> | 102 | </LinearLayout> |
99 | 103 | ||
100 | </LinearLayout> | 104 | </LinearLayout> |
101 | 105 |
PersonalCenter/app/src/main/res/layout/recycler_study_tem_view.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="120dp" | 3 | android:layout_width="120dp" |
4 | android:layout_height="120dp" | 4 | android:layout_height="120dp" |
5 | > | 5 | xmlns:fresco="http://schemas.android.com/apk/res-auto"> |
6 | 6 | <com.facebook.drawee.view.SimpleDraweeView | |
7 | <ImageView | ||
8 | android:id="@+id/id_index_gallery_item_image" | 7 | android:id="@+id/id_index_gallery_item_image" |
9 | android:layout_width="80dp" | 8 | android:layout_width="60dp" |
10 | android:layout_height="80dp" | 9 | android:layout_height="60dp" |
10 | android:scaleType="centerCrop" | ||
11 | android:layout_alignParentTop="true" | 11 | android:layout_alignParentTop="true" |
12 | android:layout_centerHorizontal="true" | 12 | android:layout_centerHorizontal="true" |
13 | android:layout_margin="5dp" | 13 | fresco:placeholderImage="@mipmap/header_default" |
14 | android:scaleType="centerCrop" /> | 14 | fresco:roundAsCircle="true" |
15 | 15 | fresco:placeholderImageScaleType="fitCenter" /> | |
16 | <TextView | 16 | <TextView |
17 | android:id="@+id/id_index_gallery_item_text" | 17 | android:id="@+id/id_index_gallery_item_text" |
18 | android:layout_width="wrap_content" | 18 | android:layout_width="wrap_content" |
19 | android:layout_height="wrap_content" | 19 | android:layout_height="wrap_content" |
20 | android:layout_below="@id/id_index_gallery_item_image" | 20 | android:layout_below="@id/id_index_gallery_item_image" |
21 | android:layout_centerHorizontal="true" | 21 | android:layout_centerHorizontal="true" |
22 | android:layout_marginBottom="5dp" | 22 | android:layout_marginBottom="5dp" |
23 | android:layout_marginTop="5dp" | 23 | android:layout_marginTop="5dp" |
24 | android:textColor="#ff0000" | 24 | android:textColor="#ff0000" |
25 | android:text="some info" | 25 | android:text="some info" |
26 | android:textSize="12dp" /> | 26 | android:textSize="12dp" /> |
27 | 27 |