Commit 484570f5e69ace351cf39d90919abe8318f8e5ad
1 parent
66afddedba
Exists in
master
BUG修改
Showing
19 changed files
with
447 additions
and
69 deletions
Show diff stats
app/src/main/AndroidManifest.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
4 | package="com.hjx.parent"> | 4 | package="com.hjx.parent"> |
5 | 5 | ||
6 | 6 | ||
7 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | 7 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> |
8 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> | 8 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> |
9 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> | 9 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> |
10 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> | 10 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> |
11 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> | 11 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> |
12 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | 12 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
13 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | 13 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
14 | <uses-permission android:name="android.permission.INTERNET" /> | 14 | <uses-permission android:name="android.permission.INTERNET" /> |
15 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | 15 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> |
16 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 16 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
17 | 17 | ||
18 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | 18 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> |
19 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 19 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
20 | <uses-permission android:name="android.permission.WAKE_LOCK" /> | 20 | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
21 | <uses-permission android:name="android.permission.CAMERA" /> | 21 | <uses-permission android:name="android.permission.CAMERA" /> |
22 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | 22 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> |
23 | <uses-permission android:name="android.permission.VIBRATE" /> | 23 | <uses-permission android:name="android.permission.VIBRATE" /> |
24 | <uses-permission | 24 | <uses-permission |
25 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" | 25 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" |
26 | tools:ignore="ScopedStorage" /> | 26 | tools:ignore="ScopedStorage" /> |
27 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> | 27 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> |
28 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> | 28 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> |
29 | 29 | ||
30 | <uses-permission | 30 | <uses-permission |
31 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | 31 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" |
32 | tools:ignore="ScopedStorage" /> | 32 | tools:ignore="ScopedStorage" /> |
33 | 33 | ||
34 | <application | 34 | <application |
35 | android:name=".App" | 35 | android:name=".App" |
36 | android:allowBackup="true" | 36 | android:allowBackup="true" |
37 | android:icon="@mipmap/icon" | 37 | android:icon="@mipmap/icon" |
38 | android:label="@string/app_name" | 38 | android:label="@string/app_name" |
39 | android:networkSecurityConfig="@xml/network_security_config" | 39 | android:networkSecurityConfig="@xml/network_security_config" |
40 | android:supportsRtl="true" | 40 | android:supportsRtl="true" |
41 | android:theme="@style/Theme.Parent"> | 41 | android:theme="@style/Theme.Parent"> |
42 | <activity | 42 | <activity |
43 | android:name=".LoginActivity" | 43 | android:name=".LoginActivity" |
44 | android:exported="true" | 44 | android:exported="true" |
45 | android:screenOrientation="portrait" | ||
45 | android:theme="@style/ThemeSplash"> | 46 | android:theme="@style/ThemeSplash"> |
46 | <intent-filter> | 47 | <intent-filter> |
47 | <action android:name="android.intent.action.MAIN" /> | 48 | <action android:name="android.intent.action.MAIN" /> |
48 | <category android:name="android.intent.category.LAUNCHER" /> | 49 | <category android:name="android.intent.category.LAUNCHER" /> |
49 | </intent-filter> | 50 | </intent-filter> |
50 | </activity> | 51 | </activity> |
51 | <activity | 52 | <activity |
52 | android:name=".MainActivity" | 53 | android:name=".MainActivity" |
53 | android:launchMode="singleTask" | 54 | android:launchMode="singleTask" |
55 | android:screenOrientation="portrait" | ||
54 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 56 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
55 | <activity | 57 | <activity |
56 | android:name=".RegisterActivity" | 58 | android:name=".RegisterActivity" |
59 | android:screenOrientation="portrait" | ||
57 | android:theme="@style/ThemeSplash" /> | 60 | android:theme="@style/ThemeSplash" /> |
58 | <activity | 61 | <activity |
59 | android:name=".UserActivity" | 62 | android:name=".UserActivity" |
63 | android:screenOrientation="portrait" | ||
60 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 64 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
61 | <activity | 65 | <activity |
62 | android:name=".YinsiActivity" | 66 | android:name=".YinsiActivity" |
67 | android:screenOrientation="portrait" | ||
63 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 68 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
64 | <activity | 69 | <activity |
65 | android:name=".QRActivity" | 70 | android:name=".QRActivity" |
71 | android:screenOrientation="portrait" | ||
66 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
67 | <activity | 73 | <activity |
68 | android:name=".AddStudentActivity" | 74 | android:name=".AddStudentActivity" |
75 | android:screenOrientation="portrait" | ||
69 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 76 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
70 | <activity | 77 | <activity |
71 | android:name=".NickActivity" | 78 | android:name=".NickActivity" |
79 | android:screenOrientation="portrait" | ||
72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 80 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
73 | <activity | 81 | <activity |
74 | android:name=".SexActivity" | 82 | android:name=".SexActivity" |
83 | android:screenOrientation="portrait" | ||
75 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
76 | <activity | 85 | <activity |
77 | android:name=".NianActivity" | 86 | android:name=".NianActivity" |
87 | android:screenOrientation="portrait" | ||
78 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 88 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
79 | <activity | 89 | <activity |
80 | android:name=".ShenActivity" | 90 | android:name=".ShenActivity" |
91 | android:screenOrientation="portrait" | ||
81 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 92 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
82 | <activity | 93 | <activity |
83 | android:name=".UserAgreementActivity" | 94 | android:name=".UserAgreementActivity" |
95 | android:screenOrientation="portrait" | ||
84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 96 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
85 | <activity | 97 | <activity |
86 | android:name=".AccountActivity" | 98 | android:name=".AccountActivity" |
99 | android:screenOrientation="portrait" | ||
87 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
88 | 101 | ||
89 | <activity | 102 | <activity |
90 | android:name=".ChangePwdActivity" | 103 | android:name=".ChangePwdActivity" |
104 | android:screenOrientation="portrait" | ||
91 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 105 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
92 | <activity | 106 | <activity |
93 | android:name=".EditStudentActivity" | 107 | android:name=".EditStudentActivity" |
108 | android:screenOrientation="portrait" | ||
94 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
95 | <activity | 110 | <activity |
96 | android:name=".ChooseActivity" | 111 | android:name=".ChooseActivity" |
112 | android:screenOrientation="portrait" | ||
97 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 113 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
98 | <activity | 114 | <activity |
99 | android:name=".AddTeacherActivity" | 115 | android:name=".AddTeacherActivity" |
116 | android:screenOrientation="portrait" | ||
100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 117 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
101 | <activity | 118 | <activity |
102 | android:name=".ErrorBookActivity" | 119 | android:name=".ErrorBookActivity" |
120 | android:screenOrientation="portrait" | ||
103 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
104 | <activity | 122 | <activity |
105 | android:name=".ImageActivity" | 123 | android:name=".ImageActivity" |
124 | android:screenOrientation="portrait" | ||
106 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 125 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
107 | <activity | 126 | <activity |
108 | android:name=".ImageEditActivity" | 127 | android:name=".ImageEditActivity" |
128 | android:screenOrientation="portrait" | ||
109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 129 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
110 | <activity | 130 | <activity |
111 | android:name=".ImageSelectActivity" | 131 | android:name=".ImageSelectActivity" |
132 | android:screenOrientation="portrait" | ||
112 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 133 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
113 | <activity | 134 | <activity |
114 | android:name=".AddSuccessActivity" | 135 | android:name=".AddSuccessActivity" |
136 | android:screenOrientation="portrait" | ||
115 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 137 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
116 | <activity | 138 | <activity |
117 | android:name=".ErrorListActivity" | 139 | android:name=".ErrorListActivity" |
140 | android:screenOrientation="portrait" | ||
118 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 141 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
119 | <activity | 142 | <activity |
120 | android:name=".ErrorDetailActivity" | 143 | android:name=".ErrorDetailActivity" |
144 | android:screenOrientation="portrait" | ||
121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 145 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
122 | <activity | 146 | <activity |
123 | android:name=".TeacherChooseActivity" | 147 | android:name=".TeacherChooseActivity" |
148 | android:screenOrientation="portrait" | ||
124 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 149 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
125 | <activity | 150 | <activity |
126 | android:name=".TeacherMainActivity" | 151 | android:name=".TeacherMainActivity" |
152 | android:screenOrientation="portrait" | ||
127 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 153 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
128 | 154 | ||
129 | <provider | 155 | <provider |
130 | android:name="androidx.core.content.FileProvider" | 156 | android:name="androidx.core.content.FileProvider" |
131 | android:authorities="com.hjx.parent.fileprovider" | 157 | android:authorities="com.hjx.parent.fileprovider" |
132 | android:exported="false" | 158 | android:exported="false" |
133 | android:grantUriPermissions="true" | 159 | android:grantUriPermissions="true" |
134 | tools:replace="android:authorities"> | 160 | tools:replace="android:authorities"> |
135 | <meta-data | 161 | <meta-data |
136 | android:name="android.support.FILE_PROVIDER_PATHS" | 162 | android:name="android.support.FILE_PROVIDER_PATHS" |
137 | android:resource="@xml/file_provider_paths" | 163 | android:resource="@xml/file_provider_paths" |
138 | tools:replace="android:resource" /> | 164 | tools:replace="android:resource" /> |
139 | </provider> | 165 | </provider> |
140 | </application> | 166 | </application> |
141 | 167 | ||
142 | </manifest> | 168 | </manifest> |
app/src/main/java/com/hjx/parent/AddSuccessActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
5 | import android.graphics.BitmapFactory; | 5 | import android.graphics.BitmapFactory; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
8 | import android.provider.MediaStore; | 8 | import android.provider.MediaStore; |
9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
10 | import android.util.Log; | 10 | import android.util.Log; |
11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
12 | import android.view.View; | 12 | import android.view.View; |
13 | 13 | ||
14 | import androidx.annotation.Nullable; | 14 | import androidx.annotation.Nullable; |
15 | import androidx.core.content.FileProvider; | 15 | import androidx.core.content.FileProvider; |
16 | 16 | ||
17 | import com.hjx.parent.databinding.ActivityAddSuccessBinding; | 17 | import com.hjx.parent.databinding.ActivityAddSuccessBinding; |
18 | import com.prws.common.utils.BitmapUtils; | 18 | import com.prws.common.utils.BitmapUtils; |
19 | import com.prws.common.utils.CommonUtil; | 19 | import com.prws.common.utils.CommonUtil; |
20 | import com.prws.common.utils.dialog.MyButtomDialog; | 20 | import com.prws.common.utils.dialog.MyButtomDialog; |
21 | import com.zhangteng.imagepicker.bean.ImageInfo; | 21 | import com.zhangteng.imagepicker.bean.ImageInfo; |
22 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 22 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
23 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 23 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
24 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 24 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
25 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 25 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
26 | import com.zhangteng.utils.IHandlerCallBack; | 26 | import com.zhangteng.utils.IHandlerCallBack; |
27 | 27 | ||
28 | import java.io.File; | 28 | import java.io.File; |
29 | import java.util.ArrayList; | 29 | import java.util.ArrayList; |
30 | import java.util.List; | 30 | import java.util.List; |
31 | 31 | ||
32 | public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> { | 32 | public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> { |
33 | private int REQUEST_CODE_IMAGE = 123; | 33 | private int REQUEST_CODE_IMAGE = 123; |
34 | private String filePath; | 34 | private String filePath; |
35 | 35 | ||
36 | @Override | 36 | @Override |
37 | public void initView(Bundle savedInstanceState) { | 37 | public void initView(Bundle savedInstanceState) { |
38 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 38 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
39 | @Override | 39 | @Override |
40 | public void onClick(View v) { | 40 | public void onClick(View v) { |
41 | finish(); | 41 | finish(); |
42 | } | 42 | } |
43 | }); | 43 | }); |
44 | binding.tvAdd.setOnClickListener(new View.OnClickListener() { | 44 | binding.tvAdd.setOnClickListener(new View.OnClickListener() { |
45 | @Override | 45 | @Override |
46 | public void onClick(View v) { | 46 | public void onClick(View v) { |
47 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 47 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
48 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 48 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
49 | dialog.setContentView(bottomView); | 49 | dialog.setContentView(bottomView); |
50 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 50 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
51 | @Override | 51 | @Override |
52 | public void onClick(View view) { | 52 | public void onClick(View view) { |
53 | dialog.dismiss(); | 53 | dialog.dismiss(); |
54 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 54 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
55 | //确保有相机来处理Intent | 55 | //确保有相机来处理Intent |
56 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 56 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
57 | File photoFile = new File(filePath); | 57 | File photoFile = new File(filePath); |
58 | if (photoFile != null) { | 58 | if (photoFile != null) { |
59 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 59 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
60 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 60 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
61 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 61 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
62 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 62 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
63 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 63 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | }); | 66 | }); |
67 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 67 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
68 | @Override | 68 | @Override |
69 | public void onClick(View view) { | 69 | public void onClick(View view) { |
70 | dialog.dismiss(); | 70 | dialog.dismiss(); |
71 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 71 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
72 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 72 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
73 | .multiSelect(true) //是否多选 | 73 | .multiSelect(true) //是否多选 |
74 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 74 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
75 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 75 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
76 | .maxImageSelectable(9) //图片可选择数 | 76 | .maxImageSelectable(5) //图片可选择数 |
77 | .maxHeight(1920) //图片最大高度 | 77 | .maxHeight(1920) //图片最大高度 |
78 | .maxWidth(1920) //图片最大宽度 | 78 | .maxWidth(1920) //图片最大宽度 |
79 | .maxImageSize(10) //图片最大大小Mb | 79 | .maxImageSize(3) //图片最大大小Mb |
80 | .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(); | 80 | .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(); |
81 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(AddSuccessActivity.this); | 81 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(AddSuccessActivity.this); |
82 | 82 | ||
83 | } | 83 | } |
84 | }); | 84 | }); |
85 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 85 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
86 | @Override | 86 | @Override |
87 | public void onClick(View view) { | 87 | public void onClick(View view) { |
88 | dialog.dismiss(); | 88 | dialog.dismiss(); |
89 | } | 89 | } |
90 | }); | 90 | }); |
91 | dialog.show(); | 91 | dialog.show(); |
92 | } | 92 | } |
93 | }); | 93 | }); |
94 | binding.tvBook.setOnClickListener(new View.OnClickListener() { | 94 | binding.tvBook.setOnClickListener(new View.OnClickListener() { |
95 | @Override | 95 | @Override |
96 | public void onClick(View v) { | 96 | public void onClick(View v) { |
97 | startActivity(new Intent(context, ErrorListActivity.class)); | 97 | startActivity(new Intent(context, ErrorListActivity.class)); |
98 | } | 98 | } |
99 | }); | 99 | }); |
100 | } | 100 | } |
101 | 101 | ||
102 | @Override | 102 | @Override |
103 | protected ActivityAddSuccessBinding getViewBinding() { | 103 | protected ActivityAddSuccessBinding getViewBinding() { |
104 | return ActivityAddSuccessBinding.inflate(getLayoutInflater()); | 104 | return ActivityAddSuccessBinding.inflate(getLayoutInflater()); |
105 | } | 105 | } |
106 | 106 | ||
107 | @Override | 107 | @Override |
108 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 108 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
109 | super.onActivityResult(requestCode, resultCode, data); | 109 | super.onActivityResult(requestCode, resultCode, data); |
110 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 110 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
111 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 111 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
112 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 112 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
113 | CommonUtil.saveBitmapToUri(b, path); | 113 | CommonUtil.saveBitmapToUri(b, path); |
114 | List<String> strings = new ArrayList<>(); | 114 | List<String> strings = new ArrayList<>(); |
115 | Intent intent = new Intent(context, ImageActivity.class); | 115 | Intent intent = new Intent(context, ImageActivity.class); |
116 | strings.add(path); | 116 | strings.add(path); |
117 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 117 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
118 | startActivity(intent); | 118 | startActivity(intent); |
119 | finish(); | 119 | finish(); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 123 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
124 | private String TAG = "---ImagePicker---"; | 124 | private String TAG = "---ImagePicker---"; |
125 | List<ImageInfo> photoList = new ArrayList<>(); | 125 | List<ImageInfo> photoList = new ArrayList<>(); |
126 | 126 | ||
127 | @Override | 127 | @Override |
128 | public void onStart() { | 128 | public void onStart() { |
129 | Log.i(TAG, "onStart: 开启"); | 129 | Log.i(TAG, "onStart: 开启"); |
130 | } | 130 | } |
131 | 131 | ||
132 | @Override | 132 | @Override |
133 | public void onSuccess(List<ImageInfo> photoList) { | 133 | public void onSuccess(List<ImageInfo> photoList) { |
134 | this.photoList = photoList; | 134 | this.photoList = photoList; |
135 | Log.i(TAG, "onSuccess: 返回数据"); | 135 | Log.i(TAG, "onSuccess: 返回数据"); |
136 | } | 136 | } |
137 | 137 | ||
138 | @Override | 138 | @Override |
139 | public void onCancel() { | 139 | public void onCancel() { |
140 | Log.i(TAG, "onCancel: 取消"); | 140 | Log.i(TAG, "onCancel: 取消"); |
141 | } | 141 | } |
142 | 142 | ||
143 | @Override | 143 | @Override |
144 | public void onFinish(List<ImageInfo> selectImage) { | 144 | public void onFinish(List<ImageInfo> selectImage) { |
145 | if (selectImage.size() == photoList.size()) { | 145 | if (selectImage.size() == photoList.size()) { |
146 | List<String> strings = new ArrayList<>(); | 146 | List<String> strings = new ArrayList<>(); |
147 | Intent intent = new Intent(context, ImageActivity.class); | 147 | Intent intent = new Intent(context, ImageActivity.class); |
148 | for (ImageInfo imageInfo : selectImage) { | 148 | for (ImageInfo imageInfo : selectImage) { |
149 | strings.add(imageInfo.getPath()); | 149 | strings.add(imageInfo.getPath()); |
150 | } | 150 | } |
151 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 151 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
152 | startActivity(intent); | 152 | startActivity(intent); |
153 | finish(); | 153 | finish(); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | @Override | 157 | @Override |
158 | public void onError() { | 158 | public void onError() { |
159 | Log.i(TAG, "onError: 出错"); | 159 | Log.i(TAG, "onError: 出错"); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 |
app/src/main/java/com/hjx/parent/ErrorBookActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
5 | import android.graphics.BitmapFactory; | 5 | import android.graphics.BitmapFactory; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
8 | import android.provider.MediaStore; | 8 | import android.provider.MediaStore; |
9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
10 | import android.util.Log; | 10 | import android.util.Log; |
11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
12 | import android.view.View; | 12 | import android.view.View; |
13 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
14 | import android.widget.LinearLayout; | 14 | import android.widget.LinearLayout; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import androidx.annotation.NonNull; | 17 | import androidx.annotation.NonNull; |
18 | import androidx.annotation.Nullable; | 18 | import androidx.annotation.Nullable; |
19 | import androidx.core.content.FileProvider; | 19 | import androidx.core.content.FileProvider; |
20 | import androidx.recyclerview.widget.LinearLayoutManager; | 20 | import androidx.recyclerview.widget.LinearLayoutManager; |
21 | import androidx.recyclerview.widget.RecyclerView; | 21 | import androidx.recyclerview.widget.RecyclerView; |
22 | 22 | ||
23 | import com.chad.library.adapter.base.BaseQuickAdapter; | 23 | import com.chad.library.adapter.base.BaseQuickAdapter; |
24 | import com.chad.library.adapter.base.BaseViewHolder; | 24 | import com.chad.library.adapter.base.BaseViewHolder; |
25 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
26 | import com.hjq.permissions.OnPermissionCallback; | 26 | import com.hjq.permissions.OnPermissionCallback; |
27 | import com.hjq.permissions.Permission; | 27 | import com.hjq.permissions.Permission; |
28 | import com.hjq.permissions.XXPermissions; | 28 | import com.hjq.permissions.XXPermissions; |
29 | import com.hjx.parent.adapter.ErrorAdapter; | 29 | import com.hjx.parent.adapter.ErrorAdapter; |
30 | import com.hjx.parent.bean.StudentBean; | 30 | import com.hjx.parent.bean.StudentBean; |
31 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | 31 | import com.hjx.parent.databinding.ActivityErrorBookBinding; |
32 | import com.prws.common.base.BasePresenter; | 32 | import com.prws.common.base.BasePresenter; |
33 | import com.prws.common.bean.ImageBean; | 33 | import com.prws.common.bean.ImageBean; |
34 | import com.prws.common.bean.PageInfo; | 34 | import com.prws.common.bean.PageInfo; |
35 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.bean.TopicBean; | 36 | import com.prws.common.bean.TopicBean; |
37 | import com.prws.common.net.NetWorks; | 37 | import com.prws.common.net.NetWorks; |
38 | import com.prws.common.utils.BitmapUtils; | 38 | import com.prws.common.utils.BitmapUtils; |
39 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
40 | import com.prws.common.utils.SharedPreferencesUtil; | 40 | import com.prws.common.utils.SharedPreferencesUtil; |
41 | import com.prws.common.utils.dialog.MyButtomDialog; | 41 | import com.prws.common.utils.dialog.MyButtomDialog; |
42 | import com.zhangteng.imagepicker.bean.ImageInfo; | 42 | import com.zhangteng.imagepicker.bean.ImageInfo; |
43 | import com.zhangteng.imagepicker.callback.HandlerCallBack; | 43 | import com.zhangteng.imagepicker.callback.HandlerCallBack; |
44 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 44 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
45 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 45 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
46 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 46 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
47 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 47 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
48 | import com.zhangteng.utils.IHandlerCallBack; | 48 | import com.zhangteng.utils.IHandlerCallBack; |
49 | 49 | ||
50 | import java.io.File; | 50 | import java.io.File; |
51 | import java.util.ArrayList; | 51 | import java.util.ArrayList; |
52 | import java.util.Arrays; | 52 | import java.util.Arrays; |
53 | import java.util.HashMap; | 53 | import java.util.HashMap; |
54 | import java.util.List; | 54 | import java.util.List; |
55 | import java.util.Map; | 55 | import java.util.Map; |
56 | 56 | ||
57 | import io.reactivex.Observer; | 57 | import io.reactivex.Observer; |
58 | import io.reactivex.disposables.Disposable; | 58 | import io.reactivex.disposables.Disposable; |
59 | 59 | ||
60 | public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { | 60 | public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { |
61 | StudentBean studentBean; | 61 | StudentBean studentBean; |
62 | private int subject; | 62 | private int subject; |
63 | private ErrorAdapter adapter; | 63 | private ErrorAdapter adapter; |
64 | private int REQUEST_CODE_IMAGE = 123; | 64 | private int REQUEST_CODE_IMAGE = 123; |
65 | private String filePath; | 65 | private String filePath; |
66 | 66 | ||
67 | @Override | 67 | @Override |
68 | public void initView(Bundle savedInstanceState) { | 68 | public void initView(Bundle savedInstanceState) { |
69 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 69 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
70 | try { | 70 | try { |
71 | studentBean = new Gson().fromJson(student, StudentBean.class); | 71 | studentBean = new Gson().fromJson(student, StudentBean.class); |
72 | } catch (Exception e) { | 72 | } catch (Exception e) { |
73 | 73 | ||
74 | } | 74 | } |
75 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 75 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
76 | @Override | 76 | @Override |
77 | public void onClick(View v) { | 77 | public void onClick(View v) { |
78 | finish(); | 78 | finish(); |
79 | } | 79 | } |
80 | }); | 80 | }); |
81 | binding.rlTakePhoto.post(new Runnable() { | 81 | binding.rlTakePhoto.post(new Runnable() { |
82 | @Override | 82 | @Override |
83 | public void run() { | 83 | public void run() { |
84 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) binding.rlTakePhoto.getLayoutParams(); | 84 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) binding.rlTakePhoto.getLayoutParams(); |
85 | layoutParams.width = CommonUtil.getScreenWidth(context); | 85 | layoutParams.width = CommonUtil.getScreenWidth(context); |
86 | layoutParams.height = CommonUtil.getScreenWidth(context) * 20 / 37; | 86 | layoutParams.height = CommonUtil.getScreenWidth(context) * 20 / 37; |
87 | binding.rlTakePhoto.setLayoutParams(layoutParams); | 87 | binding.rlTakePhoto.setLayoutParams(layoutParams); |
88 | } | 88 | } |
89 | }); | 89 | }); |
90 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { | 90 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { |
91 | @Override | 91 | @Override |
92 | public void onClick(View v) { | 92 | public void onClick(View v) { |
93 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 93 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
94 | XXPermissions.with(context) | 94 | XXPermissions.with(context) |
95 | // 申请多个权限 | 95 | // 申请多个权限 |
96 | .permission(Permission.CAMERA) | 96 | .permission(Permission.CAMERA) |
97 | .request(new OnPermissionCallback() { | 97 | .request(new OnPermissionCallback() { |
98 | @Override | 98 | @Override |
99 | public void onGranted(List<String> permissions, boolean all) { | 99 | public void onGranted(List<String> permissions, boolean all) { |
100 | if (all) { | 100 | if (all) { |
101 | //开启扫码界面 | 101 | //开启扫码界面 |
102 | showButtonDialog(); | 102 | showButtonDialog(); |
103 | } else { | 103 | } else { |
104 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | 104 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | @Override | 108 | @Override |
109 | public void onDenied(List<String> permissions, boolean never) { | 109 | public void onDenied(List<String> permissions, boolean never) { |
110 | XXPermissions.startPermissionActivity(context, permissions); | 110 | XXPermissions.startPermissionActivity(context, permissions); |
111 | } | 111 | } |
112 | }); | 112 | }); |
113 | } else { | 113 | } else { |
114 | showButtonDialog(); | 114 | showButtonDialog(); |
115 | } | 115 | } |
116 | 116 | ||
117 | } | 117 | } |
118 | }); | 118 | }); |
119 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 119 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
120 | @Override | 120 | @Override |
121 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 121 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | @Override | 125 | @Override |
126 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 126 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
127 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 127 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
128 | switch (item.getAdapterPosition()) { | 128 | switch (item.getAdapterPosition()) { |
129 | case 0: | 129 | case 0: |
130 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 130 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
131 | break; | 131 | break; |
132 | case 1: | 132 | case 1: |
133 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 133 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
134 | break; | 134 | break; |
135 | case 2: | 135 | case 2: |
136 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 136 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
137 | break; | 137 | break; |
138 | case 3: | 138 | case 3: |
139 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 139 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
140 | break; | 140 | break; |
141 | case 4: | 141 | case 4: |
142 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 142 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 145 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
146 | layoutParams.width = (CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 30)) / 4; | 146 | layoutParams.width = (CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 30)) / 4; |
147 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 147 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
148 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 148 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
149 | @Override | 149 | @Override |
150 | public void onClick(View v) { | 150 | public void onClick(View v) { |
151 | if (subject != item.getAdapterPosition()) { | 151 | if (subject != item.getAdapterPosition()) { |
152 | subject = item.getAdapterPosition(); | 152 | subject = item.getAdapterPosition(); |
153 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 153 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | }); | 156 | }); |
157 | } | 157 | } |
158 | }; | 158 | }; |
159 | binding.recycleSubject.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); | 159 | binding.recycleSubject.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); |
160 | binding.recycleSubject.setAdapter(adapter); | 160 | binding.recycleSubject.setAdapter(adapter); |
161 | subject = 0; | 161 | subject = 0; |
162 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 162 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
163 | binding.llAll.setOnClickListener(new View.OnClickListener() { | 163 | binding.llAll.setOnClickListener(new View.OnClickListener() { |
164 | @Override | 164 | @Override |
165 | public void onClick(View v) { | 165 | public void onClick(View v) { |
166 | Intent intent = new Intent(context, ErrorListActivity.class); | 166 | Intent intent = new Intent(context, ErrorListActivity.class); |
167 | startActivity(intent); | 167 | startActivity(intent); |
168 | } | 168 | } |
169 | }); | 169 | }); |
170 | } | 170 | } |
171 | 171 | ||
172 | @Override | 172 | @Override |
173 | protected ActivityErrorBookBinding getViewBinding() { | 173 | protected ActivityErrorBookBinding getViewBinding() { |
174 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); | 174 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); |
175 | } | 175 | } |
176 | 176 | ||
177 | private void showButtonDialog() { | 177 | private void showButtonDialog() { |
178 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 178 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
179 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 179 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
180 | dialog.setContentView(bottomView); | 180 | dialog.setContentView(bottomView); |
181 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 181 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
182 | @Override | 182 | @Override |
183 | public void onClick(View view) { | 183 | public void onClick(View view) { |
184 | dialog.dismiss(); | 184 | dialog.dismiss(); |
185 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 185 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
186 | //确保有相机来处理Intent | 186 | //确保有相机来处理Intent |
187 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 187 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
188 | File photoFile = new File(filePath); | 188 | File photoFile = new File(filePath); |
189 | if (photoFile != null) { | 189 | if (photoFile != null) { |
190 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 190 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
191 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 191 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
192 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 192 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
193 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 193 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
194 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 194 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | }); | 197 | }); |
198 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 198 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
199 | @Override | 199 | @Override |
200 | public void onClick(View view) { | 200 | public void onClick(View view) { |
201 | dialog.dismiss(); | 201 | dialog.dismiss(); |
202 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 202 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
203 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 203 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
204 | .multiSelect(true) //是否多选 | 204 | .multiSelect(true) //是否多选 |
205 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 205 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
206 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 206 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
207 | .maxImageSelectable(9) //图片可选择数 | 207 | .maxImageSelectable(5) //图片可选择数 |
208 | .maxHeight(1920) //图片最大高度 | 208 | .maxHeight(1920) //图片最大高度 |
209 | .maxWidth(1920) //图片最大宽度 | 209 | .maxWidth(1920) //图片最大宽度 |
210 | .maxImageSize(10) //图片最大大小Mb | 210 | .maxImageSize(3) //图片最大大小Mb |
211 | .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(); | 211 | .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(); |
212 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); | 212 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); |
213 | 213 | ||
214 | } | 214 | } |
215 | }); | 215 | }); |
216 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 216 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
217 | @Override | 217 | @Override |
218 | public void onClick(View view) { | 218 | public void onClick(View view) { |
219 | dialog.dismiss(); | 219 | dialog.dismiss(); |
220 | } | 220 | } |
221 | }); | 221 | }); |
222 | dialog.show(); | 222 | dialog.show(); |
223 | } | 223 | } |
224 | 224 | ||
225 | private void getError(String subject) { | 225 | private void getError(String subject) { |
226 | if (studentBean != null) { | 226 | if (studentBean != null) { |
227 | Map map = new HashMap(); | 227 | Map map = new HashMap(); |
228 | map.put("subject", subject); | 228 | map.put("subject", subject); |
229 | map.put("stuId", studentBean.getStuId()); | 229 | map.put("stuId", studentBean.getStuId()); |
230 | map.put("pageSize", 5); | 230 | map.put("pageSize", 5); |
231 | map.put("pageNum", 1); | 231 | map.put("pageNum", 1); |
232 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 232 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
233 | @Override | 233 | @Override |
234 | public void onSubscribe(Disposable d) { | 234 | public void onSubscribe(Disposable d) { |
235 | 235 | ||
236 | } | 236 | } |
237 | 237 | ||
238 | @Override | 238 | @Override |
239 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 239 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
240 | if (result.getData() != null && result.getCode() == 200) { | 240 | if (result.getData() != null && result.getCode() == 200) { |
241 | List<TopicBean> topicBeans = result.getData().getList(); | 241 | List<TopicBean> topicBeans = result.getData().getList(); |
242 | loadError(topicBeans); | 242 | loadError(topicBeans); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | @Override | 246 | @Override |
247 | public void onError(Throwable e) { | 247 | public void onError(Throwable e) { |
248 | e.toString(); | 248 | e.toString(); |
249 | } | 249 | } |
250 | 250 | ||
251 | @Override | 251 | @Override |
252 | public void onComplete() { | 252 | public void onComplete() { |
253 | 253 | ||
254 | } | 254 | } |
255 | }); | 255 | }); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | @Override | 259 | @Override |
260 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 260 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
261 | super.onActivityResult(requestCode, resultCode, data); | 261 | super.onActivityResult(requestCode, resultCode, data); |
262 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 262 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
263 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 263 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
264 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 264 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
265 | CommonUtil.saveBitmapToUri(b, path); | 265 | CommonUtil.saveBitmapToUri(b, path); |
266 | List<String> strings = new ArrayList<>(); | 266 | List<String> strings = new ArrayList<>(); |
267 | Intent intent = new Intent(context, ImageActivity.class); | 267 | Intent intent = new Intent(context, ImageActivity.class); |
268 | strings.add(path); | 268 | strings.add(path); |
269 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 269 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
270 | startActivity(intent); | 270 | startActivity(intent); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | private void loadError(List<TopicBean> list) { | 274 | private void loadError(List<TopicBean> list) { |
275 | if (list.size() > 0) { | 275 | if (list.size() > 0) { |
276 | binding.recycleError.setVisibility(View.VISIBLE); | 276 | binding.recycleError.setVisibility(View.VISIBLE); |
277 | binding.llEmpty.setVisibility(View.GONE); | 277 | binding.llEmpty.setVisibility(View.GONE); |
278 | if (adapter != null) { | 278 | if (adapter != null) { |
279 | adapter.refresh(list); | 279 | adapter.refresh(list); |
280 | } else { | 280 | } else { |
281 | adapter = new ErrorAdapter(context, list, false); | 281 | adapter = new ErrorAdapter(context, list, false); |
282 | binding.recycleError.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); | 282 | binding.recycleError.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); |
283 | binding.recycleError.setAdapter(adapter); | 283 | binding.recycleError.setAdapter(adapter); |
284 | } | 284 | } |
285 | } else { | 285 | } else { |
286 | binding.recycleError.setVisibility(View.GONE); | 286 | binding.recycleError.setVisibility(View.GONE); |
287 | binding.llEmpty.setVisibility(View.VISIBLE); | 287 | binding.llEmpty.setVisibility(View.VISIBLE); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | @Override | 291 | @Override |
292 | protected void onResume() { | 292 | protected void onResume() { |
293 | super.onResume(); | 293 | super.onResume(); |
294 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 294 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
295 | } | 295 | } |
296 | 296 | ||
297 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 297 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
298 | private String TAG = "---ImagePicker---"; | 298 | private String TAG = "---ImagePicker---"; |
299 | List<ImageInfo> photoList = new ArrayList<>(); | 299 | List<ImageInfo> photoList = new ArrayList<>(); |
300 | 300 | ||
301 | @Override | 301 | @Override |
302 | public void onStart() { | 302 | public void onStart() { |
303 | Log.i(TAG, "onStart: 开启"); | 303 | Log.i(TAG, "onStart: 开启"); |
304 | } | 304 | } |
305 | 305 | ||
306 | @Override | 306 | @Override |
307 | public void onSuccess(List<ImageInfo> photoList) { | 307 | public void onSuccess(List<ImageInfo> photoList) { |
308 | this.photoList = photoList; | 308 | this.photoList = photoList; |
309 | Log.i(TAG, "onSuccess: 返回数据"); | 309 | Log.i(TAG, "onSuccess: 返回数据"); |
310 | } | 310 | } |
311 | 311 | ||
312 | @Override | 312 | @Override |
313 | public void onCancel() { | 313 | public void onCancel() { |
314 | Log.i(TAG, "onCancel: 取消"); | 314 | Log.i(TAG, "onCancel: 取消"); |
315 | } | 315 | } |
316 | 316 | ||
317 | @Override | 317 | @Override |
318 | public void onFinish(List<ImageInfo> selectImage) { | 318 | public void onFinish(List<ImageInfo> selectImage) { |
319 | if (selectImage.size() == photoList.size()) { | 319 | if (selectImage.size() == photoList.size()) { |
320 | List<String> strings = new ArrayList<>(); | 320 | List<String> strings = new ArrayList<>(); |
321 | Intent intent = new Intent(context, ImageActivity.class); | 321 | Intent intent = new Intent(context, ImageActivity.class); |
322 | for (ImageInfo imageInfo : selectImage) { | 322 | for (ImageInfo imageInfo : selectImage) { |
323 | strings.add(imageInfo.getPath()); | 323 | strings.add(imageInfo.getPath()); |
324 | } | 324 | } |
325 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 325 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
326 | startActivity(intent); | 326 | startActivity(intent); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | @Override | 330 | @Override |
331 | public void onError() { | 331 | public void onError() { |
332 | Log.i(TAG, "onError: 出错"); | 332 | Log.i(TAG, "onError: 出错"); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 |
app/src/main/java/com/hjx/parent/ErrorListActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.DialogInterface; | 4 | import android.content.DialogInterface; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
8 | import android.graphics.Color; | 8 | import android.graphics.Color; |
9 | import android.graphics.drawable.Drawable; | 9 | import android.graphics.drawable.Drawable; |
10 | import android.net.Uri; | 10 | import android.net.Uri; |
11 | import android.os.Bundle; | 11 | import android.os.Bundle; |
12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.util.Log; | 14 | import android.util.Log; |
15 | import android.view.KeyEvent; | 15 | import android.view.KeyEvent; |
16 | import android.view.LayoutInflater; | 16 | import android.view.LayoutInflater; |
17 | import android.view.View; | 17 | import android.view.View; |
18 | import android.widget.CompoundButton; | 18 | import android.widget.CompoundButton; |
19 | import android.widget.RadioButton; | 19 | import android.widget.RadioButton; |
20 | import android.widget.RadioGroup; | 20 | import android.widget.RadioGroup; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import androidx.annotation.Nullable; | 24 | import androidx.annotation.Nullable; |
25 | import androidx.core.content.FileProvider; | 25 | import androidx.core.content.FileProvider; |
26 | import androidx.recyclerview.widget.GridLayoutManager; | 26 | import androidx.recyclerview.widget.GridLayoutManager; |
27 | import androidx.recyclerview.widget.LinearLayoutManager; | 27 | import androidx.recyclerview.widget.LinearLayoutManager; |
28 | import androidx.recyclerview.widget.RecyclerView; | 28 | import androidx.recyclerview.widget.RecyclerView; |
29 | 29 | ||
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.adapter.ErrorAdapter; | 34 | import com.hjx.parent.adapter.ErrorAdapter; |
35 | import com.hjx.parent.adapter.FilterAdapter; | 35 | import com.hjx.parent.adapter.FilterAdapter; |
36 | import com.hjx.parent.adapter.GradeAdapter; | ||
36 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; | 37 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; |
37 | import com.hjx.parent.bean.StudentBean; | 38 | import com.hjx.parent.bean.StudentBean; |
38 | import com.hjx.parent.databinding.ActivityErrorListBinding; | 39 | import com.hjx.parent.databinding.ActivityErrorListBinding; |
39 | import com.hjx.parent.dialog.ErrorEditDialog; | 40 | import com.hjx.parent.dialog.ErrorEditDialog; |
40 | import com.hjx.parent.dialog.TipDialog; | 41 | import com.hjx.parent.dialog.TipDialog; |
41 | import com.prws.common.bean.GradeAndSubject; | 42 | import com.prws.common.bean.GradeAndSubject; |
42 | import com.prws.common.bean.PageInfo; | 43 | import com.prws.common.bean.PageInfo; |
43 | import com.prws.common.bean.ResponseResult; | 44 | import com.prws.common.bean.ResponseResult; |
44 | import com.prws.common.bean.Subject; | 45 | import com.prws.common.bean.Subject; |
45 | import com.prws.common.bean.TopicBean; | 46 | import com.prws.common.bean.TopicBean; |
46 | import com.prws.common.net.NetWorks; | 47 | import com.prws.common.net.NetWorks; |
47 | import com.prws.common.utils.BitmapUtils; | 48 | import com.prws.common.utils.BitmapUtils; |
48 | import com.prws.common.utils.CommonUtil; | 49 | import com.prws.common.utils.CommonUtil; |
49 | import com.prws.common.utils.SharedPreferencesUtil; | 50 | import com.prws.common.utils.SharedPreferencesUtil; |
50 | import com.prws.common.utils.dialog.MyButtomDialog; | 51 | import com.prws.common.utils.dialog.MyButtomDialog; |
51 | import com.zhangteng.imagepicker.bean.ImageInfo; | 52 | import com.zhangteng.imagepicker.bean.ImageInfo; |
52 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 53 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
53 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 54 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
54 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 55 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
55 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 56 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
56 | import com.zhangteng.utils.IHandlerCallBack; | 57 | import com.zhangteng.utils.IHandlerCallBack; |
57 | 58 | ||
58 | import java.io.File; | 59 | import java.io.File; |
59 | import java.util.ArrayList; | 60 | import java.util.ArrayList; |
60 | import java.util.HashMap; | 61 | import java.util.HashMap; |
61 | import java.util.List; | 62 | import java.util.List; |
62 | import java.util.Map; | 63 | import java.util.Map; |
63 | 64 | ||
64 | import io.reactivex.Observer; | 65 | import io.reactivex.Observer; |
65 | import io.reactivex.disposables.Disposable; | 66 | import io.reactivex.disposables.Disposable; |
66 | 67 | ||
67 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { | 68 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { |
68 | private TextView last; | 69 | private TextView last; |
69 | private String subject; | 70 | private String subject; |
70 | private String grade; | 71 | private String grade; |
72 | private String grade1; | ||
71 | private String manger; | 73 | private String manger; |
72 | private String type = "全部"; | 74 | private String type = "全部"; |
73 | private String time = "全部"; | 75 | private String time = "全部"; |
74 | private FilterAdapter filterAdapter; | 76 | private FilterAdapter filterAdapter; |
77 | |||
78 | private GradeAdapter gradeAdapter; | ||
75 | StudentBean studentBean; | 79 | StudentBean studentBean; |
76 | private int page = 1; | 80 | private int page = 1; |
77 | private ErrorAdapter adapter; | 81 | private ErrorAdapter adapter; |
78 | private int total; | 82 | private int total; |
79 | private int REQUEST_CODE_IMAGE = 123; | 83 | private int REQUEST_CODE_IMAGE = 123; |
80 | private String filePath; | 84 | private String filePath; |
81 | 85 | ||
82 | @Override | 86 | @Override |
83 | public void initView(Bundle savedInstanceState) { | 87 | public void initView(Bundle savedInstanceState) { |
84 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 88 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
85 | try { | 89 | try { |
86 | studentBean = new Gson().fromJson(student, StudentBean.class); | 90 | studentBean = new Gson().fromJson(student, StudentBean.class); |
87 | } catch (Exception e) { | 91 | } catch (Exception e) { |
88 | 92 | ||
89 | } | 93 | } |
90 | binding.ivBack.setOnClickListener(this); | 94 | binding.ivBack.setOnClickListener(this); |
91 | binding.tvFilterGrade.setOnClickListener(this); | 95 | binding.tvFilterGrade.setOnClickListener(this); |
92 | binding.tvFilterSubject.setOnClickListener(this); | 96 | binding.tvFilterSubject.setOnClickListener(this); |
93 | binding.tvFilterMore.setOnClickListener(this); | 97 | binding.tvFilterMore.setOnClickListener(this); |
94 | binding.tvFilterManage.setOnClickListener(this); | 98 | binding.tvFilterManage.setOnClickListener(this); |
95 | binding.tvEdit.setOnClickListener(this); | 99 | binding.tvEdit.setOnClickListener(this); |
96 | binding.tvAdd.setOnClickListener(this); | 100 | binding.tvAdd.setOnClickListener(this); |
97 | binding.llDelete.setOnClickListener(this); | 101 | binding.llDelete.setOnClickListener(this); |
98 | binding.tvSave.setOnClickListener(this); | 102 | binding.tvSave.setOnClickListener(this); |
99 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | 103 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); |
100 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | 104 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
101 | @Override | 105 | @Override |
102 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | 106 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
103 | adapter.checkAll(isChecked); | 107 | if (binding.llEmpty.getVisibility() != View.VISIBLE) { |
108 | adapter.checkAll(isChecked); | ||
109 | } | ||
104 | } | 110 | } |
105 | }); | 111 | }); |
106 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); | 112 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); |
107 | timeButton.setChecked(true); | 113 | timeButton.setChecked(true); |
108 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 114 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
109 | @Override | 115 | @Override |
110 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 116 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
111 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 117 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
112 | time = rcheck.getText().toString(); | 118 | time = rcheck.getText().toString(); |
113 | refreshError(); | 119 | refreshError(); |
114 | } | 120 | } |
115 | }); | 121 | }); |
116 | 122 | ||
117 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); | 123 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); |
118 | typeButton.setChecked(true); | 124 | typeButton.setChecked(true); |
119 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 125 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
120 | @Override | 126 | @Override |
121 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 127 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
122 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 128 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
123 | type = rcheck.getText().toString(); | 129 | type = rcheck.getText().toString(); |
124 | refreshError(); | 130 | refreshError(); |
125 | } | 131 | } |
126 | }); | 132 | }); |
127 | refreshError(); | 133 | refreshError(); |
128 | binding.ivChange.setOnClickListener(new View.OnClickListener() { | 134 | binding.ivChange.setOnClickListener(new View.OnClickListener() { |
129 | @Override | 135 | @Override |
130 | public void onClick(View v) { | 136 | public void onClick(View v) { |
131 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { | 137 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { |
132 | Intent intent = new Intent(context, ChooseActivity.class); | 138 | Intent intent = new Intent(context, ChooseActivity.class); |
133 | intent.putExtra("needBack", true); | 139 | intent.putExtra("needBack", true); |
134 | startActivity(intent); | 140 | startActivity(intent); |
135 | } else { | 141 | } else { |
136 | Intent intent = new Intent(context, TeacherChooseActivity.class); | 142 | Intent intent = new Intent(context, TeacherChooseActivity.class); |
137 | intent.putExtra("needBack", true); | 143 | intent.putExtra("needBack", true); |
138 | startActivity(intent); | 144 | startActivity(intent); |
139 | } | 145 | } |
140 | } | 146 | } |
141 | }); | 147 | }); |
148 | setGradeFilter(); | ||
149 | } | ||
150 | |||
151 | private void setGradeFilter() { | ||
152 | if (TextUtils.isEmpty(grade)) { | ||
153 | grade = "全部"; | ||
154 | } | ||
155 | List<String> grades = new ArrayList<>(); | ||
156 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | ||
157 | grades.add(gradeAndSubject.getGrade().getGrade()); | ||
158 | } | ||
159 | grades.add("全部"); | ||
160 | gradeAdapter = new GradeAdapter(context, new GradeAdapter.Filter() { | ||
161 | @Override | ||
162 | public void onSelect(String select) { | ||
163 | grade = select; | ||
164 | page = 1; | ||
165 | gradeAdapter.refresh(select); | ||
166 | refreshError(); | ||
167 | } | ||
168 | }, grades, grade); | ||
169 | binding.recycleGrade.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | ||
170 | binding.recycleGrade.setAdapter(gradeAdapter); | ||
171 | binding.groupGrade.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | ||
172 | @Override | ||
173 | public void onCheckedChanged(RadioGroup group, int checkedId) { | ||
174 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | ||
175 | grade1 = rcheck.getText().toString(); | ||
176 | page = 1; | ||
177 | refreshError(); | ||
178 | } | ||
179 | }); | ||
142 | } | 180 | } |
143 | 181 | ||
144 | @Override | 182 | @Override |
145 | protected ActivityErrorListBinding getViewBinding() { | 183 | protected ActivityErrorListBinding getViewBinding() { |
146 | return ActivityErrorListBinding.inflate(getLayoutInflater()); | 184 | return ActivityErrorListBinding.inflate(getLayoutInflater()); |
147 | } | 185 | } |
148 | 186 | ||
149 | 187 | ||
150 | @Override | 188 | @Override |
151 | public void onClick(View v) { | 189 | public void onClick(View v) { |
152 | switch (v.getId()) { | 190 | switch (v.getId()) { |
153 | case R.id.iv_back: | 191 | case R.id.iv_back: |
154 | finish(); | 192 | finish(); |
155 | break; | 193 | break; |
156 | case R.id.tv_filter_grade: | 194 | case R.id.tv_filter_grade: |
157 | List<String> grades = new ArrayList<>(); | 195 | showFilerGrade(); |
158 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | ||
159 | grades.add(gradeAndSubject.getGrade().getGrade()); | ||
160 | } | ||
161 | grades.add("全部"); | ||
162 | setFilterAdapter(grades, binding.tvFilterGrade, grade); | ||
163 | break; | 196 | break; |
164 | case R.id.tv_filter_subject: | 197 | case R.id.tv_filter_subject: |
165 | List<String> subjects = new ArrayList<>(); | 198 | List<String> subjects = new ArrayList<>(); |
166 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 199 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
167 | for (Subject subject : gradeAndSubject.getSubjects()) { | 200 | for (Subject subject : gradeAndSubject.getSubjects()) { |
168 | if (!subjects.contains(subject.getSubject())) { | 201 | if (!subjects.contains(subject.getSubject())) { |
169 | subjects.add(subject.getSubject()); | 202 | subjects.add(subject.getSubject()); |
170 | } | 203 | } |
171 | } | 204 | } |
172 | } | 205 | } |
173 | subjects.add("全部"); | 206 | subjects.add("全部"); |
174 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); | 207 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); |
175 | break; | 208 | break; |
176 | case R.id.tv_filter_manage: | 209 | case R.id.tv_filter_manage: |
177 | List<String> manages = new ArrayList<>(); | 210 | List<String> manages = new ArrayList<>(); |
178 | manages.add("已掌握"); | 211 | manages.add("已掌握"); |
179 | manages.add("未掌握"); | 212 | manages.add("未掌握"); |
180 | manages.add("全部"); | 213 | manages.add("全部"); |
181 | setFilterAdapter(manages, binding.tvFilterManage, manger); | 214 | setFilterAdapter(manages, binding.tvFilterManage, manger); |
182 | break; | 215 | break; |
183 | case R.id.tv_filter_more: | 216 | case R.id.tv_filter_more: |
184 | showFilterMore(); | 217 | showFilterMore(); |
185 | break; | 218 | break; |
186 | case R.id.tv_edit: | 219 | case R.id.tv_edit: |
187 | if (adapter.edit) { | 220 | if (adapter.edit) { |
188 | adapter.setEdit(false); | 221 | adapter.setEdit(false); |
189 | binding.tvSave.setVisibility(View.GONE); | 222 | binding.tvSave.setVisibility(View.GONE); |
190 | binding.tvAdd.setVisibility(View.VISIBLE); | 223 | binding.tvAdd.setVisibility(View.VISIBLE); |
191 | binding.checkbox.setVisibility(View.GONE); | 224 | binding.checkbox.setVisibility(View.GONE); |
192 | binding.llDelete.setVisibility(View.GONE); | 225 | binding.llDelete.setVisibility(View.GONE); |
193 | binding.ivBack.setVisibility(View.VISIBLE); | 226 | binding.ivBack.setVisibility(View.VISIBLE); |
194 | binding.tvEdit.setText("编辑"); | 227 | binding.tvEdit.setText("编辑"); |
195 | } else { | 228 | } else { |
196 | adapter.setEdit(true); | 229 | adapter.setEdit(true); |
197 | binding.tvSave.setVisibility(View.VISIBLE); | 230 | binding.tvSave.setVisibility(View.VISIBLE); |
198 | binding.tvAdd.setVisibility(View.GONE); | 231 | binding.tvAdd.setVisibility(View.GONE); |
199 | binding.llDelete.setVisibility(View.VISIBLE); | 232 | binding.llDelete.setVisibility(View.VISIBLE); |
200 | binding.checkbox.setVisibility(View.VISIBLE); | 233 | binding.checkbox.setVisibility(View.VISIBLE); |
201 | binding.ivBack.setVisibility(View.GONE); | 234 | binding.ivBack.setVisibility(View.GONE); |
202 | binding.tvEdit.setText("取消"); | 235 | binding.tvEdit.setText("取消"); |
203 | } | 236 | } |
204 | adapter.notifyDataSetChanged(); | 237 | adapter.notifyDataSetChanged(); |
205 | break; | 238 | break; |
206 | case R.id.ll_delete: | 239 | case R.id.ll_delete: |
207 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { | 240 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { |
208 | @Override | 241 | @Override |
209 | public void onConfirm(Dialog dialog) { | 242 | public void onConfirm(Dialog dialog) { |
210 | deleteError(adapter.getChecKList()); | 243 | deleteError(adapter.getChecKList()); |
211 | dialog.dismiss(); | 244 | dialog.dismiss(); |
212 | } | 245 | } |
213 | 246 | ||
214 | @Override | 247 | @Override |
215 | public void onCancel(Dialog dialog) { | 248 | public void onCancel(Dialog dialog) { |
216 | dialog.dismiss(); | 249 | dialog.dismiss(); |
217 | } | 250 | } |
218 | }); | 251 | }); |
219 | break; | 252 | break; |
220 | case R.id.tv_add: | 253 | case R.id.tv_add: |
221 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { | 254 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { |
222 | XXPermissions.with(context) | 255 | XXPermissions.with(context) |
223 | // 申请多个权限 | 256 | // 申请多个权限 |
224 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) | 257 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) |
225 | .request(new OnPermissionCallback() { | 258 | .request(new OnPermissionCallback() { |
226 | @Override | 259 | @Override |
227 | public void onGranted(List<String> permissions, boolean all) { | 260 | public void onGranted(List<String> permissions, boolean all) { |
228 | if (all) { | 261 | if (all) { |
229 | //开启扫码界面 | 262 | //开启扫码界面 |
230 | showButtonDialog(); | 263 | showButtonDialog(); |
231 | } else { | 264 | } else { |
232 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | 265 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
233 | } | 266 | } |
234 | } | 267 | } |
235 | 268 | ||
236 | @Override | 269 | @Override |
237 | public void onDenied(List<String> permissions, boolean never) { | 270 | public void onDenied(List<String> permissions, boolean never) { |
238 | XXPermissions.startPermissionActivity(context, permissions); | 271 | XXPermissions.startPermissionActivity(context, permissions); |
239 | } | 272 | } |
240 | }); | 273 | }); |
241 | } else { | 274 | } else { |
242 | showButtonDialog(); | 275 | showButtonDialog(); |
243 | } | 276 | } |
244 | break; | 277 | break; |
245 | case R.id.tv_save: | 278 | case R.id.tv_save: |
246 | if (adapter.getChecKList().size() > 0) { | 279 | if (adapter.getChecKList().size() > 0) { |
247 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { | 280 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { |
248 | @Override | 281 | @Override |
249 | public void edit(String s, int i) { | 282 | public void edit(String s, int i) { |
250 | adapter.setEdit(false); | 283 | adapter.setEdit(false); |
251 | binding.tvSave.setVisibility(View.GONE); | 284 | binding.tvSave.setVisibility(View.GONE); |
252 | binding.tvAdd.setVisibility(View.VISIBLE); | 285 | binding.tvAdd.setVisibility(View.VISIBLE); |
253 | binding.checkbox.setVisibility(View.GONE); | 286 | binding.checkbox.setVisibility(View.GONE); |
254 | binding.llDelete.setVisibility(View.GONE); | 287 | binding.llDelete.setVisibility(View.GONE); |
255 | binding.ivBack.setVisibility(View.VISIBLE); | 288 | binding.ivBack.setVisibility(View.VISIBLE); |
256 | binding.tvEdit.setText("编辑"); | 289 | binding.tvEdit.setText("编辑"); |
257 | page = 1; | 290 | page = 1; |
258 | refreshError(); | 291 | refreshError(); |
259 | } | 292 | } |
260 | }); | 293 | }); |
261 | errorEditDialog.show(); | 294 | errorEditDialog.show(); |
262 | } | 295 | } |
263 | break; | 296 | break; |
264 | } | 297 | } |
265 | } | 298 | } |
266 | 299 | ||
267 | private void showButtonDialog() { | 300 | private void showButtonDialog() { |
268 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 301 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
269 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 302 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
270 | dialog.setContentView(bottomView); | 303 | dialog.setContentView(bottomView); |
271 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 304 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
272 | @Override | 305 | @Override |
273 | public void onClick(View view) { | 306 | public void onClick(View view) { |
274 | dialog.dismiss(); | 307 | dialog.dismiss(); |
275 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 308 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
276 | //确保有相机来处理Intent | 309 | //确保有相机来处理Intent |
277 | 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"; |
278 | File photoFile = new File(filePath); | 311 | File photoFile = new File(filePath); |
279 | if (photoFile != null) { | 312 | if (photoFile != null) { |
280 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 313 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
281 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 314 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
282 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 315 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
283 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 316 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
284 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 317 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
285 | } | 318 | } |
286 | } | 319 | } |
287 | }); | 320 | }); |
288 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 321 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
289 | @Override | 322 | @Override |
290 | public void onClick(View view) { | 323 | public void onClick(View view) { |
291 | dialog.dismiss(); | 324 | dialog.dismiss(); |
292 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 325 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
293 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 326 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
294 | .multiSelect(true) //是否多选 | 327 | .multiSelect(true) //是否多选 |
295 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 328 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
296 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 329 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
297 | .maxImageSelectable(9) //图片可选择数 | 330 | .maxImageSelectable(5) //图片可选择数 |
298 | .maxHeight(1920) //图片最大高度 | 331 | .maxHeight(1920) //图片最大高度 |
299 | .maxWidth(1920) //图片最大宽度 | 332 | .maxWidth(1920) //图片最大宽度 |
300 | .maxImageSize(10) //图片最大大小Mb | 333 | .maxImageSize(3) //图片最大大小Mb |
301 | .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(); | 334 | .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(); |
302 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); | 335 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); |
303 | 336 | ||
304 | } | 337 | } |
305 | }); | 338 | }); |
306 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 339 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
307 | @Override | 340 | @Override |
308 | public void onClick(View view) { | 341 | public void onClick(View view) { |
309 | dialog.dismiss(); | 342 | dialog.dismiss(); |
310 | } | 343 | } |
311 | }); | 344 | }); |
312 | dialog.show(); | 345 | dialog.show(); |
313 | } | 346 | } |
314 | 347 | ||
315 | private void deleteError(List<TopicBean> topicBeans) { | 348 | private void deleteError(List<TopicBean> topicBeans) { |
316 | List<String> list = new ArrayList<>(); | 349 | List<String> list = new ArrayList<>(); |
317 | for (int i = 0; i < topicBeans.size(); i++) { | 350 | for (int i = 0; i < topicBeans.size(); i++) { |
318 | list.add(topicBeans.get(i).getId()); | 351 | list.add(topicBeans.get(i).getId()); |
319 | } | 352 | } |
320 | NetWorks.deleteError(list, new Observer<ResponseResult>() { | 353 | NetWorks.deleteError(list, new Observer<ResponseResult>() { |
321 | @Override | 354 | @Override |
322 | public void onSubscribe(Disposable d) { | 355 | public void onSubscribe(Disposable d) { |
323 | 356 | ||
324 | } | 357 | } |
325 | 358 | ||
326 | @Override | 359 | @Override |
327 | public void onNext(ResponseResult responseResult) { | 360 | public void onNext(ResponseResult responseResult) { |
328 | if (responseResult.getCode() == 200) { | 361 | if (responseResult.getCode() == 200) { |
329 | adapter.setEdit(false); | 362 | adapter.setEdit(false); |
330 | binding.tvSave.setVisibility(View.GONE); | 363 | binding.tvSave.setVisibility(View.GONE); |
331 | binding.tvAdd.setVisibility(View.VISIBLE); | 364 | binding.tvAdd.setVisibility(View.VISIBLE); |
332 | binding.checkbox.setVisibility(View.GONE); | 365 | binding.checkbox.setVisibility(View.GONE); |
333 | binding.llDelete.setVisibility(View.GONE); | 366 | binding.llDelete.setVisibility(View.GONE); |
334 | binding.ivBack.setVisibility(View.VISIBLE); | 367 | binding.ivBack.setVisibility(View.VISIBLE); |
335 | binding.tvEdit.setText("编辑"); | 368 | binding.tvEdit.setText("编辑"); |
336 | page = 1; | 369 | page = 1; |
337 | refreshError(); | 370 | refreshError(); |
338 | } | 371 | } |
339 | } | 372 | } |
340 | 373 | ||
341 | @Override | 374 | @Override |
342 | public void onError(Throwable e) { | 375 | public void onError(Throwable e) { |
343 | 376 | ||
344 | } | 377 | } |
345 | 378 | ||
346 | @Override | 379 | @Override |
347 | public void onComplete() { | 380 | public void onComplete() { |
348 | 381 | ||
349 | } | 382 | } |
350 | }); | 383 | }); |
351 | } | 384 | } |
352 | 385 | ||
386 | private void showFilerGrade() { | ||
387 | binding.recycleFilter.setVisibility(View.GONE); | ||
388 | binding.llFilterMore.setVisibility(View.GONE); | ||
389 | if (binding.llFilterGrade.getVisibility() == View.VISIBLE) { | ||
390 | binding.llFilterGrade.setVisibility(View.GONE); | ||
391 | binding.tvFilterGrade.setTextColor(getColor(R.color.text_title)); | ||
392 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | ||
393 | // 这一步必须要做,否则不会显示. | ||
394 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | ||
395 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable, null); | ||
396 | } else { | ||
397 | binding.llFilterGrade.setVisibility(View.VISIBLE); | ||
398 | if (last != null) { | ||
399 | last.setTextColor(getColor(R.color.text_title)); | ||
400 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | ||
401 | // 这一步必须要做,否则不会显示. | ||
402 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | ||
403 | last.setCompoundDrawables(null, null, drawable, null); | ||
404 | } | ||
405 | binding.tvFilterGrade.setTextColor(Color.parseColor("#1C90F3")); | ||
406 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | ||
407 | // 这一步必须要做,否则不会显示. | ||
408 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | ||
409 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable1, null); | ||
410 | last = binding.tvFilterGrade; | ||
411 | } | ||
412 | |||
413 | } | ||
414 | |||
353 | private void showFilterMore() { | 415 | private void showFilterMore() { |
354 | binding.recycleFilter.setVisibility(View.GONE); | 416 | binding.recycleFilter.setVisibility(View.GONE); |
417 | binding.llFilterGrade.setVisibility(View.GONE); | ||
355 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { | 418 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { |
356 | binding.llFilterMore.setVisibility(View.GONE); | 419 | binding.llFilterMore.setVisibility(View.GONE); |
420 | binding.tvFilterMore.setTextColor(getColor(R.color.text_title)); | ||
421 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | ||
422 | // 这一步必须要做,否则不会显示. | ||
423 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | ||
424 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable, null); | ||
357 | } else { | 425 | } else { |
358 | binding.llFilterMore.setVisibility(View.VISIBLE); | 426 | binding.llFilterMore.setVisibility(View.VISIBLE); |
359 | if (last != null) { | 427 | if (last != null) { |
360 | last.setTextColor(getColor(R.color.text_title)); | 428 | last.setTextColor(getColor(R.color.text_title)); |
361 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 429 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
362 | // 这一步必须要做,否则不会显示. | 430 | // 这一步必须要做,否则不会显示. |
363 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 431 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
364 | last.setCompoundDrawables(null, null, drawable, null); | 432 | last.setCompoundDrawables(null, null, drawable, null); |
365 | } | 433 | } |
366 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); | 434 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); |
367 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 435 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
368 | // 这一步必须要做,否则不会显示. | 436 | // 这一步必须要做,否则不会显示. |
369 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | 437 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); |
370 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); | 438 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); |
371 | last = binding.tvFilterMore; | 439 | last = binding.tvFilterMore; |
372 | } | 440 | } |
373 | } | 441 | } |
374 | 442 | ||
375 | private void setFilterAdapter(List<String> list, TextView textView, String select) { | 443 | private void setFilterAdapter(List<String> list, TextView textView, String select) { |
376 | if (TextUtils.isEmpty(select)) { | 444 | if (TextUtils.isEmpty(select)) { |
377 | select = "全部"; | 445 | select = "全部"; |
378 | } | 446 | } |
447 | binding.llFilterGrade.setVisibility(View.GONE); | ||
379 | binding.llFilterMore.setVisibility(View.GONE); | 448 | binding.llFilterMore.setVisibility(View.GONE); |
380 | if (last != null && last.getId() == R.id.tv_filter_more) { | 449 | if (last != null && (last.getId() == R.id.tv_filter_more || last.getId() == R.id.tv_filter_grade)) { |
381 | last.setTextColor(getColor(R.color.text_title)); | 450 | last.setTextColor(getColor(R.color.text_title)); |
382 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 451 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
383 | // 这一步必须要做,否则不会显示. | 452 | // 这一步必须要做,否则不会显示. |
384 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 453 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
385 | last.setCompoundDrawables(null, null, drawable, null); | 454 | last.setCompoundDrawables(null, null, drawable, null); |
386 | } | 455 | } |
387 | if (binding.recycleFilter.getVisibility() == View.GONE) { | 456 | if (binding.recycleFilter.getVisibility() == View.GONE) { |
388 | if (filterAdapter != null) { | 457 | if (filterAdapter != null) { |
389 | filterAdapter.refresh(list, textView, select); | 458 | filterAdapter.refresh(list, textView, select); |
390 | } else { | 459 | } else { |
391 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { | 460 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { |
392 | @Override | 461 | @Override |
393 | public void onSelect(TextView type, String select) { | 462 | public void onSelect(TextView type, String select) { |
394 | switch (type.getId()) { | 463 | switch (type.getId()) { |
395 | case R.id.tv_filter_grade: | ||
396 | grade = select; | ||
397 | break; | ||
398 | case R.id.tv_filter_subject: | 464 | case R.id.tv_filter_subject: |
399 | subject = select; | 465 | subject = select; |
400 | break; | 466 | break; |
401 | case R.id.tv_filter_manage: | 467 | case R.id.tv_filter_manage: |
402 | manger = select; | 468 | manger = select; |
403 | break; | 469 | break; |
404 | } | 470 | } |
405 | page = 1; | 471 | page = 1; |
406 | filterAdapter.refresh(select); | 472 | filterAdapter.refresh(select); |
407 | refreshError(); | 473 | refreshError(); |
408 | } | 474 | } |
409 | }, list, textView, select); | 475 | }, list, textView, select); |
410 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | 476 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); |
411 | binding.recycleFilter.setAdapter(filterAdapter); | 477 | binding.recycleFilter.setAdapter(filterAdapter); |
412 | } | 478 | } |
413 | binding.recycleFilter.setVisibility(View.VISIBLE); | 479 | binding.recycleFilter.setVisibility(View.VISIBLE); |
414 | textView.setTextColor(Color.parseColor("#1C90F3")); | 480 | textView.setTextColor(Color.parseColor("#1C90F3")); |
415 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); | 481 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); |
416 | // 这一步必须要做,否则不会显示. | 482 | // 这一步必须要做,否则不会显示. |
417 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 483 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
418 | textView.setCompoundDrawables(null, null, drawable, null); | 484 | textView.setCompoundDrawables(null, null, drawable, null); |
419 | last = textView; | 485 | last = textView; |
420 | } else { | 486 | } else { |
421 | if (textView.getId() == last.getId()) { | 487 | if (textView.getId() == last.getId()) { |
422 | binding.recycleFilter.setVisibility(View.GONE); | 488 | binding.recycleFilter.setVisibility(View.GONE); |
423 | textView.setTextColor(getColor(R.color.text_title)); | 489 | textView.setTextColor(getColor(R.color.text_title)); |
424 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 490 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
425 | // 这一步必须要做,否则不会显示. | 491 | // 这一步必须要做,否则不会显示. |
426 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 492 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
427 | textView.setCompoundDrawables(null, null, drawable, null); | 493 | textView.setCompoundDrawables(null, null, drawable, null); |
428 | } else { | 494 | } else { |
429 | filterAdapter.refresh(list, textView, select); | 495 | filterAdapter.refresh(list, textView, select); |
430 | last.setTextColor(getColor(R.color.text_title)); | 496 | last.setTextColor(getColor(R.color.text_title)); |
431 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 497 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
432 | // 这一步必须要做,否则不会显示. | 498 | // 这一步必须要做,否则不会显示. |
433 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 499 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
434 | last.setCompoundDrawables(null, null, drawable, null); | 500 | last.setCompoundDrawables(null, null, drawable, null); |
435 | textView.setTextColor(Color.parseColor("#1C90F3")); | 501 | textView.setTextColor(Color.parseColor("#1C90F3")); |
436 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 502 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
437 | // 这一步必须要做,否则不会显示. | 503 | // 这一步必须要做,否则不会显示. |
438 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 504 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
439 | textView.setCompoundDrawables(null, null, drawable1, null); | 505 | textView.setCompoundDrawables(null, null, drawable1, null); |
440 | last = textView; | 506 | last = textView; |
441 | } | 507 | } |
442 | } | 508 | } |
443 | } | 509 | } |
444 | 510 | ||
445 | private void refreshError() { | 511 | private void refreshError() { |
446 | Map map = new HashMap(); | 512 | Map map = new HashMap(); |
447 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { | 513 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { |
448 | map.put("subject", subject); | 514 | map.put("subject", subject); |
449 | } | 515 | } |
450 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { | 516 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { |
451 | map.put("grade", grade); | 517 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { |
518 | map.put("grade", grade + grade1); | ||
519 | } else { | ||
520 | map.put("grade", grade); | ||
521 | } | ||
522 | } else { | ||
523 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { | ||
524 | map.put("grade", grade1); | ||
525 | } | ||
452 | } | 526 | } |
453 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { | 527 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { |
454 | if ("一周内".equals(time)) { | 528 | if ("一周内".equals(time)) { |
455 | map.put("time", 6); | 529 | map.put("time", 6); |
456 | } else if ("一个月内".equals(time)) { | 530 | } else if ("一个月内".equals(time)) { |
457 | map.put("time", 30); | 531 | map.put("time", 30); |
458 | } else if ("三个月内".equals(time)) { | 532 | } else if ("三个月内".equals(time)) { |
459 | map.put("time", 90); | 533 | map.put("time", 90); |
460 | } | 534 | } |
461 | } | 535 | } |
462 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { | 536 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { |
463 | map.put("type", "课内".equals(type) ? 0 : 1); | 537 | map.put("type", "课内".equals(type) ? 0 : 1); |
464 | } | 538 | } |
465 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { | 539 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { |
466 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); | 540 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); |
467 | } | 541 | } |
468 | map.put("stuId", studentBean.getStuId()); | 542 | map.put("stuId", studentBean.getStuId()); |
469 | map.put("pageSize", 10); | 543 | map.put("pageSize", 10); |
470 | map.put("pageNum", page); | 544 | map.put("pageNum", page); |
471 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 545 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
472 | @Override | 546 | @Override |
473 | public void onSubscribe(Disposable d) { | 547 | public void onSubscribe(Disposable d) { |
474 | 548 | ||
475 | } | 549 | } |
476 | 550 | ||
477 | @Override | 551 | @Override |
478 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 552 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
479 | if (result.getData() != null && result.getCode() == 200) { | 553 | if (result.getData() != null && result.getCode() == 200) { |
480 | total = result.getData().getTotal(); | 554 | total = result.getData().getTotal(); |
481 | List<TopicBean> topicBeans = result.getData().getList(); | 555 | List<TopicBean> topicBeans = result.getData().getList(); |
482 | loadError(topicBeans); | 556 | loadError(topicBeans); |
483 | } | 557 | } |
484 | } | 558 | } |
485 | 559 | ||
486 | @Override | 560 | @Override |
487 | public void onError(Throwable e) { | 561 | public void onError(Throwable e) { |
488 | e.toString(); | 562 | e.toString(); |
489 | } | 563 | } |
490 | 564 | ||
491 | @Override | 565 | @Override |
492 | public void onComplete() { | 566 | public void onComplete() { |
493 | 567 | ||
494 | } | 568 | } |
495 | }); | 569 | }); |
496 | } | 570 | } |
497 | 571 | ||
498 | private void loadError(List<TopicBean> list) { | 572 | private void loadError(List<TopicBean> list) { |
499 | if (list.size() > 0) { | 573 | if (list.size() > 0) { |
500 | binding.recycle.setVisibility(View.VISIBLE); | 574 | binding.recycle.setVisibility(View.VISIBLE); |
501 | binding.llEmpty.setVisibility(View.GONE); | 575 | binding.llEmpty.setVisibility(View.GONE); |
502 | if (adapter != null) { | 576 | if (adapter != null) { |
503 | if (page > 1) { | 577 | if (page > 1) { |
504 | adapter.addData(list); | 578 | adapter.addData(list); |
505 | } else { | 579 | } else { |
506 | adapter.refresh(list); | 580 | adapter.refresh(list); |
507 | } | 581 | } |
508 | } else { | 582 | } else { |
509 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { | 583 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { |
510 | @Override | 584 | @Override |
511 | public void onErrorCheck() { | 585 | public void onErrorCheck() { |
512 | if (adapter.getChecKList().size() > 0) { | 586 | if (adapter.getChecKList().size() > 0) { |
513 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); | 587 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); |
514 | } else { | 588 | } else { |
515 | binding.tvSave.setText("批量修改标签"); | 589 | binding.tvSave.setText("批量修改标签"); |
516 | } | 590 | } |
517 | } | 591 | } |
518 | }); | 592 | }); |
519 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); | 593 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); |
520 | binding.recycle.setLayoutManager(linearLayoutManager); | 594 | binding.recycle.setLayoutManager(linearLayoutManager); |
521 | binding.recycle.setAdapter(adapter); | 595 | binding.recycle.setAdapter(adapter); |
522 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { | 596 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { |
523 | @Override | 597 | @Override |
524 | public void onLoadMore(int currentPage) { | 598 | public void onLoadMore(int currentPage) { |
525 | if (currentPage > page) { | 599 | if (currentPage > page) { |
526 | new Thread(new Runnable() { | 600 | new Thread(new Runnable() { |
527 | @Override | 601 | @Override |
528 | public void run() { | 602 | public void run() { |
529 | try { | 603 | try { |
530 | runOnUiThread(new Runnable() { | 604 | runOnUiThread(new Runnable() { |
531 | @Override | 605 | @Override |
532 | public void run() { | 606 | public void run() { |
533 | if (page * 10 < total) { | 607 | if (page * 10 < total) { |
534 | page++; | 608 | page++; |
535 | refreshError(); | 609 | refreshError(); |
536 | } | 610 | } |
537 | } | 611 | } |
538 | }); | 612 | }); |
539 | } catch (Exception e) { | 613 | } catch (Exception e) { |
540 | e.printStackTrace(); | 614 | e.printStackTrace(); |
541 | } | 615 | } |
542 | } | 616 | } |
543 | }).start(); | 617 | }).start(); |
544 | } | 618 | } |
545 | } | 619 | } |
546 | }); | 620 | }); |
547 | } | 621 | } |
548 | } else { | 622 | } else { |
549 | if (page == 1) { | 623 | if (page == 1) { |
550 | binding.recycle.setVisibility(View.GONE); | 624 | binding.recycle.setVisibility(View.GONE); |
551 | binding.llEmpty.setVisibility(View.VISIBLE); | 625 | binding.llEmpty.setVisibility(View.VISIBLE); |
552 | } | 626 | } |
553 | } | 627 | } |
554 | } | 628 | } |
555 | 629 | ||
556 | @Override | 630 | @Override |
557 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 631 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
558 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 632 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
559 | if (adapter != null && adapter.edit) { | 633 | if (adapter != null && adapter.edit) { |
560 | adapter.setEdit(false); | 634 | adapter.setEdit(false); |
561 | binding.tvSave.setVisibility(View.GONE); | 635 | binding.tvSave.setVisibility(View.GONE); |
562 | binding.tvAdd.setVisibility(View.VISIBLE); | 636 | binding.tvAdd.setVisibility(View.VISIBLE); |
563 | binding.checkbox.setVisibility(View.GONE); | 637 | binding.checkbox.setVisibility(View.GONE); |
564 | binding.llDelete.setVisibility(View.GONE); | 638 | binding.llDelete.setVisibility(View.GONE); |
565 | binding.ivBack.setVisibility(View.VISIBLE); | 639 | binding.ivBack.setVisibility(View.VISIBLE); |
566 | binding.tvEdit.setText("编辑"); | 640 | binding.tvEdit.setText("编辑"); |
567 | adapter.notifyDataSetChanged(); | 641 | adapter.notifyDataSetChanged(); |
568 | } else { | 642 | } else { |
569 | finish(); | 643 | finish(); |
570 | } | 644 | } |
571 | return true; | 645 | return true; |
572 | } | 646 | } |
573 | return super.onKeyDown(keyCode, event); | 647 | return super.onKeyDown(keyCode, event); |
574 | } | 648 | } |
575 | 649 | ||
576 | @Override | 650 | @Override |
577 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 651 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
578 | super.onActivityResult(requestCode, resultCode, data); | 652 | super.onActivityResult(requestCode, resultCode, data); |
579 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 653 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
580 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 654 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
581 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 655 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
582 | CommonUtil.saveBitmapToUri(b, path); | 656 | CommonUtil.saveBitmapToUri(b, path); |
583 | List<String> strings = new ArrayList<>(); | 657 | List<String> strings = new ArrayList<>(); |
584 | Intent intent = new Intent(context, ImageActivity.class); | 658 | Intent intent = new Intent(context, ImageActivity.class); |
585 | strings.add(path); | 659 | strings.add(path); |
586 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 660 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
587 | startActivity(intent); | 661 | startActivity(intent); |
588 | } | 662 | } |
589 | } | 663 | } |
590 | 664 | ||
591 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 665 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
592 | private String TAG = "---ImagePicker---"; | 666 | private String TAG = "---ImagePicker---"; |
593 | List<ImageInfo> photoList = new ArrayList<>(); | 667 | List<ImageInfo> photoList = new ArrayList<>(); |
594 | 668 | ||
595 | @Override | 669 | @Override |
596 | public void onStart() { | 670 | public void onStart() { |
597 | Log.i(TAG, "onStart: 开启"); | 671 | Log.i(TAG, "onStart: 开启"); |
598 | } | 672 | } |
599 | 673 | ||
600 | @Override | 674 | @Override |
601 | public void onSuccess(List<ImageInfo> photoList) { | 675 | public void onSuccess(List<ImageInfo> photoList) { |
602 | this.photoList = photoList; | 676 | this.photoList = photoList; |
603 | Log.i(TAG, "onSuccess: 返回数据"); | 677 | Log.i(TAG, "onSuccess: 返回数据"); |
604 | } | 678 | } |
605 | 679 | ||
606 | @Override | 680 | @Override |
607 | public void onCancel() { | 681 | public void onCancel() { |
608 | Log.i(TAG, "onCancel: 取消"); | 682 | Log.i(TAG, "onCancel: 取消"); |
609 | } | 683 | } |
610 | 684 | ||
611 | @Override | 685 | @Override |
612 | public void onFinish(List<ImageInfo> selectImage) { | 686 | public void onFinish(List<ImageInfo> selectImage) { |
613 | if (selectImage.size() == photoList.size()) { | 687 | if (selectImage.size() == photoList.size()) { |
614 | List<String> strings = new ArrayList<>(); | 688 | List<String> strings = new ArrayList<>(); |
615 | Intent intent = new Intent(context, ImageActivity.class); | 689 | Intent intent = new Intent(context, ImageActivity.class); |
616 | for (ImageInfo imageInfo : selectImage) { | 690 | for (ImageInfo imageInfo : selectImage) { |
617 | strings.add(imageInfo.getPath()); | 691 | strings.add(imageInfo.getPath()); |
618 | } | 692 | } |
619 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 693 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
620 | startActivity(intent); | 694 | startActivity(intent); |
621 | } | 695 | } |
622 | } | 696 | } |
623 | 697 | ||
624 | @Override | 698 | @Override |
625 | public void onError() { | 699 | public void onError() { |
626 | Log.i(TAG, "onError: 出错"); | 700 | Log.i(TAG, "onError: 出错"); |
627 | } | 701 | } |
628 | } | 702 | } |
629 | 703 | ||
630 | @Override | 704 | @Override |
631 | protected void onResume() { | 705 | protected void onResume() { |
632 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 706 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
633 | try { | 707 | try { |
634 | studentBean = new Gson().fromJson(student, StudentBean.class); | 708 | studentBean = new Gson().fromJson(student, StudentBean.class); |
635 | } catch (Exception e) { | 709 | } catch (Exception e) { |
app/src/main/java/com/hjx/parent/ImageActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
6 | import android.graphics.BitmapFactory; | 6 | import android.graphics.BitmapFactory; |
7 | import android.graphics.Rect; | 7 | import android.graphics.Rect; |
8 | import android.net.Uri; | 8 | import android.net.Uri; |
9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
10 | import android.os.Handler; | 10 | import android.os.Handler; |
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.KeyEvent; | 14 | import android.view.KeyEvent; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | 16 | ||
17 | 17 | ||
18 | import androidx.annotation.Nullable; | 18 | import androidx.annotation.Nullable; |
19 | import androidx.core.content.FileProvider; | 19 | import androidx.core.content.FileProvider; |
20 | import androidx.viewpager2.widget.ViewPager2; | 20 | import androidx.viewpager2.widget.ViewPager2; |
21 | 21 | ||
22 | import com.google.gson.Gson; | 22 | import com.google.gson.Gson; |
23 | import com.google.gson.JsonObject; | 23 | import com.google.gson.JsonObject; |
24 | import com.hjx.parent.adapter.ImageAdapter; | 24 | import com.hjx.parent.adapter.ImageAdapter; |
25 | import com.hjx.parent.databinding.ActivityImageBinding; | 25 | import com.hjx.parent.databinding.ActivityImageBinding; |
26 | import com.hjx.parent.dialog.ErrorInputDialog; | 26 | import com.hjx.parent.dialog.ErrorInputDialog; |
27 | import com.hjx.parent.dialog.TipDialog; | 27 | import com.hjx.parent.dialog.TipDialog; |
28 | import com.prws.common.bean.CutPicBean; | 28 | import com.prws.common.bean.CutPicBean; |
29 | import com.prws.common.bean.ImageBean; | 29 | import com.prws.common.bean.ImageBean; |
30 | import com.prws.common.bean.TopicBean; | 30 | import com.prws.common.bean.TopicBean; |
31 | import com.prws.common.net.NetWorks; | 31 | import com.prws.common.net.NetWorks; |
32 | import com.prws.common.utils.BitmapUtils; | 32 | import com.prws.common.utils.BitmapUtils; |
33 | import com.prws.common.utils.CommonUtil; | 33 | import com.prws.common.utils.CommonUtil; |
34 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; | 34 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; |
35 | 35 | ||
36 | import java.io.File; | 36 | import java.io.File; |
37 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
38 | import java.util.List; | 38 | import java.util.List; |
39 | 39 | ||
40 | import io.reactivex.Observer; | 40 | import io.reactivex.Observer; |
41 | import io.reactivex.disposables.Disposable; | 41 | import io.reactivex.disposables.Disposable; |
42 | import retrofit2.Call; | 42 | import retrofit2.Call; |
43 | import retrofit2.Callback; | 43 | import retrofit2.Callback; |
44 | import retrofit2.Response; | 44 | import retrofit2.Response; |
45 | 45 | ||
46 | public class ImageActivity extends BaseActivity<ActivityImageBinding> implements View.OnClickListener { | 46 | public class ImageActivity extends BaseActivity<ActivityImageBinding> implements View.OnClickListener { |
47 | 47 | ||
48 | private List<String> images = new ArrayList<>(); | 48 | private List<String> images = new ArrayList<>(); |
49 | private ImageAdapter imageAdapter; | 49 | private ImageAdapter imageAdapter; |
50 | private List<ImageBean> list = new ArrayList<>(); | 50 | private List<ImageBean> list = new ArrayList<>(); |
51 | private String filePath; | 51 | private String filePath; |
52 | 52 | ||
53 | @Override | 53 | @Override |
54 | public void initView(Bundle savedInstanceState) { | 54 | public void initView(Bundle savedInstanceState) { |
55 | images = getIntent().getStringArrayListExtra("images"); | 55 | images = getIntent().getStringArrayListExtra("images"); |
56 | for (String s : images) { | 56 | for (String s : images) { |
57 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 57 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
58 | ImageBean imageBean = new ImageBean(); | 58 | ImageBean imageBean = new ImageBean(); |
59 | Bitmap bitmap = BitmapUtils.getimage(s); | 59 | Bitmap bitmap = BitmapUtils.getimage(s); |
60 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 60 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
61 | imageBean.setPath(filepath); | 61 | imageBean.setPath(filepath); |
62 | list.add(imageBean); | 62 | list.add(imageBean); |
63 | } | 63 | } |
64 | imageAdapter = new ImageAdapter(this, list); | 64 | imageAdapter = new ImageAdapter(this, list); |
65 | binding.viewPager.setAdapter(imageAdapter); | 65 | binding.viewPager.setAdapter(imageAdapter); |
66 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 66 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
67 | @Override | 67 | @Override |
68 | public void onPageSelected(int position) { | 68 | public void onPageSelected(int position) { |
69 | if (list.get(position).getCuts() == null) { | 69 | if (list.get(position).getCuts() == null) { |
70 | binding.ivPrevious.setEnabled(false); | 70 | // binding.ivPrevious.setEnabled(false); |
71 | binding.ivNext.setEnabled(false); | 71 | // binding.ivNext.setEnabled(false); |
72 | clearText(); | 72 | clearText(); |
73 | } | 73 | } |
74 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 74 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
75 | if (position == 0) { | 75 | if (position == 0) { |
76 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); | 76 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); |
77 | // binding.ivPrevious.setEnabled(true); | ||
77 | } else { | 78 | } else { |
78 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); | 79 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); |
80 | // binding.ivPrevious.setEnabled(false); | ||
79 | } | 81 | } |
80 | if (position == list.size() - 1) { | 82 | if (position == list.size() - 1) { |
81 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); | 83 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); |
84 | // binding.ivNext.setEnabled(true); | ||
82 | } else { | 85 | } else { |
83 | binding.ivNext.setImageResource(R.mipmap.ic_next); | 86 | binding.ivNext.setImageResource(R.mipmap.ic_next); |
87 | // binding.ivNext.setEnabled(false); | ||
84 | } | 88 | } |
85 | super.onPageSelected(position); | 89 | super.onPageSelected(position); |
86 | } | 90 | } |
87 | }); | 91 | }); |
88 | binding.ivNext.setOnClickListener(this); | 92 | binding.ivNext.setOnClickListener(this); |
89 | binding.ivPrevious.setOnClickListener(this); | 93 | binding.ivPrevious.setOnClickListener(this); |
90 | binding.ivBack.setOnClickListener(this); | 94 | binding.ivBack.setOnClickListener(this); |
91 | binding.tvPhoto.setOnClickListener(this); | 95 | binding.tvPhoto.setOnClickListener(this); |
92 | binding.tvAdd.setOnClickListener(this); | 96 | binding.tvAdd.setOnClickListener(this); |
93 | binding.llEdit.setOnClickListener(this); | 97 | binding.llEdit.setOnClickListener(this); |
94 | binding.tvSave.setOnClickListener(this); | 98 | binding.tvSave.setOnClickListener(this); |
95 | } | 99 | } |
96 | 100 | ||
97 | public void clearText() { | 101 | public void clearText() { |
98 | int index = binding.viewPager.getCurrentItem(); | 102 | int index = binding.viewPager.getCurrentItem(); |
99 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { | 103 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { |
100 | @Override | 104 | @Override |
101 | public void dimiss() { | 105 | public void dimiss() { |
102 | binding.ivPrevious.setEnabled(index != 0); | 106 | // binding.ivPrevious.setEnabled(index != 0); |
103 | binding.ivNext.setEnabled(index != list.size() - 1); | 107 | // binding.ivNext.setEnabled(index != list.size() - 1); |
104 | } | 108 | } |
105 | }); | 109 | }); |
106 | Log.i("clearText", list.get(index).getPath()); | 110 | Log.i("clearText", list.get(index).getPath()); |
107 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); | 111 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); |
108 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { | 112 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { |
109 | @Override | 113 | @Override |
110 | public void onSubscribe(Disposable d) { | 114 | public void onSubscribe(Disposable d) { |
111 | 115 | ||
112 | } | 116 | } |
113 | 117 | ||
114 | @Override | 118 | @Override |
115 | public void onNext(JsonObject jsonObject) { | 119 | public void onNext(JsonObject jsonObject) { |
116 | if (jsonObject != null && jsonObject.get("image_processed") != null) { | 120 | if (jsonObject != null && jsonObject.get("image_processed") != null) { |
117 | String image = jsonObject.get("image_processed").getAsString(); | 121 | String image = jsonObject.get("image_processed").getAsString(); |
118 | if (image != null) { | 122 | if (image != null) { |
119 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 123 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
120 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); | 124 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); |
121 | list.get(index).setPath(filepath); | 125 | list.get(index).setPath(filepath); |
122 | imageAdapter.notifyItemChanged(index); | 126 | imageAdapter.notifyItemChanged(index); |
123 | cut(filepath); | 127 | cut(filepath); |
124 | } else { | 128 | } else { |
125 | loadFail("去除字迹失败"); | 129 | loadFail("去除字迹失败"); |
126 | } | 130 | } |
127 | } else { | 131 | } else { |
128 | loadFail("去除字迹失败"); | 132 | loadFail("去除字迹失败"); |
129 | } | 133 | } |
130 | } | 134 | } |
131 | 135 | ||
132 | @Override | 136 | @Override |
133 | public void onError(Throwable e) { | 137 | public void onError(Throwable e) { |
134 | loadFail("去除字迹失败"); | 138 | loadFail("去除字迹失败"); |
135 | } | 139 | } |
136 | 140 | ||
137 | @Override | 141 | @Override |
138 | public void onComplete() { | 142 | public void onComplete() { |
139 | 143 | ||
140 | } | 144 | } |
141 | }); | 145 | }); |
142 | } | 146 | } |
143 | 147 | ||
144 | public void cut(String path) { | 148 | public void cut(String path) { |
145 | String base64 = BitmapUtils.imageToBase64(path); | 149 | String base64 = BitmapUtils.imageToBase64(path); |
146 | Log.i("figLoaction", path); | 150 | Log.i("figLoaction", path); |
147 | NetWorks.cut(base64, new Observer<CutPicBean>() { | 151 | NetWorks.cut(base64, new Observer<CutPicBean>() { |
148 | @Override | 152 | @Override |
149 | public void onSubscribe(Disposable d) { | 153 | public void onSubscribe(Disposable d) { |
150 | 154 | ||
151 | } | 155 | } |
152 | 156 | ||
153 | @Override | 157 | @Override |
154 | public void onNext(CutPicBean cutPicBean) { | 158 | public void onNext(CutPicBean cutPicBean) { |
155 | if (cutPicBean != null) { | 159 | if (cutPicBean != null) { |
156 | if (cutPicBean.getDirection() != 0) { | 160 | if (cutPicBean.getDirection() != 0) { |
157 | rotatingImage(cutPicBean); | 161 | rotatingImage(cutPicBean); |
158 | } else { | 162 | } else { |
159 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 163 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
160 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 164 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
161 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 165 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
162 | figLoactions.add(cutLocation.getFig_location()); | 166 | figLoactions.add(cutLocation.getFig_location()); |
163 | } | 167 | } |
164 | new Handler().postDelayed(new Runnable() { | 168 | new Handler().postDelayed(new Runnable() { |
165 | @Override | 169 | @Override |
166 | public void run() { | 170 | public void run() { |
167 | getRects(figLoactions); | 171 | getRects(figLoactions); |
168 | } | 172 | } |
169 | }, 1000); | 173 | }, 1000); |
170 | } else { | 174 | } else { |
171 | cancelLoadingDialog(); | 175 | cancelLoadingDialog(); |
172 | } | 176 | } |
173 | } | 177 | } |
174 | } else { | 178 | } else { |
175 | loadFail("自动切题失败"); | 179 | loadFail("自动切题失败"); |
176 | } | 180 | } |
177 | } | 181 | } |
178 | 182 | ||
179 | @Override | 183 | @Override |
180 | public void onError(Throwable e) { | 184 | public void onError(Throwable e) { |
181 | loadFail("自动切题失败"); | 185 | loadFail("自动切题失败"); |
182 | } | 186 | } |
183 | 187 | ||
184 | @Override | 188 | @Override |
185 | public void onComplete() { | 189 | public void onComplete() { |
186 | 190 | ||
187 | } | 191 | } |
188 | }); | 192 | }); |
189 | } | 193 | } |
190 | 194 | ||
191 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { | 195 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { |
192 | Log.i("figLoaction", new Gson().toJson(figLoactions)); | 196 | Log.i("figLoaction", new Gson().toJson(figLoactions)); |
193 | int index = binding.viewPager.getCurrentItem(); | 197 | int index = binding.viewPager.getCurrentItem(); |
194 | List<ImageBean.Cut> cuts = new ArrayList<>(); | 198 | List<ImageBean.Cut> cuts = new ArrayList<>(); |
195 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { | 199 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { |
196 | ImageBean.Cut cut = new ImageBean.Cut(); | 200 | ImageBean.Cut cut = new ImageBean.Cut(); |
197 | cut.setRect(figLoaction); | 201 | cut.setRect(figLoaction); |
198 | cut.setSelect(false); | 202 | cut.setSelect(false); |
199 | cuts.add(cut); | 203 | cuts.add(cut); |
200 | } | 204 | } |
201 | list.get(index).setCuts(cuts); | 205 | list.get(index).setCuts(cuts); |
202 | imageAdapter.notifyItemChanged(index); | 206 | imageAdapter.notifyItemChanged(index); |
203 | cancelLoadingDialog(); | 207 | cancelLoadingDialog(); |
204 | } | 208 | } |
205 | 209 | ||
206 | private void rotatingImage(CutPicBean cutPicBean) { | 210 | private void rotatingImage(CutPicBean cutPicBean) { |
207 | int index = binding.viewPager.getCurrentItem(); | 211 | int index = binding.viewPager.getCurrentItem(); |
208 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); | 212 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); |
209 | int angle = 0; | 213 | int angle = 0; |
210 | switch (cutPicBean.getDirection()) { | 214 | switch (cutPicBean.getDirection()) { |
211 | case 1: | 215 | case 1: |
212 | angle = 90; | 216 | angle = 90; |
213 | break; | 217 | break; |
214 | case 2: | 218 | case 2: |
215 | angle = 180; | 219 | angle = 180; |
216 | break; | 220 | break; |
217 | case 3: | 221 | case 3: |
218 | angle = 270; | 222 | angle = 270; |
219 | break; | 223 | break; |
220 | } | 224 | } |
221 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 225 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
222 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 226 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
223 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 227 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
224 | figLoactions.add(cutLocation.getFig_location()); | 228 | figLoactions.add(cutLocation.getFig_location()); |
225 | } | 229 | } |
226 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); | 230 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); |
227 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); | 231 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); |
228 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 232 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
229 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 233 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
230 | list.get(index).setPath(filepath); | 234 | list.get(index).setPath(filepath); |
231 | imageAdapter.notifyItemChanged(index); | 235 | imageAdapter.notifyItemChanged(index); |
232 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; | 236 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; |
233 | new Handler().postDelayed(new Runnable() { | 237 | new Handler().postDelayed(new Runnable() { |
234 | @Override | 238 | @Override |
235 | public void run() { | 239 | public void run() { |
236 | getRects(finalFigLoactions); | 240 | getRects(finalFigLoactions); |
237 | } | 241 | } |
238 | }, 500); | 242 | }, 500); |
239 | } else { | 243 | } else { |
240 | cancelLoadingDialog(); | 244 | cancelLoadingDialog(); |
241 | } | 245 | } |
242 | } | 246 | } |
243 | 247 | ||
244 | @Override | 248 | @Override |
245 | protected ActivityImageBinding getViewBinding() { | 249 | protected ActivityImageBinding getViewBinding() { |
246 | return ActivityImageBinding.inflate(getLayoutInflater()); | 250 | return ActivityImageBinding.inflate(getLayoutInflater()); |
247 | } | 251 | } |
248 | 252 | ||
249 | public void refreshNum() { | 253 | public void refreshNum() { |
250 | int num = 0; | 254 | int num = 0; |
251 | for (ImageBean imageBean : list) { | 255 | for (ImageBean imageBean : list) { |
252 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 256 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
253 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 257 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
254 | if (cut.isSelect()) { | 258 | if (cut.isSelect()) { |
255 | num++; | 259 | num++; |
256 | } | 260 | } |
257 | } | 261 | } |
258 | } | 262 | } |
259 | } | 263 | } |
260 | if (num > 0) { | 264 | if (num > 0) { |
261 | binding.tvSave.setEnabled(true); | 265 | binding.tvSave.setEnabled(true); |
262 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); | 266 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); |
263 | binding.tvSave.setText("保留错题(" + num + ")"); | 267 | binding.tvSave.setText("保留错题(" + num + ")"); |
264 | } else { | 268 | } else { |
265 | binding.tvSave.setEnabled(false); | 269 | binding.tvSave.setEnabled(false); |
266 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); | 270 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); |
267 | binding.tvSave.setText("保留错题"); | 271 | binding.tvSave.setText("保留错题"); |
268 | } | 272 | } |
269 | } | 273 | } |
270 | 274 | ||
271 | @Override | 275 | @Override |
272 | public void onClick(View v) { | 276 | public void onClick(View v) { |
273 | switch (v.getId()) { | 277 | switch (v.getId()) { |
274 | case R.id.iv_back: | 278 | case R.id.iv_back: |
275 | back(); | 279 | back(); |
276 | break; | 280 | break; |
277 | case R.id.iv_next: | 281 | case R.id.iv_next: |
278 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); | 282 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { |
283 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); | ||
284 | } | ||
279 | break; | 285 | break; |
280 | case R.id.iv_previous: | 286 | case R.id.iv_previous: |
281 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); | 287 | if (binding.viewPager.getCurrentItem() != 0) { |
288 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); | ||
289 | } | ||
282 | break; | 290 | break; |
283 | case R.id.ll_edit: | 291 | case R.id.ll_edit: |
284 | Intent intent = new Intent(context, ImageEditActivity.class); | 292 | Intent intent = new Intent(context, ImageEditActivity.class); |
285 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 293 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
286 | startActivityForResult(intent, 1001); | 294 | startActivityForResult(intent, 1001); |
287 | break; | 295 | break; |
288 | case R.id.tv_photo: | 296 | case R.id.tv_photo: |
289 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 297 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
290 | //确保有相机来处理Intent | 298 | //确保有相机来处理Intent |
291 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 299 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
292 | File photoFile = new File(filePath); | 300 | File photoFile = new File(filePath); |
293 | if (photoFile != null) { | 301 | if (photoFile != null) { |
294 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 302 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
295 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 303 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
296 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 304 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
297 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 305 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
298 | activity.startActivityForResult(takePictureIntent, 1002); | 306 | activity.startActivityForResult(takePictureIntent, 1002); |
299 | } | 307 | } |
300 | break; | 308 | break; |
301 | case R.id.tv_add: | 309 | case R.id.tv_add: |
302 | Intent intent1 = new Intent(context, ImageSelectActivity.class); | 310 | Intent intent1 = new Intent(context, ImageSelectActivity.class); |
303 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 311 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
304 | startActivityForResult(intent1, 1001); | 312 | startActivityForResult(intent1, 1001); |
305 | break; | 313 | break; |
306 | case R.id.tv_save: | 314 | case R.id.tv_save: |
307 | List<TopicBean> topicBeans = new ArrayList<>(); | 315 | List<TopicBean> topicBeans = new ArrayList<>(); |
308 | for (ImageBean imageBean : list) { | 316 | for (ImageBean imageBean : list) { |
309 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 317 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
310 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 318 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
311 | if (cut.isSelect()) { | 319 | if (cut.isSelect()) { |
312 | TopicBean bean = new TopicBean(); | 320 | TopicBean bean = new TopicBean(); |
313 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 321 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
314 | BitmapUtils.saveBitmap(cut.getBitmap(), path); | 322 | BitmapUtils.saveBitmap(cut.getBitmap(), path); |
315 | bean.setPath(path); | 323 | bean.setPath(path); |
316 | topicBeans.add(bean); | 324 | topicBeans.add(bean); |
317 | } | 325 | } |
318 | } | 326 | } |
319 | } | 327 | } |
320 | } | 328 | } |
321 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); | 329 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); |
322 | dialog.show(); | 330 | dialog.show(); |
323 | break; | 331 | break; |
324 | } | 332 | } |
325 | } | 333 | } |
326 | 334 | ||
327 | @Override | 335 | @Override |
328 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 336 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
329 | super.onActivityResult(requestCode, resultCode, data); | 337 | super.onActivityResult(requestCode, resultCode, data); |
330 | if (requestCode == 1001) { | 338 | if (requestCode == 1001) { |
331 | if (resultCode == 1002) { | 339 | if (resultCode == 1002) { |
332 | if (list.size() > 1) { | 340 | if (list.size() > 1) { |
333 | list.remove(binding.viewPager.getCurrentItem()); | 341 | list.remove(binding.viewPager.getCurrentItem()); |
334 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); | 342 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); |
335 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 343 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
336 | refreshNum(); | 344 | refreshNum(); |
337 | } else { | 345 | } else { |
338 | finish(); | 346 | finish(); |
339 | } | 347 | } |
340 | } else if (resultCode == 1003) { | 348 | } else if (resultCode == 1003) { |
341 | int position = binding.viewPager.getCurrentItem(); | 349 | int position = binding.viewPager.getCurrentItem(); |
342 | list.remove(position); | 350 | list.remove(position); |
343 | String path = data.getStringExtra("path"); | 351 | String path = data.getStringExtra("path"); |
344 | ImageBean imageBean = new ImageBean(); | 352 | ImageBean imageBean = new ImageBean(); |
345 | imageBean.setPath(path); | 353 | imageBean.setPath(path); |
346 | list.add(position, imageBean); | 354 | list.add(position, imageBean); |
347 | imageAdapter.notifyItemChanged(position); | 355 | imageAdapter.notifyItemChanged(position); |
348 | clearText(); | 356 | clearText(); |
349 | refreshNum(); | 357 | refreshNum(); |
350 | } else if (resultCode == 1004) { | 358 | } else if (resultCode == 1004) { |
351 | Rect rect = data.getParcelableExtra("cut"); | 359 | Rect rect = data.getParcelableExtra("cut"); |
352 | if (rect != null) { | 360 | if (rect != null) { |
353 | int position = binding.viewPager.getCurrentItem(); | 361 | int position = binding.viewPager.getCurrentItem(); |
354 | ImageBean.Cut cut = new ImageBean.Cut(); | 362 | ImageBean.Cut cut = new ImageBean.Cut(); |
355 | cut.setRect1(rect); | 363 | cut.setRect1(rect); |
356 | cut.setSelect(false); | 364 | cut.setSelect(false); |
357 | list.get(position).getCuts().add(cut); | 365 | list.get(position).getCuts().add(cut); |
358 | imageAdapter.notifyItemChanged(position); | 366 | imageAdapter.notifyItemChanged(position); |
359 | refreshNum(); | 367 | refreshNum(); |
360 | } | 368 | } |
361 | } else if (resultCode == 1005) { | 369 | } else if (resultCode == 1005) { |
362 | int i = data.getIntExtra("position", 0); | 370 | int i = data.getIntExtra("position", 0); |
363 | int position = binding.viewPager.getCurrentItem(); | 371 | int position = binding.viewPager.getCurrentItem(); |
364 | Rect rect = data.getParcelableExtra("cut"); | 372 | Rect rect = data.getParcelableExtra("cut"); |
365 | if (rect != null) { | 373 | if (rect != null) { |
366 | ImageBean.Cut cut = new ImageBean.Cut(); | 374 | ImageBean.Cut cut = new ImageBean.Cut(); |
367 | cut.setRect1(rect); | 375 | cut.setRect1(rect); |
368 | cut.setSelect(false); | 376 | cut.setSelect(false); |
369 | list.get(position).getCuts().remove(i); | 377 | list.get(position).getCuts().remove(i); |
370 | list.get(position).getCuts().add(i, cut); | 378 | list.get(position).getCuts().add(i, cut); |
371 | imageAdapter.notifyItemChanged(position); | 379 | imageAdapter.notifyItemChanged(position); |
372 | refreshNum(); | 380 | refreshNum(); |
373 | } else { | 381 | } else { |
374 | list.get(position).getCuts().remove(i); | 382 | list.get(position).getCuts().remove(i); |
375 | imageAdapter.notifyItemChanged(position); | 383 | imageAdapter.notifyItemChanged(position); |
376 | refreshNum(); | 384 | refreshNum(); |
377 | } | 385 | } |
378 | } | 386 | } |
379 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 387 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
380 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 388 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
381 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 389 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
382 | CommonUtil.saveBitmapToUri(b, path); | 390 | CommonUtil.saveBitmapToUri(b, path); |
383 | int position = binding.viewPager.getCurrentItem(); | 391 | int position = binding.viewPager.getCurrentItem(); |
384 | list.remove(position); | 392 | list.remove(position); |
385 | ImageBean imageBean = new ImageBean(); | 393 | ImageBean imageBean = new ImageBean(); |
386 | imageBean.setPath(path); | 394 | imageBean.setPath(path); |
387 | list.add(position, imageBean); | 395 | list.add(position, imageBean); |
388 | imageAdapter.notifyItemChanged(position); | 396 | imageAdapter.notifyItemChanged(position); |
389 | clearText(); | 397 | clearText(); |
390 | refreshNum(); | 398 | refreshNum(); |
391 | } | 399 | } |
392 | } | 400 | } |
393 | 401 | ||
394 | private void back() { | 402 | private void back() { |
395 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { | 403 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { |
396 | @Override | 404 | @Override |
397 | public void onConfirm(Dialog dialog) { | 405 | public void onConfirm(Dialog dialog) { |
398 | dialog.dismiss(); | 406 | dialog.dismiss(); |
399 | finish(); | 407 | finish(); |
400 | } | 408 | } |
401 | 409 | ||
402 | @Override | 410 | @Override |
403 | public void onCancel(Dialog dialog) { | 411 | public void onCancel(Dialog dialog) { |
404 | dialog.dismiss(); | 412 | dialog.dismiss(); |
405 | } | 413 | } |
406 | }); | 414 | }); |
407 | } | 415 | } |
408 | 416 | ||
409 | @Override | 417 | @Override |
410 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 418 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
411 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 419 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
412 | back(); | 420 | back(); |
413 | return true; | 421 | return true; |
414 | } | 422 | } |
415 | return super.onKeyDown(keyCode, event); | 423 | return super.onKeyDown(keyCode, event); |
416 | } | 424 | } |
417 | } | 425 | } |
418 | 426 |
app/src/main/java/com/hjx/parent/MainActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import androidx.annotation.Nullable; | 3 | import androidx.annotation.Nullable; |
4 | import androidx.appcompat.app.AppCompatActivity; | 4 | import androidx.appcompat.app.AppCompatActivity; |
5 | import androidx.constraintlayout.widget.ConstraintLayout; | 5 | import androidx.constraintlayout.widget.ConstraintLayout; |
6 | import androidx.core.content.FileProvider; | 6 | import androidx.core.content.FileProvider; |
7 | 7 | ||
8 | import android.app.Dialog; | 8 | import android.app.Dialog; |
9 | import android.app.ProgressDialog; | 9 | import android.app.ProgressDialog; |
10 | import android.content.Intent; | 10 | import android.content.Intent; |
11 | import android.graphics.Color; | 11 | import android.graphics.Color; |
12 | import android.net.Uri; | 12 | import android.net.Uri; |
13 | import android.os.Build; | 13 | import android.os.Build; |
14 | import android.os.Bundle; | 14 | import android.os.Bundle; |
15 | import android.os.Looper; | 15 | import android.os.Looper; |
16 | import android.widget.ImageView; | 16 | import android.widget.ImageView; |
17 | import android.widget.TextView; | 17 | import android.widget.TextView; |
18 | import android.widget.Toast; | 18 | import android.widget.Toast; |
19 | 19 | ||
20 | import com.google.gson.JsonObject; | 20 | import com.google.gson.JsonObject; |
21 | import com.hjq.permissions.OnPermissionCallback; | 21 | import com.hjq.permissions.OnPermissionCallback; |
22 | import com.hjq.permissions.Permission; | 22 | import com.hjq.permissions.Permission; |
23 | import com.hjq.permissions.XXPermissions; | 23 | import com.hjq.permissions.XXPermissions; |
24 | import com.hjx.parent.dialog.TipDialog; | 24 | import com.hjx.parent.dialog.TipDialog; |
25 | import com.hjx.parent.fragment.HomeFragment; | 25 | import com.hjx.parent.fragment.HomeFragment; |
26 | import com.hjx.parent.fragment.MeFragment; | 26 | import com.hjx.parent.fragment.MeFragment; |
27 | import com.prws.common.base.BaseActivity; | 27 | import com.prws.common.base.BaseActivity; |
28 | import com.prws.common.base.BasePresenter; | 28 | import com.prws.common.base.BasePresenter; |
29 | import com.prws.common.bean.GradeAndSubject; | 29 | import com.prws.common.bean.GradeAndSubject; |
30 | import com.prws.common.bean.ResponseResult; | 30 | import com.prws.common.bean.ResponseResult; |
31 | import com.prws.common.bean.UpdateBean; | 31 | import com.prws.common.bean.UpdateBean; |
32 | import com.prws.common.net.NetWorks; | 32 | import com.prws.common.net.NetWorks; |
33 | import com.prws.common.utils.DownloadUtil; | 33 | import com.prws.common.utils.DownloadUtil; |
34 | import com.prws.common.utils.SharedPreferencesUtil; | 34 | import com.prws.common.utils.SharedPreferencesUtil; |
35 | 35 | ||
36 | import java.io.File; | 36 | import java.io.File; |
37 | import java.util.List; | 37 | import java.util.List; |
38 | 38 | ||
39 | import io.reactivex.Observer; | 39 | import io.reactivex.Observer; |
40 | import io.reactivex.disposables.Disposable; | 40 | import io.reactivex.disposables.Disposable; |
41 | import retrofit2.Call; | 41 | import retrofit2.Call; |
42 | import retrofit2.Callback; | 42 | import retrofit2.Callback; |
43 | import retrofit2.Response; | 43 | import retrofit2.Response; |
44 | 44 | ||
45 | public class MainActivity extends BaseActivity { | 45 | public class MainActivity extends BaseActivity { |
46 | 46 | ||
47 | @Override | 47 | @Override |
48 | protected int layoutResId() { | 48 | protected int layoutResId() { |
49 | return R.layout.activity_main; | 49 | return R.layout.activity_main; |
50 | } | 50 | } |
51 | 51 | ||
52 | @Override | 52 | @Override |
53 | public Object getContract() { | 53 | public Object getContract() { |
54 | return null; | 54 | return null; |
55 | } | 55 | } |
56 | 56 | ||
57 | @Override | 57 | @Override |
58 | public BasePresenter getPresenter() { | 58 | public BasePresenter getPresenter() { |
59 | return null; | 59 | return null; |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | HomeFragment homeFragment; | 63 | HomeFragment homeFragment; |
64 | MeFragment meFragment; | 64 | MeFragment meFragment; |
65 | ConstraintLayout cl_home; | 65 | ConstraintLayout cl_home; |
66 | ConstraintLayout cl_me; | 66 | ConstraintLayout cl_me; |
67 | ImageView iv_3, iv_4; | 67 | ImageView iv_3, iv_4; |
68 | TextView tv_1, tv_4; | 68 | TextView tv_1, tv_4; |
69 | 69 | ||
70 | 70 | ||
71 | @Override | 71 | @Override |
72 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 72 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
73 | super.onCreate(savedInstanceState); | 73 | super.onCreate(savedInstanceState); |
74 | fullScreen(); | 74 | fullScreen(); |
75 | } | 75 | } |
76 | 76 | ||
77 | @Override | 77 | @Override |
78 | protected void initView() { | 78 | protected void initView() { |
79 | showFragment(getHomeFragment(), R.id.rl_content); | 79 | showFragment(getHomeFragment(), R.id.rl_content); |
80 | cl_home = findViewById(R.id.cl_home); | 80 | cl_home = findViewById(R.id.cl_home); |
81 | cl_me = findViewById(R.id.cl_me); | 81 | cl_me = findViewById(R.id.cl_me); |
82 | iv_3 = findViewById(R.id.iv_3); | 82 | iv_3 = findViewById(R.id.iv_3); |
83 | iv_4 = findViewById(R.id.iv_4); | 83 | iv_4 = findViewById(R.id.iv_4); |
84 | tv_1 = findViewById(R.id.tv_1); | 84 | tv_1 = findViewById(R.id.tv_1); |
85 | tv_4 = findViewById(R.id.tv_4); | 85 | tv_4 = findViewById(R.id.tv_4); |
86 | iv_3.setBackgroundResource(R.mipmap.hoss); | 86 | iv_3.setBackgroundResource(R.mipmap.hoss); |
87 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | 87 | tv_1.setTextColor(Color.parseColor("#1C90F3")); |
88 | NetWorks.getBaiduToken(new Observer<JsonObject>() { | 88 | NetWorks.getBaiduToken(new Observer<JsonObject>() { |
89 | @Override | 89 | @Override |
90 | public void onSubscribe(Disposable d) { | 90 | public void onSubscribe(Disposable d) { |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | @Override | 94 | @Override |
95 | public void onNext(JsonObject jsonObject) { | 95 | public void onNext(JsonObject jsonObject) { |
96 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); | 96 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); |
97 | } | 97 | } |
98 | 98 | ||
99 | @Override | 99 | @Override |
100 | public void onError(Throwable e) { | 100 | public void onError(Throwable e) { |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | @Override | 104 | @Override |
105 | public void onComplete() { | 105 | public void onComplete() { |
106 | 106 | ||
107 | } | 107 | } |
108 | }); | 108 | }); |
109 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { | 109 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { |
110 | @Override | 110 | @Override |
111 | public void onSubscribe(Disposable d) { | 111 | public void onSubscribe(Disposable d) { |
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | @Override | 115 | @Override |
116 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { | 116 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { |
117 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); | 117 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); |
118 | } | 118 | } |
119 | 119 | ||
120 | @Override | 120 | @Override |
121 | public void onError(Throwable e) { | 121 | public void onError(Throwable e) { |
122 | e.toString(); | 122 | e.toString(); |
123 | } | 123 | } |
124 | 124 | ||
125 | @Override | 125 | @Override |
126 | public void onComplete() { | 126 | public void onComplete() { |
127 | 127 | ||
128 | } | 128 | } |
129 | }); | 129 | }); |
130 | checkUpdate(); | 130 | checkUpdate(); |
131 | } | 131 | } |
132 | 132 | ||
133 | public HomeFragment getHomeFragment() { | 133 | public HomeFragment getHomeFragment() { |
134 | if (homeFragment == null) | 134 | if (homeFragment == null) |
135 | homeFragment = new HomeFragment(); | 135 | homeFragment = new HomeFragment(); |
136 | return homeFragment; | 136 | return homeFragment; |
137 | } | 137 | } |
138 | 138 | ||
139 | public MeFragment getMeFragment() { | 139 | public MeFragment getMeFragment() { |
140 | if (meFragment == null) | 140 | if (meFragment == null) |
141 | meFragment = new MeFragment(); | 141 | meFragment = new MeFragment(); |
142 | return meFragment; | 142 | return meFragment; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | @Override | 146 | @Override |
147 | protected void initListener() { | 147 | protected void initListener() { |
148 | cl_home.setOnClickListener(view -> { | 148 | cl_home.setOnClickListener(view -> { |
149 | fullScreen(); | 149 | fullScreen(); |
150 | showFragment(getHomeFragment(), R.id.rl_content); | 150 | showFragment(getHomeFragment(), R.id.rl_content); |
151 | iv_3.setBackgroundResource(R.mipmap.hoss); | 151 | iv_3.setBackgroundResource(R.mipmap.hoss); |
152 | tv_1.setTextColor(Color.parseColor("#1C90F3")); | 152 | tv_1.setTextColor(Color.parseColor("#1C90F3")); |
153 | iv_4.setBackgroundResource(R.mipmap.wmus); | 153 | iv_4.setBackgroundResource(R.mipmap.wmus); |
154 | tv_4.setTextColor(Color.parseColor("#333333")); | 154 | tv_4.setTextColor(Color.parseColor("#333333")); |
155 | }); | 155 | }); |
156 | 156 | ||
157 | cl_me.setOnClickListener(view -> { | 157 | cl_me.setOnClickListener(view -> { |
158 | blackBar(); | 158 | blackBar(); |
159 | showFragment(getMeFragment(), R.id.rl_content); | 159 | showFragment(getMeFragment(), R.id.rl_content); |
160 | iv_3.setBackgroundResource(R.mipmap.hous); | 160 | iv_3.setBackgroundResource(R.mipmap.hous); |
161 | tv_1.setTextColor(Color.parseColor("#333333")); | 161 | tv_1.setTextColor(Color.parseColor("#333333")); |
162 | iv_4.setBackgroundResource(R.mipmap.wmss); | 162 | iv_4.setBackgroundResource(R.mipmap.wmss); |
163 | tv_4.setTextColor(Color.parseColor("#1C90F3")); | 163 | tv_4.setTextColor(Color.parseColor("#1C90F3")); |
164 | }); | 164 | }); |
165 | } | 165 | } |
166 | 166 | ||
167 | @Override | 167 | @Override |
168 | protected void initData() { | 168 | protected void initData() { |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | @Override | 172 | @Override |
173 | public void onNetChanged(int netWorkState) { | 173 | public void onNetChanged(int netWorkState) { |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | public void downloadApk(String url, int versionCode) { | 177 | public void downloadApk(String url, int versionCode) { |
178 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; | 178 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; |
179 | ProgressDialog dialog = new ProgressDialog(this); | 179 | ProgressDialog dialog = new ProgressDialog(this); |
180 | dialog.setTitle("版本更新"); | 180 | dialog.setTitle("版本更新"); |
181 | dialog.setMessage("正在下载新版本,请稍后"); | 181 | dialog.setMessage("正在下载新版本,请稍后"); |
182 | dialog.setMax(100); | 182 | dialog.setMax(100); |
183 | dialog.setProgress(0); | 183 | dialog.setProgress(0); |
184 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | 184 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); |
185 | dialog.show(); | 185 | dialog.show(); |
186 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { | 186 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { |
187 | @Override | 187 | @Override |
188 | public void onDownloadSuccess(String path) { | 188 | public void onDownloadSuccess(String path) { |
189 | dialog.setProgress(100); | 189 | dialog.setProgress(100); |
190 | dialog.dismiss(); | 190 | dialog.dismiss(); |
191 | installApk(filepath); | 191 | installApk(filepath); |
192 | } | 192 | } |
193 | 193 | ||
194 | @Override | 194 | @Override |
195 | public void onDownloading(int progress) { | 195 | public void onDownloading(int progress) { |
196 | dialog.setProgress(progress); | 196 | dialog.setProgress(progress); |
197 | } | 197 | } |
198 | 198 | ||
199 | @Override | 199 | @Override |
200 | public void onDownloadFailed(String msg) { | 200 | public void onDownloadFailed(String msg) { |
201 | dialog.dismiss(); | 201 | dialog.dismiss(); |
202 | Looper.prepare(); | 202 | Looper.prepare(); |
203 | showToast("下载失败。"); | 203 | showToast("下载失败。"); |
204 | Looper.loop(); | 204 | Looper.loop(); |
205 | } | 205 | } |
206 | }); | 206 | }); |
207 | } | 207 | } |
208 | 208 | ||
209 | public void installApk(String path) { | 209 | public void installApk(String path) { |
210 | //开启扫码界面 | 210 | //开启扫码界面 |
211 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); | 211 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); |
212 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 212 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
213 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 | 213 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 |
214 | Uri apkUriN = FileProvider.getUriForFile(MainActivity.this, | 214 | Uri apkUriN = FileProvider.getUriForFile(MainActivity.this, |
215 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); | 215 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); |
216 | intentUpdate.addCategory("android.intent.category.DEFAULT"); | 216 | intentUpdate.addCategory("android.intent.category.DEFAULT"); |
217 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 | 217 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 |
218 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); | 218 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); |
219 | } else { | 219 | } else { |
220 | Uri apkUri = Uri.fromFile(new File(path)); | 220 | Uri apkUri = Uri.fromFile(new File(path)); |
221 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); | 221 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); |
222 | } | 222 | } |
223 | startActivity(intentUpdate); | 223 | startActivity(intentUpdate); |
224 | } | 224 | } |
225 | 225 | ||
226 | public void checkUpdate() { | 226 | public void checkUpdate() { |
227 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { | 227 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { |
228 | @Override | 228 | @Override |
229 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { | 229 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { |
230 | if (response.body() != null && response.body().getCode() == 200) { | 230 | if (response.body() != null && response.body().getCode() == 200) { |
231 | if (response.body().getData() != null) { | 231 | if (response.body().getData() != null) { |
232 | String msg = response.body().getData().getExplain(); | 232 | String msg = response.body().getData().getExplain(); |
233 | String url = response.body().getData().getUrl(); | 233 | String url = response.body().getData().getUrl(); |
234 | int versionCode = response.body().getData().getVersion(); | 234 | int versionCode = response.body().getData().getVersion(); |
235 | showUpdateDialog(msg, url, versionCode); | 235 | showUpdateDialog(msg, url, versionCode); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | @Override | 240 | @Override |
241 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { | 241 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { |
242 | } | 242 | } |
243 | }); | 243 | }); |
244 | } | 244 | } |
245 | 245 | ||
246 | public void showUpdateDialog(String msg, String url, int versionCode) { | 246 | public void showUpdateDialog(String msg, String url, int versionCode) { |
247 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { | 247 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { |
248 | @Override | 248 | @Override |
249 | public void onConfirm(Dialog dialog) { | 249 | public void onConfirm(Dialog dialog) { |
250 | if (!XXPermissions.isGranted(MainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { | 250 | if (!XXPermissions.isGranted(MainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { |
251 | XXPermissions.with(MainActivity.this) | 251 | XXPermissions.with(MainActivity.this) |
252 | // 申请多个权限 | 252 | // 申请多个权限 |
253 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) | 253 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) |
254 | .request(new OnPermissionCallback() { | 254 | .request(new OnPermissionCallback() { |
255 | @Override | 255 | @Override |
256 | public void onGranted(List<String> permissions, boolean all) { | 256 | public void onGranted(List<String> permissions, boolean all) { |
257 | if (all) { | 257 | if (all) { |
258 | //开启扫码界面 | 258 | //开启扫码界面 |
259 | downloadApk(url, versionCode); | 259 | downloadApk(url, versionCode); |
260 | } else { | 260 | } else { |
261 | Toast.makeText(MainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); | 261 | Toast.makeText(MainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | @Override | 265 | @Override |
266 | public void onDenied(List<String> permissions, boolean never) { | 266 | public void onDenied(List<String> permissions, boolean never) { |
267 | XXPermissions.startPermissionActivity(MainActivity.this, permissions); | 267 | XXPermissions.startPermissionActivity(MainActivity.this, permissions); |
268 | } | 268 | } |
269 | }); | 269 | }); |
270 | } else { | 270 | } else { |
271 | downloadApk(url, versionCode); | 271 | downloadApk(url, versionCode); |
272 | } | 272 | } |
273 | 273 | ||
274 | } | 274 | } |
275 | 275 | ||
276 | @Override | 276 | @Override |
277 | public void onCancel(Dialog dialog) { | 277 | public void onCancel(Dialog dialog) { |
278 | dialog.dismiss(); | 278 | dialog.dismiss(); |
279 | } | 279 | } |
280 | }); | 280 | }); |
281 | tipDialog.show(); | 281 | tipDialog.show(); |
282 | } | 282 | } |
283 | } | 283 | } |
app/src/main/java/com/hjx/parent/TeacherMainActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Color; | 6 | import android.graphics.Color; |
7 | import android.net.Uri; | 7 | import android.net.Uri; |
8 | import android.os.Build; | 8 | import android.os.Build; |
9 | import android.os.Looper; | 9 | import android.os.Looper; |
10 | import android.widget.ImageView; | 10 | import android.widget.ImageView; |
11 | import android.widget.TextView; | 11 | import android.widget.TextView; |
12 | import android.widget.Toast; | 12 | import android.widget.Toast; |
13 | 13 | ||
14 | import androidx.constraintlayout.widget.ConstraintLayout; | 14 | import androidx.constraintlayout.widget.ConstraintLayout; |
15 | import androidx.core.content.FileProvider; | 15 | import androidx.core.content.FileProvider; |
16 | 16 | ||
17 | import com.google.gson.JsonObject; | 17 | import com.google.gson.JsonObject; |
18 | import com.hjq.permissions.OnPermissionCallback; | 18 | import com.hjq.permissions.OnPermissionCallback; |
19 | import com.hjq.permissions.Permission; | 19 | import com.hjq.permissions.Permission; |
20 | import com.hjq.permissions.XXPermissions; | 20 | import com.hjq.permissions.XXPermissions; |
21 | import com.hjx.parent.dialog.TipDialog; | 21 | import com.hjx.parent.dialog.TipDialog; |
22 | import com.hjx.parent.fragment.ErrorFragment; | 22 | import com.hjx.parent.fragment.ErrorFragment; |
23 | import com.hjx.parent.fragment.HomeFragment; | 23 | import com.hjx.parent.fragment.HomeFragment; |
24 | import com.hjx.parent.fragment.MeFragment; | 24 | import com.hjx.parent.fragment.MeFragment; |
25 | import com.hjx.parent.fragment.TeacherFragment; | 25 | import com.hjx.parent.fragment.TeacherFragment; |
26 | import com.prws.common.base.BaseActivity; | 26 | import com.prws.common.base.BaseActivity; |
27 | import com.prws.common.base.BasePresenter; | 27 | import com.prws.common.base.BasePresenter; |
28 | import com.prws.common.bean.GradeAndSubject; | 28 | import com.prws.common.bean.GradeAndSubject; |
29 | import com.prws.common.bean.ResponseResult; | 29 | import com.prws.common.bean.ResponseResult; |
30 | import com.prws.common.bean.UpdateBean; | 30 | import com.prws.common.bean.UpdateBean; |
31 | import com.prws.common.net.NetWorks; | 31 | import com.prws.common.net.NetWorks; |
32 | import com.prws.common.utils.DownloadUtil; | 32 | import com.prws.common.utils.DownloadUtil; |
33 | import com.prws.common.utils.SharedPreferencesUtil; | 33 | import com.prws.common.utils.SharedPreferencesUtil; |
34 | 34 | ||
35 | import java.io.File; | 35 | import java.io.File; |
36 | import java.util.List; | 36 | import java.util.List; |
37 | 37 | ||
38 | import io.reactivex.Observer; | 38 | import io.reactivex.Observer; |
39 | import io.reactivex.disposables.Disposable; | 39 | import io.reactivex.disposables.Disposable; |
40 | import retrofit2.Call; | 40 | import retrofit2.Call; |
41 | import retrofit2.Callback; | 41 | import retrofit2.Callback; |
42 | import retrofit2.Response; | 42 | import retrofit2.Response; |
43 | 43 | ||
44 | public class TeacherMainActivity extends BaseActivity { | 44 | public class TeacherMainActivity extends BaseActivity { |
45 | 45 | ||
46 | @Override | 46 | @Override |
47 | protected int layoutResId() { | 47 | protected int layoutResId() { |
48 | return R.layout.activity_main; | 48 | return R.layout.activity_main; |
49 | } | 49 | } |
50 | 50 | ||
51 | @Override | 51 | @Override |
52 | public Object getContract() { | 52 | public Object getContract() { |
53 | return null; | 53 | return null; |
54 | } | 54 | } |
55 | 55 | ||
56 | @Override | 56 | @Override |
57 | public BasePresenter getPresenter() { | 57 | public BasePresenter getPresenter() { |
58 | return null; | 58 | return null; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | ErrorFragment errorFragment; | 62 | ErrorFragment errorFragment; |
63 | TeacherFragment meFragment; | 63 | TeacherFragment meFragment; |
64 | ConstraintLayout cl_home; | 64 | ConstraintLayout cl_home; |
65 | ConstraintLayout cl_me; | 65 | ConstraintLayout cl_me; |
66 | ImageView iv_3, iv_4; | 66 | ImageView iv_3, iv_4; |
67 | TextView tv_1, tv_4; | 67 | TextView tv_1, tv_4; |
68 | 68 | ||
69 | @Override | 69 | @Override |
70 | protected void initView() { | 70 | protected void initView() { |
71 | blackBar(); | 71 | blackBar(); |
72 | showFragment(getErrorFragment(), R.id.rl_content); | 72 | showFragment(getErrorFragment(), R.id.rl_content); |
73 | cl_home = findViewById(R.id.cl_home); | 73 | cl_home = findViewById(R.id.cl_home); |
74 | cl_me = findViewById(R.id.cl_me); | 74 | cl_me = findViewById(R.id.cl_me); |
75 | iv_3 = findViewById(R.id.iv_3); | 75 | iv_3 = findViewById(R.id.iv_3); |
76 | iv_4 = findViewById(R.id.iv_4); | 76 | iv_4 = findViewById(R.id.iv_4); |
77 | tv_1 = findViewById(R.id.tv_1); | 77 | tv_1 = findViewById(R.id.tv_1); |
78 | tv_4 = findViewById(R.id.tv_4); | 78 | tv_4 = findViewById(R.id.tv_4); |
79 | iv_3.setBackgroundResource(R.mipmap.hoss); | 79 | iv_3.setBackgroundResource(R.mipmap.hoss); |
80 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | 80 | tv_1.setTextColor(Color.parseColor("#1C90F3")); |
81 | NetWorks.getBaiduToken(new Observer<JsonObject>() { | 81 | NetWorks.getBaiduToken(new Observer<JsonObject>() { |
82 | @Override | 82 | @Override |
83 | public void onSubscribe(Disposable d) { | 83 | public void onSubscribe(Disposable d) { |
84 | 84 | ||
85 | } | 85 | } |
86 | 86 | ||
87 | @Override | 87 | @Override |
88 | public void onNext(JsonObject jsonObject) { | 88 | public void onNext(JsonObject jsonObject) { |
89 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); | 89 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); |
90 | } | 90 | } |
91 | 91 | ||
92 | @Override | 92 | @Override |
93 | public void onError(Throwable e) { | 93 | public void onError(Throwable e) { |
94 | 94 | ||
95 | } | 95 | } |
96 | 96 | ||
97 | @Override | 97 | @Override |
98 | public void onComplete() { | 98 | public void onComplete() { |
99 | 99 | ||
100 | } | 100 | } |
101 | }); | 101 | }); |
102 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { | 102 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { |
103 | @Override | 103 | @Override |
104 | public void onSubscribe(Disposable d) { | 104 | public void onSubscribe(Disposable d) { |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | @Override | 108 | @Override |
109 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { | 109 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { |
110 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); | 110 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); |
111 | } | 111 | } |
112 | 112 | ||
113 | @Override | 113 | @Override |
114 | public void onError(Throwable e) { | 114 | public void onError(Throwable e) { |
115 | e.toString(); | 115 | e.toString(); |
116 | } | 116 | } |
117 | 117 | ||
118 | @Override | 118 | @Override |
119 | public void onComplete() { | 119 | public void onComplete() { |
120 | 120 | ||
121 | } | 121 | } |
122 | }); | 122 | }); |
123 | checkUpdate(); | 123 | checkUpdate(); |
124 | } | 124 | } |
125 | 125 | ||
126 | public ErrorFragment getErrorFragment() { | 126 | public ErrorFragment getErrorFragment() { |
127 | if (errorFragment == null) | 127 | if (errorFragment == null) |
128 | errorFragment = new ErrorFragment(); | 128 | errorFragment = new ErrorFragment(); |
129 | return errorFragment; | 129 | return errorFragment; |
130 | } | 130 | } |
131 | 131 | ||
132 | public TeacherFragment getMeFragment() { | 132 | public TeacherFragment getMeFragment() { |
133 | if (meFragment == null) | 133 | if (meFragment == null) |
134 | meFragment = new TeacherFragment(); | 134 | meFragment = new TeacherFragment(); |
135 | return meFragment; | 135 | return meFragment; |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | @Override | 139 | @Override |
140 | protected void initListener() { | 140 | protected void initListener() { |
141 | cl_home.setOnClickListener(view -> { | 141 | cl_home.setOnClickListener(view -> { |
142 | showFragment(getErrorFragment(), R.id.rl_content); | 142 | showFragment(getErrorFragment(), R.id.rl_content); |
143 | iv_3.setBackgroundResource(R.mipmap.hoss); | 143 | iv_3.setBackgroundResource(R.mipmap.hoss); |
144 | tv_1.setTextColor(Color.parseColor("#1C90F3")); | 144 | tv_1.setTextColor(Color.parseColor("#1C90F3")); |
145 | iv_4.setBackgroundResource(R.mipmap.wmus); | 145 | iv_4.setBackgroundResource(R.mipmap.wmus); |
146 | tv_4.setTextColor(Color.parseColor("#333333")); | 146 | tv_4.setTextColor(Color.parseColor("#333333")); |
147 | }); | 147 | }); |
148 | 148 | ||
149 | cl_me.setOnClickListener(view -> { | 149 | cl_me.setOnClickListener(view -> { |
150 | showFragment(getMeFragment(), R.id.rl_content); | 150 | showFragment(getMeFragment(), R.id.rl_content); |
151 | iv_3.setBackgroundResource(R.mipmap.hous); | 151 | iv_3.setBackgroundResource(R.mipmap.hous); |
152 | tv_1.setTextColor(Color.parseColor("#333333")); | 152 | tv_1.setTextColor(Color.parseColor("#333333")); |
153 | iv_4.setBackgroundResource(R.mipmap.wmss); | 153 | iv_4.setBackgroundResource(R.mipmap.wmss); |
154 | tv_4.setTextColor(Color.parseColor("#1C90F3")); | 154 | tv_4.setTextColor(Color.parseColor("#1C90F3")); |
155 | }); | 155 | }); |
156 | } | 156 | } |
157 | 157 | ||
158 | @Override | 158 | @Override |
159 | protected void initData() { | 159 | protected void initData() { |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | @Override | 163 | @Override |
164 | public void onNetChanged(int netWorkState) { | 164 | public void onNetChanged(int netWorkState) { |
165 | 165 | ||
166 | } | 166 | } |
167 | 167 | ||
168 | public void downloadApk(String url, int versionCode) { | 168 | public void downloadApk(String url, int versionCode) { |
169 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; | 169 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; |
170 | ProgressDialog dialog = new ProgressDialog(this); | 170 | ProgressDialog dialog = new ProgressDialog(this); |
171 | dialog.setTitle("版本更新"); | 171 | dialog.setTitle("版本更新"); |
172 | dialog.setMessage("正在下载新版本,请稍后"); | 172 | dialog.setMessage("正在下载新版本,请稍后"); |
173 | dialog.setMax(100); | 173 | dialog.setMax(100); |
174 | dialog.setProgress(0); | 174 | dialog.setProgress(0); |
175 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | 175 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); |
176 | dialog.show(); | 176 | dialog.show(); |
177 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { | 177 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { |
178 | @Override | 178 | @Override |
179 | public void onDownloadSuccess(String path) { | 179 | public void onDownloadSuccess(String path) { |
180 | dialog.setProgress(100); | 180 | dialog.setProgress(100); |
181 | dialog.dismiss(); | 181 | dialog.dismiss(); |
182 | installApk(filepath); | 182 | installApk(filepath); |
183 | } | 183 | } |
184 | 184 | ||
185 | @Override | 185 | @Override |
186 | public void onDownloading(int progress) { | 186 | public void onDownloading(int progress) { |
187 | dialog.setProgress(progress); | 187 | dialog.setProgress(progress); |
188 | } | 188 | } |
189 | 189 | ||
190 | @Override | 190 | @Override |
191 | public void onDownloadFailed(String msg) { | 191 | public void onDownloadFailed(String msg) { |
192 | dialog.dismiss(); | 192 | dialog.dismiss(); |
193 | Looper.prepare(); | 193 | Looper.prepare(); |
194 | showToast("下载失败。"); | 194 | showToast("下载失败。"); |
195 | Looper.loop(); | 195 | Looper.loop(); |
196 | } | 196 | } |
197 | }); | 197 | }); |
198 | } | 198 | } |
199 | 199 | ||
200 | public void installApk(String path) { | 200 | public void installApk(String path) { |
201 | //开启扫码界面 | 201 | //开启扫码界面 |
202 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); | 202 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); |
203 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 203 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
204 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 | 204 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 |
205 | Uri apkUriN = FileProvider.getUriForFile(TeacherMainActivity.this, | 205 | Uri apkUriN = FileProvider.getUriForFile(TeacherMainActivity.this, |
206 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); | 206 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); |
207 | intentUpdate.addCategory("android.intent.category.DEFAULT"); | 207 | intentUpdate.addCategory("android.intent.category.DEFAULT"); |
208 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 | 208 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 |
209 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); | 209 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); |
210 | } else { | 210 | } else { |
211 | Uri apkUri = Uri.fromFile(new File(path)); | 211 | Uri apkUri = Uri.fromFile(new File(path)); |
212 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); | 212 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); |
213 | } | 213 | } |
214 | startActivity(intentUpdate); | 214 | startActivity(intentUpdate); |
215 | } | 215 | } |
216 | 216 | ||
217 | @Override | ||
218 | protected void onResume() { | ||
219 | super.onResume(); | ||
220 | if (errorFragment != null) { | ||
221 | errorFragment.refreshStudent(); | ||
222 | } | ||
223 | } | ||
224 | |||
217 | public void checkUpdate() { | 225 | public void checkUpdate() { |
218 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { | 226 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { |
219 | @Override | 227 | @Override |
220 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { | 228 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { |
221 | if (response.body() != null && response.body().getCode() == 200) { | 229 | if (response.body() != null && response.body().getCode() == 200) { |
222 | if (response.body().getData() != null) { | 230 | if (response.body().getData() != null) { |
223 | String msg = response.body().getData().getExplain(); | 231 | String msg = response.body().getData().getExplain(); |
224 | String url = response.body().getData().getUrl(); | 232 | String url = response.body().getData().getUrl(); |
225 | int versionCode = response.body().getData().getVersion(); | 233 | int versionCode = response.body().getData().getVersion(); |
226 | showUpdateDialog(msg, url, versionCode); | 234 | showUpdateDialog(msg, url, versionCode); |
227 | } | 235 | } |
228 | } | 236 | } |
229 | } | 237 | } |
230 | 238 | ||
231 | @Override | 239 | @Override |
232 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { | 240 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { |
233 | } | 241 | } |
234 | }); | 242 | }); |
235 | } | 243 | } |
236 | 244 | ||
237 | public void showUpdateDialog(String msg, String url, int versionCode) { | 245 | public void showUpdateDialog(String msg, String url, int versionCode) { |
238 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { | 246 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { |
239 | @Override | 247 | @Override |
240 | public void onConfirm(Dialog dialog) { | 248 | public void onConfirm(Dialog dialog) { |
241 | if (!XXPermissions.isGranted(TeacherMainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { | 249 | if (!XXPermissions.isGranted(TeacherMainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { |
242 | XXPermissions.with(TeacherMainActivity.this) | 250 | XXPermissions.with(TeacherMainActivity.this) |
243 | // 申请多个权限 | 251 | // 申请多个权限 |
244 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) | 252 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) |
245 | .request(new OnPermissionCallback() { | 253 | .request(new OnPermissionCallback() { |
246 | @Override | 254 | @Override |
247 | public void onGranted(List<String> permissions, boolean all) { | 255 | public void onGranted(List<String> permissions, boolean all) { |
248 | if (all) { | 256 | if (all) { |
249 | //开启扫码界面 | 257 | //开启扫码界面 |
250 | downloadApk(url, versionCode); | 258 | downloadApk(url, versionCode); |
251 | } else { | 259 | } else { |
252 | Toast.makeText(TeacherMainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); | 260 | Toast.makeText(TeacherMainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); |
253 | } | 261 | } |
254 | } | 262 | } |
255 | 263 | ||
256 | @Override | 264 | @Override |
257 | public void onDenied(List<String> permissions, boolean never) { | 265 | public void onDenied(List<String> permissions, boolean never) { |
258 | XXPermissions.startPermissionActivity(TeacherMainActivity.this, permissions); | 266 | XXPermissions.startPermissionActivity(TeacherMainActivity.this, permissions); |
259 | } | 267 | } |
260 | }); | 268 | }); |
261 | } else { | 269 | } else { |
262 | downloadApk(url, versionCode); | 270 | downloadApk(url, versionCode); |
263 | } | 271 | } |
264 | 272 | ||
265 | } | 273 | } |
266 | 274 | ||
267 | @Override | 275 | @Override |
268 | public void onCancel(Dialog dialog) { | 276 | public void onCancel(Dialog dialog) { |
269 | dialog.dismiss(); | 277 | dialog.dismiss(); |
270 | } | 278 | } |
271 | }); | 279 | }); |
272 | tipDialog.show(); | 280 | tipDialog.show(); |
273 | } | 281 | } |
274 | } | 282 | } |
app/src/main/java/com/hjx/parent/adapter/GradeAdapter.java
File was created | 1 | package com.hjx.parent.adapter; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.graphics.Color; | ||
5 | import android.view.LayoutInflater; | ||
6 | import android.view.View; | ||
7 | import android.view.ViewGroup; | ||
8 | import android.widget.TextView; | ||
9 | |||
10 | import androidx.annotation.NonNull; | ||
11 | import androidx.recyclerview.widget.RecyclerView; | ||
12 | |||
13 | import com.hjx.parent.R; | ||
14 | import com.hjx.parent.databinding.ItemFilterTextBinding; | ||
15 | |||
16 | import java.util.List; | ||
17 | |||
18 | public class GradeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||
19 | private List<String> list; | ||
20 | private Filter filter; | ||
21 | private Context context; | ||
22 | private String key; | ||
23 | |||
24 | public interface Filter { | ||
25 | void onSelect(String select); | ||
26 | } | ||
27 | |||
28 | public GradeAdapter(Context context, Filter filter, List<String> list, String key) { | ||
29 | this.context = context; | ||
30 | this.filter = filter; | ||
31 | this.list = list; | ||
32 | this.key = key; | ||
33 | } | ||
34 | |||
35 | public void refresh( String key) { | ||
36 | this.key = key; | ||
37 | notifyDataSetChanged(); | ||
38 | } | ||
39 | |||
40 | @NonNull | ||
41 | @Override | ||
42 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
43 | ItemFilterTextBinding itemFilterBinding = ItemFilterTextBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); | ||
44 | return new FilterHolder(itemFilterBinding); | ||
45 | } | ||
46 | |||
47 | @Override | ||
48 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) { | ||
49 | FilterHolder holder = (FilterHolder) viewHolder; | ||
50 | String value = list.get(i); | ||
51 | holder.binding.tvFilter.setText(value); | ||
52 | if (key.contains(value)) { | ||
53 | holder.binding.tvFilter.setTextColor(Color.WHITE); | ||
54 | holder.binding.tvFilter.setBackgroundResource(R.drawable.bg_soild_blue_25); | ||
55 | } else { | ||
56 | holder.binding.tvFilter.setTextColor(context.getColor(R.color.text_title)); | ||
57 | holder.binding.tvFilter.setBackgroundResource(R.drawable.bg_solid_btn_grad); | ||
58 | } | ||
59 | holder.itemView.setOnClickListener(new View.OnClickListener() { | ||
60 | @Override | ||
61 | public void onClick(View view) { | ||
62 | filter.onSelect(value); | ||
63 | } | ||
64 | }); | ||
65 | } | ||
66 | |||
67 | @Override | ||
68 | public int getItemCount() { | ||
69 | return list.size(); | ||
70 | } | ||
71 | |||
72 | static class FilterHolder extends RecyclerView.ViewHolder { | ||
73 | ItemFilterTextBinding binding; | ||
74 | |||
75 | public FilterHolder(@NonNull ItemFilterTextBinding itemView) { | ||
76 | super(itemView.getRoot()); | ||
77 | binding = itemView; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 |
app/src/main/java/com/hjx/parent/adapter/ImageAdapter.java
1 | package com.hjx.parent.adapter; | 1 | package com.hjx.parent.adapter; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
6 | import android.graphics.BitmapFactory; | 6 | import android.graphics.BitmapFactory; |
7 | import android.graphics.Rect; | 7 | import android.graphics.Rect; |
8 | import android.graphics.RectF; | 8 | import android.graphics.RectF; |
9 | import android.util.Log; | 9 | import android.util.Log; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | import android.widget.RelativeLayout; | 14 | import android.widget.RelativeLayout; |
15 | 15 | ||
16 | import androidx.annotation.NonNull; | 16 | import androidx.annotation.NonNull; |
17 | import androidx.recyclerview.widget.RecyclerView; | 17 | import androidx.recyclerview.widget.RecyclerView; |
18 | 18 | ||
19 | import com.google.gson.Gson; | 19 | import com.google.gson.Gson; |
20 | import com.hjx.parent.ImageActivity; | 20 | import com.hjx.parent.ImageActivity; |
21 | import com.hjx.parent.ImageSelectActivity; | 21 | import com.hjx.parent.ImageSelectActivity; |
22 | import com.hjx.parent.R; | 22 | import com.hjx.parent.R; |
23 | import com.hjx.parent.databinding.ItemImageBinding; | 23 | import com.hjx.parent.databinding.ItemImageBinding; |
24 | import com.prws.common.bean.ImageBean; | 24 | import com.prws.common.bean.ImageBean; |
25 | import com.prws.common.utils.CommonUtil; | 25 | import com.prws.common.utils.CommonUtil; |
26 | 26 | ||
27 | import java.util.List; | 27 | import java.util.List; |
28 | 28 | ||
29 | public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageHolder> { | 29 | public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageHolder> { |
30 | private List<ImageBean> list; | 30 | private List<ImageBean> list; |
31 | private ImageActivity context; | 31 | private ImageActivity context; |
32 | 32 | ||
33 | public ImageAdapter(ImageActivity context, List<ImageBean> list) { | 33 | public ImageAdapter(ImageActivity context, List<ImageBean> list) { |
34 | this.context = context; | 34 | this.context = context; |
35 | this.list = list; | 35 | this.list = list; |
36 | } | 36 | } |
37 | 37 | ||
38 | @NonNull | 38 | @NonNull |
39 | @Override | 39 | @Override |
40 | public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | 40 | public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
41 | ItemImageBinding itemImageBinding = ItemImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); | 41 | ItemImageBinding itemImageBinding = ItemImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); |
42 | return new ImageHolder(itemImageBinding); | 42 | return new ImageHolder(itemImageBinding); |
43 | } | 43 | } |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | public void onBindViewHolder(@NonNull ImageHolder holder, int position) { | 46 | public void onBindViewHolder(@NonNull ImageHolder holder, int position) { |
47 | ImageBean imageBean = list.get(position); | 47 | ImageBean imageBean = list.get(position); |
48 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); | 48 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); |
49 | float imageHeight = bitmap.getHeight(); | 49 | float imageHeight = bitmap.getHeight(); |
50 | float imageWidth = bitmap.getWidth(); | 50 | float imageWidth = bitmap.getWidth(); |
51 | float viewHeight = CommonUtil.getScreenHeight(context) - CommonUtil.dpToPx(context, 250); | 51 | float viewHeight = CommonUtil.getScreenHeight(context) - CommonUtil.dpToPx(context, 250); |
52 | float viewWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); | 52 | float viewWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); |
53 | 53 | ||
54 | RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(holder.binding.ivPic.getLayoutParams()); | 54 | RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(holder.binding.ivPic.getLayoutParams()); |
55 | if (imageHeight / imageWidth > viewHeight / viewWidth) { | 55 | if (imageHeight / imageWidth > viewHeight / viewWidth) { |
56 | if (viewHeight > imageHeight) { | 56 | if (viewHeight > imageHeight) { |
57 | layoutParams.height = (int) imageHeight; | 57 | layoutParams.height = (int) imageHeight; |
58 | layoutParams.width = (int) imageWidth; | 58 | layoutParams.width = (int) imageWidth; |
59 | } else { | 59 | } else { |
60 | layoutParams.height = (int) viewHeight; | 60 | layoutParams.height = (int) viewHeight; |
61 | layoutParams.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); | 61 | layoutParams.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); |
62 | } | 62 | } |
63 | } else { | 63 | } else { |
64 | if (viewWidth > imageWidth) { | 64 | if (viewWidth > imageWidth) { |
65 | layoutParams.height = (int) imageHeight; | 65 | layoutParams.height = (int) imageHeight; |
66 | layoutParams.width = (int) imageWidth; | 66 | layoutParams.width = (int) imageWidth; |
67 | } else { | 67 | } else { |
68 | layoutParams.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); | 68 | layoutParams.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); |
69 | layoutParams.width = (int) viewWidth; | 69 | layoutParams.width = (int) viewWidth; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); | 72 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); |
73 | holder.binding.ivPic.setLayoutParams(layoutParams); | 73 | holder.binding.ivPic.setLayoutParams(layoutParams); |
74 | holder.binding.ivPic.setImageBitmap(bitmap); | 74 | holder.binding.ivPic.setImageBitmap(bitmap); |
75 | 75 | ||
76 | 76 | ||
77 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(holder.binding.rlPic.getLayoutParams()); | 77 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(holder.binding.rlPic.getLayoutParams()); |
78 | if (imageHeight / imageWidth > viewHeight / viewWidth) { | 78 | if (imageHeight / imageWidth > viewHeight / viewWidth) { |
79 | if (viewHeight > imageHeight) { | 79 | if (viewHeight > imageHeight) { |
80 | layoutParams1.height = (int) imageHeight; | 80 | layoutParams1.height = (int) imageHeight; |
81 | layoutParams1.width = (int) imageWidth; | 81 | layoutParams1.width = (int) imageWidth; |
82 | } else { | 82 | } else { |
83 | layoutParams1.height = (int) viewHeight; | 83 | layoutParams1.height = (int) viewHeight; |
84 | layoutParams1.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); | 84 | layoutParams1.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); |
85 | } | 85 | } |
86 | } else { | 86 | } else { |
87 | if (viewWidth > imageWidth) { | 87 | if (viewWidth > imageWidth) { |
88 | layoutParams1.height = (int) imageHeight; | 88 | layoutParams1.height = (int) imageHeight; |
89 | layoutParams1.width = (int) imageWidth; | 89 | layoutParams1.width = (int) imageWidth; |
90 | } else { | 90 | } else { |
91 | layoutParams1.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); | 91 | layoutParams1.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); |
92 | layoutParams1.width = (int) viewWidth; | 92 | layoutParams1.width = (int) viewWidth; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | Log.i("figLoaction", "height=" + layoutParams1.height + " width=" + layoutParams1.width); | 95 | Log.i("figLoaction", "height=" + layoutParams1.height + " width=" + layoutParams1.width); |
96 | layoutParams1.addRule(RelativeLayout.CENTER_IN_PARENT); | 96 | layoutParams1.addRule(RelativeLayout.CENTER_IN_PARENT); |
97 | holder.binding.rlPic.setLayoutParams(layoutParams1); | 97 | holder.binding.rlPic.setLayoutParams(layoutParams1); |
98 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 98 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
99 | holder.binding.rlPic.removeAllViews(); | 99 | holder.binding.rlPic.removeAllViews(); |
100 | for (int i = 0; i < imageBean.getCuts().size(); i++) { | 100 | for (int i = 0; i < imageBean.getCuts().size(); i++) { |
101 | View view = LayoutInflater.from(context).inflate(R.layout.layout_select, null); | 101 | View view = LayoutInflater.from(context).inflate(R.layout.layout_select, null); |
102 | Rect rect; | 102 | Rect rect; |
103 | if (imageBean.getCuts().get(i).getRect1() != null) { | 103 | if (imageBean.getCuts().get(i).getRect1() != null) { |
104 | rect = imageBean.getCuts().get(i).getRect1(); | 104 | rect = imageBean.getCuts().get(i).getRect1(); |
105 | } else { | 105 | } else { |
106 | rect = CommonUtil.getRect(imageBean.getCuts().get(i).getRect(), bitmap, layoutParams1.height, layoutParams1.width); | 106 | rect = CommonUtil.getRect(imageBean.getCuts().get(i).getRect(), bitmap, layoutParams1.height, layoutParams1.width); |
107 | imageBean.getCuts().get(i).setRect1(rect); | 107 | imageBean.getCuts().get(i).setRect1(rect); |
108 | } | 108 | } |
109 | Log.i("figLoaction", new Gson().toJson(rect)); | 109 | Log.i("figLoaction", new Gson().toJson(rect)); |
110 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(rect.right - rect.left, rect.bottom - rect.top); | 110 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(rect.right - rect.left, rect.bottom - rect.top); |
111 | params.setMargins(rect.left, rect.top, 0, 0); | 111 | params.setMargins(rect.left, rect.top, 0, 0); |
112 | holder.binding.rlPic.addView(view, params); | 112 | holder.binding.rlPic.addView(view, params); |
113 | RelativeLayout rl_add = view.findViewById(R.id.rl_add); | 113 | RelativeLayout rl_add = view.findViewById(R.id.rl_add); |
114 | ImageView iv_state = view.findViewById(R.id.iv_state); | 114 | ImageView iv_state = view.findViewById(R.id.iv_state); |
115 | ImageView iv_edit = view.findViewById(R.id.iv_edit); | 115 | ImageView iv_edit = view.findViewById(R.id.iv_edit); |
116 | int finalI = i; | 116 | int finalI = i; |
117 | if (imageBean.getCuts().get(i).isSelect()) { | ||
118 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); | ||
119 | iv_state.setImageResource(R.mipmap.ic_selected); | ||
120 | } else { | ||
121 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); | ||
122 | iv_state.setImageResource(R.mipmap.ic_add); | ||
123 | } | ||
117 | rl_add.setOnClickListener(new View.OnClickListener() { | 124 | rl_add.setOnClickListener(new View.OnClickListener() { |
118 | @Override | 125 | @Override |
119 | public void onClick(View v) { | 126 | public void onClick(View v) { |
120 | Bitmap b = Bitmap.createBitmap(bitmap, v.getLeft() * bitmap.getWidth() / holder.binding.ivPic.getWidth(), v.getTop() * bitmap.getHeight() / holder.binding.ivPic.getHeight(), (v.getRight() - v.getLeft()) * bitmap.getWidth() / holder.binding.ivPic.getWidth(), (v.getBottom() - v.getTop()) * bitmap.getHeight() / holder.binding.ivPic.getHeight()); | 127 | Bitmap b = Bitmap.createBitmap(bitmap, v.getLeft() * bitmap.getWidth() / holder.binding.ivPic.getWidth(), v.getTop() * bitmap.getHeight() / holder.binding.ivPic.getHeight(), (v.getRight() - v.getLeft()) * bitmap.getWidth() / holder.binding.ivPic.getWidth(), (v.getBottom() - v.getTop()) * bitmap.getHeight() / holder.binding.ivPic.getHeight()); |
121 | if (imageBean.getCuts().get(finalI).isSelect()) { | 128 | if (imageBean.getCuts().get(finalI).isSelect()) { |
122 | imageBean.getCuts().get(finalI).setSelect(false); | 129 | imageBean.getCuts().get(finalI).setSelect(false); |
123 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); | 130 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); |
124 | iv_state.setImageResource(R.mipmap.ic_add); | 131 | iv_state.setImageResource(R.mipmap.ic_add); |
125 | } else { | 132 | } else { |
126 | imageBean.getCuts().get(finalI).setSelect(true); | 133 | imageBean.getCuts().get(finalI).setSelect(true); |
127 | imageBean.getCuts().get(finalI).setBitmap(b); | 134 | imageBean.getCuts().get(finalI).setBitmap(b); |
128 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); | 135 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); |
129 | iv_state.setImageResource(R.mipmap.ic_selected); | 136 | iv_state.setImageResource(R.mipmap.ic_selected); |
130 | } | 137 | } |
131 | context.refreshNum(); | 138 | context.refreshNum(); |
132 | } | 139 | } |
133 | }); | 140 | }); |
134 | iv_edit.setOnClickListener(new View.OnClickListener() { | 141 | iv_edit.setOnClickListener(new View.OnClickListener() { |
135 | @Override | 142 | @Override |
136 | public void onClick(View v) { | 143 | public void onClick(View v) { |
137 | Intent intent = new Intent(context, ImageSelectActivity.class); | 144 | Intent intent = new Intent(context, ImageSelectActivity.class); |
138 | intent.putExtra("rect", rect); | 145 | intent.putExtra("rect", rect); |
139 | intent.putExtra("path", imageBean.getPath()); | 146 | intent.putExtra("path", imageBean.getPath()); |
140 | intent.putExtra("position", finalI); | 147 | intent.putExtra("position", finalI); |
141 | context.startActivityForResult(intent, 1001); | 148 | context.startActivityForResult(intent, 1001); |
142 | } | 149 | } |
143 | }); | 150 | }); |
144 | } | 151 | } |
145 | } | 152 | } |
146 | } | 153 | } |
147 | 154 | ||
148 | @Override | 155 | @Override |
149 | public int getItemCount() { | 156 | public int getItemCount() { |
150 | return list.size(); | 157 | return list.size(); |
151 | } | 158 | } |
152 | 159 | ||
153 | static class ImageHolder extends RecyclerView.ViewHolder { | 160 | static class ImageHolder extends RecyclerView.ViewHolder { |
154 | ItemImageBinding binding; | 161 | ItemImageBinding binding; |
155 | 162 | ||
156 | public ImageHolder(@NonNull ItemImageBinding itemView) { | 163 | public ImageHolder(@NonNull ItemImageBinding itemView) { |
157 | super(itemView.getRoot()); | 164 | super(itemView.getRoot()); |
158 | binding = itemView; | 165 | binding = itemView; |
159 | } | 166 | } |
160 | } | 167 | } |
161 | } | 168 | } |
162 | 169 |
app/src/main/java/com/hjx/parent/dialog/ErrorEditDialog.java
1 | package com.hjx.parent.dialog; | 1 | package com.hjx.parent.dialog; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Color; | 6 | import android.graphics.Color; |
7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
8 | import android.view.Gravity; | 8 | import android.view.Gravity; |
9 | import android.view.View; | 9 | import android.view.View; |
10 | import android.view.Window; | 10 | import android.view.Window; |
11 | import android.view.WindowManager; | 11 | import android.view.WindowManager; |
12 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
13 | import android.widget.ArrayAdapter; | 13 | import android.widget.ArrayAdapter; |
14 | import android.widget.CompoundButton; | 14 | import android.widget.CompoundButton; |
15 | import android.widget.RadioButton; | 15 | import android.widget.RadioButton; |
16 | import android.widget.RadioGroup; | 16 | import android.widget.RadioGroup; |
17 | 17 | ||
18 | import androidx.annotation.NonNull; | 18 | import androidx.annotation.NonNull; |
19 | import androidx.recyclerview.widget.LinearLayoutManager; | 19 | import androidx.recyclerview.widget.LinearLayoutManager; |
20 | import androidx.recyclerview.widget.RecyclerView; | 20 | import androidx.recyclerview.widget.RecyclerView; |
21 | 21 | ||
22 | import com.bumptech.glide.Glide; | 22 | import com.bumptech.glide.Glide; |
23 | import com.chad.library.adapter.base.BaseQuickAdapter; | 23 | import com.chad.library.adapter.base.BaseQuickAdapter; |
24 | import com.chad.library.adapter.base.BaseViewHolder; | 24 | import com.chad.library.adapter.base.BaseViewHolder; |
25 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
26 | import com.hjx.parent.AddSuccessActivity; | 26 | import com.hjx.parent.AddSuccessActivity; |
27 | import com.hjx.parent.App; | 27 | import com.hjx.parent.App; |
28 | import com.hjx.parent.ImageActivity; | 28 | import com.hjx.parent.ImageActivity; |
29 | import com.hjx.parent.R; | 29 | import com.hjx.parent.R; |
30 | import com.hjx.parent.bean.StudentBean; | 30 | import com.hjx.parent.bean.StudentBean; |
31 | import com.hjx.parent.databinding.DialogAddErrorBinding; | 31 | import com.hjx.parent.databinding.DialogAddErrorBinding; |
32 | import com.hjx.parent.databinding.DialogEditErrorBinding; | 32 | import com.hjx.parent.databinding.DialogEditErrorBinding; |
33 | import com.prws.common.bean.Grade; | 33 | import com.prws.common.bean.Grade; |
34 | import com.prws.common.bean.GradeAndSubject; | 34 | import com.prws.common.bean.GradeAndSubject; |
35 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.bean.Subject; | 36 | import com.prws.common.bean.Subject; |
37 | import com.prws.common.bean.TopicBean; | 37 | import com.prws.common.bean.TopicBean; |
38 | import com.prws.common.net.NetWorks; | 38 | import com.prws.common.net.NetWorks; |
39 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
40 | import com.prws.common.utils.SharedPreferencesUtil; | 40 | import com.prws.common.utils.SharedPreferencesUtil; |
41 | import com.prws.common.utils.StringUtils; | 41 | import com.prws.common.utils.StringUtils; |
42 | 42 | ||
43 | import java.util.ArrayList; | 43 | import java.util.ArrayList; |
44 | import java.util.HashMap; | 44 | import java.util.HashMap; |
45 | import java.util.List; | 45 | import java.util.List; |
46 | import java.util.Map; | 46 | import java.util.Map; |
47 | 47 | ||
48 | import io.reactivex.Observer; | 48 | import io.reactivex.Observer; |
49 | import io.reactivex.disposables.Disposable; | 49 | import io.reactivex.disposables.Disposable; |
50 | 50 | ||
51 | public class ErrorEditDialog extends Dialog { | 51 | public class ErrorEditDialog extends Dialog { |
52 | private Context context; | 52 | private Context context; |
53 | private DialogEditErrorBinding binding; | 53 | private DialogEditErrorBinding binding; |
54 | private List<TopicBean> list; | 54 | private List<TopicBean> list; |
55 | private Grade grade; | 55 | private Grade grade; |
56 | private String term; | ||
56 | private Subject subject; | 57 | private Subject subject; |
57 | private int reason; | 58 | private int reason; |
58 | private int type = 0; | 59 | private int type = 0; |
59 | private EditInterface editInterface; | 60 | private EditInterface editInterface; |
60 | 61 | ||
61 | public interface EditInterface { | 62 | public interface EditInterface { |
62 | void edit(String name, int reason); | 63 | void edit(String name, int reason); |
63 | } | 64 | } |
64 | 65 | ||
65 | public ErrorEditDialog(@NonNull Context context, List<TopicBean> list, EditInterface editInterface) { | 66 | public ErrorEditDialog(@NonNull Context context, List<TopicBean> list, EditInterface editInterface) { |
66 | super(context, R.style.MyAlertDialog); | 67 | super(context, R.style.MyAlertDialog); |
67 | this.context = context; | 68 | this.context = context; |
68 | this.list = list; | 69 | this.list = list; |
69 | this.editInterface = editInterface; | 70 | this.editInterface = editInterface; |
70 | } | 71 | } |
71 | 72 | ||
72 | @Override | 73 | @Override |
73 | protected void onCreate(Bundle savedInstanceState) { | 74 | protected void onCreate(Bundle savedInstanceState) { |
74 | super.onCreate(savedInstanceState); | 75 | super.onCreate(savedInstanceState); |
75 | binding = DialogEditErrorBinding.inflate(getLayoutInflater()); | 76 | binding = DialogEditErrorBinding.inflate(getLayoutInflater()); |
76 | setContentView(binding.getRoot()); | 77 | setContentView(binding.getRoot()); |
77 | Window dialogWindow = getWindow(); | 78 | Window dialogWindow = getWindow(); |
78 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); | 79 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); |
79 | lp.width = CommonUtil.getScreenWidth(getContext()); | 80 | lp.width = CommonUtil.getScreenWidth(getContext()); |
80 | dialogWindow.setGravity(Gravity.BOTTOM); | 81 | dialogWindow.setGravity(Gravity.BOTTOM); |
81 | dialogWindow.setAttributes(lp); | 82 | dialogWindow.setAttributes(lp); |
82 | List<String> grades = new ArrayList<>(); | 83 | List<String> grades = new ArrayList<>(); |
83 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { | 84 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { |
84 | grades.add(grade.getGrade().getGrade()); | 85 | grades.add(grade.getGrade().getGrade()); |
85 | } | 86 | } |
86 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); | 87 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); |
87 | binding.spinnerGrade.setAdapter(gradeAdapter); | 88 | binding.spinnerGrade.setAdapter(gradeAdapter); |
88 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 89 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
89 | @Override | 90 | @Override |
90 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 91 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
91 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); | 92 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); |
92 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); | 93 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); |
93 | } | 94 | } |
94 | 95 | ||
95 | @Override | 96 | @Override |
96 | public void onNothingSelected(AdapterView<?> parent) { | 97 | public void onNothingSelected(AdapterView<?> parent) { |
97 | 98 | ||
98 | } | 99 | } |
99 | }); | 100 | }); |
101 | ArrayAdapter<String> gradeAdapter1 = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, getContext().getResources().getStringArray(R.array.grade_array)); | ||
102 | binding.spinnerGrade1.setAdapter(gradeAdapter1); | ||
103 | binding.spinnerGrade1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
104 | @Override | ||
105 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
106 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | public void onNothingSelected(AdapterView<?> parent) { | ||
111 | |||
112 | } | ||
113 | }); | ||
100 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); | 114 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); |
101 | binding.spinnerReason.setAdapter(reasonAdapter); | 115 | binding.spinnerReason.setAdapter(reasonAdapter); |
102 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 116 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
103 | @Override | 117 | @Override |
104 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 118 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
105 | reason = position; | 119 | reason = position; |
106 | } | 120 | } |
107 | 121 | ||
108 | @Override | 122 | @Override |
109 | public void onNothingSelected(AdapterView<?> parent) { | 123 | public void onNothingSelected(AdapterView<?> parent) { |
110 | 124 | ||
111 | } | 125 | } |
112 | }); | 126 | }); |
113 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); | 127 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); |
114 | typeButton.setChecked(true); | 128 | typeButton.setChecked(true); |
115 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 129 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
116 | @Override | 130 | @Override |
117 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 131 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
118 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 132 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
119 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; | 133 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; |
120 | } | 134 | } |
121 | }); | 135 | }); |
122 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 136 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
123 | @Override | 137 | @Override |
124 | public void onClick(View v) { | 138 | public void onClick(View v) { |
125 | dismiss(); | 139 | dismiss(); |
126 | } | 140 | } |
127 | }); | 141 | }); |
128 | binding.addTopic.setOnClickListener(new View.OnClickListener() { | 142 | binding.addTopic.setOnClickListener(new View.OnClickListener() { |
129 | @Override | 143 | @Override |
130 | public void onClick(View v) { | 144 | public void onClick(View v) { |
131 | editError(); | 145 | editError(); |
132 | } | 146 | } |
133 | }); | 147 | }); |
134 | } | 148 | } |
135 | 149 | ||
136 | private void editError() { | 150 | private void editError() { |
137 | List<HashMap<String, Object>> hashMapArrayList = new ArrayList<>(); | 151 | List<HashMap<String, Object>> hashMapArrayList = new ArrayList<>(); |
138 | for (TopicBean topicBean : list) { | 152 | for (TopicBean topicBean : list) { |
139 | HashMap<String, Object> map = new HashMap<>(); | 153 | HashMap<String, Object> map = new HashMap<>(); |
140 | map.put("bookId", topicBean.getId()); | 154 | map.put("bookId", topicBean.getId()); |
141 | map.put("grade", grade.getGrade()); | 155 | map.put("grade", grade.getGrade() + term); |
142 | map.put("subject", subject.getSubject()); | 156 | map.put("subject", subject.getSubject()); |
143 | map.put("errorReason", String.valueOf(reason)); | 157 | map.put("errorReason", String.valueOf(reason)); |
144 | map.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); | 158 | map.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); |
145 | map.put("type", type); | 159 | map.put("type", type); |
146 | hashMapArrayList.add(map); | 160 | hashMapArrayList.add(map); |
147 | } | 161 | } |
148 | NetWorks.editError(hashMapArrayList, new Observer<ResponseResult>() { | 162 | NetWorks.editError(hashMapArrayList, new Observer<ResponseResult>() { |
149 | @Override | 163 | @Override |
150 | public void onSubscribe(Disposable d) { | 164 | public void onSubscribe(Disposable d) { |
151 | 165 | ||
152 | } | 166 | } |
153 | 167 | ||
154 | @Override | 168 | @Override |
155 | public void onNext(ResponseResult responseResult) { | 169 | public void onNext(ResponseResult responseResult) { |
156 | if (responseResult.getCode() == 200) { | 170 | if (responseResult.getCode() == 200) { |
157 | editInterface.edit(grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题", reason); | 171 | editInterface.edit(grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题", reason); |
158 | dismiss(); | 172 | dismiss(); |
159 | } | 173 | } |
160 | } | 174 | } |
161 | 175 | ||
162 | @Override | 176 | @Override |
163 | public void onError(Throwable e) { | 177 | public void onError(Throwable e) { |
164 | 178 | ||
165 | } | 179 | } |
166 | 180 | ||
167 | @Override | 181 | @Override |
168 | public void onComplete() { | 182 | public void onComplete() { |
169 | 183 | ||
170 | } | 184 | } |
171 | }); | 185 | }); |
172 | } | 186 | } |
173 | 187 | ||
174 | private void refreshSubject(List<Subject> subjects) { | 188 | private void refreshSubject(List<Subject> subjects) { |
175 | List<String> s = new ArrayList<>(); | 189 | List<String> s = new ArrayList<>(); |
176 | for (Subject subject : subjects) { | 190 | for (Subject subject : subjects) { |
177 | s.add(subject.getSubject()); | 191 | s.add(subject.getSubject()); |
178 | } | 192 | } |
179 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); | 193 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); |
180 | binding.spinnerSubject.setAdapter(subjectAdapter); | 194 | binding.spinnerSubject.setAdapter(subjectAdapter); |
181 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 195 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
182 | @Override | 196 | @Override |
183 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 197 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
184 | subject = subjects.get(position); | 198 | subject = subjects.get(position); |
185 | } | 199 | } |
186 | 200 | ||
187 | @Override | 201 | @Override |
188 | public void onNothingSelected(AdapterView<?> parent) { | 202 | public void onNothingSelected(AdapterView<?> parent) { |
189 | 203 | ||
190 | } | 204 | } |
191 | }); | 205 | }); |
192 | } | 206 | } |
193 | 207 | ||
194 | } | 208 | } |
195 | 209 |
app/src/main/java/com/hjx/parent/dialog/ErrorInputDialog.java
1 | package com.hjx.parent.dialog; | 1 | package com.hjx.parent.dialog; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Color; | 6 | import android.graphics.Color; |
7 | import android.graphics.drawable.Drawable; | 7 | import android.graphics.drawable.Drawable; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.Window; | 11 | import android.view.Window; |
12 | import android.view.WindowManager; | 12 | import android.view.WindowManager; |
13 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.ArrayAdapter; | 14 | import android.widget.ArrayAdapter; |
15 | import android.widget.CompoundButton; | 15 | import android.widget.CompoundButton; |
16 | import android.widget.RadioButton; | 16 | import android.widget.RadioButton; |
17 | import android.widget.RadioGroup; | 17 | import android.widget.RadioGroup; |
18 | 18 | ||
19 | import androidx.annotation.NonNull; | 19 | import androidx.annotation.NonNull; |
20 | import androidx.recyclerview.widget.LinearLayoutManager; | 20 | import androidx.recyclerview.widget.LinearLayoutManager; |
21 | import androidx.recyclerview.widget.RecyclerView; | 21 | import androidx.recyclerview.widget.RecyclerView; |
22 | 22 | ||
23 | import com.bumptech.glide.Glide; | 23 | import com.bumptech.glide.Glide; |
24 | import com.chad.library.adapter.base.BaseQuickAdapter; | 24 | import com.chad.library.adapter.base.BaseQuickAdapter; |
25 | import com.chad.library.adapter.base.BaseViewHolder; | 25 | import com.chad.library.adapter.base.BaseViewHolder; |
26 | import com.google.gson.Gson; | 26 | import com.google.gson.Gson; |
27 | import com.hjx.parent.AddSuccessActivity; | 27 | import com.hjx.parent.AddSuccessActivity; |
28 | import com.hjx.parent.App; | 28 | import com.hjx.parent.App; |
29 | import com.hjx.parent.ImageActivity; | 29 | import com.hjx.parent.ImageActivity; |
30 | import com.hjx.parent.R; | 30 | import com.hjx.parent.R; |
31 | import com.hjx.parent.bean.StudentBean; | 31 | import com.hjx.parent.bean.StudentBean; |
32 | import com.hjx.parent.databinding.DialogAddErrorBinding; | 32 | import com.hjx.parent.databinding.DialogAddErrorBinding; |
33 | import com.prws.common.bean.Grade; | 33 | import com.prws.common.bean.Grade; |
34 | import com.prws.common.bean.GradeAndSubject; | 34 | import com.prws.common.bean.GradeAndSubject; |
35 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.bean.Subject; | 36 | import com.prws.common.bean.Subject; |
37 | import com.prws.common.bean.TopicBean; | 37 | import com.prws.common.bean.TopicBean; |
38 | import com.prws.common.net.NetWorks; | 38 | import com.prws.common.net.NetWorks; |
39 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
40 | import com.prws.common.utils.LogUtil; | 40 | import com.prws.common.utils.LogUtil; |
41 | import com.prws.common.utils.SharedPreferencesUtil; | 41 | import com.prws.common.utils.SharedPreferencesUtil; |
42 | import com.prws.common.utils.StringUtils; | 42 | import com.prws.common.utils.StringUtils; |
43 | 43 | ||
44 | import org.json.JSONArray; | 44 | import org.json.JSONArray; |
45 | import org.json.JSONObject; | 45 | import org.json.JSONObject; |
46 | 46 | ||
47 | import java.util.ArrayList; | 47 | import java.util.ArrayList; |
48 | import java.util.HashMap; | 48 | import java.util.HashMap; |
49 | import java.util.List; | 49 | import java.util.List; |
50 | import java.util.Map; | 50 | import java.util.Map; |
51 | 51 | ||
52 | import io.reactivex.Observer; | 52 | import io.reactivex.Observer; |
53 | import io.reactivex.disposables.Disposable; | 53 | import io.reactivex.disposables.Disposable; |
54 | import okhttp3.ResponseBody; | 54 | import okhttp3.ResponseBody; |
55 | 55 | ||
56 | public class ErrorInputDialog extends Dialog { | 56 | public class ErrorInputDialog extends Dialog { |
57 | private ImageActivity context; | 57 | private ImageActivity context; |
58 | private DialogAddErrorBinding binding; | 58 | private DialogAddErrorBinding binding; |
59 | private List<TopicBean> list; | 59 | private List<TopicBean> list; |
60 | private int select = 0; | 60 | private int select = 0; |
61 | private Grade grade; | 61 | private Grade grade; |
62 | private String term; | ||
62 | private Subject subject; | 63 | private Subject subject; |
63 | private int reason; | 64 | private int reason; |
64 | private int type = 0; | 65 | private int type = 0; |
65 | BaseQuickAdapter adapter; | 66 | BaseQuickAdapter adapter; |
66 | 67 | ||
67 | public ErrorInputDialog(@NonNull ImageActivity context, List<TopicBean> list) { | 68 | public ErrorInputDialog(@NonNull ImageActivity context, List<TopicBean> list) { |
68 | super(context, R.style.MyAlertDialog); | 69 | super(context, R.style.MyAlertDialog); |
69 | this.context = context; | 70 | this.context = context; |
70 | this.list = list; | 71 | this.list = list; |
71 | } | 72 | } |
72 | 73 | ||
73 | @Override | 74 | @Override |
74 | protected void onCreate(Bundle savedInstanceState) { | 75 | protected void onCreate(Bundle savedInstanceState) { |
75 | super.onCreate(savedInstanceState); | 76 | super.onCreate(savedInstanceState); |
76 | binding = DialogAddErrorBinding.inflate(getLayoutInflater()); | 77 | binding = DialogAddErrorBinding.inflate(getLayoutInflater()); |
77 | setContentView(binding.getRoot()); | 78 | setContentView(binding.getRoot()); |
78 | Window dialogWindow = getWindow(); | 79 | Window dialogWindow = getWindow(); |
79 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); | 80 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); |
80 | lp.width = CommonUtil.getScreenWidth(getContext()); | 81 | lp.width = CommonUtil.getScreenWidth(getContext()); |
81 | dialogWindow.setGravity(Gravity.BOTTOM); | 82 | dialogWindow.setGravity(Gravity.BOTTOM); |
82 | dialogWindow.setAttributes(lp); | 83 | dialogWindow.setAttributes(lp); |
83 | adapter = new BaseQuickAdapter(R.layout.item_topic, list) { | 84 | adapter = new BaseQuickAdapter(R.layout.item_topic, list) { |
84 | @Override | 85 | @Override |
85 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 86 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
86 | int position = item.getAdapterPosition(); | 87 | int position = item.getAdapterPosition(); |
87 | item.setText(R.id.tv_name, context.getString(R.string.num_topic, StringUtils.intToChinese(position + 1))); | 88 | item.setText(R.id.tv_name, context.getString(R.string.num_topic, StringUtils.intToChinese(position + 1))); |
88 | if (list.get(position).isFinish()) { | 89 | if (list.get(position).isFinish()) { |
89 | item.setGone(R.id.iv_click, true); | 90 | item.setGone(R.id.iv_click, true); |
90 | item.setBackgroundRes(R.id.tv_name, R.drawable.topic_finish_bg); | 91 | item.setBackgroundRes(R.id.tv_name, R.drawable.topic_finish_bg); |
91 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); | 92 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); |
92 | } else if (select == position) { | 93 | } else if (select == position) { |
93 | item.setGone(R.id.iv_click, false); | 94 | item.setGone(R.id.iv_click, false); |
94 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_select_topic_bg); | 95 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_select_topic_bg); |
95 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); | 96 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); |
96 | } else { | 97 | } else { |
97 | item.setGone(R.id.iv_click, false); | 98 | item.setGone(R.id.iv_click, false); |
98 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_topic_bg); | 99 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_topic_bg); |
99 | item.setTextColor(R.id.tv_name, Color.parseColor("#999999")); | 100 | item.setTextColor(R.id.tv_name, Color.parseColor("#999999")); |
100 | } | 101 | } |
101 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 102 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
102 | @Override | 103 | @Override |
103 | public void onClick(View v) { | 104 | public void onClick(View v) { |
104 | select = position; | 105 | select = position; |
105 | loadError(); | 106 | loadError(); |
106 | notifyDataSetChanged(); | 107 | notifyDataSetChanged(); |
107 | } | 108 | } |
108 | }); | 109 | }); |
109 | } | 110 | } |
110 | 111 | ||
111 | @Override | 112 | @Override |
112 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 113 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
113 | 114 | ||
114 | } | 115 | } |
115 | }; | 116 | }; |
116 | binding.listItem.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); | 117 | binding.listItem.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); |
117 | binding.listItem.setAdapter(adapter); | 118 | binding.listItem.setAdapter(adapter); |
118 | List<String> grades = new ArrayList<>(); | 119 | List<String> grades = new ArrayList<>(); |
119 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { | 120 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { |
120 | grades.add(grade.getGrade().getGrade()); | 121 | grades.add(grade.getGrade().getGrade()); |
121 | } | 122 | } |
122 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); | 123 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); |
123 | binding.spinnerGrade.setAdapter(gradeAdapter); | 124 | binding.spinnerGrade.setAdapter(gradeAdapter); |
124 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 125 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
125 | @Override | 126 | @Override |
126 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 127 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
127 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); | 128 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); |
128 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); | 129 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); |
129 | } | 130 | } |
130 | 131 | ||
131 | @Override | 132 | @Override |
132 | public void onNothingSelected(AdapterView<?> parent) { | 133 | public void onNothingSelected(AdapterView<?> parent) { |
133 | 134 | ||
134 | } | 135 | } |
135 | }); | 136 | }); |
137 | ArrayAdapter<String> gradeAdapter1 = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, getContext().getResources().getStringArray(R.array.grade_array)); | ||
138 | binding.spinnerGrade1.setAdapter(gradeAdapter1); | ||
139 | binding.spinnerGrade1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
140 | @Override | ||
141 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
142 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public void onNothingSelected(AdapterView<?> parent) { | ||
147 | |||
148 | } | ||
149 | }); | ||
136 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); | 150 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); |
137 | binding.spinnerReason.setAdapter(reasonAdapter); | 151 | binding.spinnerReason.setAdapter(reasonAdapter); |
138 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 152 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
139 | @Override | 153 | @Override |
140 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 154 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
141 | reason = position; | 155 | reason = position; |
142 | } | 156 | } |
143 | 157 | ||
144 | @Override | 158 | @Override |
145 | public void onNothingSelected(AdapterView<?> parent) { | 159 | public void onNothingSelected(AdapterView<?> parent) { |
146 | 160 | ||
147 | } | 161 | } |
148 | }); | 162 | }); |
149 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); | 163 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); |
150 | typeButton.setChecked(true); | 164 | typeButton.setChecked(true); |
151 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 165 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
152 | @Override | 166 | @Override |
153 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 167 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
154 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 168 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
155 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; | 169 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; |
156 | list.get(select).setType(type); | 170 | list.get(select).setType(type); |
157 | } | 171 | } |
158 | }); | 172 | }); |
159 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 173 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
160 | @Override | 174 | @Override |
161 | public void onClick(View v) { | 175 | public void onClick(View v) { |
162 | dismiss(); | 176 | dismiss(); |
163 | } | 177 | } |
164 | }); | 178 | }); |
165 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | 179 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
166 | @Override | 180 | @Override |
167 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | 181 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
168 | if (isChecked) { | 182 | if (isChecked) { |
169 | binding.addTopic.setText("全部加入错题本"); | 183 | binding.addTopic.setText("全部加入错题本"); |
170 | } else { | 184 | } else { |
171 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); | 185 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); |
172 | } | 186 | } |
173 | } | 187 | } |
174 | }); | 188 | }); |
175 | binding.addTopic.setOnClickListener(new View.OnClickListener() { | 189 | binding.addTopic.setOnClickListener(new View.OnClickListener() { |
176 | @Override | 190 | @Override |
177 | public void onClick(View v) { | 191 | public void onClick(View v) { |
178 | if (binding.checkbox.isChecked()) { | 192 | if (binding.checkbox.isChecked()) { |
179 | for (TopicBean topicBean : list) { | 193 | for (TopicBean topicBean : list) { |
180 | addTopic(topicBean); | 194 | addTopic(topicBean); |
181 | } | 195 | } |
182 | } else { | 196 | } else { |
183 | addTopic(list.get(select)); | 197 | addTopic(list.get(select)); |
184 | } | 198 | } |
185 | } | 199 | } |
186 | }); | 200 | }); |
187 | loadError(); | 201 | loadError(); |
188 | } | 202 | } |
189 | 203 | ||
190 | 204 | ||
191 | private void refreshSubject(List<Subject> subjects) { | 205 | private void refreshSubject(List<Subject> subjects) { |
192 | List<String> s = new ArrayList<>(); | 206 | List<String> s = new ArrayList<>(); |
193 | for (Subject subject : subjects) { | 207 | for (Subject subject : subjects) { |
194 | s.add(subject.getSubject()); | 208 | s.add(subject.getSubject()); |
195 | } | 209 | } |
196 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); | 210 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); |
197 | binding.spinnerSubject.setAdapter(subjectAdapter); | 211 | binding.spinnerSubject.setAdapter(subjectAdapter); |
198 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 212 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
199 | @Override | 213 | @Override |
200 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 214 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
201 | subject = subjects.get(position); | 215 | subject = subjects.get(position); |
202 | } | 216 | } |
203 | 217 | ||
204 | @Override | 218 | @Override |
205 | public void onNothingSelected(AdapterView<?> parent) { | 219 | public void onNothingSelected(AdapterView<?> parent) { |
206 | 220 | ||
207 | } | 221 | } |
208 | }); | 222 | }); |
209 | } | 223 | } |
210 | 224 | ||
211 | private void loadError() { | 225 | private void loadError() { |
212 | TopicBean bean = list.get(select); | 226 | TopicBean bean = list.get(select); |
213 | Glide.with(getContext()).load(bean.getPath()).override(CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(getContext(), 40), CommonUtil.dpToPx(getContext(), 90)).fitCenter().into(binding.ivTopic); | 227 | Glide.with(getContext()).load(bean.getPath()).override(CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(getContext(), 40), CommonUtil.dpToPx(getContext(), 90)).fitCenter().into(binding.ivTopic); |
214 | if (!binding.checkbox.isChecked()) { | 228 | if (!binding.checkbox.isChecked()) { |
215 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); | 229 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); |
216 | } | 230 | } |
217 | } | 231 | } |
218 | 232 | ||
219 | private void addTopic(TopicBean bean) { | 233 | private void addTopic(TopicBean bean) { |
220 | if (!bean.isFinish()) { | 234 | if (!bean.isFinish()) { |
221 | bean.setId(String.valueOf(System.currentTimeMillis())); | 235 | bean.setId(String.valueOf(System.currentTimeMillis())); |
222 | bean.setDate(String.valueOf(System.currentTimeMillis())); | 236 | bean.setDate(String.valueOf(System.currentTimeMillis())); |
223 | bean.setGrade(grade.getGrade()); | 237 | bean.setGrade(grade.getGrade()); |
224 | bean.setType(type); | 238 | bean.setType(type); |
225 | bean.setSubject(subject.getSubject()); | 239 | bean.setSubject(subject.getSubject()); |
226 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 240 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
227 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); | 241 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); |
228 | Map<String, String> param = new HashMap<>(); | 242 | Map<String, String> param = new HashMap<>(); |
229 | param.put("bookId", bean.getId()); | 243 | param.put("bookId", bean.getId()); |
230 | param.put("stuId", studentBean.getStuId()); | 244 | param.put("stuId", studentBean.getStuId()); |
231 | param.put("errorReason", String.valueOf(reason)); | 245 | param.put("errorReason", String.valueOf(reason)); |
232 | param.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); | 246 | param.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); |
233 | param.put("subject", bean.getSubject()); | 247 | param.put("subject", bean.getSubject()); |
234 | param.put("grade", bean.getGrade()); | 248 | param.put("grade", bean.getGrade() + term); |
235 | param.put("type", String.valueOf(bean.getType())); | 249 | param.put("type", String.valueOf(bean.getType())); |
236 | param.put("teacherFlag", "0"); | 250 | param.put("teacherFlag", "0"); |
237 | param.put("controlFlag", "1"); | 251 | param.put("controlFlag", "1"); |
238 | NetWorks.addError(bean.getPath(), param, new Observer<ResponseResult>() { | 252 | NetWorks.addError(bean.getPath(), param, new Observer<ResponseResult>() { |
239 | @Override | 253 | @Override |
240 | public void onSubscribe(Disposable d) { | 254 | public void onSubscribe(Disposable d) { |
241 | 255 | ||
242 | } | 256 | } |
243 | 257 | ||
244 | @Override | 258 | @Override |
245 | public void onNext(ResponseResult responseResult) { | 259 | public void onNext(ResponseResult responseResult) { |
246 | if (responseResult.getCode() == 200) { | 260 | if (responseResult.getCode() == 200) { |
247 | bean.setFinish(true); | 261 | bean.setFinish(true); |
248 | boolean isAllAdd = true; | 262 | boolean isAllAdd = true; |
249 | for (int i = 0; i < list.size(); i++) { | 263 | for (int i = 0; i < list.size(); i++) { |
250 | if (!list.get(i).isFinish()) { | 264 | if (!list.get(i).isFinish()) { |
251 | select = i; | 265 | select = i; |
252 | adapter.notifyDataSetChanged(); | 266 | adapter.notifyDataSetChanged(); |
253 | isAllAdd = false; | 267 | isAllAdd = false; |
254 | loadError(); | 268 | loadError(); |
255 | break; | 269 | break; |
256 | } | 270 | } |
257 | } | 271 | } |
258 | if (isAllAdd) { | 272 | if (isAllAdd) { |
259 | dismiss(); | 273 | dismiss(); |
260 | Intent intent = new Intent(context, AddSuccessActivity.class); | 274 | Intent intent = new Intent(context, AddSuccessActivity.class); |
261 | context.startActivity(intent); | 275 | context.startActivity(intent); |
262 | context.finish(); | 276 | context.finish(); |
263 | } | 277 | } |
264 | } | 278 | } |
265 | } | 279 | } |
266 | 280 | ||
267 | @Override | 281 | @Override |
268 | public void onError(Throwable e) { | 282 | public void onError(Throwable e) { |
269 | 283 | ||
270 | } | 284 | } |
271 | 285 | ||
272 | @Override | 286 | @Override |
273 | public void onComplete() { | 287 | public void onComplete() { |
274 | 288 | ||
275 | } | 289 | } |
276 | }); | 290 | }); |
277 | } | 291 | } |
278 | } | 292 | } |
279 | } | 293 | } |
280 | 294 |
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.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
8 | import android.net.Uri; | 8 | import android.net.Uri; |
9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
10 | import android.provider.MediaStore; | 10 | import android.provider.MediaStore; |
11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
12 | import android.util.Log; | 12 | import android.util.Log; |
13 | import android.view.LayoutInflater; | 13 | import android.view.LayoutInflater; |
14 | import android.view.View; | 14 | import android.view.View; |
15 | import android.view.ViewGroup; | 15 | import android.view.ViewGroup; |
16 | import android.widget.ImageView; | 16 | import android.widget.ImageView; |
17 | import android.widget.LinearLayout; | 17 | import android.widget.LinearLayout; |
18 | import android.widget.Toast; | 18 | import android.widget.Toast; |
19 | 19 | ||
20 | import androidx.annotation.NonNull; | 20 | import androidx.annotation.NonNull; |
21 | import androidx.annotation.Nullable; | 21 | import androidx.annotation.Nullable; |
22 | import androidx.core.content.FileProvider; | 22 | import androidx.core.content.FileProvider; |
23 | import androidx.recyclerview.widget.LinearLayoutManager; | 23 | import androidx.recyclerview.widget.LinearLayoutManager; |
24 | import androidx.recyclerview.widget.RecyclerView; | 24 | import androidx.recyclerview.widget.RecyclerView; |
25 | 25 | ||
26 | import com.bumptech.glide.Glide; | 26 | import com.bumptech.glide.Glide; |
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | import com.bumptech.glide.request.RequestOptions; | 28 | import com.bumptech.glide.request.RequestOptions; |
29 | import com.chad.library.adapter.base.BaseQuickAdapter; | 29 | import com.chad.library.adapter.base.BaseQuickAdapter; |
30 | import com.chad.library.adapter.base.BaseViewHolder; | 30 | import com.chad.library.adapter.base.BaseViewHolder; |
31 | import com.google.gson.Gson; | 31 | import com.google.gson.Gson; |
32 | import com.hjq.permissions.OnPermissionCallback; | 32 | import com.hjq.permissions.OnPermissionCallback; |
33 | import com.hjq.permissions.Permission; | 33 | import com.hjq.permissions.Permission; |
34 | import com.hjq.permissions.XXPermissions; | 34 | import com.hjq.permissions.XXPermissions; |
35 | import com.hjx.parent.ChooseActivity; | 35 | import com.hjx.parent.ChooseActivity; |
36 | import com.hjx.parent.ErrorBookActivity; | 36 | import com.hjx.parent.ErrorBookActivity; |
37 | import com.hjx.parent.ErrorListActivity; | 37 | import com.hjx.parent.ErrorListActivity; |
38 | import com.hjx.parent.ImageActivity; | 38 | import com.hjx.parent.ImageActivity; |
39 | import com.hjx.parent.R; | 39 | import com.hjx.parent.R; |
40 | import com.hjx.parent.TeacherChooseActivity; | 40 | import com.hjx.parent.TeacherChooseActivity; |
41 | import com.hjx.parent.adapter.ErrorAdapter; | 41 | import com.hjx.parent.adapter.ErrorAdapter; |
42 | import com.hjx.parent.bean.StudentBean; | 42 | import com.hjx.parent.bean.StudentBean; |
43 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | 43 | import com.hjx.parent.databinding.ActivityErrorBookBinding; |
44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
45 | import com.prws.common.bean.PageInfo; | 45 | import com.prws.common.bean.PageInfo; |
46 | import com.prws.common.bean.ResponseResult; | 46 | import com.prws.common.bean.ResponseResult; |
47 | import com.prws.common.bean.TopicBean; | 47 | import com.prws.common.bean.TopicBean; |
48 | import com.prws.common.net.NetWorks; | 48 | import com.prws.common.net.NetWorks; |
49 | import com.prws.common.utils.BitmapUtils; | 49 | import com.prws.common.utils.BitmapUtils; |
50 | import com.prws.common.utils.CommonUtil; | 50 | import com.prws.common.utils.CommonUtil; |
51 | import com.prws.common.utils.ScreenUtils; | 51 | import com.prws.common.utils.ScreenUtils; |
52 | import com.prws.common.utils.SharedPreferencesUtil; | 52 | import com.prws.common.utils.SharedPreferencesUtil; |
53 | import com.prws.common.utils.dialog.MyButtomDialog; | 53 | import com.prws.common.utils.dialog.MyButtomDialog; |
54 | import com.zhangteng.imagepicker.bean.ImageInfo; | 54 | import com.zhangteng.imagepicker.bean.ImageInfo; |
55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
59 | import com.zhangteng.utils.IHandlerCallBack; | 59 | import com.zhangteng.utils.IHandlerCallBack; |
60 | 60 | ||
61 | import java.io.File; | 61 | import java.io.File; |
62 | import java.util.ArrayList; | 62 | import java.util.ArrayList; |
63 | import java.util.Arrays; | 63 | import java.util.Arrays; |
64 | import java.util.HashMap; | 64 | import java.util.HashMap; |
65 | import java.util.List; | 65 | import java.util.List; |
66 | import java.util.Map; | 66 | import java.util.Map; |
67 | 67 | ||
68 | import io.reactivex.Observer; | 68 | import io.reactivex.Observer; |
69 | import io.reactivex.disposables.Disposable; | 69 | import io.reactivex.disposables.Disposable; |
70 | 70 | ||
71 | public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { | 71 | public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { |
72 | StudentBean studentBean; | 72 | StudentBean studentBean; |
73 | private int subject; | 73 | private int subject; |
74 | private ErrorAdapter adapter; | 74 | private ErrorAdapter adapter; |
75 | private int REQUEST_CODE_IMAGE = 123; | 75 | private int REQUEST_CODE_IMAGE = 123; |
76 | private String filePath; | 76 | private String filePath; |
77 | 77 | ||
78 | @Override | 78 | @Override |
79 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 79 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
80 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 80 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
81 | } | 81 | } |
82 | 82 | ||
83 | @Override | 83 | public void refreshStudent() { |
84 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
85 | super.onViewCreated(view, savedInstanceState); | ||
86 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 84 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
87 | try { | 85 | try { |
88 | studentBean = new Gson().fromJson(student, StudentBean.class); | 86 | studentBean = new Gson().fromJson(student, StudentBean.class); |
89 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 87 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
90 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 88 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
91 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | 89 | if (TextUtils.isEmpty(studentBean.getPhoto())) { |
92 | getBinding().ivStudent.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 90 | getBinding().ivStudent.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
93 | } else { | 91 | } else { |
94 | Glide.with(getContext()).load(studentBean.getPhoto()).apply(options).into(getBinding().ivStudent); | 92 | Glide.with(getContext()).load(studentBean.getPhoto()).apply(options).into(getBinding().ivStudent); |
95 | } | 93 | } |
96 | getBinding().tvName.setText(studentBean.getStuName()); | 94 | getBinding().tvName.setText(studentBean.getStuName()); |
97 | } catch (Exception e) { | 95 | } catch (Exception e) { |
98 | 96 | ||
99 | } | 97 | } |
98 | } | ||
99 | |||
100 | @Override | ||
101 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
102 | super.onViewCreated(view, savedInstanceState); | ||
103 | refreshStudent(); | ||
100 | getBinding().rlTakePhoto.post(new Runnable() { | 104 | getBinding().rlTakePhoto.post(new Runnable() { |
101 | @Override | 105 | @Override |
102 | public void run() { | 106 | public void run() { |
103 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); | 107 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); |
104 | layoutParams.width = CommonUtil.getScreenWidth(getContext()); | 108 | layoutParams.width = CommonUtil.getScreenWidth(getContext()); |
105 | layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; | 109 | layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; |
106 | getBinding().rlTakePhoto.setLayoutParams(layoutParams); | 110 | getBinding().rlTakePhoto.setLayoutParams(layoutParams); |
107 | } | 111 | } |
108 | }); | 112 | }); |
109 | getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { | 113 | getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { |
110 | @Override | 114 | @Override |
111 | public void onClick(View v) { | 115 | public void onClick(View v) { |
112 | startActivity(new Intent(getContext(), TeacherChooseActivity.class)); | 116 | startActivity(new Intent(getContext(), TeacherChooseActivity.class)); |
113 | getActivity().finish(); | 117 | // getActivity().finish(); |
114 | } | 118 | } |
115 | }); | 119 | }); |
116 | getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { | 120 | getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { |
117 | @Override | 121 | @Override |
118 | public void onClick(View v) { | 122 | public void onClick(View v) { |
119 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 123 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
120 | XXPermissions.with(getContext()) | 124 | XXPermissions.with(getContext()) |
121 | // 申请多个权限 | 125 | // 申请多个权限 |
122 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 126 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
123 | @Override | 127 | @Override |
124 | public void onGranted(List<String> permissions, boolean all) { | 128 | public void onGranted(List<String> permissions, boolean all) { |
125 | if (all) { | 129 | if (all) { |
126 | //开启扫码界面 | 130 | //开启扫码界面 |
127 | showButtonDialog(); | 131 | showButtonDialog(); |
128 | } else { | 132 | } else { |
129 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 133 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
130 | } | 134 | } |
131 | } | 135 | } |
132 | 136 | ||
133 | @Override | 137 | @Override |
134 | public void onDenied(List<String> permissions, boolean never) { | 138 | public void onDenied(List<String> permissions, boolean never) { |
135 | XXPermissions.startPermissionActivity(getContext(), permissions); | 139 | XXPermissions.startPermissionActivity(getContext(), permissions); |
136 | } | 140 | } |
137 | }); | 141 | }); |
138 | } else { | 142 | } else { |
139 | showButtonDialog(); | 143 | showButtonDialog(); |
140 | } | 144 | } |
141 | 145 | ||
142 | } | 146 | } |
143 | }); | 147 | }); |
144 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 148 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
145 | @Override | 149 | @Override |
146 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 150 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
147 | 151 | ||
148 | } | 152 | } |
149 | 153 | ||
150 | @Override | 154 | @Override |
151 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 155 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
152 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 156 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
153 | switch (item.getAdapterPosition()) { | 157 | switch (item.getAdapterPosition()) { |
154 | case 0: | 158 | case 0: |
155 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 159 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
156 | break; | 160 | break; |
157 | case 1: | 161 | case 1: |
158 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 162 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
159 | break; | 163 | break; |
160 | case 2: | 164 | case 2: |
161 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 165 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
162 | break; | 166 | break; |
163 | case 3: | 167 | case 3: |
164 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 168 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
165 | break; | 169 | break; |
166 | case 4: | 170 | case 4: |
167 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 171 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
168 | break; | 172 | break; |
169 | } | 173 | } |
170 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 174 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
171 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 175 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
172 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 176 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
173 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 177 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
174 | @Override | 178 | @Override |
175 | public void onClick(View v) { | 179 | public void onClick(View v) { |
176 | if (subject != item.getAdapterPosition()) { | 180 | if (subject != item.getAdapterPosition()) { |
177 | subject = item.getAdapterPosition(); | 181 | subject = item.getAdapterPosition(); |
178 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 182 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
179 | } | 183 | } |
180 | } | 184 | } |
181 | }); | 185 | }); |
182 | } | 186 | } |
183 | }; | 187 | }; |
184 | getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 188 | getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); |
185 | getBinding().recycleSubject.setAdapter(adapter); | 189 | getBinding().recycleSubject.setAdapter(adapter); |
186 | subject = 0; | 190 | subject = 0; |
187 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 191 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
188 | getBinding().llAll.setOnClickListener(new View.OnClickListener() { | 192 | getBinding().llAll.setOnClickListener(new View.OnClickListener() { |
189 | @Override | 193 | @Override |
190 | public void onClick(View v) { | 194 | public void onClick(View v) { |
191 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 195 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
192 | startActivity(intent); | 196 | startActivity(intent); |
193 | } | 197 | } |
194 | }); | 198 | }); |
195 | } | 199 | } |
196 | 200 | ||
197 | private void showButtonDialog() { | 201 | private void showButtonDialog() { |
198 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 202 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
199 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 203 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
200 | dialog.setContentView(bottomView); | 204 | dialog.setContentView(bottomView); |
201 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 205 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
202 | @Override | 206 | @Override |
203 | public void onClick(View view) { | 207 | public void onClick(View view) { |
204 | dialog.dismiss(); | 208 | dialog.dismiss(); |
205 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 209 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
206 | //确保有相机来处理Intent | 210 | //确保有相机来处理Intent |
207 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 211 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
208 | File photoFile = new File(filePath); | 212 | File photoFile = new File(filePath); |
209 | if (photoFile != null) { | 213 | if (photoFile != null) { |
210 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 214 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
211 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); | 215 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); |
212 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 216 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
213 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 217 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
214 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 218 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
215 | } | 219 | } |
216 | } | 220 | } |
217 | }); | 221 | }); |
218 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 222 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
219 | @Override | 223 | @Override |
220 | public void onClick(View view) { | 224 | public void onClick(View view) { |
221 | dialog.dismiss(); | 225 | dialog.dismiss(); |
222 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 226 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
223 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 227 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
224 | .multiSelect(true) //是否多选 | 228 | .multiSelect(true) //是否多选 |
225 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 229 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
226 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 230 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
227 | .maxImageSelectable(9) //图片可选择数 | 231 | .maxImageSelectable(5) //图片可选择数 |
228 | .maxHeight(1920) //图片最大高度 | 232 | .maxHeight(1920) //图片最大高度 |
229 | .maxWidth(1920) //图片最大宽度 | 233 | .maxWidth(1920) //图片最大宽度 |
230 | .maxImageSize(10) //图片最大大小Mb | 234 | .maxImageSize(3) //图片最大大小Mb |
231 | .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(); | 235 | .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(); |
232 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 236 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
233 | 237 | ||
234 | } | 238 | } |
235 | }); | 239 | }); |
236 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 240 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
237 | @Override | 241 | @Override |
238 | public void onClick(View view) { | 242 | public void onClick(View view) { |
239 | dialog.dismiss(); | 243 | dialog.dismiss(); |
240 | } | 244 | } |
241 | }); | 245 | }); |
242 | dialog.show(); | 246 | dialog.show(); |
243 | } | 247 | } |
244 | 248 | ||
245 | private void getError(String subject) { | 249 | private void getError(String subject) { |
246 | if (studentBean != null) { | 250 | if (studentBean != null) { |
247 | Map map = new HashMap(); | 251 | Map map = new HashMap(); |
248 | map.put("subject", subject); | 252 | map.put("subject", subject); |
249 | map.put("stuId", studentBean.getStuId()); | 253 | map.put("stuId", studentBean.getStuId()); |
250 | map.put("pageSize", 5); | 254 | map.put("pageSize", 5); |
251 | map.put("pageNum", 1); | 255 | map.put("pageNum", 1); |
252 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 256 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
253 | @Override | 257 | @Override |
254 | public void onSubscribe(Disposable d) { | 258 | public void onSubscribe(Disposable d) { |
255 | 259 | ||
256 | } | 260 | } |
257 | 261 | ||
258 | @Override | 262 | @Override |
259 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 263 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
260 | if (result.getData() != null && result.getCode() == 200) { | 264 | if (result.getData() != null && result.getCode() == 200) { |
261 | List<TopicBean> topicBeans = result.getData().getList(); | 265 | List<TopicBean> topicBeans = result.getData().getList(); |
262 | loadError(topicBeans); | 266 | loadError(topicBeans); |
263 | } | 267 | } |
264 | } | 268 | } |
265 | 269 | ||
266 | @Override | 270 | @Override |
267 | public void onError(Throwable e) { | 271 | public void onError(Throwable e) { |
268 | e.toString(); | 272 | e.toString(); |
269 | } | 273 | } |
270 | 274 | ||
271 | @Override | 275 | @Override |
272 | public void onComplete() { | 276 | public void onComplete() { |
273 | 277 | ||
274 | } | 278 | } |
275 | }); | 279 | }); |
276 | } | 280 | } |
277 | } | 281 | } |
278 | 282 | ||
279 | private void loadError(List<TopicBean> list) { | 283 | private void loadError(List<TopicBean> list) { |
280 | if (list.size() > 0) { | 284 | if (list.size() > 0) { |
281 | getBinding().recycleError.setVisibility(View.VISIBLE); | 285 | getBinding().recycleError.setVisibility(View.VISIBLE); |
282 | getBinding().llEmpty.setVisibility(View.GONE); | 286 | getBinding().llEmpty.setVisibility(View.GONE); |
283 | if (adapter != null) { | 287 | if (adapter != null) { |
284 | adapter.refresh(list); | 288 | adapter.refresh(list); |
285 | } else { | 289 | } else { |
286 | adapter = new ErrorAdapter(getActivity(), list, false); | 290 | adapter = new ErrorAdapter(getActivity(), list, false); |
287 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); | 291 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); |
288 | getBinding().recycleError.setAdapter(adapter); | 292 | getBinding().recycleError.setAdapter(adapter); |
289 | } | 293 | } |
290 | } else { | 294 | } else { |
291 | getBinding().recycleError.setVisibility(View.GONE); | 295 | getBinding().recycleError.setVisibility(View.GONE); |
292 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 296 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
293 | } | 297 | } |
294 | } | 298 | } |
295 | 299 | ||
296 | @Override | 300 | @Override |
297 | public void onResume() { | 301 | public void onResume() { |
298 | super.onResume(); | 302 | super.onResume(); |
299 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 303 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
300 | } | 304 | } |
301 | 305 | ||
302 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 306 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
303 | private String TAG = "---ImagePicker---"; | 307 | private String TAG = "---ImagePicker---"; |
304 | List<ImageInfo> photoList = new ArrayList<>(); | 308 | List<ImageInfo> photoList = new ArrayList<>(); |
305 | 309 | ||
306 | @Override | 310 | @Override |
307 | public void onStart() { | 311 | public void onStart() { |
308 | Log.i(TAG, "onStart: 开启"); | 312 | Log.i(TAG, "onStart: 开启"); |
309 | } | 313 | } |
310 | 314 | ||
311 | @Override | 315 | @Override |
312 | public void onSuccess(List<ImageInfo> photoList) { | 316 | public void onSuccess(List<ImageInfo> photoList) { |
313 | this.photoList = photoList; | 317 | this.photoList = photoList; |
314 | Log.i(TAG, "onSuccess: 返回数据"); | 318 | Log.i(TAG, "onSuccess: 返回数据"); |
315 | } | 319 | } |
316 | 320 | ||
317 | @Override | 321 | @Override |
318 | public void onCancel() { | 322 | public void onCancel() { |
319 | Log.i(TAG, "onCancel: 取消"); | 323 | Log.i(TAG, "onCancel: 取消"); |
320 | } | 324 | } |
321 | 325 | ||
322 | @Override | 326 | @Override |
323 | public void onFinish(List<ImageInfo> selectImage) { | 327 | public void onFinish(List<ImageInfo> selectImage) { |
324 | if (selectImage.size() == photoList.size()) { | 328 | if (selectImage.size() == photoList.size()) { |
325 | List<String> strings = new ArrayList<>(); | 329 | List<String> strings = new ArrayList<>(); |
326 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 330 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
327 | for (ImageInfo imageInfo : selectImage) { | 331 | for (ImageInfo imageInfo : selectImage) { |
328 | strings.add(imageInfo.getPath()); | 332 | strings.add(imageInfo.getPath()); |
329 | } | 333 | } |
330 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 334 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
331 | startActivity(intent); | 335 | startActivity(intent); |
332 | } | 336 | } |
333 | } | 337 | } |
334 | 338 | ||
335 | @Override | 339 | @Override |
336 | public void onError() { | 340 | public void onError() { |
337 | Log.i(TAG, "onError: 出错"); | 341 | Log.i(TAG, "onError: 出错"); |
338 | } | 342 | } |
339 | } | 343 | } |
340 | 344 | ||
341 | @Override | 345 | @Override |
342 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 346 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
343 | super.onActivityResult(requestCode, resultCode, data); | 347 | super.onActivityResult(requestCode, resultCode, data); |
344 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 348 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
345 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 349 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
346 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 350 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
347 | CommonUtil.saveBitmapToUri(b, path); | 351 | CommonUtil.saveBitmapToUri(b, path); |
348 | List<String> strings = new ArrayList<>(); | 352 | List<String> strings = new ArrayList<>(); |
349 | Intent intent = new Intent(getContext(), ImageActivity.class); | 353 | Intent intent = new Intent(getContext(), ImageActivity.class); |
350 | strings.add(path); | 354 | strings.add(path); |
351 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 355 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
352 | startActivity(intent); | 356 | startActivity(intent); |
353 | } | 357 | } |
354 | } | 358 | } |
app/src/main/res/layout/activity_error_list.xml
1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | xmlns:xxx="http://schemas.android.com/apk/res-auto" | 2 | xmlns:xxx="http://schemas.android.com/apk/res-auto" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | android:background="#F8F8F8" | 5 | android:background="#F8F8F8" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <RelativeLayout | 8 | <RelativeLayout |
9 | android:id="@+id/rl_top" | 9 | android:id="@+id/rl_top" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="40dp" | 11 | android:layout_height="40dp" |
12 | android:background="@color/white"> | 12 | android:background="@color/white"> |
13 | 13 | ||
14 | <TextView | 14 | <TextView |
15 | android:id="@+id/tv_title" | 15 | android:id="@+id/tv_title" |
16 | android:layout_width="wrap_content" | 16 | android:layout_width="wrap_content" |
17 | android:layout_height="wrap_content" | 17 | android:layout_height="wrap_content" |
18 | android:layout_centerInParent="true" | 18 | android:layout_centerInParent="true" |
19 | android:text="错题本" | 19 | android:text="错题本" |
20 | android:textColor="#333333" | 20 | android:textColor="#333333" |
21 | android:textSize="18sp" /> | 21 | android:textSize="18sp" /> |
22 | 22 | ||
23 | <ImageView | 23 | <ImageView |
24 | android:layout_width="30dp" | ||
25 | android:id="@+id/iv_change" | 24 | android:id="@+id/iv_change" |
26 | android:src="@mipmap/ic_change" | 25 | android:layout_width="30dp" |
27 | android:padding="5dp" | 26 | android:layout_height="30dp" |
28 | android:layout_toRightOf="@+id/tv_title" | ||
29 | android:layout_centerVertical="true" | 27 | android:layout_centerVertical="true" |
30 | android:layout_height="30dp"/> | 28 | android:layout_toRightOf="@+id/tv_title" |
29 | android:padding="5dp" | ||
30 | android:src="@mipmap/ic_change" /> | ||
31 | 31 | ||
32 | <CheckBox | 32 | <CheckBox |
33 | android:id="@+id/checkbox" | 33 | android:id="@+id/checkbox" |
34 | android:layout_width="wrap_content" | 34 | android:layout_width="wrap_content" |
35 | android:layout_height="wrap_content" | 35 | android:layout_height="wrap_content" |
36 | android:layout_centerVertical="true" | 36 | android:layout_centerVertical="true" |
37 | android:layout_marginLeft="15dp" | 37 | android:layout_marginLeft="15dp" |
38 | android:button="@drawable/selectall_selector" | 38 | android:button="@drawable/selectall_selector" |
39 | android:checked="false" | 39 | android:checked="false" |
40 | android:paddingLeft="8dp" | 40 | android:paddingLeft="8dp" |
41 | android:text="全选" | 41 | android:text="全选" |
42 | android:textColor="@color/text_title" | 42 | android:textColor="@color/text_title" |
43 | android:visibility="gone" /> | 43 | android:visibility="gone" /> |
44 | 44 | ||
45 | <ImageView | 45 | <ImageView |
46 | android:id="@+id/iv_back" | 46 | android:id="@+id/iv_back" |
47 | android:layout_width="30dp" | 47 | android:layout_width="30dp" |
48 | android:layout_height="36dp" | 48 | android:layout_height="36dp" |
49 | android:layout_centerVertical="true" | 49 | android:layout_centerVertical="true" |
50 | android:layout_marginLeft="5dp" | 50 | android:layout_marginLeft="5dp" |
51 | android:padding="10dp" | 51 | android:padding="10dp" |
52 | android:src="@mipmap/icon_back" /> | 52 | android:src="@mipmap/icon_back" /> |
53 | 53 | ||
54 | <TextView | 54 | <TextView |
55 | android:id="@+id/tv_edit" | 55 | android:id="@+id/tv_edit" |
56 | android:layout_width="wrap_content" | 56 | android:layout_width="wrap_content" |
57 | android:layout_height="wrap_content" | 57 | android:layout_height="wrap_content" |
58 | android:layout_alignParentRight="true" | 58 | android:layout_alignParentRight="true" |
59 | android:layout_centerVertical="true" | 59 | android:layout_centerVertical="true" |
60 | android:layout_marginRight="15dp" | 60 | android:layout_marginRight="15dp" |
61 | android:text="编辑" | 61 | android:text="编辑" |
62 | android:textColor="@color/text_title" | 62 | android:textColor="@color/text_title" |
63 | android:visibility="visible" /> | 63 | android:visibility="visible" /> |
64 | </RelativeLayout> | 64 | </RelativeLayout> |
65 | 65 | ||
66 | <LinearLayout | 66 | <LinearLayout |
67 | android:id="@+id/ll_filter" | 67 | android:id="@+id/ll_filter" |
68 | android:layout_width="match_parent" | 68 | android:layout_width="match_parent" |
69 | android:layout_height="40dp" | 69 | android:layout_height="40dp" |
70 | android:layout_below="@+id/rl_top" | 70 | android:layout_below="@+id/rl_top" |
71 | android:background="@color/white"> | 71 | android:background="@color/white"> |
72 | 72 | ||
73 | <RelativeLayout | 73 | <RelativeLayout |
74 | android:layout_width="0dp" | 74 | android:layout_width="0dp" |
75 | android:layout_height="40dp" | 75 | android:layout_height="40dp" |
76 | android:layout_weight="1"> | 76 | android:layout_weight="1"> |
77 | 77 | ||
78 | <TextView | 78 | <TextView |
79 | android:id="@+id/tv_filter_subject" | 79 | android:id="@+id/tv_filter_subject" |
80 | android:layout_width="wrap_content" | 80 | android:layout_width="wrap_content" |
81 | android:layout_height="40dp" | 81 | android:layout_height="40dp" |
82 | android:layout_centerVertical="true" | 82 | android:layout_centerVertical="true" |
83 | android:layout_marginLeft="15dp" | 83 | android:layout_marginLeft="15dp" |
84 | android:drawableRight="@drawable/ic_filter_gray" | 84 | android:drawableRight="@drawable/ic_filter_gray" |
85 | android:drawablePadding="5dp" | 85 | android:drawablePadding="5dp" |
86 | android:gravity="center_vertical" | 86 | android:gravity="center_vertical" |
87 | android:text="学科" | 87 | android:text="学科" |
88 | android:textColor="@color/text_title" | 88 | android:textColor="@color/text_title" |
89 | android:textSize="14sp" /> | 89 | android:textSize="14sp" /> |
90 | 90 | ||
91 | </RelativeLayout> | 91 | </RelativeLayout> |
92 | 92 | ||
93 | <RelativeLayout | 93 | <RelativeLayout |
94 | android:layout_width="0dp" | 94 | android:layout_width="0dp" |
95 | android:layout_height="40dp" | 95 | android:layout_height="40dp" |
96 | android:layout_weight="1"> | 96 | android:layout_weight="1"> |
97 | 97 | ||
98 | <TextView | 98 | <TextView |
99 | android:id="@+id/tv_filter_grade" | 99 | android:id="@+id/tv_filter_grade" |
100 | android:layout_width="wrap_content" | 100 | android:layout_width="wrap_content" |
101 | android:layout_height="40dp" | 101 | android:layout_height="40dp" |
102 | android:layout_centerVertical="true" | 102 | android:layout_centerVertical="true" |
103 | android:drawableRight="@drawable/ic_filter_gray" | 103 | android:drawableRight="@drawable/ic_filter_gray" |
104 | android:drawablePadding="5dp" | 104 | android:drawablePadding="5dp" |
105 | android:gravity="center_vertical" | 105 | android:gravity="center_vertical" |
106 | android:text="年级学期" | 106 | android:text="年级学期" |
107 | android:textColor="@color/text_title" | 107 | android:textColor="@color/text_title" |
108 | android:textSize="14sp" /> | 108 | android:textSize="14sp" /> |
109 | </RelativeLayout> | 109 | </RelativeLayout> |
110 | 110 | ||
111 | <RelativeLayout | 111 | <RelativeLayout |
112 | android:layout_width="0dp" | 112 | android:layout_width="0dp" |
113 | android:layout_height="40dp" | 113 | android:layout_height="40dp" |
114 | android:layout_weight="1"> | 114 | android:layout_weight="1"> |
115 | 115 | ||
116 | <TextView | 116 | <TextView |
117 | android:id="@+id/tv_filter_manage" | 117 | android:id="@+id/tv_filter_manage" |
118 | android:layout_width="wrap_content" | 118 | android:layout_width="wrap_content" |
119 | android:layout_height="40dp" | 119 | android:layout_height="40dp" |
120 | android:layout_centerVertical="true" | 120 | android:layout_centerVertical="true" |
121 | android:layout_marginLeft="10dp" | 121 | android:layout_marginLeft="10dp" |
122 | android:drawableRight="@drawable/ic_filter_gray" | 122 | android:drawableRight="@drawable/ic_filter_gray" |
123 | android:drawablePadding="5dp" | 123 | android:drawablePadding="5dp" |
124 | android:gravity="center_vertical" | 124 | android:gravity="center_vertical" |
125 | android:text="掌握情况" | 125 | android:text="掌握情况" |
126 | android:textColor="@color/text_title" | 126 | android:textColor="@color/text_title" |
127 | android:textSize="14sp" /> | 127 | android:textSize="14sp" /> |
128 | </RelativeLayout> | 128 | </RelativeLayout> |
129 | 129 | ||
130 | <RelativeLayout | 130 | <RelativeLayout |
131 | android:layout_width="0dp" | 131 | android:layout_width="0dp" |
132 | android:layout_height="40dp" | 132 | android:layout_height="40dp" |
133 | android:layout_weight="1"> | 133 | android:layout_weight="1"> |
134 | 134 | ||
135 | <TextView | 135 | <TextView |
136 | android:id="@+id/tv_filter_more" | 136 | android:id="@+id/tv_filter_more" |
137 | android:layout_width="wrap_content" | 137 | android:layout_width="wrap_content" |
138 | android:layout_height="40dp" | 138 | android:layout_height="40dp" |
139 | android:layout_alignParentRight="true" | 139 | android:layout_alignParentRight="true" |
140 | android:layout_centerVertical="true" | 140 | android:layout_centerVertical="true" |
141 | android:layout_marginRight="15dp" | 141 | android:layout_marginRight="15dp" |
142 | android:drawableRight="@drawable/ic_filter_gray" | 142 | android:drawableRight="@drawable/ic_filter_gray" |
143 | android:drawablePadding="5dp" | 143 | android:drawablePadding="5dp" |
144 | android:gravity="center_vertical" | 144 | android:gravity="center_vertical" |
145 | android:text="更多筛选" | 145 | android:text="更多筛选" |
146 | android:textColor="@color/text_title" | 146 | android:textColor="@color/text_title" |
147 | android:textSize="14sp" /> | 147 | android:textSize="14sp" /> |
148 | </RelativeLayout> | 148 | </RelativeLayout> |
149 | 149 | ||
150 | </LinearLayout> | 150 | </LinearLayout> |
151 | 151 | ||
152 | <androidx.recyclerview.widget.RecyclerView | 152 | <androidx.recyclerview.widget.RecyclerView |
153 | android:id="@+id/recycle" | 153 | android:id="@+id/recycle" |
154 | android:layout_width="match_parent" | 154 | android:layout_width="match_parent" |
155 | android:layout_height="match_parent" | 155 | android:layout_height="match_parent" |
156 | android:layout_above="@+id/rl_bottom" | 156 | android:layout_above="@+id/rl_bottom" |
157 | android:layout_below="@+id/ll_filter" | 157 | android:layout_below="@+id/ll_filter" |
158 | android:layout_marginTop="15dp" /> | 158 | android:layout_marginTop="15dp" /> |
159 | 159 | ||
160 | <LinearLayout | 160 | <LinearLayout |
161 | android:id="@+id/ll_filter_common" | 161 | android:id="@+id/ll_filter_common" |
162 | android:layout_width="match_parent" | 162 | android:layout_width="match_parent" |
163 | android:layout_height="wrap_content" | 163 | android:layout_height="wrap_content" |
164 | android:layout_below="@+id/ll_filter" | 164 | android:layout_below="@+id/ll_filter" |
165 | android:background="@drawable/bg_solid_white_10_bottom" | 165 | android:background="@drawable/bg_solid_white_10_bottom" |
166 | android:visibility="visible"> | 166 | android:visibility="visible"> |
167 | 167 | ||
168 | <androidx.recyclerview.widget.RecyclerView | 168 | <androidx.recyclerview.widget.RecyclerView |
169 | android:id="@+id/recycle_filter" | 169 | android:id="@+id/recycle_filter" |
170 | android:layout_width="match_parent" | 170 | android:layout_width="match_parent" |
171 | android:layout_height="wrap_content" | 171 | android:layout_height="wrap_content" |
172 | android:layout_marginLeft="15dp" | 172 | android:layout_marginLeft="15dp" |
173 | android:layout_marginTop="15dp" | 173 | android:layout_marginTop="15dp" |
174 | android:visibility="gone" /> | 174 | android:visibility="gone" /> |
175 | </LinearLayout> | 175 | </LinearLayout> |
176 | 176 | ||
177 | <LinearLayout | 177 | <LinearLayout |
178 | android:id="@+id/ll_empty" | ||
179 | android:layout_width="wrap_content" | ||
180 | android:layout_height="wrap_content" | ||
181 | android:layout_above="@+id/rl_bottom" | ||
182 | android:layout_below="@+id/ll_filter" | ||
183 | android:layout_centerHorizontal="true" | ||
184 | android:layout_marginTop="150dp" | ||
185 | android:orientation="vertical" | ||
186 | android:visibility="gone"> | ||
187 | |||
188 | <ImageView | ||
189 | android:layout_width="155dp" | ||
190 | android:layout_height="130dp" | ||
191 | android:src="@mipmap/ic_empty" /> | ||
192 | |||
193 | <TextView | ||
194 | android:layout_width="wrap_content" | ||
195 | android:layout_height="wrap_content" | ||
196 | android:layout_gravity="center_horizontal" | ||
197 | android:text="暂无错题~" /> | ||
198 | </LinearLayout> | ||
199 | |||
200 | <LinearLayout | ||
201 | android:id="@+id/ll_filter_grade" | ||
202 | android:layout_width="match_parent" | ||
203 | android:layout_height="wrap_content" | ||
204 | android:layout_below="@+id/ll_filter" | ||
205 | android:background="@drawable/bg_solid_white_10_bottom" | ||
206 | android:orientation="vertical" | ||
207 | android:visibility="gone"> | ||
208 | |||
209 | <TextView | ||
210 | android:layout_width="wrap_content" | ||
211 | android:layout_height="wrap_content" | ||
212 | android:layout_marginLeft="15dp" | ||
213 | android:layout_marginTop="15dp" | ||
214 | android:text="年级" | ||
215 | android:textColor="@color/text_title" | ||
216 | android:textSize="14sp" | ||
217 | android:textStyle="bold" /> | ||
218 | |||
219 | <androidx.recyclerview.widget.RecyclerView | ||
220 | android:id="@+id/recycle_grade" | ||
221 | android:layout_width="match_parent" | ||
222 | android:layout_height="wrap_content" | ||
223 | android:layout_marginLeft="15dp" | ||
224 | android:layout_marginTop="15dp" | ||
225 | android:visibility="visible" /> | ||
226 | |||
227 | <TextView | ||
228 | android:layout_width="wrap_content" | ||
229 | android:layout_height="wrap_content" | ||
230 | android:layout_marginLeft="15dp" | ||
231 | android:layout_marginTop="15dp" | ||
232 | android:text="学期" | ||
233 | android:textColor="@color/text_title" | ||
234 | android:textSize="14sp" | ||
235 | android:textStyle="bold" /> | ||
236 | |||
237 | <RadioGroup | ||
238 | android:id="@+id/group_grade" | ||
239 | android:layout_width="match_parent" | ||
240 | android:layout_height="30dp" | ||
241 | android:layout_marginLeft="15dp" | ||
242 | android:layout_marginTop="15dp" | ||
243 | android:layout_marginRight="15dp" | ||
244 | android:layout_marginBottom="15dp" | ||
245 | android:orientation="horizontal"> | ||
246 | |||
247 | <RadioButton | ||
248 | android:layout_width="0dp" | ||
249 | android:layout_height="match_parent" | ||
250 | android:layout_marginRight="15dp" | ||
251 | android:layout_weight="1" | ||
252 | android:background="@drawable/filter_button_selector" | ||
253 | android:button="@null" | ||
254 | android:gravity="center" | ||
255 | android:text="全部" | ||
256 | android:textColor="@drawable/radio_text_selector" | ||
257 | android:textSize="14sp" /> | ||
258 | |||
259 | <RadioButton | ||
260 | android:layout_width="0dp" | ||
261 | android:layout_height="match_parent" | ||
262 | android:layout_marginRight="15dp" | ||
263 | android:layout_weight="1" | ||
264 | android:background="@drawable/filter_button_selector" | ||
265 | android:button="@null" | ||
266 | android:gravity="center" | ||
267 | android:text="上学期" | ||
268 | android:textColor="@drawable/radio_text_selector" | ||
269 | android:textSize="14sp" /> | ||
270 | |||
271 | <RadioButton | ||
272 | android:layout_width="0dp" | ||
273 | android:layout_height="match_parent" | ||
274 | android:layout_marginRight="15dp" | ||
275 | android:layout_weight="1" | ||
276 | android:background="@drawable/filter_button_selector" | ||
277 | android:button="@null" | ||
278 | android:gravity="center" | ||
279 | android:text="下学期" | ||
280 | android:textColor="@drawable/radio_text_selector" | ||
281 | android:textSize="14sp" /> | ||
282 | |||
283 | <View | ||
284 | android:layout_width="0dp" | ||
285 | android:layout_height="match_parent" | ||
286 | android:layout_weight="1" /> | ||
287 | </RadioGroup> | ||
288 | </LinearLayout> | ||
289 | |||
290 | <LinearLayout | ||
178 | android:id="@+id/ll_filter_more" | 291 | android:id="@+id/ll_filter_more" |
179 | android:layout_width="match_parent" | 292 | android:layout_width="match_parent" |
180 | android:layout_height="wrap_content" | 293 | android:layout_height="wrap_content" |
181 | android:layout_below="@+id/ll_filter" | 294 | android:layout_below="@+id/ll_filter" |
182 | android:background="@drawable/bg_solid_white_10_bottom" | 295 | android:background="@drawable/bg_solid_white_10_bottom" |
183 | android:orientation="vertical" | 296 | android:orientation="vertical" |
184 | android:visibility="gone"> | 297 | android:visibility="gone"> |
185 | 298 | ||
186 | <TextView | 299 | <TextView |
187 | android:layout_width="wrap_content" | 300 | android:layout_width="wrap_content" |
188 | android:layout_height="wrap_content" | 301 | android:layout_height="wrap_content" |
189 | android:layout_marginLeft="15dp" | 302 | android:layout_marginLeft="15dp" |
190 | android:layout_marginTop="15dp" | 303 | android:layout_marginTop="15dp" |
191 | android:text="来源" | 304 | android:text="来源" |
192 | android:textColor="@color/text_title" | 305 | android:textColor="@color/text_title" |
193 | android:textSize="14sp" | 306 | android:textSize="14sp" |
194 | android:textStyle="bold" /> | 307 | android:textStyle="bold" /> |
195 | 308 | ||
196 | <RadioGroup | 309 | <RadioGroup |
197 | android:id="@+id/group_type" | 310 | android:id="@+id/group_type" |
198 | android:layout_width="match_parent" | 311 | android:layout_width="match_parent" |
199 | android:layout_height="30dp" | 312 | android:layout_height="30dp" |
200 | android:layout_marginLeft="15dp" | 313 | android:layout_marginLeft="15dp" |
201 | android:layout_marginTop="15dp" | 314 | android:layout_marginTop="15dp" |
202 | android:layout_marginRight="15dp" | 315 | android:layout_marginRight="15dp" |
203 | android:orientation="horizontal"> | 316 | android:orientation="horizontal"> |
204 | 317 | ||
205 | <RadioButton | 318 | <RadioButton |
206 | android:layout_width="0dp" | 319 | android:layout_width="0dp" |
207 | android:layout_height="match_parent" | 320 | android:layout_height="match_parent" |
208 | android:layout_marginRight="15dp" | 321 | android:layout_marginRight="15dp" |
209 | android:layout_weight="1" | 322 | android:layout_weight="1" |
210 | android:background="@drawable/filter_button_selector" | 323 | android:background="@drawable/filter_button_selector" |
211 | android:button="@null" | 324 | android:button="@null" |
212 | android:gravity="center" | 325 | android:gravity="center" |
213 | android:text="课内" | 326 | android:text="课内" |
214 | android:textColor="@drawable/radio_text_selector" | 327 | android:textColor="@drawable/radio_text_selector" |
215 | android:textSize="14sp" /> | 328 | android:textSize="14sp" /> |
216 | 329 | ||
217 | <RadioButton | 330 | <RadioButton |
218 | android:layout_width="0dp" | 331 | android:layout_width="0dp" |
219 | android:layout_height="match_parent" | 332 | android:layout_height="match_parent" |
220 | android:layout_marginRight="15dp" | 333 | android:layout_marginRight="15dp" |
221 | android:layout_weight="1" | 334 | android:layout_weight="1" |
222 | android:background="@drawable/filter_button_selector" | 335 | android:background="@drawable/filter_button_selector" |
223 | android:button="@null" | 336 | android:button="@null" |
224 | android:gravity="center" | 337 | android:gravity="center" |
225 | android:text="课外" | 338 | android:text="课外" |
226 | android:textColor="@drawable/radio_text_selector" | 339 | android:textColor="@drawable/radio_text_selector" |
227 | android:textSize="14sp" /> | 340 | android:textSize="14sp" /> |
228 | 341 | ||
229 | <RadioButton | 342 | <RadioButton |
230 | android:layout_width="0dp" | 343 | android:layout_width="0dp" |
231 | android:layout_height="match_parent" | 344 | android:layout_height="match_parent" |
232 | android:layout_marginRight="15dp" | 345 | android:layout_marginRight="15dp" |
233 | android:layout_weight="1" | 346 | android:layout_weight="1" |
234 | android:background="@drawable/filter_button_selector" | 347 | android:background="@drawable/filter_button_selector" |
235 | android:button="@null" | 348 | android:button="@null" |
236 | android:gravity="center" | 349 | android:gravity="center" |
237 | android:text="全部" | 350 | android:text="全部" |
238 | android:textColor="@drawable/radio_text_selector" | 351 | android:textColor="@drawable/radio_text_selector" |
239 | android:textSize="14sp" /> | 352 | android:textSize="14sp" /> |
240 | 353 | ||
241 | <View | 354 | <View |
242 | android:layout_width="0dp" | 355 | android:layout_width="0dp" |
243 | android:layout_height="match_parent" | 356 | android:layout_height="match_parent" |
244 | android:layout_weight="1" /> | 357 | android:layout_weight="1" /> |
245 | </RadioGroup> | 358 | </RadioGroup> |
246 | 359 | ||
247 | <TextView | 360 | <TextView |
248 | android:layout_width="wrap_content" | 361 | android:layout_width="wrap_content" |
249 | android:layout_height="wrap_content" | 362 | android:layout_height="wrap_content" |
250 | android:layout_marginLeft="15dp" | 363 | android:layout_marginLeft="15dp" |
251 | android:layout_marginTop="15dp" | 364 | android:layout_marginTop="15dp" |
252 | android:text="录入时间" | 365 | android:text="录入时间" |
253 | android:textColor="@color/text_title" | 366 | android:textColor="@color/text_title" |
254 | android:textSize="14sp" | 367 | android:textSize="14sp" |
255 | android:textStyle="bold" /> | 368 | android:textStyle="bold" /> |
256 | 369 | ||
257 | <RadioGroup | 370 | <RadioGroup |
258 | android:id="@+id/group_time" | 371 | android:id="@+id/group_time" |
259 | android:layout_width="match_parent" | 372 | android:layout_width="match_parent" |
260 | android:layout_height="30dp" | 373 | android:layout_height="30dp" |
261 | android:layout_marginLeft="15dp" | 374 | android:layout_marginLeft="15dp" |
262 | android:layout_marginTop="15dp" | 375 | android:layout_marginTop="15dp" |
263 | android:layout_marginRight="15dp" | 376 | android:layout_marginRight="15dp" |
264 | android:layout_marginBottom="15dp" | 377 | android:layout_marginBottom="15dp" |
265 | android:orientation="horizontal"> | 378 | android:orientation="horizontal"> |
266 | 379 | ||
267 | <RadioButton | 380 | <RadioButton |
268 | android:layout_width="0dp" | 381 | android:layout_width="0dp" |
269 | android:layout_height="match_parent" | 382 | android:layout_height="match_parent" |
270 | android:layout_marginRight="15dp" | 383 | android:layout_marginRight="15dp" |
271 | android:layout_weight="1" | 384 | android:layout_weight="1" |
272 | android:background="@drawable/filter_button_selector" | 385 | android:background="@drawable/filter_button_selector" |
273 | android:button="@null" | 386 | android:button="@null" |
274 | android:gravity="center" | 387 | android:gravity="center" |
275 | android:text="一周内" | 388 | android:text="一周内" |
276 | android:textColor="@drawable/radio_text_selector" | 389 | android:textColor="@drawable/radio_text_selector" |
277 | android:textSize="14sp" /> | 390 | android:textSize="14sp" /> |
278 | 391 | ||
279 | <RadioButton | 392 | <RadioButton |
280 | android:layout_width="0dp" | 393 | android:layout_width="0dp" |
281 | android:layout_height="match_parent" | 394 | android:layout_height="match_parent" |
282 | android:layout_marginRight="15dp" | 395 | android:layout_marginRight="15dp" |
283 | android:layout_weight="1" | 396 | android:layout_weight="1" |
284 | android:background="@drawable/filter_button_selector" | 397 | android:background="@drawable/filter_button_selector" |
285 | android:button="@null" | 398 | android:button="@null" |
286 | android:gravity="center" | 399 | android:gravity="center" |
287 | android:text="一个月内" | 400 | android:text="一个月内" |
288 | android:textColor="@drawable/radio_text_selector" | 401 | android:textColor="@drawable/radio_text_selector" |
289 | android:textSize="14sp" /> | 402 | android:textSize="14sp" /> |
290 | 403 | ||
291 | <RadioButton | 404 | <RadioButton |
292 | android:layout_width="0dp" | 405 | android:layout_width="0dp" |
293 | android:layout_height="match_parent" | 406 | android:layout_height="match_parent" |
294 | android:layout_marginRight="15dp" | 407 | android:layout_marginRight="15dp" |
295 | android:layout_weight="1" | 408 | android:layout_weight="1" |
296 | android:background="@drawable/filter_button_selector" | 409 | android:background="@drawable/filter_button_selector" |
297 | android:button="@null" | 410 | android:button="@null" |
298 | android:gravity="center" | 411 | android:gravity="center" |
299 | android:text="三个月内" | 412 | android:text="三个月内" |
300 | android:textColor="@drawable/radio_text_selector" | 413 | android:textColor="@drawable/radio_text_selector" |
301 | android:textSize="14sp" /> | 414 | android:textSize="14sp" /> |
302 | 415 | ||
303 | <RadioButton | 416 | <RadioButton |
304 | android:layout_width="0dp" | 417 | android:layout_width="0dp" |
305 | android:layout_height="match_parent" | 418 | android:layout_height="match_parent" |
306 | android:layout_marginRight="15dp" | 419 | android:layout_marginRight="15dp" |
307 | android:layout_weight="1" | 420 | android:layout_weight="1" |
308 | android:background="@drawable/filter_button_selector" | 421 | android:background="@drawable/filter_button_selector" |
309 | android:button="@null" | 422 | android:button="@null" |
310 | android:gravity="center" | 423 | android:gravity="center" |
311 | android:text="全部" | 424 | android:text="全部" |
312 | android:textColor="@drawable/radio_text_selector" | 425 | android:textColor="@drawable/radio_text_selector" |
313 | android:textSize="14sp" /> | 426 | android:textSize="14sp" /> |
314 | </RadioGroup> | 427 | </RadioGroup> |
315 | </LinearLayout> | 428 | </LinearLayout> |
316 | 429 | ||
317 | 430 | ||
318 | <LinearLayout | ||
319 | android:id="@+id/ll_empty" | ||
320 | android:layout_width="wrap_content" | ||
321 | android:layout_height="wrap_content" | ||
322 | android:layout_above="@+id/rl_bottom" | ||
323 | android:layout_below="@+id/ll_filter" | ||
324 | android:layout_centerHorizontal="true" | ||
325 | android:layout_marginTop="150dp" | ||
326 | android:orientation="vertical" | ||
327 | android:visibility="gone"> | ||
328 | |||
329 | <ImageView | ||
330 | android:layout_width="155dp" | ||
331 | android:layout_height="130dp" | ||
332 | android:src="@mipmap/ic_empty" /> | ||
333 | |||
334 | <TextView | ||
335 | android:layout_width="wrap_content" | ||
336 | android:layout_height="wrap_content" | ||
337 | android:layout_gravity="center_horizontal" | ||
338 | android:text="暂无错题~" /> | ||
339 | </LinearLayout> | ||
340 | |||
341 | <RelativeLayout | 431 | <RelativeLayout |
342 | android:id="@+id/rl_bottom" | 432 | android:id="@+id/rl_bottom" |
343 | android:layout_width="match_parent" | 433 | android:layout_width="match_parent" |
344 | android:layout_height="70dp" | 434 | android:layout_height="70dp" |
345 | android:layout_alignParentBottom="true" | 435 | android:layout_alignParentBottom="true" |
346 | android:background="@color/white"> | 436 | android:background="@color/white"> |
347 | 437 | ||
348 | <TextView | 438 | <TextView |
349 | android:id="@+id/tv_add" | 439 | android:id="@+id/tv_add" |
350 | android:layout_width="280dp" | 440 | android:layout_width="280dp" |
351 | android:layout_height="40dp" | 441 | android:layout_height="40dp" |
352 | android:layout_centerInParent="true" | 442 | android:layout_centerInParent="true" |
353 | android:background="@drawable/bg_soild_blue_5" | 443 | android:background="@drawable/bg_soild_blue_5" |
354 | android:gravity="center" | 444 | android:gravity="center" |
355 | android:text="录入错题" | 445 | android:text="录入错题" |
356 | android:textColor="@color/white" | 446 | android:textColor="@color/white" |
357 | android:textSize="18sp" /> | 447 | android:textSize="18sp" /> |
358 | 448 | ||
359 | <LinearLayout | 449 | <LinearLayout |
360 | android:id="@+id/ll_delete" | 450 | android:id="@+id/ll_delete" |
361 | android:layout_width="wrap_content" | 451 | android:layout_width="wrap_content" |
362 | android:layout_height="wrap_content" | 452 | android:layout_height="wrap_content" |
363 | android:layout_centerVertical="true" | 453 | android:layout_centerVertical="true" |
364 | android:layout_marginLeft="15dp" | 454 | android:layout_marginLeft="15dp" |
365 | android:orientation="vertical" | 455 | android:orientation="vertical" |
366 | android:visibility="gone"> | 456 | android:visibility="gone"> |
367 | 457 | ||
368 | <ImageView | 458 | <ImageView |
369 | android:layout_width="25dp" | 459 | android:layout_width="25dp" |
370 | android:layout_height="25dp" | 460 | android:layout_height="25dp" |
371 | android:layout_gravity="center_horizontal" | 461 | android:layout_gravity="center_horizontal" |
372 | android:src="@mipmap/ic_delete" /> | 462 | android:src="@mipmap/ic_delete" /> |
app/src/main/res/layout/activity_image.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="match_parent" | 3 | android:layout_height="match_parent" |
4 | android:orientation="vertical"> | 4 | android:orientation="vertical"> |
5 | 5 | ||
6 | <RelativeLayout | 6 | <RelativeLayout |
7 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
8 | android:layout_height="40dp" | 8 | android:layout_height="40dp" |
9 | android:background="@color/white"> | 9 | android:background="@color/white"> |
10 | 10 | ||
11 | <TextView | 11 | <TextView |
12 | android:id="@+id/tv_title" | 12 | android:id="@+id/tv_title" |
13 | android:layout_width="wrap_content" | 13 | android:layout_width="wrap_content" |
14 | android:layout_height="wrap_content" | 14 | android:layout_height="wrap_content" |
15 | android:layout_centerInParent="true" | 15 | android:layout_centerInParent="true" |
16 | android:textColor="#333333" | 16 | android:textColor="#333333" |
17 | android:textSize="18sp" /> | 17 | android:textSize="18sp" /> |
18 | 18 | ||
19 | <ImageView | 19 | <ImageView |
20 | android:id="@+id/iv_back" | 20 | android:id="@+id/iv_back" |
21 | android:layout_width="30dp" | 21 | android:layout_width="30dp" |
22 | android:layout_height="36dp" | 22 | android:layout_height="36dp" |
23 | android:layout_centerVertical="true" | 23 | android:layout_centerVertical="true" |
24 | android:layout_marginLeft="5dp" | 24 | android:layout_marginLeft="5dp" |
25 | android:padding="10dp" | 25 | android:padding="10dp" |
26 | android:src="@mipmap/icon_back" /> | 26 | android:src="@mipmap/icon_back" /> |
27 | 27 | ||
28 | <TextView | 28 | <TextView |
29 | android:id="@+id/tv_photo" | 29 | android:id="@+id/tv_photo" |
30 | android:layout_width="wrap_content" | 30 | android:layout_width="wrap_content" |
31 | android:layout_height="wrap_content" | 31 | android:layout_height="wrap_content" |
32 | android:layout_centerVertical="true" | 32 | android:layout_centerVertical="true" |
33 | android:layout_toRightOf="@+id/iv_back" | 33 | android:layout_toRightOf="@+id/iv_back" |
34 | android:text="重拍" | 34 | android:text="重拍" |
35 | android:textColor="#333333" | 35 | android:textColor="#333333" |
36 | android:textSize="14sp" /> | 36 | android:textSize="14sp" /> |
37 | 37 | ||
38 | <TextView | 38 | <TextView |
39 | android:layout_width="wrap_content" | 39 | android:layout_width="wrap_content" |
40 | android:layout_height="wrap_content" | 40 | android:layout_height="wrap_content" |
41 | android:layout_alignParentRight="true" | 41 | android:layout_alignParentRight="true" |
42 | android:layout_centerVertical="true" | 42 | android:layout_centerVertical="true" |
43 | android:layout_marginRight="15dp" | 43 | android:layout_marginRight="15dp" |
44 | android:text="查看原图" | 44 | android:text="查看原图" |
45 | android:textColor="#333333" | 45 | android:textColor="#333333" |
46 | android:textSize="14sp" | 46 | android:textSize="14sp" |
47 | android:visibility="gone" /> | 47 | android:visibility="gone" /> |
48 | </RelativeLayout> | 48 | </RelativeLayout> |
49 | 49 | ||
50 | <TextView | 50 | <TextView |
51 | android:layout_width="match_parent" | 51 | android:layout_width="match_parent" |
52 | android:layout_height="35dp" | 52 | android:layout_height="35dp" |
53 | android:background="#C7DFF5" | 53 | android:background="#C7DFF5" |
54 | android:gravity="center" | 54 | android:gravity="center" |
55 | android:text="已为您自动框选题目,点击“+”添加题目" | 55 | android:text="已为您自动框选题目,点击“+”添加题目" |
56 | android:textColor="#1C90F3" | 56 | android:textColor="#1C90F3" |
57 | android:textSize="13sp" /> | 57 | android:textSize="13sp" /> |
58 | 58 | ||
59 | <RelativeLayout | 59 | <RelativeLayout |
60 | android:layout_width="match_parent" | 60 | android:layout_width="match_parent" |
61 | android:layout_height="match_parent" | 61 | android:layout_height="match_parent" |
62 | android:background="#F8F8F8"> | 62 | android:background="#F8F8F8"> |
63 | 63 | ||
64 | <androidx.viewpager2.widget.ViewPager2 | 64 | <androidx.viewpager2.widget.ViewPager2 |
65 | android:id="@+id/viewPager" | 65 | android:id="@+id/viewPager" |
66 | android:layout_width="match_parent" | 66 | android:layout_width="match_parent" |
67 | android:layout_height="match_parent" | 67 | android:layout_height="match_parent" |
68 | android:layout_above="@+id/rl_previous" /> | 68 | android:layout_above="@+id/rl_previous" /> |
69 | 69 | ||
70 | <RelativeLayout | 70 | <RelativeLayout |
71 | android:id="@+id/rl_previous" | 71 | android:id="@+id/rl_previous" |
72 | android:layout_width="30dp" | 72 | android:layout_width="30dp" |
73 | android:layout_height="30dp" | 73 | android:layout_height="30dp" |
74 | android:layout_above="@+id/rl_bottom" | 74 | android:layout_above="@+id/rl_bottom" |
75 | android:layout_marginLeft="15dp" | 75 | android:layout_marginLeft="15dp" |
76 | android:layout_marginBottom="15dp" | 76 | android:layout_marginBottom="15dp" |
77 | android:background="@drawable/bg_solid_white"> | 77 | android:background="@drawable/bg_solid_white"> |
78 | 78 | ||
79 | <ImageView | 79 | <ImageView |
80 | android:id="@+id/iv_previous" | 80 | android:id="@+id/iv_previous" |
81 | android:layout_width="10dp" | 81 | android:layout_width="10dp" |
82 | android:layout_height="18dp" | 82 | android:layout_height="18dp" |
83 | android:layout_centerInParent="true" | 83 | android:layout_centerInParent="true" |
84 | android:src="@mipmap/ic_previous_gray" /> | 84 | android:src="@mipmap/ic_previous_gray" /> |
85 | </RelativeLayout> | 85 | </RelativeLayout> |
86 | 86 | ||
87 | <RelativeLayout | 87 | <RelativeLayout |
88 | android:id="@+id/rl_next" | 88 | android:id="@+id/rl_next" |
89 | android:layout_width="30dp" | 89 | android:layout_width="30dp" |
90 | android:layout_height="30dp" | 90 | android:layout_height="30dp" |
91 | android:layout_above="@+id/rl_bottom" | 91 | android:layout_above="@+id/rl_bottom" |
92 | android:layout_alignParentRight="true" | 92 | android:layout_alignParentRight="true" |
93 | android:layout_marginRight="15dp" | 93 | android:layout_marginRight="15dp" |
94 | android:layout_marginBottom="15dp" | 94 | android:layout_marginBottom="15dp" |
95 | android:background="@drawable/bg_solid_white"> | 95 | android:background="@drawable/bg_solid_white"> |
96 | 96 | ||
97 | <ImageView | 97 | <ImageView |
98 | android:id="@+id/iv_next" | 98 | android:id="@+id/iv_next" |
99 | android:layout_width="10dp" | 99 | android:layout_width="10dp" |
100 | android:layout_height="18dp" | 100 | android:layout_height="18dp" |
101 | android:layout_centerInParent="true" | 101 | android:layout_centerInParent="true" |
102 | android:src="@mipmap/ic_next_gray" /> | 102 | android:src="@mipmap/ic_next_gray" /> |
103 | </RelativeLayout> | 103 | </RelativeLayout> |
104 | 104 | ||
105 | <RelativeLayout | 105 | <RelativeLayout |
106 | android:id="@+id/rl_bottom" | 106 | android:id="@+id/rl_bottom" |
107 | android:layout_width="match_parent" | 107 | android:layout_width="match_parent" |
108 | android:layout_height="70dp" | 108 | android:layout_height="70dp" |
109 | android:layout_alignParentBottom="true" | 109 | android:layout_alignParentBottom="true" |
110 | android:background="@color/white"> | 110 | android:background="@color/white"> |
111 | 111 | ||
112 | <LinearLayout | 112 | <LinearLayout |
113 | android:id="@+id/ll_edit" | 113 | android:id="@+id/ll_edit" |
114 | android:layout_width="wrap_content" | 114 | android:layout_width="wrap_content" |
115 | android:layout_height="wrap_content" | 115 | android:layout_height="wrap_content" |
116 | android:layout_centerVertical="true" | 116 | android:layout_centerVertical="true" |
117 | android:layout_marginLeft="15dp" | 117 | android:layout_marginLeft="15dp" |
118 | android:orientation="vertical"> | 118 | android:orientation="vertical"> |
119 | 119 | ||
120 | <ImageView | 120 | <ImageView |
121 | android:layout_width="25dp" | 121 | android:layout_width="25dp" |
122 | android:layout_height="25dp" | 122 | android:layout_height="25dp" |
123 | android:layout_gravity="center_horizontal" | 123 | android:layout_gravity="center_horizontal" |
124 | android:src="@mipmap/ic_pic_edit" /> | 124 | android:src="@mipmap/ic_pic_edit" /> |
125 | 125 | ||
126 | <TextView | 126 | <TextView |
127 | android:layout_width="wrap_content" | 127 | android:layout_width="wrap_content" |
128 | android:layout_height="wrap_content" | 128 | android:layout_height="wrap_content" |
129 | android:layout_marginTop="5dp" | 129 | android:layout_marginTop="5dp" |
130 | android:text="图片编辑" | 130 | android:text="图片编辑" |
131 | android:textSize="11sp" /> | 131 | android:textSize="11sp" /> |
132 | </LinearLayout> | 132 | </LinearLayout> |
133 | 133 | ||
134 | <TextView | 134 | <TextView |
135 | android:id="@+id/tv_add" | 135 | android:id="@+id/tv_add" |
136 | android:layout_width="140dp" | 136 | android:layout_width="140dp" |
137 | android:layout_height="40dp" | 137 | android:layout_height="40dp" |
138 | android:layout_centerVertical="true" | 138 | android:layout_centerVertical="true" |
139 | android:layout_marginRight="15dp" | 139 | android:layout_marginRight="15dp" |
140 | android:layout_toLeftOf="@+id/tv_save" | 140 | android:layout_toLeftOf="@+id/tv_save" |
141 | android:background="@drawable/bg_soild_orange_5" | 141 | android:background="@drawable/bg_soild_orange_5" |
142 | android:gravity="center" | 142 | android:gravity="center" |
143 | android:text="手动框选" | 143 | android:text="手动框选" |
144 | android:textColor="@color/white" | 144 | android:textColor="@color/white" |
145 | android:textSize="18sp" /> | 145 | android:textSize="18sp" /> |
146 | 146 | ||
147 | <TextView | 147 | <TextView |
148 | android:id="@+id/tv_save" | 148 | android:id="@+id/tv_save" |
149 | android:layout_width="140dp" | 149 | android:layout_width="140dp" |
150 | android:layout_height="40dp" | 150 | android:layout_height="40dp" |
151 | android:layout_alignParentRight="true" | 151 | android:layout_alignParentRight="true" |
152 | android:layout_centerVertical="true" | 152 | android:layout_centerVertical="true" |
153 | android:layout_marginRight="15dp" | 153 | android:layout_marginRight="15dp" |
154 | android:background="@drawable/bg_soild_blue_light_5" | 154 | android:background="@drawable/bg_soild_blue_light_5" |
155 | android:enabled="false" | 155 | android:enabled="false" |
156 | android:gravity="center" | 156 | android:gravity="center" |
157 | android:text="保留错题" | 157 | android:text="保存错题" |
158 | android:textColor="@color/white" | 158 | android:textColor="@color/white" |
159 | android:textSize="18sp" /> | 159 | android:textSize="18sp" /> |
160 | </RelativeLayout> | 160 | </RelativeLayout> |
161 | </RelativeLayout> | 161 | </RelativeLayout> |
162 | </LinearLayout> | 162 | </LinearLayout> |
app/src/main/res/layout/activity_main.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
7 | android:background="#F4F6F8" | 7 | android:background="#F4F6F8" |
8 | tools:context=".MainActivity"> | 8 | tools:context=".MainActivity"> |
9 | 9 | ||
10 | <FrameLayout | 10 | <FrameLayout |
11 | android:id="@+id/rl_content" | 11 | android:id="@+id/rl_content" |
12 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
13 | android:layout_height="0dp" | 13 | android:layout_height="0dp" |
14 | app:layout_constraintBottom_toTopOf="@id/cl_1" | 14 | app:layout_constraintBottom_toTopOf="@id/cl_1" |
15 | app:layout_constraintLeft_toLeftOf="parent" | 15 | app:layout_constraintLeft_toLeftOf="parent" |
16 | app:layout_constraintTop_toTopOf="parent" /> | 16 | app:layout_constraintTop_toTopOf="parent" /> |
17 | 17 | ||
18 | 18 | ||
19 | <androidx.constraintlayout.widget.ConstraintLayout | 19 | <androidx.constraintlayout.widget.ConstraintLayout |
20 | android:id="@+id/cl_1" | 20 | android:id="@+id/cl_1" |
21 | android:layout_width="match_parent" | 21 | android:layout_width="match_parent" |
22 | android:layout_height="50dp" | 22 | android:layout_height="50dp" |
23 | android:background="@drawable/bg_solid_white_20" | 23 | android:background="@drawable/bg_solid_white_20" |
24 | app:layout_constraintBottom_toBottomOf="parent"> | 24 | app:layout_constraintBottom_toBottomOf="parent"> |
25 | 25 | ||
26 | <View | 26 | <View |
27 | android:id="@+id/view_5" | 27 | android:id="@+id/view_5" |
28 | android:layout_width="1dp" | 28 | android:layout_width="1dp" |
29 | android:layout_height="1dp" | 29 | android:layout_height="1dp" |
30 | app:layout_constraintBottom_toBottomOf="parent" | 30 | app:layout_constraintBottom_toBottomOf="parent" |
31 | app:layout_constraintLeft_toLeftOf="parent" | 31 | app:layout_constraintLeft_toLeftOf="parent" |
32 | app:layout_constraintRight_toRightOf="parent" /> | 32 | app:layout_constraintRight_toRightOf="parent" /> |
33 | 33 | ||
34 | <androidx.constraintlayout.widget.ConstraintLayout | 34 | <androidx.constraintlayout.widget.ConstraintLayout |
35 | android:id="@+id/cl_home" | 35 | android:id="@+id/cl_home" |
36 | android:layout_width="0dp" | 36 | android:layout_width="0dp" |
37 | android:layout_height="0dp" | 37 | android:layout_height="0dp" |
38 | app:layout_constraintBottom_toBottomOf="parent" | 38 | app:layout_constraintBottom_toBottomOf="parent" |
39 | app:layout_constraintLeft_toLeftOf="parent" | 39 | app:layout_constraintLeft_toLeftOf="parent" |
40 | app:layout_constraintRight_toRightOf="@id/view_5" | 40 | app:layout_constraintRight_toRightOf="@id/view_5" |
41 | app:layout_constraintTop_toTopOf="@id/cl_1"> | 41 | app:layout_constraintTop_toTopOf="@id/cl_1"> |
42 | 42 | ||
43 | <ImageView | 43 | <ImageView |
44 | android:id="@+id/iv_3" | 44 | android:id="@+id/iv_3" |
45 | android:layout_width="27dp" | 45 | android:layout_width="27dp" |
46 | android:layout_height="24dp" | 46 | android:layout_height="24dp" |
47 | android:layout_marginTop="5dp" | 47 | android:layout_marginTop="5dp" |
48 | android:background="@mipmap/hous" | 48 | android:background="@mipmap/hous" |
49 | app:layout_constraintLeft_toLeftOf="parent" | 49 | app:layout_constraintLeft_toLeftOf="parent" |
50 | app:layout_constraintRight_toRightOf="parent" | 50 | app:layout_constraintRight_toRightOf="parent" |
51 | app:layout_constraintTop_toTopOf="parent" /> | 51 | app:layout_constraintTop_toTopOf="parent" /> |
52 | 52 | ||
53 | <TextView | 53 | <TextView |
54 | android:id="@+id/tv_1" | 54 | android:id="@+id/tv_1" |
55 | android:layout_width="wrap_content" | 55 | android:layout_width="wrap_content" |
56 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
57 | android:layout_marginTop="5dp" | 57 | android:layout_marginTop="5dp" |
58 | android:text="首页" | 58 | android:text="首页" |
59 | android:textColor="@drawable/select_t_1" | 59 | android:textColor="#333333" |
60 | android:textSize="11dp" | 60 | android:textSize="11dp" |
61 | app:layout_constraintLeft_toLeftOf="parent" | 61 | app:layout_constraintLeft_toLeftOf="parent" |
62 | app:layout_constraintRight_toRightOf="parent" | 62 | app:layout_constraintRight_toRightOf="parent" |
63 | app:layout_constraintTop_toBottomOf="@id/iv_3" /> | 63 | app:layout_constraintTop_toBottomOf="@id/iv_3" /> |
64 | 64 | ||
65 | 65 | ||
66 | </androidx.constraintlayout.widget.ConstraintLayout> | 66 | </androidx.constraintlayout.widget.ConstraintLayout> |
67 | 67 | ||
68 | <androidx.constraintlayout.widget.ConstraintLayout | 68 | <androidx.constraintlayout.widget.ConstraintLayout |
69 | android:id="@+id/cl_me" | 69 | android:id="@+id/cl_me" |
70 | android:layout_width="0dp" | 70 | android:layout_width="0dp" |
71 | android:layout_height="0dp" | 71 | android:layout_height="0dp" |
72 | app:layout_constraintBottom_toBottomOf="parent" | 72 | app:layout_constraintBottom_toBottomOf="parent" |
73 | app:layout_constraintLeft_toLeftOf="@id/view_5" | 73 | app:layout_constraintLeft_toLeftOf="@id/view_5" |
74 | app:layout_constraintRight_toRightOf="parent" | 74 | app:layout_constraintRight_toRightOf="parent" |
75 | app:layout_constraintTop_toTopOf="@id/cl_1"> | 75 | app:layout_constraintTop_toTopOf="@id/cl_1"> |
76 | 76 | ||
77 | <ImageView | 77 | <ImageView |
78 | android:id="@+id/iv_4" | 78 | android:id="@+id/iv_4" |
79 | android:layout_width="22dp" | 79 | android:layout_width="22dp" |
80 | android:layout_height="25dp" | 80 | android:layout_height="25dp" |
81 | android:layout_marginTop="5dp" | 81 | android:layout_marginTop="5dp" |
82 | android:background="@mipmap/wmus" | 82 | android:background="@mipmap/wmus" |
83 | app:layout_constraintLeft_toLeftOf="parent" | 83 | app:layout_constraintLeft_toLeftOf="parent" |
84 | app:layout_constraintRight_toRightOf="parent" | 84 | app:layout_constraintRight_toRightOf="parent" |
85 | app:layout_constraintTop_toTopOf="parent" /> | 85 | app:layout_constraintTop_toTopOf="parent" /> |
86 | 86 | ||
87 | <TextView | 87 | <TextView |
88 | android:id="@+id/tv_4" | 88 | android:id="@+id/tv_4" |
89 | android:layout_width="wrap_content" | 89 | android:layout_width="wrap_content" |
90 | android:layout_height="wrap_content" | 90 | android:layout_height="wrap_content" |
91 | android:layout_marginTop="5dp" | 91 | android:layout_marginTop="5dp" |
92 | android:text="我的" | 92 | android:text="我的" |
93 | android:textColor="@drawable/select_t_1" | 93 | android:textColor="#333333" |
94 | android:textSize="11dp" | 94 | android:textSize="11dp" |
95 | app:layout_constraintLeft_toLeftOf="parent" | 95 | app:layout_constraintLeft_toLeftOf="parent" |
96 | app:layout_constraintRight_toRightOf="parent" | 96 | app:layout_constraintRight_toRightOf="parent" |
97 | app:layout_constraintTop_toBottomOf="@id/iv_4" /> | 97 | app:layout_constraintTop_toBottomOf="@id/iv_4" /> |
98 | 98 | ||
99 | </androidx.constraintlayout.widget.ConstraintLayout> | 99 | </androidx.constraintlayout.widget.ConstraintLayout> |
100 | 100 | ||
101 | 101 | ||
102 | </androidx.constraintlayout.widget.ConstraintLayout> | 102 | </androidx.constraintlayout.widget.ConstraintLayout> |
103 | 103 | ||
104 | </androidx.constraintlayout.widget.ConstraintLayout> | 104 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/dialog_add_error.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="wrap_content" | 3 | android:layout_height="wrap_content" |
4 | android:background="@drawable/bg_solid_white_10_top" | 4 | android:background="@drawable/bg_solid_white_10_top" |
5 | android:orientation="vertical"> | 5 | android:orientation="vertical"> |
6 | 6 | ||
7 | <RelativeLayout | 7 | <RelativeLayout |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="50dp"> | 9 | android:layout_height="50dp"> |
10 | 10 | ||
11 | <TextView | 11 | <TextView |
12 | android:layout_width="wrap_content" | 12 | android:layout_width="wrap_content" |
13 | android:layout_height="wrap_content" | 13 | android:layout_height="wrap_content" |
14 | android:layout_centerInParent="true" | 14 | android:layout_centerInParent="true" |
15 | android:text="加入错题本" | 15 | android:text="加入错题本" |
16 | android:textColor="@color/text_title" | 16 | android:textColor="@color/text_title" |
17 | android:textSize="17sp" | 17 | android:textSize="17sp" |
18 | android:textStyle="bold" /> | 18 | android:textStyle="bold" /> |
19 | 19 | ||
20 | <ImageView | 20 | <ImageView |
21 | android:id="@+id/iv_back" | 21 | android:id="@+id/iv_back" |
22 | android:layout_width="35dp" | 22 | android:layout_width="35dp" |
23 | android:layout_height="35dp" | 23 | android:layout_height="35dp" |
24 | android:layout_alignParentRight="true" | 24 | android:layout_alignParentRight="true" |
25 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
26 | android:layout_marginRight="10dp" | 26 | android:layout_marginRight="10dp" |
27 | android:padding="10dp" | 27 | android:padding="10dp" |
28 | android:src="@mipmap/ic_close" /> | 28 | android:src="@mipmap/ic_close" /> |
29 | </RelativeLayout> | 29 | </RelativeLayout> |
30 | 30 | ||
31 | <androidx.recyclerview.widget.RecyclerView | 31 | <androidx.recyclerview.widget.RecyclerView |
32 | android:id="@+id/list_item" | 32 | android:id="@+id/list_item" |
33 | android:layout_width="match_parent" | 33 | android:layout_width="match_parent" |
34 | android:layout_height="30dp" | 34 | android:layout_height="30dp" |
35 | android:layout_marginLeft="20dp" | 35 | android:layout_marginLeft="20dp" |
36 | android:layout_marginTop="10dp" | 36 | android:layout_marginTop="10dp" |
37 | android:layout_marginRight="20dp" /> | 37 | android:layout_marginRight="20dp" /> |
38 | 38 | ||
39 | <RelativeLayout | 39 | <RelativeLayout |
40 | android:layout_width="match_parent" | 40 | android:layout_width="match_parent" |
41 | android:layout_height="90dp" | 41 | android:layout_height="90dp" |
42 | android:layout_marginLeft="20dp" | 42 | android:layout_marginLeft="20dp" |
43 | android:layout_marginTop="20dp" | 43 | android:layout_marginTop="20dp" |
44 | android:layout_marginRight="20dp"> | 44 | android:layout_marginRight="20dp"> |
45 | 45 | ||
46 | <RelativeLayout | 46 | <RelativeLayout |
47 | android:layout_width="match_parent" | 47 | android:layout_width="match_parent" |
48 | android:layout_height="match_parent" | 48 | android:layout_height="match_parent" |
49 | android:background="#F5F5F5"> | 49 | android:background="#F5F5F5"> |
50 | 50 | ||
51 | <ImageView | 51 | <ImageView |
52 | android:id="@+id/iv_topic" | 52 | android:id="@+id/iv_topic" |
53 | android:layout_width="wrap_content" | 53 | android:layout_width="wrap_content" |
54 | android:layout_height="wrap_content" | 54 | android:layout_height="wrap_content" |
55 | android:layout_centerVertical="true" /> | 55 | android:layout_centerVertical="true" /> |
56 | </RelativeLayout> | 56 | </RelativeLayout> |
57 | </RelativeLayout> | 57 | </RelativeLayout> |
58 | 58 | ||
59 | <TextView | 59 | <TextView |
60 | android:layout_width="wrap_content" | 60 | android:layout_width="wrap_content" |
61 | android:layout_height="wrap_content" | 61 | android:layout_height="wrap_content" |
62 | android:layout_centerVertical="true" | 62 | android:layout_centerVertical="true" |
63 | android:layout_marginLeft="20dp" | 63 | android:layout_marginLeft="20dp" |
64 | android:layout_marginTop="20dp" | 64 | android:layout_marginTop="20dp" |
65 | android:text="年级学期" | 65 | android:text="年级" |
66 | android:textColor="@color/text_title" | 66 | android:textColor="@color/text_title" |
67 | android:textSize="15sp" | 67 | android:textSize="15sp" |
68 | android:textStyle="bold" /> | 68 | android:textStyle="bold" /> |
69 | 69 | ||
70 | <androidx.appcompat.widget.AppCompatSpinner | 70 | <androidx.appcompat.widget.AppCompatSpinner |
71 | android:id="@+id/spinner_grade" | 71 | android:id="@+id/spinner_grade" |
72 | style="@style/customSpinnerStyle" | 72 | style="@style/customSpinnerStyle" |
73 | android:layout_width="match_parent" | 73 | android:layout_width="match_parent" |
74 | android:layout_height="40dp" | 74 | android:layout_height="40dp" |
75 | android:layout_centerHorizontal="true" | 75 | android:layout_centerHorizontal="true" |
76 | android:layout_marginLeft="20dp" | 76 | android:layout_marginLeft="20dp" |
77 | android:layout_marginTop="10dp" | 77 | android:layout_marginTop="10dp" |
78 | android:layout_marginRight="20dp" | 78 | android:layout_marginRight="20dp" |
79 | android:background="@drawable/selector_for_custom_spinner" | 79 | android:background="@drawable/selector_for_custom_spinner" |
80 | android:entries="@array/filter_subject" | 80 | android:popupBackground="@drawable/shape_for_custom_spinner" |
81 | android:scrollbars="none" /> | ||
82 | |||
83 | <TextView | ||
84 | android:layout_width="wrap_content" | ||
85 | android:layout_height="wrap_content" | ||
86 | android:layout_centerVertical="true" | ||
87 | android:layout_marginLeft="20dp" | ||
88 | android:layout_marginTop="20dp" | ||
89 | android:text="学期" | ||
90 | android:textColor="@color/text_title" | ||
91 | android:textSize="15sp" | ||
92 | android:textStyle="bold" /> | ||
93 | |||
94 | <androidx.appcompat.widget.AppCompatSpinner | ||
95 | android:id="@+id/spinner_grade1" | ||
96 | style="@style/customSpinnerStyle" | ||
97 | android:layout_width="match_parent" | ||
98 | android:layout_height="40dp" | ||
99 | android:layout_centerHorizontal="true" | ||
100 | android:layout_marginLeft="20dp" | ||
101 | android:layout_marginTop="10dp" | ||
102 | android:layout_marginRight="20dp" | ||
103 | android:background="@drawable/selector_for_custom_spinner" | ||
104 | android:entries="@array/grade_array" | ||
81 | android:popupBackground="@drawable/shape_for_custom_spinner" | 105 | android:popupBackground="@drawable/shape_for_custom_spinner" |
82 | android:scrollbars="none" /> | 106 | android:scrollbars="none" /> |
83 | 107 | ||
84 | <TextView | 108 | <TextView |
85 | android:layout_width="wrap_content" | 109 | android:layout_width="wrap_content" |
86 | android:layout_height="wrap_content" | 110 | android:layout_height="wrap_content" |
87 | android:layout_centerVertical="true" | 111 | android:layout_centerVertical="true" |
88 | android:layout_marginLeft="20dp" | 112 | android:layout_marginLeft="20dp" |
89 | android:layout_marginTop="20dp" | 113 | android:layout_marginTop="20dp" |
90 | android:text="科目" | 114 | android:text="科目" |
91 | android:textColor="@color/text_title" | 115 | android:textColor="@color/text_title" |
92 | android:textSize="15sp" | 116 | android:textSize="15sp" |
93 | android:textStyle="bold" /> | 117 | android:textStyle="bold" /> |
94 | 118 | ||
95 | <androidx.appcompat.widget.AppCompatSpinner | 119 | <androidx.appcompat.widget.AppCompatSpinner |
96 | android:id="@+id/spinner_subject" | 120 | android:id="@+id/spinner_subject" |
97 | style="@style/customSpinnerStyle" | 121 | style="@style/customSpinnerStyle" |
98 | android:layout_width="match_parent" | 122 | android:layout_width="match_parent" |
99 | android:layout_height="40dp" | 123 | android:layout_height="40dp" |
100 | android:layout_centerHorizontal="true" | 124 | android:layout_centerHorizontal="true" |
101 | android:layout_marginLeft="20dp" | 125 | android:layout_marginLeft="20dp" |
102 | android:layout_marginTop="10dp" | 126 | android:layout_marginTop="10dp" |
103 | android:layout_marginRight="20dp" | 127 | android:layout_marginRight="20dp" |
104 | android:background="@drawable/selector_for_custom_spinner" | 128 | android:background="@drawable/selector_for_custom_spinner" |
105 | android:entries="@array/filter_subject" | 129 | android:entries="@array/filter_subject" |
106 | android:popupBackground="@drawable/shape_for_custom_spinner" | 130 | android:popupBackground="@drawable/shape_for_custom_spinner" |
107 | android:scrollbars="none" /> | 131 | android:scrollbars="none" /> |
108 | 132 | ||
109 | <TextView | 133 | <TextView |
110 | android:layout_width="wrap_content" | 134 | android:layout_width="wrap_content" |
111 | android:layout_height="wrap_content" | 135 | android:layout_height="wrap_content" |
112 | android:layout_centerVertical="true" | 136 | android:layout_centerVertical="true" |
113 | android:layout_marginLeft="20dp" | 137 | android:layout_marginLeft="20dp" |
114 | android:layout_marginTop="20dp" | 138 | android:layout_marginTop="20dp" |
115 | android:text="错误原因" | 139 | android:text="错误原因" |
116 | android:textColor="@color/text_title" | 140 | android:textColor="@color/text_title" |
117 | android:textSize="15sp" | 141 | android:textSize="15sp" |
118 | android:textStyle="bold" /> | 142 | android:textStyle="bold" /> |
119 | 143 | ||
120 | <androidx.appcompat.widget.AppCompatSpinner | 144 | <androidx.appcompat.widget.AppCompatSpinner |
121 | android:id="@+id/spinner_reason" | 145 | android:id="@+id/spinner_reason" |
122 | style="@style/customSpinnerStyle" | 146 | style="@style/customSpinnerStyle" |
123 | android:layout_width="match_parent" | 147 | android:layout_width="match_parent" |
124 | android:layout_height="40dp" | 148 | android:layout_height="40dp" |
125 | android:layout_centerHorizontal="true" | 149 | android:layout_centerHorizontal="true" |
126 | android:layout_marginLeft="20dp" | 150 | android:layout_marginLeft="20dp" |
127 | android:layout_marginTop="10dp" | 151 | android:layout_marginTop="10dp" |
128 | android:layout_marginRight="20dp" | 152 | android:layout_marginRight="20dp" |
129 | android:background="@drawable/selector_for_custom_spinner" | 153 | android:background="@drawable/selector_for_custom_spinner" |
130 | android:entries="@array/filter_subject" | 154 | android:entries="@array/filter_subject" |
131 | android:popupBackground="@drawable/shape_for_custom_spinner" | 155 | android:popupBackground="@drawable/shape_for_custom_spinner" |
132 | android:scrollbars="none" /> | 156 | android:scrollbars="none" /> |
133 | 157 | ||
134 | <TextView | 158 | <TextView |
135 | android:id="@+id/tv_student" | 159 | android:id="@+id/tv_student" |
136 | android:layout_width="wrap_content" | 160 | android:layout_width="wrap_content" |
137 | android:layout_height="wrap_content" | 161 | android:layout_height="wrap_content" |
138 | android:layout_centerVertical="true" | 162 | android:layout_centerVertical="true" |
139 | android:layout_marginLeft="20dp" | 163 | android:layout_marginLeft="20dp" |
140 | android:layout_marginTop="20dp" | 164 | android:layout_marginTop="20dp" |
141 | android:text="学生" | 165 | android:text="学生" |
142 | android:textColor="@color/text_title" | 166 | android:textColor="@color/text_title" |
143 | android:visibility="gone" | 167 | android:visibility="gone" |
144 | android:textSize="15sp" | 168 | android:textSize="15sp" |
145 | android:textStyle="bold" /> | 169 | android:textStyle="bold" /> |
146 | 170 | ||
147 | <androidx.appcompat.widget.AppCompatSpinner | 171 | <androidx.appcompat.widget.AppCompatSpinner |
148 | android:id="@+id/spinner_student" | 172 | android:id="@+id/spinner_student" |
149 | style="@style/customSpinnerStyle" | 173 | style="@style/customSpinnerStyle" |
150 | android:layout_width="match_parent" | 174 | android:layout_width="match_parent" |
151 | android:layout_height="40dp" | 175 | android:layout_height="40dp" |
152 | android:layout_centerHorizontal="true" | 176 | android:layout_centerHorizontal="true" |
153 | android:layout_marginLeft="20dp" | 177 | android:layout_marginLeft="20dp" |
154 | android:layout_marginTop="10dp" | 178 | android:layout_marginTop="10dp" |
155 | android:layout_marginRight="20dp" | 179 | android:layout_marginRight="20dp" |
156 | android:visibility="gone" | 180 | android:visibility="gone" |
157 | android:background="@drawable/selector_for_custom_spinner" | 181 | android:background="@drawable/selector_for_custom_spinner" |
158 | android:entries="@array/filter_subject" | 182 | android:entries="@array/filter_subject" |
159 | android:popupBackground="@drawable/shape_for_custom_spinner" | 183 | android:popupBackground="@drawable/shape_for_custom_spinner" |
160 | android:scrollbars="none" /> | 184 | android:scrollbars="none" /> |
161 | 185 | ||
162 | <TextView | 186 | <TextView |
163 | android:layout_width="wrap_content" | 187 | android:layout_width="wrap_content" |
164 | android:layout_height="wrap_content" | 188 | android:layout_height="wrap_content" |
165 | android:layout_centerVertical="true" | 189 | android:layout_centerVertical="true" |
166 | android:layout_marginLeft="20dp" | 190 | android:layout_marginLeft="20dp" |
167 | android:layout_marginTop="20dp" | 191 | android:layout_marginTop="20dp" |
168 | android:text="来源" | 192 | android:text="来源" |
169 | android:textColor="@color/text_title" | 193 | android:textColor="@color/text_title" |
170 | android:textSize="15sp" | 194 | android:textSize="15sp" |
171 | android:textStyle="bold" /> | 195 | android:textStyle="bold" /> |
172 | 196 | ||
173 | <RadioGroup | 197 | <RadioGroup |
174 | android:id="@+id/type_radio" | 198 | android:id="@+id/type_radio" |
175 | android:layout_width="match_parent" | 199 | android:layout_width="match_parent" |
176 | android:layout_height="40dp" | 200 | android:layout_height="40dp" |
177 | android:layout_marginLeft="20dp" | 201 | android:layout_marginLeft="20dp" |
178 | android:layout_marginTop="10dp" | 202 | android:layout_marginTop="10dp" |
179 | android:orientation="horizontal"> | 203 | android:orientation="horizontal"> |
180 | 204 | ||
181 | <RadioButton | 205 | <RadioButton |
182 | android:layout_width="65dp" | 206 | android:layout_width="65dp" |
183 | android:layout_height="match_parent" | 207 | android:layout_height="match_parent" |
184 | android:layout_marginRight="20dp" | 208 | android:layout_marginRight="20dp" |
185 | android:background="@drawable/radio_button_selector" | 209 | android:background="@drawable/radio_button_selector" |
186 | android:button="@null" | 210 | android:button="@null" |
187 | android:gravity="center" | 211 | android:gravity="center" |
188 | android:text="课内" | 212 | android:text="课内" |
189 | android:textColor="@drawable/radio_text_selector" | 213 | android:textColor="@drawable/radio_text_selector" |
190 | android:textSize="14sp" /> | 214 | android:textSize="14sp" /> |
191 | 215 | ||
192 | <RadioButton | 216 | <RadioButton |
193 | android:layout_width="65dp" | 217 | android:layout_width="65dp" |
194 | android:layout_height="match_parent" | 218 | android:layout_height="match_parent" |
195 | android:layout_marginRight="20dp" | 219 | android:layout_marginRight="20dp" |
196 | android:background="@drawable/radio_button_selector" | 220 | android:background="@drawable/radio_button_selector" |
197 | android:button="@null" | 221 | android:button="@null" |
198 | android:gravity="center" | 222 | android:gravity="center" |
199 | android:text="课外" | 223 | android:text="课外" |
200 | android:textColor="@drawable/radio_text_selector" | 224 | android:textColor="@drawable/radio_text_selector" |
201 | android:textSize="14sp" /> | 225 | android:textSize="14sp" /> |
202 | </RadioGroup> | 226 | </RadioGroup> |
203 | 227 | ||
204 | 228 | ||
205 | <RelativeLayout | 229 | <RelativeLayout |
206 | android:layout_width="match_parent" | 230 | android:layout_width="match_parent" |
207 | android:layout_height="40dp" | 231 | android:layout_height="40dp" |
208 | android:layout_marginLeft="20dp" | 232 | android:layout_marginLeft="20dp" |
209 | android:layout_marginTop="20dp" | 233 | android:layout_marginTop="20dp" |
210 | android:layout_marginRight="20dp" | 234 | android:layout_marginRight="20dp" |
211 | android:layout_marginBottom="15dp"> | 235 | android:layout_marginBottom="15dp"> |
212 | 236 | ||
213 | <TextView | 237 | <TextView |
214 | android:id="@+id/add_topic" | 238 | android:id="@+id/add_topic" |
215 | android:layout_width="250dp" | 239 | android:layout_width="250dp" |
216 | android:layout_height="match_parent" | 240 | android:layout_height="match_parent" |
217 | android:layout_alignParentRight="true" | 241 | android:layout_alignParentRight="true" |
218 | android:background="@drawable/bg_soild_blue_5" | 242 | android:background="@drawable/bg_soild_blue_5" |
219 | android:gravity="center" | 243 | android:gravity="center" |
220 | android:textColor="@color/white" | 244 | android:textColor="@color/white" |
221 | android:textSize="17sp" /> | 245 | android:textSize="17sp" /> |
222 | 246 | ||
223 | <CheckBox | 247 | <CheckBox |
224 | android:id="@+id/checkbox" | 248 | android:id="@+id/checkbox" |
225 | android:layout_width="wrap_content" | 249 | android:layout_width="wrap_content" |
226 | android:layout_height="30dp" | 250 | android:layout_height="30dp" |
227 | android:layout_centerVertical="true" | 251 | android:layout_centerVertical="true" |
228 | android:button="@drawable/checkbox_selector" | 252 | android:button="@drawable/checkbox_selector" |
229 | android:text="批量设置" | 253 | android:text="批量设置" |
230 | android:paddingLeft="8dp" | 254 | android:paddingLeft="8dp" |
231 | android:textColor="@color/text_title" | 255 | android:textColor="@color/text_title" |
232 | android:textSize="14sp" /> | 256 | android:textSize="14sp" /> |
233 | 257 | ||
234 | </RelativeLayout> | 258 | </RelativeLayout> |
235 | </LinearLayout> | 259 | </LinearLayout> |
236 | 260 | ||
237 | 261 |
app/src/main/res/layout/dialog_edit_error.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="wrap_content" | 3 | android:layout_height="wrap_content" |
4 | android:background="@drawable/bg_solid_white_10_top" | 4 | android:background="@drawable/bg_solid_white_10_top" |
5 | android:orientation="vertical"> | 5 | android:orientation="vertical"> |
6 | 6 | ||
7 | <RelativeLayout | 7 | <RelativeLayout |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="50dp"> | 9 | android:layout_height="50dp"> |
10 | 10 | ||
11 | <TextView | 11 | <TextView |
12 | android:layout_width="wrap_content" | 12 | android:layout_width="wrap_content" |
13 | android:layout_height="wrap_content" | 13 | android:layout_height="wrap_content" |
14 | android:layout_centerInParent="true" | 14 | android:layout_centerInParent="true" |
15 | android:text="错题标签" | 15 | android:text="错题标签" |
16 | android:textColor="@color/text_title" | 16 | android:textColor="@color/text_title" |
17 | android:textSize="17sp" | 17 | android:textSize="17sp" |
18 | android:textStyle="bold" /> | 18 | android:textStyle="bold" /> |
19 | 19 | ||
20 | <ImageView | 20 | <ImageView |
21 | android:id="@+id/iv_back" | 21 | android:id="@+id/iv_back" |
22 | android:layout_width="35dp" | 22 | android:layout_width="35dp" |
23 | android:layout_height="35dp" | 23 | android:layout_height="35dp" |
24 | android:layout_alignParentRight="true" | 24 | android:layout_alignParentRight="true" |
25 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
26 | android:layout_marginRight="10dp" | 26 | android:layout_marginRight="10dp" |
27 | android:padding="10dp" | 27 | android:padding="10dp" |
28 | android:src="@mipmap/ic_close" /> | 28 | android:src="@mipmap/ic_close" /> |
29 | </RelativeLayout> | 29 | </RelativeLayout> |
30 | 30 | ||
31 | <TextView | 31 | <TextView |
32 | android:layout_width="wrap_content" | 32 | android:layout_width="wrap_content" |
33 | android:layout_height="wrap_content" | 33 | android:layout_height="wrap_content" |
34 | android:layout_centerVertical="true" | 34 | android:layout_centerVertical="true" |
35 | android:layout_marginLeft="20dp" | 35 | android:layout_marginLeft="20dp" |
36 | android:layout_marginTop="20dp" | 36 | android:layout_marginTop="20dp" |
37 | android:text="年级学期" | 37 | android:text="年级" |
38 | android:textColor="@color/text_title" | 38 | android:textColor="@color/text_title" |
39 | android:textSize="15sp" | 39 | android:textSize="15sp" |
40 | android:textStyle="bold" /> | 40 | android:textStyle="bold" /> |
41 | 41 | ||
42 | <androidx.appcompat.widget.AppCompatSpinner | 42 | <androidx.appcompat.widget.AppCompatSpinner |
43 | android:id="@+id/spinner_grade" | 43 | android:id="@+id/spinner_grade" |
44 | style="@style/customSpinnerStyle" | 44 | style="@style/customSpinnerStyle" |
45 | android:layout_width="match_parent" | 45 | android:layout_width="match_parent" |
46 | android:layout_height="40dp" | 46 | android:layout_height="40dp" |
47 | android:layout_centerHorizontal="true" | 47 | android:layout_centerHorizontal="true" |
48 | android:layout_marginLeft="20dp" | 48 | android:layout_marginLeft="20dp" |
49 | android:layout_marginTop="10dp" | 49 | android:layout_marginTop="10dp" |
50 | android:layout_marginRight="20dp" | 50 | android:layout_marginRight="20dp" |
51 | android:background="@drawable/selector_for_custom_spinner" | 51 | android:background="@drawable/selector_for_custom_spinner" |
52 | android:entries="@array/filter_subject" | 52 | android:entries="@array/filter_subject" |
53 | android:popupBackground="@drawable/shape_for_custom_spinner" | 53 | android:popupBackground="@drawable/shape_for_custom_spinner" |
54 | android:scrollbars="none" /> | 54 | android:scrollbars="none" /> |
55 | 55 | ||
56 | <TextView | 56 | <TextView |
57 | android:layout_width="wrap_content" | 57 | android:layout_width="wrap_content" |
58 | android:layout_height="wrap_content" | 58 | android:layout_height="wrap_content" |
59 | android:layout_centerVertical="true" | 59 | android:layout_centerVertical="true" |
60 | android:layout_marginLeft="20dp" | 60 | android:layout_marginLeft="20dp" |
61 | android:layout_marginTop="20dp" | 61 | android:layout_marginTop="20dp" |
62 | android:text="学期" | ||
63 | android:textColor="@color/text_title" | ||
64 | android:textSize="15sp" | ||
65 | android:textStyle="bold" /> | ||
66 | |||
67 | <androidx.appcompat.widget.AppCompatSpinner | ||
68 | android:id="@+id/spinner_grade1" | ||
69 | style="@style/customSpinnerStyle" | ||
70 | android:layout_width="match_parent" | ||
71 | android:layout_height="40dp" | ||
72 | android:layout_centerHorizontal="true" | ||
73 | android:layout_marginLeft="20dp" | ||
74 | android:layout_marginTop="10dp" | ||
75 | android:layout_marginRight="20dp" | ||
76 | android:background="@drawable/selector_for_custom_spinner" | ||
77 | android:entries="@array/grade_array" | ||
78 | android:popupBackground="@drawable/shape_for_custom_spinner" | ||
79 | android:scrollbars="none" /> | ||
80 | |||
81 | <TextView | ||
82 | android:layout_width="wrap_content" | ||
83 | android:layout_height="wrap_content" | ||
84 | android:layout_centerVertical="true" | ||
85 | android:layout_marginLeft="20dp" | ||
86 | android:layout_marginTop="20dp" | ||
62 | android:text="科目" | 87 | android:text="科目" |
63 | android:textColor="@color/text_title" | 88 | android:textColor="@color/text_title" |
64 | android:textSize="15sp" | 89 | android:textSize="15sp" |
65 | android:textStyle="bold" /> | 90 | android:textStyle="bold" /> |
66 | 91 | ||
67 | <androidx.appcompat.widget.AppCompatSpinner | 92 | <androidx.appcompat.widget.AppCompatSpinner |
68 | android:id="@+id/spinner_subject" | 93 | android:id="@+id/spinner_subject" |
69 | style="@style/customSpinnerStyle" | 94 | style="@style/customSpinnerStyle" |
70 | android:layout_width="match_parent" | 95 | android:layout_width="match_parent" |
71 | android:layout_height="40dp" | 96 | android:layout_height="40dp" |
72 | android:layout_centerHorizontal="true" | 97 | android:layout_centerHorizontal="true" |
73 | android:layout_marginLeft="20dp" | 98 | android:layout_marginLeft="20dp" |
74 | android:layout_marginTop="10dp" | 99 | android:layout_marginTop="10dp" |
75 | android:layout_marginRight="20dp" | 100 | android:layout_marginRight="20dp" |
76 | android:background="@drawable/selector_for_custom_spinner" | 101 | android:background="@drawable/selector_for_custom_spinner" |
77 | android:entries="@array/filter_subject" | 102 | android:entries="@array/filter_subject" |
78 | android:popupBackground="@drawable/shape_for_custom_spinner" | 103 | android:popupBackground="@drawable/shape_for_custom_spinner" |
79 | android:scrollbars="none" /> | 104 | android:scrollbars="none" /> |
80 | 105 | ||
81 | <TextView | 106 | <TextView |
82 | android:layout_width="wrap_content" | 107 | android:layout_width="wrap_content" |
83 | android:layout_height="wrap_content" | 108 | android:layout_height="wrap_content" |
84 | android:layout_centerVertical="true" | 109 | android:layout_centerVertical="true" |
85 | android:layout_marginLeft="20dp" | 110 | android:layout_marginLeft="20dp" |
86 | android:layout_marginTop="20dp" | 111 | android:layout_marginTop="20dp" |
87 | android:text="错误原因" | 112 | android:text="错误原因" |
88 | android:textColor="@color/text_title" | 113 | android:textColor="@color/text_title" |
89 | android:textSize="15sp" | 114 | android:textSize="15sp" |
90 | android:textStyle="bold" /> | 115 | android:textStyle="bold" /> |
91 | 116 | ||
92 | <androidx.appcompat.widget.AppCompatSpinner | 117 | <androidx.appcompat.widget.AppCompatSpinner |
93 | android:id="@+id/spinner_reason" | 118 | android:id="@+id/spinner_reason" |
94 | style="@style/customSpinnerStyle" | 119 | style="@style/customSpinnerStyle" |
95 | android:layout_width="match_parent" | 120 | android:layout_width="match_parent" |
96 | android:layout_height="40dp" | 121 | android:layout_height="40dp" |
97 | android:layout_centerHorizontal="true" | 122 | android:layout_centerHorizontal="true" |
98 | android:layout_marginLeft="20dp" | 123 | android:layout_marginLeft="20dp" |
99 | android:layout_marginTop="10dp" | 124 | android:layout_marginTop="10dp" |
100 | android:layout_marginRight="20dp" | 125 | android:layout_marginRight="20dp" |
101 | android:background="@drawable/selector_for_custom_spinner" | 126 | android:background="@drawable/selector_for_custom_spinner" |
102 | android:entries="@array/filter_subject" | 127 | android:entries="@array/filter_subject" |
103 | android:popupBackground="@drawable/shape_for_custom_spinner" | 128 | android:popupBackground="@drawable/shape_for_custom_spinner" |
104 | android:scrollbars="none" /> | 129 | android:scrollbars="none" /> |
105 | 130 | ||
106 | <TextView | 131 | <TextView |
107 | android:layout_width="wrap_content" | 132 | android:layout_width="wrap_content" |
108 | android:layout_height="wrap_content" | 133 | android:layout_height="wrap_content" |
109 | android:layout_centerVertical="true" | 134 | android:layout_centerVertical="true" |
110 | android:layout_marginLeft="20dp" | 135 | android:layout_marginLeft="20dp" |
111 | android:layout_marginTop="20dp" | 136 | android:layout_marginTop="20dp" |
112 | android:text="来源" | 137 | android:text="来源" |
113 | android:textColor="@color/text_title" | 138 | android:textColor="@color/text_title" |
114 | android:textSize="15sp" | 139 | android:textSize="15sp" |
115 | android:textStyle="bold" /> | 140 | android:textStyle="bold" /> |
116 | 141 | ||
117 | <RadioGroup | 142 | <RadioGroup |
118 | android:id="@+id/type_radio" | 143 | android:id="@+id/type_radio" |
119 | android:layout_width="match_parent" | 144 | android:layout_width="match_parent" |
120 | android:layout_height="40dp" | 145 | android:layout_height="40dp" |
121 | android:layout_marginLeft="20dp" | 146 | android:layout_marginLeft="20dp" |
122 | android:layout_marginTop="10dp" | 147 | android:layout_marginTop="10dp" |
123 | android:orientation="horizontal"> | 148 | android:orientation="horizontal"> |
124 | 149 | ||
125 | <RadioButton | 150 | <RadioButton |
126 | android:layout_width="65dp" | 151 | android:layout_width="65dp" |
127 | android:layout_height="match_parent" | 152 | android:layout_height="match_parent" |
128 | android:layout_marginRight="20dp" | 153 | android:layout_marginRight="20dp" |
129 | android:background="@drawable/radio_button_selector" | 154 | android:background="@drawable/radio_button_selector" |
130 | android:button="@null" | 155 | android:button="@null" |
131 | android:gravity="center" | 156 | android:gravity="center" |
132 | android:text="课内" | 157 | android:text="课内" |
133 | android:textColor="@drawable/radio_text_selector" | 158 | android:textColor="@drawable/radio_text_selector" |
134 | android:textSize="14sp" /> | 159 | android:textSize="14sp" /> |
135 | 160 | ||
136 | <RadioButton | 161 | <RadioButton |
137 | android:layout_width="65dp" | 162 | android:layout_width="65dp" |
138 | android:layout_height="match_parent" | 163 | android:layout_height="match_parent" |
139 | android:layout_marginRight="20dp" | 164 | android:layout_marginRight="20dp" |
140 | android:background="@drawable/radio_button_selector" | 165 | android:background="@drawable/radio_button_selector" |
141 | android:button="@null" | 166 | android:button="@null" |
142 | android:gravity="center" | 167 | android:gravity="center" |
143 | android:text="课外" | 168 | android:text="课外" |
144 | android:textColor="@drawable/radio_text_selector" | 169 | android:textColor="@drawable/radio_text_selector" |
145 | android:textSize="14sp" /> | 170 | android:textSize="14sp" /> |
146 | </RadioGroup> | 171 | </RadioGroup> |
147 | 172 | ||
148 | 173 | ||
149 | <RelativeLayout | 174 | <RelativeLayout |
150 | android:layout_width="match_parent" | 175 | android:layout_width="match_parent" |
151 | android:layout_height="40dp" | 176 | android:layout_height="40dp" |
152 | android:layout_marginLeft="20dp" | 177 | android:layout_marginLeft="20dp" |
153 | android:layout_marginTop="20dp" | 178 | android:layout_marginTop="20dp" |
154 | android:layout_marginRight="20dp" | 179 | android:layout_marginRight="20dp" |
155 | android:layout_marginBottom="15dp"> | 180 | android:layout_marginBottom="15dp"> |
156 | 181 | ||
157 | <TextView | 182 | <TextView |
158 | android:id="@+id/add_topic" | 183 | android:id="@+id/add_topic" |
159 | android:layout_width="250dp" | 184 | android:layout_width="250dp" |
160 | android:layout_height="match_parent" | 185 | android:layout_height="match_parent" |
161 | android:layout_centerInParent="true" | 186 | android:layout_centerInParent="true" |
162 | android:background="@drawable/bg_soild_blue_5" | 187 | android:background="@drawable/bg_soild_blue_5" |
163 | android:gravity="center" | 188 | android:gravity="center" |
164 | android:text="确认修改" | 189 | android:text="确认修改" |
165 | android:textColor="@color/white" | 190 | android:textColor="@color/white" |
166 | android:textSize="17sp" /> | 191 | android:textSize="17sp" /> |
167 | 192 | ||
168 | 193 | ||
169 | </RelativeLayout> | 194 | </RelativeLayout> |
170 | </LinearLayout> | 195 | </LinearLayout> |
171 | 196 | ||
172 | 197 |
app/src/main/res/mipmap-xxxhdpi/ic_chinese.png
app/src/main/res/values/strings.xml
1 | <resources> | 1 | <resources> |
2 | <string name="app_name">家长管控</string> | 2 | <string name="app_name">家长管控</string> |
3 | <string name="chinese">语文</string> | 3 | <string name="chinese">语文</string> |
4 | <string name="math">数学</string> | 4 | <string name="math">数学</string> |
5 | <string name="english">英语</string> | 5 | <string name="english">英语</string> |
6 | <string name="physics">物理</string> | 6 | <string name="physics">物理</string> |
7 | <string name="chemistry">化学</string> | 7 | <string name="chemistry">化学</string> |
8 | <string name="text_done">已掌握</string> | 8 | <string name="text_done">已掌握</string> |
9 | <string name="text_undo">未掌握</string> | 9 | <string name="text_undo">未掌握</string> |
10 | <string name="topic_start">知识点</string> | 10 | <string name="topic_start">知识点</string> |
11 | <string name="loading_text">图片处理中,请稍后。。。</string> | 11 | <string name="loading_text">图片处理中,请稍后。。。</string> |
12 | <string name="num_topic">第%1$s题</string> | 12 | <string name="num_topic">第%1$s题</string> |
13 | <string name="topic_type_in">课内</string> | 13 | <string name="topic_type_in">课内</string> |
14 | <string name="topic_type_out">课外</string> | 14 | <string name="topic_type_out">课外</string> |
15 | <string-array name="filter_subject"> | 15 | <string-array name="filter_subject"> |
16 | <item>@string/chinese</item> | 16 | <item>@string/chinese</item> |
17 | <item>@string/math</item> | 17 | <item>@string/math</item> |
18 | <item>@string/english</item> | 18 | <item>@string/english</item> |
19 | <item>@string/physics</item> | 19 | <item>@string/physics</item> |
20 | <item>@string/chemistry</item> | 20 | <item>@string/chemistry</item> |
21 | </string-array> | 21 | </string-array> |
22 | <string-array name="error_reason"> | 22 | <string-array name="error_reason"> |
23 | <item>审题错误</item> | 23 | <item>审题错误</item> |
24 | <item>思路错误</item> | 24 | <item>思路错误</item> |
25 | <item>运算错误</item> | 25 | <item>运算错误</item> |
26 | <item>概念模糊</item> | 26 | <item>概念模糊</item> |
27 | <item>粗心大意</item> | 27 | <item>粗心大意</item> |
28 | <item>其他错误</item> | 28 | <item>其他错误</item> |
29 | </string-array> | 29 | </string-array> |
30 | <string-array name="grade_array"> | ||
31 | <item>上学期</item> | ||
32 | <item>下学期</item> | ||
33 | </string-array> | ||
30 | </resources> | 34 | </resources> |