Commit 8f79866a79a9fca7a458cab7406d755edbfe2004
1 parent
d454c09d63
Exists in
master
录入作业dialog
Showing
15 changed files
with
627 additions
and
48 deletions
Show diff stats
app/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | apply from: '../config.gradle' | 2 | apply from: '../config.gradle' |
3 | 3 | ||
4 | 4 | ||
5 | def androidId = rootProject.ext.androidId | 5 | def androidId = rootProject.ext.androidId |
6 | def support = rootProject.ext.dependencies | 6 | def support = rootProject.ext.dependencies |
7 | def url = rootProject.ext.url | 7 | def url = rootProject.ext.url |
8 | 8 | ||
9 | 9 | ||
10 | android { | 10 | android { |
11 | signingConfigs { | 11 | signingConfigs { |
12 | 12 | ||
13 | config { | 13 | config { |
14 | keyAlias 'alias' | 14 | keyAlias 'alias' |
15 | keyPassword '123456' | 15 | keyPassword '123456' |
16 | storeFile file('key.jks') | 16 | storeFile file('key.jks') |
17 | storePassword '123456' | 17 | storePassword '123456' |
18 | } | 18 | } |
19 | debug { | 19 | debug { |
20 | } | 20 | } |
21 | } | 21 | } |
22 | compileSdk 32 | 22 | compileSdk 32 |
23 | 23 | ||
24 | defaultConfig { | 24 | defaultConfig { |
25 | applicationId "com.hjx.parent" | 25 | applicationId "com.hjx.parent" |
26 | minSdk 24 | 26 | minSdk 24 |
27 | targetSdk 32 | 27 | targetSdk 32 |
28 | versionCode 1005 | 28 | versionCode 1005 |
29 | versionName "1.0.0.5" | 29 | versionName "1.0.0.5" |
30 | 30 | ||
31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
32 | } | 32 | } |
33 | 33 | ||
34 | android.applicationVariants.all { | 34 | android.applicationVariants.all { |
35 | variant -> | 35 | variant -> |
36 | variant.outputs.all { | 36 | variant.outputs.all { |
37 | //在这里修改apk文件名 | 37 | //在这里修改apk文件名 |
38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
39 | } | 39 | } |
40 | } | 40 | } |
41 | buildTypes { | 41 | buildTypes { |
42 | debug { | 42 | debug { |
43 | debuggable true | 43 | debuggable true |
44 | minifyEnabled false | 44 | minifyEnabled false |
45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
46 | signingConfig signingConfigs.config | 46 | signingConfig signingConfigs.config |
47 | } | 47 | } |
48 | release { | 48 | release { |
49 | debuggable true | 49 | debuggable true |
50 | minifyEnabled false | 50 | minifyEnabled false |
51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
52 | signingConfig signingConfigs.config | 52 | signingConfig signingConfigs.config |
53 | } | 53 | } |
54 | } | 54 | } |
55 | lintOptions { | 55 | lintOptions { |
56 | checkReleaseBuilds false | 56 | checkReleaseBuilds false |
57 | abortOnError false | 57 | abortOnError false |
58 | } | 58 | } |
59 | buildFeatures { | 59 | buildFeatures { |
60 | viewBinding true | 60 | viewBinding true |
61 | } | 61 | } |
62 | compileOptions { | 62 | compileOptions { |
63 | sourceCompatibility JavaVersion.VERSION_1_8 | 63 | sourceCompatibility JavaVersion.VERSION_1_8 |
64 | targetCompatibility JavaVersion.VERSION_1_8 | 64 | targetCompatibility JavaVersion.VERSION_1_8 |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | dependencies { | 68 | dependencies { |
69 | support.each { k, v -> implementation v } | 69 | support.each { k, v -> implementation v } |
70 | api project(path: ':libs:common') | 70 | api project(path: ':libs:common') |
71 | implementation 'androidx.appcompat:appcompat:1.5.1' | 71 | implementation 'androidx.appcompat:appcompat:1.5.1' |
72 | implementation 'com.google.android.material:material:1.6.1' | 72 | implementation 'com.google.android.material:material:1.6.1' |
73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
77 | //使用的三方 | 77 | //使用的三方 |
78 | implementation 'com.yalantis:ucrop:2.2.0' | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
81 | 81 | ||
82 | // rx | 82 | // rx |
83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | 83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") |
84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | 84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") |
85 | |||
86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") | ||
87 | implementation("com.contrarywind:Android-PickerView:4.1.9") | ||
85 | } | 88 | } |
app/src/main/java/com/hjx/parent/ImageActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | ||
3 | import android.app.Dialog; | 4 | import android.app.Dialog; |
4 | import android.content.Intent; | 5 | import android.content.Intent; |
5 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
6 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
7 | import android.graphics.Rect; | 8 | import android.graphics.Rect; |
8 | import android.net.Uri; | 9 | import android.net.Uri; |
9 | import android.os.Bundle; | 10 | import android.os.Bundle; |
10 | import android.os.Handler; | 11 | import android.os.Handler; |
11 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
12 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
13 | import android.util.Log; | 14 | import android.util.Log; |
14 | import android.view.KeyEvent; | 15 | import android.view.KeyEvent; |
15 | import android.view.View; | 16 | import android.view.View; |
16 | 17 | ||
17 | 18 | ||
18 | import androidx.annotation.Nullable; | 19 | import androidx.annotation.Nullable; |
19 | import androidx.core.content.FileProvider; | 20 | import androidx.core.content.FileProvider; |
20 | import androidx.viewpager2.widget.ViewPager2; | 21 | import androidx.viewpager2.widget.ViewPager2; |
21 | 22 | ||
22 | import com.google.gson.Gson; | 23 | import com.google.gson.Gson; |
23 | import com.google.gson.JsonObject; | 24 | import com.google.gson.JsonObject; |
24 | import com.hjx.parent.adapter.ImageAdapter; | 25 | import com.hjx.parent.adapter.ImageAdapter; |
25 | import com.hjx.parent.databinding.ActivityImageBinding; | 26 | import com.hjx.parent.databinding.ActivityImageBinding; |
27 | import com.hjx.parent.dialog.AddHomeworkDialog; | ||
26 | import com.hjx.parent.dialog.ErrorInputDialog; | 28 | import com.hjx.parent.dialog.ErrorInputDialog; |
27 | import com.hjx.parent.dialog.TipDialog; | 29 | import com.hjx.parent.dialog.TipDialog; |
30 | import com.hjx.parent.rx.BaseRxActivity; | ||
28 | import com.prws.common.bean.CutPicBean; | 31 | import com.prws.common.bean.CutPicBean; |
29 | import com.prws.common.bean.ImageBean; | 32 | import com.prws.common.bean.ImageBean; |
30 | import com.prws.common.bean.TopicBean; | 33 | import com.prws.common.bean.TopicBean; |
31 | import com.prws.common.net.NetWorks; | 34 | import com.prws.common.net.NetWorks; |
32 | import com.prws.common.utils.BitmapUtils; | 35 | import com.prws.common.utils.BitmapUtils; |
33 | import com.prws.common.utils.CommonUtil; | 36 | import com.prws.common.utils.CommonUtil; |
34 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; | 37 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; |
35 | 38 | ||
36 | import java.io.File; | 39 | import java.io.File; |
37 | import java.util.ArrayList; | 40 | import java.util.ArrayList; |
38 | import java.util.List; | 41 | import java.util.List; |
39 | 42 | ||
40 | import io.reactivex.Observer; | 43 | import io.reactivex.Observer; |
41 | import io.reactivex.disposables.Disposable; | 44 | import io.reactivex.disposables.Disposable; |
42 | import retrofit2.Call; | 45 | import retrofit2.Call; |
43 | import retrofit2.Callback; | 46 | import retrofit2.Callback; |
44 | import retrofit2.Response; | 47 | import retrofit2.Response; |
45 | 48 | ||
46 | public class ImageActivity extends BaseActivity<ActivityImageBinding> implements View.OnClickListener { | 49 | public class ImageActivity extends BaseRxActivity<ActivityImageBinding> implements View.OnClickListener { |
47 | 50 | ||
48 | private List<String> images = new ArrayList<>(); | 51 | private List<String> images = new ArrayList<>(); |
49 | private ImageAdapter imageAdapter; | 52 | private ImageAdapter imageAdapter; |
50 | private List<ImageBean> list = new ArrayList<>(); | 53 | private List<ImageBean> list = new ArrayList<>(); |
51 | private String filePath; | 54 | private String filePath; |
52 | 55 | ||
56 | private int type = 0; | ||
57 | private AddHomeworkDialog addHomeworkDialog; | ||
58 | |||
53 | @Override | 59 | @Override |
54 | public void initView(Bundle savedInstanceState) { | 60 | public void initView(Bundle savedInstanceState) { |
61 | type = getIntent().getIntExtra("type", 0); | ||
62 | binding.tvSave.setText(type == 0 ? "保存错题" : "录入题目"); | ||
63 | |||
55 | images = getIntent().getStringArrayListExtra("images"); | 64 | images = getIntent().getStringArrayListExtra("images"); |
56 | for (String s : images) { | 65 | for (String s : images) { |
57 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 66 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
58 | ImageBean imageBean = new ImageBean(); | 67 | ImageBean imageBean = new ImageBean(); |
59 | Bitmap bitmap = BitmapUtils.getimage(s); | 68 | Bitmap bitmap = BitmapUtils.getimage(s); |
60 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 69 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
61 | imageBean.setPath(filepath); | 70 | imageBean.setPath(filepath); |
62 | list.add(imageBean); | 71 | list.add(imageBean); |
63 | } | 72 | } |
64 | imageAdapter = new ImageAdapter(this, list); | 73 | imageAdapter = new ImageAdapter(this, list); |
65 | binding.viewPager.setAdapter(imageAdapter); | 74 | binding.viewPager.setAdapter(imageAdapter); |
66 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 75 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
67 | @Override | 76 | @Override |
68 | public void onPageSelected(int position) { | 77 | public void onPageSelected(int position) { |
69 | if (list.get(position).getCuts() == null) { | 78 | if (list.get(position).getCuts() == null) { |
70 | // binding.ivPrevious.setEnabled(false); | 79 | // binding.ivPrevious.setEnabled(false); |
71 | // binding.ivNext.setEnabled(false); | 80 | // binding.ivNext.setEnabled(false); |
72 | clearText(); | 81 | clearText(); |
73 | } | 82 | } |
74 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 83 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
75 | if (position == 0) { | 84 | if (position == 0) { |
76 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); | 85 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); |
77 | // binding.ivPrevious.setEnabled(true); | 86 | // binding.ivPrevious.setEnabled(true); |
78 | } else { | 87 | } else { |
79 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); | 88 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); |
80 | // binding.ivPrevious.setEnabled(false); | 89 | // binding.ivPrevious.setEnabled(false); |
81 | } | 90 | } |
82 | if (position == list.size() - 1) { | 91 | if (position == list.size() - 1) { |
83 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); | 92 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); |
84 | // binding.ivNext.setEnabled(true); | 93 | // binding.ivNext.setEnabled(true); |
85 | } else { | 94 | } else { |
86 | binding.ivNext.setImageResource(R.mipmap.ic_next); | 95 | binding.ivNext.setImageResource(R.mipmap.ic_next); |
87 | // binding.ivNext.setEnabled(false); | 96 | // binding.ivNext.setEnabled(false); |
88 | } | 97 | } |
89 | super.onPageSelected(position); | 98 | super.onPageSelected(position); |
90 | } | 99 | } |
91 | }); | 100 | }); |
92 | binding.ivNext.setOnClickListener(this); | 101 | binding.ivNext.setOnClickListener(this); |
93 | binding.ivPrevious.setOnClickListener(this); | 102 | binding.ivPrevious.setOnClickListener(this); |
94 | binding.ivBack.setOnClickListener(this); | 103 | binding.ivBack.setOnClickListener(this); |
95 | binding.tvPhoto.setOnClickListener(this); | 104 | binding.tvPhoto.setOnClickListener(this); |
96 | binding.tvAdd.setOnClickListener(this); | 105 | binding.tvAdd.setOnClickListener(this); |
97 | binding.llEdit.setOnClickListener(this); | 106 | binding.llEdit.setOnClickListener(this); |
98 | binding.tvSave.setOnClickListener(this); | 107 | binding.tvSave.setOnClickListener(this); |
99 | } | 108 | } |
100 | 109 | ||
101 | public void clearText() { | 110 | public void clearText() { |
102 | int index = binding.viewPager.getCurrentItem(); | 111 | int index = binding.viewPager.getCurrentItem(); |
103 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { | 112 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { |
104 | @Override | 113 | @Override |
105 | public void dimiss() { | 114 | public void dimiss() { |
106 | // binding.ivPrevious.setEnabled(index != 0); | 115 | // binding.ivPrevious.setEnabled(index != 0); |
107 | // binding.ivNext.setEnabled(index != list.size() - 1); | 116 | // binding.ivNext.setEnabled(index != list.size() - 1); |
108 | } | 117 | } |
109 | }); | 118 | }); |
110 | Log.i("clearText", list.get(index).getPath()); | 119 | Log.i("clearText", list.get(index).getPath()); |
111 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); | 120 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); |
112 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { | 121 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { |
113 | @Override | 122 | @Override |
114 | public void onSubscribe(Disposable d) { | 123 | public void onSubscribe(Disposable d) { |
115 | 124 | ||
116 | } | 125 | } |
117 | 126 | ||
118 | @Override | 127 | @Override |
119 | public void onNext(JsonObject jsonObject) { | 128 | public void onNext(JsonObject jsonObject) { |
120 | if (jsonObject != null && jsonObject.get("image_processed") != null) { | 129 | if (jsonObject != null && jsonObject.get("image_processed") != null) { |
121 | String image = jsonObject.get("image_processed").getAsString(); | 130 | String image = jsonObject.get("image_processed").getAsString(); |
122 | if (image != null) { | 131 | if (image != null) { |
123 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 132 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
124 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); | 133 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); |
125 | list.get(index).setPath(filepath); | 134 | list.get(index).setPath(filepath); |
126 | imageAdapter.notifyItemChanged(index); | 135 | imageAdapter.notifyItemChanged(index); |
127 | cut(filepath); | 136 | cut(filepath); |
128 | } else { | 137 | } else { |
129 | loadFail("去除字迹失败"); | 138 | loadFail("去除字迹失败"); |
130 | } | 139 | } |
131 | } else { | 140 | } else { |
132 | loadFail("去除字迹失败"); | 141 | loadFail("去除字迹失败"); |
133 | } | 142 | } |
134 | } | 143 | } |
135 | 144 | ||
136 | @Override | 145 | @Override |
137 | public void onError(Throwable e) { | 146 | public void onError(Throwable e) { |
138 | loadFail("去除字迹失败"); | 147 | loadFail("去除字迹失败"); |
139 | } | 148 | } |
140 | 149 | ||
141 | @Override | 150 | @Override |
142 | public void onComplete() { | 151 | public void onComplete() { |
143 | 152 | ||
144 | } | 153 | } |
145 | }); | 154 | }); |
146 | } | 155 | } |
147 | 156 | ||
148 | public void cut(String path) { | 157 | public void cut(String path) { |
149 | String base64 = BitmapUtils.imageToBase64(path); | 158 | String base64 = BitmapUtils.imageToBase64(path); |
150 | Log.i("figLoaction", path); | 159 | Log.i("figLoaction", path); |
151 | NetWorks.cut(base64, new Observer<CutPicBean>() { | 160 | NetWorks.cut(base64, new Observer<CutPicBean>() { |
152 | @Override | 161 | @Override |
153 | public void onSubscribe(Disposable d) { | 162 | public void onSubscribe(Disposable d) { |
154 | 163 | ||
155 | } | 164 | } |
156 | 165 | ||
157 | @Override | 166 | @Override |
158 | public void onNext(CutPicBean cutPicBean) { | 167 | public void onNext(CutPicBean cutPicBean) { |
159 | if (cutPicBean != null) { | 168 | if (cutPicBean != null) { |
160 | if (cutPicBean.getDirection() != 0) { | 169 | if (cutPicBean.getDirection() != 0) { |
161 | rotatingImage(cutPicBean); | 170 | rotatingImage(cutPicBean); |
162 | } else { | 171 | } else { |
163 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 172 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
164 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 173 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
165 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 174 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
166 | figLoactions.add(cutLocation.getFig_location()); | 175 | figLoactions.add(cutLocation.getFig_location()); |
167 | } | 176 | } |
168 | new Handler().postDelayed(new Runnable() { | 177 | new Handler().postDelayed(new Runnable() { |
169 | @Override | 178 | @Override |
170 | public void run() { | 179 | public void run() { |
171 | getRects(figLoactions); | 180 | getRects(figLoactions); |
172 | } | 181 | } |
173 | }, 1000); | 182 | }, 1000); |
174 | } else { | 183 | } else { |
175 | cancelLoadingDialog(); | 184 | cancelLoadingDialog(); |
176 | } | 185 | } |
177 | } | 186 | } |
178 | } else { | 187 | } else { |
179 | loadFail("自动切题失败"); | 188 | loadFail("自动切题失败"); |
180 | } | 189 | } |
181 | } | 190 | } |
182 | 191 | ||
183 | @Override | 192 | @Override |
184 | public void onError(Throwable e) { | 193 | public void onError(Throwable e) { |
185 | loadFail("自动切题失败"); | 194 | loadFail("自动切题失败"); |
186 | } | 195 | } |
187 | 196 | ||
188 | @Override | 197 | @Override |
189 | public void onComplete() { | 198 | public void onComplete() { |
190 | 199 | ||
191 | } | 200 | } |
192 | }); | 201 | }); |
193 | } | 202 | } |
194 | 203 | ||
195 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { | 204 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { |
196 | Log.i("figLoaction", new Gson().toJson(figLoactions)); | 205 | Log.i("figLoaction", new Gson().toJson(figLoactions)); |
197 | int index = binding.viewPager.getCurrentItem(); | 206 | int index = binding.viewPager.getCurrentItem(); |
198 | List<ImageBean.Cut> cuts = new ArrayList<>(); | 207 | List<ImageBean.Cut> cuts = new ArrayList<>(); |
199 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { | 208 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { |
200 | ImageBean.Cut cut = new ImageBean.Cut(); | 209 | ImageBean.Cut cut = new ImageBean.Cut(); |
201 | cut.setRect(figLoaction); | 210 | cut.setRect(figLoaction); |
202 | cut.setSelect(false); | 211 | cut.setSelect(false); |
203 | cuts.add(cut); | 212 | cuts.add(cut); |
204 | } | 213 | } |
205 | list.get(index).setCuts(cuts); | 214 | list.get(index).setCuts(cuts); |
206 | imageAdapter.notifyItemChanged(index); | 215 | imageAdapter.notifyItemChanged(index); |
207 | cancelLoadingDialog(); | 216 | cancelLoadingDialog(); |
208 | } | 217 | } |
209 | 218 | ||
210 | private void rotatingImage(CutPicBean cutPicBean) { | 219 | private void rotatingImage(CutPicBean cutPicBean) { |
211 | int index = binding.viewPager.getCurrentItem(); | 220 | int index = binding.viewPager.getCurrentItem(); |
212 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); | 221 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); |
213 | int angle = 0; | 222 | int angle = 0; |
214 | switch (cutPicBean.getDirection()) { | 223 | switch (cutPicBean.getDirection()) { |
215 | case 1: | 224 | case 1: |
216 | angle = 90; | 225 | angle = 90; |
217 | break; | 226 | break; |
218 | case 2: | 227 | case 2: |
219 | angle = 180; | 228 | angle = 180; |
220 | break; | 229 | break; |
221 | case 3: | 230 | case 3: |
222 | angle = 270; | 231 | angle = 270; |
223 | break; | 232 | break; |
224 | } | 233 | } |
225 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 234 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
226 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 235 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
227 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 236 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
228 | figLoactions.add(cutLocation.getFig_location()); | 237 | figLoactions.add(cutLocation.getFig_location()); |
229 | } | 238 | } |
230 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); | 239 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); |
231 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); | 240 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); |
232 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 241 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
233 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 242 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
234 | list.get(index).setPath(filepath); | 243 | list.get(index).setPath(filepath); |
235 | imageAdapter.notifyItemChanged(index); | 244 | imageAdapter.notifyItemChanged(index); |
236 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; | 245 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; |
237 | new Handler().postDelayed(new Runnable() { | 246 | new Handler().postDelayed(new Runnable() { |
238 | @Override | 247 | @Override |
239 | public void run() { | 248 | public void run() { |
240 | getRects(finalFigLoactions); | 249 | getRects(finalFigLoactions); |
241 | } | 250 | } |
242 | }, 500); | 251 | }, 500); |
243 | } else { | 252 | } else { |
244 | cancelLoadingDialog(); | 253 | cancelLoadingDialog(); |
245 | } | 254 | } |
246 | } | 255 | } |
247 | 256 | ||
248 | @Override | 257 | @Override |
249 | protected ActivityImageBinding getViewBinding() { | 258 | protected ActivityImageBinding getViewBinding() { |
250 | return ActivityImageBinding.inflate(getLayoutInflater()); | 259 | return ActivityImageBinding.inflate(getLayoutInflater()); |
251 | } | 260 | } |
252 | 261 | ||
262 | @SuppressLint("SetTextI18n") | ||
253 | public void refreshNum() { | 263 | public void refreshNum() { |
254 | int num = 0; | 264 | int num = 0; |
255 | for (ImageBean imageBean : list) { | 265 | for (ImageBean imageBean : list) { |
256 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 266 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
257 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 267 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
258 | if (cut.isSelect()) { | 268 | if (cut.isSelect()) { |
259 | num++; | 269 | num++; |
260 | } | 270 | } |
261 | } | 271 | } |
262 | } | 272 | } |
263 | } | 273 | } |
274 | String btnText = type == 0 ? "保存错题" : "录入题目"; | ||
264 | if (num > 0) { | 275 | if (num > 0) { |
265 | binding.tvSave.setEnabled(true); | 276 | binding.tvSave.setEnabled(true); |
266 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); | 277 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); |
267 | binding.tvSave.setText("保存错题(" + num + ")"); | 278 | binding.tvSave.setText(btnText + "(" + num + ")"); |
268 | } else { | 279 | } else { |
269 | binding.tvSave.setEnabled(false); | 280 | binding.tvSave.setEnabled(false); |
270 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); | 281 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); |
271 | binding.tvSave.setText("保存错题"); | 282 | binding.tvSave.setText(btnText); |
272 | } | 283 | } |
273 | } | 284 | } |
274 | 285 | ||
275 | @Override | 286 | @Override |
276 | public void onClick(View v) { | 287 | public void onClick(View v) { |
277 | switch (v.getId()) { | 288 | switch (v.getId()) { |
278 | case R.id.iv_back: | 289 | case R.id.iv_back: |
279 | back(); | 290 | back(); |
280 | break; | 291 | break; |
281 | case R.id.iv_next: | 292 | case R.id.iv_next: |
282 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { | 293 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { |
283 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); | 294 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); |
284 | } | 295 | } |
285 | break; | 296 | break; |
286 | case R.id.iv_previous: | 297 | case R.id.iv_previous: |
287 | if (binding.viewPager.getCurrentItem() != 0) { | 298 | if (binding.viewPager.getCurrentItem() != 0) { |
288 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); | 299 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); |
289 | } | 300 | } |
290 | break; | 301 | break; |
291 | case R.id.ll_edit: | 302 | case R.id.ll_edit: |
292 | Intent intent = new Intent(context, ImageEditActivity.class); | 303 | Intent intent = new Intent(context, ImageEditActivity.class); |
293 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 304 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
294 | startActivityForResult(intent, 1001); | 305 | startActivityForResult(intent, 1001); |
295 | break; | 306 | break; |
296 | case R.id.tv_photo: | 307 | case R.id.tv_photo: |
297 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 308 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
298 | //确保有相机来处理Intent | 309 | //确保有相机来处理Intent |
299 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 310 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
300 | File photoFile = new File(filePath); | 311 | File photoFile = new File(filePath); |
301 | if (photoFile != null) { | 312 | if (photoFile != null) { |
302 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 313 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
303 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 314 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
304 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 315 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
305 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 316 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
306 | activity.startActivityForResult(takePictureIntent, 1002); | 317 | activity.startActivityForResult(takePictureIntent, 1002); |
307 | } | 318 | } |
308 | break; | 319 | break; |
309 | case R.id.tv_add: | 320 | case R.id.tv_add: |
310 | Intent intent1 = new Intent(context, ImageSelectActivity.class); | 321 | Intent intent1 = new Intent(context, ImageSelectActivity.class); |
311 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 322 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
312 | startActivityForResult(intent1, 1001); | 323 | startActivityForResult(intent1, 1001); |
313 | break; | 324 | break; |
314 | case R.id.tv_save: | 325 | case R.id.tv_save: |
315 | List<TopicBean> topicBeans = new ArrayList<>(); | 326 | List<TopicBean> topicBeans = new ArrayList<>(); |
316 | for (ImageBean imageBean : list) { | 327 | for (ImageBean imageBean : list) { |
317 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 328 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
318 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 329 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
319 | if (cut.isSelect()) { | 330 | if (cut.isSelect()) { |
320 | TopicBean bean = new TopicBean(); | 331 | TopicBean bean = new TopicBean(); |
321 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 332 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
322 | BitmapUtils.saveBitmap(cut.getBitmap(), path); | 333 | BitmapUtils.saveBitmap(cut.getBitmap(), path); |
323 | bean.setPath(path); | 334 | bean.setPath(path); |
324 | topicBeans.add(bean); | 335 | topicBeans.add(bean); |
325 | } | 336 | } |
326 | } | 337 | } |
327 | } | 338 | } |
328 | } | 339 | } |
329 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); | 340 | save(topicBeans); |
330 | dialog.show(); | ||
331 | break; | 341 | break; |
332 | } | 342 | } |
333 | } | 343 | } |
334 | 344 | ||
345 | private void save(List<TopicBean> topicBeans) { | ||
346 | if (type == 0) { | ||
347 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); | ||
348 | dialog.show(); | ||
349 | } else { | ||
350 | if (addHomeworkDialog == null) { | ||
351 | addHomeworkDialog = new AddHomeworkDialog(this); | ||
352 | } | ||
353 | addHomeworkDialog.show(); | ||
354 | } | ||
355 | } | ||
356 | |||
335 | @Override | 357 | @Override |
336 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 358 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
337 | super.onActivityResult(requestCode, resultCode, data); | 359 | super.onActivityResult(requestCode, resultCode, data); |
338 | if (requestCode == 1001) { | 360 | if (requestCode == 1001) { |
339 | if (resultCode == 1002) { | 361 | if (resultCode == 1002) { |
340 | if (list.size() > 1) { | 362 | if (list.size() > 1) { |
341 | list.remove(binding.viewPager.getCurrentItem()); | 363 | list.remove(binding.viewPager.getCurrentItem()); |
342 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); | 364 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); |
343 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 365 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
344 | refreshNum(); | 366 | refreshNum(); |
345 | } else { | 367 | } else { |
346 | finish(); | 368 | finish(); |
347 | } | 369 | } |
348 | } else if (resultCode == 1003) { | 370 | } else if (resultCode == 1003) { |
349 | int position = binding.viewPager.getCurrentItem(); | 371 | int position = binding.viewPager.getCurrentItem(); |
350 | list.remove(position); | 372 | list.remove(position); |
351 | String path = data.getStringExtra("path"); | 373 | String path = data.getStringExtra("path"); |
352 | ImageBean imageBean = new ImageBean(); | 374 | ImageBean imageBean = new ImageBean(); |
353 | imageBean.setPath(path); | 375 | imageBean.setPath(path); |
354 | list.add(position, imageBean); | 376 | list.add(position, imageBean); |
355 | imageAdapter.notifyItemChanged(position); | 377 | imageAdapter.notifyItemChanged(position); |
356 | clearText(); | 378 | clearText(); |
357 | refreshNum(); | 379 | refreshNum(); |
358 | } else if (resultCode == 1004) { | 380 | } else if (resultCode == 1004) { |
359 | Rect rect = data.getParcelableExtra("cut"); | 381 | Rect rect = data.getParcelableExtra("cut"); |
360 | if (rect != null) { | 382 | if (rect != null) { |
361 | int position = binding.viewPager.getCurrentItem(); | 383 | int position = binding.viewPager.getCurrentItem(); |
362 | ImageBean.Cut cut = new ImageBean.Cut(); | 384 | ImageBean.Cut cut = new ImageBean.Cut(); |
363 | cut.setRect1(rect); | 385 | cut.setRect1(rect); |
364 | cut.setSelect(false); | 386 | cut.setSelect(false); |
365 | if (list.get(position).getCuts() != null) { | 387 | if (list.get(position).getCuts() != null) { |
366 | list.get(position).getCuts().add(cut); | 388 | list.get(position).getCuts().add(cut); |
367 | } else { | 389 | } else { |
368 | List<ImageBean.Cut> cuts =new ArrayList<>(); | 390 | List<ImageBean.Cut> cuts =new ArrayList<>(); |
369 | cuts.add(cut); | 391 | cuts.add(cut); |
370 | list.get(position).setCuts(cuts); | 392 | list.get(position).setCuts(cuts); |
371 | } | 393 | } |
372 | imageAdapter.notifyItemChanged(position); | 394 | imageAdapter.notifyItemChanged(position); |
373 | refreshNum(); | 395 | refreshNum(); |
374 | } | 396 | } |
375 | } else if (resultCode == 1005) { | 397 | } else if (resultCode == 1005) { |
376 | int i = data.getIntExtra("position", 0); | 398 | int i = data.getIntExtra("position", 0); |
377 | int position = binding.viewPager.getCurrentItem(); | 399 | int position = binding.viewPager.getCurrentItem(); |
378 | Rect rect = data.getParcelableExtra("cut"); | 400 | Rect rect = data.getParcelableExtra("cut"); |
379 | if (rect != null) { | 401 | if (rect != null) { |
380 | ImageBean.Cut cut = new ImageBean.Cut(); | 402 | ImageBean.Cut cut = new ImageBean.Cut(); |
381 | cut.setRect1(rect); | 403 | cut.setRect1(rect); |
382 | cut.setSelect(false); | 404 | cut.setSelect(false); |
383 | list.get(position).getCuts().remove(i); | 405 | list.get(position).getCuts().remove(i); |
384 | list.get(position).getCuts().add(i, cut); | 406 | list.get(position).getCuts().add(i, cut); |
385 | imageAdapter.notifyItemChanged(position); | 407 | imageAdapter.notifyItemChanged(position); |
386 | refreshNum(); | 408 | refreshNum(); |
387 | } else { | 409 | } else { |
388 | list.get(position).getCuts().remove(i); | 410 | list.get(position).getCuts().remove(i); |
389 | imageAdapter.notifyItemChanged(position); | 411 | imageAdapter.notifyItemChanged(position); |
390 | refreshNum(); | 412 | refreshNum(); |
391 | } | 413 | } |
392 | } | 414 | } |
393 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 415 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
394 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 416 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
395 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 417 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
396 | CommonUtil.saveBitmapToUri(b, path); | 418 | CommonUtil.saveBitmapToUri(b, path); |
397 | int position = binding.viewPager.getCurrentItem(); | 419 | int position = binding.viewPager.getCurrentItem(); |
398 | list.remove(position); | 420 | list.remove(position); |
399 | ImageBean imageBean = new ImageBean(); | 421 | ImageBean imageBean = new ImageBean(); |
400 | imageBean.setPath(path); | 422 | imageBean.setPath(path); |
401 | list.add(position, imageBean); | 423 | list.add(position, imageBean); |
402 | imageAdapter.notifyItemChanged(position); | 424 | imageAdapter.notifyItemChanged(position); |
403 | clearText(); | 425 | clearText(); |
404 | refreshNum(); | 426 | refreshNum(); |
405 | } | 427 | } |
406 | } | 428 | } |
407 | 429 | ||
408 | private void back() { | 430 | private void back() { |
409 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { | 431 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { |
410 | @Override | 432 | @Override |
411 | public void onConfirm(Dialog dialog) { | 433 | public void onConfirm(Dialog dialog) { |
412 | dialog.dismiss(); | 434 | dialog.dismiss(); |
413 | finish(); | 435 | finish(); |
414 | } | 436 | } |
415 | 437 | ||
416 | @Override | 438 | @Override |
417 | public void onCancel(Dialog dialog) { | 439 | public void onCancel(Dialog dialog) { |
418 | dialog.dismiss(); | 440 | dialog.dismiss(); |
419 | } | 441 | } |
420 | }); | 442 | }); |
421 | } | 443 | } |
422 | 444 | ||
423 | @Override | 445 | @Override |
424 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 446 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
425 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 447 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
426 | back(); | 448 | back(); |
427 | return true; | 449 | return true; |
428 | } | 450 | } |
429 | return super.onKeyDown(keyCode, event); | 451 | return super.onKeyDown(keyCode, event); |
430 | } | 452 | } |
431 | } | 453 | } |
app/src/main/java/com/hjx/parent/dialog/AddHomeworkDialog.java
File was created | 1 | package com.hjx.parent.dialog; | |
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.content.Context; | ||
5 | import android.view.View; | ||
6 | import android.widget.AdapterView; | ||
7 | import android.widget.ArrayAdapter; | ||
8 | |||
9 | import androidx.annotation.NonNull; | ||
10 | |||
11 | import com.bigkoo.pickerview.builder.TimePickerBuilder; | ||
12 | import com.bigkoo.pickerview.listener.OnTimeSelectListener; | ||
13 | import com.bigkoo.pickerview.view.TimePickerView; | ||
14 | import com.google.gson.Gson; | ||
15 | import com.hjx.parent.R; | ||
16 | import com.hjx.parent.bean.StudentBean; | ||
17 | import com.hjx.parent.databinding.DialogAddHomeworkBinding; | ||
18 | import com.hjx.parent.rx.ILifecycleActivity; | ||
19 | import com.prws.common.bean.GradeAndSubject; | ||
20 | import com.prws.common.bean.ResponseResult; | ||
21 | import com.prws.common.bean.Student; | ||
22 | import com.prws.common.bean.Subject; | ||
23 | import com.prws.common.net.NetWorks; | ||
24 | import com.prws.common.utils.SharedPreferencesUtil; | ||
25 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | ||
26 | |||
27 | import java.text.SimpleDateFormat; | ||
28 | import java.util.ArrayList; | ||
29 | import java.util.Date; | ||
30 | import java.util.List; | ||
31 | import java.util.Locale; | ||
32 | |||
33 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
34 | import io.reactivex.schedulers.Schedulers; | ||
35 | |||
36 | public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ | ||
37 | private final ILifecycleActivity activity; | ||
38 | |||
39 | String stuId; | ||
40 | |||
41 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA); | ||
42 | List<Student> studentList; | ||
43 | List<GradeAndSubject> gradeAndSubjectList; | ||
44 | |||
45 | Student student; | ||
46 | String grade; | ||
47 | String term; | ||
48 | String subject; | ||
49 | Date uploadTime = new Date(); | ||
50 | |||
51 | public AddHomeworkDialog(ILifecycleActivity context) { | ||
52 | super((Context) context); | ||
53 | activity = context; | ||
54 | } | ||
55 | |||
56 | @SuppressLint("SetTextI18n") | ||
57 | @Override | ||
58 | public void initView() { | ||
59 | binding.btnClose.setOnClickListener(v -> dismiss()); | ||
60 | stuId = getCurrentStuId(); | ||
61 | binding.spStudent.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
62 | @Override | ||
63 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
64 | student = studentList.get(position); | ||
65 | if (gradeAndSubjectList == null) return; | ||
66 | int p = 0; | ||
67 | for (GradeAndSubject it: gradeAndSubjectList) { | ||
68 | if (it.getGrade().getGrade().equals(student.grade)) { | ||
69 | p = gradeAndSubjectList.indexOf(it); | ||
70 | break; | ||
71 | } | ||
72 | } | ||
73 | binding.spGrade.setSelection(p); | ||
74 | } | ||
75 | |||
76 | @Override | ||
77 | public void onNothingSelected(AdapterView<?> parent) { | ||
78 | } | ||
79 | }); | ||
80 | binding.spTerm.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
81 | @Override | ||
82 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
83 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; | ||
84 | } | ||
85 | @Override | ||
86 | public void onNothingSelected(AdapterView<?> parent) { | ||
87 | } | ||
88 | }); | ||
89 | binding.spGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
90 | @Override | ||
91 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
92 | grade = gradeAndSubjectList.get(position).getGrade().getGrade(); | ||
93 | refreshSubjects(position); | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public void onNothingSelected(AdapterView<?> parent) { | ||
98 | } | ||
99 | }); | ||
100 | |||
101 | binding.tvDate.setText(dateFormat.format(uploadTime)); | ||
102 | binding.tvDate.setOnClickListener(v -> { | ||
103 | new TimePickerBuilder(getContext(), (date, v1) -> { | ||
104 | uploadTime = date; | ||
105 | binding.tvDate.setText(dateFormat.format(uploadTime)); | ||
106 | binding.etName.setText(dateFormat.format(uploadTime) + subject + "作业"); | ||
107 | }).setType(new boolean[]{true, true, true, false, false, false}).isDialog(true).build().show(); | ||
108 | }); | ||
109 | |||
110 | getGrade(); | ||
111 | } | ||
112 | |||
113 | private String getCurrentStuId() { | ||
114 | String student = (String) SharedPreferencesUtil.getData("student", ""); | ||
115 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); | ||
116 | return studentBean.getStuId(); | ||
117 | } | ||
118 | |||
119 | @SuppressLint("CheckResult") | ||
120 | private void getStudents() { | ||
121 | NetWorks.listStudent() | ||
122 | .subscribeOn(Schedulers.io()) | ||
123 | .observeOn(AndroidSchedulers.mainThread()) | ||
124 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) | ||
125 | .map(ResponseResult::getData) | ||
126 | .subscribe((data, th) -> { | ||
127 | if (th != null) th.printStackTrace(); | ||
128 | if (data != null && data.size() > 0) { | ||
129 | studentList = data; | ||
130 | int position = 0; | ||
131 | for (int i = 0; i < data.size(); i++) { | ||
132 | if (data.get(i).stuId.equals(stuId)) { | ||
133 | position = i; | ||
134 | break; | ||
135 | } | ||
136 | } | ||
137 | binding.spStudent.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, data)); | ||
138 | binding.spStudent.setSelection(position); | ||
139 | } | ||
140 | }); | ||
141 | } | ||
142 | |||
143 | @SuppressLint("CheckResult") | ||
144 | private void getGrade() { | ||
145 | NetWorks.service_url.listGradeAndSubject(NetWorks.getHeader()) | ||
146 | .subscribeOn(Schedulers.io()) | ||
147 | .observeOn(AndroidSchedulers.mainThread()) | ||
148 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) | ||
149 | .map(ResponseResult::getData) | ||
150 | .firstOrError() | ||
151 | .subscribe((data, th) -> { | ||
152 | if (th != null) th.printStackTrace(); | ||
153 | if (data != null && data.size() > 0) { | ||
154 | gradeAndSubjectList = data; | ||
155 | List<String> grades = new ArrayList<>(); | ||
156 | for (GradeAndSubject it: data) { | ||
157 | grades.add(it.getGrade().getGrade()); | ||
158 | } | ||
159 | binding.spGrade.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, grades)); | ||
160 | } | ||
161 | getStudents(); | ||
162 | }); | ||
163 | } | ||
164 | |||
165 | private void refreshSubjects(int gradePosition) { | ||
166 | if (gradeAndSubjectList == null) return; | ||
167 | List<Subject> subjectList = gradeAndSubjectList.get(gradePosition).getSubjects(); | ||
168 | List<String> subjects = new ArrayList<>(); | ||
169 | for (Subject s: subjectList) { | ||
170 | subjects.add(s.getSubject()); | ||
171 | } | ||
172 | binding.spSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
173 | @SuppressLint("SetTextI18n") | ||
174 | @Override | ||
175 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
176 | subject = subjects.get(position); | ||
177 | binding.etName.setText(dateFormat.format(uploadTime) + subject + "作业"); | ||
178 | } | ||
179 | @Override | ||
180 | public void onNothingSelected(AdapterView<?> parent) { | ||
181 | } | ||
182 | }); | ||
183 | binding.spSubject.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, subjects)); | ||
184 | } | ||
185 | |||
186 | @NonNull | ||
187 | @Override | ||
188 | public DialogAddHomeworkBinding getBinding() { | ||
189 | return DialogAddHomeworkBinding.inflate(getLayoutInflater()); | ||
190 | } | ||
191 | } | ||
192 |
app/src/main/java/com/hjx/parent/dialog/BaseDialog.java
File was created | 1 | package com.hjx.parent.dialog; | |
2 | |||
3 | import android.app.AlertDialog; | ||
4 | import android.content.Context; | ||
5 | import android.os.Bundle; | ||
6 | import android.view.ViewGroup; | ||
7 | import android.view.Window; | ||
8 | import android.view.WindowManager; | ||
9 | |||
10 | import androidx.annotation.NonNull; | ||
11 | import androidx.viewbinding.ViewBinding; | ||
12 | |||
13 | import com.hjx.parent.R; | ||
14 | |||
15 | |||
16 | public abstract class BaseDialog<VB extends ViewBinding> extends AlertDialog { | ||
17 | |||
18 | public BaseDialog(Context context) { | ||
19 | this(context, R.style.BaseDialog); | ||
20 | } | ||
21 | |||
22 | public BaseDialog(Context context, int themeResId) { | ||
23 | super(context, themeResId); | ||
24 | } | ||
25 | |||
26 | public VB binding; | ||
27 | private boolean isDialogCreated = false; | ||
28 | public boolean isDialogCreated() { | ||
29 | return isDialogCreated; | ||
30 | } | ||
31 | |||
32 | public void onCreate(Bundle savedInstanceState) { | ||
33 | super.onCreate(savedInstanceState); | ||
34 | binding = getBinding(); | ||
35 | setContentView(binding.getRoot()); | ||
36 | Window window = getWindow(); | ||
37 | if (window != null) { | ||
38 | setWindowsLayout(window); | ||
39 | window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); | ||
40 | } | ||
41 | |||
42 | initView(); | ||
43 | isDialogCreated = true; | ||
44 | } | ||
45 | |||
46 | public void onAttachedToWindow() { | ||
47 | super.onAttachedToWindow(); | ||
48 | onDialogStart(); | ||
49 | } | ||
50 | |||
51 | public void onDetachedFromWindow() { | ||
52 | super.onDetachedFromWindow(); | ||
53 | onDialogStop(); | ||
54 | } | ||
55 | |||
56 | public void setWindowsLayout(Window window) { | ||
57 | window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); | ||
58 | } | ||
59 | |||
60 | public void initView() { | ||
61 | } | ||
62 | |||
63 | public void onDialogStart() { | ||
64 | } | ||
65 | |||
66 | public void onDialogStop() { | ||
67 | } | ||
68 | |||
69 | @NonNull | ||
70 | public abstract VB getBinding(); | ||
71 | |||
72 | } | ||
73 |
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import static android.app.Activity.RESULT_OK; | 3 | import static android.app.Activity.RESULT_OK; |
4 | 4 | ||
5 | import android.annotation.SuppressLint; | 5 | import android.annotation.SuppressLint; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
8 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
9 | import android.net.Uri; | 9 | import android.net.Uri; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
13 | import android.util.Log; | 13 | import android.util.Log; |
14 | import android.view.LayoutInflater; | 14 | import android.view.LayoutInflater; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | import android.view.ViewGroup; | 16 | import android.view.ViewGroup; |
17 | import android.widget.Toast; | 17 | import android.widget.Toast; |
18 | 18 | ||
19 | import androidx.annotation.NonNull; | 19 | import androidx.annotation.NonNull; |
20 | import androidx.annotation.Nullable; | 20 | import androidx.annotation.Nullable; |
21 | import androidx.core.content.FileProvider; | 21 | import androidx.core.content.FileProvider; |
22 | import androidx.recyclerview.widget.RecyclerView; | 22 | import androidx.recyclerview.widget.RecyclerView; |
23 | 23 | ||
24 | import com.bumptech.glide.Glide; | 24 | import com.bumptech.glide.Glide; |
25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
26 | import com.bumptech.glide.request.RequestOptions; | 26 | import com.bumptech.glide.request.RequestOptions; |
27 | import com.chad.library.adapter.base.BaseQuickAdapter; | 27 | import com.chad.library.adapter.base.BaseQuickAdapter; |
28 | import com.chad.library.adapter.base.BaseViewHolder; | 28 | import com.chad.library.adapter.base.BaseViewHolder; |
29 | import com.google.android.material.tabs.TabLayout; | 29 | import com.google.android.material.tabs.TabLayout; |
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.ErrorListActivity; | 34 | import com.hjx.parent.ErrorListActivity; |
35 | import com.hjx.parent.ImageActivity; | 35 | import com.hjx.parent.ImageActivity; |
36 | import com.hjx.parent.R; | 36 | import com.hjx.parent.R; |
37 | import com.hjx.parent.TeacherChooseActivity; | 37 | import com.hjx.parent.TeacherChooseActivity; |
38 | import com.hjx.parent.adapter.ErrorAdapter; | 38 | import com.hjx.parent.adapter.ErrorAdapter; |
39 | import com.hjx.parent.adapter.HomeworkAdapter; | 39 | import com.hjx.parent.adapter.HomeworkAdapter; |
40 | import com.hjx.parent.bean.StudentBean; | 40 | import com.hjx.parent.bean.StudentBean; |
41 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 41 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
42 | import com.hjx.parent.rx.BaseRxFragment; | 42 | import com.hjx.parent.rx.BaseRxFragment; |
43 | import com.prws.common.bean.PageInfo; | 43 | import com.prws.common.bean.PageInfo; |
44 | import com.prws.common.bean.ResponseResult; | 44 | import com.prws.common.bean.ResponseResult; |
45 | import com.prws.common.bean.TopicBean; | 45 | import com.prws.common.bean.TopicBean; |
46 | import com.prws.common.net.NetWorks; | 46 | import com.prws.common.net.NetWorks; |
47 | import com.prws.common.utils.BitmapUtils; | 47 | import com.prws.common.utils.BitmapUtils; |
48 | import com.prws.common.utils.CommonUtil; | 48 | import com.prws.common.utils.CommonUtil; |
49 | import com.prws.common.utils.ScreenUtils; | 49 | import com.prws.common.utils.ScreenUtils; |
50 | import com.prws.common.utils.SharedPreferencesUtil; | 50 | import com.prws.common.utils.SharedPreferencesUtil; |
51 | import com.prws.common.utils.dialog.MyButtomDialog; | 51 | import com.prws.common.utils.dialog.MyButtomDialog; |
52 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 52 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
53 | import com.zhangteng.imagepicker.bean.ImageInfo; | 53 | import com.zhangteng.imagepicker.bean.ImageInfo; |
54 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 54 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
55 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 55 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
56 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 56 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
57 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 57 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
58 | import com.zhangteng.utils.IHandlerCallBack; | 58 | import com.zhangteng.utils.IHandlerCallBack; |
59 | 59 | ||
60 | import java.io.File; | 60 | import java.io.File; |
61 | import java.util.ArrayList; | 61 | import java.util.ArrayList; |
62 | import java.util.Arrays; | 62 | import java.util.Arrays; |
63 | import java.util.HashMap; | 63 | import java.util.HashMap; |
64 | import java.util.List; | 64 | import java.util.List; |
65 | import java.util.Map; | 65 | import java.util.Map; |
66 | 66 | ||
67 | import io.reactivex.Observer; | 67 | import io.reactivex.Observer; |
68 | import io.reactivex.android.schedulers.AndroidSchedulers; | 68 | import io.reactivex.android.schedulers.AndroidSchedulers; |
69 | import io.reactivex.disposables.Disposable; | 69 | import io.reactivex.disposables.Disposable; |
70 | import io.reactivex.schedulers.Schedulers; | 70 | import io.reactivex.schedulers.Schedulers; |
71 | 71 | ||
72 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 72 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
73 | StudentBean studentBean; | 73 | StudentBean studentBean; |
74 | private int subject; | 74 | private int subject; |
75 | private ErrorAdapter errorAdapter; | 75 | private ErrorAdapter errorAdapter; |
76 | private HomeworkAdapter homeworkAdapter; | 76 | private HomeworkAdapter homeworkAdapter; |
77 | private int REQUEST_CODE_IMAGE = 123; | ||
78 | private String filePath; | 77 | private String filePath; |
79 | 78 | ||
80 | @Override | 79 | @Override |
81 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 80 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
82 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 81 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
83 | } | 82 | } |
84 | 83 | ||
85 | public void refreshStudent() { | 84 | public void refreshStudent() { |
86 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 85 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
87 | try { | 86 | try { |
88 | studentBean = new Gson().fromJson(student, StudentBean.class); | 87 | studentBean = new Gson().fromJson(student, StudentBean.class); |
89 | getBinding().tvChoose.setText(studentBean.getStuName()); | 88 | getBinding().tvChoose.setText(studentBean.getStuName()); |
90 | } catch (Exception e) { | 89 | } catch (Exception e) { |
91 | e.printStackTrace(); | 90 | e.printStackTrace(); |
92 | } | 91 | } |
93 | } | 92 | } |
94 | 93 | ||
95 | @Override | 94 | @Override |
96 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 95 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
97 | super.onViewCreated(view, savedInstanceState); | 96 | super.onViewCreated(view, savedInstanceState); |
98 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 97 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
99 | if (!TextUtils.isEmpty(photo)) { | 98 | if (!TextUtils.isEmpty(photo)) { |
100 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 99 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
101 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 100 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
102 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 101 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
103 | } | 102 | } |
104 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 103 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
105 | getBinding().tvName.setText(name); | 104 | getBinding().tvName.setText(name); |
106 | refreshStudent(); | 105 | refreshStudent(); |
107 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 106 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
108 | getBinding().rlTakePhoto.setOnClickListener(v -> { | 107 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
109 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 108 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
110 | XXPermissions.with(getContext()) | ||
111 | // 申请多个权限 | ||
112 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | ||
113 | @Override | ||
114 | public void onGranted(List<String> permissions, boolean all) { | ||
115 | if (all) { | ||
116 | //开启扫码界面 | ||
117 | showButtonDialog(); | ||
118 | } else { | ||
119 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public void onDenied(List<String> permissions, boolean never) { | ||
125 | XXPermissions.startPermissionActivity(getContext(), permissions); | ||
126 | } | ||
127 | }); | ||
128 | } else { | ||
129 | showButtonDialog(); | ||
130 | } | ||
131 | |||
132 | }); | ||
133 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 109 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
134 | @Override | 110 | @Override |
135 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 111 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
136 | 112 | ||
137 | } | 113 | } |
138 | 114 | ||
139 | @Override | 115 | @Override |
140 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 116 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
141 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 117 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
142 | switch (item.getAdapterPosition()) { | 118 | switch (item.getAdapterPosition()) { |
143 | case 0: | 119 | case 0: |
144 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 120 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
145 | break; | 121 | break; |
146 | case 1: | 122 | case 1: |
147 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 123 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
148 | break; | 124 | break; |
149 | case 2: | 125 | case 2: |
150 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 126 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
151 | break; | 127 | break; |
152 | case 3: | 128 | case 3: |
153 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 129 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
154 | break; | 130 | break; |
155 | case 4: | 131 | case 4: |
156 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 132 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
157 | break; | 133 | break; |
158 | } | 134 | } |
159 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 135 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
160 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 136 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
161 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 137 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
162 | item.getConvertView().setOnClickListener(v -> { | 138 | item.getConvertView().setOnClickListener(v -> { |
163 | if (subject != item.getAdapterPosition()) { | 139 | if (subject != item.getAdapterPosition()) { |
164 | subject = item.getAdapterPosition(); | 140 | subject = item.getAdapterPosition(); |
165 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 141 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
166 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 142 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
167 | getError(subStr); | 143 | getError(subStr); |
168 | } else { | 144 | } else { |
169 | // nothing can do | 145 | // nothing can do |
170 | } | 146 | } |
171 | } | 147 | } |
172 | }); | 148 | }); |
173 | } | 149 | } |
174 | }; | 150 | }; |
175 | getBinding().rvSubject.setAdapter(adapter); | 151 | getBinding().rvSubject.setAdapter(adapter); |
176 | subject = 0; | 152 | subject = 0; |
177 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 153 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
178 | getBinding().llAll.setOnClickListener(v -> { | 154 | getBinding().llAll.setOnClickListener(v -> { |
179 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 155 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
180 | startActivity(intent); | 156 | startActivity(intent); |
181 | }); | 157 | }); |
182 | 158 | ||
183 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 159 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
184 | homeworkAdapter = new HomeworkAdapter(); | 160 | homeworkAdapter = new HomeworkAdapter(); |
185 | binding.rvMain.setAdapter(errorAdapter); | 161 | binding.rvMain.setAdapter(errorAdapter); |
186 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 162 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
187 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 163 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
188 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 164 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
189 | @Override | 165 | @Override |
190 | public void onTabSelected(TabLayout.Tab tab) { | 166 | public void onTabSelected(TabLayout.Tab tab) { |
191 | if (tab.getPosition() == 0) { | 167 | if (tab.getPosition() == 0) { |
192 | binding.rvMain.setAdapter(errorAdapter); | 168 | binding.rvMain.setAdapter(errorAdapter); |
193 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 169 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
194 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 170 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
195 | } else { | 171 | } else { |
196 | binding.rvMain.setAdapter(homeworkAdapter); | 172 | binding.rvMain.setAdapter(homeworkAdapter); |
197 | binding.rvMain.setVisibility(View.VISIBLE); | 173 | binding.rvMain.setVisibility(View.VISIBLE); |
198 | binding.llEmpty.setVisibility(View.GONE); | 174 | binding.llEmpty.setVisibility(View.GONE); |
199 | } | 175 | } |
200 | } | 176 | } |
201 | @Override | 177 | @Override |
202 | public void onTabUnselected(TabLayout.Tab tab) { | 178 | public void onTabUnselected(TabLayout.Tab tab) { |
203 | } | 179 | } |
204 | @Override | 180 | @Override |
205 | public void onTabReselected(TabLayout.Tab tab) { | 181 | public void onTabReselected(TabLayout.Tab tab) { |
206 | } | 182 | } |
207 | }); | 183 | }); |
208 | } | 184 | } |
209 | 185 | ||
210 | private void showButtonDialog() { | 186 | private void takePhoto(int type) { |
187 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | ||
188 | XXPermissions.with(getContext()) | ||
189 | // 申请多个权限 | ||
190 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | ||
191 | @Override | ||
192 | public void onGranted(List<String> permissions, boolean all) { | ||
193 | if (all) { | ||
194 | //开启扫码界面 | ||
195 | showButtonDialog(type); | ||
196 | } else { | ||
197 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | @Override | ||
202 | public void onDenied(List<String> permissions, boolean never) { | ||
203 | XXPermissions.startPermissionActivity(getContext(), permissions); | ||
204 | } | ||
205 | }); | ||
206 | } else { | ||
207 | showButtonDialog(type); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | private void showButtonDialog(int type) { | ||
211 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 212 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
212 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 213 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
213 | dialog.setContentView(bottomView); | 214 | dialog.setContentView(bottomView); |
214 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 215 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
215 | @Override | 216 | @Override |
216 | public void onClick(View view) { | 217 | public void onClick(View view) { |
217 | dialog.dismiss(); | 218 | dialog.dismiss(); |
218 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 219 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
219 | //确保有相机来处理Intent | 220 | //确保有相机来处理Intent |
220 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 221 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
221 | File photoFile = new File(filePath); | 222 | File photoFile = new File(filePath); |
222 | if (photoFile != null) { | 223 | |
223 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 224 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
224 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); | 225 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
225 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 226 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
226 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 227 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
227 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 228 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
228 | } | ||
229 | } | 229 | } |
230 | }); | 230 | }); |
231 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 231 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
232 | @Override | 232 | @Override |
233 | public void onClick(View view) { | 233 | public void onClick(View view) { |
234 | dialog.dismiss(); | 234 | dialog.dismiss(); |
235 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 235 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
236 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 236 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
237 | .multiSelect(true) //是否多选 | 237 | .multiSelect(true) //是否多选 |
238 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 238 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
239 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 239 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
240 | .maxImageSelectable(5) //图片可选择数 | 240 | .maxImageSelectable(5) //图片可选择数 |
241 | .maxHeight(1920) //图片最大高度 | 241 | .maxHeight(1920) //图片最大高度 |
242 | .maxWidth(1920) //图片最大宽度 | 242 | .maxWidth(1920) //图片最大宽度 |
243 | .maxImageSize(3) //图片最大大小Mb | 243 | .maxImageSize(3) //图片最大大小Mb |
244 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | 244 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); |
245 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 245 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
246 | 246 | ||
247 | } | 247 | } |
248 | }); | 248 | }); |
249 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 249 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
250 | @Override | 250 | @Override |
251 | public void onClick(View view) { | 251 | public void onClick(View view) { |
252 | dialog.dismiss(); | 252 | dialog.dismiss(); |
253 | } | 253 | } |
254 | }); | 254 | }); |
255 | dialog.show(); | 255 | dialog.show(); |
256 | } | 256 | } |
257 | 257 | ||
258 | @SuppressLint("CheckResult") | 258 | @SuppressLint("CheckResult") |
259 | protected void getHomework() { | 259 | protected void getHomework() { |
260 | if (studentBean == null) return; | 260 | if (studentBean == null) return; |
261 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 261 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
262 | .subscribeOn(Schedulers.io()) | 262 | .subscribeOn(Schedulers.io()) |
263 | .observeOn(AndroidSchedulers.mainThread()) | 263 | .observeOn(AndroidSchedulers.mainThread()) |
264 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 264 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
265 | .map(ResponseResult::getData) | 265 | .map(ResponseResult::getData) |
266 | .subscribe((data, th) -> { | 266 | .subscribe((data, th) -> { |
267 | if (th != null) th.printStackTrace(); | 267 | if (th != null) th.printStackTrace(); |
268 | homeworkAdapter.setNewData(data); | 268 | homeworkAdapter.setNewData(data); |
269 | }); | 269 | }); |
270 | } | 270 | } |
271 | 271 | ||
272 | private void getError(String subject) { | 272 | private void getError(String subject) { |
273 | if (studentBean == null) { | 273 | if (studentBean == null) { |
274 | return; | 274 | return; |
275 | } | 275 | } |
276 | Map<String, Object> map = new HashMap<>(); | 276 | Map<String, Object> map = new HashMap<>(); |
277 | map.put("subject", subject); | 277 | map.put("subject", subject); |
278 | map.put("stuId", studentBean.getStuId()); | 278 | map.put("stuId", studentBean.getStuId()); |
279 | map.put("pageSize", 5); | 279 | map.put("pageSize", 5); |
280 | map.put("pageNum", 1); | 280 | map.put("pageNum", 1); |
281 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 281 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
282 | @Override | 282 | @Override |
283 | public void onSubscribe(Disposable d) { | 283 | public void onSubscribe(Disposable d) { |
284 | } | 284 | } |
285 | @Override | 285 | @Override |
286 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 286 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
287 | if (result.getData() != null && result.getCode() == 200) { | 287 | if (result.getData() != null && result.getCode() == 200) { |
288 | List<TopicBean> topicBeans = result.getData().getList(); | 288 | List<TopicBean> topicBeans = result.getData().getList(); |
289 | errorAdapter.refresh(topicBeans); | 289 | errorAdapter.refresh(topicBeans); |
290 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 290 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
291 | if (topicBeans.size() > 0) { | 291 | if (topicBeans.size() > 0) { |
292 | getBinding().rvMain.setVisibility(View.VISIBLE); | 292 | getBinding().rvMain.setVisibility(View.VISIBLE); |
293 | getBinding().llEmpty.setVisibility(View.GONE); | 293 | getBinding().llEmpty.setVisibility(View.GONE); |
294 | } else { | 294 | } else { |
295 | getBinding().rvMain.setVisibility(View.GONE); | 295 | getBinding().rvMain.setVisibility(View.GONE); |
296 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 296 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | @Override | 301 | @Override |
302 | public void onError(Throwable e) { | 302 | public void onError(Throwable e) { |
303 | e.printStackTrace(); | 303 | e.printStackTrace(); |
304 | } | 304 | } |
305 | @Override | 305 | @Override |
306 | public void onComplete() { | 306 | public void onComplete() { |
307 | } | 307 | } |
308 | }); | 308 | }); |
309 | } | 309 | } |
310 | 310 | ||
311 | @Override | 311 | @Override |
312 | public void onResume() { | 312 | public void onResume() { |
313 | super.onResume(); | 313 | super.onResume(); |
314 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 314 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
315 | getHomework(); | 315 | getHomework(); |
316 | } | 316 | } |
317 | 317 | ||
318 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 318 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
319 | int type; | ||
320 | public HandlerCallBack(int type) { | ||
321 | this.type = type; | ||
322 | } | ||
323 | |||
319 | private String TAG = "---ImagePicker---"; | 324 | private String TAG = "---ImagePicker---"; |
320 | List<ImageInfo> photoList = new ArrayList<>(); | 325 | List<ImageInfo> photoList = new ArrayList<>(); |
321 | 326 | ||
322 | @Override | 327 | @Override |
323 | public void onStart() { | 328 | public void onStart() { |
324 | Log.i(TAG, "onStart: 开启"); | 329 | Log.i(TAG, "onStart: 开启"); |
325 | } | 330 | } |
326 | 331 | ||
327 | @Override | 332 | @Override |
328 | public void onSuccess(List<ImageInfo> photoList) { | 333 | public void onSuccess(List<ImageInfo> photoList) { |
329 | this.photoList = photoList; | 334 | this.photoList = photoList; |
330 | Log.i(TAG, "onSuccess: 返回数据"); | 335 | Log.i(TAG, "onSuccess: 返回数据"); |
331 | } | 336 | } |
332 | 337 | ||
333 | @Override | 338 | @Override |
334 | public void onCancel() { | 339 | public void onCancel() { |
335 | Log.i(TAG, "onCancel: 取消"); | 340 | Log.i(TAG, "onCancel: 取消"); |
336 | } | 341 | } |
337 | 342 | ||
338 | @Override | 343 | @Override |
339 | public void onFinish(List<ImageInfo> selectImage) { | 344 | public void onFinish(List<ImageInfo> selectImage) { |
340 | if (selectImage.size() == photoList.size()) { | 345 | if (selectImage.size() == photoList.size()) { |
341 | List<String> strings = new ArrayList<>(); | 346 | ArrayList<String> strings = new ArrayList<>(); |
342 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 347 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
343 | for (ImageInfo imageInfo : selectImage) { | 348 | for (ImageInfo imageInfo : selectImage) { |
344 | strings.add(imageInfo.getPath()); | 349 | strings.add(imageInfo.getPath()); |
345 | } | 350 | } |
346 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 351 | intent.putStringArrayListExtra("images", strings); |
352 | intent.putExtra("type", type); | ||
347 | startActivity(intent); | 353 | startActivity(intent); |
348 | } | 354 | } |
349 | } | 355 | } |
app/src/main/res/drawable/ic_filter_down_black.png
427 Bytes
app/src/main/res/drawable/selector_for_input_spinner.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item> | ||
4 | <shape> | ||
5 | <corners android:radius="6dp" /> | ||
6 | |||
7 | <solid android:color="#F5F5F5" /> | ||
8 | </shape> | ||
9 | </item> | ||
10 | <item | ||
11 | android:width="10dp" | ||
12 | android:height="6dp" | ||
13 | android:end="15dp" | ||
14 | android:gravity="center_vertical|end" | ||
15 | android:drawable="@drawable/ic_filter_down_black"> | ||
16 | </item> | ||
17 | </layer-list> | ||
18 |
app/src/main/res/drawable/shape_for_input_spinner.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item | ||
4 | android:top="-3dp"> | ||
5 | <shape> | ||
6 | <corners android:radius="6dp" /> | ||
7 | <solid android:color="#F5F5F5" /> | ||
8 | </shape> | ||
9 | </item> | ||
10 | </layer-list> |
app/src/main/res/drawable/shape_radius_5.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:radius="5dp"/> | ||
4 | </shape> |
app/src/main/res/drawable/shape_radius_top_10.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:topRightRadius="10dp" android:topLeftRadius="10dp"/> | ||
4 | <solid android:color="@color/white"/> | ||
5 | </shape> |
app/src/main/res/layout/dialog_add_homework.xml
File was created | 1 | <FrameLayout | |
2 | 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 | tools:ignore="HardcodedText,ContentDescription,UselessParent" > | ||
8 | |||
9 | <LinearLayout | ||
10 | android:orientation="vertical" | ||
11 | android:background="@drawable/shape_radius_top_10" | ||
12 | android:layout_marginTop="80dp" | ||
13 | android:layout_width="match_parent" | ||
14 | android:layout_height="match_parent"> | ||
15 | |||
16 | <FrameLayout | ||
17 | android:layout_marginVertical="8dp" | ||
18 | android:layout_width="match_parent" | ||
19 | android:layout_height="wrap_content"> | ||
20 | |||
21 | <TextView | ||
22 | android:text="录入作业" | ||
23 | android:textSize="17sp" | ||
24 | android:textStyle="bold" | ||
25 | android:layout_gravity="center" | ||
26 | android:textColor="@color/text_title" | ||
27 | android:layout_width="wrap_content" | ||
28 | android:layout_height="wrap_content" /> | ||
29 | |||
30 | <ImageView | ||
31 | android:id="@+id/btnClose" | ||
32 | android:padding="12dp" | ||
33 | android:src="@mipmap/ic_close" | ||
34 | android:layout_gravity="end|center_vertical" | ||
35 | android:layout_width="35dp" | ||
36 | android:layout_height="35dp" /> | ||
37 | </FrameLayout> | ||
38 | |||
39 | <TextView | ||
40 | android:layout_width="wrap_content" | ||
41 | android:layout_height="wrap_content" | ||
42 | android:layout_marginHorizontal="15dp" | ||
43 | android:text="学生" | ||
44 | android:textColor="@color/text_title" | ||
45 | android:textSize="14sp" | ||
46 | android:textStyle="bold" /> | ||
47 | |||
48 | <androidx.appcompat.widget.AppCompatSpinner | ||
49 | android:id="@+id/spStudent" | ||
50 | style="@style/customSpinnerStyle" | ||
51 | android:layout_width="match_parent" | ||
52 | android:layout_height="40dp" | ||
53 | android:layout_marginTop="10dp" | ||
54 | android:layout_marginHorizontal="15dp" | ||
55 | android:background="@drawable/selector_for_input_spinner" | ||
56 | android:popupBackground="@drawable/shape_for_input_spinner" | ||
57 | android:scrollbars="none" /> | ||
58 | |||
59 | <TextView | ||
60 | android:layout_width="wrap_content" | ||
61 | android:layout_height="wrap_content" | ||
62 | android:layout_marginHorizontal="15dp" | ||
63 | android:layout_marginTop="20dp" | ||
64 | android:text="年级" | ||
65 | android:textColor="@color/text_title" | ||
66 | android:textSize="14sp" | ||
67 | android:textStyle="bold" /> | ||
68 | |||
69 | <androidx.appcompat.widget.AppCompatSpinner | ||
70 | android:id="@+id/spGrade" | ||
71 | style="@style/customSpinnerStyle" | ||
72 | android:layout_width="match_parent" | ||
73 | android:layout_height="40dp" | ||
74 | android:layout_marginTop="10dp" | ||
75 | android:layout_marginHorizontal="15dp" | ||
76 | android:background="@drawable/selector_for_input_spinner" | ||
77 | android:popupBackground="@drawable/shape_for_input_spinner" | ||
78 | android:scrollbars="none" /> | ||
79 | |||
80 | <TextView | ||
81 | android:layout_width="wrap_content" | ||
82 | android:layout_height="wrap_content" | ||
83 | android:layout_marginHorizontal="15dp" | ||
84 | android:layout_marginTop="20dp" | ||
85 | android:text="学期" | ||
86 | android:textColor="@color/text_title" | ||
87 | android:textSize="14sp" | ||
88 | android:textStyle="bold" /> | ||
89 | |||
90 | <androidx.appcompat.widget.AppCompatSpinner | ||
91 | android:id="@+id/spTerm" | ||
92 | style="@style/customSpinnerStyle" | ||
93 | android:layout_width="match_parent" | ||
94 | android:layout_height="40dp" | ||
95 | android:layout_marginTop="10dp" | ||
96 | android:layout_marginHorizontal="15dp" | ||
97 | android:background="@drawable/selector_for_input_spinner" | ||
98 | android:entries="@array/grade_array" | ||
99 | android:popupBackground="@drawable/shape_for_input_spinner" | ||
100 | android:scrollbars="none" /> | ||
101 | |||
102 | <TextView | ||
103 | android:layout_width="wrap_content" | ||
104 | android:layout_height="wrap_content" | ||
105 | android:layout_marginHorizontal="15dp" | ||
106 | android:layout_marginTop="20dp" | ||
107 | android:text="科目" | ||
108 | android:textColor="@color/text_title" | ||
109 | android:textSize="14sp" | ||
110 | android:textStyle="bold" /> | ||
111 | |||
112 | <androidx.appcompat.widget.AppCompatSpinner | ||
113 | android:id="@+id/spSubject" | ||
114 | style="@style/customSpinnerStyle" | ||
115 | android:layout_width="match_parent" | ||
116 | android:layout_height="40dp" | ||
117 | android:layout_marginTop="10dp" | ||
118 | android:layout_marginHorizontal="15dp" | ||
119 | android:background="@drawable/selector_for_input_spinner" | ||
120 | android:popupBackground="@drawable/shape_for_input_spinner" | ||
121 | android:scrollbars="none" /> | ||
122 | |||
123 | <TextView | ||
124 | android:layout_width="wrap_content" | ||
125 | android:layout_height="wrap_content" | ||
126 | android:layout_marginHorizontal="15dp" | ||
127 | android:layout_marginTop="20dp" | ||
128 | android:text="日期" | ||
129 | android:textColor="@color/text_title" | ||
130 | android:textSize="14sp" | ||
131 | android:textStyle="bold" /> | ||
132 | |||
133 | <TextView | ||
134 | android:id="@+id/tvDate" | ||
135 | tools:text="2024-09-18" | ||
136 | android:textSize="16sp" | ||
137 | android:textColor="#333" | ||
138 | android:gravity="center_vertical" | ||
139 | android:paddingHorizontal="16dp" | ||
140 | android:layout_width="match_parent" | ||
141 | android:layout_height="40dp" | ||
142 | android:layout_marginTop="10dp" | ||
143 | android:layout_marginHorizontal="15dp" | ||
144 | android:background="@drawable/selector_for_input_spinner" /> | ||
145 | |||
146 | <TextView | ||
147 | android:layout_width="wrap_content" | ||
148 | android:layout_height="wrap_content" | ||
149 | android:layout_marginHorizontal="15dp" | ||
150 | android:layout_marginTop="20dp" | ||
151 | android:text="作业名称" | ||
152 | android:textColor="@color/text_title" | ||
153 | android:textSize="14sp" | ||
154 | android:textStyle="bold" /> | ||
155 | |||
156 | <EditText | ||
157 | android:id="@+id/etName" | ||
158 | android:layout_width="match_parent" | ||
159 | android:layout_height="40dp" | ||
160 | android:layout_marginTop="10dp" | ||
161 | android:layout_marginHorizontal="15dp" | ||
162 | android:background="@drawable/shape_for_input_spinner" | ||
163 | android:fillViewport="true" | ||
164 | android:gravity="center_vertical" | ||
165 | android:maxLength="50" | ||
166 | android:paddingHorizontal="16dp" | ||
167 | android:textColor="@color/text_title" | ||
168 | android:textSize="18sp" | ||
169 | android:inputType="text" | ||
170 | tools:ignore="Autofill,LabelFor" /> | ||
171 | |||
172 | <Space style="@style/empty_space"/> | ||
173 | <TextView | ||
174 | android:text="确认录入" | ||
175 | android:gravity="center" | ||
176 | android:textSize="16sp" | ||
177 | android:textColor="@color/white" | ||
178 | android:background="@drawable/shape_radius_5" | ||
179 | android:backgroundTint="#1C90F3" | ||
180 | android:layout_gravity="center_horizontal" | ||
181 | android:layout_marginBottom="16dp" | ||
182 | android:layout_width="224dp" | ||
183 | android:layout_height="36dp"/> | ||
184 | </LinearLayout> | ||
185 | </FrameLayout> |
app/src/main/res/layout/item_spinner.xml
File was created | 1 | <TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:layout_width="match_parent" | ||
3 | android:layout_height="40dp" | ||
4 | android:ellipsize="marquee" | ||
5 | android:gravity="center_vertical" | ||
6 | android:paddingHorizontal="14dp" | ||
7 | android:singleLine="true" | ||
8 | android:textColor="@color/text_title" | ||
9 | android:textSize="13sp" /> | ||
10 | |||
11 |
app/src/main/res/values/styles.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <resources> | 2 | <resources> |
3 | 3 | ||
4 | 4 | ||
5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> | 5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> |
6 | <item name="android:windowBackground">@drawable/welcome_bg</item> | 6 | <item name="android:windowBackground">@drawable/welcome_bg</item> |
7 | <item name="colorPrimaryDark">@android:color/transparent</item> | 7 | <item name="colorPrimaryDark">@android:color/transparent</item> |
8 | <item name="windowActionBar">false</item> | 8 | <item name="windowActionBar">false</item> |
9 | <item name="windowNoTitle">true</item> | 9 | <item name="windowNoTitle">true</item> |
10 | <item name="android:windowFullscreen">true</item> | 10 | <item name="android:windowFullscreen">true</item> |
11 | </style> | 11 | </style> |
12 | 12 | ||
13 | <style name="main_bottom_navigaton_menu_item"> | 13 | <style name="main_bottom_navigaton_menu_item"> |
14 | <item name="android:layout_width">0dp</item> | 14 | <item name="android:layout_width">0dp</item> |
15 | <item name="android:layout_weight">1</item> | 15 | <item name="android:layout_weight">1</item> |
16 | <item name="android:layout_height">match_parent</item> | 16 | <item name="android:layout_height">match_parent</item> |
17 | <item name="android:background">@android:color/transparent</item> | 17 | <item name="android:background">@android:color/transparent</item> |
18 | <item name="android:button">@null</item> | 18 | <item name="android:button">@null</item> |
19 | <item name="android:gravity">center</item> | 19 | <item name="android:gravity">center</item> |
20 | <item name="android:textSize">11dp</item> | 20 | <item name="android:textSize">11dp</item> |
21 | <item name="android:drawablePadding">2dp</item> | 21 | <item name="android:drawablePadding">2dp</item> |
22 | </style> | 22 | </style> |
23 | <!--实现BottomSheetDialog圆角效果--> | 23 | <!--实现BottomSheetDialog圆角效果--> |
24 | <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> | 24 | <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> |
25 | <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> | 25 | <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> |
26 | </style> | 26 | </style> |
27 | 27 | ||
28 | <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal"> | 28 | <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal"> |
29 | <item name="android:background">@android:color/transparent</item> | 29 | <item name="android:background">@android:color/transparent</item> |
30 | <item name="android:navigationBarColor">@android:color/transparent</item> | 30 | <item name="android:navigationBarColor">@android:color/transparent</item> |
31 | <item name="behavior_peekHeight">500dp</item> | 31 | <item name="behavior_peekHeight">500dp</item> |
32 | </style> | 32 | </style> |
33 | 33 | ||
34 | <style name="MyAlertDialog" parent="android:Theme.Material.Dialog.Alert"> | 34 | <style name="MyAlertDialog" parent="android:Theme.Material.Dialog.Alert"> |
35 | <!--背景颜色及和透明程度--> | 35 | <!--背景颜色及和透明程度--> |
36 | <item name="android:windowBackground">@null</item> | 36 | <item name="android:windowBackground">@null</item> |
37 | <!--是否去除标题 --> | 37 | <!--是否去除标题 --> |
38 | <item name="android:windowNoTitle">true</item> | 38 | <item name="android:windowNoTitle">true</item> |
39 | <!--是否去除边框--> | 39 | <!--是否去除边框--> |
40 | <item name="android:windowFrame">@null</item> | 40 | <item name="android:windowFrame">@null</item> |
41 | <!--是否浮现在activity之上--> | 41 | <!--是否浮现在activity之上--> |
42 | <item name="android:windowIsFloating">true</item> | 42 | <item name="android:windowIsFloating">true</item> |
43 | <!--是否模糊--> | 43 | <!--是否模糊--> |
44 | <item name="android:backgroundDimEnabled">true</item> | 44 | <item name="android:backgroundDimEnabled">true</item> |
45 | <item name="android:windowIsTranslucent">true</item><!--半透明--> | 45 | <item name="android:windowIsTranslucent">true</item><!--半透明--> |
46 | <item name="android:windowSoftInputMode">stateVisible|adjustPan</item> | 46 | <item name="android:windowSoftInputMode">stateVisible|adjustPan</item> |
47 | </style> | 47 | </style> |
48 | 48 | ||
49 | <style name="customSpinnerStyle" parent="android:Widget.ListView.DropDown"> | 49 | <style name="customSpinnerStyle" parent="android:Widget.ListView.DropDown"> |
50 | <item name="divider">@color/border</item> | 50 | <item name="divider">@color/border</item> |
51 | <item name="android:scrollbars">none</item> | 51 | <item name="android:scrollbars">none</item> |
52 | <item name="android:dividerHeight">1dp</item> | 52 | <item name="android:dividerHeight">1dp</item> |
53 | <item name="android:textSize">15sp</item> | 53 | <item name="android:textSize">15sp</item> |
54 | </style> | 54 | </style> |
55 | 55 | ||
56 | <style name="empty_space"> | 56 | <style name="empty_space"> |
57 | <item name="android:layout_width">0dp</item> | 57 | <item name="android:layout_width">0dp</item> |
58 | <item name="android:layout_height">0dp</item> | 58 | <item name="android:layout_height">0dp</item> |
59 | <item name="android:layout_weight">1</item> | 59 | <item name="android:layout_weight">1</item> |
60 | </style> | 60 | </style> |
61 | 61 | ||
62 | |||
63 | <style name="BaseDialog"> | ||
64 | <item name="android:background">@android:color/transparent</item> | ||
65 | <item name="android:windowBackground">@android:color/transparent</item> | ||
66 | <item name="android:windowIsFloating">true</item> | ||
67 | </style> | ||
68 | |||
62 | </resources> | 69 | </resources> |
libs/common/src/main/java/com/prws/common/bean/Student.java
File was created | 1 | package com.prws.common.bean; | |
2 | |||
3 | import androidx.annotation.NonNull; | ||
4 | |||
5 | public class Student { | ||
6 | |||
7 | public String stuId; | ||
8 | public String stuName; | ||
9 | public int gender; | ||
10 | public String term; | ||
11 | public String account; | ||
12 | public String nickName; | ||
13 | public String address; | ||
14 | public String phone; | ||
15 | public String photo; | ||
16 | public int fromType; | ||
17 | public int gradeId; | ||
18 | public String oriSchool; | ||
19 | public String parentPhone; | ||
20 | public String parentIdentity; | ||
21 | public String teacherName; | ||
22 | public int teacherId; | ||
23 | public String teacherAvatar; | ||
24 | public String grade; | ||
25 | public String teacherIdentity; | ||
26 | public int sex; | ||
27 | public Integer state; | ||
28 | |||
29 | @NonNull | ||
30 | @Override | ||
31 | public String toString() { | ||
32 | return stuName; | ||
33 | } | ||
34 | } | ||
35 |
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.Teacher; | 13 | import com.prws.common.bean.Teacher; |
13 | import com.prws.common.bean.TopicBean; | 14 | import com.prws.common.bean.TopicBean; |
14 | import com.prws.common.bean.UpdateBean; | 15 | import com.prws.common.bean.UpdateBean; |
15 | import com.prws.common.bean.homework.HomeworkList; | 16 | import com.prws.common.bean.homework.HomeworkList; |
16 | import com.prws.common.utils.SharedPreferencesUtil; | 17 | import com.prws.common.utils.SharedPreferencesUtil; |
17 | 18 | ||
18 | import java.io.File; | 19 | import java.io.File; |
19 | import java.util.HashMap; | 20 | import java.util.HashMap; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | import java.util.Map; | 22 | import java.util.Map; |
22 | 23 | ||
23 | import io.reactivex.Observable; | 24 | import io.reactivex.Observable; |
24 | import io.reactivex.Observer; | 25 | import io.reactivex.Observer; |
25 | import io.reactivex.Single; | 26 | import io.reactivex.Single; |
26 | import io.reactivex.android.schedulers.AndroidSchedulers; | 27 | import io.reactivex.android.schedulers.AndroidSchedulers; |
27 | import io.reactivex.schedulers.Schedulers; | 28 | import io.reactivex.schedulers.Schedulers; |
28 | import okhttp3.MediaType; | 29 | import okhttp3.MediaType; |
29 | import okhttp3.MultipartBody; | 30 | import okhttp3.MultipartBody; |
30 | import okhttp3.RequestBody; | 31 | import okhttp3.RequestBody; |
31 | import okhttp3.ResponseBody; | 32 | import okhttp3.ResponseBody; |
32 | import retrofit2.Call; | 33 | import retrofit2.Call; |
33 | import retrofit2.Callback; | 34 | import retrofit2.Callback; |
34 | import retrofit2.http.Body; | 35 | import retrofit2.http.Body; |
35 | import retrofit2.http.GET; | 36 | import retrofit2.http.GET; |
36 | import retrofit2.http.Header; | 37 | import retrofit2.http.Header; |
37 | import retrofit2.http.Headers; | 38 | import retrofit2.http.Headers; |
38 | import retrofit2.http.Multipart; | 39 | import retrofit2.http.Multipart; |
39 | import retrofit2.http.POST; | 40 | import retrofit2.http.POST; |
40 | import retrofit2.http.PUT; | 41 | import retrofit2.http.PUT; |
41 | import retrofit2.http.Part; | 42 | import retrofit2.http.Part; |
42 | import retrofit2.http.PartMap; | 43 | import retrofit2.http.PartMap; |
43 | import retrofit2.http.Query; | 44 | import retrofit2.http.Query; |
44 | import retrofit2.http.Url; | 45 | import retrofit2.http.Url; |
45 | 46 | ||
46 | /** | 47 | /** |
47 | * 类名称:NetWorks | 48 | * 类名称:NetWorks |
48 | * 创建人: | 49 | * 创建人: |
49 | * <p> | 50 | * <p> |
50 | * 类描述:网络请求的操作类 | 51 | * 类描述:网络请求的操作类 |
51 | */ | 52 | */ |
52 | public class NetWorks extends RetrofitUtils { | 53 | public class NetWorks extends RetrofitUtils { |
53 | //服务器路径 | 54 | //服务器路径 |
54 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); | 55 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); |
55 | 56 | ||
56 | //设缓存有效期为1天 | 57 | //设缓存有效期为1天 |
57 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 58 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
58 | //查询缓存的Cache-Control设置,使用缓存 | 59 | //查询缓存的Cache-Control设置,使用缓存 |
59 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 60 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
60 | //查询网络的Cache-Control设置。不使用缓存 | 61 | //查询网络的Cache-Control设置。不使用缓存 |
61 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 62 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
62 | 63 | ||
63 | 64 | ||
64 | public interface NetService { | 65 | public interface NetService { |
65 | 66 | ||
66 | 67 | ||
67 | @GET("/api/v1/user/logout") | 68 | @GET("/api/v1/user/logout") |
68 | Observable<ResponseBody> logout(); | 69 | Observable<ResponseBody> logout(); |
69 | 70 | ||
70 | @Multipart | 71 | @Multipart |
71 | @POST("/api/v1/user/upLoadAvatar") | 72 | @POST("/api/v1/user/upLoadAvatar") |
72 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 73 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
73 | 74 | ||
74 | 75 | ||
75 | @Headers("Content-Type: application/json") | 76 | @Headers("Content-Type: application/json") |
76 | @POST("/api/v1/user/editUser") | 77 | @POST("/api/v1/user/editUser") |
77 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 78 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
78 | 79 | ||
79 | @Headers("Content-Type: application/json") | 80 | @Headers("Content-Type: application/json") |
80 | @POST("/api/v1/user/changePassword") | 81 | @POST("/api/v1/user/changePassword") |
81 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 82 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
82 | 83 | ||
83 | 84 | ||
84 | @GET("/api/v1/user/searchById") | 85 | @GET("/api/v1/user/searchById") |
85 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 86 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
86 | 87 | ||
87 | 88 | ||
88 | @Headers("Content-Type: application/json") | 89 | @Headers("Content-Type: application/json") |
89 | @POST("/api/v1/auth/login") | 90 | @POST("/api/v1/auth/login") |
90 | Observable<ResponseBody> login(@Body RequestBody body); | 91 | Observable<ResponseBody> login(@Body RequestBody body); |
91 | 92 | ||
92 | @GET("/api/v1/resource/listGradeAndSubject") | 93 | @GET("/api/v1/resource/listGradeAndSubject") |
93 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 94 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
94 | 95 | ||
95 | 96 | ||
96 | @GET("/api/v1/manager/generalQrCode") | 97 | @GET("/api/v1/manager/generalQrCode") |
97 | Observable<ResponseBody> generalQrCode(); | 98 | Observable<ResponseBody> generalQrCode(); |
98 | 99 | ||
99 | @GET("/api/v1/parent/scanAndLogin?") | 100 | @GET("/api/v1/parent/scanAndLogin?") |
100 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); | 101 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); |
101 | 102 | ||
102 | @GET("/api/v1/parent/getChildrenList") | 103 | @GET("/api/v1/parent/getChildrenList") |
103 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 104 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
104 | 105 | ||
105 | 106 | ||
106 | @Headers("Content-Type: application/json") | 107 | @Headers("Content-Type: application/json") |
107 | @POST("/api/v1/parent/registerParent") | 108 | @POST("/api/v1/parent/registerParent") |
108 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 109 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
109 | 110 | ||
110 | 111 | ||
111 | @GET("/api/v1/parent/listChildren") | 112 | @GET("/api/v1/parent/listChildren") |
112 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 113 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
113 | 114 | ||
114 | 115 | ||
115 | @Headers("Content-Type: application/json") | 116 | @Headers("Content-Type: application/json") |
116 | @POST("/api/v1/parent/registerStudent") | 117 | @POST("/api/v1/parent/registerStudent") |
117 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 118 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
118 | 119 | ||
119 | @Headers("Content-Type: application/json") | 120 | @Headers("Content-Type: application/json") |
120 | @POST("/api/v1/parent/bindTeacher") | 121 | @POST("/api/v1/parent/bindTeacher") |
121 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 122 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
122 | 123 | ||
123 | @Multipart | 124 | @Multipart |
124 | @POST("/api/v1/user/upLoadAvatar") | 125 | @POST("/api/v1/user/upLoadAvatar") |
125 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 126 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
126 | 127 | ||
127 | 128 | ||
128 | @Multipart | 129 | @Multipart |
129 | @POST("/api/v1/student/editStudentAvatar") | 130 | @POST("/api/v1/student/editStudentAvatar") |
130 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 131 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
131 | 132 | ||
132 | @Headers("Content-Type: application/json") | 133 | @Headers("Content-Type: application/json") |
133 | @POST("/api/v1/parent/editChild") | 134 | @POST("/api/v1/parent/editChild") |
134 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 135 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
135 | 136 | ||
136 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 137 | @GET("/api/v1/student/getStudyPlanForThisWeek") |
137 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 138 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
138 | 139 | ||
139 | @GET("api/v1/parent/searchTeacher") | 140 | @GET("api/v1/parent/searchTeacher") |
140 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 141 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
141 | 142 | ||
142 | @POST("api/v1/question/listErrorBook") | 143 | @POST("api/v1/question/listErrorBook") |
143 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 144 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
144 | 145 | ||
145 | @POST | 146 | @POST |
146 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 147 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
147 | 148 | ||
148 | @POST | 149 | @POST |
149 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 150 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
150 | 151 | ||
151 | @POST | 152 | @POST |
152 | Observable<JsonObject> getBaiduToken(@Url String url); | 153 | Observable<JsonObject> getBaiduToken(@Url String url); |
153 | 154 | ||
154 | @Multipart | 155 | @Multipart |
155 | @POST("api/v1/pad/addErrorBook") | 156 | @POST("api/v1/pad/addErrorBook") |
156 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 157 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
157 | 158 | ||
158 | @POST("api/v1/pad/deleteStuErrorBook") | 159 | @POST("api/v1/pad/deleteStuErrorBook") |
159 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 160 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
160 | 161 | ||
161 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 162 | @PUT("api/v1/pad/updateStuErrorBookInfo") |
162 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 163 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
163 | 164 | ||
164 | @POST("api/v1/question/editErrorBook") | 165 | @POST("api/v1/question/editErrorBook") |
165 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 166 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
166 | 167 | ||
167 | @GET("api/v1/resource/checkUpdate") | 168 | @GET("api/v1/resource/checkUpdate") |
168 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 169 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
169 | 170 | ||
170 | @GET("api/v1/teacher/getStudentList") | 171 | @GET("api/v1/teacher/getStudentList") |
171 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | 172 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); |
172 | 173 | ||
174 | @GET("api/v1/teacher/getStudentList") | ||
175 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); | ||
176 | |||
173 | @GET("api/v1/answer/listRecordForTeacher") | 177 | @GET("api/v1/answer/listRecordForTeacher") |
174 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | 178 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
175 | 179 | ||
176 | @GET("api/v1/homework/listHomeworkByStuId") | 180 | @GET("api/v1/homework/listHomeworkByStuId") |
177 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | 181 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); |
178 | 182 | ||
179 | } | 183 | } |
180 | 184 | ||
185 | public static String getUserId() { | ||
186 | return (String) SharedPreferencesUtil.getData("userId", ""); | ||
187 | } | ||
181 | 188 | ||
182 | public static String getHeader() { | 189 | public static String getHeader() { |
183 | return (String) SharedPreferencesUtil.getData("token", ""); | 190 | return (String) SharedPreferencesUtil.getData("token", ""); |
184 | } | 191 | } |
185 | 192 | ||
186 | public static String getBaiduToken() { | 193 | public static String getBaiduToken() { |
187 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 194 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
188 | } | 195 | } |
189 | 196 | ||
190 | 197 | ||
191 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 198 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
192 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 199 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
193 | } | 200 | } |
194 | 201 | ||
195 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 202 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
196 | File file = new File(path); | 203 | File file = new File(path); |
197 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 204 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
198 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 205 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
199 | Map<String, Object> map = new HashMap<>(); | 206 | Map<String, Object> map = new HashMap<>(); |
200 | map.put("condition", param); | 207 | map.put("condition", param); |
201 | setSubscribe(service_url.addError(part, map), observer); | 208 | setSubscribe(service_url.addError(part, map), observer); |
202 | } | 209 | } |
203 | 210 | ||
204 | 211 | ||
205 | public static void cut(String base64, Observer<CutPicBean> observer) { | 212 | public static void cut(String base64, Observer<CutPicBean> observer) { |
206 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 213 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
207 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 214 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
208 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 215 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
209 | } | 216 | } |
210 | 217 | ||
211 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 218 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { |
212 | setSubscribe(service_url.editError(getHeader(), map), observer); | 219 | setSubscribe(service_url.editError(getHeader(), map), observer); |
213 | } | 220 | } |
214 | 221 | ||
215 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 222 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
216 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 223 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
217 | } | 224 | } |
218 | 225 | ||
219 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 226 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
220 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 227 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
221 | } | 228 | } |
222 | 229 | ||
223 | public static void getBaiduToken(Observer<JsonObject> observer) { | 230 | public static void getBaiduToken(Observer<JsonObject> observer) { |
224 | 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); | 231 | 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); |
225 | } | 232 | } |
226 | 233 | ||
227 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 234 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
228 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 235 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
229 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 236 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); |
230 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 237 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
231 | } | 238 | } |
232 | 239 | ||
233 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 240 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { |
234 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 241 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
235 | } | 242 | } |
236 | 243 | ||
237 | public static void logout(Observer<ResponseBody> observer) { | 244 | public static void logout(Observer<ResponseBody> observer) { |
238 | setSubscribe(service_url.logout(), observer); | 245 | setSubscribe(service_url.logout(), observer); |
239 | } | 246 | } |
240 | 247 | ||
241 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 248 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
242 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 249 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
243 | } | 250 | } |
244 | 251 | ||
245 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 252 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
246 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 253 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
247 | } | 254 | } |
248 | 255 | ||
249 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 256 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
250 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 257 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
251 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 258 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
252 | Map<String, Object> map = new HashMap<>(); | 259 | Map<String, Object> map = new HashMap<>(); |
253 | map.put("stuId", stuId); | 260 | map.put("stuId", stuId); |
254 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 261 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
255 | } | 262 | } |
256 | 263 | ||
257 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 264 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
258 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 265 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
259 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 266 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
260 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 267 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
261 | } | 268 | } |
262 | 269 | ||
263 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 270 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { |
264 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 271 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
265 | } | 272 | } |
266 | 273 | ||
267 | 274 | ||
268 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 275 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
269 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 276 | setSubscribe(service_url.editUser(getHeader(), body), observer); |
270 | } | 277 | } |
271 | 278 | ||
272 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 279 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
273 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 280 | setSubscribe(service_url.changePassword(getHeader(), body), observer); |
274 | } | 281 | } |
275 | 282 | ||
276 | 283 | ||
277 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 284 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
278 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 285 | setSubscribe(service_url.searchById(getHeader(), userId), observer); |
279 | } | 286 | } |
280 | 287 | ||
281 | 288 | ||
282 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 289 | public static void login(RequestBody body, Observer<ResponseBody> observer) { |
283 | setSubscribe(service_url.login(body), observer); | 290 | setSubscribe(service_url.login(body), observer); |
284 | } | 291 | } |
285 | 292 | ||
286 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 293 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
287 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 294 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); |
288 | } | 295 | } |
289 | 296 | ||
290 | 297 | ||
291 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { | 298 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { |
292 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | 299 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); |
293 | } | 300 | } |
294 | 301 | ||
295 | public static void getChildrenList(Observer<ResponseBody> observer) { | 302 | public static void getChildrenList(Observer<ResponseBody> observer) { |
296 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 303 | setSubscribe(service_url.getChildrenList(getHeader()), observer); |
297 | } | 304 | } |
298 | 305 | ||
299 | 306 | ||
300 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 307 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
301 | setSubscribe(service_url.registerParent(body), observer); | 308 | setSubscribe(service_url.registerParent(body), observer); |
302 | } | 309 | } |
303 | 310 | ||
304 | 311 | ||
305 | public static void listChildren(Observer<ResponseBody> observer) { | 312 | public static void listChildren(Observer<ResponseBody> observer) { |
306 | setSubscribe(service_url.listChildren(getHeader()), observer); | 313 | setSubscribe(service_url.listChildren(getHeader()), observer); |
307 | } | 314 | } |
308 | 315 | ||
309 | public static void listStudent(Observer<ResponseBody> observer) { | 316 | public static void listStudent(Observer<ResponseBody> observer) { |
310 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 317 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
311 | } | 318 | } |
312 | 319 | ||
320 | public static Single<ResponseResult<List<Student>>> listStudent() { | ||
321 | return service_url.getStudentList2(getHeader(), getUserId()); | ||
322 | } | ||
323 | |||
313 | public static void listRecord(Observer<ResponseBody> observer) { | 324 | public static void listRecord(Observer<ResponseBody> observer) { |
314 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 325 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
315 | } | 326 | } |
316 | 327 | ||
317 | 328 | ||
318 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 329 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
319 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 330 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); |
320 | } | 331 | } |
321 | 332 | ||
322 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 333 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
323 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 334 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); |
324 | } | 335 | } |
325 | 336 | ||
326 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 337 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
327 | setSubscribe(service_url.getError(getHeader(), map), observer); | 338 | setSubscribe(service_url.getError(getHeader(), map), observer); |
328 | } | 339 | } |
329 | 340 | ||
330 | 341 | ||
331 | public static RequestBody getMapRequestBody(Map map) { | 342 | public static RequestBody getMapRequestBody(Map map) { |
332 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 343 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); |
333 | } | 344 | } |
334 | 345 | ||
335 | 346 | ||
336 | public static RequestBody getArrayRequestBody(List list) { | 347 | public static RequestBody getArrayRequestBody(List list) { |
337 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 348 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); |
338 | } | 349 | } |
339 | 350 | ||
340 | public static RequestBody getFileRequestBody(File file) { | 351 | public static RequestBody getFileRequestBody(File file) { |
341 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 352 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); |
342 | } | 353 | } |
343 | 354 | ||
344 | public static RequestBody getFileRequestBody(byte[] bytes) { | 355 | public static RequestBody getFileRequestBody(byte[] bytes) { |
345 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 356 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
346 | } | 357 | } |
347 | 358 | ||
348 | public static RequestBody getObjectRequestBody(Object obj) { | 359 | public static RequestBody getObjectRequestBody(Object obj) { |
349 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 360 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
350 | } | 361 | } |
351 | 362 | ||
352 | public static RequestBody getStringRequestBody(String str) { | 363 | public static RequestBody getStringRequestBody(String str) { |
353 | return RequestBody.create(MediaType.parse("text/plain"), str); | 364 | return RequestBody.create(MediaType.parse("text/plain"), str); |
354 | } | 365 | } |
355 | 366 | ||
356 | 367 | ||
357 | /** | 368 | /** |
358 | * 插入观察者 | 369 | * 插入观察者 |
359 | * | 370 | * |
360 | * @param observable | 371 | * @param observable |
361 | * @param observer | 372 | * @param observer |
362 | * @param <T> | 373 | * @param <T> |
363 | */ | 374 | */ |
364 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 375 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
365 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | 376 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |
366 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | 377 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 |
367 | .subscribe(observer); | 378 | .subscribe(observer); |
368 | } | 379 | } |
369 | 380 | ||
370 | } | 381 | } |
371 | 382 |