Compare View
Commits (2)
Showing
10 changed files
Show diff stats
app/src/main/AndroidManifest.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
4 | package="com.hjx.parent" | 4 | package="com.hjx.parent" |
5 | tools:ignore="LockedOrientationActivity"> | ||
5 | tools:ignore="LockedOrientationActivity"> | 6 | |
6 | 7 | ||
8 | <uses-feature | ||
9 | android:name="android.hardware.camera" | ||
10 | android:required="false" /> | ||
11 | |||
7 | 12 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | |
8 | <uses-feature | 13 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> |
9 | android:name="android.hardware.camera" | 14 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> |
10 | android:required="false" /> | 15 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> |
11 | 16 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> | |
12 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | 17 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
13 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> | 18 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
14 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> | 19 | <uses-permission android:name="android.permission.INTERNET" /> |
15 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> | 20 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> |
16 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> | 21 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
17 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | 22 | |
18 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | 23 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> |
19 | <uses-permission android:name="android.permission.INTERNET" /> | 24 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
20 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | 25 | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
21 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 26 | <uses-permission android:name="android.permission.CAMERA" /> |
22 | 27 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
23 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | 28 | <uses-permission android:name="android.permission.VIBRATE" /> |
24 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 29 | <uses-permission |
25 | <uses-permission android:name="android.permission.WAKE_LOCK" /> | 30 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" |
26 | <uses-permission android:name="android.permission.CAMERA" /> | 31 | tools:ignore="ScopedStorage" /> |
27 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | 32 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> |
28 | <uses-permission android:name="android.permission.VIBRATE" /> | 33 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> |
29 | <uses-permission | 34 | |
30 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" | 35 | <uses-permission |
31 | tools:ignore="ScopedStorage" /> | 36 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" |
32 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> | 37 | tools:ignore="ScopedStorage" /> |
33 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> | 38 | |
34 | 39 | <application | |
35 | <uses-permission | 40 | android:name=".App" |
36 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | 41 | android:allowBackup="true" |
37 | tools:ignore="ScopedStorage" /> | 42 | android:icon="@mipmap/icon" |
38 | 43 | android:label="@string/app_name" | |
39 | <application | 44 | android:networkSecurityConfig="@xml/network_security_config" |
40 | android:name=".App" | 45 | android:supportsRtl="true" |
41 | android:allowBackup="true" | 46 | android:theme="@style/AppTheme"> |
42 | android:icon="@mipmap/icon" | 47 | <activity |
43 | android:label="@string/app_name" | 48 | android:name=".LoginActivity" |
44 | android:networkSecurityConfig="@xml/network_security_config" | 49 | android:exported="true" |
45 | android:supportsRtl="true" | 50 | android:screenOrientation="portrait" |
46 | android:theme="@style/AppTheme"> | 51 | android:theme="@style/ThemeSplash"> |
47 | <activity | ||
48 | android:name=".LoginActivity" | ||
49 | android:exported="true" | ||
50 | android:screenOrientation="portrait" | ||
51 | android:theme="@style/ThemeSplash"> | 52 | </activity> |
52 | </activity> | 53 | <activity |
53 | <activity | 54 | android:name=".MainActivity" |
54 | android:name=".MainActivity" | 55 | android:launchMode="singleTask" |
55 | android:launchMode="singleTask" | 56 | android:screenOrientation="portrait" /> |
56 | android:screenOrientation="portrait" /> | 57 | <activity |
57 | <activity | 58 | android:name=".RegisterActivity" |
58 | android:name=".RegisterActivity" | 59 | android:screenOrientation="portrait" |
59 | android:screenOrientation="portrait" | 60 | android:theme="@style/ThemeSplash" /> |
60 | android:theme="@style/ThemeSplash" /> | 61 | <activity |
61 | <activity | 62 | android:name=".UserActivity" |
62 | android:name=".UserActivity" | 63 | android:screenOrientation="portrait" /> |
63 | android:screenOrientation="portrait" /> | 64 | <activity |
64 | <activity | 65 | android:name=".YinsiActivity" |
65 | android:name=".YinsiActivity" | 66 | android:screenOrientation="portrait" /> |
66 | android:screenOrientation="portrait" /> | 67 | <activity |
67 | <activity | 68 | android:name=".QRActivity" |
68 | android:name=".QRActivity" | 69 | android:screenOrientation="portrait" /> |
69 | android:screenOrientation="portrait" /> | 70 | <activity |
70 | <activity | 71 | android:name=".AddStudentActivity" |
71 | android:name=".AddStudentActivity" | 72 | android:screenOrientation="portrait" /> |
72 | android:screenOrientation="portrait" /> | 73 | <activity |
73 | <activity | 74 | android:name=".NickActivity" |
74 | android:name=".NickActivity" | 75 | android:screenOrientation="portrait" /> |
75 | android:screenOrientation="portrait" /> | 76 | <activity |
76 | <activity | 77 | android:name=".SexActivity" |
77 | android:name=".SexActivity" | 78 | android:screenOrientation="portrait" /> |
78 | android:screenOrientation="portrait" /> | 79 | <activity |
79 | <activity | 80 | android:name=".NianActivity" |
80 | android:name=".NianActivity" | 81 | android:screenOrientation="portrait" /> |
81 | android:screenOrientation="portrait" /> | 82 | <activity |
82 | <activity | 83 | android:name=".ShenActivity" |
83 | android:name=".ShenActivity" | 84 | android:screenOrientation="portrait" /> |
84 | android:screenOrientation="portrait" /> | 85 | <activity |
85 | <activity | 86 | android:name=".UserAgreementActivity" |
86 | android:name=".UserAgreementActivity" | 87 | android:screenOrientation="portrait" /> |
87 | android:screenOrientation="portrait" /> | 88 | <activity |
88 | <activity | 89 | android:name=".AccountActivity" |
89 | android:name=".AccountActivity" | 90 | android:screenOrientation="portrait" /> |
90 | android:screenOrientation="portrait" /> | 91 | |
91 | 92 | <activity | |
92 | <activity | 93 | android:name=".ChangePwdActivity" |
93 | android:name=".ChangePwdActivity" | 94 | android:screenOrientation="portrait" /> |
94 | android:screenOrientation="portrait" /> | 95 | <activity |
95 | <activity | 96 | android:name=".EditStudentActivity" |
96 | android:name=".EditStudentActivity" | 97 | android:screenOrientation="portrait" /> |
97 | android:screenOrientation="portrait" /> | 98 | <activity |
98 | <activity | 99 | android:name=".ChooseActivity" |
99 | android:name=".ChooseActivity" | 100 | android:screenOrientation="portrait" /> |
100 | android:screenOrientation="portrait" /> | 101 | <activity |
101 | <activity | 102 | android:name=".AddTeacherActivity" |
102 | android:name=".AddTeacherActivity" | 103 | android:screenOrientation="portrait" /> |
103 | android:screenOrientation="portrait" /> | 104 | <activity |
104 | <activity | 105 | android:name=".ErrorBookActivity" |
105 | android:name=".ErrorBookActivity" | 106 | android:screenOrientation="portrait" /> |
106 | android:screenOrientation="portrait" /> | 107 | <activity |
107 | <activity | 108 | android:name=".ImageActivity" |
108 | android:name=".ImageActivity" | 109 | android:screenOrientation="portrait" /> |
109 | android:screenOrientation="portrait" /> | 110 | <activity |
110 | <activity | 111 | android:name=".ImageEditActivity" |
111 | android:name=".ImageEditActivity" | 112 | android:screenOrientation="portrait" /> |
112 | android:screenOrientation="portrait" /> | 113 | <activity |
113 | <activity | 114 | android:name=".ImageSelectActivity" |
114 | android:name=".ImageSelectActivity" | 115 | android:screenOrientation="portrait" /> |
115 | android:screenOrientation="portrait" /> | 116 | <activity |
116 | <activity | 117 | android:name=".AddSuccessActivity" |
117 | android:name=".AddSuccessActivity" | 118 | android:screenOrientation="portrait" /> |
118 | android:screenOrientation="portrait" /> | 119 | <activity |
119 | <activity | 120 | android:name=".ErrorListActivity" |
120 | android:name=".ErrorListActivity" | 121 | android:screenOrientation="portrait" /> |
121 | android:screenOrientation="portrait" /> | 122 | <activity |
122 | <activity | 123 | android:name=".ErrorDetailActivity" |
123 | android:name=".ErrorDetailActivity" | 124 | android:screenOrientation="portrait" /> |
124 | android:screenOrientation="portrait" /> | 125 | <activity |
125 | <activity | 126 | android:name=".TeacherChooseActivity" |
126 | android:name=".TeacherChooseActivity" | 127 | android:screenOrientation="portrait" /> |
127 | android:screenOrientation="portrait" /> | 128 | <activity |
128 | <activity | 129 | android:name=".TeacherMainActivity" |
129 | android:name=".TeacherMainActivity" | 130 | android:screenOrientation="portrait" /> |
130 | android:screenOrientation="portrait" /> | 131 | <activity android:name=".StuHomeworkActivity" /> |
131 | <activity android:name=".StuHomeworkActivity" /> | 132 | <activity android:name=".HomeworkDetailActivity" /> |
132 | <activity android:name=".HomeworkDetailActivity" /> | 133 | <activity android:name=".HomeworkSelectActivity" /> |
133 | <activity android:name=".HomeworkSelectActivity" /> | 134 | <activity android:name=".HomeworkFeedbackActivity" /> |
134 | <activity android:name=".HomeworkFeedbackActivity" /> | 135 | <activity android:name=".HomeworkTopicActivity" /> |
135 | <activity android:name=".HomeworkTopicActivity" /> | 136 | <activity android:name=".HomeworkShareActivity" /> |
136 | <activity android:name=".HomeworkShareActivity" /> | 137 | <activity android:name=".HuyouDetailActivity" /> |
138 | <activity android:name=".SmsLoginActivity" | ||
139 | android:exported="true" | ||
140 | android:screenOrientation="portrait" | ||
141 | android:theme="@style/ThemeSplash"> | ||
142 | <intent-filter> | ||
143 | <action android:name="android.intent.action.MAIN" /> | ||
144 | <category android:name="android.intent.category.LAUNCHER" /> | ||
145 | </intent-filter> | ||
146 | </activity> | ||
137 | <activity android:name=".HuyouDetailActivity" /> | 147 | |
138 | <activity android:name=".SmsLoginActivity" | 148 | <provider |
139 | android:exported="true" | 149 | android:name="androidx.core.content.FileProvider" |
140 | android:screenOrientation="portrait" | 150 | android:authorities="com.hjx.parent.fileprovider" |
141 | android:theme="@style/ThemeSplash"> | 151 | android:exported="false" |
142 | <intent-filter> | 152 | android:grantUriPermissions="true" |
143 | <action android:name="android.intent.action.MAIN" /> | 153 | tools:replace="android:authorities"> |
144 | <category android:name="android.intent.category.LAUNCHER" /> | 154 | <meta-data |
145 | </intent-filter> | 155 | android:name="android.support.FILE_PROVIDER_PATHS" |
146 | </activity> | 156 | android:resource="@xml/file_provider_paths" |
147 | 157 | tools:replace="android:resource" /> |
app/src/main/java/com/hjx/parent/AccountActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; | 3 | import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; |
4 | import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; | 4 | import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; |
5 | 5 | ||
6 | import android.app.AlertDialog; | 6 | import android.app.AlertDialog; |
7 | import android.content.DialogInterface; | 7 | import android.content.DialogInterface; |
8 | import android.content.Intent; | 8 | import android.content.Intent; |
9 | import android.graphics.Bitmap; | 9 | import android.graphics.Bitmap; |
10 | import android.net.NetworkRequest; | 10 | import android.net.NetworkRequest; |
11 | import android.net.Uri; | 11 | import android.net.Uri; |
12 | import android.os.Build; | 12 | import android.os.Build; |
13 | import android.os.Bundle; | 13 | import android.os.Bundle; |
14 | import android.os.Environment; | 14 | import android.os.Environment; |
15 | import android.provider.MediaStore; | 15 | import android.provider.MediaStore; |
16 | import android.text.TextUtils; | 16 | import android.text.TextUtils; |
17 | import android.util.Log; | 17 | import android.util.Log; |
18 | import android.view.LayoutInflater; | 18 | import android.view.LayoutInflater; |
19 | import android.view.View; | 19 | import android.view.View; |
20 | import android.widget.ImageView; | 20 | import android.widget.ImageView; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import androidx.core.content.FileProvider; | 24 | import androidx.core.content.FileProvider; |
25 | 25 | ||
26 | import com.bumptech.glide.Glide; | 26 | import com.bumptech.glide.Glide; |
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | import com.bumptech.glide.request.RequestOptions; | 28 | import com.bumptech.glide.request.RequestOptions; |
29 | import com.google.android.material.bottomsheet.BottomSheetDialog; | 29 | import com.google.android.material.bottomsheet.BottomSheetDialog; |
30 | import com.hjq.permissions.OnPermissionCallback; | 30 | import com.hjq.permissions.OnPermissionCallback; |
31 | import com.hjq.permissions.Permission; | 31 | import com.hjq.permissions.Permission; |
32 | import com.hjq.permissions.XXPermissions; | 32 | import com.hjq.permissions.XXPermissions; |
33 | import com.prws.common.base.BaseActivity; | 33 | import com.prws.common.base.BaseActivity; |
34 | import com.prws.common.base.BasePresenter; | 34 | import com.prws.common.base.BasePresenter; |
35 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.net.NetWorks; | 36 | import com.prws.common.net.NetWorks; |
37 | import com.prws.common.utils.LogUtil; | 37 | import com.prws.common.utils.LogUtil; |
38 | import com.prws.common.utils.ScreenUtils; | 38 | import com.prws.common.utils.ScreenUtils; |
39 | import com.prws.common.utils.SharedPreferencesUtil; | 39 | import com.prws.common.utils.SharedPreferencesUtil; |
40 | 40 | ||
41 | import org.json.JSONObject; | 41 | import org.json.JSONObject; |
42 | 42 | ||
43 | import java.io.File; | 43 | import java.io.File; |
44 | import java.io.FileOutputStream; | 44 | import java.io.FileOutputStream; |
45 | import java.io.IOException; | 45 | import java.io.IOException; |
46 | import java.util.HashMap; | 46 | import java.util.HashMap; |
47 | import java.util.List; | 47 | import java.util.List; |
48 | import java.util.Map; | 48 | import java.util.Map; |
49 | 49 | ||
50 | import butterknife.BindView; | 50 | import butterknife.BindView; |
51 | import butterknife.OnClick; | 51 | import butterknife.OnClick; |
52 | import io.reactivex.Observer; | 52 | import io.reactivex.Observer; |
53 | import io.reactivex.disposables.Disposable; | 53 | import io.reactivex.disposables.Disposable; |
54 | import okhttp3.ResponseBody; | 54 | import okhttp3.ResponseBody; |
55 | 55 | ||
56 | public class AccountActivity extends BaseActivity { | 56 | public class AccountActivity extends BaseActivity { |
57 | 57 | ||
58 | 58 | ||
59 | @Override | 59 | @Override |
60 | protected int layoutResId() { | 60 | protected int layoutResId() { |
61 | return R.layout.activity_setac; | 61 | return R.layout.activity_setac; |
62 | } | 62 | } |
63 | 63 | ||
64 | @Override | 64 | @Override |
65 | public Object getContract() { | 65 | public Object getContract() { |
66 | return null; | 66 | return null; |
67 | } | 67 | } |
68 | 68 | ||
69 | @Override | 69 | @Override |
70 | public BasePresenter getPresenter() { | 70 | public BasePresenter getPresenter() { |
71 | return null; | 71 | return null; |
72 | } | 72 | } |
73 | 73 | ||
74 | private static int CAMERA_REQUEST_CODE = 343; | 74 | private static int CAMERA_REQUEST_CODE = 343; |
75 | private static int ALBUM_REQUEST_CODE = 456; | 75 | private static int ALBUM_REQUEST_CODE = 456; |
76 | private static int CROP_REQUEST_CODE = 234; | 76 | private static int CROP_REQUEST_CODE = 234; |
77 | private File tempFile; | 77 | private File tempFile; |
78 | private String path; | 78 | private String path; |
79 | TextView tv_6; | 79 | TextView tv_6; |
80 | @BindView(R.id.iv_3) | 80 | @BindView(R.id.iv_3) |
81 | ImageView iv_3; | 81 | ImageView iv_3; |
82 | 82 | ||
83 | @Override | 83 | @Override |
84 | protected void initView() { | 84 | protected void initView() { |
85 | tv_6 = findViewById(R.id.tv_6); | 85 | tv_6 = findViewById(R.id.tv_6); |
86 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); | 86 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); |
87 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 87 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
88 | if (!TextUtils.isEmpty(photo)) { | 88 | if (!TextUtils.isEmpty(photo)) { |
89 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AccountActivity.this, 45)); | 89 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AccountActivity.this, 45)); |
90 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 90 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
91 | Glide.with(AccountActivity.this).load(photo).apply(options).into(iv_3); | 91 | Glide.with(AccountActivity.this).load(photo).apply(options).into(iv_3); |
92 | } | 92 | } |
93 | if (phone != null && phone.length() > 0) | 93 | if (phone != null && phone.length() > 0) |
94 | tv_6.setText(phone); | 94 | tv_6.setText(phone); |
95 | } | 95 | } |
96 | 96 | ||
97 | @Override | 97 | @Override |
98 | protected void initListener() { | 98 | protected void initListener() { |
99 | findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); | 99 | findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); |
100 | findViewById(R.id.tv_7).setOnClickListener(view -> startActivity(ChangePwdActivity.class)); | 100 | findViewById(R.id.tv_7).setOnClickListener(view -> startActivity(ChangePwdActivity.class)); |
101 | } | 101 | } |
102 | 102 | ||
103 | @Override | 103 | @Override |
104 | protected void initData() { | 104 | protected void initData() { |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | @Override | 108 | @Override |
109 | public void onNetChanged(int netWorkState) { | 109 | public void onNetChanged(int netWorkState) { |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | private void uploadAvatar(File file) { | 113 | private void uploadAvatar(File file) { |
114 | 114 | ||
115 | NetWorks.uploadAvatar(file, new Observer<ResponseResult<Map<String, String>>>() { | 115 | NetWorks.uploadAvatar(file, new Observer<ResponseResult<Map<String, String>>>() { |
116 | @Override | 116 | @Override |
117 | public void onSubscribe(Disposable d) { | 117 | public void onSubscribe(Disposable d) { |
118 | 118 | ||
119 | } | 119 | } |
120 | 120 | ||
121 | @Override | 121 | @Override |
122 | public void onNext(ResponseResult<Map<String, String>> responseBody) { | 122 | public void onNext(ResponseResult<Map<String, String>> responseBody) { |
123 | if (responseBody.getData() != null && responseBody.getCode() == 200) { | 123 | if (responseBody.getData() != null && responseBody.getCode() == 200) { |
124 | path = responseBody.getData().get("imageUrl"); | 124 | path = responseBody.getData().get("imageUrl"); |
125 | editUser(path); | 125 | editUser(path); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | @Override | 129 | @Override |
130 | public void onError(Throwable e) { | 130 | public void onError(Throwable e) { |
131 | e.toString(); | 131 | e.toString(); |
132 | } | 132 | } |
133 | 133 | ||
134 | @Override | 134 | @Override |
135 | public void onComplete() { | 135 | public void onComplete() { |
136 | 136 | ||
137 | } | 137 | } |
138 | }); | 138 | }); |
139 | } | 139 | } |
140 | 140 | ||
141 | public void editUser(String path) { | 141 | public void editUser(String path) { |
142 | Map map = new HashMap(); | 142 | Map map = new HashMap(); |
143 | map.put("userId", SharedPreferencesUtil.getData("userId", "")); | 143 | map.put("userId", SharedPreferencesUtil.getData("userId", "")); |
144 | map.put("photo", path); | 144 | map.put("photo", path); |
145 | 145 | ||
146 | NetWorks.editUser(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | 146 | NetWorks.editUser(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { |
147 | @Override | 147 | @Override |
148 | public void onSubscribe(Disposable d) { | 148 | public void onSubscribe(Disposable d) { |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | @Override | 152 | @Override |
153 | public void onNext(ResponseBody responseBody) { | 153 | public void onNext(ResponseBody responseBody) { |
154 | try { | 154 | try { |
155 | String str = responseBody.string().toString(); | 155 | String str = responseBody.string().toString(); |
156 | LogUtil.e(TAG, "----" + str); | 156 | LogUtil.e(TAG, "----" + str); |
157 | JSONObject jo = new JSONObject(str); | 157 | JSONObject jo = new JSONObject(str); |
158 | boolean isSucceed = jo.getBoolean("success"); | 158 | boolean isSucceed = jo.getBoolean("success"); |
159 | if (isSucceed) { | 159 | if (isSucceed) { |
160 | SharedPreferencesUtil.putData("photo", path); | 160 | SharedPreferencesUtil.putData("photo", path); |
161 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AccountActivity.this, 45)); | 161 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AccountActivity.this, 45)); |
162 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 162 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
163 | Glide.with(AccountActivity.this).load(path).apply(options).into(iv_3); | 163 | Glide.with(AccountActivity.this).load(path).apply(options).into(iv_3); |
164 | Toast.makeText(AccountActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); | 164 | Toast.makeText(AccountActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); |
165 | } else { | 165 | } else { |
166 | Toast.makeText(AccountActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | 166 | Toast.makeText(AccountActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); |
167 | } | 167 | } |
168 | } catch (Exception e) { | 168 | } catch (Exception e) { |
169 | e.printStackTrace(); | 169 | e.printStackTrace(); |
170 | Toast.makeText(AccountActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); | 170 | Toast.makeText(AccountActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | @Override | 174 | @Override |
175 | public void onError(Throwable e) { | 175 | public void onError(Throwable e) { |
176 | 176 | ||
177 | } | 177 | } |
178 | 178 | ||
179 | @Override | 179 | @Override |
180 | public void onComplete() { | 180 | public void onComplete() { |
181 | 181 | ||
182 | } | 182 | } |
183 | }); | 183 | }); |
184 | } | 184 | } |
185 | 185 | ||
186 | public File saveImage(String name, Bitmap bmp) { | 186 | public File saveImage(String name, Bitmap bmp) { |
187 | File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath()); | 187 | File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath()); |
188 | if (!appDir.exists()) { | 188 | if (!appDir.exists()) { |
189 | appDir.mkdir(); | 189 | appDir.mkdir(); |
190 | } | 190 | } |
191 | String fileName = name + ".jpg"; | 191 | String fileName = name + ".jpg"; |
192 | File file = new File(appDir, fileName); | 192 | File file = new File(appDir, fileName); |
193 | try { | 193 | try { |
194 | FileOutputStream fos = new FileOutputStream(file); | 194 | FileOutputStream fos = new FileOutputStream(file); |
195 | bmp.compress(Bitmap.CompressFormat.PNG, 100, fos); | 195 | bmp.compress(Bitmap.CompressFormat.PNG, 100, fos); |
196 | fos.flush(); | 196 | fos.flush(); |
197 | fos.close(); | 197 | fos.close(); |
198 | return file; | 198 | return file; |
199 | } catch (IOException e) { | 199 | } catch (IOException e) { |
200 | Log.d("dsadsadsa", e.getLocalizedMessage()); | 200 | Log.d("dsadsadsa", e.getLocalizedMessage()); |
201 | e.printStackTrace(); | 201 | e.printStackTrace(); |
202 | } | 202 | } |
203 | return null; | 203 | return null; |
204 | } | 204 | } |
205 | 205 | ||
206 | @Override | 206 | @Override |
207 | protected void onActivityResult(int requestCode, int resultCode, Intent intent) { | 207 | protected void onActivityResult(int requestCode, int resultCode, Intent intent) { |
208 | super.onActivityResult(requestCode, resultCode, intent); | 208 | super.onActivityResult(requestCode, resultCode, intent); |
209 | if (requestCode == CAMERA_REQUEST_CODE) { | 209 | if (requestCode == CAMERA_REQUEST_CODE) { |
210 | if (resultCode == RESULT_OK) { | 210 | if (resultCode == RESULT_OK) { |
211 | //用相机返回的照片去调用剪裁也需要对Uri进行处理 | 211 | //用相机返回的照片去调用剪裁也需要对Uri进行处理 |
212 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 212 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
213 | Uri contentUri = FileProvider.getUriForFile(this, | 213 | Uri contentUri = FileProvider.getUriForFile(this, |
214 | this.getPackageName() + ".fileprovider", tempFile); | 214 | this.getPackageName() + ".fileprovider", tempFile); |
215 | cropPhoto(contentUri); | 215 | cropPhoto(contentUri); |
216 | } else { | 216 | } else { |
217 | cropPhoto(Uri.fromFile(tempFile)); | 217 | cropPhoto(Uri.fromFile(tempFile)); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } else if (requestCode == ALBUM_REQUEST_CODE) { | 220 | } else if (requestCode == ALBUM_REQUEST_CODE) { |
221 | if (resultCode == RESULT_OK) { | 221 | if (resultCode == RESULT_OK) { |
222 | Uri uri = intent.getData(); | 222 | Uri uri = intent.getData(); |
223 | cropPhoto(uri); | 223 | cropPhoto(uri); |
224 | } | 224 | } |
225 | } else if (requestCode == CROP_REQUEST_CODE) { | 225 | } else if (requestCode == CROP_REQUEST_CODE) { |
226 | if (intent == null) { | 226 | if (intent == null) { |
227 | return; | 227 | return; |
228 | } | 228 | } |
229 | Bundle bundle = intent.getExtras(); | 229 | Bundle bundle = intent.getExtras(); |
230 | if (bundle != null) { | 230 | if (bundle != null) { |
231 | //在这里获得了剪裁后的Bitmap对象,可以用于上传 | 231 | //在这里获得了剪裁后的Bitmap对象,可以用于上传 |
232 | Bitmap image = bundle.getParcelable("data"); | 232 | Bitmap image = bundle.getParcelable("data"); |
233 | //设置到ImageView上 | 233 | //设置到ImageView上 |
234 | //也可以进行一些保存、压缩等操作后上传 | 234 | //也可以进行一些保存、压缩等操作后上传 |
235 | File file = saveImage("head_output", image); | 235 | File file = saveImage("head_output", image); |
236 | uploadAvatar(file); | 236 | uploadAvatar(file); |
237 | // Log.d("dsadsadsa",path); | 237 | // Log.d("dsadsadsa",path); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | private void getPicFromCamera() { | 242 | private void getPicFromCamera() { |
243 | //用于保存调用相机拍照后所生成的文件 | 243 | //用于保存调用相机拍照后所生成的文件 |
244 | tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"); | 244 | tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"); |
245 | //跳转到调用系统相机 | 245 | //跳转到调用系统相机 |
246 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 246 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
247 | //判断版本 | 247 | //判断版本 |
248 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri | 248 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri |
249 | intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 249 | intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
250 | Uri contentUri = FileProvider.getUriForFile(this, | 250 | Uri contentUri = FileProvider.getUriForFile(this, |
251 | this.getPackageName() + ".fileprovider", tempFile); | 251 | this.getPackageName() + ".fileprovider", tempFile); |
252 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); | 252 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); |
253 | } else { //否则使用Uri.fromFile(file)方法获取Uri | 253 | } else { //否则使用Uri.fromFile(file)方法获取Uri |
254 | intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); | 254 | intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); |
255 | } | 255 | } |
256 | startActivityForResult(intent, CAMERA_REQUEST_CODE); | 256 | startActivityForResult(intent, CAMERA_REQUEST_CODE); |
257 | } | 257 | } |
258 | 258 | ||
259 | private void cropPhoto(Uri uri) { | 259 | private void cropPhoto(Uri uri) { |
260 | Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg")); | 260 | Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg")); |
261 | Intent intent = new Intent("com.android.camera.action.CROP"); | 261 | Intent intent = new Intent("com.android.camera.action.CROP"); |
262 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 262 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
263 | //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片 | 263 | //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片 |
264 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 264 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
265 | } | 265 | } |
266 | intent.setDataAndType(uri, "image/*"); | 266 | intent.setDataAndType(uri, "image/*"); |
267 | intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪 | 267 | intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪 |
268 | intent.putExtra("scale", true);// 设置缩放 | 268 | intent.putExtra("scale", true);// 设置缩放 |
269 | intent.putExtra("scaleUpIfNeeded", true);// 去黑边 | 269 | intent.putExtra("scaleUpIfNeeded", true);// 去黑边 |
270 | intent.putExtra("aspectX", 1); | 270 | intent.putExtra("aspectX", 1); |
271 | intent.putExtra("aspectY", 1); | 271 | intent.putExtra("aspectY", 1); |
272 | //上述两个属性控制裁剪框的缩放比例。 | 272 | //上述两个属性控制裁剪框的缩放比例。 |
273 | //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。 | 273 | //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。 |
274 | intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。 | 274 | intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。 |
275 | intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存, | 275 | intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存, |
276 | intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式 | 276 | intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式 |
277 | intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap | 277 | intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap |
278 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径 | 278 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径 |
279 | startActivityForResult(intent, CROP_REQUEST_CODE); | 279 | startActivityForResult(intent, CROP_REQUEST_CODE); |
280 | } | 280 | } |
281 | 281 | ||
282 | /** | 282 | /** |
283 | * 从相册获取图片 | 283 | * 从相册获取图片 |
284 | */ | 284 | */ |
285 | private void getPicFromAlbm() { | 285 | private void getPicFromAlbm() { |
286 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 286 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
287 | photoPickerIntent.setType("image/*"); | 287 | photoPickerIntent.setType("image/*"); |
288 | startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE); | 288 | startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE); |
289 | } | 289 | } |
290 | 290 | ||
291 | @OnClick(R.id.iv_3) | 291 | @OnClick(R.id.iv_3) |
292 | public void showButtonDialog(View view) { | 292 | public void showButtonDialog(View view) { |
293 | BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); | 293 | BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); |
294 | View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null); | 294 | View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null); |
295 | dialog.setContentView(bottomView); | 295 | dialog.setContentView(bottomView); |
296 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 296 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
297 | @Override | 297 | @Override |
298 | public void onClick(View view) { | 298 | public void onClick(View view) { |
299 | dialog.dismiss(); | 299 | dialog.dismiss(); |
300 | if (!XXPermissions.isGranted(AccountActivity.this, Permission.CAMERA)) { | 300 | if (!XXPermissions.isGranted(AccountActivity.this, Permission.CAMERA)) { |
301 | XXPermissions.with(AccountActivity.this) | 301 | XXPermissions.with(AccountActivity.this) |
302 | // 申请多个权限 | 302 | // 申请多个权限 |
303 | .permission(Permission.CAMERA) | 303 | .permission(Permission.CAMERA) |
304 | .request(new OnPermissionCallback() { | 304 | .request(new OnPermissionCallback() { |
305 | @Override | 305 | @Override |
306 | public void onGranted(List<String> permissions, boolean all) { | 306 | public void onGranted(List<String> permissions, boolean all) { |
307 | if (all) { | 307 | if (all) { |
308 | //开启扫码界面 | 308 | //开启扫码界面 |
309 | getPicFromCamera(); | 309 | getPicFromCamera(); |
310 | } else { | 310 | } else { |
311 | Toast.makeText(AccountActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); | 311 | Toast.makeText(AccountActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | @Override | 315 | @Override |
316 | public void onDenied(List<String> permissions, boolean never) { | 316 | public void onDenied(List<String> permissions, boolean never) { |
317 | XXPermissions.startPermissionActivity(AccountActivity.this, permissions); | 317 | XXPermissions.startPermissionActivity(AccountActivity.this, permissions); |
318 | } | 318 | } |
319 | }); | 319 | }); |
320 | } else { | 320 | } else { |
321 | getPicFromCamera(); | 321 | getPicFromCamera(); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | }); | 324 | }); |
325 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 325 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
326 | @Override | 326 | @Override |
327 | public void onClick(View view) { | 327 | public void onClick(View view) { |
328 | dialog.dismiss(); | 328 | dialog.dismiss(); |
329 | getPicFromAlbm(); | 329 | getPicFromAlbm(); |
330 | } | 330 | } |
331 | }); | 331 | }); |
332 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 332 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
333 | @Override | 333 | @Override |
334 | public void onClick(View view) { | 334 | public void onClick(View view) { |
335 | dialog.dismiss(); | 335 | dialog.dismiss(); |
336 | } | 336 | } |
337 | }); | 337 | }); |
338 | dialog.show(); | 338 | dialog.show(); |
339 | } | 339 | } |
340 | 340 | ||
341 | @OnClick(R.id.logout) | 341 | @OnClick(R.id.logout) |
342 | public void logout(View view) { | 342 | public void logout(View view) { |
343 | AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | 343 | AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); |
344 | builder.setTitle("温馨提示"); | 344 | builder.setTitle("温馨提示"); |
345 | builder.setMessage("是否退出登录?"); | 345 | builder.setMessage("是否退出登录?"); |
346 | builder.setCancelable(false); | 346 | builder.setCancelable(false); |
347 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { | 347 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { |
348 | @Override | 348 | @Override |
349 | public void onClick(DialogInterface dialogInterface, int i) { | 349 | public void onClick(DialogInterface dialogInterface, int i) { |
350 | dialogInterface.dismiss(); | 350 | dialogInterface.dismiss(); |
351 | } | 351 | } |
352 | }); | 352 | }); |
353 | builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | 353 | builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { |
354 | @Override | 354 | @Override |
355 | public void onClick(DialogInterface dialogInterface, int i) { | 355 | public void onClick(DialogInterface dialogInterface, int i) { |
356 | SharedPreferencesUtil.clear(AccountActivity.this); | 356 | SharedPreferencesUtil.clear(AccountActivity.this); |
357 | restartApp(); | 357 | restartApp(); |
358 | } | 358 | } |
359 | }); | 359 | }); |
360 | builder.show(); | 360 | builder.show(); |
361 | } | 361 | } |
362 | 362 | ||
363 | private void restartApp() { | 363 | private void restartApp() { |
364 | //重启app,这一步一定要加上,如果不重启app,可能打开新的页面显示的语言会不正确 | 364 | //重启app,这一步一定要加上,如果不重启app,可能打开新的页面显示的语言会不正确 |
365 | Intent intent = new Intent(this, SmsLoginActivity.class); | 365 | Intent intent = new Intent(this, SmsLoginActivity.class); |
366 | intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); | 366 | intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); |
367 | startActivity(intent); | 367 | startActivity(intent); |
368 | android.os.Process.killProcess(android.os.Process.myPid()); | 368 | android.os.Process.killProcess(android.os.Process.myPid()); |
369 | System.exit(0); | 369 | System.exit(0); |
370 | } | 370 | } |
371 | 371 | ||
372 | } | 372 | } |
app/src/main/java/com/hjx/parent/LoginActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
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.telephony.PhoneNumberUtils; | 5 | import android.telephony.PhoneNumberUtils; |
6 | import android.text.InputType; | 6 | import android.text.InputType; |
7 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
8 | import android.text.method.HideReturnsTransformationMethod; | 8 | import android.text.method.HideReturnsTransformationMethod; |
9 | import android.text.method.PasswordTransformationMethod; | 9 | import android.text.method.PasswordTransformationMethod; |
10 | import android.widget.Button; | 10 | import android.widget.Button; |
11 | import android.widget.CheckBox; | 11 | import android.widget.CheckBox; |
12 | import android.widget.EditText; | 12 | import android.widget.EditText; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | import android.widget.TextView; | 14 | import android.widget.TextView; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import androidx.appcompat.app.AppCompatActivity; | 17 | import androidx.appcompat.app.AppCompatActivity; |
18 | 18 | ||
19 | import com.prws.common.base.BaseActivity; | 19 | import com.prws.common.base.BaseActivity; |
20 | import com.prws.common.base.BasePresenter; | 20 | import com.prws.common.base.BasePresenter; |
21 | import com.prws.common.bean.BaseEntity; | 21 | import com.prws.common.bean.BaseEntity; |
22 | import com.prws.common.net.NetWorks; | 22 | import com.prws.common.net.NetWorks; |
23 | import com.prws.common.utils.LogUtil; | 23 | import com.prws.common.utils.LogUtil; |
24 | import com.prws.common.utils.SharedPreferencesUtil; | 24 | import com.prws.common.utils.SharedPreferencesUtil; |
25 | import com.prws.common.utils.acmanager.ActivityManager; | 25 | import com.prws.common.utils.acmanager.ActivityManager; |
26 | 26 | ||
27 | import org.json.JSONObject; | 27 | import org.json.JSONObject; |
28 | 28 | ||
29 | import java.io.IOException; | 29 | import java.io.IOException; |
30 | import java.util.HashMap; | 30 | import java.util.HashMap; |
31 | import java.util.Map; | 31 | import java.util.Map; |
32 | 32 | ||
33 | import io.reactivex.Observer; | 33 | import io.reactivex.Observer; |
34 | import io.reactivex.disposables.Disposable; | 34 | import io.reactivex.disposables.Disposable; |
35 | import okhttp3.ResponseBody; | 35 | import okhttp3.ResponseBody; |
36 | 36 | ||
37 | 37 | ||
38 | public class LoginActivity extends BaseActivity { | 38 | public class LoginActivity extends BaseActivity { |
39 | 39 | ||
40 | 40 | ||
41 | EditText et_phone; | 41 | EditText et_phone; |
42 | EditText et_pwd; | 42 | EditText et_pwd; |
43 | ImageView iv_show; | 43 | ImageView iv_show; |
44 | ImageView iv_delete; | 44 | ImageView iv_delete; |
45 | Button btn_login; | 45 | Button btn_login; |
46 | |||
47 | |||
48 | @Override | ||
49 | protected int layoutResId() { | ||
50 | return R.layout.activity_login; | 46 | |
51 | } | 47 | |
52 | 48 | @Override | |
53 | @Override | 49 | protected int layoutResId() { |
54 | public Object getContract() { | 50 | return R.layout.activity_login; |
55 | return null; | 51 | } |
56 | } | 52 | |
57 | 53 | @Override | |
58 | @Override | 54 | public Object getContract() { |
59 | public BasePresenter getPresenter() { | 55 | return null; |
60 | return null; | 56 | } |
61 | } | 57 | |
62 | 58 | @Override | |
63 | 59 | public BasePresenter getPresenter() { | |
64 | @Override | 60 | return null; |
65 | protected void initView() { | 61 | } |
66 | et_phone = findViewById(R.id.et_phone); | 62 | |
67 | et_pwd = findViewById(R.id.et_pwd); | 63 | |
68 | iv_show = findViewById(R.id.iv_4); | 64 | @Override |
69 | iv_delete = findViewById(R.id.iv_2); | 65 | protected void initView() { |
70 | btn_login = findViewById(R.id.btn_1); | 66 | et_phone = findViewById(R.id.et_phone); |
71 | 67 | et_pwd = findViewById(R.id.et_pwd); | |
72 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 68 | iv_show = findViewById(R.id.iv_4); |
73 | 69 | iv_delete = findViewById(R.id.iv_2); | |
74 | if (!TextUtils.isEmpty(student)) { | 70 | btn_login = findViewById(R.id.btn_1); |
75 | LogUtil.e(TAG, "role 不是空----"); | ||
76 | if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { | ||
77 | Intent intent = new Intent(this, MainActivity.class); | ||
78 | startActivity(intent); | ||
79 | finish(); | ||
80 | } else { | 71 | |
81 | Intent intent = new Intent(this, TeacherMainActivity.class); | 72 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
82 | startActivity(intent); | 73 | |
83 | finish(); | 74 | if (!TextUtils.isEmpty(student)) { |
84 | } | 75 | LogUtil.e(TAG, "role 不是空----"); |
85 | return; | 76 | if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { |
86 | } else { | 77 | Intent intent = new Intent(this, MainActivity.class); |
87 | LogUtil.e(TAG, "role 是空----"); | 78 | startActivity(intent); |
88 | } | 79 | finish(); |
89 | 80 | } else { | |
90 | findViewById(R.id.tvBack).setOnClickListener(v -> { | 81 | Intent intent = new Intent(this, TeacherMainActivity.class); |
91 | startActivity(new Intent(this, SmsLoginActivity.class)); | 82 | startActivity(intent); |
92 | finish(); | 83 | finish(); |
93 | }); | 84 | } |
94 | 85 | return; | |
95 | } | 86 | } else { |
96 | 87 | LogUtil.e(TAG, "role 是空----"); | |
97 | @Override | 88 | } |
98 | protected void initListener() { | 89 | |
90 | findViewById(R.id.tvBack).setOnClickListener(v -> { | ||
91 | startActivity(new Intent(this, SmsLoginActivity.class)); | ||
92 | finish(); | ||
93 | }); | ||
99 | iv_delete.setOnClickListener(view -> { | 94 | |
100 | et_phone.setText(""); | 95 | } |
101 | }); | 96 | |
102 | iv_show.setOnClickListener(view -> { | 97 | @Override |
103 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { | 98 | protected void initListener() { |
104 | iv_show.setBackgroundResource(R.mipmap.yc); | 99 | iv_delete.setOnClickListener(view -> { |
105 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); | 100 | et_phone.setText(""); |
106 | et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 101 | }); |
107 | } else { | 102 | iv_show.setOnClickListener(view -> { |
108 | iv_show.setBackgroundResource(R.mipmap.xs); | 103 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { |
109 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | 104 | iv_show.setBackgroundResource(R.mipmap.yc); |
110 | et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 105 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); |
111 | } | 106 | et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
112 | }); | 107 | } else { |
113 | 108 | iv_show.setBackgroundResource(R.mipmap.xs); | |
114 | 109 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | |
115 | btn_login.setOnClickListener(view -> { | 110 | et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
116 | 111 | } | |
117 | String phone = et_phone.getText().toString().trim(); | 112 | }); |
118 | String pwd = et_pwd.getText().toString().trim(); | 113 | |
119 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { | 114 | |
120 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); | 115 | btn_login.setOnClickListener(view -> { |
121 | return; | 116 | |
122 | } | 117 | String phone = et_phone.getText().toString().trim(); |
123 | 118 | String pwd = et_pwd.getText().toString().trim(); | |
124 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { | 119 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { |
125 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); | 120 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); |
126 | return; | 121 | return; |
127 | } | 122 | } |
128 | 123 | ||
129 | // if (!cb_1.isChecked()) { | 124 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { |
130 | // Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); | 125 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); |
131 | // return; | 126 | return; |
132 | // } | 127 | } |
133 | 128 | ||
134 | login(phone, pwd); | 129 | // if (!cb_1.isChecked()) { |
135 | 130 | // Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); | |
136 | }); | 131 | // return; |
137 | 132 | // } | |
138 | // tv_ys.setOnClickListener(view -> { | 133 | |
139 | // startActivity(YinsiActivity.class); | 134 | login(phone, pwd); |
140 | // }); | 135 | |
141 | // tv_user.setOnClickListener(view -> { | 136 | }); |
142 | // startActivity(UserAgreementActivity.class); | 137 | |
143 | // }); | 138 | // tv_ys.setOnClickListener(view -> { |
144 | } | 139 | // startActivity(YinsiActivity.class); |
145 | 140 | // }); | |
146 | public void login(final String phone, String pwd) { | 141 | // tv_user.setOnClickListener(view -> { |
147 | 142 | // startActivity(UserAgreementActivity.class); | |
148 | Map map = new HashMap(); | 143 | // }); |
149 | map.put("username", phone); | ||
150 | map.put("password", pwd); | ||
151 | |||
152 | |||
153 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | ||
154 | @Override | 144 | } |
155 | public void onSubscribe(Disposable d) { | 145 | |
156 | 146 | public void login(final String phone, String pwd) { | |
157 | } | 147 | |
158 | 148 | Map map = new HashMap(); | |
159 | @Override | 149 | map.put("username", phone); |
160 | public void onNext(ResponseBody responseBody) { | 150 | map.put("password", pwd); |
161 | try { | 151 | |
162 | String str = responseBody.string().toString(); | 152 | |
163 | LogUtil.e(TAG, "----" + str); | 153 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { |
164 | JSONObject jo = new JSONObject(str); | 154 | @Override |
165 | boolean isSucceed = jo.getBoolean("success"); | 155 | public void onSubscribe(Disposable d) { |
166 | if (isSucceed) { | 156 | |
167 | JSONObject jo2 = jo.getJSONObject("data"); | 157 | } |
168 | String role = jo2.getString("role"); | 158 | |
169 | if ("member_advisor".equals(role) || "teaching_supervision".equals(role)) { | 159 | @Override |
170 | SharedPreferencesUtil.putData("phone", phone); | 160 | public void onNext(ResponseBody responseBody) { |
171 | SharedPreferencesUtil.putData("role", role); | 161 | try { |
172 | SharedPreferencesUtil.putData("userId", jo2.getString("id")); | 162 | String str = responseBody.string().toString(); |
173 | SharedPreferencesUtil.putData("token", jo2.getString("token")); | 163 | LogUtil.e(TAG, "----" + str); |
174 | SharedPreferencesUtil.putData("name", jo2.getString("username")); | 164 | JSONObject jo = new JSONObject(str); |
175 | SharedPreferencesUtil.putData("photo", jo2.getString("photo")); | 165 | boolean isSucceed = jo.getBoolean("success"); |
176 | startActivity(TeacherChooseActivity.class); | 166 | if (isSucceed) { |
177 | finish(); | 167 | JSONObject jo2 = jo.getJSONObject("data"); |
178 | } else { | 168 | String role = jo2.getString("role"); |
179 | showToast("您没有权限"); | 169 | if ("member_advisor".equals(role) || "teaching_supervision".equals(role)) { |
180 | } | ||
181 | |||
182 | } else { | ||
183 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | ||
184 | } | ||
185 | } catch (Exception e) { | ||
186 | e.printStackTrace(); | ||
187 | Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | @Override | 170 | SharedPreferencesUtil.putData("phone", phone); |
192 | public void onError(Throwable e) { | 171 | SharedPreferencesUtil.putData("role", role); |
193 | 172 | SharedPreferencesUtil.putData("userId", jo2.getString("id")); | |
194 | } | 173 | SharedPreferencesUtil.putData("token", jo2.getString("token")); |
195 | 174 | SharedPreferencesUtil.putData("name", jo2.getString("username")); | |
196 | @Override | 175 | SharedPreferencesUtil.putData("photo", jo2.getString("photo")); |
197 | public void onComplete() { | 176 | startActivity(TeacherChooseActivity.class); |
198 | 177 | finish(); | |
199 | } | 178 | } else { |
200 | }); | 179 | showToast("您没有权限"); |
201 | } | 180 | } |
202 | 181 | ||
203 | 182 | } else { | |
204 | @Override | 183 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); |
205 | protected void initData() { | 184 | } |
206 | 185 | } catch (Exception e) { | |
207 | } | 186 | e.printStackTrace(); |
208 | 187 | Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); | |
209 | @Override | 188 | } |
app/src/main/java/com/hjx/parent/SmsLoginActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.content.Intent; | ||
5 | import android.os.Bundle; | ||
6 | import android.telephony.PhoneNumberUtils; | ||
7 | import android.text.TextUtils; | ||
8 | import android.view.View; | ||
9 | import android.widget.Toast; | ||
10 | |||
11 | import com.hjx.parent.databinding.ActivitySmsLoginBinding; | ||
12 | import com.hjx.parent.rx.BaseRxActivity; | ||
13 | import com.prws.common.net.NetWorks; | ||
14 | import com.prws.common.utils.LogUtil; | ||
15 | import com.prws.common.utils.SharedPreferencesUtil; | ||
16 | |||
17 | import java.util.HashMap; | ||
18 | import java.util.Map; | ||
19 | import java.util.concurrent.TimeUnit; | ||
20 | |||
21 | import io.reactivex.Observable; | ||
22 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
23 | import io.reactivex.disposables.Disposable; | ||
24 | |||
25 | public class SmsLoginActivity extends BaseRxActivity<ActivitySmsLoginBinding> { | ||
26 | private final NetWorks.NetService api = NetWorks.service_url; | ||
27 | @Override | ||
28 | public void initView(Bundle savedInstanceState) { | ||
29 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE); | ||
30 | |||
31 | String student = (String) SharedPreferencesUtil.getData("student", ""); | ||
32 | |||
33 | if (!TextUtils.isEmpty(student)) { | ||
34 | if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { | ||
35 | Intent intent = new Intent(this, MainActivity.class); | ||
36 | startActivity(intent); | ||
37 | finish(); | ||
38 | } else { | ||
39 | Intent intent = new Intent(this, TeacherMainActivity.class); | ||
40 | startActivity(intent); | ||
41 | finish(); | ||
42 | } | ||
43 | return; | ||
44 | } | ||
45 | |||
46 | binding.tvEntrance.setOnClickListener(v -> { | ||
47 | startActivity(new Intent(this, LoginActivity.class)); | ||
48 | finish(); | ||
49 | }); | ||
50 | binding.btnGetCode.setOnClickListener(v -> { | ||
51 | String phone = binding.etPhone.getText().toString().trim(); | ||
52 | if (phone.isEmpty()) { | ||
53 | showToast("请输入手机号"); | ||
54 | return; | ||
55 | } | ||
56 | sendCode(phone); | ||
57 | }); | ||
58 | binding.btnLogin.setOnClickListener(v -> { | ||
59 | |||
60 | String phone = binding.etPhone.getText().toString().trim(); | ||
61 | String code = binding.etCode.getText().toString().trim(); | ||
62 | if (phone.isEmpty() || code.isEmpty()) { | ||
63 | Toast.makeText(this, "手机号以及验证码不能为空", Toast.LENGTH_SHORT).show(); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | if (!binding.chkPermission.isChecked()) { | ||
68 | Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); | ||
69 | return; | ||
70 | } | ||
71 | login(phone, code); | ||
72 | }); | ||
73 | |||
74 | binding.tv6.setOnClickListener(view -> { | ||
75 | startActivity(new Intent(this, YinsiActivity.class)); | ||
76 | }); | ||
77 | binding.tv4.setOnClickListener(view -> { | ||
78 | startActivity(new Intent(this, UserAgreementActivity.class)); | ||
79 | }); | ||
80 | } | ||
81 | |||
82 | @SuppressLint("CheckResult") | ||
83 | private void login(String phone, String code) { | ||
84 | binding.btnLogin.setEnabled(false); | ||
85 | Map<String, String> body = new HashMap<>(); | ||
86 | body.put("phone", phone); | ||
87 | body.put("code", code); | ||
88 | api.smsLogin(body) | ||
89 | .compose(transformSingle()) | ||
90 | .subscribe((response, th) -> { | ||
91 | binding.btnLogin.setEnabled(true); | ||
92 | if (handleResponseData(response, th)) { | ||
93 | SharedPreferencesUtil.putData("phone", phone); | ||
94 | SharedPreferencesUtil.putData("role", "parent"); | ||
95 | SharedPreferencesUtil.putData("userId", response.getData().id); | ||
96 | SharedPreferencesUtil.putData("token", response.getData().token); | ||
97 | SharedPreferencesUtil.putData("name", response.getData().username); | ||
98 | startActivity(new Intent(this, ChooseActivity.class)); | ||
99 | finish(); | ||
100 | } | ||
101 | }); | ||
102 | } | ||
103 | |||
104 | @SuppressLint({"SetTextI18n", "CheckResult"}) | ||
105 | private void sendCode(String phone) { | ||
106 | binding.btnGetCode.setEnabled(false); | ||
107 | api.smsCode(phone) | ||
108 | .compose(transformSingle()) | ||
109 | .subscribe((response, th) -> { | ||
110 | if (handleResponse(response, th)) { | ||
111 | showToast("验证码已发送"); | ||
112 | timeDown(); | ||
113 | } else { | ||
114 | if (disposable != null) disposable.dispose(); | ||
115 | binding.btnGetCode.setText("获取验证码"); | ||
116 | binding.btnGetCode.setEnabled(true); | ||
117 | } | ||
118 | }); | ||
119 | } | ||
120 | |||
121 | private int timeDown = 0; | ||
122 | private Disposable disposable; | ||
123 | @SuppressLint("SetTextI18n") | ||
124 | private void timeDown() { | ||
125 | timeDown = 60; | ||
126 | disposable = Observable | ||
127 | .interval(0, 1, TimeUnit.SECONDS) | ||
128 | .observeOn(AndroidSchedulers.mainThread()) | ||
129 | .subscribe(l -> { | ||
130 | if (--timeDown <= 0) { | ||
131 | if (disposable != null) disposable.dispose(); | ||
132 | binding.btnGetCode.setText("获取验证码"); | ||
133 | binding.btnGetCode.setEnabled(true); | ||
134 | } else { | ||
135 | binding.btnGetCode.setText("获取验证码(" + timeDown + "s)"); | ||
136 | binding.btnGetCode.setEnabled(false); | ||
137 | } | ||
138 | }, Throwable::printStackTrace); | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | protected void onDestroy() { | ||
143 | super.onDestroy(); | ||
144 | if (disposable != null) disposable.dispose(); | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | protected ActivitySmsLoginBinding getViewBinding() { | ||
149 | return ActivitySmsLoginBinding.inflate(getLayoutInflater()); | ||
150 | } | ||
151 | } | ||
1 | package com.hjx.parent; | 152 |
app/src/main/java/com/hjx/parent/bean/StudentBean.java
1 | package com.hjx.parent.bean; | 1 | package com.hjx.parent.bean; |
2 | 2 | ||
3 | public class StudentBean { | 3 | public class StudentBean { |
4 | 4 | ||
5 | private String stuId; | 5 | private String stuId; |
6 | private String stuName; | 6 | private String stuName; |
7 | private String gender; | 7 | private String gender; |
8 | private String term; | 8 | private String term; |
9 | private String account; | 9 | private String account; |
10 | private String nickName; | 10 | private String nickName; |
11 | private String address; | 11 | private String address; |
12 | private String phone; | 12 | private String phone; |
13 | private String photo; | 13 | private String photo; |
14 | private String oriSchool; | 14 | private String oriSchool; |
15 | private String parentPhone; | 15 | private String parentPhone; |
16 | private String parentIdentity; | 16 | private String parentIdentity; |
17 | private String teacherName; | 17 | private String teacherName; |
18 | private String grade; | 18 | private String grade; |
19 | private int isIntention; | 19 | private int isIntention; |
20 | 20 | ||
21 | // not exist | 21 | // not exist |
22 | private String teacherAvatar; | 22 | private String teacherAvatar; |
23 | private Integer state; | 23 | private Integer state; |
24 | 24 | ||
25 | 25 | ||
26 | public String getStuId() { | 26 | public String getStuId() { |
27 | return stuId; | 27 | return stuId; |
28 | } | 28 | } |
29 | 29 | ||
30 | public void setStuId(String stuId) { | 30 | public void setStuId(String stuId) { |
31 | this.stuId = stuId; | 31 | this.stuId = stuId; |
32 | } | 32 | } |
33 | 33 | ||
34 | public String getStuName() { | 34 | public String getStuName() { |
35 | return stuName; | 35 | return stuName; |
36 | } | 36 | } |
37 | 37 | ||
38 | public void setStuName(String stuName) { | 38 | public void setStuName(String stuName) { |
39 | this.stuName = stuName; | 39 | this.stuName = stuName; |
40 | } | 40 | } |
41 | 41 | ||
42 | public String getGender() { | 42 | public String getGender() { |
43 | return gender; | 43 | return gender; |
44 | } | 44 | } |
45 | 45 | ||
46 | public void setGender(String gender) { | 46 | public void setGender(String gender) { |
47 | this.gender = gender; | 47 | this.gender = gender; |
48 | } | 48 | } |
49 | 49 | ||
50 | public String getTerm() { | 50 | public String getTerm() { |
51 | return term; | 51 | return term; |
52 | } | 52 | } |
53 | 53 | ||
54 | public void setTerm(String term) { | 54 | public void setTerm(String term) { |
55 | this.term = term; | 55 | this.term = term; |
56 | } | 56 | } |
57 | 57 | ||
58 | public String getAccount() { | 58 | public String getAccount() { |
59 | return account; | 59 | return account; |
60 | } | 60 | } |
61 | 61 | ||
62 | public void setAccount(String account) { | 62 | public void setAccount(String account) { |
63 | this.account = account; | 63 | this.account = account; |
64 | } | 64 | } |
65 | 65 | ||
66 | public String getNickName() { | 66 | public String getNickName() { |
67 | return nickName; | 67 | return nickName == null || nickName.isEmpty() ? stuName : nickName; |
68 | } | 68 | } |
69 | 69 | ||
70 | public void setNickName(String nickName) { | 70 | public void setNickName(String nickName) { |
71 | this.nickName = nickName; | 71 | this.nickName = nickName; |
72 | } | 72 | } |
73 | 73 | ||
74 | public String getAddress() { | 74 | public String getAddress() { |
75 | return address; | 75 | return address; |
76 | } | 76 | } |
77 | 77 | ||
78 | public void setAddress(String address) { | 78 | public void setAddress(String address) { |
79 | this.address = address; | 79 | this.address = address; |
80 | } | 80 | } |
81 | 81 | ||
82 | public String getPhone() { | 82 | public String getPhone() { |
83 | return phone; | 83 | return phone; |
84 | } | 84 | } |
85 | 85 | ||
86 | public void setPhone(String phone) { | 86 | public void setPhone(String phone) { |
87 | this.phone = phone; | 87 | this.phone = phone; |
88 | } | 88 | } |
89 | 89 | ||
90 | public String getPhoto() { | 90 | public String getPhoto() { |
91 | return photo; | 91 | return photo; |
92 | } | 92 | } |
93 | 93 | ||
94 | public void setPhoto(String photo) { | 94 | public void setPhoto(String photo) { |
95 | this.photo = photo; | 95 | this.photo = photo; |
96 | } | 96 | } |
97 | 97 | ||
98 | public String getOriSchool() { | 98 | public String getOriSchool() { |
99 | return oriSchool; | 99 | return oriSchool; |
100 | } | 100 | } |
101 | 101 | ||
102 | public void setOriSchool(String oriSchool) { | 102 | public void setOriSchool(String oriSchool) { |
103 | this.oriSchool = oriSchool; | 103 | this.oriSchool = oriSchool; |
104 | } | 104 | } |
105 | 105 | ||
106 | public String getParentPhone() { | 106 | public String getParentPhone() { |
107 | return parentPhone; | 107 | return parentPhone; |
108 | } | 108 | } |
109 | 109 | ||
110 | public void setParentPhone(String parentPhone) { | 110 | public void setParentPhone(String parentPhone) { |
111 | this.parentPhone = parentPhone; | 111 | this.parentPhone = parentPhone; |
112 | } | 112 | } |
113 | 113 | ||
114 | public String getParentIdentity() { | 114 | public String getParentIdentity() { |
115 | return parentIdentity; | 115 | return parentIdentity; |
116 | } | 116 | } |
117 | 117 | ||
118 | public void setParentIdentity(String parentIdentity) { | 118 | public void setParentIdentity(String parentIdentity) { |
119 | this.parentIdentity = parentIdentity; | 119 | this.parentIdentity = parentIdentity; |
120 | } | 120 | } |
121 | 121 | ||
122 | public String getTeacherName() { | 122 | public String getTeacherName() { |
123 | return teacherName; | 123 | return teacherName; |
124 | } | 124 | } |
125 | 125 | ||
126 | public void setTeacherName(String teacherName) { | 126 | public void setTeacherName(String teacherName) { |
127 | this.teacherName = teacherName; | 127 | this.teacherName = teacherName; |
128 | } | 128 | } |
129 | 129 | ||
130 | public String getGrade() { | 130 | public String getGrade() { |
131 | return grade; | 131 | return grade; |
132 | } | 132 | } |
133 | 133 | ||
134 | public void setGrade(String grade) { | 134 | public void setGrade(String grade) { |
135 | this.grade = grade; | 135 | this.grade = grade; |
136 | } | 136 | } |
137 | 137 | ||
138 | public int getIsIntention() { | 138 | public int getIsIntention() { |
139 | return isIntention; | 139 | return isIntention; |
140 | } | 140 | } |
141 | 141 | ||
142 | public void setIsIntention(int isIntention) { | 142 | public void setIsIntention(int isIntention) { |
143 | this.isIntention = isIntention; | 143 | this.isIntention = isIntention; |
144 | } | 144 | } |
145 | 145 | ||
146 | public String getTeacherAvatar() { | 146 | public String getTeacherAvatar() { |
147 | return teacherAvatar; | 147 | return teacherAvatar; |
148 | } | 148 | } |
149 | 149 | ||
150 | public void setTeacherAvatar(String teacherAvatar) { | 150 | public void setTeacherAvatar(String teacherAvatar) { |
151 | this.teacherAvatar = teacherAvatar; | 151 | this.teacherAvatar = teacherAvatar; |
152 | } | 152 | } |
153 | 153 | ||
154 | public Integer getState() { | 154 | public Integer getState() { |
155 | return state; | 155 | return state; |
156 | } | 156 | } |
157 | 157 | ||
158 | public void setState(Integer state) { | 158 | public void setState(Integer state) { |
159 | this.state = state; | 159 | this.state = state; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 |
app/src/main/java/com/hjx/parent/rx/BaseRxActivity.java
1 | package com.hjx.parent.rx; | 1 | package com.hjx.parent.rx; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | 4 | ||
5 | import androidx.annotation.Nullable; | 5 | import androidx.annotation.Nullable; |
6 | import androidx.viewbinding.ViewBinding; | 6 | import androidx.viewbinding.ViewBinding; |
7 | 7 | ||
8 | import com.hjx.parent.BaseActivity; | 8 | import com.hjx.parent.BaseActivity; |
9 | import com.prws.common.bean.ResponseResult; | ||
9 | import com.prws.common.bean.ResponseResult; | 10 | import com.trello.rxlifecycle2.android.ActivityEvent; |
10 | import com.trello.rxlifecycle2.android.ActivityEvent; | 11 | |
11 | 12 | import io.reactivex.subjects.BehaviorSubject; | |
12 | import io.reactivex.subjects.BehaviorSubject; | 13 | |
13 | 14 | public abstract class BaseRxActivity<VB extends ViewBinding> extends BaseActivity<VB> implements ILifecycleActivity { | |
14 | public abstract class BaseRxActivity<VB extends ViewBinding> extends BaseActivity<VB> implements ILifecycleActivity { | 15 | private BehaviorSubject<ActivityEvent> rxLifecycle = BehaviorSubject.create(); |
15 | private BehaviorSubject<ActivityEvent> rxLifecycle = BehaviorSubject.create(); | 16 | |
16 | 17 | @Override | |
17 | @Override | 18 | public BehaviorSubject<ActivityEvent> getRxLifecycle() { |
18 | public BehaviorSubject<ActivityEvent> getRxLifecycle() { | 19 | return rxLifecycle; |
19 | return rxLifecycle; | 20 | } |
20 | } | 21 | |
21 | 22 | @Override | |
22 | @Override | 23 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
23 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 24 | super.onCreate(savedInstanceState); |
24 | super.onCreate(savedInstanceState); | 25 | rxLifecycle.onNext(ActivityEvent.CREATE); |
25 | rxLifecycle.onNext(ActivityEvent.CREATE); | 26 | } |
26 | } | 27 | |
27 | 28 | @Override | |
28 | @Override | 29 | protected void onStart() { |
29 | protected void onStart() { | 30 | super.onStart(); |
30 | super.onStart(); | 31 | rxLifecycle.onNext(ActivityEvent.START); |
31 | rxLifecycle.onNext(ActivityEvent.START); | 32 | } |
32 | } | 33 | |
33 | 34 | @Override | |
34 | @Override | 35 | protected void onResume() { |
35 | protected void onResume() { | 36 | super.onResume(); |
36 | super.onResume(); | 37 | rxLifecycle.onNext(ActivityEvent.RESUME); |
37 | rxLifecycle.onNext(ActivityEvent.RESUME); | 38 | } |
38 | } | 39 | |
39 | 40 | @Override | |
40 | @Override | 41 | protected void onPause() { |
41 | protected void onPause() { | 42 | super.onPause(); |
42 | super.onPause(); | 43 | rxLifecycle.onNext(ActivityEvent.PAUSE); |
43 | rxLifecycle.onNext(ActivityEvent.PAUSE); | 44 | } |
44 | } | 45 | |
45 | 46 | @Override | |
46 | @Override | 47 | protected void onStop() { |
47 | protected void onStop() { | 48 | super.onStop(); |
48 | super.onStop(); | 49 | rxLifecycle.onNext(ActivityEvent.STOP); |
49 | rxLifecycle.onNext(ActivityEvent.STOP); | 50 | } |
50 | } | 51 | |
51 | 52 | @Override | |
52 | @Override | 53 | protected void onDestroy() { |
53 | protected void onDestroy() { | 54 | super.onDestroy(); |
54 | super.onDestroy(); | 55 | rxLifecycle.onNext(ActivityEvent.DESTROY); |
55 | rxLifecycle.onNext(ActivityEvent.DESTROY); | 56 | } |
56 | } | 57 | |
58 | public <T> boolean handleResponse(ResponseResult<T> response, Throwable t) { | ||
59 | if (t != null) { | ||
60 | t.printStackTrace(); | ||
61 | showToast(t.getMessage()); | ||
62 | } | ||
63 | if (response == null) return false; | ||
64 | if (response.getSuccess() != null && response.getSuccess()) { | ||
65 | return true; | ||
66 | } else { | ||
67 | if (response.getMsg() != null && !response.getMsg().isEmpty()) { | ||
68 | showToast(response.getMsg()); | ||
69 | } | ||
70 | return false; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | public <T> boolean handleResponseData(ResponseResult<T> response, Throwable t) { | ||
75 | if (handleResponse(response, t)) { | ||
76 | return response.getData() != null; | ||
77 | } | ||
78 | return false; | ||
79 | } | ||
57 | 80 | } | |
58 | public <T> boolean handleResponse(ResponseResult<T> response, Throwable t) { | 81 |
app/src/main/res/layout/activity_login.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:background="@mipmap/bg"> | 6 | android:background="@mipmap/bg"> |
7 | 7 | ||
8 | 8 | ||
9 | <TextView | 9 | <TextView |
10 | android:id="@+id/tvBack" | ||
11 | android:text="家长登录" | ||
12 | android:textSize="13sp" | ||
13 | android:textColor="#666" | ||
14 | android:layout_width="wrap_content" | ||
15 | android:layout_height="wrap_content" | ||
16 | android:layout_marginTop="72dp" | ||
17 | android:layout_marginEnd="30dp" | ||
18 | app:layout_constraintTop_toTopOf="parent" | ||
19 | app:layout_constraintEnd_toEndOf="parent"/> | ||
20 | |||
21 | <TextView | ||
10 | android:id="@+id/tvBack" | 22 | android:layout_width="wrap_content" |
11 | android:text="家长登录" | 23 | android:layout_height="wrap_content" |
12 | android:textSize="13sp" | 24 | android:layout_marginLeft="30dp" |
13 | android:textColor="#666" | 25 | android:layout_marginTop="64dp" |
14 | android:layout_width="wrap_content" | 26 | android:text="教师登录" |
15 | android:layout_height="wrap_content" | 27 | android:textColor="#333333" |
16 | android:layout_marginTop="72dp" | 28 | android:textSize="25dp" |
17 | android:layout_marginEnd="30dp" | 29 | android:textStyle="bold" |
18 | app:layout_constraintTop_toTopOf="parent" | 30 | app:layout_constraintLeft_toLeftOf="parent" |
19 | app:layout_constraintEnd_toEndOf="parent"/> | 31 | app:layout_constraintTop_toTopOf="parent" /> |
20 | 32 | ||
21 | <TextView | 33 | <View |
22 | android:layout_width="wrap_content" | 34 | android:id="@+id/view_1" |
23 | android:layout_height="wrap_content" | 35 | android:layout_width="315dp" |
24 | android:layout_marginLeft="30dp" | 36 | android:layout_height="50dp" |
25 | android:layout_marginTop="64dp" | 37 | android:layout_marginTop="166dp" |
26 | android:text="教师登录" | 38 | android:background="@drawable/bg_solid_white" |
27 | android:textColor="#333333" | 39 | app:layout_constraintLeft_toLeftOf="parent" |
28 | android:textSize="25dp" | 40 | app:layout_constraintRight_toRightOf="parent" |
29 | android:textStyle="bold" | 41 | app:layout_constraintTop_toTopOf="parent" /> |
30 | app:layout_constraintLeft_toLeftOf="parent" | 42 | |
31 | app:layout_constraintTop_toTopOf="parent" /> | 43 | <ImageView |
32 | 44 | android:id="@+id/iv_1" | |
33 | <View | 45 | android:layout_width="16dp" |
34 | android:id="@+id/view_1" | 46 | android:layout_height="18dp" |
35 | android:layout_width="315dp" | 47 | android:layout_marginLeft="20dp" |
36 | android:layout_height="50dp" | 48 | android:background="@mipmap/sjh" |
37 | android:layout_marginTop="166dp" | 49 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
38 | android:background="@drawable/bg_solid_white" | 50 | app:layout_constraintLeft_toLeftOf="@id/view_1" |
39 | app:layout_constraintLeft_toLeftOf="parent" | 51 | app:layout_constraintTop_toTopOf="@id/view_1" /> |
40 | app:layout_constraintRight_toRightOf="parent" | 52 | |
41 | app:layout_constraintTop_toTopOf="parent" /> | 53 | <ImageView |
42 | 54 | android:id="@+id/iv_2" | |
43 | <ImageView | 55 | android:layout_width="13dp" |
44 | android:id="@+id/iv_1" | 56 | android:layout_height="13dp" |
45 | android:layout_width="16dp" | 57 | android:layout_marginRight="20dp" |
46 | android:layout_height="18dp" | 58 | android:background="@mipmap/sc" |
47 | android:layout_marginLeft="20dp" | 59 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
48 | android:background="@mipmap/sjh" | 60 | app:layout_constraintRight_toRightOf="@id/view_1" |
49 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 61 | app:layout_constraintTop_toTopOf="@id/view_1" /> |
50 | app:layout_constraintLeft_toLeftOf="@id/view_1" | 62 | |
51 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 63 | <EditText |
52 | 64 | android:id="@+id/et_phone" | |
53 | <ImageView | 65 | android:layout_width="0dp" |
54 | android:id="@+id/iv_2" | 66 | android:layout_height="0dp" |
55 | android:layout_width="13dp" | 67 | android:layout_marginLeft="46dp" |
56 | android:layout_height="13dp" | 68 | android:background="@android:color/transparent" |
57 | android:layout_marginRight="20dp" | 69 | android:gravity="left|center_vertical" |
58 | android:background="@mipmap/sc" | 70 | android:hint="请输入手机号" |
59 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 71 | android:inputType="number" |
60 | app:layout_constraintRight_toRightOf="@id/view_1" | 72 | android:maxLength="11" |
61 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 73 | android:textColorHint="#999999" |
62 | 74 | android:textSize="16dp" | |
63 | <EditText | 75 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
64 | android:id="@+id/et_phone" | 76 | app:layout_constraintLeft_toLeftOf="@id/view_1" |
65 | android:layout_width="0dp" | 77 | app:layout_constraintRight_toLeftOf="@id/iv_2" |
66 | android:layout_height="0dp" | 78 | app:layout_constraintTop_toTopOf="@id/view_1" /> |
67 | android:layout_marginLeft="46dp" | 79 | |
68 | android:background="@android:color/transparent" | 80 | |
69 | android:gravity="left|center_vertical" | 81 | <View |
70 | android:hint="请输入手机号" | 82 | android:id="@+id/view_2" |
71 | android:inputType="number" | 83 | android:layout_width="315dp" |
72 | android:maxLength="11" | 84 | android:layout_height="50dp" |
73 | android:textColorHint="#999999" | 85 | android:layout_marginTop="241dp" |
74 | android:textSize="16dp" | 86 | android:background="@drawable/bg_solid_white" |
75 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 87 | app:layout_constraintLeft_toLeftOf="parent" |
76 | app:layout_constraintLeft_toLeftOf="@id/view_1" | 88 | app:layout_constraintRight_toRightOf="parent" |
77 | app:layout_constraintRight_toLeftOf="@id/iv_2" | 89 | app:layout_constraintTop_toTopOf="parent" /> |
78 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 90 | |
79 | 91 | <ImageView | |
80 | 92 | android:id="@+id/iv_3" | |
81 | <View | 93 | android:layout_width="16dp" |
82 | android:id="@+id/view_2" | 94 | android:layout_height="18dp" |
83 | android:layout_width="315dp" | 95 | android:layout_marginLeft="20dp" |
84 | android:layout_height="50dp" | 96 | android:background="@mipmap/mm" |
85 | android:layout_marginTop="241dp" | 97 | app:layout_constraintBottom_toBottomOf="@id/view_2" |
86 | android:background="@drawable/bg_solid_white" | 98 | app:layout_constraintLeft_toLeftOf="@id/view_2" |
87 | app:layout_constraintLeft_toLeftOf="parent" | 99 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
88 | app:layout_constraintRight_toRightOf="parent" | 100 | |
89 | app:layout_constraintTop_toTopOf="parent" /> | 101 | <ImageView |
90 | 102 | android:id="@+id/iv_4" | |
91 | <ImageView | 103 | android:layout_width="20dp" |
92 | android:id="@+id/iv_3" | 104 | android:layout_height="16dp" |
93 | android:layout_width="16dp" | 105 | android:layout_marginRight="20dp" |
94 | android:layout_height="18dp" | 106 | android:background="@mipmap/xs" |
95 | android:layout_marginLeft="20dp" | 107 | app:layout_constraintBottom_toBottomOf="@id/view_2" |
96 | android:background="@mipmap/mm" | 108 | app:layout_constraintRight_toRightOf="@id/view_2" |
97 | app:layout_constraintBottom_toBottomOf="@id/view_2" | 109 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
98 | app:layout_constraintLeft_toLeftOf="@id/view_2" | 110 | |
99 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 111 | <EditText |
100 | 112 | android:id="@+id/et_pwd" | |
101 | <ImageView | 113 | android:layout_width="0dp" |
102 | android:id="@+id/iv_4" | 114 | android:layout_height="0dp" |
103 | android:layout_width="20dp" | 115 | android:layout_marginLeft="46dp" |
104 | android:layout_height="16dp" | 116 | android:layout_marginRight="20dp" |
105 | android:layout_marginRight="20dp" | 117 | android:background="@android:color/transparent" |
106 | android:background="@mipmap/xs" | 118 | android:gravity="left|center_vertical" |
107 | app:layout_constraintBottom_toBottomOf="@id/view_2" | 119 | android:hint="请输入密码" |
108 | app:layout_constraintRight_toRightOf="@id/view_2" | 120 | android:inputType="textPassword" |
109 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 121 | android:textColorHint="#999999" |
110 | 122 | android:textSize="16dp" | |
111 | <EditText | 123 | app:layout_constraintBottom_toBottomOf="@id/view_2" |
112 | android:id="@+id/et_pwd" | 124 | app:layout_constraintLeft_toLeftOf="@id/view_2" |
113 | android:layout_width="0dp" | 125 | app:layout_constraintRight_toLeftOf="@id/iv_4" |
114 | android:layout_height="0dp" | 126 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
115 | android:layout_marginLeft="46dp" | 127 | |
116 | android:layout_marginRight="20dp" | 128 | |
117 | android:background="@android:color/transparent" | 129 | <Button |
118 | android:gravity="left|center_vertical" | 130 | android:id="@+id/btn_1" |
119 | android:hint="请输入密码" | 131 | android:layout_width="315dp" |
120 | android:inputType="textPassword" | 132 | android:layout_height="50dp" |
121 | android:textColorHint="#999999" | 133 | android:layout_marginTop="331dp" |
122 | android:textSize="16dp" | 134 | android:background="@drawable/bg_solid_btn" |
123 | app:layout_constraintBottom_toBottomOf="@id/view_2" | 135 | android:text="登录" |
124 | app:layout_constraintLeft_toLeftOf="@id/view_2" | 136 | android:textColor="@color/white" |
125 | app:layout_constraintRight_toLeftOf="@id/iv_4" | 137 | android:textSize="18dp" |
126 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 138 | app:layout_constraintLeft_toLeftOf="parent" |
127 | 139 | app:layout_constraintRight_toRightOf="parent" | |
128 | 140 | app:layout_constraintTop_toTopOf="parent" /> | |
129 | <Button | 141 | |
130 | android:id="@+id/btn_1" | ||
131 | android:layout_width="315dp" |
app/src/main/res/layout/activity_sms_login.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | xmlns:tools="http://schemas.android.com/tools" | ||
5 | android:layout_width="match_parent" | ||
6 | android:layout_height="match_parent" | ||
7 | android:background="@mipmap/bg" | ||
8 | tools:ignore="HardcodedText,SpUsage,ContentDescription,Autofill"> | ||
9 | |||
10 | |||
11 | <TextView | ||
12 | android:layout_width="wrap_content" | ||
13 | android:layout_height="wrap_content" | ||
14 | android:layout_marginStart="30dp" | ||
15 | android:layout_marginTop="64dp" | ||
16 | android:text="登录" | ||
17 | android:textColor="#333333" | ||
18 | android:textSize="25dp" | ||
19 | android:textStyle="bold" | ||
20 | app:layout_constraintLeft_toLeftOf="parent" | ||
21 | app:layout_constraintTop_toTopOf="parent" /> | ||
22 | |||
23 | <TextView | ||
24 | android:id="@+id/tvEntrance" | ||
25 | android:text="教师入口" | ||
26 | android:textSize="13sp" | ||
27 | android:textColor="#666" | ||
28 | android:layout_width="wrap_content" | ||
29 | android:layout_height="wrap_content" | ||
30 | android:layout_marginTop="72dp" | ||
31 | android:layout_marginEnd="30dp" | ||
32 | app:layout_constraintTop_toTopOf="parent" | ||
33 | app:layout_constraintEnd_toEndOf="parent"/> | ||
34 | |||
35 | <View | ||
36 | android:id="@+id/view_1" | ||
37 | android:layout_width="315dp" | ||
38 | android:layout_height="50dp" | ||
39 | android:layout_marginTop="166dp" | ||
40 | android:background="@drawable/bg_solid_white" | ||
41 | app:layout_constraintLeft_toLeftOf="parent" | ||
42 | app:layout_constraintRight_toRightOf="parent" | ||
43 | app:layout_constraintTop_toTopOf="parent" /> | ||
44 | |||
45 | <ImageView | ||
46 | android:id="@+id/iv_1" | ||
47 | android:layout_width="16dp" | ||
48 | android:layout_height="18dp" | ||
49 | android:layout_marginStart="20dp" | ||
50 | android:background="@mipmap/sjh" | ||
51 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
52 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
53 | app:layout_constraintTop_toTopOf="@id/view_1" /> | ||
54 | |||
55 | <ImageView | ||
56 | android:id="@+id/iv_2" | ||
57 | android:layout_width="13dp" | ||
58 | android:layout_height="13dp" | ||
59 | android:layout_marginEnd="20dp" | ||
60 | android:background="@mipmap/sc" | ||
61 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
62 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
63 | app:layout_constraintTop_toTopOf="@id/view_1" /> | ||
64 | |||
65 | <EditText | ||
66 | android:id="@+id/etPhone" | ||
67 | android:layout_width="0dp" | ||
68 | android:layout_height="0dp" | ||
69 | android:layout_marginStart="46dp" | ||
70 | android:background="@android:color/transparent" | ||
71 | android:gravity="start|center_vertical" | ||
72 | android:hint="请输入手机号" | ||
73 | android:inputType="number" | ||
74 | android:maxLength="11" | ||
75 | android:textColorHint="#999999" | ||
76 | android:textSize="16dp" | ||
77 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
78 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
79 | app:layout_constraintRight_toLeftOf="@id/iv_2" | ||
80 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
81 | tools:ignore="TextFields" /> | ||
82 | |||
83 | |||
84 | <View | ||
85 | android:id="@+id/view_2" | ||
86 | android:layout_width="315dp" | ||
87 | android:layout_height="50dp" | ||
88 | android:layout_marginTop="241dp" | ||
89 | android:background="@drawable/bg_solid_white" | ||
90 | app:layout_constraintLeft_toLeftOf="parent" | ||
91 | app:layout_constraintRight_toRightOf="parent" | ||
92 | app:layout_constraintTop_toTopOf="parent" /> | ||
93 | |||
94 | <ImageView | ||
95 | android:id="@+id/iv_3" | ||
96 | android:layout_width="16dp" | ||
97 | android:layout_height="18dp" | ||
98 | android:layout_marginStart="20dp" | ||
99 | android:background="@mipmap/mm" | ||
100 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
101 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
102 | app:layout_constraintTop_toTopOf="@id/view_2" /> | ||
103 | |||
104 | <TextView | ||
105 | android:id="@+id/btnGetCode" | ||
106 | android:text="获取验证码" | ||
107 | android:textSize="13dp" | ||
108 | android:textColor="#999" | ||
109 | android:layout_width="wrap_content" | ||
110 | android:layout_height="wrap_content" | ||
111 | android:layout_marginEnd="20dp" | ||
112 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
113 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
114 | app:layout_constraintTop_toTopOf="@id/view_2" /> | ||
115 | |||
116 | <EditText | ||
117 | android:id="@+id/etCode" | ||
118 | android:maxLength="6" | ||
119 | android:layout_width="0dp" | ||
120 | android:layout_height="0dp" | ||
121 | android:layout_marginStart="46dp" | ||
122 | android:layout_marginEnd="20dp" | ||
123 | android:background="@android:color/transparent" | ||
124 | android:gravity="start|center_vertical" | ||
125 | android:hint="请输入验证码" | ||
126 | android:inputType="number" | ||
127 | android:textColorHint="#999999" | ||
128 | android:textSize="16dp" | ||
129 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
130 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
131 | app:layout_constraintRight_toLeftOf="@id/btnGetCode" | ||
132 | app:layout_constraintTop_toTopOf="@id/view_2" /> | ||
133 | |||
134 | |||
135 | <Button | ||
136 | android:id="@+id/btnLogin" | ||
137 | android:layout_width="315dp" | ||
138 | android:layout_height="50dp" | ||
139 | android:layout_marginTop="331dp" | ||
140 | android:background="@drawable/bg_solid_btn" | ||
141 | android:text="登录" | ||
142 | android:textColor="@color/white" | ||
143 | android:textSize="18dp" | ||
144 | app:layout_constraintLeft_toLeftOf="parent" | ||
145 | app:layout_constraintRight_toRightOf="parent" | ||
146 | app:layout_constraintTop_toTopOf="parent" /> | ||
147 | |||
148 | |||
149 | <CheckBox | ||
150 | android:id="@+id/chkPermission" | ||
151 | android:layout_width="wrap_content" | ||
152 | android:layout_height="wrap_content" | ||
153 | android:layout_marginStart="67dp" | ||
154 | android:layout_marginBottom="50dp" | ||
155 | android:background="@android:color/transparent" | ||
156 | app:layout_constraintBottom_toBottomOf="parent" | ||
157 | app:layout_constraintLeft_toLeftOf="parent" /> | ||
158 | |||
159 | <TextView | ||
160 | android:id="@+id/tv_3" | ||
161 | android:layout_width="wrap_content" | ||
162 | android:layout_height="wrap_content" | ||
163 | android:layout_marginStart="5dp" | ||
164 | android:text="已阅读并同意《" | ||
165 | android:textColor="#999999" | ||
166 | android:textSize="12dp" | ||
167 | app:layout_constraintBottom_toBottomOf="@id/chkPermission" | ||
168 | app:layout_constraintLeft_toRightOf="@id/chkPermission" | ||
169 | app:layout_constraintTop_toTopOf="@id/chkPermission" /> | ||
170 | |||
171 | <TextView | ||
172 | android:id="@+id/tv_4" | ||
173 | android:layout_width="wrap_content" | ||
174 | android:layout_height="wrap_content" | ||
175 | android:text="用户协议" | ||
176 | android:textColor="#FE5E09" | ||
177 | android:textSize="12dp" | ||
178 | app:layout_constraintBottom_toBottomOf="@id/chkPermission" | ||
179 | app:layout_constraintLeft_toRightOf="@id/tv_3" | ||
180 | app:layout_constraintTop_toTopOf="@id/chkPermission" /> | ||
181 | |||
182 | <TextView | ||
183 | android:id="@+id/tv_5" | ||
184 | android:layout_width="wrap_content" | ||
185 | android:layout_height="wrap_content" | ||
186 | android:text="》和《" | ||
187 | android:textColor="#999999" | ||
188 | android:textSize="12dp" | ||
189 | app:layout_constraintBottom_toBottomOf="@id/chkPermission" | ||
190 | app:layout_constraintLeft_toRightOf="@id/tv_4" | ||
191 | app:layout_constraintTop_toTopOf="@id/chkPermission" /> | ||
192 | |||
193 | <TextView | ||
194 | android:id="@+id/tv_6" | ||
195 | android:layout_width="wrap_content" | ||
196 | android:layout_height="wrap_content" | ||
197 | android:text="隐私政策" | ||
198 | android:textColor="#FE5E09" | ||
199 | android:textSize="12dp" | ||
200 | app:layout_constraintBottom_toBottomOf="@id/chkPermission" | ||
201 | app:layout_constraintLeft_toRightOf="@id/tv_5" | ||
202 | app:layout_constraintTop_toTopOf="@id/chkPermission" /> | ||
203 | |||
204 | <TextView | ||
205 | android:id="@+id/tv_7" | ||
206 | android:layout_width="wrap_content" | ||
207 | android:layout_height="wrap_content" | ||
208 | android:text="》" | ||
209 | android:textColor="#999999" | ||
210 | android:textSize="12dp" | ||
211 | app:layout_constraintBottom_toBottomOf="@id/chkPermission" | ||
212 | app:layout_constraintLeft_toRightOf="@id/tv_6" | ||
213 | app:layout_constraintTop_toTopOf="@id/chkPermission" /> | ||
214 | |||
215 | |||
216 | </androidx.constraintlayout.widget.ConstraintLayout> |
libs/common/src/main/java/com/prws/common/bean/User.java
File was created | 1 | package com.prws.common.bean; | |
2 | |||
3 | public class User { | ||
4 | |||
5 | public String id; | ||
6 | public String phone; | ||
7 | public String account; | ||
8 | public String password; | ||
9 | public String username; | ||
10 | public String identity; //用户身份(NORMAL,ADMIN,EMPLOYEE) | ||
11 | public String identityName; //用户身份(普通用户、管理员、内部员工) | ||
12 | public String gender; //性别 | ||
13 | public String registration; //注册方式(用户创建、员工创建) | ||
14 | public String token; | ||
15 | } | ||
1 | package com.prws.common.bean; | 16 |
libs/common/src/main/java/com/prws/common/net/NetWorks.java
1 | package com.prws.common.net; | 1 | package com.prws.common.net; |
2 | 2 | ||
3 | 3 | ||
4 | import com.google.gson.Gson; | 4 | import com.google.gson.Gson; |
5 | import com.google.gson.JsonObject; | 5 | import com.google.gson.JsonObject; |
6 | import com.prws.common.BuildConfig; | 6 | import com.prws.common.BuildConfig; |
7 | import com.prws.common.bean.CutPicBean; | 7 | import com.prws.common.bean.CutPicBean; |
8 | import com.prws.common.bean.GradeAndSubject; | 8 | import com.prws.common.bean.GradeAndSubject; |
9 | import com.prws.common.bean.PageInfo; | 9 | import com.prws.common.bean.PageInfo; |
10 | import com.prws.common.bean.ResponseResult; | 10 | import com.prws.common.bean.ResponseResult; |
11 | import com.prws.common.bean.ScheduleBean; | 11 | import com.prws.common.bean.ScheduleBean; |
12 | import com.prws.common.bean.Student; | 12 | import com.prws.common.bean.Student; |
13 | import com.prws.common.bean.Teacher; | 13 | import com.prws.common.bean.Teacher; |
14 | import com.prws.common.bean.TopicBean; | 14 | import com.prws.common.bean.TopicBean; |
15 | import com.prws.common.bean.UpdateBean; | 15 | import com.prws.common.bean.UpdateBean; |
16 | import com.prws.common.bean.User; | ||
16 | import com.prws.common.bean.User; | 17 | import com.prws.common.bean.baidu.BaiduInput; |
17 | import com.prws.common.bean.baidu.BaiduInput; | 18 | import com.prws.common.bean.homework.HomeWork; |
18 | import com.prws.common.bean.homework.HomeWork; | 19 | import com.prws.common.bean.homework.HomeworkDetail; |
19 | import com.prws.common.bean.homework.HomeworkDetail; | 20 | import com.prws.common.bean.homework.HomeworkList; |
20 | import com.prws.common.bean.homework.HomeworkList; | 21 | import com.prws.common.bean.homework.StDetail; |
21 | import com.prws.common.bean.homework.StDetail; | 22 | import com.prws.common.utils.BitmapUtils; |
22 | import com.prws.common.utils.BitmapUtils; | 23 | import com.prws.common.utils.SharedPreferencesUtil; |
23 | import com.prws.common.utils.SharedPreferencesUtil; | 24 | |
24 | 25 | import java.io.File; | |
25 | import java.io.File; | 26 | import java.util.HashMap; |
26 | import java.util.HashMap; | 27 | import java.util.List; |
27 | import java.util.List; | 28 | import java.util.Map; |
28 | import java.util.Map; | 29 | |
29 | 30 | import io.reactivex.Observable; | |
30 | import io.reactivex.Observable; | 31 | import io.reactivex.Observer; |
31 | import io.reactivex.Observer; | 32 | import io.reactivex.Single; |
32 | import io.reactivex.Single; | 33 | import io.reactivex.android.schedulers.AndroidSchedulers; |
33 | import io.reactivex.android.schedulers.AndroidSchedulers; | 34 | import io.reactivex.schedulers.Schedulers; |
34 | import io.reactivex.schedulers.Schedulers; | 35 | import okhttp3.MediaType; |
35 | import okhttp3.MediaType; | 36 | import okhttp3.MultipartBody; |
36 | import okhttp3.MultipartBody; | 37 | import okhttp3.RequestBody; |
37 | import okhttp3.RequestBody; | 38 | import okhttp3.ResponseBody; |
38 | import okhttp3.ResponseBody; | 39 | import retrofit2.Call; |
39 | import retrofit2.Call; | 40 | import retrofit2.Callback; |
40 | import retrofit2.Callback; | 41 | import retrofit2.http.Body; |
41 | import retrofit2.http.Body; | 42 | import retrofit2.http.GET; |
42 | import retrofit2.http.GET; | 43 | import retrofit2.http.Header; |
43 | import retrofit2.http.Header; | 44 | import retrofit2.http.Headers; |
44 | import retrofit2.http.Headers; | 45 | import retrofit2.http.Multipart; |
45 | import retrofit2.http.Multipart; | 46 | import retrofit2.http.POST; |
46 | import retrofit2.http.POST; | 47 | import retrofit2.http.PUT; |
47 | import retrofit2.http.PUT; | 48 | import retrofit2.http.Part; |
48 | import retrofit2.http.Part; | 49 | import retrofit2.http.PartMap; |
49 | import retrofit2.http.PartMap; | 50 | import retrofit2.http.Query; |
50 | import retrofit2.http.Query; | 51 | import retrofit2.http.Url; |
51 | import retrofit2.http.Url; | 52 | |
52 | 53 | /** | |
53 | /** | 54 | * 类名称:NetWorks |
54 | * 类名称:NetWorks | 55 | * 创建人: |
55 | * 创建人: | 56 | * <p> |
56 | * <p> | 57 | * 类描述:网络请求的操作类 |
57 | * 类描述:网络请求的操作类 | 58 | */ |
58 | */ | 59 | public class NetWorks extends RetrofitUtils { |
59 | public class NetWorks extends RetrofitUtils { | 60 | //服务器路径 |
60 | //服务器路径 | 61 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); |
61 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); | 62 | |
62 | 63 | //设缓存有效期为1天 | |
63 | //设缓存有效期为1天 | 64 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
64 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 65 | //查询缓存的Cache-Control设置,使用缓存 |
65 | //查询缓存的Cache-Control设置,使用缓存 | 66 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
66 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 67 | //查询网络的Cache-Control设置。不使用缓存 |
67 | //查询网络的Cache-Control设置。不使用缓存 | 68 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
68 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 69 | |
69 | 70 | ||
70 | 71 | public interface NetService { | |
71 | public interface NetService { | 72 | |
72 | 73 | ||
73 | 74 | @GET("/api/v1/user/logout") | |
74 | @GET("/api/v1/user/logout") | 75 | Observable<ResponseBody> logout(); |
75 | Observable<ResponseBody> logout(); | 76 | |
76 | 77 | @Multipart | |
77 | @Multipart | 78 | @POST("/api/v1/user/upLoadAvatar") |
78 | @POST("/api/v1/user/upLoadAvatar") | 79 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
79 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 80 | |
80 | 81 | ||
81 | 82 | @Headers("Content-Type: application/json") | |
82 | @Headers("Content-Type: application/json") | 83 | @POST("/api/v1/user/editUser") |
83 | @POST("/api/v1/user/editUser") | 84 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
84 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 85 | |
85 | 86 | @Headers("Content-Type: application/json") | |
86 | @Headers("Content-Type: application/json") | 87 | @POST("/api/v1/user/changePassword") |
87 | @POST("/api/v1/user/changePassword") | 88 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
88 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 89 | |
89 | 90 | ||
90 | 91 | @GET("/api/v1/user/searchById") | |
91 | @GET("/api/v1/user/searchById") | 92 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
92 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 93 | |
93 | 94 | ||
94 | 95 | @Headers("Content-Type: application/json") | |
95 | @Headers("Content-Type: application/json") | 96 | @POST("/api/v1/login/userLogin") |
96 | @POST("/api/v1/login/userLogin") | 97 | Observable<ResponseBody> login(@Body RequestBody body); |
97 | Observable<ResponseBody> login(@Body RequestBody body); | 98 | |
98 | 99 | @GET("/api/v1/resource/listGradeAndSubject") | |
99 | @GET("/api/v1/resource/listGradeAndSubject") | 100 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
100 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 101 | |
101 | 102 | ||
102 | 103 | @GET("/api/v1/manager/generalQrCode") | |
103 | @GET("/api/v1/manager/generalQrCode") | 104 | Observable<ResponseBody> generalQrCode(); |
104 | Observable<ResponseBody> generalQrCode(); | 105 | |
105 | 106 | @GET("/api/v1/parent/scanAndLogin?") | |
106 | @GET("/api/v1/parent/scanAndLogin?") | 107 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); |
107 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); | 108 | |
108 | 109 | @GET("/api/v1/parent/getChildrenList") | |
109 | @GET("/api/v1/parent/getChildrenList") | 110 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
110 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 111 | |
111 | 112 | ||
112 | 113 | @Headers("Content-Type: application/json") | |
113 | @Headers("Content-Type: application/json") | 114 | @POST("/api/v1/parent/registerParent") |
114 | @POST("/api/v1/parent/registerParent") | 115 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
115 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 116 | |
116 | 117 | ||
117 | 118 | @GET("/api/v1/parent/listChildren") | |
118 | @GET("/api/v1/parent/listChildren") | 119 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
119 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 120 | |
120 | 121 | ||
121 | 122 | @Headers("Content-Type: application/json") | |
122 | @Headers("Content-Type: application/json") | 123 | @POST("/api/v1/parent/registerStudent") |
123 | @POST("/api/v1/parent/registerStudent") | 124 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
124 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 125 | |
125 | 126 | @Headers("Content-Type: application/json") | |
126 | @Headers("Content-Type: application/json") | 127 | @POST("/api/v1/parent/bindTeacher") |
127 | @POST("/api/v1/parent/bindTeacher") | 128 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
128 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 129 | |
129 | 130 | @Multipart | |
130 | @Multipart | 131 | @POST("/api/v1/user/upLoadAvatar") |
131 | @POST("/api/v1/user/upLoadAvatar") | 132 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
132 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 133 | |
133 | 134 | ||
134 | 135 | @Multipart | |
135 | @Multipart | 136 | @POST("/api/v1/student/editStudentAvatar") |
136 | @POST("/api/v1/student/editStudentAvatar") | 137 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
137 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 138 | |
138 | 139 | @Headers("Content-Type: application/json") | |
139 | @Headers("Content-Type: application/json") | 140 | @POST("/api/v1/parent/editChild") |
140 | @POST("/api/v1/parent/editChild") | 141 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
141 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 142 | |
142 | 143 | @GET("/api/v1/student/getStudyPlanForThisWeek") | |
143 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 144 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
144 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 145 | |
145 | 146 | @GET("api/v1/parent/searchTeacher") | |
146 | @GET("api/v1/parent/searchTeacher") | 147 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
147 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 148 | |
148 | 149 | @POST("api/v1/question/listErrorBook") | |
149 | @POST("api/v1/question/listErrorBook") | 150 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
150 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 151 | |
151 | 152 | @POST | |
152 | @POST | 153 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
153 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 154 | |
154 | 155 | @POST | |
155 | @POST | 156 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
156 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 157 | |
157 | 158 | @POST | |
158 | @POST | 159 | Observable<JsonObject> getBaiduToken(@Url String url); |
159 | Observable<JsonObject> getBaiduToken(@Url String url); | 160 | |
160 | 161 | @Multipart | |
161 | @Multipart | 162 | @POST("api/v1/pad/addErrorBook") |
162 | @POST("api/v1/pad/addErrorBook") | 163 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
163 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 164 | |
164 | 165 | @POST("api/v1/pad/deleteStuErrorBook") | |
165 | @POST("api/v1/pad/deleteStuErrorBook") | 166 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
166 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 167 | |
167 | 168 | @PUT("api/v1/pad/updateStuErrorBookInfo") | |
168 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 169 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
169 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 170 | |
170 | 171 | @POST("api/v1/question/editErrorBook") | |
171 | @POST("api/v1/question/editErrorBook") | 172 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
172 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 173 | |
173 | 174 | @GET("api/v1/resource/checkUpdate") | |
174 | @GET("api/v1/resource/checkUpdate") | 175 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
175 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 176 | |
176 | 177 | @GET("api/v1/teacher/getStudentList") | |
177 | @GET("api/v1/teacher/getStudentList") | 178 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); |
178 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | 179 | |
179 | 180 | @GET("api/v1/teacher/getStudentList") | |
180 | @GET("api/v1/teacher/getStudentList") | 181 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); |
181 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); | 182 | |
182 | 183 | @GET("api/v1/answer/listRecordForTeacher") | |
183 | @GET("api/v1/answer/listRecordForTeacher") | 184 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
184 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | 185 | |
185 | 186 | @GET("api/v1/homework/listHomeworkByStuId") | |
186 | @GET("api/v1/homework/listHomeworkByStuId") | 187 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); |
187 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | 188 | |
188 | 189 | @POST | |
189 | @POST | 190 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); |
190 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); | 191 | |
191 | 192 | @Multipart | |
192 | @Multipart | 193 | @POST("api/v1/homework/uploadHomework") |
193 | @POST("api/v1/homework/uploadHomework") | 194 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); |
194 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); | 195 | |
195 | 196 | @POST("api/v1/homework/uploadHomeworkAction") | |
196 | @POST("api/v1/homework/uploadHomeworkAction") | 197 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); |
197 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); | 198 | |
198 | 199 | @GET("api/v1/homework/removeHomework") | |
199 | @GET("api/v1/homework/removeHomework") | 200 | Single<ResponseResult<Boolean>> deleteHomework( |
200 | Single<ResponseResult<Boolean>> deleteHomework( | 201 | @Header("Authorization") String token, |
201 | @Header("Authorization") String token, | 202 | @Query("homeworkId") String homeworkId |
202 | @Query("homeworkId") String homeworkId | 203 | ); |
203 | ); | 204 | |
204 | 205 | @GET("api/v1/homework/listHomeworkById") | |
205 | @GET("api/v1/homework/listHomeworkById") | 206 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); |
206 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); | 207 | |
207 | 208 | @POST("api/v1/homework/uploadHomeworkFeedback") | |
208 | @POST("api/v1/homework/uploadHomeworkFeedback") | 209 | Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); |
209 | Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); | 210 | |
210 | 211 | @POST("api/v1/homework/editHomeworkInfo") | |
211 | @POST("api/v1/homework/editHomeworkInfo") | 212 | Single<ResponseResult<Boolean>> editHomework( |
212 | Single<ResponseResult<Boolean>> editHomework( | 213 | @Header("Authorization") String token, |
213 | @Header("Authorization") String token, | 214 | @Body Object body |
214 | @Body Object body | 215 | ); |
215 | ); | 216 | |
216 | 217 | @GET("api/v1/homework/listHomeworkDetailByStuId") | |
217 | @GET("api/v1/homework/listHomeworkDetailByStuId") | 218 | Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( |
218 | Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( | 219 | @Header("Authorization") String token, |
219 | @Header("Authorization") String token, | 220 | @Query("stuId") String stuId, |
220 | @Query("stuId") String stuId, | 221 | @Query("homeworkId") String homeworkId, |
221 | @Query("homeworkId") String homeworkId, | 222 | // type 固定传true |
222 | // type 固定传true | 223 | @Query("type") boolean type |
223 | @Query("type") boolean type | 224 | ); |
224 | ); | 225 | |
225 | 226 | @GET("api/v1/homework/listHomeworkStatistics") | |
226 | @GET("api/v1/homework/listHomeworkStatistics") | 227 | Single<ResponseResult<List<StDetail>>> getHuyouList( |
227 | Single<ResponseResult<List<StDetail>>> getHuyouList( | 228 | @Header("Authorization") String token, |
228 | @Header("Authorization") String token, | 229 | @Query("stuId") String stuId, |
229 | @Query("stuId") String stuId, | 230 | @Query("type") int type //0: 周报, 1:阶段总结 |
230 | @Query("type") int type //0: 周报, 1:阶段总结 | 231 | ); |
231 | ); | 232 | |
232 | 233 | @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent") | |
233 | @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent") | 234 | Single<ResponseResult<StDetail>> getHuyouDetail( |
234 | Single<ResponseResult<StDetail>> getHuyouDetail( | 235 | @Header("Authorization") String token, |
235 | @Header("Authorization") String token, | 236 | @Query("homeworkStatisticsId") String homeworkId |
236 | @Query("homeworkStatisticsId") String homeworkId | 237 | ); |
237 | ); | 238 | |
238 | 239 | @GET("api/v1/demo/generalStatisticsHomework") | |
239 | @GET("api/v1/demo/generalStatisticsHomework") | 240 | Single<ResponseResult<Object>> generalHuyou(); |
240 | Single<ResponseResult<Object>> generalHuyou(); | 241 | |
241 | 242 | @POST("api/v1/homework/generalHomeworkStageStatistics") | |
242 | @POST("api/v1/homework/generalHomeworkStageStatistics") | 243 | Single<ResponseResult<Boolean>> generalStageHuyou( |
243 | Single<ResponseResult<Boolean>> generalStageHuyou( | 244 | @Header("Authorization") String token, |
244 | @Header("Authorization") String token, | 245 | @Body Object body |
245 | @Body Object body | 246 | ); |
246 | ); | 247 | |
247 | 248 | @GET("api/v1/homework/removeHomeworkStatistics") | |
248 | @GET("api/v1/homework/removeHomeworkStatistics") | 249 | Single<ResponseResult<Boolean>> deleteHuyou( |
249 | Single<ResponseResult<Boolean>> deleteHuyou( | 250 | @Header("Authorization") String token, |
250 | @Header("Authorization") String token, | 251 | @Query("homeworkStatisticsId") String homeworkId |
251 | @Query("homeworkStatisticsId") String homeworkId | 252 | ); |
252 | ); | 253 | |
254 | @GET("api/v1/login/smsCode") | ||
255 | Single<ResponseResult<String>> smsCode(@Query("mobile") String mobile); | ||
256 | |||
257 | @POST("api/v1/login/smsLogin") | ||
258 | Single<ResponseResult<User>> smsLogin(@Body Object body); | ||
259 | |||
253 | 260 | } | |
254 | @GET("api/v1/login/smsCode") | 261 | |
255 | Single<ResponseResult<String>> smsCode(@Query("mobile") String mobile); | 262 | public static String getUserId() { |
256 | 263 | return (String) SharedPreferencesUtil.getData("userId", ""); | |
257 | @POST("api/v1/login/smsLogin") | 264 | } |
258 | Single<ResponseResult<User>> smsLogin(@Body Object body); | 265 | |
259 | 266 | public static String getHeader() { | |
260 | } | 267 | return (String) SharedPreferencesUtil.getData("token", ""); |
261 | 268 | } | |
262 | public static String getUserId() { | 269 | |
263 | return (String) SharedPreferencesUtil.getData("userId", ""); | 270 | public static String getBaiduToken() { |
264 | } | 271 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
265 | 272 | } | |
266 | public static String getHeader() { | 273 | |
267 | return (String) SharedPreferencesUtil.getData("token", ""); | 274 | public static Single<BaiduInput> inputImage(String filePath, String id) { |
268 | } | 275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
269 | 276 | String base64 = BitmapUtils.fileToBase64(filePath); | |
270 | public static String getBaiduToken() { | 277 | File file = new File(filePath); |
271 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 278 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); |
272 | } | 279 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) |
273 | 280 | .flatMap(token -> { | |
274 | public static Single<BaiduInput> inputImage(String filePath, String id) { | 281 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); |
275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 282 | }); |
276 | String base64 = BitmapUtils.fileToBase64(filePath); | 283 | } |
277 | File file = new File(filePath); | 284 | |
278 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); | 285 | public static Single<ResponseResult> uploadImage(String path, String id) { |
279 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) | 286 | File file = new File(path); |
280 | .flatMap(token -> { | 287 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
281 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); | 288 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
282 | }); | 289 | return service_url.uploadImage(getHeader(), part, id); |
283 | } | 290 | } |
284 | 291 | ||
285 | public static Single<ResponseResult> uploadImage(String path, String id) { | 292 | |
286 | File file = new File(path); | 293 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
287 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 294 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
288 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 295 | } |
289 | return service_url.uploadImage(getHeader(), part, id); | 296 | |
290 | } | 297 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
291 | 298 | File file = new File(path); | |
292 | 299 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | |
293 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 300 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
294 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 301 | Map<String, Object> map = new HashMap<>(); |
295 | } | 302 | map.put("condition", param); |
296 | 303 | setSubscribe(service_url.addError(part, map), observer); | |
297 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 304 | } |
298 | File file = new File(path); | 305 | |
299 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 306 | |
300 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 307 | public static void cut(String base64, Observer<CutPicBean> observer) { |
301 | Map<String, Object> map = new HashMap<>(); | 308 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
302 | map.put("condition", param); | 309 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
303 | setSubscribe(service_url.addError(part, map), observer); | 310 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
304 | } | 311 | } |
305 | 312 | ||
306 | 313 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | |
307 | public static void cut(String base64, Observer<CutPicBean> observer) { | 314 | setSubscribe(service_url.editError(getHeader(), map), observer); |
308 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 315 | } |
309 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 316 | |
310 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 317 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
311 | } | 318 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
312 | 319 | } | |
313 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 320 | |
314 | setSubscribe(service_url.editError(getHeader(), map), observer); | 321 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
315 | } | 322 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
316 | 323 | } | |
317 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 324 | |
318 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 325 | public static void getBaiduToken(Observer<JsonObject> observer) { |
319 | } | 326 | setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); |
320 | 327 | } | |
321 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 328 | |
322 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 329 | public static Single<JsonObject> getBaiduTokenOcr() { |
323 | } | 330 | return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); |
324 | 331 | } | |
325 | public static void getBaiduToken(Observer<JsonObject> observer) { | 332 | |
326 | setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); | 333 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
327 | } | 334 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
328 | 335 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | |
329 | public static Single<JsonObject> getBaiduTokenOcr() { | 336 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
330 | return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); | 337 | } |
331 | } | 338 | |
332 | 339 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | |
333 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 340 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
334 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 341 | } |
335 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 342 | |
336 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 343 | public static void logout(Observer<ResponseBody> observer) { |
337 | } | 344 | setSubscribe(service_url.logout(), observer); |
338 | 345 | } | |
339 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 346 | |
340 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 347 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
341 | } | 348 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
342 | 349 | } | |
343 | public static void logout(Observer<ResponseBody> observer) { | 350 | |
344 | setSubscribe(service_url.logout(), observer); | 351 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
345 | } | 352 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
346 | 353 | } | |
347 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 354 | |
348 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 355 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
349 | } | 356 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
350 | 357 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | |
351 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 358 | Map<String, Object> map = new HashMap<>(); |
352 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 359 | map.put("stuId", stuId); |
353 | } | 360 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
354 | 361 | } | |
355 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 362 | |
356 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 363 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
357 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 364 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
358 | Map<String, Object> map = new HashMap<>(); | 365 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
359 | map.put("stuId", stuId); | 366 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
360 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 367 | } |
361 | } | 368 | |
362 | 369 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | |
363 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 370 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
364 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 371 | } |
365 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 372 | |
366 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 373 | |
367 | } | 374 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
368 | 375 | setSubscribe(service_url.editUser(getHeader(), body), observer); | |
369 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 376 | } |
370 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 377 | |
371 | } | 378 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
372 | 379 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | |
373 | 380 | } | |
374 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 381 | |
375 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 382 | |
376 | } | 383 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
377 | 384 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | |
378 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 385 | } |
379 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 386 | |
380 | } | 387 | |
381 | 388 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | |
382 | 389 | setSubscribe(service_url.login(body), observer); | |
383 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 390 | } |
384 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 391 | |
385 | } | 392 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
386 | 393 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | |
387 | 394 | } | |
388 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 395 | |
389 | setSubscribe(service_url.login(body), observer); | 396 | |
390 | } | 397 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { |
391 | 398 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | |
392 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 399 | } |
393 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 400 | |
394 | } | 401 | public static void getChildrenList(Observer<ResponseBody> observer) { |
395 | 402 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | |
396 | 403 | } | |
397 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { | 404 | |
398 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | 405 | |
399 | } | 406 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
400 | 407 | setSubscribe(service_url.registerParent(body), observer); | |
401 | public static void getChildrenList(Observer<ResponseBody> observer) { | 408 | } |
402 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 409 | |
403 | } | 410 | |
404 | 411 | public static void listChildren(Observer<ResponseBody> observer) { | |
405 | 412 | setSubscribe(service_url.listChildren(getHeader()), observer); | |
406 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 413 | } |
407 | setSubscribe(service_url.registerParent(body), observer); | 414 | |
408 | } | 415 | public static void listStudent(Observer<ResponseBody> observer) { |
409 | 416 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | |
410 | 417 | } | |
411 | public static void listChildren(Observer<ResponseBody> observer) { | 418 | |
412 | setSubscribe(service_url.listChildren(getHeader()), observer); | 419 | public static Single<ResponseResult<List<Student>>> listStudent() { |
413 | } | 420 | return service_url.getStudentList2(getHeader(), getUserId()); |
414 | 421 | } | |
415 | public static void listStudent(Observer<ResponseBody> observer) { | 422 | |
416 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 423 | public static void listRecord(Observer<ResponseBody> observer) { |
417 | } | 424 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
418 | 425 | } | |
419 | public static Single<ResponseResult<List<Student>>> listStudent() { | 426 | |
420 | return service_url.getStudentList2(getHeader(), getUserId()); | 427 | |
421 | } | 428 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
422 | 429 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | |
423 | public static void listRecord(Observer<ResponseBody> observer) { | 430 | } |
424 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 431 | |
425 | } | 432 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
426 | 433 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | |
427 | 434 | } | |
428 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 435 | |
429 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 436 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
430 | } | 437 | setSubscribe(service_url.getError(getHeader(), map), observer); |
431 | 438 | } | |
432 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 439 | |
433 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 440 | |
434 | } | 441 | public static RequestBody getMapRequestBody(Map map) { |
435 | 442 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | |
436 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 443 | } |
437 | setSubscribe(service_url.getError(getHeader(), map), observer); | 444 | |
438 | } | 445 | |
439 | 446 | public static RequestBody getArrayRequestBody(List list) { | |
440 | 447 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | |
441 | public static RequestBody getMapRequestBody(Map map) { | 448 | } |
442 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 449 | |
443 | } | 450 | public static RequestBody getFileRequestBody(File file) { |
444 | 451 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | |
445 | 452 | } | |
446 | public static RequestBody getArrayRequestBody(List list) { | 453 | |
447 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 454 | public static RequestBody getFileRequestBody(byte[] bytes) { |
448 | } | 455 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
449 | 456 | } | |
450 | public static RequestBody getFileRequestBody(File file) { | 457 | |
451 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 458 | public static RequestBody getObjectRequestBody(Object obj) { |
452 | } | 459 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
453 | 460 | } | |
454 | public static RequestBody getFileRequestBody(byte[] bytes) { | 461 | |
455 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 462 | public static RequestBody getStringRequestBody(String str) { |
456 | } | 463 | return RequestBody.create(MediaType.parse("text/plain"), str); |
457 | 464 | } | |
458 | public static RequestBody getObjectRequestBody(Object obj) { | 465 | |
459 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 466 | |
460 | } | 467 | /** |
461 | 468 | * 插入观察者 | |
462 | public static RequestBody getStringRequestBody(String str) { | 469 | * |
463 | return RequestBody.create(MediaType.parse("text/plain"), str); | 470 | * @param observable |
464 | } | 471 | * @param observer |
465 | 472 | * @param <T> | |
466 | 473 | */ | |
467 | /** | 474 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
468 | * 插入观察者 | 475 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |
469 | * | 476 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 |
470 | * @param observable | 477 | .subscribe(observer); |
471 | * @param observer | 478 | } |
472 | * @param <T> | 479 | |
473 | */ | 480 | } |
474 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 481 |