Commit 0ff2ad496e55acf609a42ce8faafdcf06052728f
1 parent
dcad913bbd
Exists in
master
学校,年级,意见反馈整理和调试
Showing
25 changed files
with
1673 additions
and
21 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" |
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 | 44 | ||
44 | } | 45 | } |
45 | 46 |
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.app.Activity; | 3 | import android.content.Intent; |
4 | import android.content.pm.PackageManager; | ||
5 | import android.graphics.Color; | ||
6 | import android.net.Uri; | ||
7 | import android.os.Build; | ||
4 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.provider.MediaStore; | ||
10 | import android.support.annotation.NonNull; | ||
11 | import android.support.v4.content.FileProvider; | ||
12 | import android.support.v7.app.AppCompatActivity; | ||
13 | import android.view.Gravity; | ||
14 | import android.view.View; | ||
15 | import android.widget.AdapterView; | ||
16 | import android.widget.EditText; | ||
17 | import android.widget.ImageView; | ||
18 | import android.widget.TextView; | ||
19 | import android.widget.Toast; | ||
5 | 20 | ||
21 | import com.facebook.drawee.backends.pipeline.Fresco; | ||
22 | import com.facebook.drawee.generic.GenericDraweeHierarchy; | ||
23 | import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; | ||
24 | import com.facebook.drawee.generic.RoundingParams; | ||
25 | import com.facebook.drawee.interfaces.DraweeController; | ||
26 | import com.facebook.drawee.view.SimpleDraweeView; | ||
6 | import com.hjx.personalcenter.R; | 27 | import com.hjx.personalcenter.R; |
28 | import com.hjx.personalcenter.util.CropUtils; | ||
29 | import com.hjx.personalcenter.util.DialogPermission; | ||
30 | import com.hjx.personalcenter.util.FileUtil; | ||
31 | import com.hjx.personalcenter.util.PermissionUtil; | ||
32 | import com.hjx.personalcenter.util.SharedPreferenceMark; | ||
33 | import com.mylhyl.circledialog.CircleDialog; | ||
34 | import com.mylhyl.circledialog.callback.ConfigButton; | ||
35 | import com.mylhyl.circledialog.callback.ConfigDialog; | ||
36 | import com.mylhyl.circledialog.params.ButtonParams; | ||
37 | import com.mylhyl.circledialog.params.DialogParams; | ||
38 | |||
39 | import java.io.File; | ||
7 | 40 | ||
8 | /** | 41 | /** |
9 | * Created by h on 2017/8/11. | 42 | * Created by h on 2017/8/11. |
10 | */ | 43 | */ |
11 | 44 | ||
12 | public class FeedBackActivity extends Activity{ | 45 | public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener { |
46 | private ImageView iv_cance,iv_show,iv_take; | ||
47 | private EditText content, phone; | ||
48 | private TextView tv_sub; | ||
49 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; | ||
50 | private static final int REQUEST_CODE_ALBUM = 2; | ||
51 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; | ||
52 | SimpleDraweeView mSimpleDraweeView; | ||
53 | private File file; | ||
54 | private Uri uri; | ||
13 | @Override | 55 | @Override |
14 | protected void onCreate(Bundle savedInstanceState) { | 56 | protected void onCreate(Bundle savedInstanceState) { |
15 | super.onCreate(savedInstanceState); | 57 | super.onCreate(savedInstanceState); |
58 | Fresco.initialize(this); | ||
16 | setContentView(R.layout.activity_feedback); | 59 | setContentView(R.layout.activity_feedback); |
60 | initView(); | ||
61 | initData(); | ||
62 | initLister(); | ||
63 | } | ||
64 | |||
65 | private void initView() { | ||
66 | iv_cance = (ImageView) findViewById(R.id.cancel); | ||
67 | mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv); | ||
68 | iv_take = (ImageView) findViewById(R.id.iv_take); | ||
69 | content = (EditText) findViewById(R.id.feedback_content); | ||
70 | phone = (EditText) findViewById(R.id.feedback_phone); | ||
71 | tv_sub = (TextView) findViewById(R.id.feedback_sub); | ||
72 | |||
73 | } | ||
74 | |||
75 | private void initData() { | ||
76 | file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | ||
77 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | ||
78 | uri = Uri.fromFile(file); | ||
79 | } else { | ||
80 | //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问) | ||
81 | uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file); | ||
82 | } | ||
83 | |||
84 | } | ||
85 | |||
86 | private void initLister() { | ||
87 | iv_cance.setOnClickListener(this); | ||
88 | iv_take.setOnClickListener(this); | ||
89 | tv_sub.setOnClickListener(this); | ||
90 | |||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public void onClick(View v) { | ||
95 | switch (v.getId()){ | ||
96 | case R.id.cancel: | ||
97 | finish(); | ||
98 | break; | ||
99 | case R.id.iv_take: | ||
100 | choiceAvatar(); | ||
101 | break; | ||
102 | case R.id.feedback_sub: | ||
103 | break; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | //拍摄头像 | ||
108 | private void choiceAvatar() { | ||
109 | final String[] items = {"拍照", "从相册选择"}; | ||
110 | new CircleDialog.Builder(this) | ||
111 | .configDialog(new ConfigDialog() { | ||
112 | @Override | ||
113 | public void onConfig(DialogParams params) { | ||
114 | //增加弹出动画 | ||
115 | params.gravity = Gravity.CENTER; | ||
116 | } | ||
117 | }) | ||
118 | .setTitle("请选择图片来源") | ||
119 | .setWidth(0.5f) | ||
120 | .setItems(items, new AdapterView.OnItemClickListener() { | ||
121 | @Override | ||
122 | public void onItemClick(AdapterView<?> parent, View view, int | ||
123 | position, long id) { | ||
124 | switch (position){ | ||
125 | case 0: | ||
126 | if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) { | ||
127 | uploadAvatarFromPhotoRequest(); | ||
128 | } | ||
129 | break; | ||
130 | case 1: | ||
131 | uploadAvatarFromAlbumRequest(); | ||
132 | break; | ||
133 | } | ||
134 | |||
135 | } | ||
136 | }) | ||
137 | .setNegative("取消", null) | ||
138 | .configNegative(new ConfigButton() { | ||
139 | @Override | ||
140 | public void onConfig(ButtonParams params) { | ||
141 | //取消按钮字体颜色 | ||
142 | params.textColor = Color.RED; | ||
143 | } | ||
144 | }) | ||
145 | .show(); | ||
146 | |||
147 | |||
148 | } | ||
149 | //照相 | ||
150 | private void uploadAvatarFromPhotoRequest() { | ||
151 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | ||
152 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||
153 | intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); | ||
154 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); | ||
155 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); | ||
156 | } | ||
157 | |||
158 | //选择图库 | ||
159 | private void uploadAvatarFromAlbumRequest() { | ||
160 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | ||
161 | photoPickerIntent.setType("image/*"); | ||
162 | startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM); | ||
163 | } | ||
164 | //回掉 | ||
165 | @Override | ||
166 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
167 | super.onActivityResult(requestCode, resultCode, data); | ||
168 | if (resultCode != -1) { | ||
169 | return; | ||
170 | } | ||
171 | if (requestCode == REQUEST_CODE_ALBUM && data != null) { | ||
172 | Uri newUri; | ||
173 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | ||
174 | newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData())); | ||
175 | } else { | ||
176 | newUri = data.getData(); | ||
177 | } | ||
178 | if (newUri != null) { | ||
179 | startPhotoZoom(newUri); | ||
180 | } else { | ||
181 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); | ||
182 | } | ||
183 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { | ||
184 | startPhotoZoom(uri); | ||
185 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { | ||
186 | uploadAvatarFromPhoto(); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | private void uploadAvatarFromPhoto() { | ||
191 | compressAndUploadAvatar(file.getPath()); | ||
192 | |||
193 | } | ||
194 | private void compressAndUploadAvatar(String fileSrc) { | ||
195 | |||
196 | |||
197 | //上传到服务器 | ||
198 | |||
199 | final File cover = FileUtil.getSmallBitmap(this, fileSrc); | ||
200 | String mimeType = "image/*"; | ||
201 | //requestBody = RequestBody.create(MediaType.parse(mimeType), file); | ||
202 | //String fileName = cover.getName(); | ||
203 | //HttpManager.getInstance().header(this, fileSrc); | ||
204 | //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | ||
205 | //Fresco设置圆形头像 | ||
206 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); | ||
207 | GenericDraweeHierarchy hierarchy = builder | ||
208 | .setDesiredAspectRatio(1f) | ||
209 | .setFailureImage(R.mipmap.blank) | ||
210 | //圆形头像 | ||
211 | .setRoundingParams(RoundingParams.asCircle()) | ||
212 | .build(); | ||
213 | |||
214 | //加载本地图片 | ||
215 | Uri uri = Uri.fromFile(cover); | ||
216 | DraweeController controller = Fresco.newDraweeControllerBuilder() | ||
217 | .setOldController(mSimpleDraweeView.getController()) | ||
218 | .setUri(uri) | ||
219 | .build(); | ||
220 | mSimpleDraweeView.setHierarchy(hierarchy); | ||
221 | mSimpleDraweeView.setController(controller); | ||
222 | |||
223 | } | ||
224 | |||
225 | public void startPhotoZoom(Uri uri) { | ||
226 | Intent intent = new Intent("com.android.camera.action.CROP"); | ||
227 | intent.setDataAndType(uri, "image/*"); | ||
228 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||
229 | intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面. | ||
230 | intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例. | ||
231 | intent.putExtra("aspectY", 1);// x:y=1:1 | ||
232 | // intent.putExtra("outputX", 400);//图片输出大小 | ||
233 | // intent.putExtra("outputY", 400); | ||
234 | intent.putExtra("output", Uri.fromFile(file)); | ||
235 | intent.putExtra("outputFormat", "JPEG");// 返回格式 | ||
236 | startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO); | ||
237 | } | ||
238 | |||
239 | @Override | ||
240 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
241 | switch (requestCode) { | ||
242 | |||
243 | case PermissionUtil.REQUEST_SHOWCAMERA: | ||
244 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||
245 | // Permission Granted | ||
246 | uploadAvatarFromPhotoRequest(); | ||
247 | |||
248 | } else { | ||
249 | if (!SharedPreferenceMark.getHasShowCamera()) { | ||
250 | SharedPreferenceMark.setHasShowCamera(true); | ||
251 | new DialogPermission(this, "关闭摄像头权限影响扫描功能"); | ||
252 | |||
253 | } else { | ||
254 | Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT) | ||
255 | .show(); | ||
256 | } | ||
257 | } | ||
258 | break; | ||
259 | default: | ||
260 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
261 | } | ||
17 | } | 262 | } |
18 | } | 263 | } |
19 | 264 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MyApplication.java
File was created | 1 | package com.hjx.personalcenter.activity; | |
2 | |||
3 | import android.app.Application; | ||
4 | import android.content.Context; | ||
5 | |||
6 | import com.facebook.drawee.backends.pipeline.Fresco; | ||
7 | import com.hjx.personalcenter.util.ImageCache; | ||
8 | import com.tencent.bugly.crashreport.CrashReport; | ||
9 | |||
10 | /** | ||
11 | * Created by ${yf} on 2017/2/16. | ||
12 | */ | ||
13 | |||
14 | public class MyApplication extends Application { | ||
15 | |||
16 | private ImageCache mImageCache; | ||
17 | private static Context context; | ||
18 | private static MyApplication instance; | ||
19 | @Override | ||
20 | public void onCreate() { | ||
21 | super.onCreate(); | ||
22 | context = getApplicationContext(); | ||
23 | //初始化Fresco | ||
24 | Fresco.initialize(this); | ||
25 | mImageCache = new ImageCache(); | ||
26 | instance = this; | ||
27 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); | ||
28 | } | ||
29 | public ImageCache getImageCache() { | ||
30 | return mImageCache; | ||
31 | } | ||
32 | |||
33 | public static Context getContext() { | ||
34 | return context; | ||
35 | } | ||
36 | public static MyApplication getInstance() { | ||
37 | return instance; | ||
38 | } | ||
39 | } | ||
40 |
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; | ||
7 | import android.view.KeyEvent; | ||
6 | import android.view.View; | 8 | import android.view.View; |
7 | import android.widget.AdapterView; | 9 | import android.widget.AdapterView; |
8 | import android.widget.Button; | 10 | import android.widget.Button; |
9 | import android.widget.EditText; | 11 | import android.widget.EditText; |
10 | import android.widget.TextView; | 12 | import android.widget.TextView; |
11 | 13 | ||
12 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
13 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 15 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
14 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 16 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
17 | import com.hjx.personalcenter.customdialog.SchoolListDialog; | ||
15 | import com.hjx.personalcenter.http.HttpManager; | 18 | import com.hjx.personalcenter.http.HttpManager; |
16 | import com.hjx.personalcenter.interfaces.DialogCallBack; | 19 | import com.hjx.personalcenter.interfaces.DialogCallBack; |
20 | import com.hjx.personalcenter.util.AlertUtils; | ||
17 | 21 | ||
18 | /**填写注册信息 熊巍 | 22 | /**填写注册信息 熊巍 |
19 | * Created by h on 2017/8/9. | 23 | * Created by h on 2017/8/9. |
20 | */ | 24 | */ |
21 | 25 | ||
22 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.CallBack { | 26 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.CallBack { |
23 | private EditText et_username; | 27 | private EditText et_username; |
24 | private TextView et_region,et_grade,et_school; | 28 | private TextView et_region,et_grade,et_school; |
25 | private Button btn_ok; | 29 | private Button btn_ok; |
26 | String[] items; | ||
27 | 30 | ||
28 | @Override | 31 | @Override |
29 | protected void onCreate(Bundle savedInstanceState) { | 32 | protected void onCreate(Bundle savedInstanceState) { |
30 | super.onCreate(savedInstanceState); | 33 | super.onCreate(savedInstanceState); |
31 | setContentView(R.layout.activity_registerinfo); | 34 | setContentView(R.layout.activity_registerinfo); |
32 | initView(); | 35 | initView(); |
33 | initData(); | 36 | initData(); |
34 | initLister(); | 37 | initLister(); |
35 | } | 38 | } |
36 | 39 | ||
37 | private void initView() { | 40 | private void initView() { |
38 | et_username = (EditText) findViewById(R.id.et_username); | 41 | et_username = (EditText) findViewById(R.id.et_username); |
39 | et_region = (TextView) findViewById(R.id.et_region); | 42 | et_region = (TextView) findViewById(R.id.et_region); |
40 | et_grade = (TextView) findViewById(R.id.et_grade); | 43 | et_grade = (TextView) findViewById(R.id.et_grade); |
41 | et_school = (TextView) findViewById(R.id.et_school); | 44 | et_school = (TextView) findViewById(R.id.et_school); |
42 | btn_ok = (Button) findViewById(R.id.btn_ok); | 45 | btn_ok = (Button) findViewById(R.id.btn_ok); |
43 | 46 | ||
44 | 47 | ||
45 | } | 48 | } |
46 | 49 | ||
47 | private void initData() { | 50 | private void initData() { |
48 | items = new String[] { "魏", "蜀", "吴" }; | ||
49 | 51 | ||
50 | } | 52 | } |
51 | 53 | ||
52 | private void initLister() { | 54 | private void initLister() { |
53 | et_region.setOnClickListener(this); | 55 | et_region.setOnClickListener(this); |
54 | et_grade.setOnClickListener(this); | 56 | et_grade.setOnClickListener(this); |
55 | et_school.setOnClickListener(this); | 57 | et_school.setOnClickListener(this); |
56 | btn_ok.setOnClickListener(this); | 58 | btn_ok.setOnClickListener(this); |
57 | 59 | ||
58 | 60 | ||
59 | } | 61 | } |
60 | 62 | ||
61 | @Override | 63 | @Override |
62 | public void onClick(View v) { | 64 | public void onClick(View v) { |
65 | String register1 = et_username.getText().toString().trim(); | ||
66 | String register2 = et_region.getText().toString().trim(); | ||
67 | String register3 = et_grade.getText().toString().trim(); | ||
68 | String register4 = et_school.getText().toString().trim(); | ||
63 | switch (v.getId()){ | 69 | switch (v.getId()){ |
64 | case R.id.et_region: | 70 | case R.id.et_region: |
65 | choiseregion(); | 71 | choiseregion(); |
66 | break; | 72 | break; |
67 | case R.id.et_grade: | 73 | case R.id.et_grade: |
68 | choisegrade(); | 74 | choisegrade(); |
69 | break; | 75 | break; |
70 | case R.id.et_school: | 76 | case R.id.et_school: |
77 | if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ | ||
78 | AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址"); | ||
79 | return; | ||
80 | }else { | ||
81 | choiseschool(); | ||
82 | } | ||
83 | |||
71 | break; | 84 | break; |
72 | case R.id.btn_ok: | 85 | case R.id.btn_ok: |
73 | Intent intent = new Intent(); | 86 | if (TextUtils.isEmpty(register1)||TextUtils.isEmpty(register4) || |
74 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 87 | TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){ |
75 | startActivity(intent); | 88 | AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整"); |
76 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 89 | return; |
90 | }else{ | ||
91 | Intent intent = new Intent(); | ||
92 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | ||
93 | startActivity(intent); | ||
94 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | ||
95 | } | ||
96 | |||
77 | break; | 97 | break; |
78 | } | 98 | } |
79 | 99 | ||
80 | } | 100 | } |
81 | //选择地区 | 101 | |
102 | //选择地区 | ||
82 | private void choiseregion() { | 103 | private void choiseregion() { |
83 | HttpManager.getInstance().provices(RegisterInfoActivity.this); | 104 | HttpManager.getInstance().provices(RegisterInfoActivity.this); |
84 | ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog"); | 105 | ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
85 | // HttpManager.getInstance().cityinfo(RegisterInfoActivity.this,111); | 106 | // HttpManager.getInstance().cityinfo(RegisterInfoActivity.this,111); |
86 | // CitysListDialog.getInstance(this).show(getSupportFragmentManager(), "CitysListDialog"); | 107 | // CitysListDialog.getInstance(this).show(getSupportFragmentManager(), "CitysListDialog"); |
87 | 108 | ||
88 | } | 109 | } |
89 | //选择年级 | 110 | //选择年级 |
90 | private void choisegrade() { | 111 | private void choisegrade() { |
112 | HttpManager.getInstance().getgrade(RegisterInfoActivity.this); | ||
91 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); | 113 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); |
92 | 114 | ||
93 | } | 115 | } |
116 | //选择学校 | ||
117 | private void choiseschool() { | ||
118 | HttpManager.getInstance().getschool(RegisterInfoActivity.this,130102,14); | ||
119 | SchoolListDialog.getInstance().show(getSupportFragmentManager(), "SchoolListDialog"); | ||
120 | |||
121 | } | ||
122 | |||
94 | 123 | ||
95 | @Override | 124 | @Override |
96 | public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id) { | 125 | public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id) { |
97 | 126 | ||
98 | View gradeView = parent.getChildAt(position); | 127 | View gradeView = parent.getChildAt(position); |
99 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); | 128 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); |
100 | et_region.setText(gradeTv.getText().toString()); | 129 | et_region.setText(gradeTv.getText().toString()); |
101 | 130 | ||
102 | 131 | ||
103 | } | 132 | } |
133 | @Override | ||
134 | public boolean onKeyUp(int keyCode, KeyEvent event) { | ||
135 | if (keyCode == KeyEvent.KEYCODE_BACK) { | ||
136 | finish(); | ||
137 | |||
138 | } | ||
139 | return super.onKeyUp(keyCode, event); | ||
140 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GrandeAdapter.java
File was created | 1 | package com.hjx.personalcenter.adapter; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.view.View; | ||
5 | import android.view.ViewGroup; | ||
6 | import android.widget.BaseAdapter; | ||
7 | import android.widget.TextView; | ||
8 | |||
9 | import com.hjx.personalcenter.R; | ||
10 | import com.hjx.personalcenter.model.GradeInfo; | ||
11 | |||
12 | import java.util.ArrayList; | ||
13 | |||
14 | /** | ||
15 | * Created by h on 2017/8/21. | ||
16 | */ | ||
17 | |||
18 | public class GrandeAdapter extends BaseAdapter{ | ||
19 | ArrayList<GradeInfo.DataBean> objects; | ||
20 | private Context context; | ||
21 | |||
22 | public GrandeAdapter(ArrayList<GradeInfo.DataBean> objects, Context context) { | ||
23 | this.objects = objects; | ||
24 | this.context = context; | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public int getCount() { | ||
29 | return objects.size(); | ||
30 | } | ||
31 | |||
32 | @Override | ||
33 | public Object getItem(int position) { | ||
34 | return position; | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | public long getItemId(int position) { | ||
39 | return position; | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | public View getView(final int position, View convertView, ViewGroup parent) { | ||
44 | |||
45 | ProvincesAdapter.ViewHolder holder = null; | ||
46 | |||
47 | if (convertView == null) { | ||
48 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); | ||
49 | holder = new ProvincesAdapter.ViewHolder(); | ||
50 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); | ||
51 | convertView.setTag(holder); | ||
52 | } else { | ||
53 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); | ||
54 | } | ||
55 | |||
56 | holder.nameText.setText(objects.get(position).getName()); | ||
57 | |||
58 | return convertView; | ||
59 | } | ||
60 | |||
61 | |||
62 | static class ViewHolder { | ||
63 | TextView nameText; | ||
64 | } | ||
65 | } | ||
66 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/SchoolAdapter.java
File was created | 1 | package com.hjx.personalcenter.adapter; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.view.View; | ||
5 | import android.view.ViewGroup; | ||
6 | import android.widget.BaseAdapter; | ||
7 | import android.widget.Filter; | ||
8 | import android.widget.Filterable; | ||
9 | import android.widget.TextView; | ||
10 | |||
11 | import com.hjx.personalcenter.R; | ||
12 | import com.hjx.personalcenter.model.SchoolInfo; | ||
13 | |||
14 | import java.util.ArrayList; | ||
15 | import java.util.List; | ||
16 | |||
17 | /** | ||
18 | * Created by h on 2017/8/21. | ||
19 | */ | ||
20 | |||
21 | public class SchoolAdapter extends BaseAdapter implements Filterable { | ||
22 | private List<SchoolInfo.DataBean> mDatas; | ||
23 | ArrayList<SchoolInfo.DataBean> objects; | ||
24 | private Context context; | ||
25 | private final Object mLock = new Object(); | ||
26 | private ArrayFilter mFilter; | ||
27 | |||
28 | public SchoolAdapter(ArrayList<SchoolInfo.DataBean> objects, Context context) { | ||
29 | this.objects = objects; | ||
30 | this.context = context; | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public int getCount() { | ||
35 | return objects.size(); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public Object getItem(int position) { | ||
40 | return position; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public long getItemId(int position) { | ||
45 | return position; | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public View getView(final int position, View convertView, ViewGroup parent) { | ||
50 | |||
51 | ProvincesAdapter.ViewHolder holder = null; | ||
52 | |||
53 | if (convertView == null) { | ||
54 | convertView = View.inflate(context, R.layout.custom_adilog_school_list_items, null); | ||
55 | holder = new ProvincesAdapter.ViewHolder(); | ||
56 | holder.nameText = (TextView) convertView.findViewById(R.id.list_school_items); | ||
57 | convertView.setTag(holder); | ||
58 | } else { | ||
59 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); | ||
60 | } | ||
61 | |||
62 | holder.nameText.setText(objects.get(position).getSchoolName()); | ||
63 | |||
64 | return convertView; | ||
65 | } | ||
66 | |||
67 | @Override | ||
68 | public Filter getFilter() { | ||
69 | if (mFilter == null) { | ||
70 | mFilter = new ArrayFilter(); | ||
71 | } | ||
72 | return mFilter; | ||
73 | } | ||
74 | |||
75 | |||
76 | static class ViewHolder { | ||
77 | TextView nameText; | ||
78 | } | ||
79 | private class ArrayFilter extends Filter { | ||
80 | //执行刷选 | ||
81 | @Override | ||
82 | protected FilterResults performFiltering(CharSequence prefix) { | ||
83 | FilterResults results = new FilterResults();//过滤的结果 | ||
84 | //原始数据备份为空时,上锁,同步复制原始数据 | ||
85 | if (objects == null) { | ||
86 | synchronized (mLock) { | ||
87 | objects = new ArrayList<>(mDatas); | ||
88 | } | ||
89 | } | ||
90 | //当首字母为空时 | ||
91 | if (prefix == null || prefix.length() == 0) { | ||
92 | ArrayList<SchoolInfo.DataBean> list; | ||
93 | synchronized (mLock) {//同步复制一个原始备份数据 | ||
94 | list = new ArrayList<>(objects); | ||
95 | } | ||
96 | results.values = list; | ||
97 | results.count = list.size();//此时返回的results就是原始的数据,不进行过滤 | ||
98 | } else { | ||
99 | String prefixString = prefix.toString().toLowerCase();//转化为小写 | ||
100 | |||
101 | ArrayList<SchoolInfo.DataBean> values; | ||
102 | synchronized (mLock) {//同步复制一个原始备份数据 | ||
103 | values = new ArrayList<>(objects); | ||
104 | } | ||
105 | final int count = values.size(); | ||
106 | final ArrayList<SchoolInfo.DataBean> newValues = new ArrayList<>(); | ||
107 | |||
108 | for (int i = 0; i < count; i++) { | ||
109 | final SchoolInfo.DataBean value = values.get(i);//从List<User>中拿到User对象 | ||
110 | // final String valueText = value.toString().toLowerCase(); | ||
111 | final String valueText = value.getSchoolName().toString().toLowerCase();//User对象的name属性作为过滤的参数 | ||
112 | // First match against the whole, non-splitted value | ||
113 | if (valueText.startsWith(prefixString) || valueText.indexOf(prefixString.toString()) != -1) {//第一个字符是否匹配 | ||
114 | newValues.add(value);//将这个item加入到数组对象中 | ||
115 | } else {//处理首字符是空格 | ||
116 | final String[] words = valueText.split(" "); | ||
117 | final int wordCount = words.length; | ||
118 | |||
119 | // Start at index 0, in case valueText starts with space(s) | ||
120 | for (int k = 0; k < wordCount; k++) { | ||
121 | if (words[k].startsWith(prefixString)) {//一旦找到匹配的就break,跳出for循环 | ||
122 | newValues.add(value); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | results.values = newValues;//此时的results就是过滤后的List<User>数组 | ||
129 | results.count = newValues.size(); | ||
130 | } | ||
131 | return results; | ||
132 | } | ||
133 | |||
134 | //刷选结果 | ||
135 | @Override | ||
136 | protected void publishResults(CharSequence prefix, FilterResults results) { | ||
137 | //noinspection unchecked | ||
138 | mDatas = (List<SchoolInfo.DataBean>) results.values;//此时,Adapter数据源就是过滤后的Results | ||
139 | if (results.count > 0) { | ||
140 | notifyDataSetChanged();//这个相当于从mDatas中删除了一些数据,只是数据的变化,故使用notifyDataSetChanged() | ||
141 | } else { | ||
142 | /** | ||
143 | * 数据容器变化 ----> notifyDataSetInValidated | ||
144 | |||
145 | 容器中的数据变化 ----> notifyDataSetChanged | ||
146 | */ | ||
147 | notifyDataSetInvalidated();//当results.count<=0时,此时数据源就是重新new出来的,说明原始的数据源已经失效了 | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.view.Gravity; | 6 | import android.view.Gravity; |
7 | import android.view.LayoutInflater; | 7 | import android.view.LayoutInflater; |
8 | import android.view.View; | 8 | import android.view.View; |
9 | import android.view.ViewGroup; | 9 | import android.view.ViewGroup; |
10 | import android.widget.AdapterView; | 10 | import android.widget.AdapterView; |
11 | import android.widget.ArrayAdapter; | ||
12 | import android.widget.ListView; | 11 | import android.widget.ListView; |
13 | import android.widget.Toast; | 12 | import android.widget.Toast; |
14 | 13 | ||
15 | import com.hjx.personalcenter.R; | 14 | import com.hjx.personalcenter.R; |
15 | import com.hjx.personalcenter.adapter.GrandeAdapter; | ||
16 | import com.hjx.personalcenter.db.SaveParam; | ||
17 | import com.hjx.personalcenter.http.HttpManager; | ||
18 | import com.hjx.personalcenter.model.GradeInfo; | ||
16 | import com.mylhyl.circledialog.BaseCircleDialog; | 19 | import com.mylhyl.circledialog.BaseCircleDialog; |
17 | import com.mylhyl.circledialog.res.values.CircleDimen; | 20 | import com.mylhyl.circledialog.res.values.CircleDimen; |
18 | 21 | ||
19 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
20 | 23 | ||
21 | /**自定义年级列表对话框 | 24 | /**自定义年级列表对话框 |
22 | * Created by h on 2017/8/10. | 25 | * Created by h on 2017/8/10. |
23 | */ | 26 | */ |
24 | 27 | ||
25 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 28 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
26 | ArrayAdapter listadapter; | 29 | private GrandeAdapter listadapter; |
27 | ListView listView; | 30 | private ListView listView; |
28 | ArrayList<String> data = new ArrayList<>(); | 31 | ArrayList<GradeInfo.DataBean> data = new ArrayList<>(); |
29 | public static GradeListDialog getInstance() { | 32 | public static GradeListDialog getInstance() { |
30 | GradeListDialog dialogFragment = new GradeListDialog(); | 33 | GradeListDialog dialogFragment = new GradeListDialog(); |
31 | dialogFragment.setCanceledBack(true); | 34 | dialogFragment.setCanceledBack(true); |
32 | dialogFragment.setCanceledOnTouchOutside(true); | 35 | dialogFragment.setCanceledOnTouchOutside(true); |
33 | dialogFragment.setRadius(CircleDimen.RADIUS); | 36 | dialogFragment.setRadius(CircleDimen.RADIUS); |
34 | dialogFragment.setWidth(0.5f); | 37 | dialogFragment.setWidth(0.5f); |
35 | dialogFragment.setGravity(Gravity.CENTER); | 38 | dialogFragment.setGravity(Gravity.CENTER); |
36 | dialogFragment.setBackgroundColor(Color.WHITE); | 39 | dialogFragment.setBackgroundColor(Color.WHITE); |
37 | return dialogFragment; | 40 | return dialogFragment; |
38 | } | 41 | } |
39 | @Override | 42 | @Override |
40 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 43 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
41 | 44 | ||
42 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); | 45 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); |
43 | } | 46 | } |
44 | @Override | 47 | @Override |
45 | public void onActivityCreated(Bundle savedInstanceState) { | 48 | public void onActivityCreated(Bundle savedInstanceState) { |
46 | super.onActivityCreated(savedInstanceState); | 49 | super.onActivityCreated(savedInstanceState); |
47 | listView = (ListView) getView().findViewById(R.id.listadapter); | 50 | listView = (ListView) getView().findViewById(R.id.listadapter); |
48 | for (int i=0;i<=50;i++){ | 51 | String gradens = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS); |
49 | data.add("sss"+i); | 52 | if (gradens != null) { |
50 | } | ||
51 | 53 | ||
52 | listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); | 54 | for (int i = 0; i < gradens.split(",").length; i++) { |
55 | GradeInfo.DataBean dataBean = new GradeInfo.DataBean(); | ||
56 | dataBean.setName(gradens.split(",")[i]); | ||
57 | data.add(dataBean); | ||
58 | } | ||
59 | } else { | ||
60 | HttpManager.getInstance().getgrade(getActivity()); | ||
61 | } | ||
62 | listadapter = new GrandeAdapter(data,getActivity()); | ||
53 | listView.setAdapter(listadapter); | 63 | listView.setAdapter(listadapter); |
54 | listView.setOnItemClickListener(this); | 64 | listView.setOnItemClickListener(this); |
55 | 65 | ||
56 | } | 66 | } |
57 | 67 | ||
58 | @Override | 68 | @Override |
59 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 69 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
60 | 70 | ||
61 | Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); | 71 | Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); |
62 | 72 | ||
63 | dismiss(); | 73 | dismiss(); |
64 | 74 | ||
65 | } | 75 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/SchoolListDialog.java
File was created | 1 | package com.hjx.personalcenter.customdialog; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.graphics.Color; | ||
5 | import android.os.Bundle; | ||
6 | import android.text.Editable; | ||
7 | import android.text.TextWatcher; | ||
8 | import android.view.Gravity; | ||
9 | import android.view.LayoutInflater; | ||
10 | import android.view.View; | ||
11 | import android.view.ViewGroup; | ||
12 | import android.widget.AdapterView; | ||
13 | import android.widget.EditText; | ||
14 | import android.widget.ListView; | ||
15 | |||
16 | import com.hjx.personalcenter.R; | ||
17 | import com.hjx.personalcenter.adapter.SchoolAdapter; | ||
18 | import com.hjx.personalcenter.db.SaveParam; | ||
19 | import com.hjx.personalcenter.http.HttpManager; | ||
20 | import com.hjx.personalcenter.interfaces.DialogCallBack; | ||
21 | import com.hjx.personalcenter.model.SchoolInfo; | ||
22 | import com.mylhyl.circledialog.BaseCircleDialog; | ||
23 | import com.mylhyl.circledialog.res.values.CircleDimen; | ||
24 | |||
25 | import java.util.ArrayList; | ||
26 | |||
27 | /** | ||
28 | * Created by h on 2017/8/21. | ||
29 | */ | ||
30 | |||
31 | public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener, View.OnClickListener { | ||
32 | private ListView school_list; | ||
33 | private EditText school_sech; | ||
34 | private SchoolAdapter listadapter; | ||
35 | private View mView; | ||
36 | boolean isFilter; | ||
37 | private DialogCallBack.CallBackView mCallBack; | ||
38 | ArrayList<SchoolInfo.DataBean> data = new ArrayList<>(); | ||
39 | |||
40 | // public SchoolListDialog(DialogCallBack.CallBackView callBack) { | ||
41 | // this.mCallBack = callBack; | ||
42 | // } | ||
43 | |||
44 | public static SchoolListDialog getInstance() { | ||
45 | SchoolListDialog dialogFragment = new SchoolListDialog(); | ||
46 | dialogFragment.setCanceledBack(true); | ||
47 | dialogFragment.setCanceledOnTouchOutside(true); | ||
48 | dialogFragment.setRadius(CircleDimen.RADIUS); | ||
49 | dialogFragment.setWidth(0.5f); | ||
50 | dialogFragment.setGravity(Gravity.CENTER); | ||
51 | dialogFragment.setBackgroundColor(Color.WHITE); | ||
52 | return dialogFragment; | ||
53 | } | ||
54 | |||
55 | @Override | ||
56 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | ||
57 | |||
58 | if (mView == null) { | ||
59 | mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false); | ||
60 | //mCallBack.provinceOnItemClick(context, inflater, container); | ||
61 | } | ||
62 | return mView; | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | public void onActivityCreated(Bundle savedInstanceState) { | ||
67 | super.onActivityCreated(savedInstanceState); | ||
68 | school_list = (ListView) getView().findViewById(R.id.listschooladapter); | ||
69 | school_sech = (EditText) getView().findViewById(R.id.et_school_sech); | ||
70 | String gradens = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOL); | ||
71 | if (gradens != null) { | ||
72 | |||
73 | for (int i = 0; i < gradens.split(",").length; i++) { | ||
74 | SchoolInfo.DataBean dataBean = new SchoolInfo.DataBean(); | ||
75 | dataBean.setSchoolName(gradens.split(",")[i]); | ||
76 | data.add(dataBean); | ||
77 | } | ||
78 | } else { | ||
79 | HttpManager.getInstance().getschool(getActivity(),130102,14); | ||
80 | } | ||
81 | listadapter = new SchoolAdapter(data, getActivity()); | ||
82 | school_list.setAdapter(listadapter); | ||
83 | school_list.setOnItemClickListener(this); | ||
84 | school_sech.setOnClickListener(this); | ||
85 | intiEditView(); | ||
86 | |||
87 | |||
88 | } | ||
89 | private void intiEditView() { | ||
90 | school_sech.addTextChangedListener(new TextWatcher() { | ||
91 | @Override | ||
92 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | ||
93 | |||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public void onTextChanged(CharSequence s, int start, int before, int count) { | ||
98 | // mAdapter.getFilter().filter(s); | ||
99 | |||
100 | listadapter.getFilter().filter(s); | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public void afterTextChanged(Editable s) { | ||
105 | |||
106 | } | ||
107 | }); | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public void onClick(View v) { | ||
112 | |||
113 | } | ||
114 | |||
115 | @Override | ||
116 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
117 | |||
118 | } | ||
119 | } | ||
120 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
1 | package com.hjx.personalcenter.db; | 1 | package com.hjx.personalcenter.db; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.content.SharedPreferences; | 5 | import android.content.SharedPreferences; |
6 | 6 | ||
7 | public class SaveParam { | 7 | public class SaveParam { |
8 | 8 | ||
9 | private static SaveParam instance; | 9 | private static SaveParam instance; |
10 | public static SaveParam getInstance(){ | 10 | public static SaveParam getInstance(){ |
11 | if (instance==null){ | 11 | if (instance==null){ |
12 | instance = new SaveParam(); | 12 | instance = new SaveParam(); |
13 | } | 13 | } |
14 | return instance; | 14 | return instance; |
15 | } | 15 | } |
16 | //个人信息 | 16 | //个人信息 |
17 | public static String GRADENS = "gradens";//年级 | ||
18 | public static String SCHOOL = "school";//学校 | ||
19 | |||
17 | //电子保卡信息 | 20 | //电子保卡信息 |
18 | public static String CARDPHONE = "cardphone";//保卡手机号 | 21 | public static String CARDPHONE = "cardphone";//保卡手机号 |
19 | public static String CUNSTEMNAME = "cunstemname";//客户姓名 | 22 | public static String CUNSTEMNAME = "cunstemname";//客户姓名 |
20 | public static String ADRESSCUNSTEM = "adresscunstem";//客户地址 | 23 | public static String ADRESSCUNSTEM = "adresscunstem";//客户地址 |
21 | public static String SHOPTIME = "shoptime";//购买时间 | 24 | public static String SHOPTIME = "shoptime";//购买时间 |
22 | public static String SHOPADRESS = "shopadress";//购买地址 | 25 | public static String SHOPADRESS = "shopadress";//购买地址 |
23 | public static String SHOPTLEPHONE = "shoptlephone";//售后电话 | 26 | public static String SHOPTLEPHONE = "shoptlephone";//售后电话 |
24 | 27 | ||
25 | //省市区参数 | 28 | //省市区参数、 |
26 | public static String PROVINCES = "provinces";//省 | 29 | public static String PROVINCES = "provinces";//省 |
27 | public static String CITYS = "citys"; | 30 | public static String CITYS = "citys";//市 |
31 | public static String COUNTRY = "country";//区 | ||
28 | 32 | ||
29 | 33 | ||
30 | public void saveLoginParam(Context context,String spname, String spstr) { | 34 | public void saveLoginParam(Context context,String spname, String spstr) { |
31 | SharedPreferences sp = context.getSharedPreferences("loginparam", | 35 | SharedPreferences sp = context.getSharedPreferences("loginparam", |
32 | Activity.MODE_PRIVATE); | 36 | Activity.MODE_PRIVATE); |
33 | 37 | ||
34 | sp.edit().putString(spname, spstr).commit(); | 38 | sp.edit().putString(spname, spstr).commit(); |
35 | } | 39 | } |
36 | 40 | ||
37 | 41 | ||
38 | public String getLoginParam(Context context,String spname) { | 42 | public String getLoginParam(Context context,String spname) { |
39 | SharedPreferences sp = context.getSharedPreferences("loginparam", | 43 | SharedPreferences sp = context.getSharedPreferences("loginparam", |
40 | Activity.MODE_PRIVATE); | 44 | Activity.MODE_PRIVATE); |
41 | String param = sp.getString(spname, null); | 45 | String param = sp.getString(spname, null); |
42 | return param; | 46 | return param; |
43 | } | 47 | } |
44 | public void clearData(Context context) { | 48 | public void clearData(Context context) { |
45 | SharedPreferences sp = context.getSharedPreferences("loginparam", | 49 | SharedPreferences sp = context.getSharedPreferences("loginparam", |
46 | Activity.MODE_PRIVATE); | 50 | Activity.MODE_PRIVATE); |
47 | sp.edit().clear().commit(); | 51 | sp.edit().clear().commit(); |
48 | } | 52 | } |
49 | 53 | ||
50 | public void saveCustomizeParam(Context context,String spname, String spstr) { | 54 | public void saveCustomizeParam(Context context,String spname, String spstr) { |
51 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | 55 | SharedPreferences sp = context.getSharedPreferences("presoninfo", |
52 | Activity.MODE_PRIVATE); | 56 | Activity.MODE_PRIVATE); |
53 | 57 | ||
54 | sp.edit().putString(spname, spstr).commit(); | 58 | sp.edit().putString(spname, spstr).commit(); |
55 | 59 | ||
56 | } | 60 | } |
57 | 61 | ||
58 | public String getCustomizeParam(Context context,String spname) { | 62 | public String getCustomizeParam(Context context,String spname) { |
59 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | 63 | SharedPreferences sp = context.getSharedPreferences("presoninfo", |
60 | Activity.MODE_PRIVATE); | 64 | Activity.MODE_PRIVATE); |
61 | String param = sp.getString(spname, null); | 65 | String param = sp.getString(spname, null); |
62 | return param; | 66 | return param; |
63 | } | 67 | } |
64 | 68 | ||
65 | public void clearCustomizeParam(Context context ){ | 69 | public void clearCustomizeParam(Context context ){ |
66 | SharedPreferences sp = context.getSharedPreferences("presoninfo", | 70 | SharedPreferences sp = context.getSharedPreferences("presoninfo", |
67 | Activity.MODE_PRIVATE); | 71 | Activity.MODE_PRIVATE); |
68 | sp.edit().clear().commit(); | 72 | sp.edit().clear().commit(); |
69 | } | 73 | } |
70 | } | 74 | } |
71 | 75 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
1 | package com.hjx.personalcenter.http; | 1 | package com.hjx.personalcenter.http; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
5 | import android.content.ComponentName; | 5 | import android.content.ComponentName; |
6 | import android.content.Context; | 6 | import android.content.Context; |
7 | import android.content.Intent; | 7 | import android.content.Intent; |
8 | import android.os.Handler; | 8 | import android.os.Handler; |
9 | import android.os.Message; | 9 | import android.os.Message; |
10 | import android.provider.Settings; | 10 | import android.provider.Settings; |
11 | import android.support.v4.app.FragmentActivity; | 11 | import android.support.v4.app.FragmentActivity; |
12 | import android.util.Log; | 12 | import android.util.Log; |
13 | import android.view.Gravity; | 13 | import android.view.Gravity; |
14 | import android.view.View; | 14 | import android.view.View; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import com.google.gson.Gson; | 17 | import com.google.gson.Gson; |
18 | import com.hjx.personalcenter.R; | 18 | import com.hjx.personalcenter.R; |
19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; | 19 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
20 | import com.hjx.personalcenter.activity.TheStartPageActivity; | 20 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
21 | import com.hjx.personalcenter.db.SaveParam; | 21 | import com.hjx.personalcenter.db.SaveParam; |
22 | import com.hjx.personalcenter.gson.GsonTool; | 22 | import com.hjx.personalcenter.gson.GsonTool; |
23 | import com.hjx.personalcenter.model.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.ProvinceInfo; | 26 | import com.hjx.personalcenter.model.ProvinceInfo; |
27 | import com.hjx.personalcenter.model.SchoolInfo; | ||
26 | import com.hjx.personalcenter.util.DialogPermission; | 28 | import com.hjx.personalcenter.util.DialogPermission; |
27 | import com.loopj.android.http.AsyncHttpResponseHandler; | 29 | import com.loopj.android.http.AsyncHttpResponseHandler; |
28 | import com.loopj.android.http.JsonHttpResponseHandler; | 30 | import com.loopj.android.http.JsonHttpResponseHandler; |
29 | import com.loopj.android.http.RequestParams; | 31 | import com.loopj.android.http.RequestParams; |
30 | import com.mylhyl.circledialog.CircleDialog; | 32 | import com.mylhyl.circledialog.CircleDialog; |
31 | import com.mylhyl.circledialog.callback.ConfigText; | 33 | import com.mylhyl.circledialog.callback.ConfigText; |
32 | import com.mylhyl.circledialog.params.TextParams; | 34 | import com.mylhyl.circledialog.params.TextParams; |
33 | 35 | ||
34 | import org.apache.http.Header; | 36 | import org.apache.http.Header; |
35 | import org.apache.http.entity.ByteArrayEntity; | 37 | import org.apache.http.entity.ByteArrayEntity; |
36 | import org.apache.http.message.BasicHeader; | 38 | import org.apache.http.message.BasicHeader; |
37 | import org.apache.http.protocol.HTTP; | 39 | import org.apache.http.protocol.HTTP; |
38 | import org.json.JSONException; | 40 | import org.json.JSONException; |
39 | import org.json.JSONObject; | 41 | import org.json.JSONObject; |
40 | 42 | ||
41 | import java.io.UnsupportedEncodingException; | 43 | import java.io.UnsupportedEncodingException; |
42 | 44 | ||
43 | public class HttpManager { | 45 | public class HttpManager { |
44 | private static HttpManager instance; | 46 | private static HttpManager instance; |
45 | private ProgressDialog mProgress = null; | 47 | private ProgressDialog mProgress = null; |
46 | 48 | ||
47 | public static HttpManager getInstance() { | 49 | public static HttpManager getInstance() { |
48 | if (instance == null) { | 50 | if (instance == null) { |
49 | instance = new HttpManager(); | 51 | instance = new HttpManager(); |
50 | } | 52 | } |
51 | return instance; | 53 | return instance; |
52 | } | 54 | } |
53 | 55 | ||
54 | 56 | ||
55 | //登录接口 | 57 | //登录接口 |
56 | 58 | ||
57 | public void login(final String username, final String password, final Context mContext) { | 59 | public void login(final String username, final String password, final Context mContext) { |
58 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", | 60 | mProgress = DialogPermission.showProgress(mContext, null, "正在登录...", |
59 | false, true, null); | 61 | false, true, null); |
60 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 62 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
61 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { | 63 | HttpClient.getInstance().get(HttpUrl.loginUrl + "?username=" + username + "&password=" + password, new AsyncHttpResponseHandler() { |
62 | @Override | 64 | @Override |
63 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 65 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
64 | 66 | ||
65 | String str = new String(arg2); | 67 | String str = new String(arg2); |
66 | JSONObject jsonObject = null; | 68 | JSONObject jsonObject = null; |
67 | try { | 69 | try { |
68 | jsonObject = new JSONObject(new String(arg2)); | 70 | jsonObject = new JSONObject(new String(arg2)); |
69 | String status = jsonObject.getString("status"); | 71 | String status = jsonObject.getString("status"); |
70 | if (status.equals("100")) { | 72 | if (status.equals("100")) { |
71 | String access_token = jsonObject.getString("access_token"); | 73 | String access_token = jsonObject.getString("access_token"); |
72 | String userId = jsonObject.getString("userId"); | 74 | String userId = jsonObject.getString("userId"); |
73 | // //登录成功,保存登录数据并且获取个人信息 | 75 | // //登录成功,保存登录数据并且获取个人信息 |
74 | saveLoginInfo(mContext, username, password, access_token, "true", userId); | 76 | saveLoginInfo(mContext, username, password, access_token, "true", userId); |
75 | //HttpManager.getInstance().getuserinfo(username,mContext); | 77 | //HttpManager.getInstance().getuserinfo(username,mContext); |
76 | 78 | ||
77 | } else if (status.equals("200")) { | 79 | } else if (status.equals("200")) { |
78 | closeProgress(); | 80 | closeProgress(); |
79 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); | 81 | Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show(); |
80 | return; | 82 | return; |
81 | } else if (status.equals("204")) { | 83 | } else if (status.equals("204")) { |
82 | closeProgress(); | 84 | closeProgress(); |
83 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); | 85 | Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show(); |
84 | } else { | 86 | } else { |
85 | closeProgress(); | 87 | closeProgress(); |
86 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); | 88 | Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show(); |
87 | 89 | ||
88 | 90 | ||
89 | } | 91 | } |
90 | } catch (JSONException e) { | 92 | } catch (JSONException e) { |
91 | e.printStackTrace(); | 93 | e.printStackTrace(); |
92 | } | 94 | } |
93 | 95 | ||
94 | 96 | ||
95 | } | 97 | } |
96 | 98 | ||
97 | @Override | 99 | @Override |
98 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 100 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
99 | closeProgress(); | 101 | closeProgress(); |
100 | new CircleDialog.Builder((FragmentActivity) mContext) | 102 | new CircleDialog.Builder((FragmentActivity) mContext) |
101 | .setCanceledOnTouchOutside(false) | 103 | .setCanceledOnTouchOutside(false) |
102 | .setCancelable(false) | 104 | .setCancelable(false) |
103 | .setWidth(0.5f) | 105 | .setWidth(0.5f) |
104 | .configText(new ConfigText() { | 106 | .configText(new ConfigText() { |
105 | @Override | 107 | @Override |
106 | public void onConfig(TextParams params) { | 108 | public void onConfig(TextParams params) { |
107 | params.gravity = Gravity.CENTER; | 109 | params.gravity = Gravity.CENTER; |
108 | params.padding = new int[]{50, 50, 50, 50}; | 110 | params.padding = new int[]{50, 50, 50, 50}; |
109 | } | 111 | } |
110 | }) | 112 | }) |
111 | .setText("当前无网络,请检查网络设置") | 113 | .setText("当前无网络,请检查网络设置") |
112 | .setNegative("继续使用", null) | 114 | .setNegative("继续使用", null) |
113 | .setPositive("设置网络", new View.OnClickListener() { | 115 | .setPositive("设置网络", new View.OnClickListener() { |
114 | @Override | 116 | @Override |
115 | public void onClick(View v) { | 117 | public void onClick(View v) { |
116 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 118 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
117 | mContext.startActivity(intent); | 119 | mContext.startActivity(intent); |
118 | } | 120 | } |
119 | }) | 121 | }) |
120 | .show(); | 122 | .show(); |
121 | } | 123 | } |
122 | }); | 124 | }); |
123 | } | 125 | } |
124 | 126 | ||
125 | //注册接口 | 127 | //注册接口 |
126 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { | 128 | public void register(final Context context, String username, String password, String smscode, String source, final Handler handler) { |
127 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", | 129 | mProgress = DialogPermission.showProgress(context, null, "正在注册...", |
128 | false, true, null); | 130 | false, true, null); |
129 | JSONObject jsonObject = new JSONObject(); | 131 | JSONObject jsonObject = new JSONObject(); |
130 | ByteArrayEntity entity = null; | 132 | ByteArrayEntity entity = null; |
131 | try { | 133 | try { |
132 | jsonObject.put(HttpKey.USERNAME, username); | 134 | jsonObject.put(HttpKey.USERNAME, username); |
133 | jsonObject.put(HttpKey.PASSWORD, password); | 135 | jsonObject.put(HttpKey.PASSWORD, password); |
134 | jsonObject.put(HttpKey.SMSCODE, smscode); | 136 | jsonObject.put(HttpKey.SMSCODE, smscode); |
135 | jsonObject.put(HttpKey.SOURCE, source); | 137 | jsonObject.put(HttpKey.SOURCE, source); |
136 | Log.e("test", "jsonObject" + jsonObject); | 138 | Log.e("test", "jsonObject" + jsonObject); |
137 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); | 139 | entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8")); |
138 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); | 140 | entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
139 | } catch (JSONException e) { | 141 | } catch (JSONException e) { |
140 | e.printStackTrace(); | 142 | e.printStackTrace(); |
141 | } catch (UnsupportedEncodingException e) { | 143 | } catch (UnsupportedEncodingException e) { |
142 | e.printStackTrace(); | 144 | e.printStackTrace(); |
143 | } | 145 | } |
144 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 146 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
145 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { | 147 | HttpClient.getInstance().post(context, HttpUrl.registeredUrl, entity, "application/json", new JsonHttpResponseHandler() { |
146 | @Override | 148 | @Override |
147 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 149 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
148 | super.onSuccess(statusCode, headers, response); | 150 | super.onSuccess(statusCode, headers, response); |
149 | closeProgress(); | 151 | closeProgress(); |
150 | Log.e("test", "onSuccess" + response); | 152 | Log.e("test", "onSuccess" + response); |
151 | Message msg = Message.obtain(); | 153 | Message msg = Message.obtain(); |
152 | msg.what = HttpCode.REGISTERED_SUCESS; | 154 | msg.what = HttpCode.REGISTERED_SUCESS; |
153 | msg.obj = response; | 155 | msg.obj = response; |
154 | handler.sendMessage(msg); | 156 | handler.sendMessage(msg); |
155 | 157 | ||
156 | } | 158 | } |
157 | 159 | ||
158 | @Override | 160 | @Override |
159 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 161 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
160 | super.onFailure(statusCode, headers, throwable, errorResponse); | 162 | super.onFailure(statusCode, headers, throwable, errorResponse); |
161 | closeProgress(); | 163 | closeProgress(); |
162 | Log.e("test", "onFailure" + errorResponse); | 164 | Log.e("test", "onFailure" + errorResponse); |
163 | new CircleDialog.Builder((FragmentActivity) context) | 165 | new CircleDialog.Builder((FragmentActivity) context) |
164 | .setCanceledOnTouchOutside(false) | 166 | .setCanceledOnTouchOutside(false) |
165 | .setCancelable(false) | 167 | .setCancelable(false) |
166 | .setWidth(0.5f) | 168 | .setWidth(0.5f) |
167 | .configText(new ConfigText() { | 169 | .configText(new ConfigText() { |
168 | @Override | 170 | @Override |
169 | public void onConfig(TextParams params) { | 171 | public void onConfig(TextParams params) { |
170 | params.gravity = Gravity.CENTER; | 172 | params.gravity = Gravity.CENTER; |
171 | params.padding = new int[]{50, 50, 50, 50}; | 173 | params.padding = new int[]{50, 50, 50, 50}; |
172 | } | 174 | } |
173 | }) | 175 | }) |
174 | .setText("当前无网络,请检查网络设置") | 176 | .setText("当前无网络,请检查网络设置") |
175 | .setNegative("继续使用", null) | 177 | .setNegative("继续使用", null) |
176 | .setPositive("设置网络", new View.OnClickListener() { | 178 | .setPositive("设置网络", new View.OnClickListener() { |
177 | @Override | 179 | @Override |
178 | public void onClick(View v) { | 180 | public void onClick(View v) { |
179 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 181 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
180 | context.startActivity(intent); | 182 | context.startActivity(intent); |
181 | } | 183 | } |
182 | }) | 184 | }) |
183 | .show(); | 185 | .show(); |
184 | } | 186 | } |
185 | 187 | ||
186 | }); | 188 | }); |
187 | } | 189 | } |
188 | 190 | ||
189 | //注册验证码 | 191 | //注册验证码 |
190 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { | 192 | public void authCode(final String type, final String mobile, final Handler handler, final Context mContext) { |
191 | RequestParams params = new RequestParams(); | 193 | RequestParams params = new RequestParams(); |
192 | params.put(HttpKey.TYPE, type); | 194 | params.put(HttpKey.TYPE, type); |
193 | params.put(HttpKey.MOBIL, mobile); | 195 | params.put(HttpKey.MOBIL, mobile); |
194 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 196 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
195 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { | 197 | HttpClient.getInstance().post(HttpUrl.authCodedUrl, params, new JsonHttpResponseHandler() { |
196 | 198 | ||
197 | @Override | 199 | @Override |
198 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 200 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
199 | Log.e("test", "onSuccess-----" + response); | 201 | Log.e("test", "onSuccess-----" + response); |
200 | Message msg = Message.obtain(); | 202 | Message msg = Message.obtain(); |
201 | msg.what = HttpCode.AUTHCODE_SUCESS; | 203 | msg.what = HttpCode.AUTHCODE_SUCESS; |
202 | msg.obj = response; | 204 | msg.obj = response; |
203 | handler.sendMessage(msg); | 205 | handler.sendMessage(msg); |
204 | } | 206 | } |
205 | 207 | ||
206 | @Override | 208 | @Override |
207 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 209 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
208 | new CircleDialog.Builder((FragmentActivity) mContext) | 210 | new CircleDialog.Builder((FragmentActivity) mContext) |
209 | .setCanceledOnTouchOutside(false) | 211 | .setCanceledOnTouchOutside(false) |
210 | .setCancelable(false) | 212 | .setCancelable(false) |
211 | .setWidth(0.5f) | 213 | .setWidth(0.5f) |
212 | .configText(new ConfigText() { | 214 | .configText(new ConfigText() { |
213 | @Override | 215 | @Override |
214 | public void onConfig(TextParams params) { | 216 | public void onConfig(TextParams params) { |
215 | params.gravity = Gravity.CENTER; | 217 | params.gravity = Gravity.CENTER; |
216 | params.padding = new int[]{50, 50, 50, 50}; | 218 | params.padding = new int[]{50, 50, 50, 50}; |
217 | } | 219 | } |
218 | }) | 220 | }) |
219 | .setText("当前无网络,请检查网络设置") | 221 | .setText("当前无网络,请检查网络设置") |
220 | .setNegative("继续使用", null) | 222 | .setNegative("继续使用", null) |
221 | .setPositive("设置网络", new View.OnClickListener() { | 223 | .setPositive("设置网络", new View.OnClickListener() { |
222 | @Override | 224 | @Override |
223 | public void onClick(View v) { | 225 | public void onClick(View v) { |
224 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 226 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
225 | mContext.startActivity(intent); | 227 | mContext.startActivity(intent); |
226 | } | 228 | } |
227 | }) | 229 | }) |
228 | .show(); | 230 | .show(); |
229 | } | 231 | } |
230 | }); | 232 | }); |
231 | } | 233 | } |
232 | 234 | ||
233 | 235 | ||
234 | //手机号是否注册 | 236 | //手机号是否注册 |
235 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { | 237 | public void isregistered(final String mobile, final Handler handler, final Context mContext) { |
236 | RequestParams params = new RequestParams(); | 238 | RequestParams params = new RequestParams(); |
237 | params.put(HttpKey.USERNAME, mobile); | 239 | params.put(HttpKey.USERNAME, mobile); |
238 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { | 240 | HttpClient.getInstance().get(HttpUrl.isRegiterUrl + "?mobile=" + mobile, new JsonHttpResponseHandler() { |
239 | @Override | 241 | @Override |
240 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { | 242 | public void onSuccess(int statusCode, Header[] headers, JSONObject response) { |
241 | Log.e("test", "isregistered" + response.toString()); | 243 | Log.e("test", "isregistered" + response.toString()); |
242 | Message msg = Message.obtain(); | 244 | Message msg = Message.obtain(); |
243 | msg.what = HttpCode.IS_REFISTER; | 245 | msg.what = HttpCode.IS_REFISTER; |
244 | msg.obj = response; | 246 | msg.obj = response; |
245 | handler.sendMessage(msg); | 247 | handler.sendMessage(msg); |
246 | 248 | ||
247 | } | 249 | } |
248 | 250 | ||
249 | @Override | 251 | @Override |
250 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { | 252 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { |
251 | new CircleDialog.Builder((FragmentActivity) mContext) | 253 | new CircleDialog.Builder((FragmentActivity) mContext) |
252 | .setCanceledOnTouchOutside(false) | 254 | .setCanceledOnTouchOutside(false) |
253 | .setCancelable(false) | 255 | .setCancelable(false) |
254 | .setWidth(0.5f) | 256 | .setWidth(0.5f) |
255 | .configText(new ConfigText() { | 257 | .configText(new ConfigText() { |
256 | @Override | 258 | @Override |
257 | public void onConfig(TextParams params) { | 259 | public void onConfig(TextParams params) { |
258 | params.gravity = Gravity.CENTER; | 260 | params.gravity = Gravity.CENTER; |
259 | params.padding = new int[]{50, 50, 50, 50}; | 261 | params.padding = new int[]{50, 50, 50, 50}; |
260 | } | 262 | } |
261 | }) | 263 | }) |
262 | .setText("当前无网络,请检查网络设置") | 264 | .setText("当前无网络,请检查网络设置") |
263 | .setNegative("继续使用", null) | 265 | .setNegative("继续使用", null) |
264 | .setPositive("设置网络", new View.OnClickListener() { | 266 | .setPositive("设置网络", new View.OnClickListener() { |
265 | @Override | 267 | @Override |
266 | public void onClick(View v) { | 268 | public void onClick(View v) { |
267 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 269 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
268 | mContext.startActivity(intent); | 270 | mContext.startActivity(intent); |
269 | } | 271 | } |
270 | }) | 272 | }) |
271 | .show(); | 273 | .show(); |
272 | 274 | ||
273 | } | 275 | } |
274 | }); | 276 | }); |
275 | } | 277 | } |
276 | 278 | ||
277 | //修改密码 | 279 | //修改密码 |
278 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { | 280 | public void changepwd(final Context context, String username, String old_pwd1, String newpassword3) { |
279 | RequestParams params = new RequestParams(); | 281 | RequestParams params = new RequestParams(); |
280 | params.put(HttpKey.USERNAME, username); | 282 | params.put(HttpKey.USERNAME, username); |
281 | params.put(HttpKey.OLDPASS, old_pwd1); | 283 | params.put(HttpKey.OLDPASS, old_pwd1); |
282 | params.put(HttpKey.NEWPASS, newpassword3); | 284 | params.put(HttpKey.NEWPASS, newpassword3); |
283 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 285 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
284 | HttpClient.getInstance().setTimeout(10 * 1000); | 286 | HttpClient.getInstance().setTimeout(10 * 1000); |
285 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { | 287 | HttpClient.getInstance().post(HttpUrl.changepassword, params, new AsyncHttpResponseHandler() { |
286 | @Override | 288 | @Override |
287 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 289 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
288 | try { | 290 | try { |
289 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 291 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
290 | String status = jsonObject.optString("status"); | 292 | String status = jsonObject.optString("status"); |
291 | if (status.equals("100")) { | 293 | if (status.equals("100")) { |
292 | Log.e("test", "onSuccess" + new String(bytes)); | 294 | Log.e("test", "onSuccess" + new String(bytes)); |
293 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 295 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
294 | SaveParam.getInstance().clearData((Activity) context); | 296 | SaveParam.getInstance().clearData((Activity) context); |
295 | Intent intent = new Intent(); | 297 | Intent intent = new Intent(); |
296 | intent.setClass(context, LoginAndRegisterActivity.class); | 298 | intent.setClass(context, LoginAndRegisterActivity.class); |
297 | ((Activity) context).startActivity(intent); | 299 | ((Activity) context).startActivity(intent); |
298 | ((Activity) context).finish(); | 300 | ((Activity) context).finish(); |
299 | } | 301 | } |
300 | } catch (JSONException e) { | 302 | } catch (JSONException e) { |
301 | e.printStackTrace(); | 303 | e.printStackTrace(); |
302 | } | 304 | } |
303 | } | 305 | } |
304 | 306 | ||
305 | @Override | 307 | @Override |
306 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 308 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
307 | Log.e("test", "onFailure" + new String(bytes)); | 309 | Log.e("test", "onFailure" + new String(bytes)); |
308 | new CircleDialog.Builder((FragmentActivity) context) | 310 | new CircleDialog.Builder((FragmentActivity) context) |
309 | .setCanceledOnTouchOutside(false) | 311 | .setCanceledOnTouchOutside(false) |
310 | .setCancelable(false) | 312 | .setCancelable(false) |
311 | .setWidth(0.5f) | 313 | .setWidth(0.5f) |
312 | .configText(new ConfigText() { | 314 | .configText(new ConfigText() { |
313 | @Override | 315 | @Override |
314 | public void onConfig(TextParams params) { | 316 | public void onConfig(TextParams params) { |
315 | params.gravity = Gravity.CENTER; | 317 | params.gravity = Gravity.CENTER; |
316 | params.padding = new int[]{50, 50, 50, 50}; | 318 | params.padding = new int[]{50, 50, 50, 50}; |
317 | } | 319 | } |
318 | }) | 320 | }) |
319 | .setText("当前无网络,请检查网络设置") | 321 | .setText("当前无网络,请检查网络设置") |
320 | .setNegative("继续使用", null) | 322 | .setNegative("继续使用", null) |
321 | .setPositive("设置网络", new View.OnClickListener() { | 323 | .setPositive("设置网络", new View.OnClickListener() { |
322 | @Override | 324 | @Override |
323 | public void onClick(View v) { | 325 | public void onClick(View v) { |
324 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 326 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
325 | context.startActivity(intent); | 327 | context.startActivity(intent); |
326 | } | 328 | } |
327 | }) | 329 | }) |
328 | .show(); | 330 | .show(); |
329 | } | 331 | } |
330 | }); | 332 | }); |
331 | 333 | ||
332 | } | 334 | } |
333 | 335 | ||
334 | //忘记密码 | 336 | //忘记密码 |
335 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { | 337 | public void forgetpassword(final Context context, String forot_pwd_phone1, String forot_pwd_pwd3, String forot_pwd_anthcode1, Handler handler) { |
336 | RequestParams params = new RequestParams(); | 338 | RequestParams params = new RequestParams(); |
337 | params.put(HttpKey.USERNAME, forot_pwd_phone1); | 339 | params.put(HttpKey.USERNAME, forot_pwd_phone1); |
338 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); | 340 | params.put(HttpKey.PASSWORD, forot_pwd_pwd3); |
339 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); | 341 | params.put(HttpKey.AUTHCODE, forot_pwd_anthcode1); |
340 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 342 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
341 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { | 343 | HttpClient.getInstance().post(HttpUrl.forgetpassword, params, new AsyncHttpResponseHandler() { |
342 | @Override | 344 | @Override |
343 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 345 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
344 | try { | 346 | try { |
345 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 347 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
346 | String status = jsonObject.optString("status"); | 348 | String status = jsonObject.optString("status"); |
347 | if (status.equals("100")) { | 349 | if (status.equals("100")) { |
348 | Log.e("test", "onSuccess" + new String(bytes)); | 350 | Log.e("test", "onSuccess" + new String(bytes)); |
349 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); | 351 | Toast.makeText(context, "密码修改成功!", Toast.LENGTH_LONG).show(); |
350 | ((Activity) context).finish(); | 352 | ((Activity) context).finish(); |
351 | } | 353 | } |
352 | } catch (JSONException e) { | 354 | } catch (JSONException e) { |
353 | e.printStackTrace(); | 355 | e.printStackTrace(); |
354 | } | 356 | } |
355 | } | 357 | } |
356 | 358 | ||
357 | @Override | 359 | @Override |
358 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 360 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
359 | Log.e("test", "onFailure" + new String(bytes)); | 361 | Log.e("test", "onFailure" + new String(bytes)); |
360 | new CircleDialog.Builder((FragmentActivity) context) | 362 | new CircleDialog.Builder((FragmentActivity) context) |
361 | .setCanceledOnTouchOutside(false) | 363 | .setCanceledOnTouchOutside(false) |
362 | .setCancelable(false) | 364 | .setCancelable(false) |
363 | .setWidth(0.5f) | 365 | .setWidth(0.5f) |
364 | .configText(new ConfigText() { | 366 | .configText(new ConfigText() { |
365 | @Override | 367 | @Override |
366 | public void onConfig(TextParams params) { | 368 | public void onConfig(TextParams params) { |
367 | params.gravity = Gravity.CENTER; | 369 | params.gravity = Gravity.CENTER; |
368 | params.padding = new int[]{50, 50, 50, 50}; | 370 | params.padding = new int[]{50, 50, 50, 50}; |
369 | } | 371 | } |
370 | }) | 372 | }) |
371 | .setText("当前无网络,请检查网络设置") | 373 | .setText("当前无网络,请检查网络设置") |
372 | .setNegative("继续使用", null) | 374 | .setNegative("继续使用", null) |
373 | .setPositive("设置网络", new View.OnClickListener() { | 375 | .setPositive("设置网络", new View.OnClickListener() { |
374 | @Override | 376 | @Override |
375 | public void onClick(View v) { | 377 | public void onClick(View v) { |
376 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 378 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
377 | context.startActivity(intent); | 379 | context.startActivity(intent); |
378 | } | 380 | } |
379 | }) | 381 | }) |
380 | .show(); | 382 | .show(); |
381 | } | 383 | } |
382 | }); | 384 | }); |
383 | 385 | ||
384 | } | 386 | } |
385 | 387 | ||
386 | //保存用户登录信息 | 388 | //保存用户登录信息 |
387 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { | 389 | public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) { |
388 | SaveParam.getInstance().saveLoginParam(context, "username", username); | 390 | SaveParam.getInstance().saveLoginParam(context, "username", username); |
389 | SaveParam.getInstance().saveLoginParam(context, "password", password); | 391 | SaveParam.getInstance().saveLoginParam(context, "password", password); |
390 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); | 392 | SaveParam.getInstance().saveLoginParam(context, "access_token", access_token); |
391 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); | 393 | SaveParam.getInstance().saveLoginParam(context, "login", loginStatus); |
392 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); | 394 | SaveParam.getInstance().saveLoginParam(context, "userId", userId); |
393 | 395 | ||
394 | 396 | ||
395 | } | 397 | } |
396 | 398 | ||
397 | //保存用户个人信息 | 399 | //保存用户个人信息 |
398 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { | 400 | public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) { |
399 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); | 401 | SaveParam.getInstance().saveLoginParam(context, "lastname", lastname); |
400 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); | 402 | SaveParam.getInstance().saveLoginParam(context, "gender", gender); |
401 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); | 403 | SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait); |
402 | } | 404 | } |
403 | 405 | ||
404 | //提交保卡信息 | 406 | //提交保卡信息 |
405 | public void subcardinfo(final Context context, int userId, String customerName, String customerAddress, | 407 | public void subcardinfo(final Context context, int userId, String customerName, String customerAddress, |
406 | String buyAddress, String buyTime, String alterSaleCall, | 408 | String buyAddress, String buyTime, String alterSaleCall, |
407 | String productModel, String deviceNumber, String macAddress, | 409 | String productModel, String deviceNumber, String macAddress, |
408 | String mobilePhone) { | 410 | String mobilePhone) { |
409 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", | 411 | mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...", |
410 | false, true, null); | 412 | false, true, null); |
411 | RequestParams params = new RequestParams(); | 413 | RequestParams params = new RequestParams(); |
412 | 414 | ||
413 | params.put(HttpKey.USEID, userId); | 415 | params.put(HttpKey.USEID, userId); |
414 | params.put(HttpKey.CUSTOMENAME, customerName); | 416 | params.put(HttpKey.CUSTOMENAME, customerName); |
415 | params.put(HttpKey.CUSTOMADRESS, customerAddress); | 417 | params.put(HttpKey.CUSTOMADRESS, customerAddress); |
416 | params.put(HttpKey.BUYADREES, buyAddress); | 418 | params.put(HttpKey.BUYADREES, buyAddress); |
417 | params.put(HttpKey.BUYTIME, buyTime); | 419 | params.put(HttpKey.BUYTIME, buyTime); |
418 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); | 420 | params.put(HttpKey.ALTERSALECALL, alterSaleCall); |
419 | params.put(HttpKey.PRODUCTMODEL, productModel); | 421 | params.put(HttpKey.PRODUCTMODEL, productModel); |
420 | params.put(HttpKey.DEVICENUMBER, deviceNumber); | 422 | params.put(HttpKey.DEVICENUMBER, deviceNumber); |
421 | params.put(HttpKey.MACADRESS, macAddress); | 423 | params.put(HttpKey.MACADRESS, macAddress); |
422 | params.put(HttpKey.MOBILPHONE, mobilePhone); | 424 | params.put(HttpKey.MOBILPHONE, mobilePhone); |
423 | 425 | ||
424 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 426 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
425 | 427 | ||
426 | Log.e("test", "params" + params); | 428 | Log.e("test", "params" + params); |
427 | HttpClient.getInstance().setTimeout(5 * 1000); | 429 | HttpClient.getInstance().setTimeout(5 * 1000); |
428 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { | 430 | HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() { |
429 | @Override | 431 | @Override |
430 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 432 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
431 | JSONObject jsonObject = null; | 433 | JSONObject jsonObject = null; |
432 | closeProgress(); | 434 | closeProgress(); |
433 | try { | 435 | try { |
434 | jsonObject = new JSONObject(new String(bytes)); | 436 | jsonObject = new JSONObject(new String(bytes)); |
435 | String status = jsonObject.optString("status"); | 437 | String status = jsonObject.optString("status"); |
436 | if (status.equals("1")) { | 438 | if (status.equals("1")) { |
437 | Log.e("test", "onSuccess" + jsonObject); | 439 | Log.e("test", "onSuccess" + jsonObject); |
438 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); | 440 | Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show(); |
439 | Intent intent = new Intent(); | 441 | Intent intent = new Intent(); |
440 | intent.setClass((Activity) context, TheStartPageActivity.class); | 442 | intent.setClass((Activity) context, TheStartPageActivity.class); |
441 | ((Activity) context).startActivity(intent); | 443 | ((Activity) context).startActivity(intent); |
442 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); | 444 | ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout); |
443 | ((Activity) context).finish(); | 445 | ((Activity) context).finish(); |
444 | } | 446 | } |
445 | } catch (JSONException e) { | 447 | } catch (JSONException e) { |
446 | e.printStackTrace(); | 448 | e.printStackTrace(); |
447 | } | 449 | } |
448 | 450 | ||
449 | 451 | ||
450 | } | 452 | } |
451 | 453 | ||
452 | @Override | 454 | @Override |
453 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 455 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
454 | Log.e("test", "onFailure" + (throwable)); | 456 | Log.e("test", "onFailure" + (throwable)); |
455 | closeProgress(); | 457 | closeProgress(); |
456 | new CircleDialog.Builder((FragmentActivity) context) | 458 | new CircleDialog.Builder((FragmentActivity) context) |
457 | .setCanceledOnTouchOutside(false) | 459 | .setCanceledOnTouchOutside(false) |
458 | .setCancelable(false) | 460 | .setCancelable(false) |
459 | .setWidth(0.5f) | 461 | .setWidth(0.5f) |
460 | .configText(new ConfigText() { | 462 | .configText(new ConfigText() { |
461 | @Override | 463 | @Override |
462 | public void onConfig(TextParams params) { | 464 | public void onConfig(TextParams params) { |
463 | params.gravity = Gravity.CENTER; | 465 | params.gravity = Gravity.CENTER; |
464 | params.padding = new int[]{50, 50, 50, 50}; | 466 | params.padding = new int[]{50, 50, 50, 50}; |
465 | } | 467 | } |
466 | }) | 468 | }) |
467 | .setText("当前无网络,请检查网络设置") | 469 | .setText("当前无网络,请检查网络设置") |
468 | .setNegative("继续使用", null) | 470 | .setNegative("继续使用", null) |
469 | .setPositive("设置网络", new View.OnClickListener() { | 471 | .setPositive("设置网络", new View.OnClickListener() { |
470 | @Override | 472 | @Override |
471 | public void onClick(View v) { | 473 | public void onClick(View v) { |
472 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 474 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
473 | context.startActivity(intent); | 475 | context.startActivity(intent); |
474 | } | 476 | } |
475 | }) | 477 | }) |
476 | .show(); | 478 | .show(); |
477 | 479 | ||
478 | } | 480 | } |
479 | }); | 481 | }); |
480 | 482 | ||
481 | } | 483 | } |
482 | //获取保卡信息 | 484 | //获取保卡信息 |
483 | public void getcardinfo(final Context mContext, int userId , final Handler handler) { | 485 | public void getcardinfo(final Context mContext, int userId , final Handler handler) { |
484 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", | 486 | mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...", |
485 | false, true, null); | 487 | false, true, null); |
486 | HttpClient.getInstance().setTimeout(5 * 1000); | 488 | HttpClient.getInstance().setTimeout(5 * 1000); |
487 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 489 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
488 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { | 490 | HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() { |
489 | @Override | 491 | @Override |
490 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 492 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
491 | closeProgress(); | 493 | closeProgress(); |
492 | Log.e("test", "省" + new String(arg2)); | 494 | Log.e("test", "省" + new String(arg2)); |
493 | Message msg = Message.obtain(); | 495 | Message msg = Message.obtain(); |
494 | msg.what = HttpCode.SUCHCARDINFO; | 496 | msg.what = HttpCode.SUCHCARDINFO; |
495 | msg.obj = new String(arg2); | 497 | msg.obj = new String(arg2); |
496 | handler.sendMessage(msg); | 498 | handler.sendMessage(msg); |
497 | } | 499 | } |
498 | 500 | ||
499 | @Override | 501 | @Override |
500 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 502 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
501 | closeProgress(); | 503 | closeProgress(); |
502 | new CircleDialog.Builder((FragmentActivity) mContext) | 504 | new CircleDialog.Builder((FragmentActivity) mContext) |
503 | .setCanceledOnTouchOutside(false) | 505 | .setCanceledOnTouchOutside(false) |
504 | .setCancelable(false) | 506 | .setCancelable(false) |
505 | .setWidth(0.5f) | 507 | .setWidth(0.5f) |
506 | .configText(new ConfigText() { | 508 | .configText(new ConfigText() { |
507 | @Override | 509 | @Override |
508 | public void onConfig(TextParams params) { | 510 | public void onConfig(TextParams params) { |
509 | params.gravity = Gravity.CENTER; | 511 | params.gravity = Gravity.CENTER; |
510 | params.padding = new int[]{50, 50, 50, 50}; | 512 | params.padding = new int[]{50, 50, 50, 50}; |
511 | } | 513 | } |
512 | }) | 514 | }) |
513 | .setText("当前无网络,请检查网络设置") | 515 | .setText("当前无网络,请检查网络设置") |
514 | .setNegative("继续使用", null) | 516 | .setNegative("继续使用", null) |
515 | .setPositive("设置网络", new View.OnClickListener() { | 517 | .setPositive("设置网络", new View.OnClickListener() { |
516 | @Override | 518 | @Override |
517 | public void onClick(View v) { | 519 | public void onClick(View v) { |
518 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 520 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
519 | mContext.startActivity(intent); | 521 | mContext.startActivity(intent); |
520 | } | 522 | } |
521 | }) | 523 | }) |
522 | .show(); | 524 | .show(); |
523 | } | 525 | } |
524 | }); | 526 | }); |
525 | } | 527 | } |
526 | //修改保卡信息电话 | 528 | //修改保卡信息电话 |
527 | public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) { | 529 | public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) { |
528 | RequestParams params = new RequestParams(); | 530 | RequestParams params = new RequestParams(); |
529 | params.put("userId", userId); | 531 | params.put("userId", userId); |
530 | params.put("customerPhone", customerPhone); | 532 | params.put("customerPhone", customerPhone); |
531 | params.put("authCode", authCode); | 533 | params.put("authCode", authCode); |
532 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 534 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
533 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 535 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
534 | @Override | 536 | @Override |
535 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 537 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
536 | try { | 538 | try { |
537 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 539 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
538 | String status = jsonObject.optString("status"); | 540 | String status = jsonObject.optString("status"); |
539 | if (status.equals("1")) { | 541 | if (status.equals("1")) { |
540 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 542 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
541 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); | 543 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone); |
542 | ((Activity) mContext).finish(); | 544 | ((Activity) mContext).finish(); |
543 | }else if (status.equals("1001")){ | 545 | }else if (status.equals("1001")){ |
544 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); | 546 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
545 | } | 547 | } |
546 | } catch (JSONException e) { | 548 | } catch (JSONException e) { |
547 | e.printStackTrace(); | 549 | e.printStackTrace(); |
548 | } | 550 | } |
549 | } | 551 | } |
550 | 552 | ||
551 | @Override | 553 | @Override |
552 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 554 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
553 | Log.e("test", "onFailure" + new String(bytes)); | 555 | Log.e("test", "onFailure" + new String(bytes)); |
554 | new CircleDialog.Builder((FragmentActivity) mContext) | 556 | new CircleDialog.Builder((FragmentActivity) mContext) |
555 | .setCanceledOnTouchOutside(false) | 557 | .setCanceledOnTouchOutside(false) |
556 | .setCancelable(false) | 558 | .setCancelable(false) |
557 | .setWidth(0.5f) | 559 | .setWidth(0.5f) |
558 | .configText(new ConfigText() { | 560 | .configText(new ConfigText() { |
559 | @Override | 561 | @Override |
560 | public void onConfig(TextParams params) { | 562 | public void onConfig(TextParams params) { |
561 | params.gravity = Gravity.CENTER; | 563 | params.gravity = Gravity.CENTER; |
562 | params.padding = new int[]{50, 50, 50, 50}; | 564 | params.padding = new int[]{50, 50, 50, 50}; |
563 | } | 565 | } |
564 | }) | 566 | }) |
565 | .setText("当前无网络,请检查网络设置") | 567 | .setText("当前无网络,请检查网络设置") |
566 | .setNegative("继续使用", null) | 568 | .setNegative("继续使用", null) |
567 | .setPositive("设置网络", new View.OnClickListener() { | 569 | .setPositive("设置网络", new View.OnClickListener() { |
568 | @Override | 570 | @Override |
569 | public void onClick(View v) { | 571 | public void onClick(View v) { |
570 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 572 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
571 | mContext.startActivity(intent); | 573 | mContext.startActivity(intent); |
572 | } | 574 | } |
573 | }) | 575 | }) |
574 | .show(); | 576 | .show(); |
575 | } | 577 | } |
576 | }); | 578 | }); |
577 | } | 579 | } |
578 | //修改保卡信息地址 | 580 | //修改保卡信息地址 |
579 | public void changecardadressinfo(final Context mContext, int userId, final String customerPhone, String authCode, final String customerAddress) { | 581 | public void changecardadressinfo(final Context mContext, int userId, final String customerPhone, String authCode, final String customerAddress) { |
580 | RequestParams params = new RequestParams(); | 582 | RequestParams params = new RequestParams(); |
581 | params.put("userId", userId); | 583 | params.put("userId", userId); |
582 | params.put("customerPhone", customerPhone); | 584 | params.put("customerPhone", customerPhone); |
583 | params.put("authCode", authCode); | 585 | params.put("authCode", authCode); |
584 | params.put("customerAddress", customerAddress); | 586 | params.put("customerAddress", customerAddress); |
585 | HttpClient.getInstance().addHeader("Accept", "*/*"); | 587 | HttpClient.getInstance().addHeader("Accept", "*/*"); |
586 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { | 588 | HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() { |
587 | @Override | 589 | @Override |
588 | public void onSuccess(int i, Header[] headers, byte[] bytes) { | 590 | public void onSuccess(int i, Header[] headers, byte[] bytes) { |
589 | try { | 591 | try { |
590 | JSONObject jsonObject = new JSONObject(new String(bytes)); | 592 | JSONObject jsonObject = new JSONObject(new String(bytes)); |
591 | String status = jsonObject.optString("status"); | 593 | String status = jsonObject.optString("status"); |
592 | if (status.equals("1")) { | 594 | if (status.equals("1")) { |
593 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); | 595 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
594 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); | 596 | SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.ADRESSCUNSTEM, customerAddress); |
595 | ((Activity) mContext).finish(); | 597 | ((Activity) mContext).finish(); |
596 | } | 598 | } |
597 | } catch (JSONException e) { | 599 | } catch (JSONException e) { |
598 | e.printStackTrace(); | 600 | e.printStackTrace(); |
599 | } | 601 | } |
600 | } | 602 | } |
601 | 603 | ||
602 | @Override | 604 | @Override |
603 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | 605 | public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { |
604 | Log.e("test", "onFailure" + new String(bytes)); | 606 | Log.e("test", "onFailure" + new String(bytes)); |
605 | new CircleDialog.Builder((FragmentActivity) mContext) | 607 | new CircleDialog.Builder((FragmentActivity) mContext) |
606 | .setCanceledOnTouchOutside(false) | 608 | .setCanceledOnTouchOutside(false) |
607 | .setCancelable(false) | 609 | .setCancelable(false) |
608 | .setWidth(0.5f) | 610 | .setWidth(0.5f) |
609 | .configText(new ConfigText() { | 611 | .configText(new ConfigText() { |
610 | @Override | 612 | @Override |
611 | public void onConfig(TextParams params) { | 613 | public void onConfig(TextParams params) { |
612 | params.gravity = Gravity.CENTER; | 614 | params.gravity = Gravity.CENTER; |
613 | params.padding = new int[]{50, 50, 50, 50}; | 615 | params.padding = new int[]{50, 50, 50, 50}; |
614 | } | 616 | } |
615 | }) | 617 | }) |
616 | .setText("当前无网络,请检查网络设置") | 618 | .setText("当前无网络,请检查网络设置") |
617 | .setNegative("继续使用", null) | 619 | .setNegative("继续使用", null) |
618 | .setPositive("设置网络", new View.OnClickListener() { | 620 | .setPositive("设置网络", new View.OnClickListener() { |
619 | @Override | 621 | @Override |
620 | public void onClick(View v) { | 622 | public void onClick(View v) { |
621 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 623 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
622 | mContext.startActivity(intent); | 624 | mContext.startActivity(intent); |
623 | } | 625 | } |
624 | }) | 626 | }) |
625 | .show(); | 627 | .show(); |
626 | } | 628 | } |
627 | }); | 629 | }); |
628 | } | 630 | } |
629 | //验证是否保卡信息 | 631 | //验证是否保卡信息 |
630 | public void cardinfocheck(final Context mContext, int userId, final Handler handler) { | 632 | public void cardinfocheck(final Context mContext, int userId, final Handler handler) { |
631 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 633 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
632 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { | 634 | HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() { |
633 | @Override | 635 | @Override |
634 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 636 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
635 | Log.e("test", "省" + new String(arg2)); | 637 | Log.e("test", "---" + new String(arg2)); |
636 | Message msg = Message.obtain(); | 638 | Message msg = Message.obtain(); |
637 | msg.what = HttpCode.CHECKCARD; | 639 | msg.what = HttpCode.CHECKCARD; |
638 | msg.obj = new String(arg2); | 640 | msg.obj = new String(arg2); |
639 | handler.sendMessage(msg); | 641 | handler.sendMessage(msg); |
640 | } | 642 | } |
641 | 643 | ||
642 | @Override | 644 | @Override |
643 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 645 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
644 | new CircleDialog.Builder((FragmentActivity) mContext) | 646 | new CircleDialog.Builder((FragmentActivity) mContext) |
645 | .setCanceledOnTouchOutside(false) | 647 | .setCanceledOnTouchOutside(false) |
646 | .setCancelable(false) | 648 | .setCancelable(false) |
647 | .configText(new ConfigText() { | 649 | .configText(new ConfigText() { |
648 | @Override | 650 | @Override |
649 | public void onConfig(TextParams params) { | 651 | public void onConfig(TextParams params) { |
650 | params.gravity = Gravity.CENTER; | 652 | params.gravity = Gravity.CENTER; |
651 | params.padding = new int[]{250, 50, 250, 50}; | 653 | params.padding = new int[]{250, 50, 250, 50}; |
652 | } | 654 | } |
653 | }) | 655 | }) |
654 | .setText("当前无网络,请检查网络设置") | 656 | .setText("当前无网络,请检查网络设置") |
655 | .setNegative("取消", null) | 657 | .setNegative("取消", null) |
656 | .setPositive("确定", new View.OnClickListener() { | 658 | .setPositive("确定", new View.OnClickListener() { |
657 | @Override | 659 | @Override |
658 | public void onClick(View v) { | 660 | public void onClick(View v) { |
659 | Intent intent = new Intent("/"); | 661 | Intent intent = new Intent("/"); |
660 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); | 662 | ComponentName cm = new ComponentName("com.android.settings","com.android.settings.WirelessSettings"); |
661 | intent.setComponent(cm); | 663 | intent.setComponent(cm); |
662 | intent.setAction("android.intent.action.VIEW"); | 664 | intent.setAction("android.intent.action.VIEW"); |
663 | ((Activity) mContext).startActivityForResult( intent , 0); | 665 | ((Activity) mContext).startActivityForResult( intent , 0); |
664 | } | 666 | } |
665 | }) | 667 | }) |
666 | .show(); | 668 | .show(); |
667 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); | 669 | //Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show(); |
668 | } | 670 | } |
669 | }); | 671 | }); |
670 | } | 672 | } |
671 | 673 | ||
674 | ///获取年级 | ||
675 | public void getgrade(final Context mContext) { | ||
676 | HttpClient.getInstance().addHeader("Accept", "application/json"); | ||
677 | HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() { | ||
678 | @Override | ||
679 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
680 | Log.e("test", "年级" + new String(arg2)); | ||
681 | GradeInfo gradensInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据 | ||
682 | StringBuffer sb = new StringBuffer(); | ||
683 | for (int i = 0; i < gradensInfo.getData().size(); i++) { | ||
684 | sb.append(gradensInfo.getData().get(i).getName() + ","); | ||
685 | |||
686 | } | ||
687 | Log.e("test", "年级" + sb.toString()); | ||
688 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.GRADENS, "" + sb.toString()); | ||
689 | |||
690 | |||
691 | } | ||
692 | |||
693 | @Override | ||
694 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
695 | new CircleDialog.Builder((FragmentActivity) mContext) | ||
696 | .setCanceledOnTouchOutside(false) | ||
697 | .setCancelable(false) | ||
698 | .setWidth(0.5f) | ||
699 | .configText(new ConfigText() { | ||
700 | @Override | ||
701 | public void onConfig(TextParams params) { | ||
702 | params.gravity = Gravity.CENTER; | ||
703 | params.padding = new int[]{50, 50, 50, 50}; | ||
704 | } | ||
705 | }) | ||
706 | .setText("当前无网络,请检查网络设置") | ||
707 | .setNegative("继续使用", null) | ||
708 | .setPositive("设置网络", new View.OnClickListener() { | ||
709 | @Override | ||
710 | public void onClick(View v) { | ||
711 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
712 | mContext.startActivity(intent); | ||
713 | } | ||
714 | }) | ||
715 | .show(); | ||
716 | } | ||
717 | }); | ||
718 | } | ||
719 | ///获取学校 | ||
720 | public void getschool(final Context mContext,int regionId,int gradeId) { | ||
721 | HttpClient.getInstance().addHeader("Accept", "application/json"); | ||
722 | HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() { | ||
723 | @Override | ||
724 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | ||
725 | Log.e("test", "学校" + new String(arg2)); | ||
726 | SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据 | ||
727 | StringBuffer sb = new StringBuffer(); | ||
728 | for (int i = 0; i < schoolInfo.getData().size(); i++) { | ||
729 | sb.append(schoolInfo.getData().get(i).getSchoolName() + ","); | ||
730 | |||
731 | } | ||
732 | Log.e("test", "学校" + sb.toString()); | ||
733 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.SCHOOL, "" + sb.toString()); | ||
734 | |||
735 | |||
736 | } | ||
737 | |||
738 | @Override | ||
739 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | ||
740 | new CircleDialog.Builder((FragmentActivity) mContext) | ||
741 | .setCanceledOnTouchOutside(false) | ||
742 | .setCancelable(false) | ||
743 | .setWidth(0.5f) | ||
744 | .configText(new ConfigText() { | ||
745 | @Override | ||
746 | public void onConfig(TextParams params) { | ||
747 | params.gravity = Gravity.CENTER; | ||
748 | params.padding = new int[]{50, 50, 50, 50}; | ||
749 | } | ||
750 | }) | ||
751 | .setText("当前无网络,请检查网络设置") | ||
752 | .setNegative("继续使用", null) | ||
753 | .setPositive("设置网络", new View.OnClickListener() { | ||
754 | @Override | ||
755 | public void onClick(View v) { | ||
756 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | ||
757 | mContext.startActivity(intent); | ||
758 | } | ||
759 | }) | ||
760 | .show(); | ||
761 | } | ||
762 | }); | ||
763 | } | ||
764 | |||
765 | |||
672 | 766 | ||
673 | 767 | ||
674 | 768 | ||
675 | ///省级接口 | 769 | ///省级接口 |
676 | public void provices(final Context mContext) { | 770 | public void provices(final Context mContext) { |
677 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 771 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
678 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { | 772 | HttpClient.getInstance().get(HttpUrl.provinceUrl, new AsyncHttpResponseHandler() { |
679 | @Override | 773 | @Override |
680 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 774 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
681 | Log.e("test", "省" + new String(arg2)); | 775 | Log.e("test", "省" + new String(arg2)); |
682 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 | 776 | ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据 |
683 | Log.e("test", "状态码" + provinceInfo.getStatus()); | 777 | Log.e("test", "状态码" + provinceInfo.getStatus()); |
684 | StringBuffer sb = new StringBuffer(); | 778 | StringBuffer sb = new StringBuffer(); |
685 | for (int i = 0; i < provinceInfo.getProvinces().size(); i++) { | 779 | for (int i = 0; i < provinceInfo.getProvinces().size(); i++) { |
686 | sb.append(provinceInfo.getProvinces().get(i).getRegionName() + ","); | 780 | sb.append(provinceInfo.getProvinces().get(i).getRegionName() + ","); |
687 | 781 | ||
688 | } | 782 | } |
689 | Log.e("test", "省" + sb.toString()); | 783 | Log.e("test", "省" + sb.toString()); |
690 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.PROVINCES, "" + sb.toString()); | 784 | SaveParam.getInstance().saveLoginParam(mContext, SaveParam.PROVINCES, "" + sb.toString()); |
691 | 785 | ||
692 | 786 | ||
693 | } | 787 | } |
694 | 788 | ||
695 | @Override | 789 | @Override |
696 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 790 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
697 | new CircleDialog.Builder((FragmentActivity) mContext) | 791 | new CircleDialog.Builder((FragmentActivity) mContext) |
698 | .setCanceledOnTouchOutside(false) | 792 | .setCanceledOnTouchOutside(false) |
699 | .setCancelable(false) | 793 | .setCancelable(false) |
700 | .setWidth(0.5f) | 794 | .setWidth(0.5f) |
701 | .configText(new ConfigText() { | 795 | .configText(new ConfigText() { |
702 | @Override | 796 | @Override |
703 | public void onConfig(TextParams params) { | 797 | public void onConfig(TextParams params) { |
704 | params.gravity = Gravity.CENTER; | 798 | params.gravity = Gravity.CENTER; |
705 | params.padding = new int[]{50, 50, 50, 50}; | 799 | params.padding = new int[]{50, 50, 50, 50}; |
706 | } | 800 | } |
707 | }) | 801 | }) |
708 | .setText("当前无网络,请检查网络设置") | 802 | .setText("当前无网络,请检查网络设置") |
709 | .setNegative("继续使用", null) | 803 | .setNegative("继续使用", null) |
710 | .setPositive("设置网络", new View.OnClickListener() { | 804 | .setPositive("设置网络", new View.OnClickListener() { |
711 | @Override | 805 | @Override |
712 | public void onClick(View v) { | 806 | public void onClick(View v) { |
713 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 807 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
714 | mContext.startActivity(intent); | 808 | mContext.startActivity(intent); |
715 | } | 809 | } |
716 | }) | 810 | }) |
717 | .show(); | 811 | .show(); |
718 | } | 812 | } |
719 | }); | 813 | }); |
720 | } | 814 | } |
721 | 815 | ||
722 | //市级接口 | 816 | //市级接口 |
723 | public void cityinfo(final Context mContext, int regionId) { | 817 | public void cityinfo(final Context mContext, int regionId) { |
724 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 818 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
725 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { | 819 | HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() { |
726 | @Override | 820 | @Override |
727 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 821 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
728 | Log.e("test", "市" + new String(arg2)); | 822 | Log.e("test", "市" + new String(arg2)); |
729 | Gson gson = new Gson(); | 823 | Gson gson = new Gson(); |
730 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); | 824 | CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class); |
731 | for (int i = 0; i < cityInfo.getCities().size(); i++) { | 825 | for (int i = 0; i < cityInfo.getCities().size(); i++) { |
732 | Log.e("test", "市" + cityInfo.getCities().get(i) | 826 | Log.e("test", "市" + cityInfo.getCities().get(i) |
733 | .getParentId()); | 827 | .getParentId()); |
734 | Log.e("test", "市" + cityInfo.getCities().get(i) | 828 | Log.e("test", "市" + cityInfo.getCities().get(i) |
735 | .getRegionId()); | 829 | .getRegionId()); |
736 | Log.e("test", "市" + cityInfo.getCities().get(i).getRegionName() + ""); | 830 | Log.e("test", "市" + cityInfo.getCities().get(i).getRegionName() + ""); |
737 | 831 | ||
738 | } | 832 | } |
739 | 833 | ||
740 | 834 | ||
741 | } | 835 | } |
742 | 836 | ||
743 | @Override | 837 | @Override |
744 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 838 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
745 | new CircleDialog.Builder((FragmentActivity) mContext) | 839 | new CircleDialog.Builder((FragmentActivity) mContext) |
746 | .setCanceledOnTouchOutside(false) | 840 | .setCanceledOnTouchOutside(false) |
747 | .setCancelable(false) | 841 | .setCancelable(false) |
748 | .setWidth(0.5f) | 842 | .setWidth(0.5f) |
749 | .configText(new ConfigText() { | 843 | .configText(new ConfigText() { |
750 | @Override | 844 | @Override |
751 | public void onConfig(TextParams params) { | 845 | public void onConfig(TextParams params) { |
752 | params.gravity = Gravity.CENTER; | 846 | params.gravity = Gravity.CENTER; |
753 | params.padding = new int[]{50, 50, 50, 50}; | 847 | params.padding = new int[]{50, 50, 50, 50}; |
754 | } | 848 | } |
755 | }) | 849 | }) |
756 | .setText("当前无网络,请检查网络设置") | 850 | .setText("当前无网络,请检查网络设置") |
757 | .setNegative("继续使用", null) | 851 | .setNegative("继续使用", null) |
758 | .setPositive("设置网络", new View.OnClickListener() { | 852 | .setPositive("设置网络", new View.OnClickListener() { |
759 | @Override | 853 | @Override |
760 | public void onClick(View v) { | 854 | public void onClick(View v) { |
761 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 855 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
762 | mContext.startActivity(intent); | 856 | mContext.startActivity(intent); |
763 | } | 857 | } |
764 | }) | 858 | }) |
765 | .show(); | 859 | .show(); |
766 | } | 860 | } |
767 | }); | 861 | }); |
768 | } | 862 | } |
769 | 863 | ||
770 | //区县级接口 | 864 | //区县级接口 |
771 | public void countyinfo(final Context mContext, int parentId) { | 865 | public void countyinfo(final Context mContext, int parentId) { |
772 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | 866 | HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); |
773 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { | 867 | HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() { |
774 | @Override | 868 | @Override |
775 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { | 869 | public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { |
776 | Log.e("test", "区" + new String(arg2)); | 870 | Log.e("test", "区" + new String(arg2)); |
777 | Gson gson = new Gson(); | 871 | Gson gson = new Gson(); |
778 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); | 872 | CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class); |
779 | for (int i = 0; i < countyInfo.getCounties().size(); i++) { | 873 | for (int i = 0; i < countyInfo.getCounties().size(); i++) { |
780 | Log.e("test", "区" + countyInfo.getCounties().get(i) | 874 | Log.e("test", "区" + countyInfo.getCounties().get(i) |
781 | .getParentId()); | 875 | .getParentId()); |
782 | Log.e("test", "区" + countyInfo.getCounties().get(i) | 876 | Log.e("test", "区" + countyInfo.getCounties().get(i) |
783 | .getRegionId()); | 877 | .getRegionId()); |
784 | Log.e("test", "区" + countyInfo.getCounties().get(i).getRegionName() + ""); | 878 | Log.e("test", "区" + countyInfo.getCounties().get(i).getRegionName() + ""); |
785 | 879 | ||
786 | } | 880 | } |
787 | 881 | ||
788 | 882 | ||
789 | } | 883 | } |
790 | 884 | ||
791 | @Override | 885 | @Override |
792 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { | 886 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
793 | new CircleDialog.Builder((FragmentActivity) mContext) | 887 | new CircleDialog.Builder((FragmentActivity) mContext) |
794 | .setCanceledOnTouchOutside(false) | 888 | .setCanceledOnTouchOutside(false) |
795 | .setCancelable(false) | 889 | .setCancelable(false) |
796 | .setWidth(0.5f) | 890 | .setWidth(0.5f) |
797 | .configText(new ConfigText() { | 891 | .configText(new ConfigText() { |
798 | @Override | 892 | @Override |
799 | public void onConfig(TextParams params) { | 893 | public void onConfig(TextParams params) { |
800 | params.gravity = Gravity.CENTER; | 894 | params.gravity = Gravity.CENTER; |
801 | params.padding = new int[]{50, 50, 50, 50}; | 895 | params.padding = new int[]{50, 50, 50, 50}; |
802 | } | 896 | } |
803 | }) | 897 | }) |
804 | .setText("当前无网络,请检查网络设置") | 898 | .setText("当前无网络,请检查网络设置") |
805 | .setNegative("继续使用", null) | 899 | .setNegative("继续使用", null) |
806 | .setPositive("设置网络", new View.OnClickListener() { | 900 | .setPositive("设置网络", new View.OnClickListener() { |
807 | @Override | 901 | @Override |
808 | public void onClick(View v) { | 902 | public void onClick(View v) { |
809 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 | 903 | Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面 |
810 | mContext.startActivity(intent); | 904 | mContext.startActivity(intent); |
811 | } | 905 | } |
812 | }) | 906 | }) |
813 | .show(); | 907 | .show(); |
814 | } | 908 | } |
815 | }); | 909 | }); |
816 | } | 910 | } |
817 | 911 | ||
818 | 912 | ||
819 | private void closeProgress() { | 913 | private void closeProgress() { |
820 | try { | 914 | try { |
821 | if (mProgress != null) { | 915 | if (mProgress != null) { |
822 | mProgress.dismiss(); | 916 | mProgress.dismiss(); |
823 | mProgress = null; | 917 | mProgress = null; |
824 | } | 918 | } |
825 | } catch (Exception e) { | 919 | } catch (Exception e) { |
826 | e.printStackTrace(); | 920 | e.printStackTrace(); |
827 | } | 921 | } |
828 | } | 922 | } |
829 | 923 | ||
830 | } | 924 | } |
831 | 925 |
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";//学校 | ||
16 | public static String gradesUrl = GetDomain()+"/grades";//年级 | ||
15 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 | 17 | public static String provinceUrl = GetDomain()+"/ozing/provinces";//省 |
16 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 | 18 | public static String cityUrl = GetDomain()+"/ozing/cities";//市 |
17 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 | 19 | public static String countyUrl = GetDomain()+"/ozing/counties";//区县 |
18 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ | 20 | public static String forgetpassword=GetDomain()+"/ozing/timer/user/newpassword";//忘记密码/ |
19 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 | 21 | public static String registeredUrl=GetDomain()+"/ozing/timer/anking/user";//注册 |
20 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 | 22 | public static String authCodedUrl=GetDomain()+"/ozing/timer/user/fetchAuthCode";//验证码 |
21 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 | 23 | public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册 |
22 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 | 24 | public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码 |
23 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 | 25 | public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息 |
24 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 | 26 | public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息 |
25 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 | 27 | public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息 |
26 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 | 28 | public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写 |
27 | 29 | ||
28 | } | 30 | } |
29 | 31 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/GradeInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | public class GradeInfo { | ||
6 | |||
7 | private List<DataBean> data; | ||
8 | |||
9 | public List<DataBean> getData() { | ||
10 | return data; | ||
11 | } | ||
12 | |||
13 | public void setData(List<DataBean> data) { | ||
14 | this.data = data; | ||
15 | } | ||
16 | |||
17 | public static class DataBean { | ||
18 | /** | ||
19 | * name : 小学 | ||
20 | * id : 1 | ||
21 | * children : [{"name":"一年级","id":2},{"name":"二年级","id":3},{"name":"三年级","id":4},{"name":"四年级","id":5},{"name":"五年级","id":6},{"name":"小学六年级","id":7}] | ||
22 | */ | ||
23 | |||
24 | private String name; | ||
25 | private int id; | ||
26 | private List<ChildrenBean> children; | ||
27 | |||
28 | public String getName() { | ||
29 | return name; | ||
30 | } | ||
31 | |||
32 | public void setName(String name) { | ||
33 | this.name = name; | ||
34 | } | ||
35 | |||
36 | public int getId() { | ||
37 | return id; | ||
38 | } | ||
39 | |||
40 | public void setId(int id) { | ||
41 | this.id = id; | ||
42 | } | ||
43 | |||
44 | public List<ChildrenBean> getChildren() { | ||
45 | return children; | ||
46 | } | ||
47 | |||
48 | public void setChildren(List<ChildrenBean> children) { | ||
49 | this.children = children; | ||
50 | } | ||
51 | |||
52 | public static class ChildrenBean { | ||
53 | /** | ||
54 | * name : 一年级 | ||
55 | * id : 2 | ||
56 | */ | ||
57 | |||
58 | private String name; | ||
59 | private int id; | ||
60 | |||
61 | public String getName() { | ||
62 | return name; | ||
63 | } | ||
64 | |||
65 | public void setName(String name) { | ||
66 | this.name = name; | ||
67 | } | ||
68 | |||
69 | public int getId() { | ||
70 | return id; | ||
71 | } | ||
72 | |||
73 | public void setId(int id) { | ||
74 | this.id = id; | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/SchoolInfo.java
File was created | 1 | package com.hjx.personalcenter.model; | |
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | /** | ||
6 | * Created by h on 2017/8/21. | ||
7 | */ | ||
8 | |||
9 | public class SchoolInfo { | ||
10 | |||
11 | /** | ||
12 | * status : 1 | ||
13 | * pageSize : 0 | ||
14 | * data : [{"schoolName":"自强学校","schoolId":554606},{"schoolName":"石家庄十三中","schoolId":560171},{"schoolName":"石家庄五十中","schoolId":560172},{"schoolName":"石家庄二十二中","schoolId":561412},{"schoolName":"石家庄二十四中","schoolId":561413},{"schoolName":"石家庄四十五中","schoolId":561414},{"schoolName":"石家庄五十二中","schoolId":561415},{"schoolName":"石家庄五十三中","schoolId":561416},{"schoolName":"石家庄五十一中","schoolId":561417},{"schoolName":"国化工十二建公学校","schoolId":562347},{"schoolName":"建一局六公司子弟学校","schoolId":562540},{"schoolName":"石家庄八十二中(化肥厂学校)","schoolId":562966},{"schoolName":"固安一中","schoolId":605836},{"schoolName":"石家庄市二十一中","schoolId":647584}] | ||
15 | * msg : success | ||
16 | * pageNum : 0 | ||
17 | */ | ||
18 | |||
19 | private int status; | ||
20 | private int pageSize; | ||
21 | private String msg; | ||
22 | private int pageNum; | ||
23 | private List<DataBean> data; | ||
24 | |||
25 | public int getStatus() { | ||
26 | return status; | ||
27 | } | ||
28 | |||
29 | public void setStatus(int status) { | ||
30 | this.status = status; | ||
31 | } | ||
32 | |||
33 | public int getPageSize() { | ||
34 | return pageSize; | ||
35 | } | ||
36 | |||
37 | public void setPageSize(int pageSize) { | ||
38 | this.pageSize = pageSize; | ||
39 | } | ||
40 | |||
41 | public String getMsg() { | ||
42 | return msg; | ||
43 | } | ||
44 | |||
45 | public void setMsg(String msg) { | ||
46 | this.msg = msg; | ||
47 | } | ||
48 | |||
49 | public int getPageNum() { | ||
50 | return pageNum; | ||
51 | } | ||
52 | |||
53 | public void setPageNum(int pageNum) { | ||
54 | this.pageNum = pageNum; | ||
55 | } | ||
56 | |||
57 | public List<DataBean> getData() { | ||
58 | return data; | ||
59 | } | ||
60 | |||
61 | public void setData(List<DataBean> data) { | ||
62 | this.data = data; | ||
63 | } | ||
64 | |||
65 | public static class DataBean { | ||
66 | /** | ||
67 | * schoolName : 自强学校 | ||
68 | * schoolId : 554606 | ||
69 | */ | ||
70 | |||
71 | private String schoolName; | ||
72 | private int schoolId; | ||
73 | |||
74 | public String getSchoolName() { | ||
75 | return schoolName; | ||
76 | } | ||
77 | |||
78 | public void setSchoolName(String schoolName) { | ||
79 | this.schoolName = schoolName; | ||
80 | } | ||
81 | |||
82 | public int getSchoolId() { | ||
83 | return schoolId; | ||
84 | } | ||
85 | |||
86 | public void setSchoolId(int schoolId) { | ||
87 | this.schoolId = schoolId; | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/CropUtils.java
File was created | 1 | package com.hjx.personalcenter.util; | |
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.content.ContentUris; | ||
5 | import android.content.Context; | ||
6 | import android.database.Cursor; | ||
7 | import android.net.Uri; | ||
8 | import android.os.Build; | ||
9 | import android.os.Environment; | ||
10 | import android.provider.DocumentsContract; | ||
11 | import android.provider.MediaStore; | ||
12 | import android.util.Log; | ||
13 | |||
14 | import static android.content.ContentValues.TAG; | ||
15 | |||
16 | /** | ||
17 | * Created by yf on 2016/2/23. | ||
18 | */ | ||
19 | public class CropUtils { | ||
20 | @SuppressLint("NewApi") | ||
21 | public static String getPath(final Context context, final Uri uri) { | ||
22 | |||
23 | final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; | ||
24 | |||
25 | // DocumentProvider | ||
26 | if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { | ||
27 | // ExternalStorageProvider | ||
28 | if (isExternalStorageDocument(uri)) { | ||
29 | final String docId = DocumentsContract.getDocumentId(uri); | ||
30 | final String[] split = docId.split(":"); | ||
31 | final String type = split[0]; | ||
32 | |||
33 | if ("primary".equalsIgnoreCase(type)) { | ||
34 | return Environment.getExternalStorageDirectory() + "/" + split[1]; | ||
35 | } | ||
36 | |||
37 | } | ||
38 | // DownloadsProvider | ||
39 | else if (isDownloadsDocument(uri)) { | ||
40 | |||
41 | final String id = DocumentsContract.getDocumentId(uri); | ||
42 | final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); | ||
43 | |||
44 | return getDataColumn(context, contentUri, null, null); | ||
45 | } | ||
46 | // MediaProvider | ||
47 | else if (isMediaDocument(uri)) { | ||
48 | final String docId = DocumentsContract.getDocumentId(uri); | ||
49 | final String[] split = docId.split(":"); | ||
50 | final String type = split[0]; | ||
51 | |||
52 | Uri contentUri = null; | ||
53 | if ("image".equals(type)) { | ||
54 | contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; | ||
55 | } else if ("video".equals(type)) { | ||
56 | contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; | ||
57 | } else if ("audio".equals(type)) { | ||
58 | contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; | ||
59 | } | ||
60 | |||
61 | final String selection = "_id=?"; | ||
62 | final String[] selectionArgs = new String[]{split[1]}; | ||
63 | |||
64 | return getDataColumn(context, contentUri, selection, selectionArgs); | ||
65 | } | ||
66 | } | ||
67 | // MediaStore (and general) | ||
68 | else if ("content".equalsIgnoreCase(uri.getScheme())) { | ||
69 | return getDataColumn(context, uri, null, null); | ||
70 | } | ||
71 | // File | ||
72 | else if ("file".equalsIgnoreCase(uri.getScheme())) { | ||
73 | return uri.getPath(); | ||
74 | } else { | ||
75 | String uriStr = uri.toString(); | ||
76 | String path = uriStr.substring(10, uriStr.length()); | ||
77 | if (path.startsWith("com.sec.android.gallery3d")) { | ||
78 | Log.e(TAG, "It's auto backup pic path:" + uri.toString()); | ||
79 | return null; | ||
80 | } | ||
81 | String[] filePathColumn = {MediaStore.Images.Media.DATA}; | ||
82 | Cursor cursor = context.getContentResolver().query(uri, filePathColumn, null, null, null); | ||
83 | if (cursor != null) { | ||
84 | cursor.moveToFirst(); | ||
85 | } | ||
86 | int columnIndex = cursor.getColumnIndex(filePathColumn[0]); | ||
87 | String picturePath = cursor.getString(columnIndex); | ||
88 | cursor.close(); | ||
89 | return picturePath; | ||
90 | } | ||
91 | |||
92 | return null; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * Get the value of the data column for this Uri. This is useful for | ||
97 | * MediaStore Uris, and other file-based ContentProviders. | ||
98 | * | ||
99 | * @param context The context. | ||
100 | * @param uri The Uri to query. | ||
101 | * @param selection (Optional) Filter used in the query. | ||
102 | * @param selectionArgs (Optional) Selection arguments used in the query. | ||
103 | * @return The value of the _data column, which is typically a file path. | ||
104 | */ | ||
105 | private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { | ||
106 | |||
107 | Cursor cursor = null; | ||
108 | final String column = "_data"; | ||
109 | final String[] projection = {column}; | ||
110 | |||
111 | try { | ||
112 | cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); | ||
113 | if (cursor != null && cursor.moveToFirst()) { | ||
114 | final int column_index = cursor.getColumnIndexOrThrow(column); | ||
115 | return cursor.getString(column_index); | ||
116 | } | ||
117 | } finally { | ||
118 | if (cursor != null) | ||
119 | cursor.close(); | ||
120 | } | ||
121 | return null; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * @param uri The Uri to check. | ||
126 | * @return Whether the Uri authority is ExternalStorageProvider. | ||
127 | */ | ||
128 | private static boolean isExternalStorageDocument(Uri uri) { | ||
129 | return "com.android.externalstorage.documents".equals(uri.getAuthority()); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * @param uri The Uri to check. | ||
134 | * @return Whether the Uri authority is DownloadsProvider. | ||
135 | */ | ||
136 | private static boolean isDownloadsDocument(Uri uri) { | ||
137 | return "com.android.providers.downloads.documents".equals(uri.getAuthority()); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * @param uri The Uri to check. | ||
142 | * @return Whether the Uri authority is MediaProvider. | ||
143 | */ | ||
144 | private static boolean isMediaDocument(Uri uri) { | ||
145 | return "com.android.providers.media.documents".equals(uri.getAuthority()); | ||
146 | } | ||
147 | |||
148 | } | ||
149 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/FileUtil.java
File was created | 1 | package com.hjx.personalcenter.util; | |
2 | |||
3 | |||
4 | import android.content.Context; | ||
5 | import android.graphics.Bitmap; | ||
6 | import android.graphics.BitmapFactory; | ||
7 | import android.os.Environment; | ||
8 | import android.util.Log; | ||
9 | |||
10 | import java.io.File; | ||
11 | import java.io.FileNotFoundException; | ||
12 | import java.io.FileOutputStream; | ||
13 | import java.io.OutputStream; | ||
14 | |||
15 | /** | ||
16 | * Created by yf on 2016/7/22 0022. | ||
17 | * 文件的缓存与读取 | ||
18 | */ | ||
19 | public class FileUtil { | ||
20 | private static final String TAG = "FileUtil"; | ||
21 | |||
22 | /** | ||
23 | * 获取缓存路径 | ||
24 | * | ||
25 | * @param context | ||
26 | * @return | ||
27 | */ | ||
28 | public static String getCachePath(Context context) { | ||
29 | String cachePath = null; | ||
30 | |||
31 | if (Environment.MEDIA_MOUNTED.equals(Environment | ||
32 | .getExternalStorageState()) | ||
33 | || !Environment.isExternalStorageRemovable()) { | ||
34 | |||
35 | cachePath = context.getExternalCacheDir().getPath(); | ||
36 | |||
37 | } else { | ||
38 | cachePath = context.getCacheDir().getPath(); | ||
39 | } | ||
40 | return cachePath; | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * 删除指定文件 | ||
45 | * | ||
46 | * @param file | ||
47 | * @return | ||
48 | */ | ||
49 | public static boolean deleteFile(File file) { | ||
50 | if (file.exists() && file.isFile()) { | ||
51 | return file.delete(); | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * 递归删除文件和文件夹 | ||
58 | * | ||
59 | * @param file 要删除的根目录 | ||
60 | */ | ||
61 | public static void recursionDeleteFile(File file) { | ||
62 | if (file.isFile()) { | ||
63 | file.delete(); | ||
64 | return; | ||
65 | } | ||
66 | if (file.isDirectory()) { | ||
67 | File[] childFile = file.listFiles(); | ||
68 | if (childFile == null || childFile.length == 0) { | ||
69 | file.delete(); | ||
70 | return; | ||
71 | } | ||
72 | for (File f : childFile) { | ||
73 | recursionDeleteFile(f); | ||
74 | } | ||
75 | file.delete(); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * 压缩图片方法,为了上传到服务器,保证图片大小在100k一下 | ||
82 | * | ||
83 | * @param context | ||
84 | * @param fileSrc | ||
85 | * @return | ||
86 | */ | ||
87 | public static File getSmallBitmap(Context context, String fileSrc) { | ||
88 | BitmapFactory.Options options = new BitmapFactory.Options(); | ||
89 | options.inJustDecodeBounds = true; | ||
90 | BitmapFactory.decodeFile(fileSrc, options); | ||
91 | options.inSampleSize = calculateInSampleSize(options, 480, 800); | ||
92 | Log.i(TAG, "options.inSampleSize-->" + options.inSampleSize); | ||
93 | options.inJustDecodeBounds = false; | ||
94 | Bitmap img = BitmapFactory.decodeFile(fileSrc, options); | ||
95 | Log.i(TAG, "file size after compress-->" + img.getByteCount() / 256); | ||
96 | String filename = context.getFilesDir() + File.separator + "video-" + img.hashCode() + ".jpg"; | ||
97 | saveBitmap2File(img, filename); | ||
98 | return new File(filename); | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * 设置压缩的图片的大小设置的参数 | ||
103 | * | ||
104 | * @param options | ||
105 | * @param reqWidth | ||
106 | * @param reqHeight | ||
107 | * @return | ||
108 | */ | ||
109 | public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { | ||
110 | int height = options.outHeight; | ||
111 | int width = options.outWidth; | ||
112 | int inSampleSize = 1; | ||
113 | if (height > reqHeight || width > reqWidth) { | ||
114 | int heightRatio = Math.round(height) / reqHeight; | ||
115 | int widthRatio = Math.round(width) / reqWidth; | ||
116 | inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; | ||
117 | } | ||
118 | return inSampleSize; | ||
119 | } | ||
120 | |||
121 | |||
122 | /** | ||
123 | * 保存bitmap到文件 | ||
124 | * | ||
125 | * @param bmp | ||
126 | * @param filename | ||
127 | * @return | ||
128 | */ | ||
129 | public static boolean saveBitmap2File(Bitmap bmp, String filename) { | ||
130 | Bitmap.CompressFormat format = Bitmap.CompressFormat.JPEG; | ||
131 | int quality = 50;//压缩50% 100表示不压缩 | ||
132 | OutputStream stream = null; | ||
133 | try { | ||
134 | stream = new FileOutputStream(filename); | ||
135 | } catch (FileNotFoundException e) { | ||
136 | // TODO Auto-generated catch block | ||
137 | e.printStackTrace(); | ||
138 | } | ||
139 | |||
140 | return bmp.compress(format, quality, stream); | ||
141 | } | ||
142 | } |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/ImageCache.java
File was created | 1 | ||
2 | |||
3 | package com.hjx.personalcenter.util; | ||
4 | |||
5 | import android.graphics.Bitmap; | ||
6 | |||
7 | import java.util.WeakHashMap; | ||
8 | |||
9 | public class ImageCache extends WeakHashMap<String, Bitmap> { | ||
10 | |||
11 | private static final long serialVersionUID = 1L; | ||
12 | |||
13 | public boolean isCached(String url){ | ||
14 | return containsKey(url) && get(url) != null; | ||
15 | } | ||
16 | |||
17 | } | ||
18 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/PermissionUtil.java
File was created | 1 | package com.hjx.personalcenter.util; | |
2 | |||
3 | import android.Manifest; | ||
4 | import android.app.Activity; | ||
5 | import android.content.pm.PackageManager; | ||
6 | import android.os.Build; | ||
7 | import android.support.v4.app.ActivityCompat; | ||
8 | import android.support.v4.content.ContextCompat; | ||
9 | import android.support.v4.util.SimpleArrayMap; | ||
10 | import android.util.Log; | ||
11 | |||
12 | /** | ||
13 | * Created by yf on 2016/7/22 0022. | ||
14 | */ | ||
15 | public class PermissionUtil { | ||
16 | public static final int REQUEST_SHOWCAMERA = 0; | ||
17 | public static final int REQUEST_READ_EXTERNAL_STORAGE = 1; | ||
18 | public static final int REQUEST_RECORD_AUDIO = 2; | ||
19 | public static final int REQUEST_CONTACTS = 3; | ||
20 | public static final int REQUEST_LOCATION = 4; | ||
21 | |||
22 | |||
23 | private static final SimpleArrayMap<String, Integer> MIN_SDK_PERMISSIONS; | ||
24 | static { | ||
25 | MIN_SDK_PERMISSIONS = new SimpleArrayMap<>(8); | ||
26 | MIN_SDK_PERMISSIONS.put("com.android.voicemail.permission.ADD_VOICEMAIL", 14); | ||
27 | MIN_SDK_PERMISSIONS.put("android.permission.BODY_SENSORS", 20); | ||
28 | MIN_SDK_PERMISSIONS.put("android.permission.READ_CALL_LOG", 16); | ||
29 | MIN_SDK_PERMISSIONS.put("android.permission.READ_EXTERNAL_STORAGE", 16); | ||
30 | MIN_SDK_PERMISSIONS.put("android.permission.USE_SIP", 9); | ||
31 | MIN_SDK_PERMISSIONS.put("android.permission.WRITE_CALL_LOG", 16); | ||
32 | MIN_SDK_PERMISSIONS.put("android.permission.SYSTEM_ALERT_WINDOW", 23); | ||
33 | MIN_SDK_PERMISSIONS.put("android.permission.WRITE_SETTINGS", 23); | ||
34 | } | ||
35 | private static boolean permissionExists(String permission) { | ||
36 | Integer minVersion = MIN_SDK_PERMISSIONS.get(permission); | ||
37 | return minVersion == null || Build.VERSION.SDK_INT >= minVersion; | ||
38 | } | ||
39 | |||
40 | public static boolean hasCameraPermission(Activity activity){ | ||
41 | int hasPermission = ContextCompat.checkSelfPermission(activity, | ||
42 | Manifest.permission.CAMERA); | ||
43 | if(!permissionExists(Manifest.permission.CAMERA)){ | ||
44 | Log.e("permission","your system does not suppport"+ Manifest.permission.CAMERA+" permission"); | ||
45 | return false; | ||
46 | } | ||
47 | if (hasPermission != PackageManager.PERMISSION_GRANTED) { | ||
48 | ActivityCompat.requestPermissions(activity, | ||
49 | new String[]{Manifest.permission.CAMERA}, | ||
50 | PermissionUtil.REQUEST_SHOWCAMERA); | ||
51 | return false; | ||
52 | } | ||
53 | return true; | ||
54 | } | ||
55 | |||
56 | public static boolean hasReadExternalStoragePermission(Activity activity){ | ||
57 | int hasPermission = ContextCompat.checkSelfPermission(activity, | ||
58 | Manifest.permission.READ_EXTERNAL_STORAGE); | ||
59 | if(!permissionExists(Manifest.permission.READ_EXTERNAL_STORAGE)){ | ||
60 | Log.e("permission","your system does not suppport "+ Manifest.permission.READ_EXTERNAL_STORAGE+" permission"); | ||
61 | return false; | ||
62 | } | ||
63 | if (hasPermission != PackageManager.PERMISSION_GRANTED) { | ||
64 | ActivityCompat.requestPermissions(activity, | ||
65 | new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, | ||
66 | PermissionUtil.REQUEST_READ_EXTERNAL_STORAGE); | ||
67 | return false; | ||
68 | } | ||
69 | return true; | ||
70 | } | ||
71 | public static boolean hasRecordAudioPermission(Activity activity){ | ||
72 | int hasPermission = ContextCompat.checkSelfPermission(activity, | ||
73 | Manifest.permission.RECORD_AUDIO); | ||
74 | if(!permissionExists(Manifest.permission.RECORD_AUDIO)){ | ||
75 | Log.e("permission","your system does not suppport"+ Manifest.permission.RECORD_AUDIO+" permission"); | ||
76 | return false; | ||
77 | } | ||
78 | if (hasPermission != PackageManager.PERMISSION_GRANTED) { | ||
79 | ActivityCompat.requestPermissions(activity, | ||
80 | new String[]{Manifest.permission.RECORD_AUDIO}, | ||
81 | PermissionUtil.REQUEST_RECORD_AUDIO); | ||
82 | return false; | ||
83 | } | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | public static boolean hasContactsPermission(Activity activity){ | ||
88 | int hasWPermission = ContextCompat.checkSelfPermission(activity, | ||
89 | Manifest.permission.WRITE_CONTACTS); | ||
90 | int hasRPermission = ContextCompat.checkSelfPermission(activity, | ||
91 | Manifest.permission.READ_CONTACTS); | ||
92 | |||
93 | if(hasRPermission== PackageManager.PERMISSION_GRANTED && hasWPermission== PackageManager.PERMISSION_GRANTED){ | ||
94 | return true; | ||
95 | } | ||
96 | ActivityCompat.requestPermissions(activity, | ||
97 | new String[]{Manifest.permission.WRITE_CONTACTS, Manifest.permission.READ_CONTACTS}, | ||
98 | PermissionUtil.REQUEST_CONTACTS); | ||
99 | return false; | ||
100 | } | ||
101 | public static boolean hasLocationPermission(Activity activity){ | ||
102 | int hasFPermission = ContextCompat.checkSelfPermission(activity, | ||
103 | Manifest.permission.ACCESS_FINE_LOCATION); | ||
104 | int hasCPermission = ContextCompat.checkSelfPermission(activity, | ||
105 | Manifest.permission.ACCESS_COARSE_LOCATION); | ||
106 | |||
107 | if(hasFPermission== PackageManager.PERMISSION_GRANTED&&hasCPermission== PackageManager.PERMISSION_GRANTED){ | ||
108 | return true; | ||
109 | } | ||
110 | ActivityCompat.requestPermissions(activity, | ||
111 | new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, | ||
112 | PermissionUtil.REQUEST_LOCATION); | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | } | ||
117 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/SharedPreferenceMark.java
File was created | 1 | package com.hjx.personalcenter.util; | |
2 | |||
3 | /** | ||
4 | * SharedPreference存储 记录只出现一次的组件是否已经出现过 | ||
5 | * Created by yf on 2016/7/25. | ||
6 | */ | ||
7 | public final class SharedPreferenceMark { | ||
8 | |||
9 | |||
10 | public static Boolean hasShowCamera=false;//是否已经提示过摄像头权限 | ||
11 | public static Boolean hasShowLocation=false;//是否已经提示过摄像头权限 | ||
12 | public static Boolean hasShowRecordAudio=false;//是否已经提示过摄像头权限 | ||
13 | public static Boolean hasShowExtralStoreage=false;//是否已经提示过摄像头权限 | ||
14 | public static Boolean hasShowContact=false;//是否已经提示过摄像头权限 | ||
15 | |||
16 | |||
17 | public static Boolean getHasShowCamera() { | ||
18 | return hasShowCamera; | ||
19 | } | ||
20 | |||
21 | public static void setHasShowCamera(Boolean hasShowCamera) { | ||
22 | SharedPreferenceMark.hasShowCamera = hasShowCamera; | ||
23 | } | ||
24 | |||
25 | public static Boolean getHasShowLocation() { | ||
26 | return hasShowLocation; | ||
27 | } | ||
28 | |||
29 | public static void setHasShowLocation(Boolean hasShowLocation) { | ||
30 | SharedPreferenceMark.hasShowLocation = hasShowLocation; | ||
31 | } | ||
32 | |||
33 | public static Boolean getHasShowRecordAudio() { | ||
34 | return hasShowRecordAudio; | ||
35 | } | ||
36 | |||
37 | public static void setHasShowRecordAudio(Boolean hasShowRecordAudio) { | ||
38 | SharedPreferenceMark.hasShowRecordAudio = hasShowRecordAudio; | ||
39 | } | ||
40 | |||
41 | public static Boolean getHasShowExtralStoreage() { | ||
42 | return hasShowExtralStoreage; | ||
43 | } | ||
44 | |||
45 | public static void setHasShowExtralStoreage(Boolean hasShowExtralStoreage) { | ||
46 | SharedPreferenceMark.hasShowExtralStoreage = hasShowExtralStoreage; | ||
47 | } | ||
48 | |||
49 | public static Boolean getHasShowContact() { | ||
50 | return hasShowContact; | ||
51 | } | ||
52 | |||
53 | public static void setHasShowContact(Boolean hasShowContact) { | ||
54 | SharedPreferenceMark.hasShowContact = hasShowContact; | ||
55 | } | ||
56 | } | ||
57 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/widget/ClearEditText.java
File was created | 1 | package com.hjx.personalcenter.widget; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.graphics.Rect; | ||
5 | import android.graphics.drawable.Drawable; | ||
6 | import android.text.Editable; | ||
7 | import android.text.TextWatcher; | ||
8 | import android.util.AttributeSet; | ||
9 | import android.view.MotionEvent; | ||
10 | import android.view.View; | ||
11 | import android.view.animation.Animation; | ||
12 | import android.view.animation.CycleInterpolator; | ||
13 | import android.view.animation.TranslateAnimation; | ||
14 | import android.widget.EditText; | ||
15 | |||
16 | import com.hjx.personalcenter.R; | ||
17 | |||
18 | /** | ||
19 | * 项目名称:EditSearch | ||
20 | * 类描述: | ||
21 | * 创建人:tonycheng | ||
22 | * 创建时间:2016/4/26 14:39 | ||
23 | * 邮箱:tonycheng93@outlook.com | ||
24 | * 修改人: | ||
25 | * 修改时间: | ||
26 | * 修改备注: | ||
27 | */ | ||
28 | public class ClearEditText extends EditText implements View.OnFocusChangeListener,TextWatcher { | ||
29 | /** | ||
30 | * 删除按钮的引用 | ||
31 | */ | ||
32 | private Drawable mClearDrawable; | ||
33 | private Context context; | ||
34 | |||
35 | /** | ||
36 | * 控件是否有焦点 | ||
37 | */ | ||
38 | private boolean hasFocus; | ||
39 | |||
40 | public ClearEditText(Context context) { | ||
41 | this(context,null); | ||
42 | // super(context); | ||
43 | // this.context = context; | ||
44 | // init(); | ||
45 | } | ||
46 | public ClearEditText(Context context, AttributeSet attrs){ | ||
47 | //这里构造方法也很重要,不加这个很多属性不能再XML里面定义 | ||
48 | this(context, attrs, android.R.attr.editTextStyle); | ||
49 | } | ||
50 | |||
51 | public ClearEditText(Context context, AttributeSet attrs, int defStyle) { | ||
52 | super(context, attrs, defStyle); | ||
53 | init(); | ||
54 | } | ||
55 | private void init() { | ||
56 | //获取EditText的DrawableRight,假如没有设置我们就使用默认的图片 | ||
57 | mClearDrawable = getCompoundDrawables()[2]; | ||
58 | if (mClearDrawable == null) { | ||
59 | mClearDrawable = getResources().getDrawable(R.drawable.delete_selector); | ||
60 | } | ||
61 | mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight()); | ||
62 | //默认设置隐藏图标 | ||
63 | setClearIconVisible(false); | ||
64 | //设置焦点改变的监听 | ||
65 | setOnFocusChangeListener(this); | ||
66 | //设置输入框里面内容发生改变的监听 | ||
67 | addTextChangedListener(this); | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | public boolean onTouchEvent(MotionEvent event) { | ||
72 | |||
73 | if (mClearDrawable != null && event.getAction() == MotionEvent.ACTION_UP) { | ||
74 | int x = (int) event.getX(); | ||
75 | //判断触摸点是否在水平范围内 | ||
76 | boolean isInnerWidth = (x > (getWidth() - getTotalPaddingRight())) && | ||
77 | (x < (getWidth() - getPaddingRight())); | ||
78 | //获取删除图标的边界,返回一个Rect对象 | ||
79 | Rect rect = mClearDrawable.getBounds(); | ||
80 | //获取删除图标的高度 | ||
81 | int height = rect.height(); | ||
82 | int y = (int) event.getY(); | ||
83 | //计算图标底部到控件底部的距离 | ||
84 | int distance = (getHeight() - height) / 2; | ||
85 | //判断触摸点是否在竖直范围内(可能会有点误差) | ||
86 | //触摸点的纵坐标在distance到(distance+图标自身的高度)之内,则视为点中删除图标 | ||
87 | boolean isInnerHeight = (y > distance) && (y < (distance + height)); | ||
88 | if (isInnerHeight && isInnerWidth) { | ||
89 | this.setText(""); | ||
90 | } | ||
91 | } | ||
92 | return super.onTouchEvent(event); | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * 设置清除图标的显示与隐藏,调用setCompoundDrawables为EditText绘制上去 | ||
97 | * | ||
98 | * @param visible | ||
99 | */ | ||
100 | private void setClearIconVisible(boolean visible) { | ||
101 | Drawable right = visible ? mClearDrawable : null; | ||
102 | setCompoundDrawables(getCompoundDrawables()[0], getCompoundDrawables()[1], | ||
103 | right, getCompoundDrawables()[3]); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * 当ClearEditText焦点发生变化的时候,判断里面字符串长度设置清除图标的显示与隐藏 | ||
108 | */ | ||
109 | @Override | ||
110 | public void onFocusChange(View v, boolean hasFocus) { | ||
111 | this.hasFocus = hasFocus; | ||
112 | if (hasFocus) { | ||
113 | setClearIconVisible(getText().length() > 0); | ||
114 | } else { | ||
115 | setClearIconVisible(false); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * 当输入框里面内容发生变化的时候回调的方法 | ||
121 | */ | ||
122 | @Override | ||
123 | public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { | ||
124 | if (hasFocus) { | ||
125 | setClearIconVisible(text.length() > 0); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | ||
131 | |||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public void afterTextChanged(Editable s) { | ||
136 | |||
137 | } | ||
138 | |||
139 | /** | ||
140 | * 设置晃动动画 | ||
141 | */ | ||
142 | public void setShakeAnimation() { | ||
143 | this.setAnimation(shakeAnimation(5)); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * 晃动动画 | ||
148 | * | ||
149 | * @param counts 1秒钟晃动多少下 | ||
150 | * @return | ||
151 | */ | ||
152 | public static Animation shakeAnimation(int counts) { | ||
153 | Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); | ||
154 | translateAnimation.setInterpolator(new CycleInterpolator(counts)); | ||
155 | translateAnimation.setDuration(1000); | ||
156 | return translateAnimation; | ||
157 | } | ||
158 | } | ||
159 |
PersonalCenter/app/src/main/res/drawable/delete_selector.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_pressed" android:state_pressed="true"/> | ||
4 | <item android:drawable="@drawable/search_clear_normal"/> | ||
5 | </selector> |
PersonalCenter/app/src/main/res/drawable/search_clear_normal.png
453 Bytes
PersonalCenter/app/src/main/res/drawable/search_clear_pressed.png
436 Bytes
PersonalCenter/app/src/main/res/layout/activity_feedback.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="match_parent" | 3 | xmlns:fresco="http://schemas.android.com/tools" |
4 | android:orientation="vertical" | ||
5 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
5 | android:background="@color/backgerangde_laout"> | 7 | android:background="@color/backgerangde_laout"> |
6 | <RelativeLayout | 8 | <RelativeLayout |
7 | android:id="@+id/title" | 9 | android:id="@+id/title" |
8 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
9 | android:layout_height="50dp" | 11 | android:layout_height="50dp" |
10 | android:background="@color/login_text_blue"> | 12 | android:background="@color/login_text_blue"> |
11 | 13 | ||
12 | <ImageView | 14 | <ImageView |
13 | android:id="@+id/cancel" | 15 | android:id="@+id/cancel" |
14 | android:layout_width="wrap_content" | 16 | android:layout_width="wrap_content" |
15 | android:layout_height="match_parent" | 17 | android:layout_height="match_parent" |
16 | android:paddingLeft="20dp" | 18 | android:paddingLeft="20dp" |
17 | android:paddingRight="20dp" | 19 | android:paddingRight="20dp" |
18 | android:src="@mipmap/title_back" /> | 20 | android:src="@mipmap/title_back" /> |
19 | 21 | ||
20 | <TextView | 22 | <TextView |
21 | android:id="@+id/menu_title" | 23 | android:id="@+id/menu_title" |
22 | android:layout_width="wrap_content" | 24 | android:layout_width="wrap_content" |
23 | android:layout_height="match_parent" | 25 | android:layout_height="match_parent" |
24 | android:layout_centerInParent="true" | 26 | android:layout_centerInParent="true" |
25 | android:gravity="center_vertical" | 27 | android:gravity="center_vertical" |
26 | android:text="意见反馈" | 28 | android:text="意见反馈" |
27 | android:textColor="@android:color/white" | 29 | android:textColor="@android:color/white" |
28 | android:textSize="22sp" /> | 30 | android:textSize="22sp" /> |
29 | <TextView | 31 | <TextView |
30 | android:id="@+id/feedback_sub" | 32 | android:id="@+id/feedback_sub" |
31 | android:layout_width="wrap_content" | 33 | android:layout_width="wrap_content" |
32 | android:layout_height="match_parent" | 34 | android:layout_height="match_parent" |
33 | android:paddingLeft="20dp" | 35 | android:paddingLeft="20dp" |
34 | android:paddingRight="20dp" | 36 | android:paddingRight="20dp" |
35 | android:gravity="center_vertical" | 37 | android:gravity="center_vertical" |
36 | android:layout_alignParentRight="true" | 38 | android:layout_alignParentRight="true" |
37 | android:text="提交" | 39 | android:text="提交" |
38 | android:textColor="@android:color/white" | 40 | android:textColor="@android:color/white" |
39 | android:textSize="22sp" /> | 41 | android:textSize="22sp" /> |
40 | 42 | ||
41 | 43 | ||
42 | </RelativeLayout> | 44 | </RelativeLayout> |
43 | <EditText | 45 | <EditText |
44 | android:id="@+id/feedback_content" | 46 | android:id="@+id/feedback_content" |
45 | android:layout_width="match_parent" | 47 | android:layout_width="match_parent" |
46 | android:layout_height="250dp" | 48 | android:layout_height="250dp" |
47 | android:hint="@string/feedback" | 49 | android:hint="@string/feedback" |
48 | android:textColor="@color/electronic_text" | 50 | android:textColor="@color/electronic_text" |
49 | android:textSize="18sp" | 51 | android:textSize="18sp" |
50 | android:textScaleX="1" | 52 | android:textScaleX="1" |
51 | android:padding="20dp" | 53 | android:padding="20dp" |
52 | android:gravity="top" | 54 | android:gravity="top" |
53 | android:background="@color/white"/> | 55 | android:background="@color/white"/> |
54 | <LinearLayout | 56 | <LinearLayout |
55 | android:id="@+id/take_phone" | 57 | android:id="@+id/take_phone" |
56 | android:layout_width="match_parent" | 58 | android:layout_width="match_parent" |
57 | android:layout_height="wrap_content" | 59 | android:layout_height="wrap_content" |
58 | android:background="@color/white"> | 60 | android:background="@color/white"> |
59 | <ImageView | 61 | <ImageView |
62 | android:id="@+id/iv_take" | ||
60 | android:layout_margin="20dp" | 63 | android:layout_margin="20dp" |
61 | android:layout_width="wrap_content" | 64 | android:layout_width="wrap_content" |
62 | android:layout_height="wrap_content" | 65 | android:layout_height="wrap_content" |
63 | android:src="@mipmap/feedback_take_phone"/> | 66 | android:src="@mipmap/feedback_take_phone"/> |
64 | 67 | ||
68 | <com.facebook.drawee.view.SimpleDraweeView | ||
69 | android:id="@+id/show_iv" | ||
70 | android:layout_width="54dp" | ||
71 | android:layout_height="54dp" | ||
72 | android:layout_gravity="center" | ||
73 | fresco:placeholderImage="@mipmap/title_back" | ||
74 | fresco:roundAsCircle="true" | ||
75 | fresco:placeholderImageScaleType="fitCenter" /> | ||
76 | |||
65 | </LinearLayout> | 77 | </LinearLayout> |
66 | <EditText | 78 | <EditText |
79 | android:id="@+id/feedback_phone" | ||
67 | android:layout_width="match_parent" | 80 | android:layout_width="match_parent" |
68 | android:layout_marginTop="20dp" | 81 | android:layout_marginTop="20dp" |
69 | android:background="@color/white" | 82 | android:background="@color/white" |
70 | android:hint="@string/qq" | 83 | android:hint="@string/qq" |
71 | android:padding="20dp" | 84 | android:padding="20dp" |
72 | android:layout_height="60dp" /> | 85 | android:layout_height="60dp" /> |
73 | <TextView | 86 | <TextView |
74 | android:layout_width="match_parent" | 87 | android:layout_width="match_parent" |
75 | android:text="@string/hint" | 88 | android:text="@string/hint" |
76 | android:padding="20dp" | 89 | android:padding="20dp" |
77 | android:textSize="18sp" | 90 | android:textSize="18sp" |
78 | android:layout_height="wrap_content" /> | 91 | android:layout_height="wrap_content" /> |
79 | 92 | ||
80 | 93 | ||
81 | 94 | ||
82 | </LinearLayout> | 95 | </LinearLayout> |
PersonalCenter/app/src/main/res/layout/custom_adilog_school_list.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:orientation="vertical" android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent"> | ||
5 | <RelativeLayout | ||
6 | android:id="@+id/title" | ||
7 | android:layout_width="match_parent" | ||
8 | android:layout_height="wrap_content" | ||
9 | android:minHeight="70dp" > | ||
10 | |||
11 | <ImageView | ||
12 | android:id="@+id/cancel" | ||
13 | android:layout_width="wrap_content" | ||
14 | android:layout_height="wrap_content" | ||
15 | android:layout_centerVertical="true" | ||
16 | android:layout_alignParentRight="true" | ||
17 | android:padding="20dp" | ||
18 | android:src="@mipmap/cancel_fork" /> | ||
19 | |||
20 | <TextView | ||
21 | android:id="@+id/menu_title" | ||
22 | android:layout_width="wrap_content" | ||
23 | android:layout_height="wrap_content" | ||
24 | android:layout_centerInParent="true" | ||
25 | android:padding="20dp" | ||
26 | android:text="选学校" | ||
27 | android:textColor="@android:color/black" | ||
28 | android:textSize="22sp" /> | ||
29 | </RelativeLayout> | ||
30 | <com.hjx.personalcenter.widget.ClearEditText | ||
31 | android:id="@+id/et_school_sech" | ||
32 | android:layout_marginLeft="20dp" | ||
33 | android:layout_marginRight="20dp" | ||
34 | android:layout_marginTop="10dp" | ||
35 | android:paddingLeft="20dp" | ||
36 | android:layout_marginBottom="10dp" | ||
37 | android:hint="请输入学校名称" | ||
38 | android:layout_width="match_parent" | ||
39 | android:background="@drawable/corcle_black_bg" | ||
40 | android:layout_height="50dp"/> | ||
41 | <ListView | ||
42 | android:layout_marginLeft="20dp" | ||
43 | android:layout_marginRight="20dp" | ||
44 | android:id="@+id/listschooladapter" | ||
45 | android:layout_width="match_parent" | ||
46 | android:layout_height="400dp"> | ||
47 | |||
48 | </ListView> | ||
49 | |||
50 | </LinearLayout> |
PersonalCenter/app/src/main/res/layout/custom_adilog_school_list_items.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:orientation="vertical" android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent"> | ||
5 | <TextView | ||
6 | android:id="@+id/list_school_items" | ||
7 | android:textSize="18sp" | ||
8 | android:layout_width="match_parent" | ||
9 | android:layout_height="50dp" | ||
10 | android:textColor="@color/btn_text_color"/> | ||
11 | |||
12 | </LinearLayout> |