Commit d34cc18f6a8cca56b51a2627648451176f55548a
1 parent
7d8ce5d272
Exists in
master
作业列表与筛选
Showing
18 changed files
with
640 additions
and
7 deletions
Show diff stats
app/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | apply from: '../config.gradle' | 2 | apply from: '../config.gradle' |
3 | 3 | ||
4 | 4 | ||
5 | def androidId = rootProject.ext.androidId | 5 | def androidId = rootProject.ext.androidId |
6 | def support = rootProject.ext.dependencies | 6 | def support = rootProject.ext.dependencies |
7 | def url = rootProject.ext.url | 7 | def url = rootProject.ext.url |
8 | 8 | ||
9 | 9 | ||
10 | android { | 10 | android { |
11 | signingConfigs { | 11 | signingConfigs { |
12 | 12 | ||
13 | config { | 13 | config { |
14 | keyAlias 'alias' | 14 | keyAlias 'alias' |
15 | keyPassword '123456' | 15 | keyPassword '123456' |
16 | storeFile file('key.jks') | 16 | storeFile file('key.jks') |
17 | storePassword '123456' | 17 | storePassword '123456' |
18 | } | 18 | } |
19 | debug { | 19 | debug { |
20 | } | 20 | } |
21 | } | 21 | } |
22 | compileSdk 32 | 22 | compileSdk 32 |
23 | 23 | ||
24 | defaultConfig { | 24 | defaultConfig { |
25 | applicationId "com.hjx.parent" | 25 | applicationId "com.hjx.parent" |
26 | minSdk 24 | 26 | minSdk 24 |
27 | targetSdk 32 | 27 | targetSdk 32 |
28 | versionCode 1005 | 28 | versionCode 1005 |
29 | versionName "1.0.0.5" | 29 | versionName "1.0.0.5" |
30 | 30 | ||
31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
32 | } | 32 | } |
33 | 33 | ||
34 | android.applicationVariants.all { | 34 | android.applicationVariants.all { |
35 | variant -> | 35 | variant -> |
36 | variant.outputs.all { | 36 | variant.outputs.all { |
37 | //在这里修改apk文件名 | 37 | //在这里修改apk文件名 |
38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
39 | } | 39 | } |
40 | } | 40 | } |
41 | buildTypes { | 41 | buildTypes { |
42 | debug { | 42 | debug { |
43 | debuggable true | 43 | debuggable true |
44 | minifyEnabled false | 44 | minifyEnabled false |
45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
46 | signingConfig signingConfigs.config | 46 | signingConfig signingConfigs.config |
47 | } | 47 | } |
48 | release { | 48 | release { |
49 | debuggable true | 49 | debuggable true |
50 | minifyEnabled false | 50 | minifyEnabled false |
51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
52 | signingConfig signingConfigs.config | 52 | signingConfig signingConfigs.config |
53 | } | 53 | } |
54 | } | 54 | } |
55 | lintOptions { | 55 | lintOptions { |
56 | checkReleaseBuilds false | 56 | checkReleaseBuilds false |
57 | abortOnError false | 57 | abortOnError false |
58 | } | 58 | } |
59 | buildFeatures { | 59 | buildFeatures { |
60 | viewBinding true | 60 | viewBinding true |
61 | dataBinding true | ||
61 | } | 62 | } |
62 | compileOptions { | 63 | compileOptions { |
63 | sourceCompatibility JavaVersion.VERSION_1_8 | 64 | sourceCompatibility JavaVersion.VERSION_1_8 |
64 | targetCompatibility JavaVersion.VERSION_1_8 | 65 | targetCompatibility JavaVersion.VERSION_1_8 |
65 | } | 66 | } |
66 | } | 67 | } |
67 | 68 | ||
68 | dependencies { | 69 | dependencies { |
69 | support.each { k, v -> implementation v } | 70 | support.each { k, v -> implementation v } |
70 | api project(path: ':libs:common') | 71 | api project(path: ':libs:common') |
71 | implementation 'androidx.appcompat:appcompat:1.5.1' | 72 | implementation 'androidx.appcompat:appcompat:1.5.1' |
72 | implementation 'com.google.android.material:material:1.6.1' | 73 | implementation 'com.google.android.material:material:1.6.1' |
73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 74 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 75 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 76 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 77 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
77 | //使用的三方 | 78 | //使用的三方 |
78 | implementation 'com.yalantis:ucrop:2.2.0' | 79 | implementation 'com.yalantis:ucrop:2.2.0' |
79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 80 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 81 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
81 | 82 | ||
82 | // rx | 83 | // rx |
83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | 84 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") |
84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | 85 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") |
85 | 86 | ||
86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") | 87 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") |
87 | implementation("com.contrarywind:Android-PickerView:4.1.9") | 88 | implementation("com.contrarywind:Android-PickerView:4.1.9") |
88 | } | 89 | } |
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.AppCompat.Light.NoActionBar"> |
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:screenOrientation="portrait" |
46 | android:theme="@style/ThemeSplash"> | 46 | android:theme="@style/ThemeSplash"> |
47 | <intent-filter> | 47 | <intent-filter> |
48 | <action android:name="android.intent.action.MAIN" /> | 48 | <action android:name="android.intent.action.MAIN" /> |
49 | <category android:name="android.intent.category.LAUNCHER" /> | 49 | <category android:name="android.intent.category.LAUNCHER" /> |
50 | </intent-filter> | 50 | </intent-filter> |
51 | </activity> | 51 | </activity> |
52 | <activity | 52 | <activity |
53 | android:name=".MainActivity" | 53 | android:name=".MainActivity" |
54 | android:launchMode="singleTask" | 54 | android:launchMode="singleTask" |
55 | android:screenOrientation="portrait" | 55 | android:screenOrientation="portrait" |
56 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 56 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
57 | <activity | 57 | <activity |
58 | android:name=".RegisterActivity" | 58 | android:name=".RegisterActivity" |
59 | android:screenOrientation="portrait" | 59 | android:screenOrientation="portrait" |
60 | android:theme="@style/ThemeSplash" /> | 60 | android:theme="@style/ThemeSplash" /> |
61 | <activity | 61 | <activity |
62 | android:name=".UserActivity" | 62 | android:name=".UserActivity" |
63 | android:screenOrientation="portrait" | 63 | android:screenOrientation="portrait" |
64 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 64 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
65 | <activity | 65 | <activity |
66 | android:name=".YinsiActivity" | 66 | android:name=".YinsiActivity" |
67 | android:screenOrientation="portrait" | 67 | android:screenOrientation="portrait" |
68 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 68 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
69 | <activity | 69 | <activity |
70 | android:name=".QRActivity" | 70 | android:name=".QRActivity" |
71 | android:screenOrientation="portrait" | 71 | android:screenOrientation="portrait" |
72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
73 | <activity | 73 | <activity |
74 | android:name=".AddStudentActivity" | 74 | android:name=".AddStudentActivity" |
75 | android:screenOrientation="portrait" | 75 | android:screenOrientation="portrait" |
76 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 76 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
77 | <activity | 77 | <activity |
78 | android:name=".NickActivity" | 78 | android:name=".NickActivity" |
79 | android:screenOrientation="portrait" | 79 | android:screenOrientation="portrait" |
80 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 80 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
81 | <activity | 81 | <activity |
82 | android:name=".SexActivity" | 82 | android:name=".SexActivity" |
83 | android:screenOrientation="portrait" | 83 | android:screenOrientation="portrait" |
84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
85 | <activity | 85 | <activity |
86 | android:name=".NianActivity" | 86 | android:name=".NianActivity" |
87 | android:screenOrientation="portrait" | 87 | android:screenOrientation="portrait" |
88 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 88 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
89 | <activity | 89 | <activity |
90 | android:name=".ShenActivity" | 90 | android:name=".ShenActivity" |
91 | android:screenOrientation="portrait" | 91 | android:screenOrientation="portrait" |
92 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 92 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
93 | <activity | 93 | <activity |
94 | android:name=".UserAgreementActivity" | 94 | android:name=".UserAgreementActivity" |
95 | android:screenOrientation="portrait" | 95 | android:screenOrientation="portrait" |
96 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 96 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
97 | <activity | 97 | <activity |
98 | android:name=".AccountActivity" | 98 | android:name=".AccountActivity" |
99 | android:screenOrientation="portrait" | 99 | android:screenOrientation="portrait" |
100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
101 | 101 | ||
102 | <activity | 102 | <activity |
103 | android:name=".ChangePwdActivity" | 103 | android:name=".ChangePwdActivity" |
104 | android:screenOrientation="portrait" | 104 | android:screenOrientation="portrait" |
105 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 105 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
106 | <activity | 106 | <activity |
107 | android:name=".EditStudentActivity" | 107 | android:name=".EditStudentActivity" |
108 | android:screenOrientation="portrait" | 108 | android:screenOrientation="portrait" |
109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
110 | <activity | 110 | <activity |
111 | android:name=".ChooseActivity" | 111 | android:name=".ChooseActivity" |
112 | android:screenOrientation="portrait" | 112 | android:screenOrientation="portrait" |
113 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 113 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
114 | <activity | 114 | <activity |
115 | android:name=".AddTeacherActivity" | 115 | android:name=".AddTeacherActivity" |
116 | android:screenOrientation="portrait" | 116 | android:screenOrientation="portrait" |
117 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 117 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
118 | <activity | 118 | <activity |
119 | android:name=".ErrorBookActivity" | 119 | android:name=".ErrorBookActivity" |
120 | android:screenOrientation="portrait" | 120 | android:screenOrientation="portrait" |
121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
122 | <activity | 122 | <activity |
123 | android:name=".ImageActivity" | 123 | android:name=".ImageActivity" |
124 | android:screenOrientation="portrait" | 124 | android:screenOrientation="portrait" |
125 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 125 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
126 | <activity | 126 | <activity |
127 | android:name=".ImageEditActivity" | 127 | android:name=".ImageEditActivity" |
128 | android:screenOrientation="portrait" | 128 | android:screenOrientation="portrait" |
129 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 129 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
130 | <activity | 130 | <activity |
131 | android:name=".ImageSelectActivity" | 131 | android:name=".ImageSelectActivity" |
132 | android:screenOrientation="portrait" | 132 | android:screenOrientation="portrait" |
133 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 133 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
134 | <activity | 134 | <activity |
135 | android:name=".AddSuccessActivity" | 135 | android:name=".AddSuccessActivity" |
136 | android:screenOrientation="portrait" | 136 | android:screenOrientation="portrait" |
137 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 137 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
138 | <activity | 138 | <activity |
139 | android:name=".ErrorListActivity" | 139 | android:name=".ErrorListActivity" |
140 | android:screenOrientation="portrait" | 140 | android:screenOrientation="portrait" |
141 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 141 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
142 | <activity | 142 | <activity |
143 | android:name=".ErrorDetailActivity" | 143 | android:name=".ErrorDetailActivity" |
144 | android:screenOrientation="portrait" | 144 | android:screenOrientation="portrait" |
145 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 145 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
146 | <activity | 146 | <activity |
147 | android:name=".TeacherChooseActivity" | 147 | android:name=".TeacherChooseActivity" |
148 | android:screenOrientation="portrait" | 148 | android:screenOrientation="portrait" |
149 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 149 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
150 | <activity | 150 | <activity |
151 | android:name=".TeacherMainActivity" | 151 | android:name=".TeacherMainActivity" |
152 | android:screenOrientation="portrait" | 152 | android:screenOrientation="portrait" |
153 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 153 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
154 | <activity android:name=".StuHomeworkActivity" /> | ||
154 | 155 | ||
155 | <provider | 156 | <provider |
156 | android:name="androidx.core.content.FileProvider" | 157 | android:name="androidx.core.content.FileProvider" |
157 | android:authorities="com.hjx.parent.fileprovider" | 158 | android:authorities="com.hjx.parent.fileprovider" |
158 | android:exported="false" | 159 | android:exported="false" |
159 | android:grantUriPermissions="true" | 160 | android:grantUriPermissions="true" |
160 | tools:replace="android:authorities"> | 161 | tools:replace="android:authorities"> |
161 | <meta-data | 162 | <meta-data |
162 | android:name="android.support.FILE_PROVIDER_PATHS" | 163 | android:name="android.support.FILE_PROVIDER_PATHS" |
163 | android:resource="@xml/file_provider_paths" | 164 | android:resource="@xml/file_provider_paths" |
164 | tools:replace="android:resource" /> | 165 | tools:replace="android:resource" /> |
165 | </provider> | 166 | </provider> |
166 | </application> | 167 | </application> |
167 | 168 | ||
168 | </manifest> | 169 | </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 | private int type; | 36 | private int type; |
37 | private String stuId; | 37 | private String studentJson; |
38 | 38 | ||
39 | @Override | 39 | @Override |
40 | public void initView(Bundle savedInstanceState) { | 40 | public void initView(Bundle savedInstanceState) { |
41 | type = getIntent().getIntExtra("type", 0); | 41 | type = getIntent().getIntExtra("type", 0); |
42 | stuId = getIntent().getStringExtra("stuId"); | 42 | studentJson = getIntent().getStringExtra("studentJson"); |
43 | if (type == 1) { | 43 | if (type == 1) { |
44 | binding.tvMsg.setText("作业录入成功!"); | 44 | binding.tvMsg.setText("作业录入成功!"); |
45 | binding.tvAdd.setText("继续录入作业"); | 45 | binding.tvAdd.setText("继续录入作业"); |
46 | binding.tvBook.setText("查看作业详情"); | 46 | binding.tvBook.setText("查看作业详情"); |
47 | } | 47 | } |
48 | 48 | ||
49 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 49 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
50 | @Override | 50 | @Override |
51 | public void onClick(View v) { | 51 | public void onClick(View v) { |
52 | finish(); | 52 | finish(); |
53 | } | 53 | } |
54 | }); | 54 | }); |
55 | binding.tvAdd.setOnClickListener(new View.OnClickListener() { | 55 | binding.tvAdd.setOnClickListener(new View.OnClickListener() { |
56 | @Override | 56 | @Override |
57 | public void onClick(View v) { | 57 | public void onClick(View v) { |
58 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 58 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
59 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 59 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
60 | dialog.setContentView(bottomView); | 60 | dialog.setContentView(bottomView); |
61 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 61 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
62 | @Override | 62 | @Override |
63 | public void onClick(View view) { | 63 | public void onClick(View view) { |
64 | dialog.dismiss(); | 64 | dialog.dismiss(); |
65 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 65 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
66 | //确保有相机来处理Intent | 66 | //确保有相机来处理Intent |
67 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 67 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
68 | File photoFile = new File(filePath); | 68 | File photoFile = new File(filePath); |
69 | if (photoFile != null) { | 69 | if (photoFile != null) { |
70 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 70 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
71 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 71 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
72 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 72 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
73 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 73 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
74 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 74 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | }); | 77 | }); |
78 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 78 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
79 | @Override | 79 | @Override |
80 | public void onClick(View view) { | 80 | public void onClick(View view) { |
81 | dialog.dismiss(); | 81 | dialog.dismiss(); |
82 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 82 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
83 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 83 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
84 | .multiSelect(true) //是否多选 | 84 | .multiSelect(true) //是否多选 |
85 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 85 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
86 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 86 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
87 | .maxImageSelectable(5) //图片可选择数 | 87 | .maxImageSelectable(5) //图片可选择数 |
88 | .maxHeight(1920) //图片最大高度 | 88 | .maxHeight(1920) //图片最大高度 |
89 | .maxWidth(1920) //图片最大宽度 | 89 | .maxWidth(1920) //图片最大宽度 |
90 | .maxImageSize(3) //图片最大大小Mb | 90 | .maxImageSize(3) //图片最大大小Mb |
91 | .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(); | 91 | .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(); |
92 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(AddSuccessActivity.this); | 92 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(AddSuccessActivity.this); |
93 | 93 | ||
94 | } | 94 | } |
95 | }); | 95 | }); |
96 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 96 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
97 | @Override | 97 | @Override |
98 | public void onClick(View view) { | 98 | public void onClick(View view) { |
99 | dialog.dismiss(); | 99 | dialog.dismiss(); |
100 | } | 100 | } |
101 | }); | 101 | }); |
102 | dialog.show(); | 102 | dialog.show(); |
103 | } | 103 | } |
104 | }); | 104 | }); |
105 | binding.tvBook.setOnClickListener(new View.OnClickListener() { | 105 | binding.tvBook.setOnClickListener(new View.OnClickListener() { |
106 | @Override | 106 | @Override |
107 | public void onClick(View v) { | 107 | public void onClick(View v) { |
108 | if (type == 0) { | 108 | if (type == 0) { |
109 | startActivity(new Intent(context, ErrorListActivity.class)); | 109 | startActivity(new Intent(context, ErrorListActivity.class)); |
110 | } else { | 110 | } else { |
111 | // TODO | 111 | Intent intent = new Intent(context, StuHomeworkActivity.class); |
112 | intent.putExtra("studentJson", studentJson); | ||
113 | startActivity(intent); | ||
112 | } | 114 | } |
113 | } | 115 | } |
114 | }); | 116 | }); |
115 | } | 117 | } |
116 | 118 | ||
117 | @Override | 119 | @Override |
118 | protected ActivityAddSuccessBinding getViewBinding() { | 120 | protected ActivityAddSuccessBinding getViewBinding() { |
119 | return ActivityAddSuccessBinding.inflate(getLayoutInflater()); | 121 | return ActivityAddSuccessBinding.inflate(getLayoutInflater()); |
120 | } | 122 | } |
121 | 123 | ||
122 | @Override | 124 | @Override |
123 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 125 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
124 | super.onActivityResult(requestCode, resultCode, data); | 126 | super.onActivityResult(requestCode, resultCode, data); |
125 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 127 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
126 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 128 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
127 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 129 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
128 | CommonUtil.saveBitmapToUri(b, path); | 130 | CommonUtil.saveBitmapToUri(b, path); |
129 | List<String> strings = new ArrayList<>(); | 131 | List<String> strings = new ArrayList<>(); |
130 | Intent intent = new Intent(context, ImageActivity.class); | 132 | Intent intent = new Intent(context, ImageActivity.class); |
131 | intent.putExtra("type", type); | 133 | intent.putExtra("type", type); |
132 | strings.add(path); | 134 | strings.add(path); |
133 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 135 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
134 | startActivity(intent); | 136 | startActivity(intent); |
135 | finish(); | 137 | finish(); |
136 | } | 138 | } |
137 | } | 139 | } |
138 | 140 | ||
139 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 141 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
140 | private String TAG = "---ImagePicker---"; | 142 | private String TAG = "---ImagePicker---"; |
141 | List<ImageInfo> photoList = new ArrayList<>(); | 143 | List<ImageInfo> photoList = new ArrayList<>(); |
142 | 144 | ||
143 | @Override | 145 | @Override |
144 | public void onStart() { | 146 | public void onStart() { |
145 | Log.i(TAG, "onStart: 开启"); | 147 | Log.i(TAG, "onStart: 开启"); |
146 | } | 148 | } |
147 | 149 | ||
148 | @Override | 150 | @Override |
149 | public void onSuccess(List<ImageInfo> photoList) { | 151 | public void onSuccess(List<ImageInfo> photoList) { |
150 | this.photoList = photoList; | 152 | this.photoList = photoList; |
151 | Log.i(TAG, "onSuccess: 返回数据"); | 153 | Log.i(TAG, "onSuccess: 返回数据"); |
152 | } | 154 | } |
153 | 155 | ||
154 | @Override | 156 | @Override |
155 | public void onCancel() { | 157 | public void onCancel() { |
156 | Log.i(TAG, "onCancel: 取消"); | 158 | Log.i(TAG, "onCancel: 取消"); |
157 | } | 159 | } |
158 | 160 | ||
159 | @Override | 161 | @Override |
160 | public void onFinish(List<ImageInfo> selectImage) { | 162 | public void onFinish(List<ImageInfo> selectImage) { |
161 | if (selectImage.size() == photoList.size()) { | 163 | if (selectImage.size() == photoList.size()) { |
162 | List<String> strings = new ArrayList<>(); | 164 | List<String> strings = new ArrayList<>(); |
163 | Intent intent = new Intent(context, ImageActivity.class); | 165 | Intent intent = new Intent(context, ImageActivity.class); |
164 | intent.putExtra("type", type); | 166 | intent.putExtra("type", type); |
165 | for (ImageInfo imageInfo : selectImage) { | 167 | for (ImageInfo imageInfo : selectImage) { |
166 | strings.add(imageInfo.getPath()); | 168 | strings.add(imageInfo.getPath()); |
167 | } | 169 | } |
168 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 170 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
169 | startActivity(intent); | 171 | startActivity(intent); |
170 | finish(); | 172 | finish(); |
171 | } | 173 | } |
172 | } | 174 | } |
173 | 175 | ||
174 | @Override | 176 | @Override |
175 | public void onError() { | 177 | public void onError() { |
176 | Log.i(TAG, "onError: 出错"); | 178 | Log.i(TAG, "onError: 出错"); |
177 | } | 179 | } |
178 | } | 180 | } |
179 | } | 181 | } |
180 | 182 |
app/src/main/java/com/hjx/parent/ImageActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.app.Dialog; | 4 | import android.app.Dialog; |
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.Rect; | 8 | import android.graphics.Rect; |
9 | import android.net.Uri; | 9 | import android.net.Uri; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.os.Handler; | 11 | import android.os.Handler; |
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.View; | 16 | import android.view.View; |
17 | 17 | ||
18 | 18 | ||
19 | import androidx.annotation.Nullable; | 19 | import androidx.annotation.Nullable; |
20 | import androidx.core.content.FileProvider; | 20 | import androidx.core.content.FileProvider; |
21 | import androidx.viewpager2.widget.ViewPager2; | 21 | import androidx.viewpager2.widget.ViewPager2; |
22 | 22 | ||
23 | import com.google.gson.Gson; | 23 | import com.google.gson.Gson; |
24 | import com.google.gson.JsonObject; | 24 | import com.google.gson.JsonObject; |
25 | import com.hjx.parent.adapter.ImageAdapter; | 25 | import com.hjx.parent.adapter.ImageAdapter; |
26 | import com.hjx.parent.databinding.ActivityImageBinding; | 26 | import com.hjx.parent.databinding.ActivityImageBinding; |
27 | import com.hjx.parent.dialog.AddHomeworkDialog; | 27 | import com.hjx.parent.dialog.AddHomeworkDialog; |
28 | import com.hjx.parent.dialog.ErrorInputDialog; | 28 | import com.hjx.parent.dialog.ErrorInputDialog; |
29 | import com.hjx.parent.dialog.TipDialog; | 29 | import com.hjx.parent.dialog.TipDialog; |
30 | import com.hjx.parent.rx.BaseRxActivity; | 30 | import com.hjx.parent.rx.BaseRxActivity; |
31 | import com.prws.common.bean.CutPicBean; | 31 | import com.prws.common.bean.CutPicBean; |
32 | import com.prws.common.bean.ImageBean; | 32 | import com.prws.common.bean.ImageBean; |
33 | import com.prws.common.bean.TopicBean; | 33 | import com.prws.common.bean.TopicBean; |
34 | import com.prws.common.net.NetWorks; | 34 | import com.prws.common.net.NetWorks; |
35 | import com.prws.common.utils.BitmapUtils; | 35 | import com.prws.common.utils.BitmapUtils; |
36 | import com.prws.common.utils.CommonUtil; | 36 | import com.prws.common.utils.CommonUtil; |
37 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; | 37 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; |
38 | 38 | ||
39 | import java.io.File; | 39 | import java.io.File; |
40 | import java.util.ArrayList; | 40 | import java.util.ArrayList; |
41 | import java.util.List; | 41 | import java.util.List; |
42 | 42 | ||
43 | import io.reactivex.Observer; | 43 | import io.reactivex.Observer; |
44 | import io.reactivex.disposables.Disposable; | 44 | import io.reactivex.disposables.Disposable; |
45 | import retrofit2.Call; | 45 | import retrofit2.Call; |
46 | import retrofit2.Callback; | 46 | import retrofit2.Callback; |
47 | import retrofit2.Response; | 47 | import retrofit2.Response; |
48 | 48 | ||
49 | public class ImageActivity extends BaseRxActivity<ActivityImageBinding> implements View.OnClickListener { | 49 | public class ImageActivity extends BaseRxActivity<ActivityImageBinding> implements View.OnClickListener { |
50 | 50 | ||
51 | private List<String> images = new ArrayList<>(); | 51 | private List<String> images = new ArrayList<>(); |
52 | private ImageAdapter imageAdapter; | 52 | private ImageAdapter imageAdapter; |
53 | private List<ImageBean> list = new ArrayList<>(); | 53 | private List<ImageBean> list = new ArrayList<>(); |
54 | private String filePath; | 54 | private String filePath; |
55 | 55 | ||
56 | private int type = 0; | 56 | private int type = 0; |
57 | private AddHomeworkDialog addHomeworkDialog; | 57 | private AddHomeworkDialog addHomeworkDialog; |
58 | 58 | ||
59 | @Override | 59 | @Override |
60 | public void initView(Bundle savedInstanceState) { | 60 | public void initView(Bundle savedInstanceState) { |
61 | type = getIntent().getIntExtra("type", 0); | 61 | type = getIntent().getIntExtra("type", 0); |
62 | binding.tvSave.setText(type == 0 ? "保存错题" : "录入题目"); | 62 | binding.tvSave.setText(type == 0 ? "保存错题" : "录入题目"); |
63 | 63 | ||
64 | images = getIntent().getStringArrayListExtra("images"); | 64 | images = getIntent().getStringArrayListExtra("images"); |
65 | for (String s : images) { | 65 | for (String s : images) { |
66 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 66 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
67 | ImageBean imageBean = new ImageBean(); | 67 | ImageBean imageBean = new ImageBean(); |
68 | Bitmap bitmap = BitmapUtils.getimage(s); | 68 | Bitmap bitmap = BitmapUtils.getimage(s); |
69 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 69 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
70 | imageBean.setPath(filepath); | 70 | imageBean.setPath(filepath); |
71 | list.add(imageBean); | 71 | list.add(imageBean); |
72 | } | 72 | } |
73 | imageAdapter = new ImageAdapter(this, list); | 73 | imageAdapter = new ImageAdapter(this, list); |
74 | binding.viewPager.setAdapter(imageAdapter); | 74 | binding.viewPager.setAdapter(imageAdapter); |
75 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 75 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
76 | @Override | 76 | @Override |
77 | public void onPageSelected(int position) { | 77 | public void onPageSelected(int position) { |
78 | if (list.get(position).getCuts() == null) { | 78 | if (list.get(position).getCuts() == null) { |
79 | // binding.ivPrevious.setEnabled(false); | 79 | // binding.ivPrevious.setEnabled(false); |
80 | // binding.ivNext.setEnabled(false); | 80 | // binding.ivNext.setEnabled(false); |
81 | clearText(); | 81 | clearText(); |
82 | } | 82 | } |
83 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 83 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
84 | if (position == 0) { | 84 | if (position == 0) { |
85 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); | 85 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); |
86 | // binding.ivPrevious.setEnabled(true); | 86 | // binding.ivPrevious.setEnabled(true); |
87 | } else { | 87 | } else { |
88 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); | 88 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); |
89 | // binding.ivPrevious.setEnabled(false); | 89 | // binding.ivPrevious.setEnabled(false); |
90 | } | 90 | } |
91 | if (position == list.size() - 1) { | 91 | if (position == list.size() - 1) { |
92 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); | 92 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); |
93 | // binding.ivNext.setEnabled(true); | 93 | // binding.ivNext.setEnabled(true); |
94 | } else { | 94 | } else { |
95 | binding.ivNext.setImageResource(R.mipmap.ic_next); | 95 | binding.ivNext.setImageResource(R.mipmap.ic_next); |
96 | // binding.ivNext.setEnabled(false); | 96 | // binding.ivNext.setEnabled(false); |
97 | } | 97 | } |
98 | super.onPageSelected(position); | 98 | super.onPageSelected(position); |
99 | } | 99 | } |
100 | }); | 100 | }); |
101 | binding.ivNext.setOnClickListener(this); | 101 | binding.ivNext.setOnClickListener(this); |
102 | binding.ivPrevious.setOnClickListener(this); | 102 | binding.ivPrevious.setOnClickListener(this); |
103 | binding.ivBack.setOnClickListener(this); | 103 | binding.ivBack.setOnClickListener(this); |
104 | binding.tvPhoto.setOnClickListener(this); | 104 | binding.tvPhoto.setOnClickListener(this); |
105 | binding.tvAdd.setOnClickListener(this); | 105 | binding.tvAdd.setOnClickListener(this); |
106 | binding.llEdit.setOnClickListener(this); | 106 | binding.llEdit.setOnClickListener(this); |
107 | binding.tvSave.setOnClickListener(this); | 107 | binding.tvSave.setOnClickListener(this); |
108 | } | 108 | } |
109 | 109 | ||
110 | public void clearText() { | 110 | public void clearText() { |
111 | int index = binding.viewPager.getCurrentItem(); | 111 | int index = binding.viewPager.getCurrentItem(); |
112 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { | 112 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { |
113 | @Override | 113 | @Override |
114 | public void dimiss() { | 114 | public void dimiss() { |
115 | // binding.ivPrevious.setEnabled(index != 0); | 115 | // binding.ivPrevious.setEnabled(index != 0); |
116 | // binding.ivNext.setEnabled(index != list.size() - 1); | 116 | // binding.ivNext.setEnabled(index != list.size() - 1); |
117 | } | 117 | } |
118 | }); | 118 | }); |
119 | Log.i("clearText", list.get(index).getPath()); | 119 | Log.i("clearText", list.get(index).getPath()); |
120 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); | 120 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); |
121 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { | 121 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { |
122 | @Override | 122 | @Override |
123 | public void onSubscribe(Disposable d) { | 123 | public void onSubscribe(Disposable d) { |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | @Override | 127 | @Override |
128 | public void onNext(JsonObject jsonObject) { | 128 | public void onNext(JsonObject jsonObject) { |
129 | if (jsonObject != null && jsonObject.get("image_processed") != null) { | 129 | if (jsonObject != null && jsonObject.get("image_processed") != null) { |
130 | String image = jsonObject.get("image_processed").getAsString(); | 130 | String image = jsonObject.get("image_processed").getAsString(); |
131 | if (image != null) { | 131 | if (image != null) { |
132 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 132 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
133 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); | 133 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); |
134 | list.get(index).setPath(filepath); | 134 | list.get(index).setPath(filepath); |
135 | imageAdapter.notifyItemChanged(index); | 135 | imageAdapter.notifyItemChanged(index); |
136 | cut(filepath); | 136 | cut(filepath); |
137 | } else { | 137 | } else { |
138 | loadFail("去除字迹失败"); | 138 | loadFail("去除字迹失败"); |
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | loadFail("去除字迹失败"); | 141 | loadFail("去除字迹失败"); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | @Override | 145 | @Override |
146 | public void onError(Throwable e) { | 146 | public void onError(Throwable e) { |
147 | loadFail("去除字迹失败"); | 147 | loadFail("去除字迹失败"); |
148 | } | 148 | } |
149 | 149 | ||
150 | @Override | 150 | @Override |
151 | public void onComplete() { | 151 | public void onComplete() { |
152 | 152 | ||
153 | } | 153 | } |
154 | }); | 154 | }); |
155 | } | 155 | } |
156 | 156 | ||
157 | public void cut(String path) { | 157 | public void cut(String path) { |
158 | String base64 = BitmapUtils.imageToBase64(path); | 158 | String base64 = BitmapUtils.imageToBase64(path); |
159 | Log.i("figLoaction", path); | 159 | Log.i("figLoaction", path); |
160 | NetWorks.cut(base64, new Observer<CutPicBean>() { | 160 | NetWorks.cut(base64, new Observer<CutPicBean>() { |
161 | @Override | 161 | @Override |
162 | public void onSubscribe(Disposable d) { | 162 | public void onSubscribe(Disposable d) { |
163 | 163 | ||
164 | } | 164 | } |
165 | 165 | ||
166 | @Override | 166 | @Override |
167 | public void onNext(CutPicBean cutPicBean) { | 167 | public void onNext(CutPicBean cutPicBean) { |
168 | if (cutPicBean != null) { | 168 | if (cutPicBean != null) { |
169 | if (cutPicBean.getDirection() != 0) { | 169 | if (cutPicBean.getDirection() != 0) { |
170 | rotatingImage(cutPicBean); | 170 | rotatingImage(cutPicBean); |
171 | } else { | 171 | } else { |
172 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 172 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
173 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 173 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
174 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 174 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
175 | figLoactions.add(cutLocation.getFig_location()); | 175 | figLoactions.add(cutLocation.getFig_location()); |
176 | } | 176 | } |
177 | new Handler().postDelayed(new Runnable() { | 177 | new Handler().postDelayed(new Runnable() { |
178 | @Override | 178 | @Override |
179 | public void run() { | 179 | public void run() { |
180 | getRects(figLoactions); | 180 | getRects(figLoactions); |
181 | } | 181 | } |
182 | }, 1000); | 182 | }, 1000); |
183 | } else { | 183 | } else { |
184 | cancelLoadingDialog(); | 184 | cancelLoadingDialog(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | } else { | 187 | } else { |
188 | loadFail("自动切题失败"); | 188 | loadFail("自动切题失败"); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | @Override | 192 | @Override |
193 | public void onError(Throwable e) { | 193 | public void onError(Throwable e) { |
194 | loadFail("自动切题失败"); | 194 | loadFail("自动切题失败"); |
195 | } | 195 | } |
196 | 196 | ||
197 | @Override | 197 | @Override |
198 | public void onComplete() { | 198 | public void onComplete() { |
199 | 199 | ||
200 | } | 200 | } |
201 | }); | 201 | }); |
202 | } | 202 | } |
203 | 203 | ||
204 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { | 204 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { |
205 | Log.i("figLoaction", new Gson().toJson(figLoactions)); | 205 | Log.i("figLoaction", new Gson().toJson(figLoactions)); |
206 | int index = binding.viewPager.getCurrentItem(); | 206 | int index = binding.viewPager.getCurrentItem(); |
207 | List<ImageBean.Cut> cuts = new ArrayList<>(); | 207 | List<ImageBean.Cut> cuts = new ArrayList<>(); |
208 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { | 208 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { |
209 | ImageBean.Cut cut = new ImageBean.Cut(); | 209 | ImageBean.Cut cut = new ImageBean.Cut(); |
210 | cut.setRect(figLoaction); | 210 | cut.setRect(figLoaction); |
211 | cut.setSelect(false); | 211 | cut.setSelect(false); |
212 | cuts.add(cut); | 212 | cuts.add(cut); |
213 | } | 213 | } |
214 | list.get(index).setCuts(cuts); | 214 | list.get(index).setCuts(cuts); |
215 | imageAdapter.notifyItemChanged(index); | 215 | imageAdapter.notifyItemChanged(index); |
216 | cancelLoadingDialog(); | 216 | cancelLoadingDialog(); |
217 | } | 217 | } |
218 | 218 | ||
219 | private void rotatingImage(CutPicBean cutPicBean) { | 219 | private void rotatingImage(CutPicBean cutPicBean) { |
220 | int index = binding.viewPager.getCurrentItem(); | 220 | int index = binding.viewPager.getCurrentItem(); |
221 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); | 221 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); |
222 | int angle = 0; | 222 | int angle = 0; |
223 | switch (cutPicBean.getDirection()) { | 223 | switch (cutPicBean.getDirection()) { |
224 | case 1: | 224 | case 1: |
225 | angle = 90; | 225 | angle = 90; |
226 | break; | 226 | break; |
227 | case 2: | 227 | case 2: |
228 | angle = 180; | 228 | angle = 180; |
229 | break; | 229 | break; |
230 | case 3: | 230 | case 3: |
231 | angle = 270; | 231 | angle = 270; |
232 | break; | 232 | break; |
233 | } | 233 | } |
234 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 234 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
235 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 235 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
236 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 236 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
237 | figLoactions.add(cutLocation.getFig_location()); | 237 | figLoactions.add(cutLocation.getFig_location()); |
238 | } | 238 | } |
239 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); | 239 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); |
240 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); | 240 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); |
241 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 241 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
242 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 242 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
243 | list.get(index).setPath(filepath); | 243 | list.get(index).setPath(filepath); |
244 | imageAdapter.notifyItemChanged(index); | 244 | imageAdapter.notifyItemChanged(index); |
245 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; | 245 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; |
246 | new Handler().postDelayed(new Runnable() { | 246 | new Handler().postDelayed(new Runnable() { |
247 | @Override | 247 | @Override |
248 | public void run() { | 248 | public void run() { |
249 | getRects(finalFigLoactions); | 249 | getRects(finalFigLoactions); |
250 | } | 250 | } |
251 | }, 500); | 251 | }, 500); |
252 | } else { | 252 | } else { |
253 | cancelLoadingDialog(); | 253 | cancelLoadingDialog(); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | @Override | 257 | @Override |
258 | protected ActivityImageBinding getViewBinding() { | 258 | protected ActivityImageBinding getViewBinding() { |
259 | return ActivityImageBinding.inflate(getLayoutInflater()); | 259 | return ActivityImageBinding.inflate(getLayoutInflater()); |
260 | } | 260 | } |
261 | 261 | ||
262 | @SuppressLint("SetTextI18n") | 262 | @SuppressLint("SetTextI18n") |
263 | public void refreshNum() { | 263 | public void refreshNum() { |
264 | int num = 0; | 264 | int num = 0; |
265 | for (ImageBean imageBean : list) { | 265 | for (ImageBean imageBean : list) { |
266 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 266 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
267 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 267 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
268 | if (cut.isSelect()) { | 268 | if (cut.isSelect()) { |
269 | num++; | 269 | num++; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | } | 272 | } |
273 | } | 273 | } |
274 | String btnText = type == 0 ? "保存错题" : "录入题目"; | 274 | String btnText = type == 0 ? "保存错题" : "录入题目"; |
275 | if (num > 0) { | 275 | if (num > 0) { |
276 | binding.tvSave.setEnabled(true); | 276 | binding.tvSave.setEnabled(true); |
277 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); | 277 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); |
278 | binding.tvSave.setText(btnText + "(" + num + ")"); | 278 | binding.tvSave.setText(btnText + "(" + num + ")"); |
279 | } else { | 279 | } else { |
280 | binding.tvSave.setEnabled(false); | 280 | binding.tvSave.setEnabled(false); |
281 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); | 281 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); |
282 | binding.tvSave.setText(btnText); | 282 | binding.tvSave.setText(btnText); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | @Override | 286 | @Override |
287 | public void onClick(View v) { | 287 | public void onClick(View v) { |
288 | switch (v.getId()) { | 288 | switch (v.getId()) { |
289 | case R.id.iv_back: | 289 | case R.id.iv_back: |
290 | back(); | 290 | back(); |
291 | break; | 291 | break; |
292 | case R.id.iv_next: | 292 | case R.id.iv_next: |
293 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { | 293 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { |
294 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); | 294 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); |
295 | } | 295 | } |
296 | break; | 296 | break; |
297 | case R.id.iv_previous: | 297 | case R.id.iv_previous: |
298 | if (binding.viewPager.getCurrentItem() != 0) { | 298 | if (binding.viewPager.getCurrentItem() != 0) { |
299 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); | 299 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); |
300 | } | 300 | } |
301 | break; | 301 | break; |
302 | case R.id.ll_edit: | 302 | case R.id.ll_edit: |
303 | Intent intent = new Intent(context, ImageEditActivity.class); | 303 | Intent intent = new Intent(context, ImageEditActivity.class); |
304 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 304 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
305 | startActivityForResult(intent, 1001); | 305 | startActivityForResult(intent, 1001); |
306 | break; | 306 | break; |
307 | case R.id.tv_photo: | 307 | case R.id.tv_photo: |
308 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 308 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
309 | //确保有相机来处理Intent | 309 | //确保有相机来处理Intent |
310 | 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"; |
311 | File photoFile = new File(filePath); | 311 | File photoFile = new File(filePath); |
312 | if (photoFile != null) { | 312 | if (photoFile != null) { |
313 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 313 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
314 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 314 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
315 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 315 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
316 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 316 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
317 | activity.startActivityForResult(takePictureIntent, 1002); | 317 | activity.startActivityForResult(takePictureIntent, 1002); |
318 | } | 318 | } |
319 | break; | 319 | break; |
320 | case R.id.tv_add: | 320 | case R.id.tv_add: |
321 | Intent intent1 = new Intent(context, ImageSelectActivity.class); | 321 | Intent intent1 = new Intent(context, ImageSelectActivity.class); |
322 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 322 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
323 | startActivityForResult(intent1, 1001); | 323 | startActivityForResult(intent1, 1001); |
324 | break; | 324 | break; |
325 | case R.id.tv_save: | 325 | case R.id.tv_save: |
326 | List<TopicBean> topicBeans = new ArrayList<>(); | 326 | List<TopicBean> topicBeans = new ArrayList<>(); |
327 | for (ImageBean imageBean : list) { | 327 | for (ImageBean imageBean : list) { |
328 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 328 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
329 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 329 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
330 | if (cut.isSelect()) { | 330 | if (cut.isSelect()) { |
331 | TopicBean bean = new TopicBean(); | 331 | TopicBean bean = new TopicBean(); |
332 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 332 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
333 | BitmapUtils.saveBitmap(cut.getBitmap(), path); | 333 | BitmapUtils.saveBitmap(cut.getBitmap(), path); |
334 | bean.setPath(path); | 334 | bean.setPath(path); |
335 | topicBeans.add(bean); | 335 | topicBeans.add(bean); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | } | 339 | } |
340 | save(topicBeans); | 340 | save(topicBeans); |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | private void save(List<TopicBean> topicBeans) { | 345 | private void save(List<TopicBean> topicBeans) { |
346 | if (type == 0) { | 346 | if (type == 0) { |
347 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); | 347 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); |
348 | dialog.show(); | 348 | dialog.show(); |
349 | } else { | 349 | } else { |
350 | List<String> paths = new ArrayList<>(); | 350 | List<String> paths = new ArrayList<>(); |
351 | for (TopicBean it: topicBeans) { | 351 | for (TopicBean it: topicBeans) { |
352 | paths.add(it.getPath()); | 352 | paths.add(it.getPath()); |
353 | } | 353 | } |
354 | if (addHomeworkDialog == null) { | 354 | if (addHomeworkDialog == null) { |
355 | addHomeworkDialog = new AddHomeworkDialog(this); | 355 | addHomeworkDialog = new AddHomeworkDialog(this); |
356 | } | 356 | } |
357 | addHomeworkDialog.show(paths, student -> { | 357 | addHomeworkDialog.show(paths, student -> { |
358 | Intent intent = new Intent(context, AddSuccessActivity.class); | 358 | Intent intent = new Intent(context, AddSuccessActivity.class); |
359 | intent.putExtra("type", type); | 359 | intent.putExtra("type", type); |
360 | intent.putExtra("stuId", student.stuId); | 360 | intent.putExtra("studentJson", new Gson().toJson(student)); |
361 | startActivity(intent); | 361 | startActivity(intent); |
362 | finish(); | 362 | finish(); |
363 | }); | 363 | }); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | @Override | 367 | @Override |
368 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 368 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
369 | super.onActivityResult(requestCode, resultCode, data); | 369 | super.onActivityResult(requestCode, resultCode, data); |
370 | if (requestCode == 1001) { | 370 | if (requestCode == 1001) { |
371 | if (resultCode == 1002) { | 371 | if (resultCode == 1002) { |
372 | if (list.size() > 1) { | 372 | if (list.size() > 1) { |
373 | list.remove(binding.viewPager.getCurrentItem()); | 373 | list.remove(binding.viewPager.getCurrentItem()); |
374 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); | 374 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); |
375 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 375 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
376 | refreshNum(); | 376 | refreshNum(); |
377 | } else { | 377 | } else { |
378 | finish(); | 378 | finish(); |
379 | } | 379 | } |
380 | } else if (resultCode == 1003) { | 380 | } else if (resultCode == 1003) { |
381 | int position = binding.viewPager.getCurrentItem(); | 381 | int position = binding.viewPager.getCurrentItem(); |
382 | list.remove(position); | 382 | list.remove(position); |
383 | String path = data.getStringExtra("path"); | 383 | String path = data.getStringExtra("path"); |
384 | ImageBean imageBean = new ImageBean(); | 384 | ImageBean imageBean = new ImageBean(); |
385 | imageBean.setPath(path); | 385 | imageBean.setPath(path); |
386 | list.add(position, imageBean); | 386 | list.add(position, imageBean); |
387 | imageAdapter.notifyItemChanged(position); | 387 | imageAdapter.notifyItemChanged(position); |
388 | clearText(); | 388 | clearText(); |
389 | refreshNum(); | 389 | refreshNum(); |
390 | } else if (resultCode == 1004) { | 390 | } else if (resultCode == 1004) { |
391 | Rect rect = data.getParcelableExtra("cut"); | 391 | Rect rect = data.getParcelableExtra("cut"); |
392 | if (rect != null) { | 392 | if (rect != null) { |
393 | int position = binding.viewPager.getCurrentItem(); | 393 | int position = binding.viewPager.getCurrentItem(); |
394 | ImageBean.Cut cut = new ImageBean.Cut(); | 394 | ImageBean.Cut cut = new ImageBean.Cut(); |
395 | cut.setRect1(rect); | 395 | cut.setRect1(rect); |
396 | cut.setSelect(false); | 396 | cut.setSelect(false); |
397 | if (list.get(position).getCuts() != null) { | 397 | if (list.get(position).getCuts() != null) { |
398 | list.get(position).getCuts().add(cut); | 398 | list.get(position).getCuts().add(cut); |
399 | } else { | 399 | } else { |
400 | List<ImageBean.Cut> cuts =new ArrayList<>(); | 400 | List<ImageBean.Cut> cuts =new ArrayList<>(); |
401 | cuts.add(cut); | 401 | cuts.add(cut); |
402 | list.get(position).setCuts(cuts); | 402 | list.get(position).setCuts(cuts); |
403 | } | 403 | } |
404 | imageAdapter.notifyItemChanged(position); | 404 | imageAdapter.notifyItemChanged(position); |
405 | refreshNum(); | 405 | refreshNum(); |
406 | } | 406 | } |
407 | } else if (resultCode == 1005) { | 407 | } else if (resultCode == 1005) { |
408 | int i = data.getIntExtra("position", 0); | 408 | int i = data.getIntExtra("position", 0); |
409 | int position = binding.viewPager.getCurrentItem(); | 409 | int position = binding.viewPager.getCurrentItem(); |
410 | Rect rect = data.getParcelableExtra("cut"); | 410 | Rect rect = data.getParcelableExtra("cut"); |
411 | if (rect != null) { | 411 | if (rect != null) { |
412 | ImageBean.Cut cut = new ImageBean.Cut(); | 412 | ImageBean.Cut cut = new ImageBean.Cut(); |
413 | cut.setRect1(rect); | 413 | cut.setRect1(rect); |
414 | cut.setSelect(false); | 414 | cut.setSelect(false); |
415 | list.get(position).getCuts().remove(i); | 415 | list.get(position).getCuts().remove(i); |
416 | list.get(position).getCuts().add(i, cut); | 416 | list.get(position).getCuts().add(i, cut); |
417 | imageAdapter.notifyItemChanged(position); | 417 | imageAdapter.notifyItemChanged(position); |
418 | refreshNum(); | 418 | refreshNum(); |
419 | } else { | 419 | } else { |
420 | list.get(position).getCuts().remove(i); | 420 | list.get(position).getCuts().remove(i); |
421 | imageAdapter.notifyItemChanged(position); | 421 | imageAdapter.notifyItemChanged(position); |
422 | refreshNum(); | 422 | refreshNum(); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 425 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
426 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 426 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
427 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 427 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
428 | CommonUtil.saveBitmapToUri(b, path); | 428 | CommonUtil.saveBitmapToUri(b, path); |
429 | int position = binding.viewPager.getCurrentItem(); | 429 | int position = binding.viewPager.getCurrentItem(); |
430 | list.remove(position); | 430 | list.remove(position); |
431 | ImageBean imageBean = new ImageBean(); | 431 | ImageBean imageBean = new ImageBean(); |
432 | imageBean.setPath(path); | 432 | imageBean.setPath(path); |
433 | list.add(position, imageBean); | 433 | list.add(position, imageBean); |
434 | imageAdapter.notifyItemChanged(position); | 434 | imageAdapter.notifyItemChanged(position); |
435 | clearText(); | 435 | clearText(); |
436 | refreshNum(); | 436 | refreshNum(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | private void back() { | 440 | private void back() { |
441 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { | 441 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { |
442 | @Override | 442 | @Override |
443 | public void onConfirm(Dialog dialog) { | 443 | public void onConfirm(Dialog dialog) { |
444 | dialog.dismiss(); | 444 | dialog.dismiss(); |
445 | finish(); | 445 | finish(); |
446 | } | 446 | } |
447 | 447 | ||
448 | @Override | 448 | @Override |
449 | public void onCancel(Dialog dialog) { | 449 | public void onCancel(Dialog dialog) { |
450 | dialog.dismiss(); | 450 | dialog.dismiss(); |
451 | } | 451 | } |
452 | }); | 452 | }); |
453 | } | 453 | } |
454 | 454 | ||
455 | @Override | 455 | @Override |
456 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 456 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
457 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 457 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
458 | back(); | 458 | back(); |
459 | return true; | 459 | return true; |
460 | } | 460 | } |
461 | return super.onKeyDown(keyCode, event); | 461 | return super.onKeyDown(keyCode, event); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | 464 |
app/src/main/java/com/hjx/parent/StuHomeworkActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.os.Bundle; | ||
5 | import android.widget.LinearLayout; | ||
6 | import android.widget.PopupWindow; | ||
7 | |||
8 | import androidx.lifecycle.MutableLiveData; | ||
9 | |||
10 | import com.google.gson.Gson; | ||
11 | import com.hjx.parent.adapter.HomeworkAdapter; | ||
12 | import com.hjx.parent.databinding.ActivityStudentHomeworkBinding; | ||
13 | import com.hjx.parent.databinding.PopupFilterFeedbackBinding; | ||
14 | import com.hjx.parent.databinding.PopupFilterGradeBinding; | ||
15 | import com.hjx.parent.databinding.PopupFilterSubjectBinding; | ||
16 | import com.hjx.parent.databinding.PopupFilterTermBinding; | ||
17 | import com.hjx.parent.rx.BaseRxActivity; | ||
18 | import com.prws.common.bean.Student; | ||
19 | import com.prws.common.net.NetWorks; | ||
20 | import com.prws.common.utils.SharedPreferencesUtil; | ||
21 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | ||
22 | |||
23 | import java.util.Collections; | ||
24 | |||
25 | import io.reactivex.Observable; | ||
26 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
27 | import io.reactivex.schedulers.Schedulers; | ||
28 | |||
29 | public class StuHomeworkActivity extends BaseRxActivity<ActivityStudentHomeworkBinding> { | ||
30 | |||
31 | private final HomeworkAdapter homeworkAdapter = new HomeworkAdapter(); | ||
32 | |||
33 | PopupWindow subjectFilter, gradeFilter, termFilter, feedbackFilter; | ||
34 | State state = new State(); | ||
35 | |||
36 | private void handlerIntent() { | ||
37 | String json = getIntent().getStringExtra("studentJson"); | ||
38 | if (json == null) json = (String) SharedPreferencesUtil.getData("student", ""); | ||
39 | try { state.student = new Gson().fromJson(json, Student.class); } | ||
40 | catch (Throwable t) { t.printStackTrace(); } | ||
41 | } | ||
42 | |||
43 | @SuppressLint("SetTextI18n") | ||
44 | @Override | ||
45 | public void initView(Bundle savedInstanceState) { | ||
46 | handlerIntent(); | ||
47 | if (state.student == null) { | ||
48 | finish(); | ||
49 | return; | ||
50 | } | ||
51 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | ||
52 | binding.tvTitle.setText(state.student.stuName + "的全部作业"); | ||
53 | |||
54 | binding.recyclerView.setAdapter(homeworkAdapter); | ||
55 | getHomework(); | ||
56 | |||
57 | binding.ftSubject.setOnClickListener(v -> showSubjectFilter()); | ||
58 | binding.ftGrade.setOnClickListener(v -> showGradeFilter()); | ||
59 | binding.ftTerm.setOnClickListener(v -> showTermFilter()); | ||
60 | binding.ftFeedback.setOnClickListener(v -> showFeedbackFilter()); | ||
61 | } | ||
62 | |||
63 | |||
64 | @SuppressLint("CheckResult") | ||
65 | protected void getHomework() { | ||
66 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), state.student.stuId) | ||
67 | .subscribeOn(Schedulers.io()) | ||
68 | .observeOn(AndroidSchedulers.mainThread()) | ||
69 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | ||
70 | .toObservable() | ||
71 | .flatMap(response -> Observable.fromIterable(response.getData())) | ||
72 | // 过滤 | ||
73 | .filter(data -> { // 学科 | ||
74 | String subject = state.subject.getValue(); | ||
75 | if (subject == null || subject.isEmpty()) return true; | ||
76 | else return subject.equals(data.getSubject()); | ||
77 | }) | ||
78 | .filter(data -> { // 年级 | ||
79 | String grade = state.grade.getValue(); | ||
80 | if (grade == null || grade.isEmpty()) return true; | ||
81 | else return grade.equals(data.getGrade()); | ||
82 | }) | ||
83 | .filter(data -> { // 学期 | ||
84 | String term = state.term.getValue(); | ||
85 | if (term == null || term.isEmpty()) return true; | ||
86 | else return term.equals(data.getTerm()); | ||
87 | }) | ||
88 | .filter(data -> { // 反馈 | ||
89 | Integer feedback = state.feedback.getValue(); | ||
90 | if (feedback == null || feedback == 0) return true; | ||
91 | else return (feedback == 1 && data.getRight() != null) || (feedback == 2 && data.getRight() == null); | ||
92 | }) | ||
93 | // 过滤完成, 收集 | ||
94 | .toList() | ||
95 | .subscribe((data, th) -> { | ||
96 | if (th != null) th.printStackTrace(); | ||
97 | Collections.sort(data); | ||
98 | homeworkAdapter.setNewData(data); | ||
99 | }); | ||
100 | } | ||
101 | |||
102 | private void showSubjectFilter() { | ||
103 | if (subjectFilter == null) { | ||
104 | PopupFilterSubjectBinding db = PopupFilterSubjectBinding.inflate(getLayoutInflater()); | ||
105 | db.setLifecycleOwner(this); | ||
106 | db.setState(state); | ||
107 | db.bg.setOnClickListener(v -> subjectFilter.dismiss()); | ||
108 | subjectFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | ||
109 | subjectFilter.setOutsideTouchable(true); | ||
110 | subjectFilter.setOnDismissListener(this::getHomework); | ||
111 | } | ||
112 | subjectFilter.showAsDropDown(binding.anchorView); | ||
113 | } | ||
114 | |||
115 | private void showGradeFilter() { | ||
116 | if (gradeFilter == null) { | ||
117 | PopupFilterGradeBinding db = PopupFilterGradeBinding.inflate(getLayoutInflater()); | ||
118 | db.setLifecycleOwner(this); | ||
119 | db.setState(state); | ||
120 | db.bg.setOnClickListener(v -> gradeFilter.dismiss()); | ||
121 | gradeFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | ||
122 | gradeFilter.setOutsideTouchable(true); | ||
123 | gradeFilter.setOnDismissListener(this::getHomework); | ||
124 | } | ||
125 | gradeFilter.showAsDropDown(binding.anchorView); | ||
126 | } | ||
127 | |||
128 | private void showTermFilter() { | ||
129 | if (termFilter == null) { | ||
130 | PopupFilterTermBinding db = PopupFilterTermBinding.inflate(getLayoutInflater()); | ||
131 | db.setLifecycleOwner(this); | ||
132 | db.setState(state); | ||
133 | db.bg.setOnClickListener(v -> termFilter.dismiss()); | ||
134 | termFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | ||
135 | termFilter.setOutsideTouchable(true); | ||
136 | termFilter.setOnDismissListener(this::getHomework); | ||
137 | } | ||
138 | termFilter.showAsDropDown(binding.anchorView); | ||
139 | } | ||
140 | |||
141 | private void showFeedbackFilter() { | ||
142 | if (feedbackFilter == null) { | ||
143 | PopupFilterFeedbackBinding db = PopupFilterFeedbackBinding.inflate(getLayoutInflater()); | ||
144 | db.setLifecycleOwner(this); | ||
145 | db.setState(state); | ||
146 | db.bg.setOnClickListener(v -> feedbackFilter.dismiss()); | ||
147 | feedbackFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | ||
148 | feedbackFilter.setOutsideTouchable(true); | ||
149 | feedbackFilter.setOnDismissListener(this::getHomework); | ||
150 | } | ||
151 | feedbackFilter.showAsDropDown(binding.anchorView); | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | protected ActivityStudentHomeworkBinding getViewBinding() { | ||
156 | return ActivityStudentHomeworkBinding.inflate(getLayoutInflater()); | ||
157 | } | ||
158 | |||
159 | public static class State { | ||
160 | public Student student; | ||
161 | |||
162 | public MutableLiveData<String> subject = new MutableLiveData<>(""); | ||
163 | public void setSubject(String value) { | ||
164 | subject.setValue(value); | ||
165 | } | ||
166 | |||
167 | public MutableLiveData<String> grade = new MutableLiveData<>(""); | ||
168 | public void setGrade(String value) { | ||
169 | grade.setValue(value); | ||
170 | } | ||
171 | |||
172 | public MutableLiveData<String> term = new MutableLiveData<>(""); | ||
173 | public void setTerm(String value) { | ||
174 | term.setValue(value); | ||
175 | } | ||
176 | |||
177 | //0:全部, 1: 已反馈, 2:未反馈 | ||
178 | public MutableLiveData<Integer> feedback = new MutableLiveData<>(0); | ||
179 | public void setFeedback(int value) { | ||
180 | feedback.setValue(value); | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 |
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import static android.app.Activity.RESULT_OK; | 3 | import static android.app.Activity.RESULT_OK; |
4 | 4 | ||
5 | import android.annotation.SuppressLint; | 5 | import android.annotation.SuppressLint; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
8 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
9 | import android.net.Uri; | 9 | import android.net.Uri; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
13 | import android.util.Log; | 13 | import android.util.Log; |
14 | import android.view.LayoutInflater; | 14 | import android.view.LayoutInflater; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | import android.view.ViewGroup; | 16 | import android.view.ViewGroup; |
17 | import android.widget.Toast; | 17 | import android.widget.Toast; |
18 | 18 | ||
19 | import androidx.annotation.NonNull; | 19 | import androidx.annotation.NonNull; |
20 | import androidx.annotation.Nullable; | 20 | import androidx.annotation.Nullable; |
21 | import androidx.core.content.FileProvider; | 21 | import androidx.core.content.FileProvider; |
22 | import androidx.recyclerview.widget.RecyclerView; | 22 | import androidx.recyclerview.widget.RecyclerView; |
23 | 23 | ||
24 | import com.bumptech.glide.Glide; | 24 | import com.bumptech.glide.Glide; |
25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
26 | import com.bumptech.glide.request.RequestOptions; | 26 | import com.bumptech.glide.request.RequestOptions; |
27 | import com.chad.library.adapter.base.BaseQuickAdapter; | 27 | import com.chad.library.adapter.base.BaseQuickAdapter; |
28 | import com.chad.library.adapter.base.BaseViewHolder; | 28 | import com.chad.library.adapter.base.BaseViewHolder; |
29 | import com.google.android.material.tabs.TabLayout; | 29 | import com.google.android.material.tabs.TabLayout; |
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.ErrorListActivity; | 34 | import com.hjx.parent.ErrorListActivity; |
35 | import com.hjx.parent.ImageActivity; | 35 | import com.hjx.parent.ImageActivity; |
36 | import com.hjx.parent.R; | 36 | import com.hjx.parent.R; |
37 | import com.hjx.parent.StuHomeworkActivity; | ||
37 | import com.hjx.parent.TeacherChooseActivity; | 38 | import com.hjx.parent.TeacherChooseActivity; |
38 | import com.hjx.parent.adapter.ErrorAdapter; | 39 | import com.hjx.parent.adapter.ErrorAdapter; |
39 | import com.hjx.parent.adapter.HomeworkAdapter; | 40 | import com.hjx.parent.adapter.HomeworkAdapter; |
40 | import com.hjx.parent.bean.StudentBean; | 41 | import com.hjx.parent.bean.StudentBean; |
41 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 42 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
42 | import com.hjx.parent.rx.BaseRxFragment; | 43 | import com.hjx.parent.rx.BaseRxFragment; |
43 | import com.prws.common.bean.PageInfo; | 44 | import com.prws.common.bean.PageInfo; |
44 | import com.prws.common.bean.ResponseResult; | 45 | import com.prws.common.bean.ResponseResult; |
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.ScreenUtils; | 50 | import com.prws.common.utils.ScreenUtils; |
50 | import com.prws.common.utils.SharedPreferencesUtil; | 51 | import com.prws.common.utils.SharedPreferencesUtil; |
51 | import com.prws.common.utils.dialog.MyButtomDialog; | 52 | import com.prws.common.utils.dialog.MyButtomDialog; |
52 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 53 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
53 | import com.zhangteng.imagepicker.bean.ImageInfo; | 54 | import com.zhangteng.imagepicker.bean.ImageInfo; |
54 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
55 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
56 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
57 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
58 | import com.zhangteng.utils.IHandlerCallBack; | 59 | import com.zhangteng.utils.IHandlerCallBack; |
59 | 60 | ||
60 | import java.io.File; | 61 | import java.io.File; |
61 | import java.util.ArrayList; | 62 | import java.util.ArrayList; |
62 | import java.util.Arrays; | 63 | import java.util.Arrays; |
63 | import java.util.Collections; | 64 | import java.util.Collections; |
64 | import java.util.HashMap; | 65 | import java.util.HashMap; |
65 | import java.util.List; | 66 | import java.util.List; |
66 | import java.util.Map; | 67 | import java.util.Map; |
67 | 68 | ||
68 | import io.reactivex.Observer; | 69 | import io.reactivex.Observer; |
69 | import io.reactivex.android.schedulers.AndroidSchedulers; | 70 | import io.reactivex.android.schedulers.AndroidSchedulers; |
70 | import io.reactivex.disposables.Disposable; | 71 | import io.reactivex.disposables.Disposable; |
71 | import io.reactivex.schedulers.Schedulers; | 72 | import io.reactivex.schedulers.Schedulers; |
72 | 73 | ||
73 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 74 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
74 | StudentBean studentBean; | 75 | StudentBean studentBean; |
75 | private int subject; | 76 | private int subject; |
76 | private ErrorAdapter errorAdapter; | 77 | private ErrorAdapter errorAdapter; |
77 | private HomeworkAdapter homeworkAdapter; | 78 | private HomeworkAdapter homeworkAdapter; |
78 | private String filePath; | 79 | private String filePath; |
79 | 80 | ||
80 | @Override | 81 | @Override |
81 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 82 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
82 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 83 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
83 | } | 84 | } |
84 | 85 | ||
85 | public void refreshStudent() { | 86 | public void refreshStudent() { |
86 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 87 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
87 | try { | 88 | try { |
88 | studentBean = new Gson().fromJson(student, StudentBean.class); | 89 | studentBean = new Gson().fromJson(student, StudentBean.class); |
89 | getBinding().tvChoose.setText(studentBean.getStuName()); | 90 | getBinding().tvChoose.setText(studentBean.getStuName()); |
90 | } catch (Exception e) { | 91 | } catch (Exception e) { |
91 | e.printStackTrace(); | 92 | e.printStackTrace(); |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | @Override | 96 | @Override |
96 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 97 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
97 | super.onViewCreated(view, savedInstanceState); | 98 | super.onViewCreated(view, savedInstanceState); |
98 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 99 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
99 | if (!TextUtils.isEmpty(photo)) { | 100 | if (!TextUtils.isEmpty(photo)) { |
100 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 101 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
101 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 102 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
102 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 103 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
103 | } | 104 | } |
104 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 105 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
105 | getBinding().tvName.setText(name); | 106 | getBinding().tvName.setText(name); |
106 | refreshStudent(); | 107 | refreshStudent(); |
107 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 108 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
108 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); | 109 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
109 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); | 110 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
110 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 111 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
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 | @Override | 117 | @Override |
117 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 118 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
118 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 119 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
119 | switch (item.getAdapterPosition()) { | 120 | switch (item.getAdapterPosition()) { |
120 | case 0: | 121 | case 0: |
121 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 122 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
122 | break; | 123 | break; |
123 | case 1: | 124 | case 1: |
124 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 125 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
125 | break; | 126 | break; |
126 | case 2: | 127 | case 2: |
127 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 128 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
128 | break; | 129 | break; |
129 | case 3: | 130 | case 3: |
130 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 131 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
131 | break; | 132 | break; |
132 | case 4: | 133 | case 4: |
133 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 134 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
134 | break; | 135 | break; |
135 | } | 136 | } |
136 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 137 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
137 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 138 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
138 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 139 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
139 | item.getConvertView().setOnClickListener(v -> { | 140 | item.getConvertView().setOnClickListener(v -> { |
140 | if (subject != item.getAdapterPosition()) { | 141 | if (subject != item.getAdapterPosition()) { |
141 | subject = item.getAdapterPosition(); | 142 | subject = item.getAdapterPosition(); |
142 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 143 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
143 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 144 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
144 | getError(subStr); | 145 | getError(subStr); |
145 | } else { | 146 | } else { |
146 | // nothing can do | 147 | // nothing can do |
147 | } | 148 | } |
148 | } | 149 | } |
149 | }); | 150 | }); |
150 | } | 151 | } |
151 | }; | 152 | }; |
152 | getBinding().rvSubject.setAdapter(adapter); | 153 | getBinding().rvSubject.setAdapter(adapter); |
153 | subject = 0; | 154 | subject = 0; |
154 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 155 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
155 | getBinding().llAll.setOnClickListener(v -> { | 156 | getBinding().llAll.setOnClickListener(v -> { |
156 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 157 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
157 | startActivity(intent); | 158 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
159 | startActivity(intent); | ||
160 | } else { | ||
161 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); | ||
162 | startActivity(intent); | ||
163 | } | ||
158 | }); | 164 | }); |
159 | 165 | ||
160 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 166 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
161 | homeworkAdapter = new HomeworkAdapter(); | 167 | homeworkAdapter = new HomeworkAdapter(); |
162 | binding.rvMain.setAdapter(errorAdapter); | 168 | binding.rvMain.setAdapter(errorAdapter); |
163 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 169 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
164 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 170 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
165 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 171 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
166 | @Override | 172 | @Override |
167 | public void onTabSelected(TabLayout.Tab tab) { | 173 | public void onTabSelected(TabLayout.Tab tab) { |
168 | if (tab.getPosition() == 0) { | 174 | if (tab.getPosition() == 0) { |
169 | binding.rvMain.setAdapter(errorAdapter); | 175 | binding.rvMain.setAdapter(errorAdapter); |
170 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 176 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
171 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 177 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
172 | } else { | 178 | } else { |
173 | binding.rvMain.setAdapter(homeworkAdapter); | 179 | binding.rvMain.setAdapter(homeworkAdapter); |
174 | binding.rvMain.setVisibility(View.VISIBLE); | 180 | binding.rvMain.setVisibility(View.VISIBLE); |
175 | binding.llEmpty.setVisibility(View.GONE); | 181 | binding.llEmpty.setVisibility(View.GONE); |
176 | } | 182 | } |
177 | } | 183 | } |
178 | @Override | 184 | @Override |
179 | public void onTabUnselected(TabLayout.Tab tab) { | 185 | public void onTabUnselected(TabLayout.Tab tab) { |
180 | } | 186 | } |
181 | @Override | 187 | @Override |
182 | public void onTabReselected(TabLayout.Tab tab) { | 188 | public void onTabReselected(TabLayout.Tab tab) { |
183 | } | 189 | } |
184 | }); | 190 | }); |
185 | } | 191 | } |
186 | 192 | ||
187 | private void takePhoto(int type) { | 193 | private void takePhoto(int type) { |
188 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 194 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
189 | XXPermissions.with(getContext()) | 195 | XXPermissions.with(getContext()) |
190 | // 申请多个权限 | 196 | // 申请多个权限 |
191 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 197 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
192 | @Override | 198 | @Override |
193 | public void onGranted(List<String> permissions, boolean all) { | 199 | public void onGranted(List<String> permissions, boolean all) { |
194 | if (all) { | 200 | if (all) { |
195 | //开启扫码界面 | 201 | //开启扫码界面 |
196 | showButtonDialog(type); | 202 | showButtonDialog(type); |
197 | } else { | 203 | } else { |
198 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 204 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
199 | } | 205 | } |
200 | } | 206 | } |
201 | 207 | ||
202 | @Override | 208 | @Override |
203 | public void onDenied(List<String> permissions, boolean never) { | 209 | public void onDenied(List<String> permissions, boolean never) { |
204 | XXPermissions.startPermissionActivity(getContext(), permissions); | 210 | XXPermissions.startPermissionActivity(getContext(), permissions); |
205 | } | 211 | } |
206 | }); | 212 | }); |
207 | } else { | 213 | } else { |
208 | showButtonDialog(type); | 214 | showButtonDialog(type); |
209 | } | 215 | } |
210 | } | 216 | } |
211 | 217 | ||
212 | private void showButtonDialog(int type) { | 218 | private void showButtonDialog(int type) { |
213 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 219 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
214 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 220 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
215 | dialog.setContentView(bottomView); | 221 | dialog.setContentView(bottomView); |
216 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 222 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
217 | @Override | 223 | @Override |
218 | public void onClick(View view) { | 224 | public void onClick(View view) { |
219 | dialog.dismiss(); | 225 | dialog.dismiss(); |
220 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 226 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
221 | //确保有相机来处理Intent | 227 | //确保有相机来处理Intent |
222 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 228 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
223 | File photoFile = new File(filePath); | 229 | File photoFile = new File(filePath); |
224 | 230 | ||
225 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 231 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
226 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); | 232 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
227 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 233 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
228 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 234 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
229 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); | 235 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
230 | } | 236 | } |
231 | }); | 237 | }); |
232 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 238 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
233 | @Override | 239 | @Override |
234 | public void onClick(View view) { | 240 | public void onClick(View view) { |
235 | dialog.dismiss(); | 241 | dialog.dismiss(); |
236 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 242 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
237 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) | 243 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
238 | .multiSelect(true) //是否多选 | 244 | .multiSelect(true) //是否多选 |
239 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 245 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
240 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 246 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
241 | .maxImageSelectable(5) //图片可选择数 | 247 | .maxImageSelectable(5) //图片可选择数 |
242 | .maxHeight(1920) //图片最大高度 | 248 | .maxHeight(1920) //图片最大高度 |
243 | .maxWidth(1920) //图片最大宽度 | 249 | .maxWidth(1920) //图片最大宽度 |
244 | .maxImageSize(3) //图片最大大小Mb | 250 | .maxImageSize(3) //图片最大大小Mb |
245 | .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(); | 251 | .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(); |
246 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 252 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
247 | 253 | ||
248 | } | 254 | } |
249 | }); | 255 | }); |
250 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 256 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
251 | @Override | 257 | @Override |
252 | public void onClick(View view) { | 258 | public void onClick(View view) { |
253 | dialog.dismiss(); | 259 | dialog.dismiss(); |
254 | } | 260 | } |
255 | }); | 261 | }); |
256 | dialog.show(); | 262 | dialog.show(); |
257 | } | 263 | } |
258 | 264 | ||
259 | @SuppressLint("CheckResult") | 265 | @SuppressLint("CheckResult") |
260 | protected void getHomework() { | 266 | protected void getHomework() { |
261 | if (studentBean == null) return; | 267 | if (studentBean == null) return; |
262 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 268 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
263 | .subscribeOn(Schedulers.io()) | 269 | .subscribeOn(Schedulers.io()) |
264 | .observeOn(AndroidSchedulers.mainThread()) | 270 | .observeOn(AndroidSchedulers.mainThread()) |
265 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 271 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
266 | .map(ResponseResult::getData) | 272 | .map(ResponseResult::getData) |
267 | .subscribe((data, th) -> { | 273 | .subscribe((data, th) -> { |
268 | if (th != null) th.printStackTrace(); | 274 | if (th != null) th.printStackTrace(); |
269 | if (data != null) { | 275 | if (data != null) { |
270 | Collections.sort(data); | 276 | Collections.sort(data); |
271 | } | 277 | } |
272 | homeworkAdapter.setNewData(data); | 278 | homeworkAdapter.setNewData(data); |
273 | }); | 279 | }); |
274 | } | 280 | } |
275 | 281 | ||
276 | private void getError(String subject) { | 282 | private void getError(String subject) { |
277 | if (studentBean == null) { | 283 | if (studentBean == null) { |
278 | return; | 284 | return; |
279 | } | 285 | } |
280 | Map<String, Object> map = new HashMap<>(); | 286 | Map<String, Object> map = new HashMap<>(); |
281 | map.put("subject", subject); | 287 | map.put("subject", subject); |
282 | map.put("stuId", studentBean.getStuId()); | 288 | map.put("stuId", studentBean.getStuId()); |
283 | map.put("pageSize", 5); | 289 | map.put("pageSize", 5); |
284 | map.put("pageNum", 1); | 290 | map.put("pageNum", 1); |
285 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 291 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
286 | @Override | 292 | @Override |
287 | public void onSubscribe(Disposable d) { | 293 | public void onSubscribe(Disposable d) { |
288 | } | 294 | } |
289 | @Override | 295 | @Override |
290 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 296 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
291 | if (result.getData() != null && result.getCode() == 200) { | 297 | if (result.getData() != null && result.getCode() == 200) { |
292 | List<TopicBean> topicBeans = result.getData().getList(); | 298 | List<TopicBean> topicBeans = result.getData().getList(); |
293 | errorAdapter.refresh(topicBeans); | 299 | errorAdapter.refresh(topicBeans); |
294 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 300 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
295 | if (topicBeans.size() > 0) { | 301 | if (topicBeans.size() > 0) { |
296 | getBinding().rvMain.setVisibility(View.VISIBLE); | 302 | getBinding().rvMain.setVisibility(View.VISIBLE); |
297 | getBinding().llEmpty.setVisibility(View.GONE); | 303 | getBinding().llEmpty.setVisibility(View.GONE); |
298 | } else { | 304 | } else { |
299 | getBinding().rvMain.setVisibility(View.GONE); | 305 | getBinding().rvMain.setVisibility(View.GONE); |
300 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 306 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
301 | } | 307 | } |
302 | } | 308 | } |
303 | } | 309 | } |
304 | } | 310 | } |
305 | @Override | 311 | @Override |
306 | public void onError(Throwable e) { | 312 | public void onError(Throwable e) { |
307 | e.printStackTrace(); | 313 | e.printStackTrace(); |
308 | } | 314 | } |
309 | @Override | 315 | @Override |
310 | public void onComplete() { | 316 | public void onComplete() { |
311 | } | 317 | } |
312 | }); | 318 | }); |
313 | } | 319 | } |
314 | 320 | ||
315 | @Override | 321 | @Override |
316 | public void onResume() { | 322 | public void onResume() { |
317 | super.onResume(); | 323 | super.onResume(); |
318 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 324 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
319 | getHomework(); | 325 | getHomework(); |
320 | } | 326 | } |
321 | 327 | ||
322 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 328 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
323 | int type; | 329 | int type; |
324 | public HandlerCallBack(int type) { | 330 | public HandlerCallBack(int type) { |
325 | this.type = type; | 331 | this.type = type; |
326 | } | 332 | } |
327 | 333 | ||
328 | private String TAG = "---ImagePicker---"; | 334 | private String TAG = "---ImagePicker---"; |
329 | List<ImageInfo> photoList = new ArrayList<>(); | 335 | List<ImageInfo> photoList = new ArrayList<>(); |
330 | 336 | ||
331 | @Override | 337 | @Override |
332 | public void onStart() { | 338 | public void onStart() { |
333 | Log.i(TAG, "onStart: 开启"); | 339 | Log.i(TAG, "onStart: 开启"); |
334 | } | 340 | } |
335 | 341 | ||
336 | @Override | 342 | @Override |
337 | public void onSuccess(List<ImageInfo> photoList) { | 343 | public void onSuccess(List<ImageInfo> photoList) { |
338 | this.photoList = photoList; | 344 | this.photoList = photoList; |
339 | Log.i(TAG, "onSuccess: 返回数据"); | 345 | Log.i(TAG, "onSuccess: 返回数据"); |
340 | } | 346 | } |
341 | 347 | ||
342 | @Override | 348 | @Override |
343 | public void onCancel() { | 349 | public void onCancel() { |
344 | Log.i(TAG, "onCancel: 取消"); | 350 | Log.i(TAG, "onCancel: 取消"); |
345 | } | 351 | } |
346 | 352 | ||
347 | @Override | 353 | @Override |
348 | public void onFinish(List<ImageInfo> selectImage) { | 354 | public void onFinish(List<ImageInfo> selectImage) { |
349 | if (selectImage.size() == photoList.size()) { | 355 | if (selectImage.size() == photoList.size()) { |
350 | ArrayList<String> strings = new ArrayList<>(); | 356 | ArrayList<String> strings = new ArrayList<>(); |
351 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 357 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
352 | for (ImageInfo imageInfo : selectImage) { | 358 | for (ImageInfo imageInfo : selectImage) { |
353 | strings.add(imageInfo.getPath()); | 359 | strings.add(imageInfo.getPath()); |
354 | } | 360 | } |
355 | intent.putStringArrayListExtra("images", strings); | 361 | intent.putStringArrayListExtra("images", strings); |
356 | intent.putExtra("type", type); | 362 | intent.putExtra("type", type); |
357 | startActivity(intent); | 363 | startActivity(intent); |
358 | } | 364 | } |
359 | } | 365 | } |
360 | 366 | ||
361 | @Override | 367 | @Override |
362 | public void onError() { | 368 | public void onError() { |
363 | Log.i(TAG, "onError: 出错"); | 369 | Log.i(TAG, "onError: 出错"); |
364 | } | 370 | } |
365 | } | 371 | } |
366 | 372 | ||
367 | @Override | 373 | @Override |
368 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 374 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
369 | super.onActivityResult(requestCode, resultCode, data); | 375 | super.onActivityResult(requestCode, resultCode, data); |
370 | if (resultCode != RESULT_OK) return; | 376 | if (resultCode != RESULT_OK) return; |
371 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { | 377 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { |
372 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 378 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
373 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 379 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
374 | CommonUtil.saveBitmapToUri(b, path); | 380 | CommonUtil.saveBitmapToUri(b, path); |
375 | ArrayList<String> strings = new ArrayList<>(); | 381 | ArrayList<String> strings = new ArrayList<>(); |
376 | Intent intent = new Intent(getContext(), ImageActivity.class); | 382 | Intent intent = new Intent(getContext(), ImageActivity.class); |
377 | strings.add(path); | 383 | strings.add(path); |
378 | intent.putStringArrayListExtra("images", strings); | 384 | intent.putStringArrayListExtra("images", strings); |
379 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); | 385 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); |
380 | startActivity(intent); | 386 | startActivity(intent); |
381 | } | 387 | } |
382 | } | 388 | } |
383 | } | 389 | } |
384 | 390 |
app/src/main/res/color/color_filter_item.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:color="@color/white" android:state_checked="true"/> | ||
4 | <item android:color="#333"/> | ||
5 | </selector> |
app/src/main/res/color/color_filter_state.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:color="#1C90F3" android:state_activated="true"/> | ||
4 | <item android:color="#333333"/> | ||
5 | </selector> |
app/src/main/res/drawable/btn_homework_filter_item.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | |||
4 | <item android:state_checked="true"> | ||
5 | <shape> | ||
6 | <corners android:radius="888dp"/> | ||
7 | <solid android:color="#1C90F3"/> | ||
8 | </shape> | ||
9 | </item> | ||
10 | <item> | ||
11 | <shape> | ||
12 | <corners android:radius="888dp"/> | ||
13 | <solid android:color="#F5F5F5"/> | ||
14 | </shape> | ||
15 | </item> | ||
16 | </selector> |
app/src/main/res/drawable/shape_radius_bottom_10dp.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp"/> | ||
4 | <solid android:color="@color/white"/> | ||
5 | </shape> |
app/src/main/res/drawable/svg_back.xml
File was created | 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:width="13dp" | ||
3 | android:height="19dp" | ||
4 | android:viewportWidth="26" | ||
5 | android:viewportHeight="38"> | ||
6 | <path | ||
7 | android:pathData="M20.839,5.679L7.87,17.825L20.839,29.971" | ||
8 | android:strokeLineJoin="miter" | ||
9 | android:strokeWidth="4" | ||
10 | android:fillColor="#00000000" | ||
11 | android:fillType="evenOdd" | ||
12 | android:strokeColor="#333333" | ||
13 | android:strokeLineCap="round"/> | ||
14 | </vector> | ||
15 |
app/src/main/res/drawable/svg_filter_drop_down.xml
File was created | 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:width="8dp" | ||
3 | android:height="4dp" | ||
4 | android:viewportWidth="14" | ||
5 | android:viewportHeight="7"> | ||
6 | <path | ||
7 | android:pathData="M13.071,0L7,6.071L0.929,0" | ||
8 | android:fillColor="#999999" | ||
9 | android:fillType="evenOdd"/> | ||
10 | </vector> | ||
11 |
app/src/main/res/layout/activity_student_homework.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | xmlns:tools="http://schemas.android.com/tools" | ||
5 | android:orientation="vertical" | ||
6 | android:layout_width="match_parent" | ||
7 | android:layout_height="match_parent" | ||
8 | tools:ignore="HardcodedText"> | ||
9 | |||
10 | <androidx.appcompat.widget.Toolbar | ||
11 | android:id="@+id/toolbar" | ||
12 | app:navigationIcon="@drawable/svg_back" | ||
13 | android:paddingStart="-8dp" | ||
14 | android:paddingEnd="-8dp" | ||
15 | android:background="@color/white" | ||
16 | android:layout_width="match_parent" | ||
17 | android:layout_height="40dp"> | ||
18 | <TextView | ||
19 | android:id="@+id/tvTitle" | ||
20 | tools:text="小明的全部作业" | ||
21 | android:textSize="18sp" | ||
22 | android:textColor="#333" | ||
23 | android:textStyle="bold" | ||
24 | android:layout_gravity="center" | ||
25 | android:layout_width="wrap_content" | ||
26 | android:layout_height="wrap_content"/> | ||
27 | </androidx.appcompat.widget.Toolbar> | ||
28 | <LinearLayout | ||
29 | android:orientation="horizontal" | ||
30 | android:background="@color/white" | ||
31 | android:paddingHorizontal="15dp" | ||
32 | android:paddingVertical="11dp" | ||
33 | android:layout_width="match_parent" | ||
34 | android:layout_height="wrap_content"> | ||
35 | <androidx.appcompat.widget.AppCompatTextView | ||
36 | android:id="@+id/ftSubject" | ||
37 | android:text="学科" | ||
38 | style="@style/tv_StudentHomeworkFilter"/> | ||
39 | <Space style="@style/empty_space"/> | ||
40 | <androidx.appcompat.widget.AppCompatTextView | ||
41 | android:id="@+id/ftGrade" | ||
42 | android:text="年级" | ||
43 | style="@style/tv_StudentHomeworkFilter"/> | ||
44 | <Space style="@style/empty_space"/> | ||
45 | <androidx.appcompat.widget.AppCompatTextView | ||
46 | android:id="@+id/ftTerm" | ||
47 | android:text="学期" | ||
48 | style="@style/tv_StudentHomeworkFilter"/> | ||
49 | <Space style="@style/empty_space"/> | ||
50 | <androidx.appcompat.widget.AppCompatTextView | ||
51 | android:id="@+id/ftFeedback" | ||
52 | android:text="反馈状态" | ||
53 | style="@style/tv_StudentHomeworkFilter"/> | ||
54 | </LinearLayout> | ||
55 | <androidx.legacy.widget.Space | ||
56 | android:id="@+id/anchorView" | ||
57 | android:layout_width="0dp" | ||
58 | android:layout_height="0dp"/> | ||
59 | |||
60 | <androidx.recyclerview.widget.RecyclerView | ||
61 | android:id="@+id/recyclerView" | ||
62 | android:background="#F8F8F8" | ||
63 | android:orientation="vertical" | ||
64 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
65 | android:layout_width="match_parent" | ||
66 | android:layout_height="match_parent"/> | ||
67 | </LinearLayout> |
app/src/main/res/layout/popup_filter_feedback.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layout xmlns:tools="http://schemas.android.com/tools" | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | tools:ignore="HardcodedText"> | ||
5 | |||
6 | <data> | ||
7 | <import type="com.hjx.parent.StuHomeworkActivity.State"/> | ||
8 | <variable | ||
9 | name="state" | ||
10 | type="State" /> | ||
11 | </data> | ||
12 | |||
13 | <LinearLayout | ||
14 | android:orientation="vertical" | ||
15 | android:background="#80000000" | ||
16 | android:layout_width="match_parent" | ||
17 | android:layout_height="wrap_content"> | ||
18 | <LinearLayout | ||
19 | android:orientation="vertical" | ||
20 | android:padding="8dp" | ||
21 | android:background="@drawable/shape_radius_bottom_10dp" | ||
22 | android:layout_width="match_parent" | ||
23 | android:layout_height="wrap_content"> | ||
24 | <LinearLayout | ||
25 | android:orientation="horizontal" | ||
26 | android:weightSum="4" | ||
27 | android:layout_width="match_parent" | ||
28 | android:layout_height="wrap_content" | ||
29 | tools:ignore="UselessParent"> | ||
30 | <RadioButton | ||
31 | android:text="全部" | ||
32 | android:checked="@{state.feedback == 0}" | ||
33 | android:onClick='@{() -> state.setFeedback(0)}' | ||
34 | style="@style/chk_HomeworkFilterItem"/> | ||
35 | <RadioButton | ||
36 | android:text="已反馈" | ||
37 | android:checked='@{state.feedback == 1}' | ||
38 | android:onClick='@{() -> state.setFeedback(1)}' | ||
39 | style="@style/chk_HomeworkFilterItem"/> | ||
40 | <RadioButton | ||
41 | android:text="未反馈" | ||
42 | android:checked='@{state.feedback == 2}' | ||
43 | android:onClick='@{() -> state.setFeedback(2)}' | ||
44 | style="@style/chk_HomeworkFilterItem"/> | ||
45 | <RadioButton | ||
46 | android:visibility="invisible" | ||
47 | style="@style/chk_HomeworkFilterItem"/> | ||
48 | </LinearLayout> | ||
49 | </LinearLayout> | ||
50 | |||
51 | <View | ||
52 | android:id="@+id/bg" | ||
53 | android:layout_width="match_parent" | ||
54 | android:layout_height="match_parent"/> | ||
55 | </LinearLayout> | ||
56 | </layout> |
app/src/main/res/layout/popup_filter_grade.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layout xmlns:tools="http://schemas.android.com/tools" | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | tools:ignore="HardcodedText"> | ||
5 | |||
6 | <data> | ||
7 | <import type="com.hjx.parent.StuHomeworkActivity.State"/> | ||
8 | <variable | ||
9 | name="state" | ||
10 | type="State" /> | ||
11 | </data> | ||
12 | |||
13 | <LinearLayout | ||
14 | android:orientation="vertical" | ||
15 | android:background="#80000000" | ||
16 | android:layout_width="match_parent" | ||
17 | android:layout_height="wrap_content"> | ||
18 | <LinearLayout | ||
19 | android:orientation="vertical" | ||
20 | android:padding="8dp" | ||
21 | android:background="@drawable/shape_radius_bottom_10dp" | ||
22 | android:layout_width="match_parent" | ||
23 | android:layout_height="wrap_content"> | ||
24 | <LinearLayout | ||
25 | android:orientation="horizontal" | ||
26 | android:weightSum="4" | ||
27 | android:layout_width="match_parent" | ||
28 | android:layout_height="wrap_content"> | ||
29 | <RadioButton | ||
30 | android:text="全部" | ||
31 | android:checked="@{state.grade.empty}" | ||
32 | android:onClick='@{() -> state.setGrade("")}' | ||
33 | style="@style/chk_HomeworkFilterItem"/> | ||
34 | <RadioButton | ||
35 | android:text="七年级" | ||
36 | android:checked='@{state.grade.equals("七年级")}' | ||
37 | android:onClick='@{() -> state.setGrade("七年级")}' | ||
38 | style="@style/chk_HomeworkFilterItem"/> | ||
39 | <RadioButton | ||
40 | android:text="八年级" | ||
41 | android:checked='@{state.grade.equals("八年级")}' | ||
42 | android:onClick='@{() -> state.setGrade("八年级")}' | ||
43 | style="@style/chk_HomeworkFilterItem"/> | ||
44 | <RadioButton | ||
45 | android:text="九年级" | ||
46 | android:checked='@{state.grade.equals("九年级")}' | ||
47 | android:onClick='@{() -> state.setGrade("九年级")}' | ||
48 | style="@style/chk_HomeworkFilterItem"/> | ||
49 | </LinearLayout> | ||
50 | <LinearLayout | ||
51 | android:orientation="horizontal" | ||
52 | android:weightSum="4" | ||
53 | android:layout_width="match_parent" | ||
54 | android:layout_height="wrap_content"> | ||
55 | <RadioButton | ||
56 | android:text="一年级" | ||
57 | android:checked='@{state.grade.equals("一年级")}' | ||
58 | android:onClick='@{() -> state.setGrade("一年级")}' | ||
59 | style="@style/chk_HomeworkFilterItem"/> | ||
60 | <RadioButton | ||
61 | android:text="二年级" | ||
62 | android:checked='@{state.grade.equals("二年级")}' | ||
63 | android:onClick='@{() -> state.setGrade("二年级")}' | ||
64 | style="@style/chk_HomeworkFilterItem"/> | ||
65 | <RadioButton | ||
66 | android:text="三年级" | ||
67 | android:checked='@{state.grade.equals("三年级")}' | ||
68 | android:onClick='@{() -> state.setGrade("三年级")}' | ||
69 | style="@style/chk_HomeworkFilterItem"/> | ||
70 | <RadioButton | ||
71 | android:text="四年级" | ||
72 | android:checked='@{state.grade.equals("四年级")}' | ||
73 | android:onClick='@{() -> state.setGrade("四年级")}' | ||
74 | style="@style/chk_HomeworkFilterItem"/> | ||
75 | </LinearLayout> | ||
76 | <LinearLayout | ||
77 | android:orientation="horizontal" | ||
78 | android:weightSum="4" | ||
79 | android:layout_width="match_parent" | ||
80 | android:layout_height="wrap_content"> | ||
81 | <RadioButton | ||
82 | android:text="五年级" | ||
83 | android:checked='@{state.grade.equals("五年级")}' | ||
84 | android:onClick='@{() -> state.setGrade("五年级")}' | ||
85 | style="@style/chk_HomeworkFilterItem"/> | ||
86 | <RadioButton | ||
87 | android:text="六年级" | ||
88 | android:checked='@{state.grade.equals("六年级")}' | ||
89 | android:onClick='@{() -> state.setGrade("六年级")}' | ||
90 | style="@style/chk_HomeworkFilterItem"/> | ||
91 | <RadioButton | ||
92 | android:visibility="invisible" | ||
93 | style="@style/chk_HomeworkFilterItem"/> | ||
94 | <RadioButton | ||
95 | android:visibility="invisible" | ||
96 | style="@style/chk_HomeworkFilterItem"/> | ||
97 | </LinearLayout> | ||
98 | </LinearLayout> | ||
99 | |||
100 | <View | ||
101 | android:id="@+id/bg" | ||
102 | android:layout_width="match_parent" | ||
103 | android:layout_height="match_parent"/> | ||
104 | </LinearLayout> | ||
105 | </layout> |
app/src/main/res/layout/popup_filter_subject.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layout xmlns:tools="http://schemas.android.com/tools" | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | tools:ignore="HardcodedText"> | ||
5 | |||
6 | <data> | ||
7 | <import type="com.hjx.parent.StuHomeworkActivity.State"/> | ||
8 | <variable | ||
9 | name="state" | ||
10 | type="State" /> | ||
11 | </data> | ||
12 | |||
13 | <LinearLayout | ||
14 | android:orientation="vertical" | ||
15 | android:background="#80000000" | ||
16 | android:layout_width="match_parent" | ||
17 | android:layout_height="wrap_content"> | ||
18 | <LinearLayout | ||
19 | android:orientation="vertical" | ||
20 | android:padding="8dp" | ||
21 | android:background="@drawable/shape_radius_bottom_10dp" | ||
22 | android:layout_width="match_parent" | ||
23 | android:layout_height="wrap_content"> | ||
24 | <LinearLayout | ||
25 | android:orientation="horizontal" | ||
26 | android:weightSum="4" | ||
27 | android:layout_width="match_parent" | ||
28 | android:layout_height="wrap_content"> | ||
29 | <RadioButton | ||
30 | android:text="全部" | ||
31 | android:checked="@{state.subject.empty}" | ||
32 | android:onClick='@{() -> state.setSubject("")}' | ||
33 | style="@style/chk_HomeworkFilterItem"/> | ||
34 | <RadioButton | ||
35 | android:text="语文" | ||
36 | android:checked='@{state.subject.equals("语文")}' | ||
37 | android:onClick='@{() -> state.setSubject("语文")}' | ||
38 | style="@style/chk_HomeworkFilterItem"/> | ||
39 | <RadioButton | ||
40 | android:text="数学" | ||
41 | android:checked='@{state.subject.equals("数学")}' | ||
42 | android:onClick='@{() -> state.setSubject("数学")}' | ||
43 | style="@style/chk_HomeworkFilterItem"/> | ||
44 | <RadioButton | ||
45 | android:text="英语" | ||
46 | android:checked='@{state.subject.equals("英语")}' | ||
47 | android:onClick='@{() -> state.setSubject("英语")}' | ||
48 | style="@style/chk_HomeworkFilterItem"/> | ||
49 | </LinearLayout> | ||
50 | <LinearLayout | ||
51 | android:orientation="horizontal" | ||
52 | android:weightSum="4" | ||
53 | android:layout_width="match_parent" | ||
54 | android:layout_height="wrap_content"> | ||
55 | <RadioButton | ||
56 | android:text="物理" | ||
57 | android:checked='@{state.subject.equals("物理")}' | ||
58 | android:onClick='@{() -> state.setSubject("物理")}' | ||
59 | style="@style/chk_HomeworkFilterItem"/> | ||
60 | <RadioButton | ||
61 | android:text="化学" | ||
62 | android:checked='@{state.subject.equals("化学")}' | ||
63 | android:onClick='@{() -> state.setSubject("化学")}' | ||
64 | style="@style/chk_HomeworkFilterItem"/> | ||
65 | <RadioButton | ||
66 | android:visibility="invisible" | ||
67 | style="@style/chk_HomeworkFilterItem"/> | ||
68 | <RadioButton | ||
69 | android:visibility="invisible" | ||
70 | style="@style/chk_HomeworkFilterItem"/> | ||
71 | </LinearLayout> | ||
72 | </LinearLayout> | ||
73 | |||
74 | <View | ||
75 | android:id="@+id/bg" | ||
76 | android:layout_width="match_parent" | ||
77 | android:layout_height="match_parent"/> | ||
78 | </LinearLayout> | ||
79 | </layout> |
app/src/main/res/layout/popup_filter_term.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layout xmlns:tools="http://schemas.android.com/tools" | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | tools:ignore="HardcodedText"> | ||
5 | |||
6 | <data> | ||
7 | <import type="com.hjx.parent.StuHomeworkActivity.State"/> | ||
8 | <variable | ||
9 | name="state" | ||
10 | type="State" /> | ||
11 | </data> | ||
12 | |||
13 | <LinearLayout | ||
14 | android:orientation="vertical" | ||
15 | android:background="#80000000" | ||
16 | android:layout_width="match_parent" | ||
17 | android:layout_height="wrap_content"> | ||
18 | <LinearLayout | ||
19 | android:orientation="vertical" | ||
20 | android:padding="8dp" | ||
21 | android:background="@drawable/shape_radius_bottom_10dp" | ||
22 | android:layout_width="match_parent" | ||
23 | android:layout_height="wrap_content"> | ||
24 | <LinearLayout | ||
25 | android:orientation="horizontal" | ||
26 | android:weightSum="4" | ||
27 | android:layout_width="match_parent" | ||
28 | android:layout_height="wrap_content" | ||
29 | tools:ignore="UselessParent"> | ||
30 | <RadioButton | ||
31 | android:text="全部" | ||
32 | android:checked="@{state.term.empty}" | ||
33 | android:onClick='@{() -> state.setTerm("")}' | ||
34 | style="@style/chk_HomeworkFilterItem"/> | ||
35 | <RadioButton | ||
36 | android:text="上学期" | ||
37 | android:checked='@{state.term.equals("上学期")}' | ||
38 | android:onClick='@{() -> state.setTerm("上学期")}' | ||
39 | style="@style/chk_HomeworkFilterItem"/> | ||
40 | <RadioButton | ||
41 | android:text="下学期" | ||
42 | android:checked='@{state.term.equals("下学期")}' | ||
43 | android:onClick='@{() -> state.setTerm("下学期")}' | ||
44 | style="@style/chk_HomeworkFilterItem"/> | ||
45 | <RadioButton | ||
46 | android:visibility="invisible" | ||
47 | style="@style/chk_HomeworkFilterItem"/> | ||
48 | </LinearLayout> | ||
49 | </LinearLayout> | ||
50 | |||
51 | <View | ||
52 | android:id="@+id/bg" | ||
53 | android:layout_width="match_parent" | ||
54 | android:layout_height="match_parent"/> | ||
55 | </LinearLayout> | ||
56 | </layout> |
app/src/main/res/values/styles.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <resources> | 2 | <resources> |
3 | 3 | ||
4 | 4 | ||
5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> | 5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> |
6 | <item name="android:windowBackground">@drawable/welcome_bg</item> | 6 | <item name="android:windowBackground">@drawable/welcome_bg</item> |
7 | <item name="colorPrimaryDark">@android:color/transparent</item> | 7 | <item name="colorPrimaryDark">@android:color/transparent</item> |
8 | <item name="windowActionBar">false</item> | 8 | <item name="windowActionBar">false</item> |
9 | <item name="windowNoTitle">true</item> | 9 | <item name="windowNoTitle">true</item> |
10 | <item name="android:windowFullscreen">true</item> | 10 | <item name="android:windowFullscreen">true</item> |
11 | </style> | 11 | </style> |
12 | 12 | ||
13 | <style name="main_bottom_navigaton_menu_item"> | 13 | <style name="main_bottom_navigaton_menu_item"> |
14 | <item name="android:layout_width">0dp</item> | 14 | <item name="android:layout_width">0dp</item> |
15 | <item name="android:layout_weight">1</item> | 15 | <item name="android:layout_weight">1</item> |
16 | <item name="android:layout_height">match_parent</item> | 16 | <item name="android:layout_height">match_parent</item> |
17 | <item name="android:background">@android:color/transparent</item> | 17 | <item name="android:background">@android:color/transparent</item> |
18 | <item name="android:button">@null</item> | 18 | <item name="android:button">@null</item> |
19 | <item name="android:gravity">center</item> | 19 | <item name="android:gravity">center</item> |
20 | <item name="android:textSize">11dp</item> | 20 | <item name="android:textSize">11dp</item> |
21 | <item name="android:drawablePadding">2dp</item> | 21 | <item name="android:drawablePadding">2dp</item> |
22 | </style> | 22 | </style> |
23 | <!--实现BottomSheetDialog圆角效果--> | 23 | <!--实现BottomSheetDialog圆角效果--> |
24 | <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> | 24 | <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> |
25 | <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> | 25 | <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> |
26 | </style> | 26 | </style> |
27 | 27 | ||
28 | <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal"> | 28 | <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal"> |
29 | <item name="android:background">@android:color/transparent</item> | 29 | <item name="android:background">@android:color/transparent</item> |
30 | <item name="android:navigationBarColor">@android:color/transparent</item> | 30 | <item name="android:navigationBarColor">@android:color/transparent</item> |
31 | <item name="behavior_peekHeight">500dp</item> | 31 | <item name="behavior_peekHeight">500dp</item> |
32 | </style> | 32 | </style> |
33 | 33 | ||
34 | <style name="MyAlertDialog" parent="android:Theme.Material.Dialog.Alert"> | 34 | <style name="MyAlertDialog" parent="android:Theme.Material.Dialog.Alert"> |
35 | <!--背景颜色及和透明程度--> | 35 | <!--背景颜色及和透明程度--> |
36 | <item name="android:windowBackground">@null</item> | 36 | <item name="android:windowBackground">@null</item> |
37 | <!--是否去除标题 --> | 37 | <!--是否去除标题 --> |
38 | <item name="android:windowNoTitle">true</item> | 38 | <item name="android:windowNoTitle">true</item> |
39 | <!--是否去除边框--> | 39 | <!--是否去除边框--> |
40 | <item name="android:windowFrame">@null</item> | 40 | <item name="android:windowFrame">@null</item> |
41 | <!--是否浮现在activity之上--> | 41 | <!--是否浮现在activity之上--> |
42 | <item name="android:windowIsFloating">true</item> | 42 | <item name="android:windowIsFloating">true</item> |
43 | <!--是否模糊--> | 43 | <!--是否模糊--> |
44 | <item name="android:backgroundDimEnabled">true</item> | 44 | <item name="android:backgroundDimEnabled">true</item> |
45 | <item name="android:windowIsTranslucent">true</item><!--半透明--> | 45 | <item name="android:windowIsTranslucent">true</item><!--半透明--> |
46 | <item name="android:windowSoftInputMode">stateVisible|adjustPan</item> | 46 | <item name="android:windowSoftInputMode">stateVisible|adjustPan</item> |
47 | </style> | 47 | </style> |
48 | 48 | ||
49 | <style name="customSpinnerStyle" parent="android:Widget.ListView.DropDown"> | 49 | <style name="customSpinnerStyle" parent="android:Widget.ListView.DropDown"> |
50 | <item name="divider">@color/border</item> | 50 | <item name="divider">@color/border</item> |
51 | <item name="android:scrollbars">none</item> | 51 | <item name="android:scrollbars">none</item> |
52 | <item name="android:dividerHeight">1dp</item> | 52 | <item name="android:dividerHeight">1dp</item> |
53 | <item name="android:textSize">15sp</item> | 53 | <item name="android:textSize">15sp</item> |
54 | </style> | 54 | </style> |
55 | 55 | ||
56 | <style name="empty_space"> | 56 | <style name="empty_space"> |
57 | <item name="android:layout_width">0dp</item> | 57 | <item name="android:layout_width">0dp</item> |
58 | <item name="android:layout_height">0dp</item> | 58 | <item name="android:layout_height">0dp</item> |
59 | <item name="android:layout_weight">1</item> | 59 | <item name="android:layout_weight">1</item> |
60 | </style> | 60 | </style> |
61 | 61 | ||
62 | 62 | ||
63 | <style name="BaseDialog"> | 63 | <style name="BaseDialog"> |
64 | <item name="android:background">@android:color/transparent</item> | 64 | <item name="android:background">@android:color/transparent</item> |
65 | <item name="android:windowBackground">@android:color/transparent</item> | 65 | <item name="android:windowBackground">@android:color/transparent</item> |
66 | <item name="android:windowIsFloating">true</item> | 66 | <item name="android:windowIsFloating">true</item> |
67 | </style> | 67 | </style> |
68 | 68 | ||
69 | <style name="tv_StudentHomeworkFilter"> | ||
70 | <item name="android:textSize">13sp</item> | ||
71 | <item name="android:textColor">@color/color_filter_state</item> | ||
72 | <item name="android:drawableTint">@color/color_filter_state</item> | ||
73 | <item name="android:drawableEnd">@drawable/svg_filter_drop_down</item> | ||
74 | <item name="android:drawablePadding">8dp</item> | ||
75 | <item name="android:layout_width">wrap_content</item> | ||
76 | <item name="android:layout_height">wrap_content</item> | ||
77 | </style> | ||
78 | |||
79 | <style name="chk_HomeworkFilterItem"> | ||
80 | <item name="android:textSize">13sp</item> | ||
81 | <item name="android:textColor">@color/color_filter_item</item> | ||
82 | <item name="android:gravity">center</item> | ||
83 | <item name="android:button">@null</item> | ||
84 | <item name="android:background">@drawable/btn_homework_filter_item</item> | ||
85 | <item name="android:layout_margin">8dp</item> | ||
86 | <item name="android:layout_weight">1</item> | ||
87 | <item name="android:layout_width">0dp</item> | ||
88 | <item name="android:layout_height">26dp</item> | ||
89 | </style> | ||
90 | |||
69 | </resources> | 91 | </resources> |