Commit d37e980ebbef954a2d5193d97cb8c9c7321ac22b
1 parent
16a469f2c7
Exists in
master
BUG修改
Showing
9 changed files
with
142 additions
and
32 deletions
Show diff stats
app/src/main/AndroidManifest.xml
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | android:theme="@style/Theme.AppCompat.NoActionBar" /> |
46 | 46 | <activity |
47 | 47 | android:name=".RegisterActivity" |
48 | - android:theme="@style/Theme.AppCompat.NoActionBar" /> | |
48 | + android:theme="@style/ThemeSplash" /> | |
49 | 49 | <activity |
50 | 50 | android:name=".UserActivity" |
51 | 51 | android:theme="@style/Theme.AppCompat.NoActionBar" /> | ... | ... |
app/src/main/java/com/hjx/parent/AccountActivity.java
... | ... | @@ -24,6 +24,9 @@ import com.bumptech.glide.Glide; |
24 | 24 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
25 | 25 | import com.bumptech.glide.request.RequestOptions; |
26 | 26 | import com.google.android.material.bottomsheet.BottomSheetDialog; |
27 | +import com.hjq.permissions.OnPermissionCallback; | |
28 | +import com.hjq.permissions.Permission; | |
29 | +import com.hjq.permissions.XXPermissions; | |
27 | 30 | import com.prws.common.base.BaseActivity; |
28 | 31 | import com.prws.common.base.BasePresenter; |
29 | 32 | import com.prws.common.bean.ResponseResult; |
... | ... | @@ -38,6 +41,7 @@ import java.io.File; |
38 | 41 | import java.io.FileOutputStream; |
39 | 42 | import java.io.IOException; |
40 | 43 | import java.util.HashMap; |
44 | +import java.util.List; | |
41 | 45 | import java.util.Map; |
42 | 46 | |
43 | 47 | import butterknife.BindView; |
... | ... | @@ -78,7 +82,7 @@ public class AccountActivity extends BaseActivity { |
78 | 82 | tv_6 = findViewById(R.id.tv_6); |
79 | 83 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); |
80 | 84 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
81 | - if(!TextUtils.isEmpty(photo)){ | |
85 | + if (!TextUtils.isEmpty(photo)) { | |
82 | 86 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AccountActivity.this, 45)); |
83 | 87 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
84 | 88 | Glide.with(AccountActivity.this).load(photo).apply(options).into(iv_3); |
... | ... | @@ -290,7 +294,29 @@ public class AccountActivity extends BaseActivity { |
290 | 294 | @Override |
291 | 295 | public void onClick(View view) { |
292 | 296 | dialog.dismiss(); |
293 | - getPicFromCamera(); | |
297 | + if (!XXPermissions.isGranted(AccountActivity.this, Permission.CAMERA)) { | |
298 | + XXPermissions.with(AccountActivity.this) | |
299 | + // 申请多个权限 | |
300 | + .permission(Permission.CAMERA) | |
301 | + .request(new OnPermissionCallback() { | |
302 | + @Override | |
303 | + public void onGranted(List<String> permissions, boolean all) { | |
304 | + if (all) { | |
305 | + //开启扫码界面 | |
306 | + getPicFromCamera(); | |
307 | + } else { | |
308 | + Toast.makeText(AccountActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); | |
309 | + } | |
310 | + } | |
311 | + | |
312 | + @Override | |
313 | + public void onDenied(List<String> permissions, boolean never) { | |
314 | + XXPermissions.startPermissionActivity(AccountActivity.this, permissions); | |
315 | + } | |
316 | + }); | |
317 | + } else { | |
318 | + getPicFromCamera(); | |
319 | + } | |
294 | 320 | } |
295 | 321 | }); |
296 | 322 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | ... | ... |
app/src/main/java/com/hjx/parent/AddStudentActivity.java
... | ... | @@ -22,6 +22,9 @@ import com.bumptech.glide.Glide; |
22 | 22 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
23 | 23 | import com.bumptech.glide.request.RequestOptions; |
24 | 24 | import com.google.android.material.bottomsheet.BottomSheetDialog; |
25 | +import com.hjq.permissions.OnPermissionCallback; | |
26 | +import com.hjq.permissions.Permission; | |
27 | +import com.hjq.permissions.XXPermissions; | |
25 | 28 | import com.prws.common.base.BaseActivity; |
26 | 29 | import com.prws.common.base.BasePresenter; |
27 | 30 | import com.prws.common.bean.ResponseResult; |
... | ... | @@ -36,6 +39,7 @@ import java.io.File; |
36 | 39 | import java.io.FileOutputStream; |
37 | 40 | import java.io.IOException; |
38 | 41 | import java.util.HashMap; |
42 | +import java.util.List; | |
39 | 43 | import java.util.Map; |
40 | 44 | |
41 | 45 | import butterknife.BindView; |
... | ... | @@ -236,7 +240,29 @@ public class AddStudentActivity extends BaseActivity { |
236 | 240 | @Override |
237 | 241 | public void onClick(View view) { |
238 | 242 | dialog.dismiss(); |
239 | - getPicFromCamera(); | |
243 | + if (!XXPermissions.isGranted(AddStudentActivity.this, Permission.CAMERA)) { | |
244 | + XXPermissions.with(AddStudentActivity.this) | |
245 | + // 申请多个权限 | |
246 | + .permission(Permission.CAMERA) | |
247 | + .request(new OnPermissionCallback() { | |
248 | + @Override | |
249 | + public void onGranted(List<String> permissions, boolean all) { | |
250 | + if (all) { | |
251 | + //开启扫码界面 | |
252 | + getPicFromCamera(); | |
253 | + } else { | |
254 | + Toast.makeText(AddStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); | |
255 | + } | |
256 | + } | |
257 | + | |
258 | + @Override | |
259 | + public void onDenied(List<String> permissions, boolean never) { | |
260 | + XXPermissions.startPermissionActivity(AddStudentActivity.this, permissions); | |
261 | + } | |
262 | + }); | |
263 | + } else { | |
264 | + getPicFromCamera(); | |
265 | + } | |
240 | 266 | } |
241 | 267 | }); |
242 | 268 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
... | ... | @@ -315,9 +341,6 @@ public class AddStudentActivity extends BaseActivity { |
315 | 341 | } |
316 | 342 | |
317 | 343 | private void uploadAvatar(File file) { |
318 | - RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 45)); | |
319 | - RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | |
320 | - Glide.with(this).load(file).apply(options).into(iv_avatar); | |
321 | 344 | NetWorks.uploadAvatar(file, new Observer<ResponseResult<Map<String, String>>>() { |
322 | 345 | @Override |
323 | 346 | public void onSubscribe(Disposable d) { |
... | ... | @@ -328,6 +351,9 @@ public class AddStudentActivity extends BaseActivity { |
328 | 351 | public void onNext(ResponseResult<Map<String, String>> responseBody) { |
329 | 352 | if (responseBody.getData() != null && responseBody.getCode() == 200) { |
330 | 353 | path = responseBody.getData().get("imageUrl"); |
354 | + RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AddStudentActivity.this, 45)); | |
355 | + RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | |
356 | + Glide.with(AddStudentActivity.this).load(path).apply(options).into(iv_avatar); | |
331 | 357 | } |
332 | 358 | } |
333 | 359 | ... | ... |
app/src/main/java/com/hjx/parent/ChooseActivity.java
... | ... | @@ -188,10 +188,12 @@ public class ChooseActivity extends BaseActivity { |
188 | 188 | public void confirm(View view) { |
189 | 189 | if (alist.size() > 0 && alist.size() - 1 >= select && alist.get(select) != null) { |
190 | 190 | StudentBean studentBean = alist.get(select); |
191 | - Intent intent = new Intent(ChooseActivity.this, MainActivity.class); | |
192 | - SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); | |
193 | - startActivity(intent); | |
194 | - finish(); | |
191 | + if (studentBean.getStuId() != null) { | |
192 | + Intent intent = new Intent(ChooseActivity.this, MainActivity.class); | |
193 | + SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); | |
194 | + startActivity(intent); | |
195 | + finish(); | |
196 | + } | |
195 | 197 | } |
196 | 198 | } |
197 | 199 | } | ... | ... |
app/src/main/java/com/hjx/parent/EditStudentActivity.java
... | ... | @@ -24,6 +24,9 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
24 | 24 | import com.bumptech.glide.request.RequestOptions; |
25 | 25 | import com.google.android.material.bottomsheet.BottomSheetDialog; |
26 | 26 | import com.google.gson.Gson; |
27 | +import com.hjq.permissions.OnPermissionCallback; | |
28 | +import com.hjq.permissions.Permission; | |
29 | +import com.hjq.permissions.XXPermissions; | |
27 | 30 | import com.hjx.parent.bean.StudentBean; |
28 | 31 | import com.prws.common.base.BaseActivity; |
29 | 32 | import com.prws.common.base.BasePresenter; |
... | ... | @@ -39,6 +42,7 @@ import java.io.File; |
39 | 42 | import java.io.FileOutputStream; |
40 | 43 | import java.io.IOException; |
41 | 44 | import java.util.HashMap; |
45 | +import java.util.List; | |
42 | 46 | import java.util.Map; |
43 | 47 | |
44 | 48 | import butterknife.BindView; |
... | ... | @@ -363,7 +367,30 @@ public class EditStudentActivity extends BaseActivity { |
363 | 367 | @Override |
364 | 368 | public void onClick(View view) { |
365 | 369 | dialog.dismiss(); |
366 | - getPicFromCamera(); | |
370 | + if (!XXPermissions.isGranted(EditStudentActivity.this, Permission.CAMERA)) { | |
371 | + XXPermissions.with(EditStudentActivity.this) | |
372 | + // 申请多个权限 | |
373 | + .permission(Permission.CAMERA) | |
374 | + .request(new OnPermissionCallback() { | |
375 | + @Override | |
376 | + public void onGranted(List<String> permissions, boolean all) { | |
377 | + if (all) { | |
378 | + //开启扫码界面 | |
379 | + getPicFromCamera(); | |
380 | + } else { | |
381 | + Toast.makeText(EditStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); | |
382 | + } | |
383 | + } | |
384 | + | |
385 | + @Override | |
386 | + public void onDenied(List<String> permissions, boolean never) { | |
387 | + XXPermissions.startPermissionActivity(EditStudentActivity.this, permissions); | |
388 | + } | |
389 | + }); | |
390 | + } else { | |
391 | + getPicFromCamera(); | |
392 | + } | |
393 | + | |
367 | 394 | } |
368 | 395 | }); |
369 | 396 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | ... | ... |
app/src/main/java/com/hjx/parent/NianActivity.java
... | ... | @@ -45,6 +45,7 @@ public class NianActivity extends BaseActivity { |
45 | 45 | @BindView(R.id.tv_xq) |
46 | 46 | TextView tv_xq; |
47 | 47 | private int gradeId; |
48 | + List<GradeAndSubject> list; | |
48 | 49 | |
49 | 50 | @Override |
50 | 51 | protected void initView() { |
... | ... | @@ -55,6 +56,7 @@ public class NianActivity extends BaseActivity { |
55 | 56 | SharedPreferencesUtil.putData("grade", gradeId); |
56 | 57 | finish(); |
57 | 58 | }); |
59 | + getGradeAndSubject(); | |
58 | 60 | } |
59 | 61 | |
60 | 62 | @OnClick(R.id.view_3) |
... | ... | @@ -73,8 +75,34 @@ public class NianActivity extends BaseActivity { |
73 | 75 | builder.show(); |
74 | 76 | } |
75 | 77 | |
78 | + | |
76 | 79 | @OnClick(R.id.view_2) |
77 | - public void getGradeAndSubject(View view) { | |
80 | + public void showGradeDialog(View view) { | |
81 | + if (list!=null&&list.size() > 0) { | |
82 | + | |
83 | + } else { | |
84 | + getGradeAndSubject(); | |
85 | + } | |
86 | + List<String> stringList = new ArrayList<>(); | |
87 | + for (GradeAndSubject gradeAndSubject : list) { | |
88 | + stringList.add(gradeAndSubject.getGrade().getGrade()); | |
89 | + } | |
90 | + String[] strings = stringList.toArray(new String[stringList.size()]); | |
91 | + AlertDialog.Builder builder = new AlertDialog.Builder(NianActivity.this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | |
92 | + builder.setTitle("请选择年级"); | |
93 | + builder.setSingleChoiceItems(strings, 0, new DialogInterface.OnClickListener() { | |
94 | + @Override | |
95 | + public void onClick(DialogInterface dialogInterface, int i) { | |
96 | + tv_nian.setText(list.get(i).getGrade().getGrade()); | |
97 | + gradeId = list.get(i).getGrade().getId(); | |
98 | + dialogInterface.dismiss(); | |
99 | + } | |
100 | + }); | |
101 | + builder.setCancelable(false); | |
102 | + builder.show(); | |
103 | + } | |
104 | + | |
105 | + public void getGradeAndSubject() { | |
78 | 106 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { |
79 | 107 | @Override |
80 | 108 | public void onSubscribe(Disposable d) { |
... | ... | @@ -84,24 +112,9 @@ public class NianActivity extends BaseActivity { |
84 | 112 | @Override |
85 | 113 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { |
86 | 114 | if (listResponseResult != null && listResponseResult.getCode() == 200) { |
87 | - List<GradeAndSubject> list = listResponseResult.getData(); | |
88 | - List<String> stringList = new ArrayList<>(); | |
89 | - for (GradeAndSubject gradeAndSubject : list) { | |
90 | - stringList.add(gradeAndSubject.getGrade().getGrade()); | |
91 | - } | |
92 | - String[] strings = stringList.toArray(new String[stringList.size()]); | |
93 | - AlertDialog.Builder builder = new AlertDialog.Builder(NianActivity.this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | |
94 | - builder.setTitle("请选择年级"); | |
95 | - builder.setSingleChoiceItems(strings, 0, new DialogInterface.OnClickListener() { | |
96 | - @Override | |
97 | - public void onClick(DialogInterface dialogInterface, int i) { | |
98 | - tv_nian.setText(list.get(i).getGrade().getGrade()); | |
99 | - gradeId = list.get(i).getGrade().getId(); | |
100 | - dialogInterface.dismiss(); | |
101 | - } | |
102 | - }); | |
103 | - builder.setCancelable(false); | |
104 | - builder.show(); | |
115 | + list = listResponseResult.getData(); | |
116 | + tv_nian.setText(list.get(0).getGrade().getGrade()); | |
117 | + gradeId = list.get(0).getGrade().getId(); | |
105 | 118 | } |
106 | 119 | } |
107 | 120 | ... | ... |
app/src/main/java/com/hjx/parent/RegisterActivity.java
... | ... | @@ -22,6 +22,7 @@ import com.prws.common.base.BaseActivity; |
22 | 22 | import com.prws.common.base.BasePresenter; |
23 | 23 | import com.prws.common.bean.BaseEntity; |
24 | 24 | import com.prws.common.net.NetWorks; |
25 | +import com.prws.common.utils.Common; | |
25 | 26 | import com.prws.common.utils.GsonUtil; |
26 | 27 | import com.prws.common.utils.LogUtil; |
27 | 28 | import com.prws.common.utils.SharedPreferencesUtil; |
... | ... | @@ -127,6 +128,13 @@ public class RegisterActivity extends BaseActivity { |
127 | 128 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); |
128 | 129 | return; |
129 | 130 | } |
131 | + if (pwd.length() < 6 || pwd.length() > 16 || pwd2.length() < 6 || pwd2.length() > 16) { | |
132 | + Toast.makeText(this, "密码必须为6-16位,数字或字母", Toast.LENGTH_SHORT).show(); | |
133 | + } | |
134 | + if (!Common.isValidPhoneNumber(phone)) { | |
135 | + Toast.makeText(this, "请输入有效手机号", Toast.LENGTH_SHORT).show(); | |
136 | + return; | |
137 | + } | |
130 | 138 | |
131 | 139 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { |
132 | 140 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); | ... | ... |
app/src/main/res/layout/activity_register.xml
... | ... | @@ -205,7 +205,7 @@ |
205 | 205 | android:layout_width="wrap_content" |
206 | 206 | android:layout_height="wrap_content" |
207 | 207 | android:layout_marginTop="15dp" |
208 | - android:text="登陆" | |
208 | + android:text="登录" | |
209 | 209 | android:textColor="#FE5E09" |
210 | 210 | android:textSize="17dp" |
211 | 211 | app:layout_constraintLeft_toRightOf="@id/tv_1" | ... | ... |
libs/common/src/main/java/com/prws/common/utils/Common.java
... | ... | @@ -55,6 +55,14 @@ public class Common { |
55 | 55 | // |
56 | 56 | // } |
57 | 57 | |
58 | + public static boolean isValidPhoneNumber(String phoneNumber) { | |
59 | + if ((phoneNumber != null) && (!phoneNumber.isEmpty())) { | |
60 | + return Pattern.matches("^1[3-9]\\d{9}$", phoneNumber); | |
61 | + } | |
62 | + return false; | |
63 | + } | |
64 | + | |
65 | + | |
58 | 66 | public static byte[] hexStrToBinaryStr(String hexString) { |
59 | 67 | if (hexString == null) { |
60 | 68 | return null; | ... | ... |