Commit fbe6b1873d311a68b7ad80eda9efb35312b761c2
1 parent
fc85bfe197
Exists in
master
首页展示已反馈作业
Showing
3 changed files
with
25 additions
and
21 deletions
Show diff stats
.idea/deploymentTargetDropDown.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | <component name="deploymentTargetDropDown"> | 3 | <component name="deploymentTargetDropDown"> |
4 | <value> | 4 | <value> |
5 | <entry key="app"> | 5 | <entry key="app"> |
6 | <State> | 6 | <State /> |
7 | <runningDeviceTargetSelectedWithDropDown> | ||
8 | <Target> | ||
9 | <type value="RUNNING_DEVICE_TARGET" /> | ||
10 | <deviceKey> | ||
11 | <Key> | ||
12 | <type value="SERIAL_NUMBER" /> | ||
13 | <value value="951f9ace" /> | ||
14 | </Key> | ||
15 | </deviceKey> | ||
16 | </Target> | ||
17 | </runningDeviceTargetSelectedWithDropDown> | ||
18 | <timeTargetWasSelectedWithDropDown value="2024-10-11T05:46:18.103982900Z" /> | ||
19 | </State> | ||
20 | </entry> | 7 | </entry> |
21 | </value> | 8 | </value> |
22 | </component> | 9 | </component> |
23 | </project> | 10 | </project> |
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 26 | 26 | minSdk 26 |
27 | targetSdk 32 | 27 | targetSdk 32 |
28 | versionCode 1005 | 28 | versionCode 1006 |
29 | versionName "1.0.0.5" | 29 | versionName "1.0.0.6" |
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 | dataBinding true | 61 | dataBinding true |
62 | } | 62 | } |
63 | compileOptions { | 63 | compileOptions { |
64 | sourceCompatibility JavaVersion.VERSION_1_8 | 64 | sourceCompatibility JavaVersion.VERSION_1_8 |
65 | targetCompatibility JavaVersion.VERSION_1_8 | 65 | targetCompatibility JavaVersion.VERSION_1_8 |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | dependencies { | 69 | dependencies { |
70 | support.each { k, v -> implementation v } | 70 | support.each { k, v -> implementation v } |
71 | api project(path: ':libs:common') | 71 | api project(path: ':libs:common') |
72 | implementation 'androidx.appcompat:appcompat:1.5.1' | 72 | implementation 'androidx.appcompat:appcompat:1.5.1' |
73 | implementation 'com.google.android.material:material:1.6.1' | 73 | implementation 'com.google.android.material:material:1.6.1' |
74 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 74 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
75 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 75 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
76 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 76 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
77 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 77 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
78 | //使用的三方 | 78 | //使用的三方 |
79 | implementation 'com.yalantis:ucrop:2.2.0' | 79 | implementation 'com.yalantis:ucrop:2.2.0' |
80 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 80 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
81 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 81 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
82 | 82 | ||
83 | // rx | 83 | // rx |
84 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | 84 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") |
85 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | 85 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") |
86 | 86 | ||
87 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") | 87 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") |
88 | implementation("com.contrarywind:Android-PickerView:4.1.9") | 88 | implementation("com.contrarywind:Android-PickerView:4.1.9") |
89 | 89 | ||
90 | implementation 'com.google.android:flexbox:1.0.0' | 90 | implementation 'com.google.android:flexbox:1.0.0' |
91 | 91 | ||
92 | // 沉浸式状态栏和他的Kotlin拓展 | 92 | // 沉浸式状态栏和他的Kotlin拓展 |
93 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' | 93 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' |
94 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' | 94 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' |
95 | 95 | ||
96 | // 图片查看 | 96 | // 图片查看 |
97 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' | 97 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' |
98 | } | 98 | } |
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.HomeworkDetailActivity; | 35 | import com.hjx.parent.HomeworkDetailActivity; |
36 | import com.hjx.parent.HomeworkShareActivity; | ||
36 | import com.hjx.parent.ImageActivity; | 37 | import com.hjx.parent.ImageActivity; |
37 | import com.hjx.parent.R; | 38 | import com.hjx.parent.R; |
38 | import com.hjx.parent.StuHomeworkActivity; | 39 | import com.hjx.parent.StuHomeworkActivity; |
39 | import com.hjx.parent.TeacherChooseActivity; | 40 | import com.hjx.parent.TeacherChooseActivity; |
40 | import com.hjx.parent.adapter.ErrorAdapter; | 41 | import com.hjx.parent.adapter.ErrorAdapter; |
41 | import com.hjx.parent.adapter.HomeworkAdapter; | 42 | import com.hjx.parent.adapter.HomeworkAdapter; |
42 | import com.hjx.parent.bean.StudentBean; | 43 | import com.hjx.parent.bean.StudentBean; |
43 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
44 | import com.hjx.parent.rx.BaseRxFragment; | 45 | import com.hjx.parent.rx.BaseRxFragment; |
45 | import com.prws.common.bean.PageInfo; | 46 | import com.prws.common.bean.PageInfo; |
46 | import com.prws.common.bean.ResponseResult; | 47 | import com.prws.common.bean.ResponseResult; |
47 | import com.prws.common.bean.Student; | 48 | import com.prws.common.bean.Student; |
48 | import com.prws.common.bean.TopicBean; | 49 | import com.prws.common.bean.TopicBean; |
50 | import com.prws.common.bean.homework.HomeworkList; | ||
49 | import com.prws.common.net.NetWorks; | 51 | import com.prws.common.net.NetWorks; |
50 | import com.prws.common.utils.BitmapUtils; | 52 | import com.prws.common.utils.BitmapUtils; |
51 | import com.prws.common.utils.CommonUtil; | 53 | import com.prws.common.utils.CommonUtil; |
52 | import com.prws.common.utils.ScreenUtils; | 54 | import com.prws.common.utils.ScreenUtils; |
53 | import com.prws.common.utils.SharedPreferencesUtil; | 55 | import com.prws.common.utils.SharedPreferencesUtil; |
54 | import com.prws.common.utils.dialog.MyButtomDialog; | 56 | import com.prws.common.utils.dialog.MyButtomDialog; |
55 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 57 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
56 | import com.zhangteng.imagepicker.bean.ImageInfo; | 58 | import com.zhangteng.imagepicker.bean.ImageInfo; |
57 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 59 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
58 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 60 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
59 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 61 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
60 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 62 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
61 | import com.zhangteng.utils.IHandlerCallBack; | 63 | import com.zhangteng.utils.IHandlerCallBack; |
62 | 64 | ||
63 | import java.io.File; | 65 | import java.io.File; |
66 | import java.text.SimpleDateFormat; | ||
64 | import java.util.ArrayList; | 67 | import java.util.ArrayList; |
65 | import java.util.Arrays; | 68 | import java.util.Arrays; |
66 | import java.util.Collections; | 69 | import java.util.Collections; |
67 | import java.util.HashMap; | 70 | import java.util.HashMap; |
68 | import java.util.List; | 71 | import java.util.List; |
72 | import java.util.Locale; | ||
69 | import java.util.Map; | 73 | import java.util.Map; |
70 | 74 | ||
71 | import io.reactivex.Observable; | 75 | import io.reactivex.Observable; |
72 | import io.reactivex.Observer; | 76 | import io.reactivex.Observer; |
73 | import io.reactivex.android.schedulers.AndroidSchedulers; | 77 | import io.reactivex.android.schedulers.AndroidSchedulers; |
74 | import io.reactivex.disposables.Disposable; | 78 | import io.reactivex.disposables.Disposable; |
75 | import io.reactivex.schedulers.Schedulers; | 79 | import io.reactivex.schedulers.Schedulers; |
76 | 80 | ||
77 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 81 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
78 | StudentBean studentBean; | 82 | StudentBean studentBean; |
79 | private int subject; | 83 | private int subject; |
80 | private ErrorAdapter errorAdapter; | 84 | private ErrorAdapter errorAdapter; |
81 | private HomeworkAdapter homeworkAdapter; | 85 | private HomeworkAdapter homeworkAdapter; |
82 | private String filePath; | 86 | private String filePath; |
83 | 87 | ||
84 | @Override | 88 | @Override |
85 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 89 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
86 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 90 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
87 | } | 91 | } |
88 | 92 | ||
89 | public void refreshStudent() { | 93 | public void refreshStudent() { |
90 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 94 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
91 | try { | 95 | try { |
92 | studentBean = new Gson().fromJson(student, StudentBean.class); | 96 | studentBean = new Gson().fromJson(student, StudentBean.class); |
93 | getBinding().tvChoose.setText(studentBean.getStuName()); | 97 | getBinding().tvChoose.setText(studentBean.getStuName()); |
94 | } catch (Exception e) { | 98 | } catch (Exception e) { |
95 | e.printStackTrace(); | 99 | e.printStackTrace(); |
96 | } | 100 | } |
97 | } | 101 | } |
98 | 102 | ||
99 | @Override | 103 | @Override |
100 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 104 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
101 | super.onViewCreated(view, savedInstanceState); | 105 | super.onViewCreated(view, savedInstanceState); |
102 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 106 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
103 | if (!TextUtils.isEmpty(photo)) { | 107 | if (!TextUtils.isEmpty(photo)) { |
104 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 108 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
105 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 109 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
106 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 110 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
107 | } | 111 | } |
108 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 112 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
109 | getBinding().tvName.setText(name); | 113 | getBinding().tvName.setText(name); |
110 | refreshStudent(); | 114 | refreshStudent(); |
111 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 115 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
112 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); | 116 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
113 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); | 117 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
114 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 118 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
115 | @Override | 119 | @Override |
116 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 120 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
117 | 121 | ||
118 | } | 122 | } |
119 | 123 | ||
120 | @Override | 124 | @Override |
121 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 125 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
122 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 126 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
123 | switch (item.getAdapterPosition()) { | 127 | switch (item.getAdapterPosition()) { |
124 | case 0: | 128 | case 0: |
125 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 129 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
126 | break; | 130 | break; |
127 | case 1: | 131 | case 1: |
128 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 132 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
129 | break; | 133 | break; |
130 | case 2: | 134 | case 2: |
131 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 135 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
132 | break; | 136 | break; |
133 | case 3: | 137 | case 3: |
134 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 138 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
135 | break; | 139 | break; |
136 | case 4: | 140 | case 4: |
137 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 141 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
138 | break; | 142 | break; |
139 | } | 143 | } |
140 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 144 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
141 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 145 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
142 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 146 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
143 | item.getConvertView().setOnClickListener(v -> { | 147 | item.getConvertView().setOnClickListener(v -> { |
144 | if (subject != item.getAdapterPosition()) { | 148 | if (subject != item.getAdapterPosition()) { |
145 | subject = item.getAdapterPosition(); | 149 | subject = item.getAdapterPosition(); |
146 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 150 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
147 | getError(subStr); | 151 | getError(subStr); |
148 | getHomework(subStr); | 152 | getHomework(subStr); |
149 | } | 153 | } |
150 | }); | 154 | }); |
151 | } | 155 | } |
152 | }; | 156 | }; |
153 | getBinding().rvSubject.setAdapter(adapter); | 157 | getBinding().rvSubject.setAdapter(adapter); |
154 | subject = 0; | 158 | subject = 0; |
155 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 159 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
156 | getBinding().llAll.setOnClickListener(v -> { | 160 | getBinding().llAll.setOnClickListener(v -> { |
157 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 161 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
158 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 162 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
159 | startActivity(intent); | 163 | startActivity(intent); |
160 | } else { | 164 | } else { |
161 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); | 165 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); |
162 | startActivity(intent); | 166 | startActivity(intent); |
163 | } | 167 | } |
164 | }); | 168 | }); |
165 | 169 | ||
166 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 170 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
167 | homeworkAdapter = new HomeworkAdapter(); | 171 | homeworkAdapter = new HomeworkAdapter(); |
168 | homeworkAdapter.setOnItemClickListener((baseQuickAdapter, view1, i) -> { | 172 | homeworkAdapter.setOnItemClickListener((baseQuickAdapter, view1, i) -> { |
173 | HomeworkList data = homeworkAdapter.getData().get(i); | ||
169 | Gson gson = new Gson(); | 174 | Gson gson = new Gson(); |
170 | String json = gson.toJson(studentBean); | 175 | String json = gson.toJson(studentBean); |
171 | Student s = gson.fromJson(json, Student.class); | 176 | Student s = gson.fromJson(json, Student.class); |
172 | Intent intent = new Intent(requireContext(), HomeworkDetailActivity.class); | 177 | if (data.getRight() == null) { |
173 | intent.putExtra("student", s); | 178 | Intent intent = new Intent(requireContext(), HomeworkDetailActivity.class); |
174 | intent.putExtra("data", homeworkAdapter.getData().get(i)); | 179 | intent.putExtra("student", s); |
175 | startActivity(intent); | 180 | intent.putExtra("data", data); |
181 | startActivity(intent); | ||
182 | } else { | ||
183 | Intent intent = new Intent(requireContext(), HomeworkShareActivity.class); | ||
184 | intent.putExtra("student", s); | ||
185 | intent.putExtra("id", data.getId()); | ||
186 | intent.putExtra("grade", data.getGrade()); | ||
187 | intent.putExtra("subject", data.getSubject()); | ||
188 | String name1 = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(data.uploadTime); | ||
189 | intent.putExtra("name", name1); | ||
190 | startActivity(intent); | ||
191 | } | ||
176 | }); | 192 | }); |
177 | binding.rvMain.setAdapter(errorAdapter); | 193 | binding.rvMain.setAdapter(errorAdapter); |
178 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 194 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
179 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 195 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
180 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 196 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
181 | @Override | 197 | @Override |
182 | public void onTabSelected(TabLayout.Tab tab) { | 198 | public void onTabSelected(TabLayout.Tab tab) { |
183 | if (tab.getPosition() == 0) { | 199 | if (tab.getPosition() == 0) { |
184 | binding.rvMain.setAdapter(errorAdapter); | 200 | binding.rvMain.setAdapter(errorAdapter); |
185 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 201 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
186 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 202 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
187 | binding.tvListTitle.setText("最近错题"); | 203 | binding.tvListTitle.setText("最近错题"); |
188 | binding.tvEmpty.setText("暂无错题~"); | 204 | binding.tvEmpty.setText("暂无错题~"); |
189 | } else { | 205 | } else { |
190 | binding.rvMain.setAdapter(homeworkAdapter); | 206 | binding.rvMain.setAdapter(homeworkAdapter); |
191 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); | 207 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); |
192 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); | 208 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); |
193 | binding.tvListTitle.setText("最近作业"); | 209 | binding.tvListTitle.setText("最近作业"); |
194 | binding.tvEmpty.setText("暂无作业~"); | 210 | binding.tvEmpty.setText("暂无作业~"); |
195 | } | 211 | } |
196 | } | 212 | } |
197 | @Override | 213 | @Override |
198 | public void onTabUnselected(TabLayout.Tab tab) { | 214 | public void onTabUnselected(TabLayout.Tab tab) { |
199 | } | 215 | } |
200 | @Override | 216 | @Override |
201 | public void onTabReselected(TabLayout.Tab tab) { | 217 | public void onTabReselected(TabLayout.Tab tab) { |
202 | } | 218 | } |
203 | }); | 219 | }); |
204 | } | 220 | } |
205 | 221 | ||
206 | private void takePhoto(int type) { | 222 | private void takePhoto(int type) { |
207 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 223 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
208 | XXPermissions.with(getContext()) | 224 | XXPermissions.with(getContext()) |
209 | // 申请多个权限 | 225 | // 申请多个权限 |
210 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 226 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
211 | @Override | 227 | @Override |
212 | public void onGranted(List<String> permissions, boolean all) { | 228 | public void onGranted(List<String> permissions, boolean all) { |
213 | if (all) { | 229 | if (all) { |
214 | //开启扫码界面 | 230 | //开启扫码界面 |
215 | showButtonDialog(type); | 231 | showButtonDialog(type); |
216 | } else { | 232 | } else { |
217 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 233 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
218 | } | 234 | } |
219 | } | 235 | } |
220 | 236 | ||
221 | @Override | 237 | @Override |
222 | public void onDenied(List<String> permissions, boolean never) { | 238 | public void onDenied(List<String> permissions, boolean never) { |
223 | XXPermissions.startPermissionActivity(getContext(), permissions); | 239 | XXPermissions.startPermissionActivity(getContext(), permissions); |
224 | } | 240 | } |
225 | }); | 241 | }); |
226 | } else { | 242 | } else { |
227 | showButtonDialog(type); | 243 | showButtonDialog(type); |
228 | } | 244 | } |
229 | } | 245 | } |
230 | 246 | ||
231 | private void showButtonDialog(int type) { | 247 | private void showButtonDialog(int type) { |
232 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 248 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
233 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 249 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
234 | dialog.setContentView(bottomView); | 250 | dialog.setContentView(bottomView); |
235 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 251 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
236 | @Override | 252 | @Override |
237 | public void onClick(View view) { | 253 | public void onClick(View view) { |
238 | dialog.dismiss(); | 254 | dialog.dismiss(); |
239 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 255 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
240 | //确保有相机来处理Intent | 256 | //确保有相机来处理Intent |
241 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 257 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
242 | File photoFile = new File(filePath); | 258 | File photoFile = new File(filePath); |
243 | 259 | ||
244 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 260 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
245 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); | 261 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
246 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 262 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
247 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 263 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
248 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); | 264 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
249 | } | 265 | } |
250 | }); | 266 | }); |
251 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 267 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
252 | @Override | 268 | @Override |
253 | public void onClick(View view) { | 269 | public void onClick(View view) { |
254 | dialog.dismiss(); | 270 | dialog.dismiss(); |
255 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 271 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
256 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) | 272 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
257 | .multiSelect(true) //是否多选 | 273 | .multiSelect(true) //是否多选 |
258 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 274 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
259 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 275 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
260 | .maxImageSelectable(5) //图片可选择数 | 276 | .maxImageSelectable(5) //图片可选择数 |
261 | .maxHeight(1920) //图片最大高度 | 277 | .maxHeight(1920) //图片最大高度 |
262 | .maxWidth(1920) //图片最大宽度 | 278 | .maxWidth(1920) //图片最大宽度 |
263 | .maxImageSize(3) //图片最大大小Mb | 279 | .maxImageSize(3) //图片最大大小Mb |
264 | .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(); | 280 | .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(); |
265 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 281 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
266 | 282 | ||
267 | } | 283 | } |
268 | }); | 284 | }); |
269 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 285 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
270 | @Override | 286 | @Override |
271 | public void onClick(View view) { | 287 | public void onClick(View view) { |
272 | dialog.dismiss(); | 288 | dialog.dismiss(); |
273 | } | 289 | } |
274 | }); | 290 | }); |
275 | dialog.show(); | 291 | dialog.show(); |
276 | } | 292 | } |
277 | 293 | ||
278 | @SuppressLint("CheckResult") | 294 | @SuppressLint("CheckResult") |
279 | protected void getHomework(String subject) { | 295 | protected void getHomework(String subject) { |
280 | if (studentBean == null) return; | 296 | if (studentBean == null) return; |
281 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 297 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
282 | .subscribeOn(Schedulers.io()) | 298 | .subscribeOn(Schedulers.io()) |
283 | .observeOn(AndroidSchedulers.mainThread()) | 299 | .observeOn(AndroidSchedulers.mainThread()) |
284 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 300 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
285 | .map(ResponseResult::getData) | 301 | .map(ResponseResult::getData) |
286 | .toObservable() | 302 | .toObservable() |
287 | .concatMap(Observable::fromIterable) | 303 | .concatMap(Observable::fromIterable) |
288 | .filter(data -> subject.equals(data.getSubject())) | 304 | .filter(data -> subject.equals(data.getSubject())) |
289 | .filter(data -> data.getRight() == null) | 305 | //.filter(data -> data.getRight() == null) |
306 | .take(5) | ||
290 | .toList() | 307 | .toList() |
291 | .subscribe((data, th) -> { | 308 | .subscribe((data, th) -> { |
292 | if (th != null) th.printStackTrace(); | 309 | if (th != null) th.printStackTrace(); |
293 | homeworkAdapter.setNewData(data); | 310 | homeworkAdapter.setNewData(data); |
294 | if (binding.tabLayout.getSelectedTabPosition() == 1) { | 311 | if (binding.tabLayout.getSelectedTabPosition() == 1) { |
295 | binding.rvMain.setVisibility(data == null || data.isEmpty() ? View.GONE : View.VISIBLE); | 312 | binding.rvMain.setVisibility(data == null || data.isEmpty() ? View.GONE : View.VISIBLE); |
296 | binding.llEmpty.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE); | 313 | binding.llEmpty.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE); |
297 | } | 314 | } |
298 | }); | 315 | }); |
299 | } | 316 | } |
300 | 317 | ||
301 | private void getError(String subject) { | 318 | private void getError(String subject) { |
302 | if (studentBean == null) { | 319 | if (studentBean == null) { |
303 | return; | 320 | return; |
304 | } | 321 | } |
305 | Map<String, Object> map = new HashMap<>(); | 322 | Map<String, Object> map = new HashMap<>(); |
306 | map.put("subject", subject); | 323 | map.put("subject", subject); |
307 | map.put("stuId", studentBean.getStuId()); | 324 | map.put("stuId", studentBean.getStuId()); |
308 | map.put("pageSize", 5); | 325 | map.put("pageSize", 5); |
309 | map.put("pageNum", 1); | 326 | map.put("pageNum", 1); |
310 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 327 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
311 | @Override | 328 | @Override |
312 | public void onSubscribe(Disposable d) { | 329 | public void onSubscribe(Disposable d) { |
313 | } | 330 | } |
314 | @Override | 331 | @Override |
315 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 332 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
316 | if (result.getData() != null && result.getCode() == 200) { | 333 | if (result.getData() != null && result.getCode() == 200) { |
317 | List<TopicBean> topicBeans = result.getData().getList(); | 334 | List<TopicBean> topicBeans = result.getData().getList(); |
318 | errorAdapter.refresh(topicBeans); | 335 | errorAdapter.refresh(topicBeans); |
319 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 336 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
320 | if (topicBeans.size() > 0) { | 337 | if (topicBeans.size() > 0) { |
321 | getBinding().rvMain.setVisibility(View.VISIBLE); | 338 | getBinding().rvMain.setVisibility(View.VISIBLE); |
322 | getBinding().llEmpty.setVisibility(View.GONE); | 339 | getBinding().llEmpty.setVisibility(View.GONE); |
323 | } else { | 340 | } else { |
324 | getBinding().rvMain.setVisibility(View.GONE); | 341 | getBinding().rvMain.setVisibility(View.GONE); |
325 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 342 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
326 | } | 343 | } |
327 | } | 344 | } |
328 | } | 345 | } |
329 | } | 346 | } |
330 | @Override | 347 | @Override |
331 | public void onError(Throwable e) { | 348 | public void onError(Throwable e) { |
332 | e.printStackTrace(); | 349 | e.printStackTrace(); |
333 | } | 350 | } |
334 | @Override | 351 | @Override |
335 | public void onComplete() { | 352 | public void onComplete() { |
336 | } | 353 | } |
337 | }); | 354 | }); |
338 | } | 355 | } |
339 | 356 | ||
340 | @Override | 357 | @Override |
341 | public void onResume() { | 358 | public void onResume() { |
342 | super.onResume(); | 359 | super.onResume(); |
343 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 360 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
344 | getError(subStr); | 361 | getError(subStr); |
345 | getHomework(subStr); | 362 | getHomework(subStr); |
346 | } | 363 | } |
347 | 364 | ||
348 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 365 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
349 | int type; | 366 | int type; |
350 | public HandlerCallBack(int type) { | 367 | public HandlerCallBack(int type) { |
351 | this.type = type; | 368 | this.type = type; |
352 | } | 369 | } |
353 | 370 | ||
354 | private String TAG = "---ImagePicker---"; | 371 | private String TAG = "---ImagePicker---"; |
355 | List<ImageInfo> photoList = new ArrayList<>(); | 372 | List<ImageInfo> photoList = new ArrayList<>(); |
356 | 373 | ||
357 | @Override | 374 | @Override |
358 | public void onStart() { | 375 | public void onStart() { |
359 | Log.i(TAG, "onStart: 开启"); | 376 | Log.i(TAG, "onStart: 开启"); |
360 | } | 377 | } |
361 | 378 | ||
362 | @Override | 379 | @Override |
363 | public void onSuccess(List<ImageInfo> photoList) { | 380 | public void onSuccess(List<ImageInfo> photoList) { |
364 | this.photoList = photoList; | 381 | this.photoList = photoList; |
365 | Log.i(TAG, "onSuccess: 返回数据"); | 382 | Log.i(TAG, "onSuccess: 返回数据"); |
366 | } | 383 | } |
367 | 384 | ||
368 | @Override | 385 | @Override |
369 | public void onCancel() { | 386 | public void onCancel() { |
370 | Log.i(TAG, "onCancel: 取消"); | 387 | Log.i(TAG, "onCancel: 取消"); |
371 | } | 388 | } |
372 | 389 | ||
373 | @Override | 390 | @Override |
374 | public void onFinish(List<ImageInfo> selectImage) { | 391 | public void onFinish(List<ImageInfo> selectImage) { |
375 | if (selectImage.size() == photoList.size()) { | 392 | if (selectImage.size() == photoList.size()) { |
376 | ArrayList<String> strings = new ArrayList<>(); | 393 | ArrayList<String> strings = new ArrayList<>(); |
377 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 394 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
378 | for (ImageInfo imageInfo : selectImage) { | 395 | for (ImageInfo imageInfo : selectImage) { |
379 | strings.add(imageInfo.getPath()); | 396 | strings.add(imageInfo.getPath()); |
380 | } | 397 | } |
381 | intent.putStringArrayListExtra("images", strings); | 398 | intent.putStringArrayListExtra("images", strings); |
382 | intent.putExtra("type", type); | 399 | intent.putExtra("type", type); |
383 | startActivity(intent); | 400 | startActivity(intent); |
384 | } | 401 | } |
385 | } | 402 | } |
386 | 403 | ||
387 | @Override | 404 | @Override |
388 | public void onError() { | 405 | public void onError() { |
389 | Log.i(TAG, "onError: 出错"); | 406 | Log.i(TAG, "onError: 出错"); |
390 | } | 407 | } |
391 | } | 408 | } |
392 | 409 | ||
393 | @Override | 410 | @Override |
394 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 411 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
395 | super.onActivityResult(requestCode, resultCode, data); | 412 | super.onActivityResult(requestCode, resultCode, data); |
396 | if (resultCode != RESULT_OK) return; | 413 | if (resultCode != RESULT_OK) return; |
397 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { | 414 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { |
398 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 415 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
399 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 416 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
400 | CommonUtil.saveBitmapToUri(b, path); | 417 | CommonUtil.saveBitmapToUri(b, path); |
401 | ArrayList<String> strings = new ArrayList<>(); | 418 | ArrayList<String> strings = new ArrayList<>(); |
402 | Intent intent = new Intent(getContext(), ImageActivity.class); | 419 | Intent intent = new Intent(getContext(), ImageActivity.class); |
403 | strings.add(path); | 420 | strings.add(path); |
404 | intent.putStringArrayListExtra("images", strings); | 421 | intent.putStringArrayListExtra("images", strings); |
405 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); | 422 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); |
406 | startActivity(intent); | 423 | startActivity(intent); |
407 | } | 424 | } |
408 | } | 425 | } |
409 | } | 426 | } |
410 | 427 |