Commit f1ce56b9bbc90fcfe12b08c7d9b55e6f62ee7c4c
1 parent
484570f5e6
Exists in
master
BUG修改
Showing
19 changed files
with
191 additions
and
155 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 1003 | 28 | versionCode 1004 |
29 | versionName "1.0.0.3" | 29 | versionName "1.0.0.4" |
30 | 30 | ||
31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
32 | } | 32 | } |
33 | 33 | ||
34 | android.applicationVariants.all { | 34 | android.applicationVariants.all { |
35 | variant -> | 35 | variant -> |
36 | variant.outputs.all { | 36 | variant.outputs.all { |
37 | //在这里修改apk文件名 | 37 | //在这里修改apk文件名 |
38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
39 | } | 39 | } |
40 | } | 40 | } |
41 | buildTypes { | 41 | buildTypes { |
42 | debug { | 42 | debug { |
43 | debuggable true | 43 | debuggable true |
44 | minifyEnabled false | 44 | minifyEnabled false |
45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
46 | signingConfig signingConfigs.config | 46 | signingConfig signingConfigs.config |
47 | } | 47 | } |
48 | release { | 48 | release { |
49 | debuggable true | 49 | debuggable true |
50 | minifyEnabled false | 50 | minifyEnabled false |
51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
52 | signingConfig signingConfigs.config | 52 | signingConfig signingConfigs.config |
53 | } | 53 | } |
54 | } | 54 | } |
55 | lintOptions { | 55 | lintOptions { |
56 | checkReleaseBuilds false | 56 | checkReleaseBuilds false |
57 | abortOnError false | 57 | abortOnError false |
58 | } | 58 | } |
59 | buildFeatures { | 59 | buildFeatures { |
60 | viewBinding true | 60 | viewBinding true |
61 | } | 61 | } |
62 | compileOptions { | 62 | compileOptions { |
63 | sourceCompatibility JavaVersion.VERSION_1_8 | 63 | sourceCompatibility JavaVersion.VERSION_1_8 |
64 | targetCompatibility JavaVersion.VERSION_1_8 | 64 | targetCompatibility JavaVersion.VERSION_1_8 |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | dependencies { | 68 | dependencies { |
69 | support.each { k, v -> implementation v } | 69 | support.each { k, v -> implementation v } |
70 | api project(path: ':libs:common') | 70 | api project(path: ':libs:common') |
71 | implementation 'androidx.appcompat:appcompat:1.5.1' | 71 | implementation 'androidx.appcompat:appcompat:1.5.1' |
72 | implementation 'com.google.android.material:material:1.6.1' | 72 | implementation 'com.google.android.material:material:1.6.1' |
73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
77 | //使用的三方 | 77 | //使用的三方 |
78 | implementation 'com.yalantis:ucrop:2.2.0' | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
81 | } | 81 | } |
app/src/main/assets/style.css
1 | body{font-family: "微软雅黑", Arial,"宋体"; font-size: 14px; line-height: 1.5em; color: #333;} | 1 | body{font-family: "微软雅黑", Arial,"宋体"; font-size: 16px; line-height: 1.5em; color: #333;} |
2 | a{ text-decoration: none; color: #2489f6;} | 2 | a{ text-decoration: none; color: #2489f6;} |
3 | dl, ul, ol, ul { list-style: none; padding: 0; margin: 0; } | 3 | dl, ul, ol, ul { list-style: none; padding: 0; margin: 0; } |
4 | .wrapper{ width: 1200px; margin: 0 auto; } | 4 | .wrapper{ width: 1200px; margin: 0 auto; } |
5 | .ques-detail{} | 5 | .ques-detail{} |
6 | .ques-detail ul li{margin-bottom: 20px;border: 1px solid #dadada;background: #fff;border-radius: 10px;} | 6 | .ques-detail ul li{margin-bottom: 20px;border: 1px solid #dadada;background: #fff;border-radius: 10px;} |
7 | .ques-detail ul li:last-child{ margin-bottom: 0; } | 7 | .ques-detail ul li:last-child{ margin-bottom: 0; } |
8 | 8 | ||
9 | table.edittable{ border-collapse: collapse; text-align: center; margin: 2px; } | 9 | table.edittable{ border-collapse: collapse; text-align: center; margin: 2px; } |
10 | table.edittable th, table.edittable td{ line-height: 30px; padding: 5px; white-space: normal; word-break: break-all; border: 1px solid #000; vertical-align: middle; } | 10 | table.edittable th, table.edittable td{ line-height: 30px; padding: 5px; white-space: normal; word-break: break-all; border: 1px solid #000; vertical-align: middle; } |
11 | table.composition{ border-collapse: collapse; text-align: left; margin: 2px; width: 98%; } | 11 | table.composition{ border-collapse: collapse; text-align: left; margin: 2px; width: 98%; } |
12 | table.composition th, table.composition td{ line-height: 30px; white-space: normal; word-break: break-all; border-width: 0px; vertical-align: middle; } | 12 | table.composition th, table.composition td{ line-height: 30px; white-space: normal; word-break: break-all; border-width: 0px; vertical-align: middle; } |
13 | table.composition2{ border-collapse: collapse;width:auto } | 13 | table.composition2{ border-collapse: collapse;width:auto } |
14 | table.composition2 th, table.composition2 td{text-align:left;line-height:30px; white-space:normal;word-break:break-all;border:none;border-width: 0px;vertical-align: middle; } | 14 | table.composition2 th, table.composition2 td{text-align:left;line-height:30px; white-space:normal;word-break:break-all;border:none;border-width: 0px;vertical-align: middle; } |
15 | .MathJye{ border: 0 none; direction: ltr; line-height: normal; display: inline-block; float: none; font-family: 'Times New Roman','宋体'; font-size: 15px; font-style: normal; font-weight: normal; letter-spacing: 1px; line-height: normal; margin: 0; padding: 0; text-align: left; text-indent: 0; text-transform: none; white-space: nowrap; word-spacing: normal; word-wrap: normal; -webkit-text-size-adjust: none; } | 15 | .MathJye{ border: 0 none; direction: ltr; line-height: normal; display: inline-block; float: none; font-family: 'Times New Roman','宋体'; font-size: 15px; font-style: normal; font-weight: normal; letter-spacing: 1px; line-height: normal; margin: 0; padding: 0; text-align: left; text-indent: 0; text-transform: none; white-space: nowrap; word-spacing: normal; word-wrap: normal; -webkit-text-size-adjust: none; } |
16 | .MathJye div, .MathJye span{ border: 0 none; margin: 0; padding: 0; line-height: normal; text-align: left; height: auto; _height: auto; white-space: normal; } | 16 | .MathJye div, .MathJye span{ border: 0 none; margin: 0; padding: 0; line-height: normal; text-align: left; height: auto; _height: auto; white-space: normal; } |
17 | .MathJye table{ border-collapse: collapse; margin: 0; padding: 0; text-align: center; vertical-align: middle; line-height: normal; font-size: inherit; *font-size: 100%; _font-size: 100%; font-style: normal; font-weight: normal; border: 0; float: none; display: inline-block; *display: inline; zoom: 0; } | 17 | .MathJye table{ border-collapse: collapse; margin: 0; padding: 0; text-align: center; vertical-align: middle; line-height: normal; font-size: inherit; *font-size: 100%; _font-size: 100%; font-style: normal; font-weight: normal; border: 0; float: none; display: inline-block; *display: inline; zoom: 0; } |
18 | .MathJye table td{ padding: 0; font-size: inherit; line-height: normal; white-space: nowrap; border: 0 none; width: auto; _height: auto; } | 18 | .MathJye table td{ padding: 0; font-size: inherit; line-height: normal; white-space: nowrap; border: 0 none; width: auto; _height: auto; } |
19 | .MathJye_mi{ font-style: italic; } | 19 | .MathJye_mi{ font-style: italic; } |
20 | .flipv{-ms-transform: scaleX(-1);-moz-transform: scaleX(-1);-webkit-transform: scaleX(-1);-o-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;} | 20 | .flipv{-ms-transform: scaleX(-1);-moz-transform: scaleX(-1);-webkit-transform: scaleX(-1);-o-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;} |
21 | .fliph{-ms-transform: scaleY(-1);-moz-transform: scaleY(-1);-webkit-transform: scaleY(-1);-o-transform: scaleY(-1);transform: scaleY(-1);filter: FlipV;} | 21 | .fliph{-ms-transform: scaleY(-1);-moz-transform: scaleY(-1);-webkit-transform: scaleY(-1);-o-transform: scaleY(-1);transform: scaleY(-1);filter: FlipV;} |
22 | .mathjye-bold{font-weight:800} | 22 | .mathjye-bold{font-weight:800} |
23 | .mathjye-del{text-decoration:line-through} | 23 | .mathjye-del{text-decoration:line-through} |
24 | .mathjye-underline{border-bottom:1px solid #000;padding-bottom:2px;} | 24 | .mathjye-underline{border-bottom:1px solid #000;padding-bottom:2px;} |
25 | @-moz-document url-prefix() {.mathjye-underline{padding-bottom:0px;}} | 25 | @-moz-document url-prefix() {.mathjye-underline{padding-bottom:0px;}} |
26 | .mathjye-underpline{border-bottom:2px dotted #000; padding-bottom:3px;} | 26 | .mathjye-underpline{border-bottom:2px dotted #000; padding-bottom:3px;} |
27 | @-moz-document url-prefix() {.mathjye-underpline {padding-bottom:1px;}} | 27 | @-moz-document url-prefix() {.mathjye-underpline {padding-bottom:1px;}} |
28 | .mathjye-underpoint{background: url(http://img.jyeoo.net/images/formula/point.png) no-repeat center bottom; padding-bottom:4px;} | 28 | .mathjye-underpoint{background: url(http://img.jyeoo.net/images/formula/point.png) no-repeat center bottom; padding-bottom:4px;} |
29 | .mathjye-underpoint2{border-bottom:2px dotted #000; padding-bottom:3px;} | 29 | .mathjye-underpoint2{border-bottom:2px dotted #000; padding-bottom:3px;} |
30 | @-moz-document url-prefix() {.mathjye-underpoint{padding-bottom:1px;}} | 30 | @-moz-document url-prefix() {.mathjye-underpoint{padding-bottom:1px;}} |
31 | .mathjye-underwave{background: url(http://img.jyeoo.net/images/formula/wave.png) bottom repeat-x; padding-bottom:4px;} | 31 | .mathjye-underwave{background: url(http://img.jyeoo.net/images/formula/wave.png) bottom repeat-x; padding-bottom:4px;} |
32 | @-moz-document url-prefix() {.mathjye-underwave {padding-bottom:1px;}} | 32 | @-moz-document url-prefix() {.mathjye-underwave {padding-bottom:1px;}} |
33 | .mathjye-alignleft{display:block;text-align:left;} | 33 | .mathjye-alignleft{display:block;text-align:left;} |
34 | .mathjye-aligncenter{display:block;text-align:center;} | 34 | .mathjye-aligncenter{display:block;text-align:center;} |
35 | .mathjye-alignright{display:block;text-align:right;} | 35 | .mathjye-alignright{display:block;text-align:right;} |
36 | 36 | ||
37 | 37 | ||
38 | /*试题*/ | 38 | /*试题*/ |
39 | .artpreview fieldset { padding-top: 10px; font-size: 14px; clear: both; overflow: hidden; zoom: 1; line-height: 24px; font-family: 'Times New Roman',宋体,sans-serif; position: relative; } | 39 | .artpreview fieldset { padding-top: 10px; font-size: 14px; clear: both; overflow: hidden; zoom: 1; line-height: 24px; font-family: 'Times New Roman',宋体,sans-serif; position: relative; } |
40 | .artpreview fieldset legend { padding: 5px 0; display: block; margin: 5px; background: #f1f1f1; color: #000; overflow: hidden; zoom: 1; } | 40 | .artpreview fieldset legend { padding: 5px 0; display: block; margin: 5px; background: #f1f1f1; color: #000; overflow: hidden; zoom: 1; } |
41 | .queserror { border: 1px dotted #f00; padding: 2px; } | 41 | .queserror { border: 1px dotted #f00; padding: 2px; } |
42 | fieldset.quesborder {display: block;padding: 0;line-height: 25px;letter-spacing: 1px;word-break: break-all;margin: 0;} | 42 | fieldset.quesborder {display: block;padding: 0;line-height: 25px;letter-spacing: 1px;word-break: break-all;margin: 0;} |
43 | fieldset.queserror { border: 1px solid #f00; font-size: 12px; padding: 2px; margin-bottom: 1px; } | 43 | fieldset.queserror { border: 1px solid #f00; font-size: 12px; padding: 2px; margin-bottom: 1px; } |
44 | fieldset.quesborder td, fieldset.queserror td { line-height: 16px; } | 44 | fieldset.quesborder td, fieldset.queserror td { line-height: 16px; } |
45 | fieldset.quesborder em, fieldset.queserror em { font-style: normal; font-weight: bold; position: absolute; left: 20px; } | 45 | fieldset.quesborder em, fieldset.queserror em { font-style: normal; font-weight: bold; position: absolute; left: 20px; } |
46 | fieldset.thiserror1 { border: 1px solid #f00; } | 46 | fieldset.thiserror1 { border: 1px solid #f00; } |
47 | fieldset.thiserror1 legend { border: 4px solid #f00; } | 47 | fieldset.thiserror1 legend { border: 4px solid #f00; } |
48 | fieldset.thiserror2 { border: 1px solid #ADCD3C; } | 48 | fieldset.thiserror2 { border: 1px solid #ADCD3C; } |
49 | fieldset.thiserror2 legend { border: 4px solid #ADCD3C; } | 49 | fieldset.thiserror2 legend { border: 4px solid #ADCD3C; } |
50 | fieldset.thisques { border: 1px solid blue; } | 50 | fieldset.thisques { border: 1px solid blue; } |
51 | fieldset.thison { border: 1px solid #A9C9E2; } | 51 | fieldset.thison { border: 1px solid #A9C9E2; } |
52 | fieldset.thison div.border { border: 1px solid #ADCD3C; background-color: #F2FDDB; } | 52 | fieldset.thison div.border { border: 1px solid #ADCD3C; background-color: #F2FDDB; } |
53 | fieldset, img { border: 0 none; } | 53 | fieldset, img { border: 0 none; } |
54 | table.thison { border: 1px solid #00F; } | 54 | table.thison { border: 1px solid #00F; } |
55 | table.thiserr { border: 1px solid #F00; } | 55 | table.thiserr { border: 1px solid #F00; } |
56 | fieldset.thisvip1 { border: 1px solid #00F; } | 56 | fieldset.thisvip1 { border: 1px solid #00F; } |
57 | fieldset.thisvip1 legend { border: 4px solid #00F; } | 57 | fieldset.thisvip1 legend { border: 4px solid #00F; } |
58 | fieldset.status17 { border: 1px solid #ff00ff; } | 58 | fieldset.status17 { border: 1px solid #ff00ff; } |
59 | fieldset.status17 legend { border: 4px solid #ff00ff; } | 59 | fieldset.status17 legend { border: 4px solid #ff00ff; } |
60 | .selectoption { vertical-align: middle; font-size: 14px; padding: 2px; } | 60 | .selectoption { vertical-align: middle; font-size: 14px; padding: 2px; } |
61 | .selectoption:hover { color: #EA8511; } | 61 | .selectoption:hover { color: #EA8511; } |
62 | .selectoption label { padding: 4px; line-height: 24px; } | 62 | .selectoption label { padding: 4px; line-height: 24px; } |
63 | fieldset.quesbordere { border: 2px dotted #f00; } | 63 | fieldset.quesbordere { border: 2px dotted #f00; } |
64 | .answer { border: 1px dotted #ffffff; } | 64 | .answer { border: 1px dotted #ffffff; } |
65 | ol.answer li, ul.answer li { padding: 1px; font-size: 14px; } | 65 | ol.answer li, ul.answer li { padding: 1px; font-size: 14px; } |
66 | ol.answer li:hover { background: #f2f2f2; } | 66 | ol.answer li:hover { background: #f2f2f2; } |
67 | .collapseContainerPanel { border: 0; } | 67 | .collapseContainerPanel { border: 0; } |
68 | .collapsePanelHeader { height: 30px; font-weight: bold; padding: 6px 0 0 0; } | 68 | .collapsePanelHeader { height: 30px; font-weight: bold; padding: 6px 0 0 0; } |
69 | .collapseHeaderContent { float: left; padding-left: 5px; } | 69 | .collapseHeaderContent { float: left; padding-left: 5px; } |
70 | .collapseContent { margin: 0; padding: 0; border: 1px solid #ccc; border-top: 0; } | 70 | .collapseContent { margin: 0; padding: 0; border: 1px solid #ccc; border-top: 0; } |
71 | .pt0 { padding: 2px 0 5px 0; font-size: 14px; font-family: "黑体",sans-serif; font-weight: 700; } | 71 | .pt0 { padding: 2px 0 5px 0; font-size: 14px; font-family: "黑体",sans-serif; font-weight: 700; } |
72 | .pt1 {overflow: hidden;zoom: 1;clear: both;line-height: 25px;font-size: 14px;padding: 20px;position: relative;word-break: break-word;} | 72 | .pt1 {overflow: hidden;zoom: 1;clear: both;line-height: 25px;font-size: 14px;padding: 20px;position: relative;word-break: break-word;} |
73 | fieldset.quesborder .pt1 em { position: static; } | 73 | fieldset.quesborder .pt1 em { position: static; } |
74 | .pt1 img { position: relative; } | 74 | .pt1 img { position: relative; } |
75 | .pt2 {padding: 20px;padding-top: 0;} | 75 | .pt2 {padding: 20px;padding-top: 0;} |
76 | .pt3, .pt4, .pt5, .pt6, .pt7 { clear: both; zoom: 1; position: relative; padding: 0px 20px 20px 80px; } | 76 | .pt3, .pt4, .pt5, .pt6, .pt7 { clear: both; zoom: 1; position: relative; padding: 0px 20px 20px 80px; } |
77 | .pt8 a:link, .pt8 a:visited { margin-right: 10px; padding: 2px 5px; } | 77 | .pt8 a:link, .pt8 a:visited { margin-right: 10px; padding: 2px 5px; } |
78 | .pt8 a:hover { background: #fc0; } | 78 | .pt8 a:hover { background: #fc0; } |
79 | .pt9 { padding: 20px; border: 0 none; color: #999999; font-size: 12px; } | 79 | .pt9 { padding: 20px; border: 0 none; color: #999999; font-size: 12px; } |
80 | .fieldtip {height: 36px;line-height: 36px;background-color: #f4f4f4;border-top: 1px solid #dadada;padding: 0 20px;color: #666666;position: relative;font-size: 12px;border-radius: 0 0 10px 10px;} | 80 | .fieldtip {height: 36px;line-height: 36px;background-color: #f4f4f4;border-top: 1px solid #dadada;padding: 0 20px;color: #666666;position: relative;font-size: 12px;border-radius: 0 0 10px 10px;} |
81 | .newFieldtip .pt1, .newFieldtip .pt2, .newFieldtip .pt3, .newFieldtip .pt4, .newFieldtip .pt5, .newFieldtip .pt6, .newFieldtip .pt7, .newFieldtip .pt8, .newFieldtip.pt9, .newFieldtip + .fieldtip { padding: 0; } | 81 | .newFieldtip .pt1, .newFieldtip .pt2, .newFieldtip .pt3, .newFieldtip .pt4, .newFieldtip .pt5, .newFieldtip .pt6, .newFieldtip .pt7, .newFieldtip .pt8, .newFieldtip.pt9, .newFieldtip + .fieldtip { padding: 0; } |
82 | fieldset img { max-width: 100%; } | 82 | fieldset img { max-width: 100%; } |
83 | 83 | ||
84 | .fieldtip-left {float: left;} | 84 | .fieldtip-left {float: left;} |
85 | .fieldtip-left >* {margin-right: 20px;} | 85 | .fieldtip-left >* {margin-right: 20px;} |
86 | .fieldtip-right { float: right; } | 86 | .fieldtip-right { float: right; } |
87 | .fieldtip-right>* { margin-left: 20px; display: inline-block; color: #666666; } | 87 | .fieldtip-right>* { margin-left: 20px; display: inline-block; color: #666666; } |
88 | .fieldtip .btn {display: inline-block;margin-bottom: 0;font-weight: normal;text-align: center;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;font-size: 14px;border-radius: 4px;color: #ffffff;background-color: #ff8a00;line-height: 18px;min-width: 28px;padding: 0 5px;} | 88 | .fieldtip .btn {display: inline-block;margin-bottom: 0;font-weight: normal;text-align: center;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;font-size: 14px;border-radius: 4px;color: #ffffff;background-color: #ff8a00;line-height: 18px;min-width: 28px;padding: 0 5px;} |
89 | .fieldtip .btn:hover, .fieldtip .btn:active, .fieldtip .btn:active:hover, .fieldtip .btn:hover { color: #ffffff; background-color: #faad4a; } | 89 | .fieldtip .btn:hover, .fieldtip .btn:active, .fieldtip .btn:active:hover, .fieldtip .btn:hover { color: #ffffff; background-color: #faad4a; } |
90 | 90 | ||
91 | /*填空题*/ | 91 | /*填空题*/ |
92 | div.quizPutTag { display: inline-block; *display: inline; padding: 3px 10px 1px 10px; margin: 0 3px; font-size: 14px; min-width: 1em; min-height: 16px; line-height: 18px; height: auto; border-bottom: 1px solid #0033FF; text-decoration: none; zoom: 1; color: #127176; word-break: break-all; } | 92 | div.quizPutTag { display: inline-block; *display: inline; padding: 3px 10px 1px 10px; margin: 0 3px; font-size: 14px; min-width: 1em; min-height: 16px; line-height: 18px; height: auto; border-bottom: 1px solid #0033FF; text-decoration: none; zoom: 1; color: #127176; word-break: break-all; } |
93 | div.quizPutTag:hover { color: #f60; } | 93 | div.quizPutTag:hover { color: #f60; } |
94 | div.quizPutTag img { cursor: pointer; width: 200px; margin-left: 10px; } | 94 | div.quizPutTag img { cursor: pointer; width: 200px; margin-left: 10px; } |
95 | .sanwser { padding: 4px 10px; margin: 0px; border: 1px solid #ADCD3C; background-color: #F2FDDB; color: #000; display: none; } | 95 | .sanwser { padding: 4px 10px; margin: 0px; border: 1px solid #ADCD3C; background-color: #F2FDDB; color: #000; display: none; } |
96 | /*答案*/ | 96 | /*答案*/ |
97 | .selectoption label.s, div.s { border: 1px solid #91cbed; background-color: #deeeff; display: inline-block; } | 97 | .selectoption label.s, div.s { border: 1px solid #91cbed; background-color: #deeeff; display: inline-block; } |
98 | .selectoption label.s.sh, div.s.sh { margin: 1px; border: none; background: none; } | 98 | .selectoption label.s.sh, div.s.sh { margin: 1px; border: none; background: none; } |
99 | del { text-decoration: none; color: #f00; font-style: normal; font-weight: normal; } |
app/src/main/java/com/hjx/parent/ErrorDetailActivity.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.Color; | 4 | import android.graphics.Color; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.os.Handler; | 6 | import android.os.Handler; |
7 | import android.text.Html; | ||
7 | import android.text.TextUtils; | 8 | import android.text.TextUtils; |
8 | import android.view.MotionEvent; | 9 | import android.view.MotionEvent; |
9 | import android.view.View; | 10 | import android.view.View; |
10 | import android.webkit.WebSettings; | 11 | import android.webkit.WebSettings; |
11 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
12 | import android.widget.RadioButton; | 13 | import android.widget.RadioButton; |
13 | import android.widget.RadioGroup; | 14 | import android.widget.RadioGroup; |
14 | 15 | ||
15 | import com.bumptech.glide.Glide; | 16 | import com.bumptech.glide.Glide; |
16 | import com.hjx.parent.databinding.ActivityErrorDetailBinding; | 17 | import com.hjx.parent.databinding.ActivityErrorDetailBinding; |
17 | import com.hjx.parent.dialog.ErrorEditDialog; | 18 | import com.hjx.parent.dialog.ErrorEditDialog; |
18 | import com.prws.common.bean.ErrorDetailBean; | 19 | import com.prws.common.bean.ErrorDetailBean; |
19 | import com.prws.common.bean.ResponseResult; | 20 | import com.prws.common.bean.ResponseResult; |
20 | import com.prws.common.bean.TopicBean; | 21 | import com.prws.common.bean.TopicBean; |
21 | import com.prws.common.net.NetWorks; | 22 | import com.prws.common.net.NetWorks; |
22 | import com.prws.common.utils.CommonUtil; | 23 | import com.prws.common.utils.CommonUtil; |
23 | import com.prws.common.utils.StringUtils; | 24 | import com.prws.common.utils.StringUtils; |
24 | 25 | ||
25 | import java.util.ArrayList; | 26 | import java.util.ArrayList; |
26 | import java.util.HashMap; | 27 | import java.util.HashMap; |
27 | import java.util.List; | 28 | import java.util.List; |
28 | import java.util.Map; | 29 | import java.util.Map; |
29 | 30 | ||
30 | import io.reactivex.Observer; | 31 | import io.reactivex.Observer; |
31 | import io.reactivex.disposables.Disposable; | 32 | import io.reactivex.disposables.Disposable; |
32 | 33 | ||
33 | public class ErrorDetailActivity extends BaseActivity<ActivityErrorDetailBinding> { | 34 | public class ErrorDetailActivity extends BaseActivity<ActivityErrorDetailBinding> { |
34 | private TopicBean bean; | 35 | private TopicBean bean; |
35 | 36 | ||
36 | @Override | 37 | @Override |
37 | public void initView(Bundle savedInstanceState) { | 38 | public void initView(Bundle savedInstanceState) { |
38 | bean = (TopicBean) getIntent().getSerializableExtra("errorBean"); | 39 | bean = (TopicBean) getIntent().getSerializableExtra("errorBean"); |
39 | loadError(); | 40 | loadError(); |
40 | } | 41 | } |
41 | 42 | ||
42 | public void loadError() { | 43 | public void loadError() { |
43 | if (bean.getBean() != null) { | 44 | if (bean.getBean() != null) { |
44 | binding.tvTip.setVisibility(View.GONE); | 45 | binding.tvTip.setVisibility(View.GONE); |
45 | ErrorDetailBean errorDetailBean = bean.getBean(); | 46 | ErrorDetailBean errorDetailBean = bean.getBean(); |
46 | if (TextUtils.isEmpty(errorDetailBean.getContent())) { | 47 | if (TextUtils.isEmpty(errorDetailBean.getContent())) { |
47 | binding.llOrigin.setVisibility(View.GONE); | 48 | binding.llOrigin.setVisibility(View.GONE); |
48 | } else { | 49 | } else { |
49 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; | 50 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; |
50 | StringBuilder sb = new StringBuilder(4096); | 51 | StringBuilder sb = new StringBuilder(4096); |
51 | if (!TextUtils.isEmpty(errorDetailBean.getLabel())) { | 52 | if (!TextUtils.isEmpty(errorDetailBean.getLabel())) { |
52 | sb.append(errorDetailBean.getLabel()); | 53 | sb.append(errorDetailBean.getLabel()); |
53 | } | 54 | } |
54 | sb.append(errorDetailBean.getContent()); | 55 | sb.append(errorDetailBean.getContent()); |
55 | if (errorDetailBean.getOptions() != null && errorDetailBean.getOptions().size() > 0) { | 56 | if (errorDetailBean.getOptions() != null && errorDetailBean.getOptions().size() > 0) { |
56 | sb.append("<div class='pt1'>"); | 57 | sb.append("<div class='pt1'>"); |
57 | sb.append(StringUtils.OptionsHtml(errorDetailBean.getOptions(), null)); | 58 | sb.append(StringUtils.OptionsHtml(errorDetailBean.getOptions(), null)); |
58 | sb.append("</div>"); | 59 | sb.append("</div>"); |
59 | } | 60 | } |
60 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; | 61 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; |
61 | binding.webContent.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); | 62 | binding.webContent.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); |
62 | binding.webContent.setVisibility(View.VISIBLE); | 63 | binding.webContent.setVisibility(View.VISIBLE); |
63 | binding.llOrigin.setVisibility(View.VISIBLE); | 64 | binding.llOrigin.setVisibility(View.VISIBLE); |
64 | binding.webContent.setOnTouchListener(new View.OnTouchListener() { | 65 | binding.webContent.setOnTouchListener(new View.OnTouchListener() { |
65 | @Override | 66 | @Override |
66 | public boolean onTouch(View v, MotionEvent event) { | 67 | public boolean onTouch(View v, MotionEvent event) { |
67 | return true; | 68 | return true; |
68 | } | 69 | } |
69 | }); | 70 | }); |
70 | } | 71 | } |
71 | 72 | ||
72 | if (TextUtils.isEmpty(errorDetailBean.getMethod())) { | 73 | if (TextUtils.isEmpty(errorDetailBean.getMethod())) { |
73 | binding.llAnalyse.setVisibility(View.GONE); | 74 | binding.llAnalyse.setVisibility(View.GONE); |
74 | } else { | 75 | } else { |
75 | binding.llAnalyse.setVisibility(View.VISIBLE); | 76 | binding.llAnalyse.setVisibility(View.VISIBLE); |
76 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; | 77 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; |
77 | String body = "<html><header>" + linkCss + "</header>" + errorDetailBean.getMethod() + "</body></html>"; | 78 | String body = "<html><header>" + linkCss + "</header>" + errorDetailBean.getMethod() + "</body></html>"; |
78 | binding.webAnalyse.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); | 79 | binding.webAnalyse.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); |
79 | binding.webAnalyse.setBackgroundColor(Color.parseColor("#F5F5F5")); | 80 | binding.webAnalyse.setBackgroundColor(Color.parseColor("#F5F5F5")); |
80 | } | 81 | } |
81 | if (TextUtils.isEmpty(errorDetailBean.getDisplayAnswer())) { | 82 | if (TextUtils.isEmpty(errorDetailBean.getDisplayAnswer())) { |
82 | binding.llAnswer.setVisibility(View.GONE); | 83 | binding.llAnswer.setVisibility(View.GONE); |
83 | } else { | 84 | } else { |
84 | binding.llAnswer.setVisibility(View.VISIBLE); | 85 | binding.llAnswer.setVisibility(View.VISIBLE); |
85 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; | 86 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; |
86 | String body = "<html><header>" + linkCss + "</header>" + errorDetailBean.getDisplayAnswer() + "</body></html>"; | 87 | String body = "<html><header>" + linkCss + "</header>" + errorDetailBean.getDisplayAnswer() + "</body></html>"; |
87 | binding.webAnswer.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); | 88 | binding.webAnswer.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); |
88 | binding.webAnswer.setBackgroundColor(Color.parseColor("#F5F5F5")); | 89 | binding.webAnswer.setBackgroundColor(Color.parseColor("#F5F5F5")); |
89 | } | 90 | } |
90 | if (errorDetailBean.getPoints().size() > 0) { | 91 | if (errorDetailBean.getPoints().size() > 0) { |
91 | List<String> points = new ArrayList<>(); | 92 | List<String> points = new ArrayList<>(); |
92 | String topic = ""; | 93 | String topic = ""; |
93 | for (int j = 0; j < errorDetailBean.getPoints().size(); j++) { | 94 | for (int j = 0; j < errorDetailBean.getPoints().size(); j++) { |
94 | if (j > 0) { | 95 | if (j > 0) { |
95 | topic += "、"; | 96 | topic += "、"; |
96 | } | 97 | } |
97 | topic += errorDetailBean.getPoints().get(j).getValue(); | 98 | topic += errorDetailBean.getPoints().get(j).getValue(); |
98 | points.add(errorDetailBean.getPoints().get(j).getKey()); | 99 | points.add(errorDetailBean.getPoints().get(j).getKey()); |
99 | } | 100 | } |
100 | binding.llPoints.setVisibility(View.VISIBLE); | 101 | binding.llPoints.setVisibility(View.VISIBLE); |
101 | binding.tvPoints.setText(topic); | 102 | binding.tvPoints.setText(topic); |
102 | } else { | 103 | } else { |
103 | binding.llPoints.setVisibility(View.GONE); | 104 | binding.llPoints.setVisibility(View.GONE); |
104 | } | 105 | } |
105 | } else { | 106 | } else { |
106 | binding.tvTip.setVisibility(View.VISIBLE); | 107 | binding.tvTip.setVisibility(View.VISIBLE); |
107 | binding.llAnalyse.setVisibility(View.GONE); | 108 | binding.llAnalyse.setVisibility(View.GONE); |
108 | binding.llAnswer.setVisibility(View.GONE); | 109 | binding.llAnswer.setVisibility(View.GONE); |
109 | binding.llOrigin.setVisibility(View.GONE); | 110 | binding.llOrigin.setVisibility(View.GONE); |
110 | binding.llPoints.setVisibility(View.GONE); | 111 | binding.llPoints.setVisibility(View.GONE); |
111 | } | 112 | } |
112 | if (TextUtils.isEmpty(bean.getPath())) { | 113 | if (TextUtils.isEmpty(bean.getPath())) { |
113 | binding.llPic.setVisibility(View.GONE); | 114 | binding.llPic.setVisibility(View.GONE); |
114 | } else { | 115 | } else { |
115 | Glide.with(context).load(bean.getPath()).override(CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 40), CommonUtil.dpToPx(context, 90)).fitCenter().into(binding.ivTopic); | 116 | Glide.with(context).load(bean.getPath()).override(CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 40), CommonUtil.dpToPx(context, 90)).fitCenter().into(binding.ivTopic); |
116 | } | 117 | } |
117 | binding.tvTitle.setText(bean.getName()); | 118 | // binding.tvTitle.setText(bean.getName()); |
118 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(bean.getIsDone()); | 119 | refresh(); |
119 | typeButton.setChecked(true); | ||
120 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | ||
121 | @Override | ||
122 | public void onCheckedChanged(RadioGroup group, int checkedId) { | ||
123 | new Handler().postDelayed(new Runnable() { | ||
124 | @Override | ||
125 | public void run() { | ||
126 | saveError(); | ||
127 | } | ||
128 | }, 1000); | ||
129 | |||
130 | } | ||
131 | }); | ||
132 | binding.spinnerReason.setSelection(bean.getReason()); | ||
133 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
134 | @Override | ||
135 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
136 | saveError(); | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public void onNothingSelected(AdapterView<?> parent) { | ||
141 | |||
142 | } | ||
143 | }); | ||
144 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 120 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
145 | @Override | 121 | @Override |
146 | public void onClick(View v) { | 122 | public void onClick(View v) { |
147 | finish(); | 123 | finish(); |
148 | } | 124 | } |
149 | }); | 125 | }); |
150 | binding.ivEdit.setOnClickListener(new View.OnClickListener() { | 126 | binding.tvEdit.setOnClickListener(new View.OnClickListener() { |
151 | @Override | 127 | @Override |
152 | public void onClick(View v) { | 128 | public void onClick(View v) { |
153 | List<TopicBean> topicBeans = new ArrayList<>(); | 129 | List<TopicBean> topicBeans = new ArrayList<>(); |
154 | topicBeans.add(bean); | 130 | topicBeans.add(bean); |
155 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, topicBeans, new ErrorEditDialog.EditInterface() { | 131 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, topicBeans, new ErrorEditDialog.EditInterface() { |
156 | @Override | 132 | @Override |
157 | public void edit(String name, int reason) { | 133 | public void edit(String name, String grade, String subject, int type, int reason, int done) { |
158 | binding.tvTitle.setText(name); | 134 | // binding.tvTitle.setText(name); |
159 | binding.spinnerReason.setSelection(reason); | 135 | bean.setGrade(grade); |
136 | bean.setSubject(subject); | ||
137 | bean.setType(type); | ||
138 | bean.setDone(done == 0); | ||
139 | bean.setReason(reason); | ||
140 | refresh(); | ||
160 | } | 141 | } |
142 | |||
161 | }); | 143 | }); |
162 | errorEditDialog.show(); | 144 | errorEditDialog.show(); |
163 | } | 145 | } |
164 | }); | 146 | }); |
165 | } | 147 | } |
166 | 148 | ||
167 | public void saveError() { | 149 | private void refresh() { |
168 | int done = 0; | 150 | binding.tvSubject.setText(Html.fromHtml(getString(R.string.topic_subject, bean.getSubject()))); |
169 | for (int i = 0; i < binding.typeRadio.getChildCount(); i++) { | 151 | binding.tvGrade.setText(Html.fromHtml(getString(R.string.topic_grade, bean.getGrade()))); |
170 | RadioButton rb = (RadioButton) binding.typeRadio.getChildAt(i); | 152 | binding.tvReason.setText(Html.fromHtml(getString(R.string.topic_reason, getResources().getStringArray(R.array.error_reason)[bean.getReason()]))); |
171 | if (rb.isChecked()) { | 153 | binding.tvManager.setText(Html.fromHtml(getString(R.string.topic_manager, bean.getIsDone() == 0 ? "已掌握" : "未掌握"))); |
172 | done = i; | 154 | binding.tvType.setText(Html.fromHtml(getString(R.string.topic_type, bean.getType() == 0 ? "课内" : "课外"))); |
173 | } | ||
174 | } | ||
175 | bean.setDone(done == 1); | ||
176 | Map<String, Object> map = new HashMap<>(); | ||
177 | map.put("bookId", bean.getId()); | ||
178 | map.put("controlFlag", done); | ||
179 | map.put("errorReason", binding.spinnerReason.getSelectedItemPosition()); | ||
180 | NetWorks.editError(map, new Observer<ResponseResult>() { | ||
181 | @Override | ||
182 | public void onSubscribe(Disposable d) { | ||
183 | |||
184 | } | ||
185 | |||
186 | @Override | ||
187 | public void onNext(ResponseResult responseResult) { | ||
188 | responseResult.toString(); | ||
189 | } | ||
190 | |||
191 | @Override | ||
192 | public void onError(Throwable e) { | ||
193 | |||
194 | } | ||
195 | |||
196 | @Override | ||
197 | public void onComplete() { | ||
198 | |||
199 | } | ||
200 | }); | ||
201 | } | 155 | } |
app/src/main/java/com/hjx/parent/ErrorListActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.DialogInterface; | 4 | import android.content.DialogInterface; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
8 | import android.graphics.Color; | 8 | import android.graphics.Color; |
9 | import android.graphics.drawable.Drawable; | 9 | import android.graphics.drawable.Drawable; |
10 | import android.net.Uri; | 10 | import android.net.Uri; |
11 | import android.os.Bundle; | 11 | import android.os.Bundle; |
12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.util.Log; | 14 | import android.util.Log; |
15 | import android.view.KeyEvent; | 15 | import android.view.KeyEvent; |
16 | import android.view.LayoutInflater; | 16 | import android.view.LayoutInflater; |
17 | import android.view.View; | 17 | import android.view.View; |
18 | import android.widget.CompoundButton; | 18 | import android.widget.CompoundButton; |
19 | import android.widget.RadioButton; | 19 | import android.widget.RadioButton; |
20 | import android.widget.RadioGroup; | 20 | import android.widget.RadioGroup; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import androidx.annotation.Nullable; | 24 | import androidx.annotation.Nullable; |
25 | import androidx.core.content.FileProvider; | 25 | import androidx.core.content.FileProvider; |
26 | import androidx.recyclerview.widget.GridLayoutManager; | 26 | import androidx.recyclerview.widget.GridLayoutManager; |
27 | import androidx.recyclerview.widget.LinearLayoutManager; | 27 | import androidx.recyclerview.widget.LinearLayoutManager; |
28 | import androidx.recyclerview.widget.RecyclerView; | 28 | import androidx.recyclerview.widget.RecyclerView; |
29 | 29 | ||
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.adapter.ErrorAdapter; | 34 | import com.hjx.parent.adapter.ErrorAdapter; |
35 | import com.hjx.parent.adapter.FilterAdapter; | 35 | import com.hjx.parent.adapter.FilterAdapter; |
36 | import com.hjx.parent.adapter.GradeAdapter; | 36 | import com.hjx.parent.adapter.GradeAdapter; |
37 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; | 37 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; |
38 | import com.hjx.parent.bean.StudentBean; | 38 | import com.hjx.parent.bean.StudentBean; |
39 | import com.hjx.parent.databinding.ActivityErrorListBinding; | 39 | import com.hjx.parent.databinding.ActivityErrorListBinding; |
40 | import com.hjx.parent.dialog.ErrorEditDialog; | 40 | import com.hjx.parent.dialog.ErrorEditDialog; |
41 | import com.hjx.parent.dialog.TipDialog; | 41 | import com.hjx.parent.dialog.TipDialog; |
42 | import com.prws.common.bean.GradeAndSubject; | 42 | import com.prws.common.bean.GradeAndSubject; |
43 | import com.prws.common.bean.PageInfo; | 43 | import com.prws.common.bean.PageInfo; |
44 | import com.prws.common.bean.ResponseResult; | 44 | import com.prws.common.bean.ResponseResult; |
45 | import com.prws.common.bean.Subject; | 45 | import com.prws.common.bean.Subject; |
46 | import com.prws.common.bean.TopicBean; | 46 | import com.prws.common.bean.TopicBean; |
47 | import com.prws.common.net.NetWorks; | 47 | import com.prws.common.net.NetWorks; |
48 | import com.prws.common.utils.BitmapUtils; | 48 | import com.prws.common.utils.BitmapUtils; |
49 | import com.prws.common.utils.CommonUtil; | 49 | import com.prws.common.utils.CommonUtil; |
50 | import com.prws.common.utils.SharedPreferencesUtil; | 50 | import com.prws.common.utils.SharedPreferencesUtil; |
51 | import com.prws.common.utils.dialog.MyButtomDialog; | 51 | import com.prws.common.utils.dialog.MyButtomDialog; |
52 | import com.zhangteng.imagepicker.bean.ImageInfo; | 52 | import com.zhangteng.imagepicker.bean.ImageInfo; |
53 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 53 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
54 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 54 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
55 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 55 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
56 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 56 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
57 | import com.zhangteng.utils.IHandlerCallBack; | 57 | import com.zhangteng.utils.IHandlerCallBack; |
58 | 58 | ||
59 | import java.io.File; | 59 | import java.io.File; |
60 | import java.util.ArrayList; | 60 | import java.util.ArrayList; |
61 | import java.util.HashMap; | 61 | import java.util.HashMap; |
62 | import java.util.List; | 62 | import java.util.List; |
63 | import java.util.Map; | 63 | import java.util.Map; |
64 | 64 | ||
65 | import io.reactivex.Observer; | 65 | import io.reactivex.Observer; |
66 | import io.reactivex.disposables.Disposable; | 66 | import io.reactivex.disposables.Disposable; |
67 | 67 | ||
68 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { | 68 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { |
69 | private TextView last; | 69 | private TextView last; |
70 | private String subject; | 70 | private String subject; |
71 | private String grade; | 71 | private String grade; |
72 | private String grade1; | 72 | private String grade1; |
73 | private String manger; | 73 | private String manger; |
74 | private String type = "全部"; | 74 | private String type = "全部"; |
75 | private String time = "全部"; | 75 | private String time = "全部"; |
76 | private FilterAdapter filterAdapter; | 76 | private FilterAdapter filterAdapter; |
77 | 77 | ||
78 | private GradeAdapter gradeAdapter; | 78 | private GradeAdapter gradeAdapter; |
79 | StudentBean studentBean; | 79 | StudentBean studentBean; |
80 | private int page = 1; | 80 | private int page = 1; |
81 | private ErrorAdapter adapter; | 81 | private ErrorAdapter adapter; |
82 | private int total; | 82 | private int total; |
83 | private int REQUEST_CODE_IMAGE = 123; | 83 | private int REQUEST_CODE_IMAGE = 123; |
84 | private String filePath; | 84 | private String filePath; |
85 | 85 | ||
86 | @Override | 86 | @Override |
87 | public void initView(Bundle savedInstanceState) { | 87 | public void initView(Bundle savedInstanceState) { |
88 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 88 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
89 | try { | 89 | try { |
90 | studentBean = new Gson().fromJson(student, StudentBean.class); | 90 | studentBean = new Gson().fromJson(student, StudentBean.class); |
91 | } catch (Exception e) { | 91 | } catch (Exception e) { |
92 | 92 | ||
93 | } | 93 | } |
94 | binding.ivBack.setOnClickListener(this); | 94 | binding.ivBack.setOnClickListener(this); |
95 | binding.tvFilterGrade.setOnClickListener(this); | 95 | binding.tvFilterGrade.setOnClickListener(this); |
96 | binding.tvFilterSubject.setOnClickListener(this); | 96 | binding.tvFilterSubject.setOnClickListener(this); |
97 | binding.tvFilterMore.setOnClickListener(this); | 97 | binding.tvFilterMore.setOnClickListener(this); |
98 | binding.tvFilterManage.setOnClickListener(this); | 98 | binding.tvFilterManage.setOnClickListener(this); |
99 | binding.tvEdit.setOnClickListener(this); | 99 | binding.tvEdit.setOnClickListener(this); |
100 | binding.tvAdd.setOnClickListener(this); | 100 | binding.tvAdd.setOnClickListener(this); |
101 | binding.llDelete.setOnClickListener(this); | 101 | binding.llDelete.setOnClickListener(this); |
102 | binding.tvSave.setOnClickListener(this); | 102 | binding.tvSave.setOnClickListener(this); |
103 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | 103 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); |
104 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | 104 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
105 | @Override | 105 | @Override |
106 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | 106 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
107 | if (binding.llEmpty.getVisibility() != View.VISIBLE) { | 107 | if (binding.llEmpty.getVisibility() != View.VISIBLE) { |
108 | adapter.checkAll(isChecked); | 108 | adapter.checkAll(isChecked); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | }); | 111 | }); |
112 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); | 112 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); |
113 | timeButton.setChecked(true); | 113 | timeButton.setChecked(true); |
114 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 114 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
115 | @Override | 115 | @Override |
116 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 116 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
117 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 117 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
118 | time = rcheck.getText().toString(); | 118 | time = rcheck.getText().toString(); |
119 | refreshError(); | 119 | refreshError(); |
120 | } | 120 | } |
121 | }); | 121 | }); |
122 | 122 | ||
123 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); | 123 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); |
124 | typeButton.setChecked(true); | 124 | typeButton.setChecked(true); |
125 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 125 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
126 | @Override | 126 | @Override |
127 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 127 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
128 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 128 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
129 | type = rcheck.getText().toString(); | 129 | type = rcheck.getText().toString(); |
130 | refreshError(); | 130 | refreshError(); |
131 | } | 131 | } |
132 | }); | 132 | }); |
133 | refreshError(); | 133 | refreshError(); |
134 | binding.ivChange.setOnClickListener(new View.OnClickListener() { | 134 | binding.ivChange.setOnClickListener(new View.OnClickListener() { |
135 | @Override | 135 | @Override |
136 | public void onClick(View v) { | 136 | public void onClick(View v) { |
137 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { | 137 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { |
138 | Intent intent = new Intent(context, ChooseActivity.class); | 138 | Intent intent = new Intent(context, ChooseActivity.class); |
139 | intent.putExtra("needBack", true); | 139 | intent.putExtra("needBack", true); |
140 | startActivity(intent); | 140 | startActivity(intent); |
141 | } else { | 141 | } else { |
142 | Intent intent = new Intent(context, TeacherChooseActivity.class); | 142 | Intent intent = new Intent(context, TeacherChooseActivity.class); |
143 | intent.putExtra("needBack", true); | 143 | intent.putExtra("needBack", true); |
144 | startActivity(intent); | 144 | startActivity(intent); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | }); | 147 | }); |
148 | setGradeFilter(); | 148 | setGradeFilter(); |
149 | } | 149 | } |
150 | 150 | ||
151 | private void setGradeFilter() { | 151 | private void setGradeFilter() { |
152 | if (TextUtils.isEmpty(grade)) { | 152 | if (TextUtils.isEmpty(grade)) { |
153 | grade = "全部"; | 153 | grade = "全部"; |
154 | } | 154 | } |
155 | List<String> grades = new ArrayList<>(); | 155 | List<String> grades = new ArrayList<>(); |
156 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 156 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
157 | grades.add(gradeAndSubject.getGrade().getGrade()); | 157 | grades.add(gradeAndSubject.getGrade().getGrade()); |
158 | } | 158 | } |
159 | grades.add("全部"); | 159 | grades.add("全部"); |
160 | gradeAdapter = new GradeAdapter(context, new GradeAdapter.Filter() { | 160 | gradeAdapter = new GradeAdapter(context, new GradeAdapter.Filter() { |
161 | @Override | 161 | @Override |
162 | public void onSelect(String select) { | 162 | public void onSelect(String select) { |
163 | grade = select; | 163 | grade = select; |
164 | page = 1; | 164 | page = 1; |
165 | gradeAdapter.refresh(select); | 165 | gradeAdapter.refresh(select); |
166 | refreshError(); | 166 | refreshError(); |
167 | } | 167 | } |
168 | }, grades, grade); | 168 | }, grades, grade); |
169 | binding.recycleGrade.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | 169 | binding.recycleGrade.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); |
170 | binding.recycleGrade.setAdapter(gradeAdapter); | 170 | binding.recycleGrade.setAdapter(gradeAdapter); |
171 | binding.groupGrade.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 171 | binding.groupGrade.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
172 | @Override | 172 | @Override |
173 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 173 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
174 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 174 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
175 | grade1 = rcheck.getText().toString(); | 175 | grade1 = rcheck.getText().toString(); |
176 | page = 1; | 176 | page = 1; |
177 | refreshError(); | 177 | refreshError(); |
178 | } | 178 | } |
179 | }); | 179 | }); |
180 | } | 180 | } |
181 | 181 | ||
182 | @Override | 182 | @Override |
183 | protected ActivityErrorListBinding getViewBinding() { | 183 | protected ActivityErrorListBinding getViewBinding() { |
184 | return ActivityErrorListBinding.inflate(getLayoutInflater()); | 184 | return ActivityErrorListBinding.inflate(getLayoutInflater()); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | @Override | 188 | @Override |
189 | public void onClick(View v) { | 189 | public void onClick(View v) { |
190 | switch (v.getId()) { | 190 | switch (v.getId()) { |
191 | case R.id.iv_back: | 191 | case R.id.iv_back: |
192 | finish(); | 192 | finish(); |
193 | break; | 193 | break; |
194 | case R.id.tv_filter_grade: | 194 | case R.id.tv_filter_grade: |
195 | showFilerGrade(); | 195 | showFilerGrade(); |
196 | break; | 196 | break; |
197 | case R.id.tv_filter_subject: | 197 | case R.id.tv_filter_subject: |
198 | List<String> subjects = new ArrayList<>(); | 198 | List<String> subjects = new ArrayList<>(); |
199 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 199 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
200 | for (Subject subject : gradeAndSubject.getSubjects()) { | 200 | for (Subject subject : gradeAndSubject.getSubjects()) { |
201 | if (!subjects.contains(subject.getSubject())) { | 201 | if (!subjects.contains(subject.getSubject())) { |
202 | subjects.add(subject.getSubject()); | 202 | subjects.add(subject.getSubject()); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | } | 205 | } |
206 | subjects.add("全部"); | 206 | subjects.add("全部"); |
207 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); | 207 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); |
208 | break; | 208 | break; |
209 | case R.id.tv_filter_manage: | 209 | case R.id.tv_filter_manage: |
210 | List<String> manages = new ArrayList<>(); | 210 | List<String> manages = new ArrayList<>(); |
211 | manages.add("已掌握"); | 211 | manages.add("已掌握"); |
212 | manages.add("未掌握"); | 212 | manages.add("未掌握"); |
213 | manages.add("全部"); | 213 | manages.add("全部"); |
214 | setFilterAdapter(manages, binding.tvFilterManage, manger); | 214 | setFilterAdapter(manages, binding.tvFilterManage, manger); |
215 | break; | 215 | break; |
216 | case R.id.tv_filter_more: | 216 | case R.id.tv_filter_more: |
217 | showFilterMore(); | 217 | showFilterMore(); |
218 | break; | 218 | break; |
219 | case R.id.tv_edit: | 219 | case R.id.tv_edit: |
220 | if (adapter.edit) { | 220 | if (adapter.edit) { |
221 | adapter.setEdit(false); | 221 | adapter.setEdit(false); |
222 | binding.tvSave.setVisibility(View.GONE); | 222 | binding.tvSave.setVisibility(View.GONE); |
223 | binding.tvAdd.setVisibility(View.VISIBLE); | 223 | binding.tvAdd.setVisibility(View.VISIBLE); |
224 | binding.checkbox.setVisibility(View.GONE); | 224 | binding.checkbox.setVisibility(View.GONE); |
225 | binding.llDelete.setVisibility(View.GONE); | 225 | binding.llDelete.setVisibility(View.GONE); |
226 | binding.ivBack.setVisibility(View.VISIBLE); | 226 | binding.ivBack.setVisibility(View.VISIBLE); |
227 | binding.tvEdit.setText("编辑"); | 227 | binding.tvEdit.setText("编辑"); |
228 | } else { | 228 | } else { |
229 | adapter.setEdit(true); | 229 | adapter.setEdit(true); |
230 | binding.tvSave.setVisibility(View.VISIBLE); | 230 | binding.tvSave.setVisibility(View.VISIBLE); |
231 | binding.tvAdd.setVisibility(View.GONE); | 231 | binding.tvAdd.setVisibility(View.GONE); |
232 | binding.llDelete.setVisibility(View.VISIBLE); | 232 | binding.llDelete.setVisibility(View.VISIBLE); |
233 | binding.checkbox.setVisibility(View.VISIBLE); | 233 | binding.checkbox.setVisibility(View.VISIBLE); |
234 | binding.ivBack.setVisibility(View.GONE); | 234 | binding.ivBack.setVisibility(View.GONE); |
235 | binding.tvEdit.setText("取消"); | 235 | binding.tvEdit.setText("取消"); |
236 | } | 236 | } |
237 | adapter.notifyDataSetChanged(); | 237 | adapter.notifyDataSetChanged(); |
238 | break; | 238 | break; |
239 | case R.id.ll_delete: | 239 | case R.id.ll_delete: |
240 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { | 240 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { |
241 | @Override | 241 | @Override |
242 | public void onConfirm(Dialog dialog) { | 242 | public void onConfirm(Dialog dialog) { |
243 | deleteError(adapter.getChecKList()); | 243 | deleteError(adapter.getChecKList()); |
244 | dialog.dismiss(); | 244 | dialog.dismiss(); |
245 | } | 245 | } |
246 | 246 | ||
247 | @Override | 247 | @Override |
248 | public void onCancel(Dialog dialog) { | 248 | public void onCancel(Dialog dialog) { |
249 | dialog.dismiss(); | 249 | dialog.dismiss(); |
250 | } | 250 | } |
251 | }); | 251 | }); |
252 | break; | 252 | break; |
253 | case R.id.tv_add: | 253 | case R.id.tv_add: |
254 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { | 254 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { |
255 | XXPermissions.with(context) | 255 | XXPermissions.with(context) |
256 | // 申请多个权限 | 256 | // 申请多个权限 |
257 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) | 257 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) |
258 | .request(new OnPermissionCallback() { | 258 | .request(new OnPermissionCallback() { |
259 | @Override | 259 | @Override |
260 | public void onGranted(List<String> permissions, boolean all) { | 260 | public void onGranted(List<String> permissions, boolean all) { |
261 | if (all) { | 261 | if (all) { |
262 | //开启扫码界面 | 262 | //开启扫码界面 |
263 | showButtonDialog(); | 263 | showButtonDialog(); |
264 | } else { | 264 | } else { |
265 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | 265 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | @Override | 269 | @Override |
270 | public void onDenied(List<String> permissions, boolean never) { | 270 | public void onDenied(List<String> permissions, boolean never) { |
271 | XXPermissions.startPermissionActivity(context, permissions); | 271 | XXPermissions.startPermissionActivity(context, permissions); |
272 | } | 272 | } |
273 | }); | 273 | }); |
274 | } else { | 274 | } else { |
275 | showButtonDialog(); | 275 | showButtonDialog(); |
276 | } | 276 | } |
277 | break; | 277 | break; |
278 | case R.id.tv_save: | 278 | case R.id.tv_save: |
279 | if (adapter.getChecKList().size() > 0) { | 279 | if (adapter.getChecKList().size() > 0) { |
280 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { | 280 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { |
281 | @Override | 281 | @Override |
282 | public void edit(String s, int i) { | 282 | public void edit(String name, String grade, String subject, int type, int reason, int manager) { |
283 | adapter.setEdit(false); | 283 | adapter.setEdit(false); |
284 | binding.tvSave.setVisibility(View.GONE); | 284 | binding.tvSave.setVisibility(View.GONE); |
285 | binding.tvAdd.setVisibility(View.VISIBLE); | 285 | binding.tvAdd.setVisibility(View.VISIBLE); |
286 | binding.checkbox.setVisibility(View.GONE); | 286 | binding.checkbox.setVisibility(View.GONE); |
287 | binding.llDelete.setVisibility(View.GONE); | 287 | binding.llDelete.setVisibility(View.GONE); |
288 | binding.ivBack.setVisibility(View.VISIBLE); | 288 | binding.ivBack.setVisibility(View.VISIBLE); |
289 | binding.tvEdit.setText("编辑"); | 289 | binding.tvEdit.setText("编辑"); |
290 | page = 1; | 290 | page = 1; |
291 | refreshError(); | 291 | refreshError(); |
292 | } | 292 | } |
293 | |||
293 | }); | 294 | }); |
294 | errorEditDialog.show(); | 295 | errorEditDialog.show(); |
295 | } | 296 | } |
296 | break; | 297 | break; |
297 | } | 298 | } |
298 | } | 299 | } |
299 | 300 | ||
300 | private void showButtonDialog() { | 301 | private void showButtonDialog() { |
301 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 302 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
302 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 303 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
303 | dialog.setContentView(bottomView); | 304 | dialog.setContentView(bottomView); |
304 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 305 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
305 | @Override | 306 | @Override |
306 | public void onClick(View view) { | 307 | public void onClick(View view) { |
307 | dialog.dismiss(); | 308 | dialog.dismiss(); |
308 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 309 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
309 | //确保有相机来处理Intent | 310 | //确保有相机来处理Intent |
310 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 311 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
311 | File photoFile = new File(filePath); | 312 | File photoFile = new File(filePath); |
312 | if (photoFile != null) { | 313 | if (photoFile != null) { |
313 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 314 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
314 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 315 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
315 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 316 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
316 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 317 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
317 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 318 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
318 | } | 319 | } |
319 | } | 320 | } |
320 | }); | 321 | }); |
321 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 322 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
322 | @Override | 323 | @Override |
323 | public void onClick(View view) { | 324 | public void onClick(View view) { |
324 | dialog.dismiss(); | 325 | dialog.dismiss(); |
325 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 326 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
326 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 327 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
327 | .multiSelect(true) //是否多选 | 328 | .multiSelect(true) //是否多选 |
328 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 329 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
329 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 330 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
330 | .maxImageSelectable(5) //图片可选择数 | 331 | .maxImageSelectable(5) //图片可选择数 |
331 | .maxHeight(1920) //图片最大高度 | 332 | .maxHeight(1920) //图片最大高度 |
332 | .maxWidth(1920) //图片最大宽度 | 333 | .maxWidth(1920) //图片最大宽度 |
333 | .maxImageSize(3) //图片最大大小Mb | 334 | .maxImageSize(3) //图片最大大小Mb |
334 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | 335 | .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(); |
335 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); | 336 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); |
336 | 337 | ||
337 | } | 338 | } |
338 | }); | 339 | }); |
339 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 340 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
340 | @Override | 341 | @Override |
341 | public void onClick(View view) { | 342 | public void onClick(View view) { |
342 | dialog.dismiss(); | 343 | dialog.dismiss(); |
343 | } | 344 | } |
344 | }); | 345 | }); |
345 | dialog.show(); | 346 | dialog.show(); |
346 | } | 347 | } |
347 | 348 | ||
348 | private void deleteError(List<TopicBean> topicBeans) { | 349 | private void deleteError(List<TopicBean> topicBeans) { |
349 | List<String> list = new ArrayList<>(); | 350 | List<String> list = new ArrayList<>(); |
350 | for (int i = 0; i < topicBeans.size(); i++) { | 351 | for (int i = 0; i < topicBeans.size(); i++) { |
351 | list.add(topicBeans.get(i).getId()); | 352 | list.add(topicBeans.get(i).getId()); |
352 | } | 353 | } |
353 | NetWorks.deleteError(list, new Observer<ResponseResult>() { | 354 | NetWorks.deleteError(list, new Observer<ResponseResult>() { |
354 | @Override | 355 | @Override |
355 | public void onSubscribe(Disposable d) { | 356 | public void onSubscribe(Disposable d) { |
356 | 357 | ||
357 | } | 358 | } |
358 | 359 | ||
359 | @Override | 360 | @Override |
360 | public void onNext(ResponseResult responseResult) { | 361 | public void onNext(ResponseResult responseResult) { |
361 | if (responseResult.getCode() == 200) { | 362 | if (responseResult.getCode() == 200) { |
362 | adapter.setEdit(false); | 363 | adapter.setEdit(false); |
363 | binding.tvSave.setVisibility(View.GONE); | 364 | binding.tvSave.setVisibility(View.GONE); |
364 | binding.tvAdd.setVisibility(View.VISIBLE); | 365 | binding.tvAdd.setVisibility(View.VISIBLE); |
365 | binding.checkbox.setVisibility(View.GONE); | 366 | binding.checkbox.setVisibility(View.GONE); |
366 | binding.llDelete.setVisibility(View.GONE); | 367 | binding.llDelete.setVisibility(View.GONE); |
367 | binding.ivBack.setVisibility(View.VISIBLE); | 368 | binding.ivBack.setVisibility(View.VISIBLE); |
368 | binding.tvEdit.setText("编辑"); | 369 | binding.tvEdit.setText("编辑"); |
369 | page = 1; | 370 | page = 1; |
370 | refreshError(); | 371 | refreshError(); |
371 | } | 372 | } |
372 | } | 373 | } |
373 | 374 | ||
374 | @Override | 375 | @Override |
375 | public void onError(Throwable e) { | 376 | public void onError(Throwable e) { |
376 | 377 | ||
377 | } | 378 | } |
378 | 379 | ||
379 | @Override | 380 | @Override |
380 | public void onComplete() { | 381 | public void onComplete() { |
381 | 382 | ||
382 | } | 383 | } |
383 | }); | 384 | }); |
384 | } | 385 | } |
385 | 386 | ||
386 | private void showFilerGrade() { | 387 | private void showFilerGrade() { |
387 | binding.recycleFilter.setVisibility(View.GONE); | 388 | binding.recycleFilter.setVisibility(View.GONE); |
388 | binding.llFilterMore.setVisibility(View.GONE); | 389 | binding.llFilterMore.setVisibility(View.GONE); |
389 | if (binding.llFilterGrade.getVisibility() == View.VISIBLE) { | 390 | if (binding.llFilterGrade.getVisibility() == View.VISIBLE) { |
390 | binding.llFilterGrade.setVisibility(View.GONE); | 391 | binding.llFilterGrade.setVisibility(View.GONE); |
391 | binding.tvFilterGrade.setTextColor(getColor(R.color.text_title)); | 392 | binding.tvFilterGrade.setTextColor(getColor(R.color.text_title)); |
392 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 393 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
393 | // 这一步必须要做,否则不会显示. | 394 | // 这一步必须要做,否则不会显示. |
394 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 395 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
395 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable, null); | 396 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable, null); |
396 | } else { | 397 | } else { |
397 | binding.llFilterGrade.setVisibility(View.VISIBLE); | 398 | binding.llFilterGrade.setVisibility(View.VISIBLE); |
398 | if (last != null) { | 399 | if (last != null) { |
399 | last.setTextColor(getColor(R.color.text_title)); | 400 | last.setTextColor(getColor(R.color.text_title)); |
400 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 401 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
401 | // 这一步必须要做,否则不会显示. | 402 | // 这一步必须要做,否则不会显示. |
402 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 403 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
403 | last.setCompoundDrawables(null, null, drawable, null); | 404 | last.setCompoundDrawables(null, null, drawable, null); |
404 | } | 405 | } |
405 | binding.tvFilterGrade.setTextColor(Color.parseColor("#1C90F3")); | 406 | binding.tvFilterGrade.setTextColor(Color.parseColor("#1C90F3")); |
406 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 407 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
407 | // 这一步必须要做,否则不会显示. | 408 | // 这一步必须要做,否则不会显示. |
408 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | 409 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); |
409 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable1, null); | 410 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable1, null); |
410 | last = binding.tvFilterGrade; | 411 | last = binding.tvFilterGrade; |
411 | } | 412 | } |
412 | 413 | ||
413 | } | 414 | } |
414 | 415 | ||
415 | private void showFilterMore() { | 416 | private void showFilterMore() { |
416 | binding.recycleFilter.setVisibility(View.GONE); | 417 | binding.recycleFilter.setVisibility(View.GONE); |
417 | binding.llFilterGrade.setVisibility(View.GONE); | 418 | binding.llFilterGrade.setVisibility(View.GONE); |
418 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { | 419 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { |
419 | binding.llFilterMore.setVisibility(View.GONE); | 420 | binding.llFilterMore.setVisibility(View.GONE); |
420 | binding.tvFilterMore.setTextColor(getColor(R.color.text_title)); | 421 | binding.tvFilterMore.setTextColor(getColor(R.color.text_title)); |
421 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 422 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
422 | // 这一步必须要做,否则不会显示. | 423 | // 这一步必须要做,否则不会显示. |
423 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 424 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
424 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable, null); | 425 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable, null); |
425 | } else { | 426 | } else { |
426 | binding.llFilterMore.setVisibility(View.VISIBLE); | 427 | binding.llFilterMore.setVisibility(View.VISIBLE); |
427 | if (last != null) { | 428 | if (last != null) { |
428 | last.setTextColor(getColor(R.color.text_title)); | 429 | last.setTextColor(getColor(R.color.text_title)); |
429 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 430 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
430 | // 这一步必须要做,否则不会显示. | 431 | // 这一步必须要做,否则不会显示. |
431 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 432 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
432 | last.setCompoundDrawables(null, null, drawable, null); | 433 | last.setCompoundDrawables(null, null, drawable, null); |
433 | } | 434 | } |
434 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); | 435 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); |
435 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 436 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
436 | // 这一步必须要做,否则不会显示. | 437 | // 这一步必须要做,否则不会显示. |
437 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | 438 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); |
438 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); | 439 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); |
439 | last = binding.tvFilterMore; | 440 | last = binding.tvFilterMore; |
440 | } | 441 | } |
441 | } | 442 | } |
442 | 443 | ||
443 | private void setFilterAdapter(List<String> list, TextView textView, String select) { | 444 | private void setFilterAdapter(List<String> list, TextView textView, String select) { |
444 | if (TextUtils.isEmpty(select)) { | 445 | if (TextUtils.isEmpty(select)) { |
445 | select = "全部"; | 446 | select = "全部"; |
446 | } | 447 | } |
447 | binding.llFilterGrade.setVisibility(View.GONE); | 448 | binding.llFilterGrade.setVisibility(View.GONE); |
448 | binding.llFilterMore.setVisibility(View.GONE); | 449 | binding.llFilterMore.setVisibility(View.GONE); |
449 | if (last != null && (last.getId() == R.id.tv_filter_more || last.getId() == R.id.tv_filter_grade)) { | 450 | if (last != null && (last.getId() == R.id.tv_filter_more || last.getId() == R.id.tv_filter_grade)) { |
450 | last.setTextColor(getColor(R.color.text_title)); | 451 | last.setTextColor(getColor(R.color.text_title)); |
451 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 452 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
452 | // 这一步必须要做,否则不会显示. | 453 | // 这一步必须要做,否则不会显示. |
453 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 454 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
454 | last.setCompoundDrawables(null, null, drawable, null); | 455 | last.setCompoundDrawables(null, null, drawable, null); |
455 | } | 456 | } |
456 | if (binding.recycleFilter.getVisibility() == View.GONE) { | 457 | if (binding.recycleFilter.getVisibility() == View.GONE) { |
457 | if (filterAdapter != null) { | 458 | if (filterAdapter != null) { |
458 | filterAdapter.refresh(list, textView, select); | 459 | filterAdapter.refresh(list, textView, select); |
459 | } else { | 460 | } else { |
460 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { | 461 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { |
461 | @Override | 462 | @Override |
462 | public void onSelect(TextView type, String select) { | 463 | public void onSelect(TextView type, String select) { |
463 | switch (type.getId()) { | 464 | switch (type.getId()) { |
464 | case R.id.tv_filter_subject: | 465 | case R.id.tv_filter_subject: |
465 | subject = select; | 466 | subject = select; |
466 | break; | 467 | break; |
467 | case R.id.tv_filter_manage: | 468 | case R.id.tv_filter_manage: |
468 | manger = select; | 469 | manger = select; |
469 | break; | 470 | break; |
470 | } | 471 | } |
471 | page = 1; | 472 | page = 1; |
472 | filterAdapter.refresh(select); | 473 | filterAdapter.refresh(select); |
473 | refreshError(); | 474 | refreshError(); |
474 | } | 475 | } |
475 | }, list, textView, select); | 476 | }, list, textView, select); |
476 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | 477 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); |
477 | binding.recycleFilter.setAdapter(filterAdapter); | 478 | binding.recycleFilter.setAdapter(filterAdapter); |
478 | } | 479 | } |
479 | binding.recycleFilter.setVisibility(View.VISIBLE); | 480 | binding.recycleFilter.setVisibility(View.VISIBLE); |
480 | textView.setTextColor(Color.parseColor("#1C90F3")); | 481 | textView.setTextColor(Color.parseColor("#1C90F3")); |
481 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); | 482 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); |
482 | // 这一步必须要做,否则不会显示. | 483 | // 这一步必须要做,否则不会显示. |
483 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 484 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
484 | textView.setCompoundDrawables(null, null, drawable, null); | 485 | textView.setCompoundDrawables(null, null, drawable, null); |
485 | last = textView; | 486 | last = textView; |
486 | } else { | 487 | } else { |
487 | if (textView.getId() == last.getId()) { | 488 | if (textView.getId() == last.getId()) { |
488 | binding.recycleFilter.setVisibility(View.GONE); | 489 | binding.recycleFilter.setVisibility(View.GONE); |
489 | textView.setTextColor(getColor(R.color.text_title)); | 490 | textView.setTextColor(getColor(R.color.text_title)); |
490 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 491 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
491 | // 这一步必须要做,否则不会显示. | 492 | // 这一步必须要做,否则不会显示. |
492 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 493 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
493 | textView.setCompoundDrawables(null, null, drawable, null); | 494 | textView.setCompoundDrawables(null, null, drawable, null); |
494 | } else { | 495 | } else { |
495 | filterAdapter.refresh(list, textView, select); | 496 | filterAdapter.refresh(list, textView, select); |
496 | last.setTextColor(getColor(R.color.text_title)); | 497 | last.setTextColor(getColor(R.color.text_title)); |
497 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 498 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
498 | // 这一步必须要做,否则不会显示. | 499 | // 这一步必须要做,否则不会显示. |
499 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 500 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
500 | last.setCompoundDrawables(null, null, drawable, null); | 501 | last.setCompoundDrawables(null, null, drawable, null); |
501 | textView.setTextColor(Color.parseColor("#1C90F3")); | 502 | textView.setTextColor(Color.parseColor("#1C90F3")); |
502 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 503 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
503 | // 这一步必须要做,否则不会显示. | 504 | // 这一步必须要做,否则不会显示. |
504 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 505 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
505 | textView.setCompoundDrawables(null, null, drawable1, null); | 506 | textView.setCompoundDrawables(null, null, drawable1, null); |
506 | last = textView; | 507 | last = textView; |
507 | } | 508 | } |
508 | } | 509 | } |
509 | } | 510 | } |
510 | 511 | ||
511 | private void refreshError() { | 512 | private void refreshError() { |
512 | Map map = new HashMap(); | 513 | Map map = new HashMap(); |
513 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { | 514 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { |
514 | map.put("subject", subject); | 515 | map.put("subject", subject); |
515 | } | 516 | } |
516 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { | 517 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { |
517 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { | 518 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { |
518 | map.put("grade", grade + grade1); | 519 | map.put("grade", grade + grade1); |
519 | } else { | 520 | } else { |
520 | map.put("grade", grade); | 521 | map.put("grade", grade); |
521 | } | 522 | } |
522 | } else { | 523 | } else { |
523 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { | 524 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { |
524 | map.put("grade", grade1); | 525 | map.put("grade", grade1); |
525 | } | 526 | } |
526 | } | 527 | } |
527 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { | 528 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { |
528 | if ("一周内".equals(time)) { | 529 | if ("一周内".equals(time)) { |
529 | map.put("time", 6); | 530 | map.put("time", 6); |
530 | } else if ("一个月内".equals(time)) { | 531 | } else if ("一个月内".equals(time)) { |
531 | map.put("time", 30); | 532 | map.put("time", 30); |
532 | } else if ("三个月内".equals(time)) { | 533 | } else if ("三个月内".equals(time)) { |
533 | map.put("time", 90); | 534 | map.put("time", 90); |
534 | } | 535 | } |
535 | } | 536 | } |
536 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { | 537 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { |
537 | map.put("type", "课内".equals(type) ? 0 : 1); | 538 | map.put("type", "课内".equals(type) ? 0 : 1); |
538 | } | 539 | } |
539 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { | 540 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { |
540 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); | 541 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); |
541 | } | 542 | } |
542 | map.put("stuId", studentBean.getStuId()); | 543 | map.put("stuId", studentBean.getStuId()); |
543 | map.put("pageSize", 10); | 544 | map.put("pageSize", 10); |
544 | map.put("pageNum", page); | 545 | map.put("pageNum", page); |
545 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 546 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
546 | @Override | 547 | @Override |
547 | public void onSubscribe(Disposable d) { | 548 | public void onSubscribe(Disposable d) { |
548 | 549 | ||
549 | } | 550 | } |
550 | 551 | ||
551 | @Override | 552 | @Override |
552 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 553 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
553 | if (result.getData() != null && result.getCode() == 200) { | 554 | if (result.getData() != null && result.getCode() == 200) { |
554 | total = result.getData().getTotal(); | 555 | total = result.getData().getTotal(); |
555 | List<TopicBean> topicBeans = result.getData().getList(); | 556 | List<TopicBean> topicBeans = result.getData().getList(); |
556 | loadError(topicBeans); | 557 | loadError(topicBeans); |
557 | } | 558 | } |
558 | } | 559 | } |
559 | 560 | ||
560 | @Override | 561 | @Override |
561 | public void onError(Throwable e) { | 562 | public void onError(Throwable e) { |
562 | e.toString(); | 563 | e.toString(); |
563 | } | 564 | } |
564 | 565 | ||
565 | @Override | 566 | @Override |
566 | public void onComplete() { | 567 | public void onComplete() { |
567 | 568 | ||
568 | } | 569 | } |
569 | }); | 570 | }); |
570 | } | 571 | } |
571 | 572 | ||
572 | private void loadError(List<TopicBean> list) { | 573 | private void loadError(List<TopicBean> list) { |
573 | if (list.size() > 0) { | 574 | if (list.size() > 0) { |
574 | binding.recycle.setVisibility(View.VISIBLE); | 575 | binding.recycle.setVisibility(View.VISIBLE); |
575 | binding.llEmpty.setVisibility(View.GONE); | 576 | binding.llEmpty.setVisibility(View.GONE); |
576 | if (adapter != null) { | 577 | if (adapter != null) { |
577 | if (page > 1) { | 578 | if (page > 1) { |
578 | adapter.addData(list); | 579 | adapter.addData(list); |
579 | } else { | 580 | } else { |
580 | adapter.refresh(list); | 581 | adapter.refresh(list); |
581 | } | 582 | } |
582 | } else { | 583 | } else { |
583 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { | 584 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { |
584 | @Override | 585 | @Override |
585 | public void onErrorCheck() { | 586 | public void onErrorCheck() { |
586 | if (adapter.getChecKList().size() > 0) { | 587 | if (adapter.getChecKList().size() > 0) { |
587 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); | 588 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); |
588 | } else { | 589 | } else { |
589 | binding.tvSave.setText("批量修改标签"); | 590 | binding.tvSave.setText("批量修改标签"); |
590 | } | 591 | } |
591 | } | 592 | } |
592 | }); | 593 | }); |
593 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); | 594 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); |
594 | binding.recycle.setLayoutManager(linearLayoutManager); | 595 | binding.recycle.setLayoutManager(linearLayoutManager); |
595 | binding.recycle.setAdapter(adapter); | 596 | binding.recycle.setAdapter(adapter); |
596 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { | 597 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { |
597 | @Override | 598 | @Override |
598 | public void onLoadMore(int currentPage) { | 599 | public void onLoadMore(int currentPage) { |
599 | if (currentPage > page) { | 600 | if (currentPage > page) { |
600 | new Thread(new Runnable() { | 601 | new Thread(new Runnable() { |
601 | @Override | 602 | @Override |
602 | public void run() { | 603 | public void run() { |
603 | try { | 604 | try { |
604 | runOnUiThread(new Runnable() { | 605 | runOnUiThread(new Runnable() { |
605 | @Override | 606 | @Override |
606 | public void run() { | 607 | public void run() { |
607 | if (page * 10 < total) { | 608 | if (page * 10 < total) { |
608 | page++; | 609 | page++; |
609 | refreshError(); | 610 | refreshError(); |
610 | } | 611 | } |
611 | } | 612 | } |
612 | }); | 613 | }); |
613 | } catch (Exception e) { | 614 | } catch (Exception e) { |
614 | e.printStackTrace(); | 615 | e.printStackTrace(); |
615 | } | 616 | } |
616 | } | 617 | } |
617 | }).start(); | 618 | }).start(); |
618 | } | 619 | } |
619 | } | 620 | } |
620 | }); | 621 | }); |
621 | } | 622 | } |
622 | } else { | 623 | } else { |
623 | if (page == 1) { | 624 | if (page == 1) { |
624 | binding.recycle.setVisibility(View.GONE); | 625 | binding.recycle.setVisibility(View.GONE); |
625 | binding.llEmpty.setVisibility(View.VISIBLE); | 626 | binding.llEmpty.setVisibility(View.VISIBLE); |
626 | } | 627 | } |
627 | } | 628 | } |
628 | } | 629 | } |
629 | 630 | ||
630 | @Override | 631 | @Override |
631 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 632 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
632 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 633 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
633 | if (adapter != null && adapter.edit) { | 634 | if (adapter != null && adapter.edit) { |
634 | adapter.setEdit(false); | 635 | adapter.setEdit(false); |
635 | binding.tvSave.setVisibility(View.GONE); | 636 | binding.tvSave.setVisibility(View.GONE); |
636 | binding.tvAdd.setVisibility(View.VISIBLE); | 637 | binding.tvAdd.setVisibility(View.VISIBLE); |
637 | binding.checkbox.setVisibility(View.GONE); | 638 | binding.checkbox.setVisibility(View.GONE); |
638 | binding.llDelete.setVisibility(View.GONE); | 639 | binding.llDelete.setVisibility(View.GONE); |
639 | binding.ivBack.setVisibility(View.VISIBLE); | 640 | binding.ivBack.setVisibility(View.VISIBLE); |
640 | binding.tvEdit.setText("编辑"); | 641 | binding.tvEdit.setText("编辑"); |
641 | adapter.notifyDataSetChanged(); | 642 | adapter.notifyDataSetChanged(); |
642 | } else { | 643 | } else { |
643 | finish(); | 644 | finish(); |
644 | } | 645 | } |
645 | return true; | 646 | return true; |
646 | } | 647 | } |
647 | return super.onKeyDown(keyCode, event); | 648 | return super.onKeyDown(keyCode, event); |
648 | } | 649 | } |
649 | 650 | ||
650 | @Override | 651 | @Override |
651 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 652 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
652 | super.onActivityResult(requestCode, resultCode, data); | 653 | super.onActivityResult(requestCode, resultCode, data); |
653 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 654 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
654 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 655 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
655 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 656 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
656 | CommonUtil.saveBitmapToUri(b, path); | 657 | CommonUtil.saveBitmapToUri(b, path); |
657 | List<String> strings = new ArrayList<>(); | 658 | List<String> strings = new ArrayList<>(); |
658 | Intent intent = new Intent(context, ImageActivity.class); | 659 | Intent intent = new Intent(context, ImageActivity.class); |
659 | strings.add(path); | 660 | strings.add(path); |
660 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 661 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
661 | startActivity(intent); | 662 | startActivity(intent); |
662 | } | 663 | } |
663 | } | 664 | } |
664 | 665 | ||
665 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 666 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
666 | private String TAG = "---ImagePicker---"; | 667 | private String TAG = "---ImagePicker---"; |
667 | List<ImageInfo> photoList = new ArrayList<>(); | 668 | List<ImageInfo> photoList = new ArrayList<>(); |
668 | 669 | ||
669 | @Override | 670 | @Override |
670 | public void onStart() { | 671 | public void onStart() { |
671 | Log.i(TAG, "onStart: 开启"); | 672 | Log.i(TAG, "onStart: 开启"); |
672 | } | 673 | } |
673 | 674 | ||
674 | @Override | 675 | @Override |
675 | public void onSuccess(List<ImageInfo> photoList) { | 676 | public void onSuccess(List<ImageInfo> photoList) { |
676 | this.photoList = photoList; | 677 | this.photoList = photoList; |
677 | Log.i(TAG, "onSuccess: 返回数据"); | 678 | Log.i(TAG, "onSuccess: 返回数据"); |
678 | } | 679 | } |
679 | 680 | ||
680 | @Override | 681 | @Override |
681 | public void onCancel() { | 682 | public void onCancel() { |
682 | Log.i(TAG, "onCancel: 取消"); | 683 | Log.i(TAG, "onCancel: 取消"); |
683 | } | 684 | } |
684 | 685 | ||
685 | @Override | 686 | @Override |
686 | public void onFinish(List<ImageInfo> selectImage) { | 687 | public void onFinish(List<ImageInfo> selectImage) { |
687 | if (selectImage.size() == photoList.size()) { | 688 | if (selectImage.size() == photoList.size()) { |
688 | List<String> strings = new ArrayList<>(); | 689 | List<String> strings = new ArrayList<>(); |
689 | Intent intent = new Intent(context, ImageActivity.class); | 690 | Intent intent = new Intent(context, ImageActivity.class); |
690 | for (ImageInfo imageInfo : selectImage) { | 691 | for (ImageInfo imageInfo : selectImage) { |
691 | strings.add(imageInfo.getPath()); | 692 | strings.add(imageInfo.getPath()); |
692 | } | 693 | } |
693 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 694 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
694 | startActivity(intent); | 695 | startActivity(intent); |
695 | } | 696 | } |
696 | } | 697 | } |
697 | 698 | ||
698 | @Override | 699 | @Override |
699 | public void onError() { | 700 | public void onError() { |
700 | Log.i(TAG, "onError: 出错"); | 701 | Log.i(TAG, "onError: 出错"); |
701 | } | 702 | } |
702 | } | 703 | } |
703 | 704 | ||
704 | @Override | 705 | @Override |
705 | protected void onResume() { | 706 | protected void onResume() { |
706 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 707 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
707 | try { | 708 | try { |
708 | studentBean = new Gson().fromJson(student, StudentBean.class); | 709 | studentBean = new Gson().fromJson(student, StudentBean.class); |
709 | } catch (Exception e) { | 710 | } catch (Exception e) { |
710 | 711 | ||
711 | } | 712 | } |
712 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | 713 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); |
713 | refreshError(); | 714 | refreshError(); |
714 | super.onResume(); | 715 | super.onResume(); |
715 | } | 716 | } |
716 | } | 717 | } |
717 | 718 |
app/src/main/java/com/hjx/parent/ImageActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
6 | import android.graphics.BitmapFactory; | 6 | import android.graphics.BitmapFactory; |
7 | import android.graphics.Rect; | 7 | import android.graphics.Rect; |
8 | import android.net.Uri; | 8 | import android.net.Uri; |
9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
10 | import android.os.Handler; | 10 | import android.os.Handler; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
13 | import android.util.Log; | 13 | import android.util.Log; |
14 | import android.view.KeyEvent; | 14 | import android.view.KeyEvent; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | 16 | ||
17 | 17 | ||
18 | import androidx.annotation.Nullable; | 18 | import androidx.annotation.Nullable; |
19 | import androidx.core.content.FileProvider; | 19 | import androidx.core.content.FileProvider; |
20 | import androidx.viewpager2.widget.ViewPager2; | 20 | import androidx.viewpager2.widget.ViewPager2; |
21 | 21 | ||
22 | import com.google.gson.Gson; | 22 | import com.google.gson.Gson; |
23 | import com.google.gson.JsonObject; | 23 | import com.google.gson.JsonObject; |
24 | import com.hjx.parent.adapter.ImageAdapter; | 24 | import com.hjx.parent.adapter.ImageAdapter; |
25 | import com.hjx.parent.databinding.ActivityImageBinding; | 25 | import com.hjx.parent.databinding.ActivityImageBinding; |
26 | import com.hjx.parent.dialog.ErrorInputDialog; | 26 | import com.hjx.parent.dialog.ErrorInputDialog; |
27 | import com.hjx.parent.dialog.TipDialog; | 27 | import com.hjx.parent.dialog.TipDialog; |
28 | import com.prws.common.bean.CutPicBean; | 28 | import com.prws.common.bean.CutPicBean; |
29 | import com.prws.common.bean.ImageBean; | 29 | import com.prws.common.bean.ImageBean; |
30 | import com.prws.common.bean.TopicBean; | 30 | import com.prws.common.bean.TopicBean; |
31 | import com.prws.common.net.NetWorks; | 31 | import com.prws.common.net.NetWorks; |
32 | import com.prws.common.utils.BitmapUtils; | 32 | import com.prws.common.utils.BitmapUtils; |
33 | import com.prws.common.utils.CommonUtil; | 33 | import com.prws.common.utils.CommonUtil; |
34 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; | 34 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; |
35 | 35 | ||
36 | import java.io.File; | 36 | import java.io.File; |
37 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
38 | import java.util.List; | 38 | import java.util.List; |
39 | 39 | ||
40 | import io.reactivex.Observer; | 40 | import io.reactivex.Observer; |
41 | import io.reactivex.disposables.Disposable; | 41 | import io.reactivex.disposables.Disposable; |
42 | import retrofit2.Call; | 42 | import retrofit2.Call; |
43 | import retrofit2.Callback; | 43 | import retrofit2.Callback; |
44 | import retrofit2.Response; | 44 | import retrofit2.Response; |
45 | 45 | ||
46 | public class ImageActivity extends BaseActivity<ActivityImageBinding> implements View.OnClickListener { | 46 | public class ImageActivity extends BaseActivity<ActivityImageBinding> implements View.OnClickListener { |
47 | 47 | ||
48 | private List<String> images = new ArrayList<>(); | 48 | private List<String> images = new ArrayList<>(); |
49 | private ImageAdapter imageAdapter; | 49 | private ImageAdapter imageAdapter; |
50 | private List<ImageBean> list = new ArrayList<>(); | 50 | private List<ImageBean> list = new ArrayList<>(); |
51 | private String filePath; | 51 | private String filePath; |
52 | 52 | ||
53 | @Override | 53 | @Override |
54 | public void initView(Bundle savedInstanceState) { | 54 | public void initView(Bundle savedInstanceState) { |
55 | images = getIntent().getStringArrayListExtra("images"); | 55 | images = getIntent().getStringArrayListExtra("images"); |
56 | for (String s : images) { | 56 | for (String s : images) { |
57 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 57 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
58 | ImageBean imageBean = new ImageBean(); | 58 | ImageBean imageBean = new ImageBean(); |
59 | Bitmap bitmap = BitmapUtils.getimage(s); | 59 | Bitmap bitmap = BitmapUtils.getimage(s); |
60 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 60 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
61 | imageBean.setPath(filepath); | 61 | imageBean.setPath(filepath); |
62 | list.add(imageBean); | 62 | list.add(imageBean); |
63 | } | 63 | } |
64 | imageAdapter = new ImageAdapter(this, list); | 64 | imageAdapter = new ImageAdapter(this, list); |
65 | binding.viewPager.setAdapter(imageAdapter); | 65 | binding.viewPager.setAdapter(imageAdapter); |
66 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 66 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
67 | @Override | 67 | @Override |
68 | public void onPageSelected(int position) { | 68 | public void onPageSelected(int position) { |
69 | if (list.get(position).getCuts() == null) { | 69 | if (list.get(position).getCuts() == null) { |
70 | // binding.ivPrevious.setEnabled(false); | 70 | // binding.ivPrevious.setEnabled(false); |
71 | // binding.ivNext.setEnabled(false); | 71 | // binding.ivNext.setEnabled(false); |
72 | clearText(); | 72 | clearText(); |
73 | } | 73 | } |
74 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 74 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
75 | if (position == 0) { | 75 | if (position == 0) { |
76 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); | 76 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); |
77 | // binding.ivPrevious.setEnabled(true); | 77 | // binding.ivPrevious.setEnabled(true); |
78 | } else { | 78 | } else { |
79 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); | 79 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); |
80 | // binding.ivPrevious.setEnabled(false); | 80 | // binding.ivPrevious.setEnabled(false); |
81 | } | 81 | } |
82 | if (position == list.size() - 1) { | 82 | if (position == list.size() - 1) { |
83 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); | 83 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); |
84 | // binding.ivNext.setEnabled(true); | 84 | // binding.ivNext.setEnabled(true); |
85 | } else { | 85 | } else { |
86 | binding.ivNext.setImageResource(R.mipmap.ic_next); | 86 | binding.ivNext.setImageResource(R.mipmap.ic_next); |
87 | // binding.ivNext.setEnabled(false); | 87 | // binding.ivNext.setEnabled(false); |
88 | } | 88 | } |
89 | super.onPageSelected(position); | 89 | super.onPageSelected(position); |
90 | } | 90 | } |
91 | }); | 91 | }); |
92 | binding.ivNext.setOnClickListener(this); | 92 | binding.ivNext.setOnClickListener(this); |
93 | binding.ivPrevious.setOnClickListener(this); | 93 | binding.ivPrevious.setOnClickListener(this); |
94 | binding.ivBack.setOnClickListener(this); | 94 | binding.ivBack.setOnClickListener(this); |
95 | binding.tvPhoto.setOnClickListener(this); | 95 | binding.tvPhoto.setOnClickListener(this); |
96 | binding.tvAdd.setOnClickListener(this); | 96 | binding.tvAdd.setOnClickListener(this); |
97 | binding.llEdit.setOnClickListener(this); | 97 | binding.llEdit.setOnClickListener(this); |
98 | binding.tvSave.setOnClickListener(this); | 98 | binding.tvSave.setOnClickListener(this); |
99 | } | 99 | } |
100 | 100 | ||
101 | public void clearText() { | 101 | public void clearText() { |
102 | int index = binding.viewPager.getCurrentItem(); | 102 | int index = binding.viewPager.getCurrentItem(); |
103 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { | 103 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { |
104 | @Override | 104 | @Override |
105 | public void dimiss() { | 105 | public void dimiss() { |
106 | // binding.ivPrevious.setEnabled(index != 0); | 106 | // binding.ivPrevious.setEnabled(index != 0); |
107 | // binding.ivNext.setEnabled(index != list.size() - 1); | 107 | // binding.ivNext.setEnabled(index != list.size() - 1); |
108 | } | 108 | } |
109 | }); | 109 | }); |
110 | Log.i("clearText", list.get(index).getPath()); | 110 | Log.i("clearText", list.get(index).getPath()); |
111 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); | 111 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); |
112 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { | 112 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { |
113 | @Override | 113 | @Override |
114 | public void onSubscribe(Disposable d) { | 114 | public void onSubscribe(Disposable d) { |
115 | 115 | ||
116 | } | 116 | } |
117 | 117 | ||
118 | @Override | 118 | @Override |
119 | public void onNext(JsonObject jsonObject) { | 119 | public void onNext(JsonObject jsonObject) { |
120 | if (jsonObject != null && jsonObject.get("image_processed") != null) { | 120 | if (jsonObject != null && jsonObject.get("image_processed") != null) { |
121 | String image = jsonObject.get("image_processed").getAsString(); | 121 | String image = jsonObject.get("image_processed").getAsString(); |
122 | if (image != null) { | 122 | if (image != null) { |
123 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 123 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
124 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); | 124 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); |
125 | list.get(index).setPath(filepath); | 125 | list.get(index).setPath(filepath); |
126 | imageAdapter.notifyItemChanged(index); | 126 | imageAdapter.notifyItemChanged(index); |
127 | cut(filepath); | 127 | cut(filepath); |
128 | } else { | 128 | } else { |
129 | loadFail("去除字迹失败"); | 129 | loadFail("去除字迹失败"); |
130 | } | 130 | } |
131 | } else { | 131 | } else { |
132 | loadFail("去除字迹失败"); | 132 | loadFail("去除字迹失败"); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | @Override | 136 | @Override |
137 | public void onError(Throwable e) { | 137 | public void onError(Throwable e) { |
138 | loadFail("去除字迹失败"); | 138 | loadFail("去除字迹失败"); |
139 | } | 139 | } |
140 | 140 | ||
141 | @Override | 141 | @Override |
142 | public void onComplete() { | 142 | public void onComplete() { |
143 | 143 | ||
144 | } | 144 | } |
145 | }); | 145 | }); |
146 | } | 146 | } |
147 | 147 | ||
148 | public void cut(String path) { | 148 | public void cut(String path) { |
149 | String base64 = BitmapUtils.imageToBase64(path); | 149 | String base64 = BitmapUtils.imageToBase64(path); |
150 | Log.i("figLoaction", path); | 150 | Log.i("figLoaction", path); |
151 | NetWorks.cut(base64, new Observer<CutPicBean>() { | 151 | NetWorks.cut(base64, new Observer<CutPicBean>() { |
152 | @Override | 152 | @Override |
153 | public void onSubscribe(Disposable d) { | 153 | public void onSubscribe(Disposable d) { |
154 | 154 | ||
155 | } | 155 | } |
156 | 156 | ||
157 | @Override | 157 | @Override |
158 | public void onNext(CutPicBean cutPicBean) { | 158 | public void onNext(CutPicBean cutPicBean) { |
159 | if (cutPicBean != null) { | 159 | if (cutPicBean != null) { |
160 | if (cutPicBean.getDirection() != 0) { | 160 | if (cutPicBean.getDirection() != 0) { |
161 | rotatingImage(cutPicBean); | 161 | rotatingImage(cutPicBean); |
162 | } else { | 162 | } else { |
163 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 163 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
164 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 164 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
165 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 165 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
166 | figLoactions.add(cutLocation.getFig_location()); | 166 | figLoactions.add(cutLocation.getFig_location()); |
167 | } | 167 | } |
168 | new Handler().postDelayed(new Runnable() { | 168 | new Handler().postDelayed(new Runnable() { |
169 | @Override | 169 | @Override |
170 | public void run() { | 170 | public void run() { |
171 | getRects(figLoactions); | 171 | getRects(figLoactions); |
172 | } | 172 | } |
173 | }, 1000); | 173 | }, 1000); |
174 | } else { | 174 | } else { |
175 | cancelLoadingDialog(); | 175 | cancelLoadingDialog(); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } else { | 178 | } else { |
179 | loadFail("自动切题失败"); | 179 | loadFail("自动切题失败"); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | @Override | 183 | @Override |
184 | public void onError(Throwable e) { | 184 | public void onError(Throwable e) { |
185 | loadFail("自动切题失败"); | 185 | loadFail("自动切题失败"); |
186 | } | 186 | } |
187 | 187 | ||
188 | @Override | 188 | @Override |
189 | public void onComplete() { | 189 | public void onComplete() { |
190 | 190 | ||
191 | } | 191 | } |
192 | }); | 192 | }); |
193 | } | 193 | } |
194 | 194 | ||
195 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { | 195 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { |
196 | Log.i("figLoaction", new Gson().toJson(figLoactions)); | 196 | Log.i("figLoaction", new Gson().toJson(figLoactions)); |
197 | int index = binding.viewPager.getCurrentItem(); | 197 | int index = binding.viewPager.getCurrentItem(); |
198 | List<ImageBean.Cut> cuts = new ArrayList<>(); | 198 | List<ImageBean.Cut> cuts = new ArrayList<>(); |
199 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { | 199 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { |
200 | ImageBean.Cut cut = new ImageBean.Cut(); | 200 | ImageBean.Cut cut = new ImageBean.Cut(); |
201 | cut.setRect(figLoaction); | 201 | cut.setRect(figLoaction); |
202 | cut.setSelect(false); | 202 | cut.setSelect(false); |
203 | cuts.add(cut); | 203 | cuts.add(cut); |
204 | } | 204 | } |
205 | list.get(index).setCuts(cuts); | 205 | list.get(index).setCuts(cuts); |
206 | imageAdapter.notifyItemChanged(index); | 206 | imageAdapter.notifyItemChanged(index); |
207 | cancelLoadingDialog(); | 207 | cancelLoadingDialog(); |
208 | } | 208 | } |
209 | 209 | ||
210 | private void rotatingImage(CutPicBean cutPicBean) { | 210 | private void rotatingImage(CutPicBean cutPicBean) { |
211 | int index = binding.viewPager.getCurrentItem(); | 211 | int index = binding.viewPager.getCurrentItem(); |
212 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); | 212 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); |
213 | int angle = 0; | 213 | int angle = 0; |
214 | switch (cutPicBean.getDirection()) { | 214 | switch (cutPicBean.getDirection()) { |
215 | case 1: | 215 | case 1: |
216 | angle = 90; | 216 | angle = 90; |
217 | break; | 217 | break; |
218 | case 2: | 218 | case 2: |
219 | angle = 180; | 219 | angle = 180; |
220 | break; | 220 | break; |
221 | case 3: | 221 | case 3: |
222 | angle = 270; | 222 | angle = 270; |
223 | break; | 223 | break; |
224 | } | 224 | } |
225 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 225 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
226 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 226 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
227 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 227 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
228 | figLoactions.add(cutLocation.getFig_location()); | 228 | figLoactions.add(cutLocation.getFig_location()); |
229 | } | 229 | } |
230 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); | 230 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); |
231 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); | 231 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); |
232 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 232 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
233 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 233 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
234 | list.get(index).setPath(filepath); | 234 | list.get(index).setPath(filepath); |
235 | imageAdapter.notifyItemChanged(index); | 235 | imageAdapter.notifyItemChanged(index); |
236 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; | 236 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; |
237 | new Handler().postDelayed(new Runnable() { | 237 | new Handler().postDelayed(new Runnable() { |
238 | @Override | 238 | @Override |
239 | public void run() { | 239 | public void run() { |
240 | getRects(finalFigLoactions); | 240 | getRects(finalFigLoactions); |
241 | } | 241 | } |
242 | }, 500); | 242 | }, 500); |
243 | } else { | 243 | } else { |
244 | cancelLoadingDialog(); | 244 | cancelLoadingDialog(); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | @Override | 248 | @Override |
249 | protected ActivityImageBinding getViewBinding() { | 249 | protected ActivityImageBinding getViewBinding() { |
250 | return ActivityImageBinding.inflate(getLayoutInflater()); | 250 | return ActivityImageBinding.inflate(getLayoutInflater()); |
251 | } | 251 | } |
252 | 252 | ||
253 | public void refreshNum() { | 253 | public void refreshNum() { |
254 | int num = 0; | 254 | int num = 0; |
255 | for (ImageBean imageBean : list) { | 255 | for (ImageBean imageBean : list) { |
256 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 256 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
257 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 257 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
258 | if (cut.isSelect()) { | 258 | if (cut.isSelect()) { |
259 | num++; | 259 | num++; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } | 263 | } |
264 | if (num > 0) { | 264 | if (num > 0) { |
265 | binding.tvSave.setEnabled(true); | 265 | binding.tvSave.setEnabled(true); |
266 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); | 266 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); |
267 | binding.tvSave.setText("保留错题(" + num + ")"); | 267 | binding.tvSave.setText("保存错题(" + num + ")"); |
268 | } else { | 268 | } else { |
269 | binding.tvSave.setEnabled(false); | 269 | binding.tvSave.setEnabled(false); |
270 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); | 270 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); |
271 | binding.tvSave.setText("保留错题"); | 271 | binding.tvSave.setText("保存错题"); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | @Override | 275 | @Override |
276 | public void onClick(View v) { | 276 | public void onClick(View v) { |
277 | switch (v.getId()) { | 277 | switch (v.getId()) { |
278 | case R.id.iv_back: | 278 | case R.id.iv_back: |
279 | back(); | 279 | back(); |
280 | break; | 280 | break; |
281 | case R.id.iv_next: | 281 | case R.id.iv_next: |
282 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { | 282 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { |
283 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); | 283 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); |
284 | } | 284 | } |
285 | break; | 285 | break; |
286 | case R.id.iv_previous: | 286 | case R.id.iv_previous: |
287 | if (binding.viewPager.getCurrentItem() != 0) { | 287 | if (binding.viewPager.getCurrentItem() != 0) { |
288 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); | 288 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); |
289 | } | 289 | } |
290 | break; | 290 | break; |
291 | case R.id.ll_edit: | 291 | case R.id.ll_edit: |
292 | Intent intent = new Intent(context, ImageEditActivity.class); | 292 | Intent intent = new Intent(context, ImageEditActivity.class); |
293 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 293 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
294 | startActivityForResult(intent, 1001); | 294 | startActivityForResult(intent, 1001); |
295 | break; | 295 | break; |
296 | case R.id.tv_photo: | 296 | case R.id.tv_photo: |
297 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 297 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
298 | //确保有相机来处理Intent | 298 | //确保有相机来处理Intent |
299 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 299 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
300 | File photoFile = new File(filePath); | 300 | File photoFile = new File(filePath); |
301 | if (photoFile != null) { | 301 | if (photoFile != null) { |
302 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 302 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
303 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 303 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
304 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 304 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
305 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 305 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
306 | activity.startActivityForResult(takePictureIntent, 1002); | 306 | activity.startActivityForResult(takePictureIntent, 1002); |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | case R.id.tv_add: | 309 | case R.id.tv_add: |
310 | Intent intent1 = new Intent(context, ImageSelectActivity.class); | 310 | Intent intent1 = new Intent(context, ImageSelectActivity.class); |
311 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 311 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
312 | startActivityForResult(intent1, 1001); | 312 | startActivityForResult(intent1, 1001); |
313 | break; | 313 | break; |
314 | case R.id.tv_save: | 314 | case R.id.tv_save: |
315 | List<TopicBean> topicBeans = new ArrayList<>(); | 315 | List<TopicBean> topicBeans = new ArrayList<>(); |
316 | for (ImageBean imageBean : list) { | 316 | for (ImageBean imageBean : list) { |
317 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 317 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
318 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 318 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
319 | if (cut.isSelect()) { | 319 | if (cut.isSelect()) { |
320 | TopicBean bean = new TopicBean(); | 320 | TopicBean bean = new TopicBean(); |
321 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 321 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
322 | BitmapUtils.saveBitmap(cut.getBitmap(), path); | 322 | BitmapUtils.saveBitmap(cut.getBitmap(), path); |
323 | bean.setPath(path); | 323 | bean.setPath(path); |
324 | topicBeans.add(bean); | 324 | topicBeans.add(bean); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | } | 327 | } |
328 | } | 328 | } |
329 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); | 329 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); |
330 | dialog.show(); | 330 | dialog.show(); |
331 | break; | 331 | break; |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | @Override | 335 | @Override |
336 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 336 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
337 | super.onActivityResult(requestCode, resultCode, data); | 337 | super.onActivityResult(requestCode, resultCode, data); |
338 | if (requestCode == 1001) { | 338 | if (requestCode == 1001) { |
339 | if (resultCode == 1002) { | 339 | if (resultCode == 1002) { |
340 | if (list.size() > 1) { | 340 | if (list.size() > 1) { |
341 | list.remove(binding.viewPager.getCurrentItem()); | 341 | list.remove(binding.viewPager.getCurrentItem()); |
342 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); | 342 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); |
343 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 343 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
344 | refreshNum(); | 344 | refreshNum(); |
345 | } else { | 345 | } else { |
346 | finish(); | 346 | finish(); |
347 | } | 347 | } |
348 | } else if (resultCode == 1003) { | 348 | } else if (resultCode == 1003) { |
349 | int position = binding.viewPager.getCurrentItem(); | 349 | int position = binding.viewPager.getCurrentItem(); |
350 | list.remove(position); | 350 | list.remove(position); |
351 | String path = data.getStringExtra("path"); | 351 | String path = data.getStringExtra("path"); |
352 | ImageBean imageBean = new ImageBean(); | 352 | ImageBean imageBean = new ImageBean(); |
353 | imageBean.setPath(path); | 353 | imageBean.setPath(path); |
354 | list.add(position, imageBean); | 354 | list.add(position, imageBean); |
355 | imageAdapter.notifyItemChanged(position); | 355 | imageAdapter.notifyItemChanged(position); |
356 | clearText(); | 356 | clearText(); |
357 | refreshNum(); | 357 | refreshNum(); |
358 | } else if (resultCode == 1004) { | 358 | } else if (resultCode == 1004) { |
359 | Rect rect = data.getParcelableExtra("cut"); | 359 | Rect rect = data.getParcelableExtra("cut"); |
360 | if (rect != null) { | 360 | if (rect != null) { |
361 | int position = binding.viewPager.getCurrentItem(); | 361 | int position = binding.viewPager.getCurrentItem(); |
362 | ImageBean.Cut cut = new ImageBean.Cut(); | 362 | ImageBean.Cut cut = new ImageBean.Cut(); |
363 | cut.setRect1(rect); | 363 | cut.setRect1(rect); |
364 | cut.setSelect(false); | 364 | cut.setSelect(false); |
365 | list.get(position).getCuts().add(cut); | 365 | if (list.get(position).getCuts() != null) { |
366 | list.get(position).getCuts().add(cut); | ||
367 | } else { | ||
368 | List<ImageBean.Cut> cuts =new ArrayList<>(); | ||
369 | cuts.add(cut); | ||
370 | list.get(position).setCuts(cuts); | ||
371 | } | ||
366 | imageAdapter.notifyItemChanged(position); | 372 | imageAdapter.notifyItemChanged(position); |
367 | refreshNum(); | 373 | refreshNum(); |
368 | } | 374 | } |
369 | } else if (resultCode == 1005) { | 375 | } else if (resultCode == 1005) { |
370 | int i = data.getIntExtra("position", 0); | 376 | int i = data.getIntExtra("position", 0); |
371 | int position = binding.viewPager.getCurrentItem(); | 377 | int position = binding.viewPager.getCurrentItem(); |
372 | Rect rect = data.getParcelableExtra("cut"); | 378 | Rect rect = data.getParcelableExtra("cut"); |
373 | if (rect != null) { | 379 | if (rect != null) { |
374 | ImageBean.Cut cut = new ImageBean.Cut(); | 380 | ImageBean.Cut cut = new ImageBean.Cut(); |
375 | cut.setRect1(rect); | 381 | cut.setRect1(rect); |
376 | cut.setSelect(false); | 382 | cut.setSelect(false); |
377 | list.get(position).getCuts().remove(i); | 383 | list.get(position).getCuts().remove(i); |
378 | list.get(position).getCuts().add(i, cut); | 384 | list.get(position).getCuts().add(i, cut); |
379 | imageAdapter.notifyItemChanged(position); | 385 | imageAdapter.notifyItemChanged(position); |
380 | refreshNum(); | 386 | refreshNum(); |
381 | } else { | 387 | } else { |
382 | list.get(position).getCuts().remove(i); | 388 | list.get(position).getCuts().remove(i); |
383 | imageAdapter.notifyItemChanged(position); | 389 | imageAdapter.notifyItemChanged(position); |
384 | refreshNum(); | 390 | refreshNum(); |
385 | } | 391 | } |
386 | } | 392 | } |
387 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 393 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
388 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 394 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
389 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 395 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
390 | CommonUtil.saveBitmapToUri(b, path); | 396 | CommonUtil.saveBitmapToUri(b, path); |
391 | int position = binding.viewPager.getCurrentItem(); | 397 | int position = binding.viewPager.getCurrentItem(); |
392 | list.remove(position); | 398 | list.remove(position); |
393 | ImageBean imageBean = new ImageBean(); | 399 | ImageBean imageBean = new ImageBean(); |
394 | imageBean.setPath(path); | 400 | imageBean.setPath(path); |
395 | list.add(position, imageBean); | 401 | list.add(position, imageBean); |
396 | imageAdapter.notifyItemChanged(position); | 402 | imageAdapter.notifyItemChanged(position); |
397 | clearText(); | 403 | clearText(); |
398 | refreshNum(); | 404 | refreshNum(); |
399 | } | 405 | } |
400 | } | 406 | } |
401 | 407 | ||
402 | private void back() { | 408 | private void back() { |
403 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { | 409 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { |
404 | @Override | 410 | @Override |
405 | public void onConfirm(Dialog dialog) { | 411 | public void onConfirm(Dialog dialog) { |
406 | dialog.dismiss(); | 412 | dialog.dismiss(); |
407 | finish(); | 413 | finish(); |
408 | } | 414 | } |
409 | 415 | ||
410 | @Override | 416 | @Override |
411 | public void onCancel(Dialog dialog) { | 417 | public void onCancel(Dialog dialog) { |
412 | dialog.dismiss(); | 418 | dialog.dismiss(); |
413 | } | 419 | } |
414 | }); | 420 | }); |
415 | } | 421 | } |
416 | 422 | ||
417 | @Override | 423 | @Override |
418 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 424 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
419 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 425 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
420 | back(); | 426 | back(); |
421 | return true; | 427 | return true; |
422 | } | 428 | } |
423 | return super.onKeyDown(keyCode, event); | 429 | return super.onKeyDown(keyCode, event); |
424 | } | 430 | } |
425 | } | 431 | } |
426 | 432 |
app/src/main/java/com/hjx/parent/LoginActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.telephony.PhoneNumberUtils; | 5 | import android.telephony.PhoneNumberUtils; |
6 | import android.text.InputType; | 6 | import android.text.InputType; |
7 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
8 | import android.text.method.HideReturnsTransformationMethod; | 8 | import android.text.method.HideReturnsTransformationMethod; |
9 | import android.text.method.PasswordTransformationMethod; | 9 | import android.text.method.PasswordTransformationMethod; |
10 | import android.widget.Button; | 10 | import android.widget.Button; |
11 | import android.widget.CheckBox; | 11 | import android.widget.CheckBox; |
12 | import android.widget.EditText; | 12 | import android.widget.EditText; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | import android.widget.TextView; | 14 | import android.widget.TextView; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import androidx.appcompat.app.AppCompatActivity; | 17 | import androidx.appcompat.app.AppCompatActivity; |
18 | 18 | ||
19 | import com.prws.common.base.BaseActivity; | 19 | import com.prws.common.base.BaseActivity; |
20 | import com.prws.common.base.BasePresenter; | 20 | import com.prws.common.base.BasePresenter; |
21 | import com.prws.common.bean.BaseEntity; | 21 | import com.prws.common.bean.BaseEntity; |
22 | import com.prws.common.net.NetWorks; | 22 | import com.prws.common.net.NetWorks; |
23 | import com.prws.common.utils.LogUtil; | 23 | import com.prws.common.utils.LogUtil; |
24 | import com.prws.common.utils.SharedPreferencesUtil; | 24 | import com.prws.common.utils.SharedPreferencesUtil; |
25 | import com.prws.common.utils.acmanager.ActivityManager; | 25 | import com.prws.common.utils.acmanager.ActivityManager; |
26 | 26 | ||
27 | import org.json.JSONObject; | 27 | import org.json.JSONObject; |
28 | 28 | ||
29 | import java.io.IOException; | 29 | import java.io.IOException; |
30 | import java.util.HashMap; | 30 | import java.util.HashMap; |
31 | import java.util.Map; | 31 | import java.util.Map; |
32 | 32 | ||
33 | import io.reactivex.Observer; | 33 | import io.reactivex.Observer; |
34 | import io.reactivex.disposables.Disposable; | 34 | import io.reactivex.disposables.Disposable; |
35 | import okhttp3.ResponseBody; | 35 | import okhttp3.ResponseBody; |
36 | 36 | ||
37 | 37 | ||
38 | public class LoginActivity extends BaseActivity { | 38 | public class LoginActivity extends BaseActivity { |
39 | 39 | ||
40 | 40 | ||
41 | EditText et_phone; | 41 | EditText et_phone; |
42 | EditText et_pwd; | 42 | EditText et_pwd; |
43 | ImageView iv_show; | 43 | ImageView iv_show; |
44 | ImageView iv_delete; | 44 | ImageView iv_delete; |
45 | Button btn_login; | 45 | Button btn_login; |
46 | TextView tv_reg; | 46 | TextView tv_reg; |
47 | CheckBox cb_1; | 47 | CheckBox cb_1; |
48 | TextView tv_user; | 48 | TextView tv_user; |
49 | TextView tv_ys; | 49 | TextView tv_ys; |
50 | 50 | ||
51 | 51 | ||
52 | @Override | 52 | @Override |
53 | protected int layoutResId() { | 53 | protected int layoutResId() { |
54 | return R.layout.activity_login; | 54 | return R.layout.activity_login; |
55 | } | 55 | } |
56 | 56 | ||
57 | @Override | 57 | @Override |
58 | public Object getContract() { | 58 | public Object getContract() { |
59 | return null; | 59 | return null; |
60 | } | 60 | } |
61 | 61 | ||
62 | @Override | 62 | @Override |
63 | public BasePresenter getPresenter() { | 63 | public BasePresenter getPresenter() { |
64 | return null; | 64 | return null; |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | @Override | 68 | @Override |
69 | protected void initView() { | 69 | protected void initView() { |
70 | et_phone = findViewById(R.id.et_phone); | 70 | et_phone = findViewById(R.id.et_phone); |
71 | et_pwd = findViewById(R.id.et_pwd); | 71 | et_pwd = findViewById(R.id.et_pwd); |
72 | iv_show = findViewById(R.id.iv_4); | 72 | iv_show = findViewById(R.id.iv_4); |
73 | iv_delete = findViewById(R.id.iv_2); | 73 | iv_delete = findViewById(R.id.iv_2); |
74 | btn_login = findViewById(R.id.btn_1); | 74 | btn_login = findViewById(R.id.btn_1); |
75 | tv_reg = findViewById(R.id.tv_2); | 75 | tv_reg = findViewById(R.id.tv_2); |
76 | cb_1 = findViewById(R.id.cb_1); | 76 | cb_1 = findViewById(R.id.cb_1); |
77 | tv_user = findViewById(R.id.tv_4); | 77 | tv_user = findViewById(R.id.tv_4); |
78 | tv_ys = findViewById(R.id.tv_6); | 78 | tv_ys = findViewById(R.id.tv_6); |
79 | 79 | ||
80 | 80 | ||
81 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 81 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
82 | 82 | ||
83 | if (!TextUtils.isEmpty(student)) { | 83 | if (!TextUtils.isEmpty(student)) { |
84 | LogUtil.e(TAG, "role 不是空----"); | 84 | LogUtil.e(TAG, "role 不是空----"); |
85 | if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { | 85 | if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { |
86 | Intent intent = new Intent(this, MainActivity.class); | 86 | Intent intent = new Intent(this, MainActivity.class); |
87 | startActivity(intent); | 87 | startActivity(intent); |
88 | finish(); | 88 | finish(); |
89 | } else { | 89 | } else { |
90 | Intent intent = new Intent(this, TeacherMainActivity.class); | 90 | Intent intent = new Intent(this, TeacherMainActivity.class); |
91 | startActivity(intent); | 91 | startActivity(intent); |
92 | finish(); | 92 | finish(); |
93 | } | 93 | } |
94 | return; | 94 | return; |
95 | } else { | 95 | } else { |
96 | LogUtil.e(TAG, "role 是空----"); | 96 | LogUtil.e(TAG, "role 是空----"); |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | } | 100 | } |
101 | 101 | ||
102 | @Override | 102 | @Override |
103 | protected void initListener() { | 103 | protected void initListener() { |
104 | iv_delete.setOnClickListener(view -> { | 104 | iv_delete.setOnClickListener(view -> { |
105 | et_phone.setText(""); | 105 | et_phone.setText(""); |
106 | }); | 106 | }); |
107 | iv_show.setOnClickListener(view -> { | 107 | iv_show.setOnClickListener(view -> { |
108 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { | 108 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { |
109 | iv_show.setBackgroundResource(R.mipmap.yc); | 109 | iv_show.setBackgroundResource(R.mipmap.yc); |
110 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); | 110 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); |
111 | et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 111 | et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
112 | } else { | 112 | } else { |
113 | iv_show.setBackgroundResource(R.mipmap.xs); | 113 | iv_show.setBackgroundResource(R.mipmap.xs); |
114 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | 114 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); |
115 | et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 115 | et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
116 | } | 116 | } |
117 | }); | 117 | }); |
118 | 118 | ||
119 | 119 | ||
120 | btn_login.setOnClickListener(view -> { | 120 | btn_login.setOnClickListener(view -> { |
121 | 121 | ||
122 | String phone = et_phone.getText().toString().trim(); | 122 | String phone = et_phone.getText().toString().trim(); |
123 | String pwd = et_pwd.getText().toString().trim(); | 123 | String pwd = et_pwd.getText().toString().trim(); |
124 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { | 124 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { |
125 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); | 125 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | 128 | ||
129 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { | 129 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { |
130 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); | 130 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | 133 | ||
134 | if (!cb_1.isChecked()) { | 134 | if (!cb_1.isChecked()) { |
135 | Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); | 135 | Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | 138 | ||
139 | login(phone, pwd); | 139 | login(phone, pwd); |
140 | 140 | ||
141 | }); | 141 | }); |
142 | 142 | ||
143 | tv_reg.setOnClickListener(view -> { | 143 | tv_reg.setOnClickListener(view -> { |
144 | startActivity(RegisterActivity.class); | 144 | startActivity(RegisterActivity.class); |
145 | finish(); | 145 | finish(); |
146 | }); | 146 | }); |
147 | 147 | ||
148 | tv_ys.setOnClickListener(view -> { | 148 | tv_ys.setOnClickListener(view -> { |
149 | startActivity(YinsiActivity.class); | 149 | startActivity(YinsiActivity.class); |
150 | }); | 150 | }); |
151 | tv_user.setOnClickListener(view -> { | 151 | tv_user.setOnClickListener(view -> { |
152 | startActivity(UserAgreementActivity.class); | 152 | startActivity(UserAgreementActivity.class); |
153 | }); | 153 | }); |
154 | } | 154 | } |
155 | 155 | ||
156 | public void login(final String phone, String pwd) { | 156 | public void login(final String phone, String pwd) { |
157 | 157 | ||
158 | Map map = new HashMap(); | 158 | Map map = new HashMap(); |
159 | map.put("username", phone); | 159 | map.put("username", phone); |
160 | map.put("password", pwd); | 160 | map.put("password", pwd); |
161 | 161 | ||
162 | 162 | ||
163 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | 163 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { |
164 | @Override | 164 | @Override |
165 | public void onSubscribe(Disposable d) { | 165 | public void onSubscribe(Disposable d) { |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | @Override | 169 | @Override |
170 | public void onNext(ResponseBody responseBody) { | 170 | public void onNext(ResponseBody responseBody) { |
171 | try { | 171 | try { |
172 | String str = responseBody.string().toString(); | 172 | String str = responseBody.string().toString(); |
173 | LogUtil.e(TAG, "----" + str); | 173 | LogUtil.e(TAG, "----" + str); |
174 | JSONObject jo = new JSONObject(str); | 174 | JSONObject jo = new JSONObject(str); |
175 | boolean isSucceed = jo.getBoolean("success"); | 175 | boolean isSucceed = jo.getBoolean("success"); |
176 | if (isSucceed) { | 176 | if (isSucceed) { |
177 | JSONObject jo2 = jo.getJSONObject("data"); | 177 | JSONObject jo2 = jo.getJSONObject("data"); |
178 | if ("parent".equals(jo2.getString("role"))) { | 178 | if ("parent".equals(jo2.getString("role"))) { |
179 | SharedPreferencesUtil.putData("phone", phone); | 179 | SharedPreferencesUtil.putData("phone", phone); |
180 | SharedPreferencesUtil.putData("role", jo2.getString("role")); | 180 | SharedPreferencesUtil.putData("role", jo2.getString("role")); |
181 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); | 181 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); |
182 | SharedPreferencesUtil.putData("token", jo2.getString("token")); | 182 | SharedPreferencesUtil.putData("token", jo2.getString("token")); |
183 | JSONObject user = new JSONObject(jo2.getString("user")); | 183 | JSONObject user = new JSONObject(jo2.getString("user")); |
184 | SharedPreferencesUtil.putData("photo", user.getString("photo")); | 184 | if (user.getString("photo") != null && !user.getString("photo").equals("null")) { |
185 | SharedPreferencesUtil.putData("photo", user.getString("photo")); | ||
186 | } | ||
185 | SharedPreferencesUtil.putData("name", user.getString("userName")); | 187 | SharedPreferencesUtil.putData("name", user.getString("userName")); |
186 | startActivity(ChooseActivity.class); | 188 | startActivity(ChooseActivity.class); |
187 | finish(); | 189 | finish(); |
188 | } else if ("member_advisor".equals(jo2.getString("role")) || "teaching_supervision".equals(jo2.getString("role"))) { | 190 | } else if ("member_advisor".equals(jo2.getString("role")) || "teaching_supervision".equals(jo2.getString("role"))) { |
189 | SharedPreferencesUtil.putData("phone", phone); | 191 | SharedPreferencesUtil.putData("phone", phone); |
190 | SharedPreferencesUtil.putData("role", jo2.getString("role")); | 192 | SharedPreferencesUtil.putData("role", jo2.getString("role")); |
191 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); | 193 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); |
192 | SharedPreferencesUtil.putData("token", jo2.getString("token")); | 194 | SharedPreferencesUtil.putData("token", jo2.getString("token")); |
193 | JSONObject user = new JSONObject(jo2.getString("user")); | 195 | JSONObject user = new JSONObject(jo2.getString("user")); |
194 | SharedPreferencesUtil.putData("name", user.getString("userName")); | 196 | SharedPreferencesUtil.putData("name", user.getString("userName")); |
195 | SharedPreferencesUtil.putData("photo", user.getString("photo")); | 197 | SharedPreferencesUtil.putData("photo", user.getString("photo")); |
196 | startActivity(TeacherChooseActivity.class); | 198 | startActivity(TeacherChooseActivity.class); |
197 | finish(); | 199 | finish(); |
198 | } else { | 200 | } else { |
199 | showToast("您没有权限"); | 201 | showToast("您没有权限"); |
200 | } | 202 | } |
201 | 203 | ||
202 | } else { | 204 | } else { |
203 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | 205 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); |
204 | } | 206 | } |
205 | } catch (Exception e) { | 207 | } catch (Exception e) { |
206 | e.printStackTrace(); | 208 | e.printStackTrace(); |
207 | Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); | 209 | Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); |
208 | } | 210 | } |
209 | } | 211 | } |
210 | 212 | ||
211 | @Override | 213 | @Override |
212 | public void onError(Throwable e) { | 214 | public void onError(Throwable e) { |
213 | 215 | ||
214 | } | 216 | } |
215 | 217 | ||
216 | @Override | 218 | @Override |
217 | public void onComplete() { | 219 | public void onComplete() { |
218 | 220 | ||
219 | } | 221 | } |
220 | }); | 222 | }); |
221 | } | 223 | } |
222 | 224 | ||
223 | 225 | ||
224 | @Override | 226 | @Override |
225 | protected void initData() { | 227 | protected void initData() { |
226 | 228 | ||
227 | } | 229 | } |
228 | 230 | ||
229 | @Override | 231 | @Override |
230 | public void onNetChanged(int netWorkState) { | 232 | public void onNetChanged(int netWorkState) { |
231 | 233 | ||
232 | } | 234 | } |
233 | } | 235 | } |
app/src/main/java/com/hjx/parent/adapter/ImageAdapter.java
1 | package com.hjx.parent.adapter; | 1 | package com.hjx.parent.adapter; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
6 | import android.graphics.BitmapFactory; | 6 | import android.graphics.BitmapFactory; |
7 | import android.graphics.Rect; | 7 | import android.graphics.Rect; |
8 | import android.graphics.RectF; | 8 | import android.graphics.RectF; |
9 | import android.util.Log; | 9 | import android.util.Log; |
10 | import android.view.LayoutInflater; | 10 | import android.view.LayoutInflater; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.view.ViewGroup; | 12 | import android.view.ViewGroup; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | import android.widget.RelativeLayout; | 14 | import android.widget.RelativeLayout; |
15 | 15 | ||
16 | import androidx.annotation.NonNull; | 16 | import androidx.annotation.NonNull; |
17 | import androidx.recyclerview.widget.RecyclerView; | 17 | import androidx.recyclerview.widget.RecyclerView; |
18 | 18 | ||
19 | import com.google.gson.Gson; | 19 | import com.google.gson.Gson; |
20 | import com.hjx.parent.ImageActivity; | 20 | import com.hjx.parent.ImageActivity; |
21 | import com.hjx.parent.ImageSelectActivity; | 21 | import com.hjx.parent.ImageSelectActivity; |
22 | import com.hjx.parent.R; | 22 | import com.hjx.parent.R; |
23 | import com.hjx.parent.databinding.ItemImageBinding; | 23 | import com.hjx.parent.databinding.ItemImageBinding; |
24 | import com.prws.common.bean.ImageBean; | 24 | import com.prws.common.bean.ImageBean; |
25 | import com.prws.common.utils.CommonUtil; | 25 | import com.prws.common.utils.CommonUtil; |
26 | 26 | ||
27 | import java.util.List; | 27 | import java.util.List; |
28 | 28 | ||
29 | public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageHolder> { | 29 | public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageHolder> { |
30 | private List<ImageBean> list; | 30 | private List<ImageBean> list; |
31 | private ImageActivity context; | 31 | private ImageActivity context; |
32 | 32 | ||
33 | public ImageAdapter(ImageActivity context, List<ImageBean> list) { | 33 | public ImageAdapter(ImageActivity context, List<ImageBean> list) { |
34 | this.context = context; | 34 | this.context = context; |
35 | this.list = list; | 35 | this.list = list; |
36 | } | 36 | } |
37 | 37 | ||
38 | @NonNull | 38 | @NonNull |
39 | @Override | 39 | @Override |
40 | public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | 40 | public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
41 | ItemImageBinding itemImageBinding = ItemImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); | 41 | ItemImageBinding itemImageBinding = ItemImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); |
42 | return new ImageHolder(itemImageBinding); | 42 | return new ImageHolder(itemImageBinding); |
43 | } | 43 | } |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | public void onBindViewHolder(@NonNull ImageHolder holder, int position) { | 46 | public void onBindViewHolder(@NonNull ImageHolder holder, int position) { |
47 | ImageBean imageBean = list.get(position); | 47 | ImageBean imageBean = list.get(position); |
48 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); | 48 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); |
49 | float imageHeight = bitmap.getHeight(); | 49 | float imageHeight = bitmap.getHeight(); |
50 | float imageWidth = bitmap.getWidth(); | 50 | float imageWidth = bitmap.getWidth(); |
51 | float viewHeight = CommonUtil.getScreenHeight(context) - CommonUtil.dpToPx(context, 250); | 51 | float viewHeight = CommonUtil.getScreenHeight(context) - CommonUtil.dpToPx(context, 250); |
52 | float viewWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); | 52 | float viewWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); |
53 | 53 | ||
54 | RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(holder.binding.ivPic.getLayoutParams()); | 54 | RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(holder.binding.ivPic.getLayoutParams()); |
55 | if (imageHeight / imageWidth > viewHeight / viewWidth) { | 55 | if (imageHeight / imageWidth > viewHeight / viewWidth) { |
56 | if (viewHeight > imageHeight) { | 56 | if (viewHeight > imageHeight) { |
57 | layoutParams.height = (int) imageHeight; | 57 | layoutParams.height = (int) imageHeight; |
58 | layoutParams.width = (int) imageWidth; | 58 | layoutParams.width = (int) imageWidth; |
59 | } else { | 59 | } else { |
60 | layoutParams.height = (int) viewHeight; | 60 | layoutParams.height = (int) viewHeight; |
61 | layoutParams.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); | 61 | layoutParams.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); |
62 | } | 62 | } |
63 | } else { | 63 | } else { |
64 | if (viewWidth > imageWidth) { | 64 | if (viewWidth > imageWidth) { |
65 | layoutParams.height = (int) imageHeight; | 65 | layoutParams.height = (int) imageHeight; |
66 | layoutParams.width = (int) imageWidth; | 66 | layoutParams.width = (int) imageWidth; |
67 | } else { | 67 | } else { |
68 | layoutParams.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); | 68 | layoutParams.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); |
69 | layoutParams.width = (int) viewWidth; | 69 | layoutParams.width = (int) viewWidth; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); | 72 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); |
73 | holder.binding.ivPic.setLayoutParams(layoutParams); | 73 | holder.binding.ivPic.setLayoutParams(layoutParams); |
74 | holder.binding.ivPic.setImageBitmap(bitmap); | 74 | holder.binding.ivPic.setImageBitmap(bitmap); |
75 | 75 | ||
76 | 76 | ||
77 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(holder.binding.rlPic.getLayoutParams()); | 77 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(holder.binding.rlPic.getLayoutParams()); |
78 | if (imageHeight / imageWidth > viewHeight / viewWidth) { | 78 | if (imageHeight / imageWidth > viewHeight / viewWidth) { |
79 | if (viewHeight > imageHeight) { | 79 | if (viewHeight > imageHeight) { |
80 | layoutParams1.height = (int) imageHeight; | 80 | layoutParams1.height = (int) imageHeight; |
81 | layoutParams1.width = (int) imageWidth; | 81 | layoutParams1.width = (int) imageWidth; |
82 | } else { | 82 | } else { |
83 | layoutParams1.height = (int) viewHeight; | 83 | layoutParams1.height = (int) viewHeight; |
84 | layoutParams1.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); | 84 | layoutParams1.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); |
85 | } | 85 | } |
86 | } else { | 86 | } else { |
87 | if (viewWidth > imageWidth) { | 87 | if (viewWidth > imageWidth) { |
88 | layoutParams1.height = (int) imageHeight; | 88 | layoutParams1.height = (int) imageHeight; |
89 | layoutParams1.width = (int) imageWidth; | 89 | layoutParams1.width = (int) imageWidth; |
90 | } else { | 90 | } else { |
91 | layoutParams1.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); | 91 | layoutParams1.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); |
92 | layoutParams1.width = (int) viewWidth; | 92 | layoutParams1.width = (int) viewWidth; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | Log.i("figLoaction", "height=" + layoutParams1.height + " width=" + layoutParams1.width); | 95 | Log.i("figLoaction", "height=" + layoutParams1.height + " width=" + layoutParams1.width); |
96 | layoutParams1.addRule(RelativeLayout.CENTER_IN_PARENT); | 96 | layoutParams1.addRule(RelativeLayout.CENTER_IN_PARENT); |
97 | holder.binding.rlPic.setLayoutParams(layoutParams1); | 97 | holder.binding.rlPic.setLayoutParams(layoutParams1); |
98 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 98 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
99 | holder.binding.rlPic.removeAllViews(); | 99 | holder.binding.rlPic.removeAllViews(); |
100 | for (int i = 0; i < imageBean.getCuts().size(); i++) { | 100 | for (int i = 0; i < imageBean.getCuts().size(); i++) { |
101 | View view = LayoutInflater.from(context).inflate(R.layout.layout_select, null); | 101 | View view = LayoutInflater.from(context).inflate(R.layout.layout_select, null); |
102 | Rect rect; | 102 | Rect rect; |
103 | if (imageBean.getCuts().get(i).getRect1() != null) { | 103 | if (imageBean.getCuts().get(i).getRect1() != null) { |
104 | rect = imageBean.getCuts().get(i).getRect1(); | 104 | rect = imageBean.getCuts().get(i).getRect1(); |
105 | } else { | 105 | } else { |
106 | rect = CommonUtil.getRect(imageBean.getCuts().get(i).getRect(), bitmap, layoutParams1.height, layoutParams1.width); | 106 | rect = CommonUtil.getRect(imageBean.getCuts().get(i).getRect(), bitmap, layoutParams1.height, layoutParams1.width); |
107 | imageBean.getCuts().get(i).setRect1(rect); | 107 | imageBean.getCuts().get(i).setRect1(rect); |
108 | } | 108 | } |
109 | Log.i("figLoaction", new Gson().toJson(rect)); | 109 | Log.i("figLoaction", new Gson().toJson(rect)); |
110 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(rect.right - rect.left, rect.bottom - rect.top); | 110 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(rect.right - rect.left, rect.bottom - rect.top); |
111 | params.setMargins(rect.left, rect.top, 0, 0); | 111 | params.setMargins(rect.left, rect.top, 0, 0); |
112 | holder.binding.rlPic.addView(view, params); | 112 | holder.binding.rlPic.addView(view, params); |
113 | RelativeLayout rl_add = view.findViewById(R.id.rl_add); | 113 | RelativeLayout rl_add = view.findViewById(R.id.rl_add); |
114 | ImageView iv_state = view.findViewById(R.id.iv_state); | 114 | ImageView iv_state = view.findViewById(R.id.iv_state); |
115 | ImageView iv_edit = view.findViewById(R.id.iv_edit); | 115 | ImageView iv_edit = view.findViewById(R.id.iv_edit); |
116 | int finalI = i; | 116 | int finalI = i; |
117 | if (imageBean.getCuts().get(i).isSelect()) { | 117 | if (imageBean.getCuts().get(i).isSelect()) { |
118 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); | 118 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); |
119 | iv_state.setImageResource(R.mipmap.ic_selected); | 119 | iv_state.setImageResource(R.mipmap.ic_selected); |
120 | } else { | 120 | } else { |
121 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); | 121 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); |
122 | iv_state.setImageResource(R.mipmap.ic_add); | 122 | iv_state.setImageResource(R.mipmap.ic_add); |
123 | } | 123 | } |
124 | rl_add.setOnClickListener(new View.OnClickListener() { | 124 | rl_add.setOnClickListener(new View.OnClickListener() { |
125 | @Override | 125 | @Override |
126 | public void onClick(View v) { | 126 | public void onClick(View v) { |
127 | Bitmap b = Bitmap.createBitmap(bitmap, v.getLeft() * bitmap.getWidth() / holder.binding.ivPic.getWidth(), v.getTop() * bitmap.getHeight() / holder.binding.ivPic.getHeight(), (v.getRight() - v.getLeft()) * bitmap.getWidth() / holder.binding.ivPic.getWidth(), (v.getBottom() - v.getTop()) * bitmap.getHeight() / holder.binding.ivPic.getHeight()); | 127 | Bitmap b = Bitmap.createBitmap(bitmap, v.getLeft() * bitmap.getWidth() / holder.binding.ivPic.getWidth(), v.getTop() * bitmap.getHeight() / holder.binding.ivPic.getHeight(), (v.getRight() - v.getLeft()) * bitmap.getWidth() / holder.binding.ivPic.getWidth(), (v.getBottom() - v.getTop()) * bitmap.getHeight() / holder.binding.ivPic.getHeight()); |
128 | if (imageBean.getCuts().get(finalI).isSelect()) { | 128 | if (imageBean.getCuts().get(finalI).isSelect()) { |
129 | imageBean.getCuts().get(finalI).setSelect(false); | 129 | imageBean.getCuts().get(finalI).setSelect(false); |
130 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); | 130 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); |
131 | iv_state.setImageResource(R.mipmap.ic_add); | 131 | iv_state.setImageResource(R.mipmap.ic_add); |
132 | } else { | 132 | } else { |
133 | imageBean.getCuts().get(finalI).setSelect(true); | 133 | imageBean.getCuts().get(finalI).setSelect(true); |
134 | imageBean.getCuts().get(finalI).setBitmap(b); | 134 | imageBean.getCuts().get(finalI).setBitmap(b); |
135 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); | 135 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); |
136 | iv_state.setImageResource(R.mipmap.ic_selected); | 136 | iv_state.setImageResource(R.mipmap.ic_selected); |
137 | } | 137 | } |
138 | context.refreshNum(); | 138 | context.refreshNum(); |
139 | } | 139 | } |
140 | }); | 140 | }); |
141 | iv_edit.setOnClickListener(new View.OnClickListener() { | 141 | iv_edit.setOnClickListener(new View.OnClickListener() { |
142 | @Override | 142 | @Override |
143 | public void onClick(View v) { | 143 | public void onClick(View v) { |
144 | Intent intent = new Intent(context, ImageSelectActivity.class); | 144 | Intent intent = new Intent(context, ImageSelectActivity.class); |
145 | intent.putExtra("rect", rect); | 145 | intent.putExtra("rect", rect); |
146 | intent.putExtra("path", imageBean.getPath()); | 146 | intent.putExtra("path", imageBean.getPath()); |
147 | intent.putExtra("position", finalI); | 147 | intent.putExtra("position", finalI); |
148 | context.startActivityForResult(intent, 1001); | 148 | context.startActivityForResult(intent, 1001); |
149 | } | 149 | } |
150 | }); | 150 | }); |
151 | } | 151 | } |
152 | } else { | ||
153 | holder.binding.rlPic.removeAllViews(); | ||
152 | } | 154 | } |
153 | } | 155 | } |
154 | 156 | ||
155 | @Override | 157 | @Override |
156 | public int getItemCount() { | 158 | public int getItemCount() { |
157 | return list.size(); | 159 | return list.size(); |
158 | } | 160 | } |
159 | 161 | ||
160 | static class ImageHolder extends RecyclerView.ViewHolder { | 162 | static class ImageHolder extends RecyclerView.ViewHolder { |
161 | ItemImageBinding binding; | 163 | ItemImageBinding binding; |
162 | 164 | ||
163 | public ImageHolder(@NonNull ItemImageBinding itemView) { | 165 | public ImageHolder(@NonNull ItemImageBinding itemView) { |
164 | super(itemView.getRoot()); | 166 | super(itemView.getRoot()); |
165 | binding = itemView; | 167 | binding = itemView; |
166 | } | 168 | } |
167 | } | 169 | } |
168 | } | 170 | } |
169 | 171 |
app/src/main/java/com/hjx/parent/dialog/ErrorEditDialog.java
1 | package com.hjx.parent.dialog; | 1 | package com.hjx.parent.dialog; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Color; | 6 | import android.graphics.Color; |
7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
8 | import android.view.Gravity; | 8 | import android.view.Gravity; |
9 | import android.view.View; | 9 | import android.view.View; |
10 | import android.view.Window; | 10 | import android.view.Window; |
11 | import android.view.WindowManager; | 11 | import android.view.WindowManager; |
12 | import android.widget.AdapterView; | 12 | import android.widget.AdapterView; |
13 | import android.widget.ArrayAdapter; | 13 | import android.widget.ArrayAdapter; |
14 | import android.widget.CompoundButton; | 14 | import android.widget.CompoundButton; |
15 | import android.widget.RadioButton; | 15 | import android.widget.RadioButton; |
16 | import android.widget.RadioGroup; | 16 | import android.widget.RadioGroup; |
17 | 17 | ||
18 | import androidx.annotation.NonNull; | 18 | import androidx.annotation.NonNull; |
19 | import androidx.recyclerview.widget.LinearLayoutManager; | 19 | import androidx.recyclerview.widget.LinearLayoutManager; |
20 | import androidx.recyclerview.widget.RecyclerView; | 20 | import androidx.recyclerview.widget.RecyclerView; |
21 | 21 | ||
22 | import com.bumptech.glide.Glide; | 22 | import com.bumptech.glide.Glide; |
23 | import com.chad.library.adapter.base.BaseQuickAdapter; | 23 | import com.chad.library.adapter.base.BaseQuickAdapter; |
24 | import com.chad.library.adapter.base.BaseViewHolder; | 24 | import com.chad.library.adapter.base.BaseViewHolder; |
25 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
26 | import com.hjx.parent.AddSuccessActivity; | 26 | import com.hjx.parent.AddSuccessActivity; |
27 | import com.hjx.parent.App; | 27 | import com.hjx.parent.App; |
28 | import com.hjx.parent.ImageActivity; | 28 | import com.hjx.parent.ImageActivity; |
29 | import com.hjx.parent.R; | 29 | import com.hjx.parent.R; |
30 | import com.hjx.parent.bean.StudentBean; | 30 | import com.hjx.parent.bean.StudentBean; |
31 | import com.hjx.parent.databinding.DialogAddErrorBinding; | 31 | import com.hjx.parent.databinding.DialogAddErrorBinding; |
32 | import com.hjx.parent.databinding.DialogEditErrorBinding; | 32 | import com.hjx.parent.databinding.DialogEditErrorBinding; |
33 | import com.prws.common.bean.Grade; | 33 | import com.prws.common.bean.Grade; |
34 | import com.prws.common.bean.GradeAndSubject; | 34 | import com.prws.common.bean.GradeAndSubject; |
35 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.bean.Subject; | 36 | import com.prws.common.bean.Subject; |
37 | import com.prws.common.bean.TopicBean; | 37 | import com.prws.common.bean.TopicBean; |
38 | import com.prws.common.net.NetWorks; | 38 | import com.prws.common.net.NetWorks; |
39 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
40 | import com.prws.common.utils.SharedPreferencesUtil; | 40 | import com.prws.common.utils.SharedPreferencesUtil; |
41 | import com.prws.common.utils.StringUtils; | 41 | import com.prws.common.utils.StringUtils; |
42 | 42 | ||
43 | import java.util.ArrayList; | 43 | import java.util.ArrayList; |
44 | import java.util.HashMap; | 44 | import java.util.HashMap; |
45 | import java.util.List; | 45 | import java.util.List; |
46 | import java.util.Map; | 46 | import java.util.Map; |
47 | 47 | ||
48 | import io.reactivex.Observer; | 48 | import io.reactivex.Observer; |
49 | import io.reactivex.disposables.Disposable; | 49 | import io.reactivex.disposables.Disposable; |
50 | 50 | ||
51 | public class ErrorEditDialog extends Dialog { | 51 | public class ErrorEditDialog extends Dialog { |
52 | private Context context; | 52 | private Context context; |
53 | private DialogEditErrorBinding binding; | 53 | private DialogEditErrorBinding binding; |
54 | private List<TopicBean> list; | 54 | private List<TopicBean> list; |
55 | private Grade grade; | 55 | private Grade grade; |
56 | private String term; | 56 | private String term; |
57 | private Subject subject; | 57 | private Subject subject; |
58 | private int reason; | 58 | private int reason; |
59 | private int type = 0; | 59 | private int type = 0; |
60 | private int done = 1; | ||
60 | private EditInterface editInterface; | 61 | private EditInterface editInterface; |
61 | 62 | ||
62 | public interface EditInterface { | 63 | public interface EditInterface { |
63 | void edit(String name, int reason); | 64 | void edit(String name, String grade, String subject, int type, int reason, int manager); |
64 | } | 65 | } |
65 | 66 | ||
66 | public ErrorEditDialog(@NonNull Context context, List<TopicBean> list, EditInterface editInterface) { | 67 | public ErrorEditDialog(@NonNull Context context, List<TopicBean> list, EditInterface editInterface) { |
67 | super(context, R.style.MyAlertDialog); | 68 | super(context, R.style.MyAlertDialog); |
68 | this.context = context; | 69 | this.context = context; |
69 | this.list = list; | 70 | this.list = list; |
70 | this.editInterface = editInterface; | 71 | this.editInterface = editInterface; |
71 | } | 72 | } |
72 | 73 | ||
73 | @Override | 74 | @Override |
74 | protected void onCreate(Bundle savedInstanceState) { | 75 | protected void onCreate(Bundle savedInstanceState) { |
75 | super.onCreate(savedInstanceState); | 76 | super.onCreate(savedInstanceState); |
76 | binding = DialogEditErrorBinding.inflate(getLayoutInflater()); | 77 | binding = DialogEditErrorBinding.inflate(getLayoutInflater()); |
77 | setContentView(binding.getRoot()); | 78 | setContentView(binding.getRoot()); |
78 | Window dialogWindow = getWindow(); | 79 | Window dialogWindow = getWindow(); |
79 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); | 80 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); |
80 | lp.width = CommonUtil.getScreenWidth(getContext()); | 81 | lp.width = CommonUtil.getScreenWidth(getContext()); |
81 | dialogWindow.setGravity(Gravity.BOTTOM); | 82 | dialogWindow.setGravity(Gravity.BOTTOM); |
82 | dialogWindow.setAttributes(lp); | 83 | dialogWindow.setAttributes(lp); |
84 | TopicBean bean = list.get(0); | ||
83 | List<String> grades = new ArrayList<>(); | 85 | List<String> grades = new ArrayList<>(); |
86 | int selectGrade = 0; | ||
84 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { | 87 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { |
85 | grades.add(grade.getGrade().getGrade()); | 88 | grades.add(grade.getGrade().getGrade()); |
89 | if (bean.getGrade().contains(grade.getGrade().getGrade())) { | ||
90 | selectGrade = App.getInstance().getGradeAndSubjects().indexOf(grade); | ||
91 | } | ||
86 | } | 92 | } |
87 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); | 93 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); |
88 | binding.spinnerGrade.setAdapter(gradeAdapter); | 94 | binding.spinnerGrade.setAdapter(gradeAdapter); |
95 | binding.spinnerGrade.setSelection(selectGrade); | ||
89 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 96 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
90 | @Override | 97 | @Override |
91 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 98 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
92 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); | 99 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); |
93 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); | 100 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); |
94 | } | 101 | } |
95 | 102 | ||
96 | @Override | 103 | @Override |
97 | public void onNothingSelected(AdapterView<?> parent) { | 104 | public void onNothingSelected(AdapterView<?> parent) { |
98 | 105 | ||
99 | } | 106 | } |
100 | }); | 107 | }); |
101 | ArrayAdapter<String> gradeAdapter1 = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, getContext().getResources().getStringArray(R.array.grade_array)); | 108 | ArrayAdapter<String> gradeAdapter1 = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, getContext().getResources().getStringArray(R.array.grade_array)); |
102 | binding.spinnerGrade1.setAdapter(gradeAdapter1); | 109 | binding.spinnerGrade1.setAdapter(gradeAdapter1); |
110 | binding.spinnerGrade1.setSelection(bean.getGrade().contains("下学期") ? 1 : 0); | ||
103 | binding.spinnerGrade1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 111 | binding.spinnerGrade1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
104 | @Override | 112 | @Override |
105 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 113 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
106 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; | 114 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; |
107 | } | 115 | } |
108 | 116 | ||
109 | @Override | 117 | @Override |
110 | public void onNothingSelected(AdapterView<?> parent) { | 118 | public void onNothingSelected(AdapterView<?> parent) { |
111 | 119 | ||
112 | } | 120 | } |
113 | }); | 121 | }); |
114 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); | 122 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); |
115 | binding.spinnerReason.setAdapter(reasonAdapter); | 123 | binding.spinnerReason.setAdapter(reasonAdapter); |
124 | binding.spinnerReason.setSelection(bean.getReason()); | ||
116 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 125 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
117 | @Override | 126 | @Override |
118 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 127 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
119 | reason = position; | 128 | reason = position; |
120 | } | 129 | } |
121 | 130 | ||
122 | @Override | 131 | @Override |
123 | public void onNothingSelected(AdapterView<?> parent) { | 132 | public void onNothingSelected(AdapterView<?> parent) { |
124 | 133 | ||
125 | } | 134 | } |
126 | }); | 135 | }); |
127 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); | 136 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(bean.getType()); |
128 | typeButton.setChecked(true); | 137 | typeButton.setChecked(true); |
129 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 138 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
130 | @Override | 139 | @Override |
131 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 140 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
132 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 141 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
133 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; | 142 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; |
134 | } | 143 | } |
135 | }); | 144 | }); |
145 | RadioButton manager = (RadioButton) binding.managerRadio.getChildAt(bean.getIsDone()); | ||
146 | manager.setChecked(true); | ||
147 | binding.managerRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | ||
148 | @Override | ||
149 | public void onCheckedChanged(RadioGroup group, int checkedId) { | ||
150 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | ||
151 | done = getContext().getString(R.string.text_done).equals(rcheck.getText().toString()) ? 0 : 1; | ||
152 | } | ||
153 | }); | ||
154 | |||
136 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 155 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
137 | @Override | 156 | @Override |
138 | public void onClick(View v) { | 157 | public void onClick(View v) { |
139 | dismiss(); | 158 | dismiss(); |
140 | } | 159 | } |
141 | }); | 160 | }); |
142 | binding.addTopic.setOnClickListener(new View.OnClickListener() { | 161 | binding.addTopic.setOnClickListener(new View.OnClickListener() { |
143 | @Override | 162 | @Override |
144 | public void onClick(View v) { | 163 | public void onClick(View v) { |
145 | editError(); | 164 | editError(); |
146 | } | 165 | } |
147 | }); | 166 | }); |
148 | } | 167 | } |
149 | 168 | ||
150 | private void editError() { | 169 | private void editError() { |
151 | List<HashMap<String, Object>> hashMapArrayList = new ArrayList<>(); | 170 | List<HashMap<String, Object>> hashMapArrayList = new ArrayList<>(); |
152 | for (TopicBean topicBean : list) { | 171 | for (TopicBean topicBean : list) { |
153 | HashMap<String, Object> map = new HashMap<>(); | 172 | HashMap<String, Object> map = new HashMap<>(); |
154 | map.put("bookId", topicBean.getId()); | 173 | map.put("bookId", topicBean.getId()); |
155 | map.put("grade", grade.getGrade() + term); | 174 | map.put("grade", grade.getGrade() + term); |
156 | map.put("subject", subject.getSubject()); | 175 | map.put("subject", subject.getSubject()); |
157 | map.put("errorReason", String.valueOf(reason)); | 176 | map.put("errorReason", String.valueOf(reason)); |
158 | map.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); | 177 | map.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); |
159 | map.put("type", type); | 178 | map.put("type", type); |
179 | map.put("controlFlag", done); | ||
160 | hashMapArrayList.add(map); | 180 | hashMapArrayList.add(map); |
161 | } | 181 | } |
162 | NetWorks.editError(hashMapArrayList, new Observer<ResponseResult>() { | 182 | NetWorks.editError(hashMapArrayList, new Observer<ResponseResult>() { |
163 | @Override | 183 | @Override |
164 | public void onSubscribe(Disposable d) { | 184 | public void onSubscribe(Disposable d) { |
165 | 185 | ||
166 | } | 186 | } |
167 | 187 | ||
168 | @Override | 188 | @Override |
169 | public void onNext(ResponseResult responseResult) { | 189 | public void onNext(ResponseResult responseResult) { |
170 | if (responseResult.getCode() == 200) { | 190 | if (responseResult.getCode() == 200) { |
171 | editInterface.edit(grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题", reason); | 191 | editInterface.edit(grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题", grade.getGrade() + term, subject.getSubject(), type, reason, done); |
172 | dismiss(); | 192 | dismiss(); |
173 | } | 193 | } |
174 | } | 194 | } |
175 | 195 | ||
176 | @Override | 196 | @Override |
177 | public void onError(Throwable e) { | 197 | public void onError(Throwable e) { |
178 | 198 | ||
179 | } | 199 | } |
180 | 200 | ||
181 | @Override | 201 | @Override |
182 | public void onComplete() { | 202 | public void onComplete() { |
183 | 203 | ||
184 | } | 204 | } |
185 | }); | 205 | }); |
186 | } | 206 | } |
187 | 207 | ||
188 | private void refreshSubject(List<Subject> subjects) { | 208 | private void refreshSubject(List<Subject> subjects) { |
209 | int selectSubject = 0; | ||
189 | List<String> s = new ArrayList<>(); | 210 | List<String> s = new ArrayList<>(); |
190 | for (Subject subject : subjects) { | 211 | for (Subject subject : subjects) { |
191 | s.add(subject.getSubject()); | 212 | s.add(subject.getSubject()); |
213 | if (list.get(0).getSubject().equals(subject.getSubject())) { | ||
214 | selectSubject = subjects.indexOf(subject); | ||
215 | } | ||
192 | } | 216 | } |
193 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); | 217 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); |
194 | binding.spinnerSubject.setAdapter(subjectAdapter); | 218 | binding.spinnerSubject.setAdapter(subjectAdapter); |
219 | binding.spinnerSubject.setSelection(selectSubject); | ||
195 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 220 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
196 | @Override | 221 | @Override |
197 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 222 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
198 | subject = subjects.get(position); | 223 | subject = subjects.get(position); |
199 | } | 224 | } |
200 | 225 | ||
201 | @Override | 226 | @Override |
202 | public void onNothingSelected(AdapterView<?> parent) { | 227 | public void onNothingSelected(AdapterView<?> parent) { |
203 | 228 | ||
204 | } | 229 | } |
205 | }); | 230 | }); |
206 | } | 231 | } |
207 | 232 | ||
208 | } | 233 | } |
209 | 234 |
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import static android.app.Activity.RESULT_OK; | 3 | import static android.app.Activity.RESULT_OK; |
4 | 4 | ||
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
8 | import android.net.Uri; | 8 | import android.net.Uri; |
9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
10 | import android.provider.MediaStore; | 10 | import android.provider.MediaStore; |
11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
12 | import android.util.Log; | 12 | import android.util.Log; |
13 | import android.view.LayoutInflater; | 13 | import android.view.LayoutInflater; |
14 | import android.view.View; | 14 | import android.view.View; |
15 | import android.view.ViewGroup; | 15 | import android.view.ViewGroup; |
16 | import android.widget.ImageView; | 16 | import android.widget.ImageView; |
17 | import android.widget.LinearLayout; | 17 | import android.widget.LinearLayout; |
18 | import android.widget.Toast; | 18 | import android.widget.Toast; |
19 | 19 | ||
20 | import androidx.annotation.NonNull; | 20 | import androidx.annotation.NonNull; |
21 | import androidx.annotation.Nullable; | 21 | import androidx.annotation.Nullable; |
22 | import androidx.core.content.FileProvider; | 22 | import androidx.core.content.FileProvider; |
23 | import androidx.recyclerview.widget.LinearLayoutManager; | 23 | import androidx.recyclerview.widget.LinearLayoutManager; |
24 | import androidx.recyclerview.widget.RecyclerView; | 24 | import androidx.recyclerview.widget.RecyclerView; |
25 | 25 | ||
26 | import com.bumptech.glide.Glide; | 26 | import com.bumptech.glide.Glide; |
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | import com.bumptech.glide.request.RequestOptions; | 28 | import com.bumptech.glide.request.RequestOptions; |
29 | import com.chad.library.adapter.base.BaseQuickAdapter; | 29 | import com.chad.library.adapter.base.BaseQuickAdapter; |
30 | import com.chad.library.adapter.base.BaseViewHolder; | 30 | import com.chad.library.adapter.base.BaseViewHolder; |
31 | import com.google.gson.Gson; | 31 | import com.google.gson.Gson; |
32 | import com.hjq.permissions.OnPermissionCallback; | 32 | import com.hjq.permissions.OnPermissionCallback; |
33 | import com.hjq.permissions.Permission; | 33 | import com.hjq.permissions.Permission; |
34 | import com.hjq.permissions.XXPermissions; | 34 | import com.hjq.permissions.XXPermissions; |
35 | import com.hjx.parent.ChooseActivity; | 35 | import com.hjx.parent.ChooseActivity; |
36 | import com.hjx.parent.ErrorBookActivity; | 36 | import com.hjx.parent.ErrorBookActivity; |
37 | import com.hjx.parent.ErrorListActivity; | 37 | import com.hjx.parent.ErrorListActivity; |
38 | import com.hjx.parent.ImageActivity; | 38 | import com.hjx.parent.ImageActivity; |
39 | import com.hjx.parent.R; | 39 | import com.hjx.parent.R; |
40 | import com.hjx.parent.TeacherChooseActivity; | 40 | import com.hjx.parent.TeacherChooseActivity; |
41 | import com.hjx.parent.adapter.ErrorAdapter; | 41 | import com.hjx.parent.adapter.ErrorAdapter; |
42 | import com.hjx.parent.bean.StudentBean; | 42 | import com.hjx.parent.bean.StudentBean; |
43 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | 43 | import com.hjx.parent.databinding.ActivityErrorBookBinding; |
44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
45 | import com.prws.common.bean.PageInfo; | 45 | import com.prws.common.bean.PageInfo; |
46 | import com.prws.common.bean.ResponseResult; | 46 | import com.prws.common.bean.ResponseResult; |
47 | import com.prws.common.bean.TopicBean; | 47 | import com.prws.common.bean.TopicBean; |
48 | import com.prws.common.net.NetWorks; | 48 | import com.prws.common.net.NetWorks; |
49 | import com.prws.common.utils.BitmapUtils; | 49 | import com.prws.common.utils.BitmapUtils; |
50 | import com.prws.common.utils.CommonUtil; | 50 | import com.prws.common.utils.CommonUtil; |
51 | import com.prws.common.utils.ScreenUtils; | 51 | import com.prws.common.utils.ScreenUtils; |
52 | import com.prws.common.utils.SharedPreferencesUtil; | 52 | import com.prws.common.utils.SharedPreferencesUtil; |
53 | import com.prws.common.utils.dialog.MyButtomDialog; | 53 | import com.prws.common.utils.dialog.MyButtomDialog; |
54 | import com.zhangteng.imagepicker.bean.ImageInfo; | 54 | import com.zhangteng.imagepicker.bean.ImageInfo; |
55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
59 | import com.zhangteng.utils.IHandlerCallBack; | 59 | import com.zhangteng.utils.IHandlerCallBack; |
60 | 60 | ||
61 | import java.io.File; | 61 | import java.io.File; |
62 | import java.util.ArrayList; | 62 | import java.util.ArrayList; |
63 | import java.util.Arrays; | 63 | import java.util.Arrays; |
64 | import java.util.HashMap; | 64 | import java.util.HashMap; |
65 | import java.util.List; | 65 | import java.util.List; |
66 | import java.util.Map; | 66 | import java.util.Map; |
67 | 67 | ||
68 | import io.reactivex.Observer; | 68 | import io.reactivex.Observer; |
69 | import io.reactivex.disposables.Disposable; | 69 | import io.reactivex.disposables.Disposable; |
70 | 70 | ||
71 | public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { | 71 | public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { |
72 | StudentBean studentBean; | 72 | StudentBean studentBean; |
73 | private int subject; | 73 | private int subject; |
74 | private ErrorAdapter adapter; | 74 | private ErrorAdapter adapter; |
75 | private int REQUEST_CODE_IMAGE = 123; | 75 | private int REQUEST_CODE_IMAGE = 123; |
76 | private String filePath; | 76 | private String filePath; |
77 | 77 | ||
78 | @Override | 78 | @Override |
79 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 79 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
80 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 80 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
81 | } | 81 | } |
82 | 82 | ||
83 | public void refreshStudent() { | 83 | public void refreshStudent() { |
84 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 84 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
85 | try { | 85 | try { |
86 | studentBean = new Gson().fromJson(student, StudentBean.class); | 86 | studentBean = new Gson().fromJson(student, StudentBean.class); |
87 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 87 | getBinding().tvChoose.setText(studentBean.getStuName()); |
88 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | ||
89 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | ||
90 | getBinding().ivStudent.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | ||
91 | } else { | ||
92 | Glide.with(getContext()).load(studentBean.getPhoto()).apply(options).into(getBinding().ivStudent); | ||
93 | } | ||
94 | getBinding().tvName.setText(studentBean.getStuName()); | ||
95 | } catch (Exception e) { | 88 | } catch (Exception e) { |
96 | 89 | ||
97 | } | 90 | } |
98 | } | 91 | } |
99 | 92 | ||
100 | @Override | 93 | @Override |
101 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 94 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
102 | super.onViewCreated(view, savedInstanceState); | 95 | super.onViewCreated(view, savedInstanceState); |
96 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | ||
97 | if (!TextUtils.isEmpty(photo)) { | ||
98 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | ||
99 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | ||
100 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | ||
101 | } | ||
102 | String name = (String) SharedPreferencesUtil.getData("name", ""); | ||
103 | getBinding().tvName.setText(name); | ||
103 | refreshStudent(); | 104 | refreshStudent(); |
104 | getBinding().rlTakePhoto.post(new Runnable() { | 105 | getBinding().rlTakePhoto.post(new Runnable() { |
105 | @Override | 106 | @Override |
106 | public void run() { | 107 | public void run() { |
107 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); | 108 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); |
108 | layoutParams.width = CommonUtil.getScreenWidth(getContext()); | 109 | layoutParams.width = CommonUtil.getScreenWidth(getContext()); |
109 | layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; | 110 | layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; |
110 | getBinding().rlTakePhoto.setLayoutParams(layoutParams); | 111 | getBinding().rlTakePhoto.setLayoutParams(layoutParams); |
111 | } | 112 | } |
112 | }); | 113 | }); |
113 | getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { | 114 | getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { |
114 | @Override | 115 | @Override |
115 | public void onClick(View v) { | 116 | public void onClick(View v) { |
116 | startActivity(new Intent(getContext(), TeacherChooseActivity.class)); | 117 | startActivity(new Intent(getContext(), TeacherChooseActivity.class)); |
117 | // getActivity().finish(); | 118 | // getActivity().finish(); |
118 | } | 119 | } |
119 | }); | 120 | }); |
120 | getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { | 121 | getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { |
121 | @Override | 122 | @Override |
122 | public void onClick(View v) { | 123 | public void onClick(View v) { |
123 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 124 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
124 | XXPermissions.with(getContext()) | 125 | XXPermissions.with(getContext()) |
125 | // 申请多个权限 | 126 | // 申请多个权限 |
126 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 127 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
127 | @Override | 128 | @Override |
128 | public void onGranted(List<String> permissions, boolean all) { | 129 | public void onGranted(List<String> permissions, boolean all) { |
129 | if (all) { | 130 | if (all) { |
130 | //开启扫码界面 | 131 | //开启扫码界面 |
131 | showButtonDialog(); | 132 | showButtonDialog(); |
132 | } else { | 133 | } else { |
133 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 134 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
137 | @Override | 138 | @Override |
138 | public void onDenied(List<String> permissions, boolean never) { | 139 | public void onDenied(List<String> permissions, boolean never) { |
139 | XXPermissions.startPermissionActivity(getContext(), permissions); | 140 | XXPermissions.startPermissionActivity(getContext(), permissions); |
140 | } | 141 | } |
141 | }); | 142 | }); |
142 | } else { | 143 | } else { |
143 | showButtonDialog(); | 144 | showButtonDialog(); |
144 | } | 145 | } |
145 | 146 | ||
146 | } | 147 | } |
147 | }); | 148 | }); |
148 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 149 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
149 | @Override | 150 | @Override |
150 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 151 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
151 | 152 | ||
152 | } | 153 | } |
153 | 154 | ||
154 | @Override | 155 | @Override |
155 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 156 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
156 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 157 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
157 | switch (item.getAdapterPosition()) { | 158 | switch (item.getAdapterPosition()) { |
158 | case 0: | 159 | case 0: |
159 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 160 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
160 | break; | 161 | break; |
161 | case 1: | 162 | case 1: |
162 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 163 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
163 | break; | 164 | break; |
164 | case 2: | 165 | case 2: |
165 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 166 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
166 | break; | 167 | break; |
167 | case 3: | 168 | case 3: |
168 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 169 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
169 | break; | 170 | break; |
170 | case 4: | 171 | case 4: |
171 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 172 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
172 | break; | 173 | break; |
173 | } | 174 | } |
174 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 175 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
175 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 176 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
176 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 177 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
177 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 178 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
178 | @Override | 179 | @Override |
179 | public void onClick(View v) { | 180 | public void onClick(View v) { |
180 | if (subject != item.getAdapterPosition()) { | 181 | if (subject != item.getAdapterPosition()) { |
181 | subject = item.getAdapterPosition(); | 182 | subject = item.getAdapterPosition(); |
182 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 183 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
183 | } | 184 | } |
184 | } | 185 | } |
185 | }); | 186 | }); |
186 | } | 187 | } |
187 | }; | 188 | }; |
188 | getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 189 | getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); |
189 | getBinding().recycleSubject.setAdapter(adapter); | 190 | getBinding().recycleSubject.setAdapter(adapter); |
190 | subject = 0; | 191 | subject = 0; |
191 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 192 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
192 | getBinding().llAll.setOnClickListener(new View.OnClickListener() { | 193 | getBinding().llAll.setOnClickListener(new View.OnClickListener() { |
193 | @Override | 194 | @Override |
194 | public void onClick(View v) { | 195 | public void onClick(View v) { |
195 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 196 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
196 | startActivity(intent); | 197 | startActivity(intent); |
197 | } | 198 | } |
198 | }); | 199 | }); |
199 | } | 200 | } |
200 | 201 | ||
201 | private void showButtonDialog() { | 202 | private void showButtonDialog() { |
202 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 203 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
203 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 204 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
204 | dialog.setContentView(bottomView); | 205 | dialog.setContentView(bottomView); |
205 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 206 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
206 | @Override | 207 | @Override |
207 | public void onClick(View view) { | 208 | public void onClick(View view) { |
208 | dialog.dismiss(); | 209 | dialog.dismiss(); |
209 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 210 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
210 | //确保有相机来处理Intent | 211 | //确保有相机来处理Intent |
211 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 212 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
212 | File photoFile = new File(filePath); | 213 | File photoFile = new File(filePath); |
213 | if (photoFile != null) { | 214 | if (photoFile != null) { |
214 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 215 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
215 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); | 216 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); |
216 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 217 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
217 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 218 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
218 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 219 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
219 | } | 220 | } |
220 | } | 221 | } |
221 | }); | 222 | }); |
222 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 223 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
223 | @Override | 224 | @Override |
224 | public void onClick(View view) { | 225 | public void onClick(View view) { |
225 | dialog.dismiss(); | 226 | dialog.dismiss(); |
226 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 227 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
227 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 228 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
228 | .multiSelect(true) //是否多选 | 229 | .multiSelect(true) //是否多选 |
229 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 230 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
230 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 231 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
231 | .maxImageSelectable(5) //图片可选择数 | 232 | .maxImageSelectable(5) //图片可选择数 |
232 | .maxHeight(1920) //图片最大高度 | 233 | .maxHeight(1920) //图片最大高度 |
233 | .maxWidth(1920) //图片最大宽度 | 234 | .maxWidth(1920) //图片最大宽度 |
234 | .maxImageSize(3) //图片最大大小Mb | 235 | .maxImageSize(3) //图片最大大小Mb |
235 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | 236 | .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(); |
236 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 237 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
237 | 238 | ||
238 | } | 239 | } |
239 | }); | 240 | }); |
240 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 241 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
241 | @Override | 242 | @Override |
242 | public void onClick(View view) { | 243 | public void onClick(View view) { |
243 | dialog.dismiss(); | 244 | dialog.dismiss(); |
244 | } | 245 | } |
245 | }); | 246 | }); |
246 | dialog.show(); | 247 | dialog.show(); |
247 | } | 248 | } |
248 | 249 | ||
249 | private void getError(String subject) { | 250 | private void getError(String subject) { |
250 | if (studentBean != null) { | 251 | if (studentBean != null) { |
251 | Map map = new HashMap(); | 252 | Map map = new HashMap(); |
252 | map.put("subject", subject); | 253 | map.put("subject", subject); |
253 | map.put("stuId", studentBean.getStuId()); | 254 | map.put("stuId", studentBean.getStuId()); |
254 | map.put("pageSize", 5); | 255 | map.put("pageSize", 5); |
255 | map.put("pageNum", 1); | 256 | map.put("pageNum", 1); |
256 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 257 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
257 | @Override | 258 | @Override |
258 | public void onSubscribe(Disposable d) { | 259 | public void onSubscribe(Disposable d) { |
259 | 260 | ||
260 | } | 261 | } |
261 | 262 | ||
262 | @Override | 263 | @Override |
263 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 264 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
264 | if (result.getData() != null && result.getCode() == 200) { | 265 | if (result.getData() != null && result.getCode() == 200) { |
265 | List<TopicBean> topicBeans = result.getData().getList(); | 266 | List<TopicBean> topicBeans = result.getData().getList(); |
266 | loadError(topicBeans); | 267 | loadError(topicBeans); |
267 | } | 268 | } |
268 | } | 269 | } |
269 | 270 | ||
270 | @Override | 271 | @Override |
271 | public void onError(Throwable e) { | 272 | public void onError(Throwable e) { |
272 | e.toString(); | 273 | e.toString(); |
273 | } | 274 | } |
274 | 275 | ||
275 | @Override | 276 | @Override |
276 | public void onComplete() { | 277 | public void onComplete() { |
277 | 278 | ||
278 | } | 279 | } |
279 | }); | 280 | }); |
280 | } | 281 | } |
281 | } | 282 | } |
282 | 283 | ||
283 | private void loadError(List<TopicBean> list) { | 284 | private void loadError(List<TopicBean> list) { |
284 | if (list.size() > 0) { | 285 | if (list.size() > 0) { |
285 | getBinding().recycleError.setVisibility(View.VISIBLE); | 286 | getBinding().recycleError.setVisibility(View.VISIBLE); |
286 | getBinding().llEmpty.setVisibility(View.GONE); | 287 | getBinding().llEmpty.setVisibility(View.GONE); |
287 | if (adapter != null) { | 288 | if (adapter != null) { |
288 | adapter.refresh(list); | 289 | adapter.refresh(list); |
289 | } else { | 290 | } else { |
290 | adapter = new ErrorAdapter(getActivity(), list, false); | 291 | adapter = new ErrorAdapter(getActivity(), list, false); |
291 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); | 292 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); |
292 | getBinding().recycleError.setAdapter(adapter); | 293 | getBinding().recycleError.setAdapter(adapter); |
293 | } | 294 | } |
294 | } else { | 295 | } else { |
295 | getBinding().recycleError.setVisibility(View.GONE); | 296 | getBinding().recycleError.setVisibility(View.GONE); |
296 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 297 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
297 | } | 298 | } |
298 | } | 299 | } |
299 | 300 | ||
300 | @Override | 301 | @Override |
301 | public void onResume() { | 302 | public void onResume() { |
302 | super.onResume(); | 303 | super.onResume(); |
303 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 304 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
304 | } | 305 | } |
305 | 306 | ||
306 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 307 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
307 | private String TAG = "---ImagePicker---"; | 308 | private String TAG = "---ImagePicker---"; |
308 | List<ImageInfo> photoList = new ArrayList<>(); | 309 | List<ImageInfo> photoList = new ArrayList<>(); |
309 | 310 | ||
310 | @Override | 311 | @Override |
311 | public void onStart() { | 312 | public void onStart() { |
312 | Log.i(TAG, "onStart: 开启"); | 313 | Log.i(TAG, "onStart: 开启"); |
313 | } | 314 | } |
314 | 315 | ||
315 | @Override | 316 | @Override |
316 | public void onSuccess(List<ImageInfo> photoList) { | 317 | public void onSuccess(List<ImageInfo> photoList) { |
317 | this.photoList = photoList; | 318 | this.photoList = photoList; |
318 | Log.i(TAG, "onSuccess: 返回数据"); | 319 | Log.i(TAG, "onSuccess: 返回数据"); |
319 | } | 320 | } |
320 | 321 | ||
321 | @Override | 322 | @Override |
322 | public void onCancel() { | 323 | public void onCancel() { |
323 | Log.i(TAG, "onCancel: 取消"); | 324 | Log.i(TAG, "onCancel: 取消"); |
324 | } | 325 | } |
325 | 326 | ||
326 | @Override | 327 | @Override |
327 | public void onFinish(List<ImageInfo> selectImage) { | 328 | public void onFinish(List<ImageInfo> selectImage) { |
328 | if (selectImage.size() == photoList.size()) { | 329 | if (selectImage.size() == photoList.size()) { |
329 | List<String> strings = new ArrayList<>(); | 330 | List<String> strings = new ArrayList<>(); |
330 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 331 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
331 | for (ImageInfo imageInfo : selectImage) { | 332 | for (ImageInfo imageInfo : selectImage) { |
332 | strings.add(imageInfo.getPath()); | 333 | strings.add(imageInfo.getPath()); |
333 | } | 334 | } |
334 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 335 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
335 | startActivity(intent); | 336 | startActivity(intent); |
336 | } | 337 | } |
337 | } | 338 | } |
338 | 339 | ||
339 | @Override | 340 | @Override |
340 | public void onError() { | 341 | public void onError() { |
341 | Log.i(TAG, "onError: 出错"); | 342 | Log.i(TAG, "onError: 出错"); |
342 | } | 343 | } |
343 | } | 344 | } |
344 | 345 | ||
345 | @Override | 346 | @Override |
346 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 347 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
347 | super.onActivityResult(requestCode, resultCode, data); | 348 | super.onActivityResult(requestCode, resultCode, data); |
348 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 349 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
349 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 350 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
350 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 351 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
351 | CommonUtil.saveBitmapToUri(b, path); | 352 | CommonUtil.saveBitmapToUri(b, path); |
352 | List<String> strings = new ArrayList<>(); | 353 | List<String> strings = new ArrayList<>(); |
353 | Intent intent = new Intent(getContext(), ImageActivity.class); | 354 | Intent intent = new Intent(getContext(), ImageActivity.class); |
app/src/main/java/com/hjx/parent/fragment/HomeFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
6 | import android.view.LayoutInflater; | 6 | import android.view.LayoutInflater; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
9 | import android.widget.LinearLayout; | 9 | import android.widget.LinearLayout; |
10 | import android.widget.TextView; | 10 | import android.widget.TextView; |
11 | import android.widget.Toast; | 11 | import android.widget.Toast; |
12 | 12 | ||
13 | import androidx.annotation.NonNull; | 13 | import androidx.annotation.NonNull; |
14 | import androidx.annotation.Nullable; | 14 | import androidx.annotation.Nullable; |
15 | import androidx.recyclerview.widget.LinearLayoutManager; | 15 | import androidx.recyclerview.widget.LinearLayoutManager; |
16 | import androidx.recyclerview.widget.RecyclerView; | 16 | import androidx.recyclerview.widget.RecyclerView; |
17 | 17 | ||
18 | import com.bumptech.glide.Glide; | 18 | import com.bumptech.glide.Glide; |
19 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 19 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
20 | import com.bumptech.glide.request.RequestOptions; | 20 | import com.bumptech.glide.request.RequestOptions; |
21 | import com.chad.library.adapter.base.BaseQuickAdapter; | 21 | import com.chad.library.adapter.base.BaseQuickAdapter; |
22 | import com.chad.library.adapter.base.BaseViewHolder; | 22 | import com.chad.library.adapter.base.BaseViewHolder; |
23 | import com.google.gson.Gson; | 23 | import com.google.gson.Gson; |
24 | import com.hjq.permissions.OnPermissionCallback; | 24 | import com.hjq.permissions.OnPermissionCallback; |
25 | import com.hjq.permissions.Permission; | 25 | import com.hjq.permissions.Permission; |
26 | import com.hjq.permissions.XXPermissions; | 26 | import com.hjq.permissions.XXPermissions; |
27 | import com.hjx.parent.ChooseActivity; | 27 | import com.hjx.parent.ChooseActivity; |
28 | import com.hjx.parent.ErrorBookActivity; | 28 | import com.hjx.parent.ErrorBookActivity; |
29 | import com.hjx.parent.QRActivity; | 29 | import com.hjx.parent.QRActivity; |
30 | import com.hjx.parent.R; | 30 | import com.hjx.parent.R; |
31 | import com.hjx.parent.bean.StudentBean; | 31 | import com.hjx.parent.bean.StudentBean; |
32 | import com.prws.common.base.BaseFragment; | 32 | import com.prws.common.base.BaseFragment; |
33 | import com.prws.common.bean.ResponseResult; | 33 | import com.prws.common.bean.ResponseResult; |
34 | import com.prws.common.bean.ScheduleBean; | 34 | import com.prws.common.bean.ScheduleBean; |
35 | import com.prws.common.bean.Video; | 35 | import com.prws.common.bean.Video; |
36 | import com.prws.common.net.NetWorks; | 36 | import com.prws.common.net.NetWorks; |
37 | import com.prws.common.utils.ScreenUtils; | 37 | import com.prws.common.utils.ScreenUtils; |
38 | import com.prws.common.utils.SharedPreferencesUtil; | 38 | import com.prws.common.utils.SharedPreferencesUtil; |
39 | import com.uuzuche.lib_zxing.activity.CaptureActivity; | 39 | import com.uuzuche.lib_zxing.activity.CaptureActivity; |
40 | import com.uuzuche.lib_zxing.activity.CodeUtils; | 40 | import com.uuzuche.lib_zxing.activity.CodeUtils; |
41 | 41 | ||
42 | import java.text.SimpleDateFormat; | 42 | import java.text.SimpleDateFormat; |
43 | import java.util.ArrayList; | 43 | import java.util.ArrayList; |
44 | import java.util.List; | 44 | import java.util.List; |
45 | 45 | ||
46 | import butterknife.BindView; | 46 | import butterknife.BindView; |
47 | import butterknife.OnClick; | 47 | import butterknife.OnClick; |
48 | import io.reactivex.Observer; | 48 | import io.reactivex.Observer; |
49 | import io.reactivex.disposables.Disposable; | 49 | import io.reactivex.disposables.Disposable; |
50 | 50 | ||
51 | public class HomeFragment extends BaseFragment { | 51 | public class HomeFragment extends BaseFragment { |
52 | @Override | 52 | @Override |
53 | protected int getLayoutRes() { | 53 | protected int getLayoutRes() { |
54 | return R.layout.fragment_home; | 54 | return R.layout.fragment_home; |
55 | } | 55 | } |
56 | 56 | ||
57 | ImageView iv_sapmiao; | 57 | ImageView iv_sapmiao; |
58 | TextView tv_name; | 58 | TextView tv_name; |
59 | StudentBean studentBean; | 59 | StudentBean studentBean; |
60 | ImageView iv_2; | 60 | ImageView iv_2; |
61 | @BindView(R.id.recycle) | 61 | @BindView(R.id.recycle) |
62 | RecyclerView recyclerView; | 62 | RecyclerView recyclerView; |
63 | @BindView(R.id.tv_empty) | 63 | @BindView(R.id.tv_empty) |
64 | TextView tv_empty; | 64 | TextView tv_empty; |
65 | @BindView(R.id.iv_empty) | 65 | @BindView(R.id.iv_empty) |
66 | ImageView iv_empty; | 66 | ImageView iv_empty; |
67 | 67 | ||
68 | @Override | 68 | @Override |
69 | protected void initDatas() { | 69 | protected void initDatas() { |
70 | super.initDatas(); | 70 | super.initDatas(); |
71 | iv_2 = mRootView.findViewById(R.id.iv_2); | 71 | iv_2 = mRootView.findViewById(R.id.iv_2); |
72 | iv_sapmiao = mRootView.findViewById(R.id.iv_sapmiao); | 72 | iv_sapmiao = mRootView.findViewById(R.id.iv_sapmiao); |
73 | tv_name = mRootView.findViewById(R.id.tv_name); | 73 | tv_name = mRootView.findViewById(R.id.tv_name); |
74 | iv_sapmiao.setOnClickListener(view -> { | 74 | iv_sapmiao.setOnClickListener(view -> { |
75 | if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)) { | 75 | if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)) { |
76 | XXPermissions.with(getActivity()) | 76 | XXPermissions.with(getActivity()) |
77 | // 申请多个权限 | 77 | // 申请多个权限 |
78 | .permission(Permission.CAMERA) | 78 | .permission(Permission.CAMERA) |
79 | .request(new OnPermissionCallback() { | 79 | .request(new OnPermissionCallback() { |
80 | @Override | 80 | @Override |
81 | public void onGranted(List<String> permissions, boolean all) { | 81 | public void onGranted(List<String> permissions, boolean all) { |
82 | if (all) { | 82 | if (all) { |
83 | //开启扫码界面 | 83 | //开启扫码界面 |
84 | startQRView(); | 84 | startQRView(); |
85 | 85 | ||
86 | 86 | ||
87 | } else { | 87 | } else { |
88 | Toast.makeText(getActivity(), "需要相机权限", Toast.LENGTH_SHORT).show(); | 88 | Toast.makeText(getActivity(), "需要相机权限", Toast.LENGTH_SHORT).show(); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | @Override | 92 | @Override |
93 | public void onDenied(List<String> permissions, boolean never) { | 93 | public void onDenied(List<String> permissions, boolean never) { |
94 | XXPermissions.startPermissionActivity(getActivity(), permissions); | 94 | XXPermissions.startPermissionActivity(getActivity(), permissions); |
95 | } | 95 | } |
96 | }); | 96 | }); |
97 | } else { | 97 | } else { |
98 | startQRView(); | 98 | startQRView(); |
99 | } | 99 | } |
100 | 100 | ||
101 | }); | 101 | }); |
102 | } | 102 | } |
103 | 103 | ||
104 | @OnClick({R.id.ll_device, R.id.ll_app}) | ||
105 | public void goApps(View view) { | ||
106 | Toast.makeText(getActivity(), "功能暂未上线,敬请期待", Toast.LENGTH_SHORT).show(); | ||
107 | } | ||
108 | |||
104 | @OnClick(R.id.ll_error) | 109 | @OnClick(R.id.ll_error) |
105 | public void goError(View view) { | 110 | public void goError(View view) { |
106 | Intent intent = new Intent(getActivity(), ErrorBookActivity.class); | 111 | Intent intent = new Intent(getActivity(), ErrorBookActivity.class); |
107 | startActivity(intent); | 112 | startActivity(intent); |
108 | } | 113 | } |
109 | 114 | ||
110 | @Override | 115 | @Override |
111 | public void onResume() { | 116 | public void onResume() { |
112 | super.onResume(); | 117 | super.onResume(); |
113 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 118 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
114 | try { | 119 | try { |
115 | studentBean = new Gson().fromJson(student, StudentBean.class); | 120 | studentBean = new Gson().fromJson(student, StudentBean.class); |
116 | tv_name.setText(studentBean.getNickName()); | 121 | tv_name.setText(studentBean.getNickName()); |
117 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | 122 | if (TextUtils.isEmpty(studentBean.getPhoto())) { |
118 | iv_2.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 123 | iv_2.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
119 | } else { | 124 | } else { |
120 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 30)); | 125 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 30)); |
121 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 126 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
122 | Glide.with(getActivity()).load(studentBean.getPhoto()).apply(options).into(iv_2); | 127 | Glide.with(getActivity()).load(studentBean.getPhoto()).apply(options).into(iv_2); |
123 | } | 128 | } |
124 | getWeekPlan(studentBean.getStuId()); | 129 | getWeekPlan(studentBean.getStuId()); |
125 | } catch (Exception e) { | 130 | } catch (Exception e) { |
126 | 131 | ||
127 | } | 132 | } |
128 | } | 133 | } |
129 | 134 | ||
130 | public void getWeekPlan(String id) { | 135 | public void getWeekPlan(String id) { |
131 | NetWorks.getWeekPlan(id, new Observer<ResponseResult<ScheduleBean>>() { | 136 | NetWorks.getWeekPlan(id, new Observer<ResponseResult<ScheduleBean>>() { |
132 | @Override | 137 | @Override |
133 | public void onSubscribe(Disposable d) { | 138 | public void onSubscribe(Disposable d) { |
134 | 139 | ||
135 | } | 140 | } |
136 | 141 | ||
137 | @Override | 142 | @Override |
138 | public void onNext(ResponseResult<ScheduleBean> result) { | 143 | public void onNext(ResponseResult<ScheduleBean> result) { |
139 | if (result != null && result.getCode() == 200) { | 144 | if (result != null && result.getCode() == 200) { |
140 | showWeekPlan(result.getData().getList()); | 145 | showWeekPlan(result.getData().getList()); |
141 | } | 146 | } |
142 | } | 147 | } |
143 | 148 | ||
144 | @Override | 149 | @Override |
145 | public void onError(Throwable e) { | 150 | public void onError(Throwable e) { |
146 | 151 | ||
147 | } | 152 | } |
148 | 153 | ||
149 | @Override | 154 | @Override |
150 | public void onComplete() { | 155 | public void onComplete() { |
151 | 156 | ||
152 | } | 157 | } |
153 | }); | 158 | }); |
154 | } | 159 | } |
155 | 160 | ||
156 | public void startQRView() { | 161 | public void startQRView() { |
157 | startActivityForResult(new Intent(getActivity(), QRActivity.class), 101); | 162 | startActivityForResult(new Intent(getActivity(), QRActivity.class), 101); |
158 | } | 163 | } |
159 | 164 | ||
160 | @Override | 165 | @Override |
161 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 166 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
162 | super.onActivityResult(requestCode, resultCode, data); | 167 | super.onActivityResult(requestCode, resultCode, data); |
163 | if (requestCode == 101) { | 168 | if (requestCode == 101) { |
164 | if (null != data) { | 169 | if (null != data) { |
165 | Bundle bundle = data.getExtras(); | 170 | Bundle bundle = data.getExtras(); |
166 | if (bundle == null) { | 171 | if (bundle == null) { |
167 | return; | 172 | return; |
168 | } | 173 | } |
169 | if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { | 174 | if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { |
170 | String result = bundle.getString(CodeUtils.RESULT_STRING); | 175 | String result = bundle.getString(CodeUtils.RESULT_STRING); |
171 | Toast.makeText(getActivity(), "解析结果:" + result, Toast.LENGTH_LONG).show(); | 176 | Toast.makeText(getActivity(), "解析结果:" + result, Toast.LENGTH_LONG).show(); |
172 | } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { | 177 | } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { |
173 | Toast.makeText(getActivity(), "解析二维码失败", Toast.LENGTH_LONG).show(); | 178 | Toast.makeText(getActivity(), "解析二维码失败", Toast.LENGTH_LONG).show(); |
174 | } | 179 | } |
175 | } | 180 | } |
176 | } | 181 | } |
177 | } | 182 | } |
178 | 183 | ||
179 | @OnClick({R.id.iv_3, R.id.tv_name}) | 184 | @OnClick({R.id.iv_3, R.id.tv_name}) |
180 | public void choose(View view) { | 185 | public void choose(View view) { |
181 | Intent intent = new Intent(getActivity(), ChooseActivity.class); | 186 | Intent intent = new Intent(getActivity(), ChooseActivity.class); |
182 | startActivity(intent); | 187 | startActivity(intent); |
183 | } | 188 | } |
184 | 189 | ||
185 | @OnClick(R.id.iv_1) | 190 | @OnClick(R.id.iv_1) |
186 | public void exit(View view) { | 191 | public void exit(View view) { |
187 | getActivity().finish(); | 192 | getActivity().finish(); |
188 | } | 193 | } |
189 | 194 | ||
190 | private void showWeekPlan(List<Video> list) { | 195 | private void showWeekPlan(List<Video> list) { |
191 | iv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); | 196 | iv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); |
192 | tv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); | 197 | tv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); |
193 | List<Schedule> schedules = new ArrayList<>(); | 198 | List<Schedule> schedules = new ArrayList<>(); |
194 | for (int i = 0; i < list.size(); i++) { | 199 | for (int i = 0; i < list.size(); i++) { |
195 | String date = new SimpleDateFormat("yyyy.MM.dd").format(list.get(i).getStudyTime()); | 200 | String date = new SimpleDateFormat("yyyy.MM.dd").format(list.get(i).getStudyTime()); |
196 | if (schedules.size() > 0 && schedules.get(schedules.size() - 1).getDate().equals(date)) { | 201 | if (schedules.size() > 0 && schedules.get(schedules.size() - 1).getDate().equals(date)) { |
197 | schedules.get(schedules.size() - 1).getStrings().add(list.get(i).getSectionChildName()); | 202 | schedules.get(schedules.size() - 1).getStrings().add(list.get(i).getSectionChildName()); |
198 | } else { | 203 | } else { |
199 | List<String> stringList = new ArrayList<>(); | 204 | List<String> stringList = new ArrayList<>(); |
200 | Schedule schedule = new Schedule(); | 205 | Schedule schedule = new Schedule(); |
201 | schedule.setDate(date); | 206 | schedule.setDate(date); |
202 | stringList.add(list.get(i).getSectionChildName()); | 207 | stringList.add(list.get(i).getSectionChildName()); |
203 | schedule.setStrings(stringList); | 208 | schedule.setStrings(stringList); |
204 | schedules.add(schedule); | 209 | schedules.add(schedule); |
205 | } | 210 | } |
206 | } | 211 | } |
207 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_schedule, schedules) { | 212 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_schedule, schedules) { |
208 | @Override | 213 | @Override |
209 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 214 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
210 | 215 | ||
211 | } | 216 | } |
212 | 217 | ||
213 | @Override | 218 | @Override |
214 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 219 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
215 | Schedule schedule = schedules.get(item.getAdapterPosition()); | 220 | Schedule schedule = schedules.get(item.getAdapterPosition()); |
216 | item.setText(R.id.tv_date, schedule.getDate()); | 221 | item.setText(R.id.tv_date, schedule.getDate()); |
217 | LinearLayout layout = item.getView(R.id.ll_schedule); | 222 | LinearLayout layout = item.getView(R.id.ll_schedule); |
218 | for (int i = 0; i < schedule.getStrings().size(); i++) { | 223 | for (int i = 0; i < schedule.getStrings().size(); i++) { |
219 | View view = LayoutInflater.from(getContext()).inflate(R.layout.item_video, null); | 224 | View view = LayoutInflater.from(getContext()).inflate(R.layout.item_video, null); |
220 | TextView textView = view.findViewById(R.id.tv_name); | 225 | TextView textView = view.findViewById(R.id.tv_name); |
221 | textView.setText(schedule.getStrings().get(i)); | 226 | textView.setText(schedule.getStrings().get(i)); |
222 | layout.addView(view); | 227 | layout.addView(view); |
223 | } | 228 | } |
224 | } | 229 | } |
225 | }; | 230 | }; |
226 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); | 231 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); |
227 | recyclerView.setAdapter(adapter); | 232 | recyclerView.setAdapter(adapter); |
228 | } | 233 | } |
229 | 234 | ||
230 | class Schedule { | 235 | class Schedule { |
231 | String date; | 236 | String date; |
232 | List<String> strings; | 237 | List<String> strings; |
233 | 238 | ||
234 | public void setDate(String date) { | 239 | public void setDate(String date) { |
235 | this.date = date; | 240 | this.date = date; |
236 | } | 241 | } |
237 | 242 | ||
238 | public void setStrings(List<String> strings) { | 243 | public void setStrings(List<String> strings) { |
239 | this.strings = strings; | 244 | this.strings = strings; |
240 | } | 245 | } |
241 | 246 | ||
242 | public String getDate() { | 247 | public String getDate() { |
243 | return date; | 248 | return date; |
244 | } | 249 | } |
245 | 250 | ||
246 | public List<String> getStrings() { | 251 | public List<String> getStrings() { |
247 | return strings; | 252 | return strings; |
248 | } | 253 | } |
249 | } | 254 | } |
250 | } | 255 | } |
251 | 256 |
app/src/main/java/com/hjx/parent/fragment/MeFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import android.app.AlertDialog; | 3 | import android.app.AlertDialog; |
4 | import android.content.DialogInterface; | 4 | import android.content.DialogInterface; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
9 | import android.widget.TextView; | 9 | import android.widget.TextView; |
10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
11 | 11 | ||
12 | import androidx.annotation.NonNull; | 12 | import androidx.annotation.NonNull; |
13 | import androidx.annotation.Nullable; | 13 | import androidx.annotation.Nullable; |
14 | import androidx.constraintlayout.widget.Group; | 14 | import androidx.constraintlayout.widget.Group; |
15 | import androidx.recyclerview.widget.LinearLayoutManager; | 15 | import androidx.recyclerview.widget.LinearLayoutManager; |
16 | import androidx.recyclerview.widget.RecyclerView; | 16 | import androidx.recyclerview.widget.RecyclerView; |
17 | 17 | ||
18 | import com.bumptech.glide.Glide; | 18 | import com.bumptech.glide.Glide; |
19 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 19 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
20 | import com.bumptech.glide.request.RequestOptions; | 20 | import com.bumptech.glide.request.RequestOptions; |
21 | import com.chad.library.adapter.base.BaseQuickAdapter; | 21 | import com.chad.library.adapter.base.BaseQuickAdapter; |
22 | import com.chad.library.adapter.base.BaseViewHolder; | 22 | import com.chad.library.adapter.base.BaseViewHolder; |
23 | import com.developer.wang.utils.PermissionUtils; | 23 | import com.developer.wang.utils.PermissionUtils; |
24 | import com.google.gson.Gson; | 24 | import com.google.gson.Gson; |
25 | import com.google.gson.JsonArray; | 25 | import com.google.gson.JsonArray; |
26 | import com.hjq.permissions.OnPermissionCallback; | 26 | import com.hjq.permissions.OnPermissionCallback; |
27 | import com.hjq.permissions.Permission; | 27 | import com.hjq.permissions.Permission; |
28 | import com.hjq.permissions.XXPermissions; | 28 | import com.hjq.permissions.XXPermissions; |
29 | import com.hjx.parent.AccountActivity; | 29 | import com.hjx.parent.AccountActivity; |
30 | import com.hjx.parent.AddStudentActivity; | 30 | import com.hjx.parent.AddStudentActivity; |
31 | import com.hjx.parent.EditStudentActivity; | 31 | import com.hjx.parent.EditStudentActivity; |
32 | import com.hjx.parent.LoginActivity; | 32 | import com.hjx.parent.LoginActivity; |
33 | import com.hjx.parent.MainActivity; | 33 | import com.hjx.parent.MainActivity; |
34 | import com.hjx.parent.QRActivity; | 34 | import com.hjx.parent.QRActivity; |
35 | import com.hjx.parent.R; | 35 | import com.hjx.parent.R; |
36 | import com.hjx.parent.UserActivity; | 36 | import com.hjx.parent.UserActivity; |
37 | import com.hjx.parent.YinsiActivity; | 37 | import com.hjx.parent.YinsiActivity; |
38 | import com.hjx.parent.bean.StudentBean; | 38 | import com.hjx.parent.bean.StudentBean; |
39 | import com.prws.common.base.BaseFragment; | 39 | import com.prws.common.base.BaseFragment; |
40 | import com.prws.common.net.NetWorks; | 40 | import com.prws.common.net.NetWorks; |
41 | import com.prws.common.utils.LogUtil; | 41 | import com.prws.common.utils.LogUtil; |
42 | import com.prws.common.utils.ScreenUtils; | 42 | import com.prws.common.utils.ScreenUtils; |
43 | import com.prws.common.utils.SharedPreferencesUtil; | 43 | import com.prws.common.utils.SharedPreferencesUtil; |
44 | 44 | ||
45 | import org.json.JSONArray; | 45 | import org.json.JSONArray; |
46 | import org.json.JSONObject; | 46 | import org.json.JSONObject; |
47 | 47 | ||
48 | import java.util.ArrayList; | 48 | import java.util.ArrayList; |
49 | import java.util.HashMap; | 49 | import java.util.HashMap; |
50 | import java.util.List; | 50 | import java.util.List; |
51 | import java.util.Map; | 51 | import java.util.Map; |
52 | 52 | ||
53 | import butterknife.BindView; | 53 | import butterknife.BindView; |
54 | import butterknife.OnClick; | 54 | import butterknife.OnClick; |
55 | import io.reactivex.Observer; | 55 | import io.reactivex.Observer; |
56 | import io.reactivex.disposables.Disposable; | 56 | import io.reactivex.disposables.Disposable; |
57 | import okhttp3.ResponseBody; | 57 | import okhttp3.ResponseBody; |
58 | 58 | ||
59 | public class MeFragment extends BaseFragment { | 59 | public class MeFragment extends BaseFragment { |
60 | @Override | 60 | @Override |
61 | protected int getLayoutRes() { | 61 | protected int getLayoutRes() { |
62 | return R.layout.fragment_me; | 62 | return R.layout.fragment_me; |
63 | } | 63 | } |
64 | 64 | ||
65 | Group group_1; | 65 | Group group_1; |
66 | TextView tv_name; | 66 | TextView tv_name; |
67 | TextView tv_phone; | 67 | TextView tv_phone; |
68 | ImageView iv_toux; | 68 | ImageView iv_toux; |
69 | RecyclerView recycle; | 69 | RecyclerView recycle; |
70 | 70 | ||
71 | @Override | 71 | @Override |
72 | protected void initDatas() { | 72 | protected void initDatas() { |
73 | super.initDatas(); | 73 | super.initDatas(); |
74 | recycle = mRootView.findViewById(R.id.recycle); | 74 | recycle = mRootView.findViewById(R.id.recycle); |
75 | group_1 = mRootView.findViewById(R.id.group_1); | 75 | group_1 = mRootView.findViewById(R.id.group_1); |
76 | String role = (String) SharedPreferencesUtil.getData("role", ""); | 76 | String role = (String) SharedPreferencesUtil.getData("role", ""); |
77 | String userId = (String) SharedPreferencesUtil.getData("userId", ""); | 77 | String userId = (String) SharedPreferencesUtil.getData("userId", ""); |
78 | String token = (String) SharedPreferencesUtil.getData("token", ""); | 78 | String token = (String) SharedPreferencesUtil.getData("token", ""); |
79 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); | 79 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); |
80 | group_1.setVisibility(View.VISIBLE); | 80 | group_1.setVisibility(View.VISIBLE); |
81 | iv_toux = mRootView.findViewById(R.id.iv_toux); | 81 | iv_toux = mRootView.findViewById(R.id.iv_toux); |
82 | tv_name = mRootView.findViewById(R.id.tv_name); | 82 | tv_name = mRootView.findViewById(R.id.tv_name); |
83 | tv_phone = mRootView.findViewById(R.id.tv_phone); | 83 | tv_phone = mRootView.findViewById(R.id.tv_phone); |
84 | tv_phone.setVisibility(View.GONE); | 84 | tv_phone.setVisibility(View.GONE); |
85 | // tv_phone.setText(phone); | 85 | // tv_phone.setText(phone); |
86 | tv_name.setText(phone); | 86 | tv_name.setText(phone); |
87 | } | 87 | } |
88 | 88 | ||
89 | @Override | 89 | @Override |
90 | public void onResume() { | 90 | public void onResume() { |
91 | super.onResume(); | 91 | super.onResume(); |
92 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 92 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
93 | if (!TextUtils.isEmpty(photo)) { | 93 | if (!TextUtils.isEmpty(photo)) { |
94 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 94 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
95 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 95 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
96 | Glide.with(getContext()).load(photo).apply(options).into(iv_toux); | 96 | Glide.with(getContext()).load(photo).error(R.mipmap.ic_parent_avatar).apply(options).into(iv_toux); |
97 | } | 97 | } |
98 | loadChildList(); | 98 | loadChildList(); |
99 | } | 99 | } |
100 | 100 | ||
101 | ArrayList<StudentBean> alist = new ArrayList<>(); | 101 | ArrayList<StudentBean> alist = new ArrayList<>(); |
102 | 102 | ||
103 | public void loadChildList() { | 103 | public void loadChildList() { |
104 | NetWorks.listChildren(new Observer<ResponseBody>() { | 104 | NetWorks.listChildren(new Observer<ResponseBody>() { |
105 | @Override | 105 | @Override |
106 | public void onSubscribe(Disposable d) { | 106 | public void onSubscribe(Disposable d) { |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | @Override | 110 | @Override |
111 | public void onNext(ResponseBody responseBody) { | 111 | public void onNext(ResponseBody responseBody) { |
112 | try { | 112 | try { |
113 | 113 | ||
114 | String str = responseBody.string().toString(); | 114 | String str = responseBody.string().toString(); |
115 | 115 | ||
116 | 116 | ||
117 | LogUtil.e("TAG", "----" + str); | 117 | LogUtil.e("TAG", "----" + str); |
118 | JSONObject jo = new JSONObject(str); | 118 | JSONObject jo = new JSONObject(str); |
119 | boolean isSucceed = jo.getBoolean("success"); | 119 | boolean isSucceed = jo.getBoolean("success"); |
120 | if (isSucceed) { | 120 | if (isSucceed) { |
121 | JSONArray jarr = jo.getJSONArray("data"); | 121 | JSONArray jarr = jo.getJSONArray("data"); |
122 | alist.clear(); | 122 | alist.clear(); |
123 | for (int i = 0; i < jarr.length(); i++) { | 123 | for (int i = 0; i < jarr.length(); i++) { |
124 | JSONObject jo2 = jarr.getJSONObject(i); | 124 | JSONObject jo2 = jarr.getJSONObject(i); |
125 | Gson gson = new Gson(); | 125 | Gson gson = new Gson(); |
126 | StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class); | 126 | StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class); |
127 | alist.add(sb); | 127 | alist.add(sb); |
128 | } | 128 | } |
129 | if (alist.size() > 0) { | 129 | if (alist.size() > 0) { |
130 | loadList(); | 130 | loadList(); |
131 | } | 131 | } |
132 | 132 | ||
133 | } else { | 133 | } else { |
134 | 134 | ||
135 | } | 135 | } |
136 | } catch (Exception e) { | 136 | } catch (Exception e) { |
137 | e.printStackTrace(); | 137 | e.printStackTrace(); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | @Override | 141 | @Override |
142 | public void onError(Throwable e) { | 142 | public void onError(Throwable e) { |
143 | e.toString(); | 143 | e.toString(); |
144 | } | 144 | } |
145 | 145 | ||
146 | @Override | 146 | @Override |
147 | public void onComplete() { | 147 | public void onComplete() { |
148 | 148 | ||
149 | } | 149 | } |
150 | }); | 150 | }); |
151 | mRootView.findViewById(R.id.view_4).setOnClickListener(view -> startActivity(new Intent(getActivity(), YinsiActivity.class))); | 151 | mRootView.findViewById(R.id.view_4).setOnClickListener(view -> startActivity(new Intent(getActivity(), YinsiActivity.class))); |
152 | mRootView.findViewById(R.id.view_5).setOnClickListener(view -> startActivity(new Intent(getActivity(), UserActivity.class))); | 152 | mRootView.findViewById(R.id.view_5).setOnClickListener(view -> startActivity(new Intent(getActivity(), UserActivity.class))); |
153 | mRootView.findViewById(R.id.view_3).setOnClickListener(view -> startActivityForResult(new Intent(getActivity(), AccountActivity.class), 1003)); | 153 | mRootView.findViewById(R.id.view_3).setOnClickListener(view -> startActivityForResult(new Intent(getActivity(), AccountActivity.class), 1003)); |
154 | } | 154 | } |
155 | 155 | ||
156 | // @Override | 156 | // @Override |
157 | // public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 157 | // public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
158 | // super.onActivityResult(requestCode, resultCode, data); | 158 | // super.onActivityResult(requestCode, resultCode, data); |
159 | // Intent intent = new Intent(getActivity(), LoginActivity.class); | 159 | // Intent intent = new Intent(getActivity(), LoginActivity.class); |
160 | // startActivity(intent); | 160 | // startActivity(intent); |
161 | // getActivity().finish(); | 161 | // getActivity().finish(); |
162 | // } | 162 | // } |
163 | 163 | ||
164 | public void loadList() { | 164 | public void loadList() { |
165 | StudentBean sb = new StudentBean(); | 165 | StudentBean sb = new StudentBean(); |
166 | sb.setNickName("添加学生"); | 166 | sb.setNickName("添加学生"); |
167 | alist.add(0, sb); | 167 | alist.add(0, sb); |
168 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child, alist) { | 168 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child, alist) { |
169 | @Override | 169 | @Override |
170 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 170 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | @Override | 174 | @Override |
175 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 175 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
176 | StudentBean studentBean = alist.get(item.getAdapterPosition()); | 176 | StudentBean studentBean = alist.get(item.getAdapterPosition()); |
177 | item.setText(R.id.tv_name, studentBean.getNickName()); | 177 | item.setText(R.id.tv_name, studentBean.getNickName()); |
178 | if (TextUtils.isEmpty(studentBean.getStuId())) { | 178 | if (TextUtils.isEmpty(studentBean.getStuId())) { |
179 | item.setImageResource(R.id.iv_avatar, R.mipmap.tjxss); | 179 | item.setImageResource(R.id.iv_avatar, R.mipmap.tjxss); |
180 | item.setVisible(R.id.iv_vip, false); | 180 | item.setVisible(R.id.iv_vip, false); |
181 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 181 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
182 | @Override | 182 | @Override |
183 | public void onClick(View view) { | 183 | public void onClick(View view) { |
184 | startActivity(new Intent(getActivity(), AddStudentActivity.class)); | 184 | startActivity(new Intent(getActivity(), AddStudentActivity.class)); |
185 | } | 185 | } |
186 | }); | 186 | }); |
187 | } else { | 187 | } else { |
188 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | 188 | if (TextUtils.isEmpty(studentBean.getPhoto())) { |
189 | item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 189 | item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
190 | } else { | 190 | } else { |
191 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 191 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
192 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 192 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
193 | Glide.with(getActivity()).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar)); | 193 | Glide.with(getActivity()).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar)); |
194 | } | 194 | } |
195 | item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity())); | 195 | item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity())); |
196 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 196 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
197 | @Override | 197 | @Override |
198 | public void onClick(View view) { | 198 | public void onClick(View view) { |
199 | startActivity(new Intent(getActivity(), EditStudentActivity.class).putExtra("student", new Gson().toJson(studentBean))); | 199 | startActivity(new Intent(getActivity(), EditStudentActivity.class).putExtra("student", new Gson().toJson(studentBean))); |
200 | } | 200 | } |
201 | }); | 201 | }); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | }; | 204 | }; |
205 | recycle.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 205 | recycle.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); |
206 | recycle.setAdapter(adapter); | 206 | recycle.setAdapter(adapter); |
207 | } | 207 | } |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 |
app/src/main/java/com/hjx/parent/fragment/TeacherFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; | 3 | import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; |
4 | import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; | 4 | import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; |
5 | 5 | ||
6 | import android.app.AlertDialog; | 6 | import android.app.AlertDialog; |
7 | import android.content.DialogInterface; | 7 | import android.content.DialogInterface; |
8 | import android.content.Intent; | 8 | import android.content.Intent; |
9 | import android.graphics.drawable.Drawable; | 9 | import android.graphics.drawable.Drawable; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
12 | import android.view.LayoutInflater; | 12 | import android.view.LayoutInflater; |
13 | import android.view.MotionEvent; | 13 | import android.view.MotionEvent; |
14 | import android.view.View; | 14 | import android.view.View; |
15 | import android.view.ViewGroup; | 15 | import android.view.ViewGroup; |
16 | import android.webkit.WebSettings; | 16 | import android.webkit.WebSettings; |
17 | import android.webkit.WebView; | 17 | import android.webkit.WebView; |
18 | import android.widget.ImageView; | 18 | import android.widget.ImageView; |
19 | import android.widget.LinearLayout; | 19 | import android.widget.LinearLayout; |
20 | 20 | ||
21 | import androidx.annotation.NonNull; | 21 | import androidx.annotation.NonNull; |
22 | import androidx.annotation.Nullable; | 22 | import androidx.annotation.Nullable; |
23 | import androidx.recyclerview.widget.LinearLayoutManager; | 23 | import androidx.recyclerview.widget.LinearLayoutManager; |
24 | import androidx.recyclerview.widget.RecyclerView; | 24 | import androidx.recyclerview.widget.RecyclerView; |
25 | 25 | ||
26 | import com.bumptech.glide.Glide; | 26 | import com.bumptech.glide.Glide; |
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | import com.bumptech.glide.request.RequestOptions; | 28 | import com.bumptech.glide.request.RequestOptions; |
29 | import com.bumptech.glide.request.target.SimpleTarget; | 29 | import com.bumptech.glide.request.target.SimpleTarget; |
30 | import com.bumptech.glide.request.transition.Transition; | 30 | import com.bumptech.glide.request.transition.Transition; |
31 | import com.chad.library.adapter.base.BaseQuickAdapter; | 31 | import com.chad.library.adapter.base.BaseQuickAdapter; |
32 | import com.chad.library.adapter.base.BaseViewHolder; | 32 | import com.chad.library.adapter.base.BaseViewHolder; |
33 | import com.google.gson.Gson; | 33 | import com.google.gson.Gson; |
34 | import com.hjx.parent.AccountActivity; | 34 | import com.hjx.parent.AccountActivity; |
35 | import com.hjx.parent.ErrorDetailActivity; | 35 | import com.hjx.parent.ErrorDetailActivity; |
36 | import com.hjx.parent.LoginActivity; | 36 | import com.hjx.parent.LoginActivity; |
37 | import com.hjx.parent.R; | 37 | import com.hjx.parent.R; |
38 | import com.hjx.parent.TeacherChooseActivity; | 38 | import com.hjx.parent.TeacherChooseActivity; |
39 | import com.hjx.parent.bean.StudentBean; | 39 | import com.hjx.parent.bean.StudentBean; |
40 | import com.hjx.parent.databinding.FragmentTeacherBinding; | 40 | import com.hjx.parent.databinding.FragmentTeacherBinding; |
41 | import com.prws.common.bean.Record; | 41 | import com.prws.common.bean.Record; |
42 | import com.prws.common.net.NetWorks; | 42 | import com.prws.common.net.NetWorks; |
43 | import com.prws.common.utils.CommonUtil; | 43 | import com.prws.common.utils.CommonUtil; |
44 | import com.prws.common.utils.LogUtil; | 44 | import com.prws.common.utils.LogUtil; |
45 | import com.prws.common.utils.ScreenUtils; | 45 | import com.prws.common.utils.ScreenUtils; |
46 | import com.prws.common.utils.SharedPreferencesUtil; | 46 | import com.prws.common.utils.SharedPreferencesUtil; |
47 | import com.prws.common.utils.StringUtils; | 47 | import com.prws.common.utils.StringUtils; |
48 | 48 | ||
49 | import org.json.JSONArray; | 49 | import org.json.JSONArray; |
50 | import org.json.JSONObject; | 50 | import org.json.JSONObject; |
51 | 51 | ||
52 | import java.text.SimpleDateFormat; | 52 | import java.text.SimpleDateFormat; |
53 | import java.util.ArrayList; | 53 | import java.util.ArrayList; |
54 | import java.util.logging.SimpleFormatter; | 54 | import java.util.logging.SimpleFormatter; |
55 | 55 | ||
56 | import io.reactivex.Observer; | 56 | import io.reactivex.Observer; |
57 | import io.reactivex.disposables.Disposable; | 57 | import io.reactivex.disposables.Disposable; |
58 | import okhttp3.ResponseBody; | 58 | import okhttp3.ResponseBody; |
59 | 59 | ||
60 | public class TeacherFragment extends BaseBindingFragment<FragmentTeacherBinding> { | 60 | public class TeacherFragment extends BaseBindingFragment<FragmentTeacherBinding> { |
61 | ArrayList<Record> alist = new ArrayList<>(); | 61 | ArrayList<Record> alist = new ArrayList<>(); |
62 | 62 | ||
63 | @Override | 63 | @Override |
64 | protected FragmentTeacherBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 64 | protected FragmentTeacherBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
65 | return FragmentTeacherBinding.inflate(inflater, parent, false); | 65 | return FragmentTeacherBinding.inflate(inflater, parent, false); |
66 | } | 66 | } |
67 | 67 | ||
68 | @Override | 68 | @Override |
69 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 69 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
70 | super.onViewCreated(view, savedInstanceState); | 70 | super.onViewCreated(view, savedInstanceState); |
71 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 71 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
72 | if (!TextUtils.isEmpty(photo)) { | 72 | if (!TextUtils.isEmpty(photo)) { |
73 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 73 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
74 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 74 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
75 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivTeacher); | 75 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivTeacher); |
76 | } | 76 | } |
77 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 77 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
78 | getBinding().tvTeacher.setText(name); | 78 | getBinding().tvTeacher.setText(name); |
79 | getBinding().tvAnswerName.setText("亲爱的" + name + "老师"); | 79 | getBinding().tvAnswerName.setText("亲爱的" + name + "老师"); |
80 | getBinding().logout.setOnClickListener(new View.OnClickListener() { | 80 | getBinding().logout.setOnClickListener(new View.OnClickListener() { |
81 | @Override | 81 | @Override |
82 | public void onClick(View v) { | 82 | public void onClick(View v) { |
83 | logout(); | 83 | logout(); |
84 | } | 84 | } |
85 | }); | 85 | }); |
86 | NetWorks.listRecord(new Observer<ResponseBody>() { | 86 | NetWorks.listRecord(new Observer<ResponseBody>() { |
87 | @Override | 87 | @Override |
88 | public void onSubscribe(Disposable d) { | 88 | public void onSubscribe(Disposable d) { |
89 | 89 | ||
90 | } | 90 | } |
91 | 91 | ||
92 | @Override | 92 | @Override |
93 | public void onNext(ResponseBody responseBody) { | 93 | public void onNext(ResponseBody responseBody) { |
94 | try { | 94 | try { |
95 | String str = responseBody.string().toString(); | 95 | String str = responseBody.string().toString(); |
96 | LogUtil.e("TAG", "----" + str); | 96 | LogUtil.e("TAG", "----" + str); |
97 | JSONObject jo = new JSONObject(str); | 97 | JSONObject jo = new JSONObject(str); |
98 | boolean isSucceed = jo.getBoolean("success"); | 98 | boolean isSucceed = jo.getBoolean("success"); |
99 | if (isSucceed) { | 99 | if (isSucceed) { |
100 | JSONArray jarr = jo.getJSONArray("data"); | 100 | JSONArray jarr = jo.getJSONArray("data"); |
101 | if (jarr.length() > 0) { | 101 | if (jarr.length() > 0) { |
102 | getBinding().tvNum.setText("您有" + jarr.length() + "个题目需要答疑"); | 102 | getBinding().tvNum.setText("您有" + jarr.length() + "个题目需要答疑"); |
103 | alist.clear(); | 103 | alist.clear(); |
104 | for (int i = 0; i < jarr.length(); i++) { | 104 | for (int i = 0; i < jarr.length(); i++) { |
105 | JSONObject jo2 = jarr.getJSONObject(i); | 105 | JSONObject jo2 = jarr.getJSONObject(i); |
106 | Gson gson = new Gson(); | 106 | Gson gson = new Gson(); |
107 | Record sb = gson.fromJson(jo2.toString(), Record.class); | 107 | Record sb = gson.fromJson(jo2.toString(), Record.class); |
108 | alist.add(sb); | 108 | alist.add(sb); |
109 | } | 109 | } |
110 | loadList(); | 110 | loadList(); |
111 | } else { | 111 | } else { |
112 | getBinding().tvNum.setText("您暂时没有题目需要答疑"); | 112 | getBinding().tvNum.setText("您暂时没有题目需要答疑"); |
113 | } | 113 | } |
114 | } else { | 114 | } else { |
115 | 115 | ||
116 | } | 116 | } |
117 | } catch (Exception e) { | 117 | } catch (Exception e) { |
118 | e.printStackTrace(); | 118 | e.printStackTrace(); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | @Override | 122 | @Override |
123 | public void onError(Throwable e) { | 123 | public void onError(Throwable e) { |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | @Override | 127 | @Override |
128 | public void onComplete() { | 128 | public void onComplete() { |
129 | 129 | ||
130 | } | 130 | } |
131 | }); | 131 | }); |
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | private void loadList() { | 135 | private void loadList() { |
136 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_record, alist) { | 136 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_record, alist) { |
137 | @Override | 137 | @Override |
138 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 138 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
139 | Record record = alist.get(item.getAdapterPosition()); | 139 | Record record = alist.get(item.getAdapterPosition()); |
140 | item.setText(R.id.tv_name, record.getStuName()); | 140 | item.setText(R.id.tv_name, record.getStuName()); |
141 | item.setText(R.id.tv_date, "提问时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(record.getAskTime())); | 141 | item.setText(R.id.tv_date, "提问时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(record.getAskTime())); |
142 | if (TextUtils.isEmpty(record.getPhoto())) { | 142 | if (TextUtils.isEmpty(record.getPhoto())) { |
143 | item.setImageResource(R.id.iv_student, record.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 143 | item.setImageResource(R.id.iv_student, record.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
144 | } else { | 144 | } else { |
145 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 145 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
146 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 146 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
147 | Glide.with(getContext()).load(record.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_student)); | 147 | Glide.with(getContext()).load(record.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_student)); |
148 | } | 148 | } |
149 | if (TextUtils.isEmpty(record.getContent())) { | 149 | if (TextUtils.isEmpty(record.getContent())) { |
150 | item.setGone(R.id.iv_topic, true); | 150 | item.setGone(R.id.iv_topic, true); |
151 | item.setGone(R.id.webview, false); | 151 | item.setGone(R.id.webview, false); |
152 | int maxWidth = CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 60); | 152 | int maxWidth = CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 60); |
153 | Glide.with(getContext()).load(record.getQuestionUrl()).into(new SimpleTarget<Drawable>() { | 153 | Glide.with(getContext()).load(record.getQuestionUrl()).into(new SimpleTarget<Drawable>() { |
154 | @Override | 154 | @Override |
155 | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { | 155 | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { |
156 | int width = resource.getIntrinsicWidth(); | 156 | int width = resource.getIntrinsicWidth(); |
157 | int height = resource.getIntrinsicHeight(); | 157 | int height = resource.getIntrinsicHeight(); |
158 | int newHeight = maxWidth * height / width; | 158 | int newHeight = maxWidth * height / width; |
159 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) item.getView(R.id.iv_topic).getLayoutParams(); | 159 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) item.getView(R.id.iv_topic).getLayoutParams(); |
160 | layoutParams.width = maxWidth; | 160 | layoutParams.width = maxWidth; |
161 | layoutParams.height = newHeight; | 161 | layoutParams.height = newHeight; |
162 | item.getView(R.id.iv_topic).setLayoutParams(layoutParams); | 162 | item.getView(R.id.iv_topic).setLayoutParams(layoutParams); |
163 | ((ImageView) item.getView(R.id.iv_topic)).setImageDrawable(resource); | 163 | ((ImageView) item.getView(R.id.iv_topic)).setImageDrawable(resource); |
164 | } | 164 | } |
165 | }); | 165 | }); |
166 | } else { | 166 | } else { |
167 | item.setGone(R.id.iv_topic, false); | 167 | item.setGone(R.id.iv_topic, false); |
168 | item.setGone(R.id.webview, true); | 168 | item.setGone(R.id.webview, true); |
169 | WebView webView = item.getView(R.id.webview); | 169 | WebView webView = item.getView(R.id.webview); |
170 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; | 170 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; |
171 | StringBuilder sb = new StringBuilder(4096); | 171 | StringBuilder sb = new StringBuilder(4096); |
172 | if (!TextUtils.isEmpty(record.getLabel())) { | 172 | if (!TextUtils.isEmpty(record.getLabel())) { |
173 | sb.append(record.getLabel()); | 173 | sb.append(record.getLabel()); |
174 | } | 174 | } |
175 | sb.append(record.getContent()); | 175 | sb.append(record.getContent()); |
176 | if (record.getOptions() != null && record.getOptionsList().size() > 0) { | 176 | if (record.getOptions() != null && record.getOptionsList().size() > 0) { |
177 | sb.append("<div class='pt1'>"); | 177 | sb.append("<div class='pt1'>"); |
178 | sb.append(StringUtils.OptionsHtml(record.getOptionsList(), null)); | 178 | sb.append(StringUtils.OptionsHtml(record.getOptionsList(), null)); |
179 | sb.append("</div>"); | 179 | sb.append("</div>"); |
180 | } | 180 | } |
181 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; | 181 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; |
182 | WebSettings settings = webView.getSettings(); | ||
183 | settings.setUseWideViewPort(true);//设定支持 viewport | ||
184 | settings.setLoadWithOverviewMode(true); //自适应屏幕 | ||
182 | webView.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); | 185 | webView.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); |
183 | webView.setVisibility(View.VISIBLE); | 186 | webView.setVisibility(View.VISIBLE); |
184 | webView.setOnTouchListener(new View.OnTouchListener() { | 187 | webView.setOnTouchListener(new View.OnTouchListener() { |
185 | @Override | 188 | @Override |
186 | public boolean onTouch(View v, MotionEvent event) { | 189 | public boolean onTouch(View v, MotionEvent event) { |
187 | return true; | 190 | return true; |
188 | } | 191 | } |
189 | }); | 192 | }); |
190 | } | 193 | } |
191 | } | 194 | } |
192 | 195 | ||
193 | @Override | 196 | @Override |
194 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 197 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
195 | 198 | ||
196 | } | 199 | } |
197 | }; | 200 | }; |
198 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); | 201 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); |
199 | getBinding().recycleError.setAdapter(adapter); | 202 | getBinding().recycleError.setAdapter(adapter); |
200 | } | 203 | } |
201 | 204 | ||
202 | public void logout() { | 205 | public void logout() { |
203 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | 206 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); |
204 | builder.setTitle("温馨提示"); | 207 | builder.setTitle("温馨提示"); |
205 | builder.setMessage("是否退出登录?"); | 208 | builder.setMessage("是否退出登录?"); |
206 | builder.setCancelable(false); | 209 | builder.setCancelable(false); |
207 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { | 210 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { |
208 | @Override | 211 | @Override |
209 | public void onClick(DialogInterface dialogInterface, int i) { | 212 | public void onClick(DialogInterface dialogInterface, int i) { |
210 | dialogInterface.dismiss(); | 213 | dialogInterface.dismiss(); |
211 | } | 214 | } |
212 | }); | 215 | }); |
213 | builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | 216 | builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { |
214 | @Override | 217 | @Override |
215 | public void onClick(DialogInterface dialogInterface, int i) { | 218 | public void onClick(DialogInterface dialogInterface, int i) { |
216 | SharedPreferencesUtil.clear(getContext()); | 219 | SharedPreferencesUtil.clear(getContext()); |
217 | restartApp(); | 220 | restartApp(); |
218 | } | 221 | } |
219 | }); | 222 | }); |
220 | builder.show(); | 223 | builder.show(); |
221 | } | 224 | } |
222 | 225 | ||
223 | private void restartApp() { | 226 | private void restartApp() { |
224 | //重启app,这一步一定要加上,如果不重启app,可能打开新的页面显示的语言会不正确 | 227 | //重启app,这一步一定要加上,如果不重启app,可能打开新的页面显示的语言会不正确 |
225 | Intent intent = new Intent(getContext(), LoginActivity.class); | 228 | Intent intent = new Intent(getContext(), LoginActivity.class); |
226 | intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); | 229 | intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); |
227 | startActivity(intent); | 230 | startActivity(intent); |
228 | android.os.Process.killProcess(android.os.Process.myPid()); | 231 | android.os.Process.killProcess(android.os.Process.myPid()); |
229 | System.exit(0); | 232 | System.exit(0); |
230 | } | 233 | } |
231 | 234 | ||
232 | } | 235 | } |
233 | 236 |
app/src/main/res/layout/activity_error_detail.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | xmlns:tools="http://schemas.android.com/tools" | 2 | xmlns:tools="http://schemas.android.com/tools" |
3 | xmlns:xxx="http://schemas.android.com/apk/res-auto" | 3 | xmlns:xxx="http://schemas.android.com/apk/res-auto" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:background="#F5F5F5" | 6 | android:background="#F5F5F5" |
7 | android:orientation="vertical"> | 7 | android:orientation="vertical"> |
8 | 8 | ||
9 | <RelativeLayout | 9 | <RelativeLayout |
10 | android:id="@+id/rl_top" | 10 | android:id="@+id/rl_top" |
11 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
12 | android:layout_height="40dp" | 12 | android:layout_height="40dp" |
13 | android:background="@color/white"> | 13 | android:background="@color/white"> |
14 | 14 | ||
15 | <TextView | 15 | <TextView |
16 | android:id="@+id/tv_title" | 16 | android:id="@+id/tv_title" |
17 | android:layout_width="wrap_content" | 17 | android:layout_width="wrap_content" |
18 | android:layout_height="wrap_content" | 18 | android:layout_height="wrap_content" |
19 | android:layout_centerInParent="true" | 19 | android:layout_centerInParent="true" |
20 | android:ellipsize="end" | 20 | android:ellipsize="end" |
21 | android:maxWidth="330dp" | 21 | android:maxWidth="330dp" |
22 | android:text="错题详情" | ||
22 | android:singleLine="true" | 23 | android:singleLine="true" |
23 | android:textColor="#333333" | 24 | android:textColor="#333333" |
24 | android:textSize="18sp" /> | 25 | android:textSize="18sp" /> |
25 | 26 | ||
26 | <ImageView | ||
27 | android:id="@+id/iv_edit" | ||
28 | android:layout_width="40dp" | ||
29 | android:layout_height="40dp" | ||
30 | android:layout_toRightOf="@+id/tv_title" | ||
31 | android:padding="10dp" | ||
32 | android:src="@mipmap/ic_error_edit" /> | ||
33 | 27 | ||
34 | <ImageView | 28 | <ImageView |
35 | android:id="@+id/iv_back" | 29 | android:id="@+id/iv_back" |
36 | android:layout_width="30dp" | 30 | android:layout_width="30dp" |
37 | android:layout_height="36dp" | 31 | android:layout_height="36dp" |
38 | android:layout_centerVertical="true" | 32 | android:layout_centerVertical="true" |
39 | android:layout_marginLeft="5dp" | 33 | android:layout_marginLeft="5dp" |
40 | android:padding="10dp" | 34 | android:padding="10dp" |
41 | android:src="@mipmap/icon_back" /> | 35 | android:src="@mipmap/icon_back" /> |
42 | 36 | ||
43 | </RelativeLayout> | 37 | </RelativeLayout> |
44 | 38 | ||
45 | <ScrollView | 39 | <ScrollView |
46 | android:layout_width="match_parent" | 40 | android:layout_width="match_parent" |
47 | android:layout_height="match_parent"> | 41 | android:layout_height="match_parent"> |
48 | 42 | ||
49 | <LinearLayout | 43 | <LinearLayout |
50 | android:layout_width="match_parent" | 44 | android:layout_width="match_parent" |
51 | android:layout_height="wrap_content" | 45 | android:layout_height="wrap_content" |
52 | android:background="#F5F5F5" | 46 | android:background="#F5F5F5" |
53 | android:orientation="vertical"> | 47 | android:orientation="vertical"> |
54 | 48 | ||
55 | <LinearLayout | 49 | <LinearLayout |
56 | android:id="@+id/ll_pic" | 50 | android:id="@+id/ll_pic" |
57 | android:layout_width="match_parent" | 51 | android:layout_width="match_parent" |
58 | android:layout_height="wrap_content" | 52 | android:layout_height="wrap_content" |
59 | android:background="@color/white" | 53 | android:background="@color/white" |
60 | android:orientation="vertical"> | 54 | android:orientation="vertical"> |
61 | 55 | ||
62 | <TextView | 56 | <TextView |
63 | android:layout_width="wrap_content" | 57 | android:layout_width="wrap_content" |
64 | android:layout_height="wrap_content" | 58 | android:layout_height="wrap_content" |
65 | android:layout_marginLeft="15dp" | 59 | android:layout_marginLeft="15dp" |
66 | android:layout_marginTop="15dp" | 60 | android:layout_marginTop="15dp" |
67 | android:text="原题图片" | 61 | android:text="原题图片" |
68 | android:textColor="@color/text_title" | 62 | android:textColor="@color/text_title" |
69 | android:textSize="15sp" /> | 63 | android:textSize="15sp" /> |
70 | 64 | ||
71 | <RelativeLayout | 65 | <RelativeLayout |
72 | android:layout_width="match_parent" | 66 | android:layout_width="match_parent" |
73 | android:layout_height="90dp" | 67 | android:layout_height="90dp" |
74 | android:layout_marginLeft="15dp" | 68 | android:layout_marginLeft="15dp" |
75 | android:layout_marginTop="15dp" | 69 | android:layout_marginTop="15dp" |
76 | android:layout_marginRight="15dp" | 70 | android:layout_marginRight="15dp" |
77 | android:layout_marginBottom="15dp"> | 71 | android:layout_marginBottom="15dp"> |
78 | 72 | ||
79 | <RelativeLayout | 73 | <RelativeLayout |
80 | android:layout_width="match_parent" | 74 | android:layout_width="match_parent" |
81 | android:layout_height="match_parent" | 75 | android:layout_height="match_parent" |
82 | android:background="#F5F5F5"> | 76 | android:background="#F5F5F5"> |
83 | 77 | ||
84 | <ImageView | 78 | <ImageView |
85 | android:id="@+id/iv_topic" | 79 | android:id="@+id/iv_topic" |
86 | android:layout_width="wrap_content" | 80 | android:layout_width="wrap_content" |
87 | android:layout_height="wrap_content" | 81 | android:layout_height="wrap_content" |
88 | android:layout_centerVertical="true" /> | 82 | android:layout_centerVertical="true" /> |
89 | </RelativeLayout> | 83 | </RelativeLayout> |
90 | </RelativeLayout> | 84 | </RelativeLayout> |
91 | </LinearLayout> | 85 | </LinearLayout> |
92 | 86 | ||
93 | <LinearLayout | 87 | <LinearLayout |
94 | android:id="@+id/ll_origin" | 88 | android:id="@+id/ll_origin" |
95 | android:layout_width="match_parent" | 89 | android:layout_width="match_parent" |
96 | android:layout_height="wrap_content" | 90 | android:layout_height="wrap_content" |
97 | android:background="@color/white" | 91 | android:background="@color/white" |
98 | android:orientation="vertical" | 92 | android:orientation="vertical" |
99 | tools:ignore="WebViewLayout"> | 93 | tools:ignore="WebViewLayout"> |
100 | 94 | ||
101 | <TextView | 95 | <TextView |
102 | android:layout_width="wrap_content" | 96 | android:layout_width="wrap_content" |
103 | android:layout_height="wrap_content" | 97 | android:layout_height="wrap_content" |
104 | android:layout_marginLeft="15dp" | 98 | android:layout_marginLeft="15dp" |
105 | android:layout_marginTop="15dp" | 99 | android:layout_marginTop="15dp" |
106 | android:text="题目" | 100 | android:text="题目" |
107 | android:textColor="@color/text_title" | 101 | android:textColor="@color/text_title" |
108 | android:textSize="15sp" /> | 102 | android:textSize="15sp" /> |
109 | 103 | ||
110 | <WebView | 104 | <WebView |
111 | android:id="@+id/web_content" | 105 | android:id="@+id/web_content" |
112 | android:layout_width="wrap_content" | 106 | android:layout_width="wrap_content" |
113 | android:layout_height="wrap_content" | 107 | android:layout_height="wrap_content" |
114 | android:layout_marginLeft="10dp" | 108 | android:layout_marginLeft="10dp" |
115 | android:layout_marginTop="10dp" | 109 | android:layout_marginTop="10dp" |
116 | android:layout_marginBottom="10dp" /> | 110 | android:layout_marginBottom="10dp" /> |
117 | </LinearLayout> | 111 | </LinearLayout> |
118 | 112 | ||
119 | <LinearLayout | 113 | <LinearLayout |
120 | android:id="@+id/ll_analyse" | 114 | android:id="@+id/ll_analyse" |
121 | android:layout_width="match_parent" | 115 | android:layout_width="match_parent" |
122 | android:layout_height="wrap_content" | 116 | android:layout_height="wrap_content" |
123 | android:layout_marginTop="15dp" | 117 | android:layout_marginTop="15dp" |
124 | android:background="@color/white" | 118 | android:background="@color/white" |
125 | android:orientation="vertical" | 119 | android:orientation="vertical" |
126 | tools:ignore="WebViewLayout"> | 120 | tools:ignore="WebViewLayout"> |
127 | 121 | ||
128 | <TextView | 122 | <TextView |
129 | android:layout_width="wrap_content" | 123 | android:layout_width="wrap_content" |
130 | android:layout_height="wrap_content" | 124 | android:layout_height="wrap_content" |
131 | android:layout_marginLeft="15dp" | 125 | android:layout_marginLeft="15dp" |
132 | android:layout_marginTop="15dp" | 126 | android:layout_marginTop="15dp" |
133 | android:text="解答" | 127 | android:text="解答" |
134 | android:textColor="@color/text_title" | 128 | android:textColor="@color/text_title" |
135 | android:textSize="15sp" /> | 129 | android:textSize="15sp" /> |
136 | 130 | ||
137 | <LinearLayout | 131 | <LinearLayout |
138 | android:layout_width="match_parent" | 132 | android:layout_width="match_parent" |
139 | android:layout_height="wrap_content" | 133 | android:layout_height="wrap_content" |
140 | android:layout_margin="15dp" | 134 | android:layout_margin="15dp" |
141 | android:background="@drawable/bg_soild_gray_5"> | 135 | android:background="@drawable/bg_soild_gray_5"> |
142 | 136 | ||
143 | <WebView | 137 | <WebView |
144 | android:id="@+id/web_analyse" | 138 | android:id="@+id/web_analyse" |
145 | android:background="#F5F5F5" | ||
146 | android:layout_width="wrap_content" | 139 | android:layout_width="wrap_content" |
147 | android:layout_height="wrap_content" | 140 | android:layout_height="wrap_content" |
148 | android:layout_margin="10dp" /> | 141 | android:layout_margin="10dp" |
142 | android:background="#F5F5F5" /> | ||
149 | </LinearLayout> | 143 | </LinearLayout> |
150 | </LinearLayout> | 144 | </LinearLayout> |
151 | 145 | ||
152 | <LinearLayout | 146 | <LinearLayout |
153 | android:id="@+id/ll_answer" | 147 | android:id="@+id/ll_answer" |
154 | android:layout_width="match_parent" | 148 | android:layout_width="match_parent" |
155 | android:layout_height="wrap_content" | 149 | android:layout_height="wrap_content" |
156 | android:layout_marginTop="15dp" | 150 | android:layout_marginTop="15dp" |
157 | android:background="@color/white" | 151 | android:background="@color/white" |
158 | android:orientation="vertical" | 152 | android:orientation="vertical" |
159 | tools:ignore="WebViewLayout"> | 153 | tools:ignore="WebViewLayout"> |
160 | 154 | ||
161 | <TextView | 155 | <TextView |
162 | android:layout_width="wrap_content" | 156 | android:layout_width="wrap_content" |
163 | android:layout_height="wrap_content" | 157 | android:layout_height="wrap_content" |
164 | android:layout_marginLeft="15dp" | 158 | android:layout_marginLeft="15dp" |
165 | android:layout_marginTop="15dp" | 159 | android:layout_marginTop="15dp" |
166 | android:text="答案" | 160 | android:text="答案" |
167 | android:textColor="@color/text_title" | 161 | android:textColor="@color/text_title" |
168 | android:textSize="15sp" /> | 162 | android:textSize="15sp" /> |
169 | 163 | ||
170 | <LinearLayout | 164 | <LinearLayout |
171 | android:layout_width="match_parent" | 165 | android:layout_width="match_parent" |
172 | android:layout_height="wrap_content" | 166 | android:layout_height="wrap_content" |
173 | android:layout_margin="15dp" | 167 | android:layout_margin="15dp" |
174 | android:background="@drawable/bg_soild_gray_5"> | 168 | android:background="@drawable/bg_soild_gray_5"> |
175 | 169 | ||
176 | <WebView | 170 | <WebView |
177 | android:id="@+id/web_answer" | 171 | android:id="@+id/web_answer" |
178 | android:layout_width="wrap_content" | 172 | android:layout_width="wrap_content" |
179 | android:layout_height="wrap_content" | 173 | android:layout_height="wrap_content" |
180 | android:background="#F5F5F5" | 174 | android:layout_margin="10dp" |
181 | android:layout_margin="10dp" /> | 175 | android:background="#F5F5F5" /> |
182 | </LinearLayout> | 176 | </LinearLayout> |
183 | </LinearLayout> | 177 | </LinearLayout> |
184 | 178 | ||
185 | <LinearLayout | 179 | <LinearLayout |
186 | android:id="@+id/ll_points" | 180 | android:id="@+id/ll_points" |
187 | android:layout_width="match_parent" | 181 | android:layout_width="match_parent" |
188 | android:layout_height="wrap_content" | 182 | android:layout_height="wrap_content" |
189 | android:layout_marginTop="15dp" | 183 | android:layout_marginTop="15dp" |
190 | android:background="@color/white" | 184 | android:background="@color/white" |
191 | android:orientation="vertical" | 185 | android:orientation="vertical" |
192 | tools:ignore="WebViewLayout"> | 186 | tools:ignore="WebViewLayout"> |
193 | 187 | ||
194 | <TextView | 188 | <TextView |
195 | android:layout_width="wrap_content" | 189 | android:layout_width="wrap_content" |
196 | android:layout_height="wrap_content" | 190 | android:layout_height="wrap_content" |
197 | android:layout_marginLeft="15dp" | 191 | android:layout_marginLeft="15dp" |
198 | android:layout_marginTop="15dp" | 192 | android:layout_marginTop="15dp" |
199 | android:text="知识点" | 193 | android:text="知识点" |
200 | android:textColor="@color/text_title" | 194 | android:textColor="@color/text_title" |
201 | android:textSize="15sp" /> | 195 | android:textSize="15sp" /> |
202 | 196 | ||
203 | <LinearLayout | 197 | <LinearLayout |
204 | android:layout_width="match_parent" | 198 | android:layout_width="match_parent" |
205 | android:layout_height="40dp" | 199 | android:layout_height="40dp" |
206 | android:layout_margin="15dp" | 200 | android:layout_margin="15dp" |
207 | android:background="@drawable/bg_soild_gray_5"> | 201 | android:background="@drawable/bg_soild_gray_5"> |
208 | 202 | ||
209 | <TextView | 203 | <TextView |
210 | android:id="@+id/tv_points" | 204 | android:id="@+id/tv_points" |
211 | android:layout_width="wrap_content" | 205 | android:layout_width="wrap_content" |
212 | android:layout_height="wrap_content" | 206 | android:layout_height="wrap_content" |
213 | android:layout_gravity="center_vertical" | 207 | android:layout_gravity="center_vertical" |
214 | android:layout_marginLeft="15dp" | 208 | android:layout_marginLeft="15dp" |
215 | android:gravity="center_vertical" | 209 | android:gravity="center_vertical" |
216 | android:textColor="#1C90F3" | 210 | android:textColor="#1C90F3" |
217 | android:textSize="14sp" /> | 211 | android:textSize="14sp" /> |
218 | </LinearLayout> | 212 | </LinearLayout> |
219 | </LinearLayout> | 213 | </LinearLayout> |
220 | 214 | ||
221 | <LinearLayout | 215 | <RelativeLayout |
222 | android:id="@+id/ll_reason" | 216 | android:id="@+id/ll_reason" |
223 | android:layout_width="match_parent" | 217 | android:layout_width="match_parent" |
224 | android:layout_height="wrap_content" | 218 | android:layout_height="wrap_content" |
225 | android:layout_marginTop="15dp" | 219 | android:layout_marginTop="15dp" |
226 | android:background="@color/white" | 220 | android:background="@color/white" |
227 | android:orientation="vertical" | 221 | android:orientation="vertical" |
228 | tools:ignore="WebViewLayout"> | 222 | tools:ignore="WebViewLayout"> |
229 | 223 | ||
230 | <TextView | 224 | <TextView |
231 | android:layout_width="wrap_content" | 225 | android:layout_width="wrap_content" |
232 | android:layout_height="wrap_content" | 226 | android:layout_height="25dp" |
233 | android:layout_marginLeft="15dp" | 227 | android:layout_marginLeft="15dp" |
234 | android:layout_marginTop="15dp" | 228 | android:layout_marginTop="15dp" |
235 | android:text="错误原因" | 229 | android:gravity="center" |
230 | android:text="本题标签" | ||
236 | android:textColor="@color/text_title" | 231 | android:textColor="@color/text_title" |
237 | android:textSize="15sp" /> | 232 | android:textSize="15sp" /> |
238 | 233 | ||
239 | <androidx.appcompat.widget.AppCompatSpinner | 234 | <TextView |
240 | android:id="@+id/spinner_reason" | 235 | android:id="@+id/tv_edit" |
241 | style="@style/customSpinnerStyle" | 236 | android:layout_width="70dp" |
242 | android:layout_width="match_parent" | 237 | android:layout_height="25dp" |
243 | android:layout_height="40dp" | 238 | android:layout_alignParentRight="true" |
244 | android:layout_centerHorizontal="true" | ||
245 | android:layout_marginLeft="15dp" | ||
246 | android:layout_marginTop="15dp" | 239 | android:layout_marginTop="15dp" |
247 | android:layout_marginRight="15dp" | 240 | android:layout_marginRight="15dp" |
248 | android:layout_marginBottom="15dp" | 241 | android:background="@drawable/bg_soild_blue_25" |
249 | android:background="@drawable/selector_for_custom_spinner" | 242 | android:gravity="center" |
250 | android:entries="@array/error_reason" | 243 | android:text="修改标签" |
251 | android:popupBackground="@drawable/shape_for_custom_spinner" | 244 | android:textColor="@color/white" /> |
252 | android:scrollbars="none" /> | ||
253 | </LinearLayout> | ||
254 | |||
255 | <LinearLayout | ||
256 | android:layout_width="match_parent" | ||
257 | android:layout_height="wrap_content" | ||
258 | android:layout_marginTop="15dp" | ||
259 | android:layout_marginBottom="15dp" | ||
260 | android:background="@color/white" | ||
261 | android:orientation="vertical" | ||
262 | tools:ignore="WebViewLayout"> | ||
263 | 245 | ||
264 | <TextView | 246 | <TextView |
247 | android:id="@+id/tv_subject" | ||
265 | android:layout_width="wrap_content" | 248 | android:layout_width="wrap_content" |
266 | android:layout_height="wrap_content" | 249 | android:layout_height="wrap_content" |
250 | android:layout_below="@+id/tv_edit" | ||
267 | android:layout_marginLeft="15dp" | 251 | android:layout_marginLeft="15dp" |
268 | android:layout_marginTop="15dp" | 252 | android:layout_marginTop="15dp" |
269 | android:text="掌握状态" | 253 | android:textColor="#333333" /> |
270 | android:textColor="@color/text_title" | ||
271 | android:textSize="15sp" /> | ||
272 | 254 | ||
273 | <RadioGroup | 255 | <TextView |
274 | android:id="@+id/type_radio" | 256 | android:id="@+id/tv_grade" |
275 | android:layout_width="match_parent" | 257 | android:layout_width="wrap_content" |
276 | android:layout_height="40dp" | 258 | android:layout_height="wrap_content" |
259 | android:layout_below="@+id/tv_subject" | ||
277 | android:layout_marginLeft="15dp" | 260 | android:layout_marginLeft="15dp" |
278 | android:layout_marginTop="15dp" | 261 | android:layout_marginTop="10dp" |
279 | android:layout_marginBottom="15dp" | 262 | android:textColor="#333333" /> |
280 | android:orientation="horizontal"> | ||
281 | 263 | ||
282 | <RadioButton | 264 | <TextView |
283 | android:layout_width="70dp" | 265 | android:id="@+id/tv_reason" |
284 | android:layout_height="match_parent" | 266 | android:layout_width="wrap_content" |
285 | android:layout_marginRight="20dp" | 267 | android:layout_height="wrap_content" |
286 | android:background="@drawable/radio_button_selector" | 268 | android:layout_below="@+id/tv_grade" |
287 | android:button="@null" | 269 | android:layout_marginLeft="15dp" |
288 | android:gravity="center" | 270 | android:layout_marginTop="10dp" |
289 | android:text="已掌握" | 271 | android:textColor="#333333" /> |
290 | android:textColor="@drawable/radio_text_selector" | 272 | |
291 | android:textSize="14sp" /> | 273 | <TextView |
274 | android:id="@+id/tv_manager" | ||
275 | android:layout_width="wrap_content" | ||
276 | android:layout_height="wrap_content" | ||
277 | android:layout_below="@+id/tv_reason" | ||
278 | android:layout_marginLeft="15dp" | ||
279 | android:layout_marginTop="10dp" | ||
280 | android:textColor="#333333" /> | ||
281 | |||
282 | <TextView | ||
283 | android:id="@+id/tv_type" | ||
284 | android:layout_width="wrap_content" | ||
285 | android:layout_height="wrap_content" | ||
286 | android:layout_below="@+id/tv_manager" | ||
287 | android:layout_marginLeft="15dp" | ||
288 | android:layout_marginTop="10dp" | ||
289 | android:layout_marginBottom="15dp" | ||
290 | android:textColor="#333333" /> | ||
291 | </RelativeLayout> | ||
292 | 292 | ||
293 | <RadioButton | ||
294 | android:layout_width="70dp" |
app/src/main/res/layout/dialog_edit_error.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="wrap_content" | 3 | android:layout_height="wrap_content" |
4 | android:background="@drawable/bg_solid_white_10_top" | 4 | android:background="@drawable/bg_solid_white_10_top" |
5 | android:orientation="vertical"> | 5 | android:orientation="vertical"> |
6 | 6 | ||
7 | <RelativeLayout | 7 | <RelativeLayout |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="50dp"> | 9 | android:layout_height="50dp"> |
10 | 10 | ||
11 | <TextView | 11 | <TextView |
12 | android:layout_width="wrap_content" | 12 | android:layout_width="wrap_content" |
13 | android:layout_height="wrap_content" | 13 | android:layout_height="wrap_content" |
14 | android:layout_centerInParent="true" | 14 | android:layout_centerInParent="true" |
15 | android:text="错题标签" | 15 | android:text="错题标签" |
16 | android:textColor="@color/text_title" | 16 | android:textColor="@color/text_title" |
17 | android:textSize="17sp" | 17 | android:textSize="17sp" |
18 | android:textStyle="bold" /> | 18 | android:textStyle="bold" /> |
19 | 19 | ||
20 | <ImageView | 20 | <ImageView |
21 | android:id="@+id/iv_back" | 21 | android:id="@+id/iv_back" |
22 | android:layout_width="35dp" | 22 | android:layout_width="35dp" |
23 | android:layout_height="35dp" | 23 | android:layout_height="35dp" |
24 | android:layout_alignParentRight="true" | 24 | android:layout_alignParentRight="true" |
25 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
26 | android:layout_marginRight="10dp" | 26 | android:layout_marginRight="10dp" |
27 | android:padding="10dp" | 27 | android:padding="10dp" |
28 | android:src="@mipmap/ic_close" /> | 28 | android:src="@mipmap/ic_close" /> |
29 | </RelativeLayout> | 29 | </RelativeLayout> |
30 | 30 | ||
31 | <TextView | 31 | <TextView |
32 | android:layout_width="wrap_content" | 32 | android:layout_width="wrap_content" |
33 | android:layout_height="wrap_content" | 33 | android:layout_height="wrap_content" |
34 | android:layout_centerVertical="true" | 34 | android:layout_centerVertical="true" |
35 | android:layout_marginLeft="20dp" | 35 | android:layout_marginLeft="20dp" |
36 | android:layout_marginTop="20dp" | 36 | android:layout_marginTop="20dp" |
37 | android:text="年级" | 37 | android:text="年级" |
38 | android:textColor="@color/text_title" | 38 | android:textColor="@color/text_title" |
39 | android:textSize="15sp" | 39 | android:textSize="15sp" |
40 | android:textStyle="bold" /> | 40 | android:textStyle="bold" /> |
41 | 41 | ||
42 | <androidx.appcompat.widget.AppCompatSpinner | 42 | <androidx.appcompat.widget.AppCompatSpinner |
43 | android:id="@+id/spinner_grade" | 43 | android:id="@+id/spinner_grade" |
44 | style="@style/customSpinnerStyle" | 44 | style="@style/customSpinnerStyle" |
45 | android:layout_width="match_parent" | 45 | android:layout_width="match_parent" |
46 | android:layout_height="40dp" | 46 | android:layout_height="40dp" |
47 | android:layout_centerHorizontal="true" | 47 | android:layout_centerHorizontal="true" |
48 | android:layout_marginLeft="20dp" | 48 | android:layout_marginLeft="20dp" |
49 | android:layout_marginTop="10dp" | 49 | android:layout_marginTop="10dp" |
50 | android:layout_marginRight="20dp" | 50 | android:layout_marginRight="20dp" |
51 | android:background="@drawable/selector_for_custom_spinner" | 51 | android:background="@drawable/selector_for_custom_spinner" |
52 | android:entries="@array/filter_subject" | 52 | android:entries="@array/filter_subject" |
53 | android:popupBackground="@drawable/shape_for_custom_spinner" | 53 | android:popupBackground="@drawable/shape_for_custom_spinner" |
54 | android:scrollbars="none" /> | 54 | android:scrollbars="none" /> |
55 | 55 | ||
56 | <TextView | 56 | <TextView |
57 | android:layout_width="wrap_content" | 57 | android:layout_width="wrap_content" |
58 | android:layout_height="wrap_content" | 58 | android:layout_height="wrap_content" |
59 | android:layout_centerVertical="true" | 59 | android:layout_centerVertical="true" |
60 | android:layout_marginLeft="20dp" | 60 | android:layout_marginLeft="20dp" |
61 | android:layout_marginTop="20dp" | 61 | android:layout_marginTop="20dp" |
62 | android:text="学期" | 62 | android:text="学期" |
63 | android:textColor="@color/text_title" | 63 | android:textColor="@color/text_title" |
64 | android:textSize="15sp" | 64 | android:textSize="15sp" |
65 | android:textStyle="bold" /> | 65 | android:textStyle="bold" /> |
66 | 66 | ||
67 | <androidx.appcompat.widget.AppCompatSpinner | 67 | <androidx.appcompat.widget.AppCompatSpinner |
68 | android:id="@+id/spinner_grade1" | 68 | android:id="@+id/spinner_grade1" |
69 | style="@style/customSpinnerStyle" | 69 | style="@style/customSpinnerStyle" |
70 | android:layout_width="match_parent" | 70 | android:layout_width="match_parent" |
71 | android:layout_height="40dp" | 71 | android:layout_height="40dp" |
72 | android:layout_centerHorizontal="true" | 72 | android:layout_centerHorizontal="true" |
73 | android:layout_marginLeft="20dp" | 73 | android:layout_marginLeft="20dp" |
74 | android:layout_marginTop="10dp" | 74 | android:layout_marginTop="10dp" |
75 | android:layout_marginRight="20dp" | 75 | android:layout_marginRight="20dp" |
76 | android:background="@drawable/selector_for_custom_spinner" | 76 | android:background="@drawable/selector_for_custom_spinner" |
77 | android:entries="@array/grade_array" | 77 | android:entries="@array/grade_array" |
78 | android:popupBackground="@drawable/shape_for_custom_spinner" | 78 | android:popupBackground="@drawable/shape_for_custom_spinner" |
79 | android:scrollbars="none" /> | 79 | android:scrollbars="none" /> |
80 | 80 | ||
81 | <TextView | 81 | <TextView |
82 | android:layout_width="wrap_content" | 82 | android:layout_width="wrap_content" |
83 | android:layout_height="wrap_content" | 83 | android:layout_height="wrap_content" |
84 | android:layout_centerVertical="true" | 84 | android:layout_centerVertical="true" |
85 | android:layout_marginLeft="20dp" | 85 | android:layout_marginLeft="20dp" |
86 | android:layout_marginTop="20dp" | 86 | android:layout_marginTop="20dp" |
87 | android:text="科目" | 87 | android:text="科目" |
88 | android:textColor="@color/text_title" | 88 | android:textColor="@color/text_title" |
89 | android:textSize="15sp" | 89 | android:textSize="15sp" |
90 | android:textStyle="bold" /> | 90 | android:textStyle="bold" /> |
91 | 91 | ||
92 | <androidx.appcompat.widget.AppCompatSpinner | 92 | <androidx.appcompat.widget.AppCompatSpinner |
93 | android:id="@+id/spinner_subject" | 93 | android:id="@+id/spinner_subject" |
94 | style="@style/customSpinnerStyle" | 94 | style="@style/customSpinnerStyle" |
95 | android:layout_width="match_parent" | 95 | android:layout_width="match_parent" |
96 | android:layout_height="40dp" | 96 | android:layout_height="40dp" |
97 | android:layout_centerHorizontal="true" | 97 | android:layout_centerHorizontal="true" |
98 | android:layout_marginLeft="20dp" | 98 | android:layout_marginLeft="20dp" |
99 | android:layout_marginTop="10dp" | 99 | android:layout_marginTop="10dp" |
100 | android:layout_marginRight="20dp" | 100 | android:layout_marginRight="20dp" |
101 | android:background="@drawable/selector_for_custom_spinner" | 101 | android:background="@drawable/selector_for_custom_spinner" |
102 | android:entries="@array/filter_subject" | 102 | android:entries="@array/filter_subject" |
103 | android:popupBackground="@drawable/shape_for_custom_spinner" | 103 | android:popupBackground="@drawable/shape_for_custom_spinner" |
104 | android:scrollbars="none" /> | 104 | android:scrollbars="none" /> |
105 | 105 | ||
106 | <TextView | 106 | <TextView |
107 | android:layout_width="wrap_content" | 107 | android:layout_width="wrap_content" |
108 | android:layout_height="wrap_content" | 108 | android:layout_height="wrap_content" |
109 | android:layout_centerVertical="true" | 109 | android:layout_centerVertical="true" |
110 | android:layout_marginLeft="20dp" | 110 | android:layout_marginLeft="20dp" |
111 | android:layout_marginTop="20dp" | 111 | android:layout_marginTop="20dp" |
112 | android:text="错误原因" | 112 | android:text="错误原因" |
113 | android:textColor="@color/text_title" | 113 | android:textColor="@color/text_title" |
114 | android:textSize="15sp" | 114 | android:textSize="15sp" |
115 | android:textStyle="bold" /> | 115 | android:textStyle="bold" /> |
116 | 116 | ||
117 | <androidx.appcompat.widget.AppCompatSpinner | 117 | <androidx.appcompat.widget.AppCompatSpinner |
118 | android:id="@+id/spinner_reason" | 118 | android:id="@+id/spinner_reason" |
119 | style="@style/customSpinnerStyle" | 119 | style="@style/customSpinnerStyle" |
120 | android:layout_width="match_parent" | 120 | android:layout_width="match_parent" |
121 | android:layout_height="40dp" | 121 | android:layout_height="40dp" |
122 | android:layout_centerHorizontal="true" | 122 | android:layout_centerHorizontal="true" |
123 | android:layout_marginLeft="20dp" | 123 | android:layout_marginLeft="20dp" |
124 | android:layout_marginTop="10dp" | 124 | android:layout_marginTop="10dp" |
125 | android:layout_marginRight="20dp" | 125 | android:layout_marginRight="20dp" |
126 | android:background="@drawable/selector_for_custom_spinner" | 126 | android:background="@drawable/selector_for_custom_spinner" |
127 | android:entries="@array/filter_subject" | 127 | android:entries="@array/filter_subject" |
128 | android:popupBackground="@drawable/shape_for_custom_spinner" | 128 | android:popupBackground="@drawable/shape_for_custom_spinner" |
129 | android:scrollbars="none" /> | 129 | android:scrollbars="none" /> |
130 | 130 | ||
131 | <TextView | 131 | <TextView |
132 | android:layout_width="wrap_content" | 132 | android:layout_width="wrap_content" |
133 | android:layout_height="wrap_content" | 133 | android:layout_height="wrap_content" |
134 | android:layout_centerVertical="true" | 134 | android:layout_centerVertical="true" |
135 | android:layout_marginLeft="20dp" | 135 | android:layout_marginLeft="20dp" |
136 | android:layout_marginTop="20dp" | 136 | android:layout_marginTop="20dp" |
137 | android:text="来源" | 137 | android:text="来源" |
138 | android:textColor="@color/text_title" | 138 | android:textColor="@color/text_title" |
139 | android:textSize="15sp" | 139 | android:textSize="15sp" |
140 | android:textStyle="bold" /> | 140 | android:textStyle="bold" /> |
141 | 141 | ||
142 | <RadioGroup | 142 | <RadioGroup |
143 | android:id="@+id/type_radio" | 143 | android:id="@+id/type_radio" |
144 | android:layout_width="match_parent" | 144 | android:layout_width="match_parent" |
145 | android:layout_height="40dp" | 145 | android:layout_height="40dp" |
146 | android:layout_marginLeft="20dp" | 146 | android:layout_marginLeft="20dp" |
147 | android:layout_marginTop="10dp" | 147 | android:layout_marginTop="10dp" |
148 | android:orientation="horizontal"> | 148 | android:orientation="horizontal"> |
149 | 149 | ||
150 | <RadioButton | 150 | <RadioButton |
151 | android:layout_width="65dp" | 151 | android:layout_width="65dp" |
152 | android:layout_height="match_parent" | 152 | android:layout_height="match_parent" |
153 | android:layout_marginRight="20dp" | 153 | android:layout_marginRight="20dp" |
154 | android:background="@drawable/radio_button_selector" | 154 | android:background="@drawable/radio_button_selector" |
155 | android:button="@null" | 155 | android:button="@null" |
156 | android:gravity="center" | 156 | android:gravity="center" |
157 | android:text="课内" | 157 | android:text="课内" |
158 | android:textColor="@drawable/radio_text_selector" | 158 | android:textColor="@drawable/radio_text_selector" |
159 | android:textSize="14sp" /> | 159 | android:textSize="14sp" /> |
160 | 160 | ||
161 | <RadioButton | 161 | <RadioButton |
162 | android:layout_width="65dp" | 162 | android:layout_width="65dp" |
163 | android:layout_height="match_parent" | 163 | android:layout_height="match_parent" |
164 | android:layout_marginRight="20dp" | 164 | android:layout_marginRight="20dp" |
165 | android:background="@drawable/radio_button_selector" | 165 | android:background="@drawable/radio_button_selector" |
166 | android:button="@null" | 166 | android:button="@null" |
167 | android:gravity="center" | 167 | android:gravity="center" |
168 | android:text="课外" | 168 | android:text="课外" |
169 | android:textColor="@drawable/radio_text_selector" | 169 | android:textColor="@drawable/radio_text_selector" |
170 | android:textSize="14sp" /> | 170 | android:textSize="14sp" /> |
171 | </RadioGroup> | 171 | </RadioGroup> |
172 | 172 | ||
173 | <TextView | ||
174 | android:layout_width="wrap_content" | ||
175 | android:layout_height="wrap_content" | ||
176 | android:layout_centerVertical="true" | ||
177 | android:layout_marginLeft="20dp" | ||
178 | android:layout_marginTop="20dp" | ||
179 | android:text="掌握状态" | ||
180 | android:textColor="@color/text_title" | ||
181 | android:textSize="15sp" | ||
182 | android:textStyle="bold" /> | ||
183 | |||
184 | <RadioGroup | ||
185 | android:id="@+id/manager_radio" | ||
186 | android:layout_width="match_parent" | ||
187 | android:layout_height="40dp" | ||
188 | android:layout_marginLeft="20dp" | ||
189 | android:layout_marginTop="10dp" | ||
190 | android:orientation="horizontal"> | ||
191 | |||
192 | <RadioButton | ||
193 | android:layout_width="65dp" | ||
194 | android:layout_height="match_parent" | ||
195 | android:layout_marginRight="20dp" | ||
196 | android:background="@drawable/radio_button_selector" | ||
197 | android:button="@null" | ||
198 | android:gravity="center" | ||
199 | android:text="已掌握" | ||
200 | android:textColor="@drawable/radio_text_selector" | ||
201 | android:textSize="14sp" /> | ||
202 | |||
203 | <RadioButton | ||
204 | android:layout_width="65dp" | ||
205 | android:layout_height="match_parent" | ||
206 | android:layout_marginRight="20dp" | ||
207 | android:background="@drawable/radio_button_selector" | ||
208 | android:button="@null" | ||
209 | android:gravity="center" | ||
210 | android:text="未掌握" | ||
211 | android:textColor="@drawable/radio_text_selector" | ||
212 | android:textSize="14sp" /> | ||
213 | </RadioGroup> | ||
173 | 214 | ||
174 | <RelativeLayout | 215 | <RelativeLayout |
175 | android:layout_width="match_parent" | 216 | android:layout_width="match_parent" |
176 | android:layout_height="40dp" | 217 | android:layout_height="40dp" |
177 | android:layout_marginLeft="20dp" | 218 | android:layout_marginLeft="20dp" |
178 | android:layout_marginTop="20dp" | 219 | android:layout_marginTop="20dp" |
179 | android:layout_marginRight="20dp" | 220 | android:layout_marginRight="20dp" |
180 | android:layout_marginBottom="15dp"> | 221 | android:layout_marginBottom="15dp"> |
181 | 222 | ||
182 | <TextView | 223 | <TextView |
183 | android:id="@+id/add_topic" | 224 | android:id="@+id/add_topic" |
184 | android:layout_width="250dp" | 225 | android:layout_width="250dp" |
185 | android:layout_height="match_parent" | 226 | android:layout_height="match_parent" |
186 | android:layout_centerInParent="true" | 227 | android:layout_centerInParent="true" |
187 | android:background="@drawable/bg_soild_blue_5" | 228 | android:background="@drawable/bg_soild_blue_5" |
188 | android:gravity="center" | 229 | android:gravity="center" |
189 | android:text="确认修改" | 230 | android:text="确认修改" |
190 | android:textColor="@color/white" | 231 | android:textColor="@color/white" |
191 | android:textSize="17sp" /> | 232 | android:textSize="17sp" /> |
192 | 233 | ||
193 | 234 | ||
194 | </RelativeLayout> | 235 | </RelativeLayout> |
195 | </LinearLayout> | 236 | </LinearLayout> |
196 | 237 | ||
197 | 238 |
app/src/main/res/layout/fragment_error_book.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="match_parent" | 3 | android:layout_height="match_parent" |
4 | android:orientation="vertical"> | 4 | android:orientation="vertical"> |
5 | 5 | ||
6 | <RelativeLayout | 6 | <RelativeLayout |
7 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
8 | android:layout_height="40dp" | 8 | android:layout_height="40dp" |
9 | android:layout_marginTop="20dp"> | 9 | android:layout_marginTop="30dp"> |
10 | 10 | ||
11 | <ImageView | 11 | <ImageView |
12 | android:id="@+id/iv_student" | 12 | android:id="@+id/iv_student" |
13 | android:layout_width="35dp" | 13 | android:layout_width="35dp" |
14 | android:layout_height="35dp" | 14 | android:layout_height="35dp" |
15 | android:layout_centerVertical="true" | 15 | android:layout_centerVertical="true" |
16 | android:layout_marginLeft="15dp" /> | 16 | android:layout_marginLeft="15dp" /> |
17 | 17 | ||
18 | <TextView | 18 | <TextView |
19 | android:id="@+id/tv_name" | 19 | android:id="@+id/tv_name" |
20 | android:layout_width="wrap_content" | 20 | android:layout_width="wrap_content" |
21 | android:layout_height="wrap_content" | 21 | android:layout_height="wrap_content" |
22 | android:layout_centerVertical="true" | 22 | android:layout_centerVertical="true" |
23 | android:layout_marginLeft="10dp" | 23 | android:layout_marginLeft="10dp" |
24 | android:layout_toRightOf="@+id/iv_student" | 24 | android:layout_toRightOf="@+id/iv_student" |
25 | android:textColor="#333333" | 25 | android:textColor="#333333" |
26 | android:textSize="16sp" /> | 26 | android:textSize="16sp" /> |
27 | 27 | ||
28 | <TextView | 28 | <TextView |
29 | android:id="@+id/tv_choose" | 29 | android:id="@+id/tv_choose" |
30 | android:layout_width="wrap_content" | 30 | android:layout_width="wrap_content" |
31 | android:layout_height="wrap_content" | 31 | android:layout_height="wrap_content" |
32 | android:layout_alignParentRight="true" | 32 | android:layout_alignParentRight="true" |
33 | android:layout_centerVertical="true" | 33 | android:layout_centerVertical="true" |
34 | android:layout_marginRight="15dp" | 34 | android:layout_marginRight="15dp" |
35 | android:drawableRight="@drawable/ic_filter_black" | 35 | android:drawableRight="@drawable/ic_filter_black" |
36 | android:drawablePadding="5dp" | 36 | android:drawablePadding="5dp" |
37 | android:text="选择学生" | 37 | android:text="选择学生" |
38 | android:textColor="#333333" | 38 | android:textColor="#333333" |
39 | android:textSize="14sp" /> | 39 | android:textSize="14sp" /> |
40 | 40 | ||
41 | </RelativeLayout> | 41 | </RelativeLayout> |
42 | 42 | ||
43 | <RelativeLayout | 43 | <RelativeLayout |
44 | android:id="@+id/rl_take_photo" | 44 | android:id="@+id/rl_take_photo" |
45 | android:layout_width="match_parent" | 45 | android:layout_width="match_parent" |
46 | android:layout_height="200dp" | 46 | android:layout_height="200dp" |
47 | android:background="@mipmap/ic_take_photo"> | 47 | android:background="@mipmap/ic_take_photo"> |
48 | 48 | ||
49 | <TextView | 49 | <TextView |
50 | android:layout_width="wrap_content" | 50 | android:layout_width="wrap_content" |
51 | android:layout_height="wrap_content" | 51 | android:layout_height="wrap_content" |
52 | android:layout_alignParentRight="true" | 52 | android:layout_alignParentRight="true" |
53 | android:layout_centerVertical="true" | 53 | android:layout_centerVertical="true" |
54 | android:layout_marginRight="70dp" | 54 | android:layout_marginRight="70dp" |
55 | android:text="录入错题" | 55 | android:text="录入错题" |
56 | android:textColor="#EDF6FF" | 56 | android:textColor="#EDF6FF" |
57 | android:textSize="22sp" | 57 | android:textSize="22sp" |
58 | android:textStyle="bold" /> | 58 | android:textStyle="bold" /> |
59 | </RelativeLayout> | 59 | </RelativeLayout> |
60 | 60 | ||
61 | <RelativeLayout | 61 | <RelativeLayout |
62 | android:layout_width="match_parent" | 62 | android:layout_width="match_parent" |
63 | android:layout_height="25dp"> | 63 | android:layout_height="25dp"> |
64 | 64 | ||
65 | <TextView | 65 | <TextView |
66 | android:layout_width="wrap_content" | 66 | android:layout_width="wrap_content" |
67 | android:layout_height="wrap_content" | 67 | android:layout_height="wrap_content" |
68 | android:layout_marginLeft="15dp" | 68 | android:layout_marginLeft="15dp" |
69 | android:text="最近录入错题" | 69 | android:text="最近录入错题" |
70 | android:textColor="#333333" | 70 | android:textColor="#333333" |
71 | android:textSize="16sp" | 71 | android:textSize="16sp" |
72 | android:textStyle="bold" /> | 72 | android:textStyle="bold" /> |
73 | 73 | ||
74 | <LinearLayout | 74 | <LinearLayout |
75 | android:id="@+id/ll_all" | 75 | android:id="@+id/ll_all" |
76 | android:layout_width="wrap_content" | 76 | android:layout_width="wrap_content" |
77 | android:layout_height="wrap_content" | 77 | android:layout_height="wrap_content" |
78 | android:layout_alignParentRight="true" | 78 | android:layout_alignParentRight="true" |
79 | android:layout_centerVertical="true" | 79 | android:layout_centerVertical="true" |
80 | android:layout_marginRight="15dp"> | 80 | android:layout_marginRight="15dp"> |
81 | 81 | ||
82 | <TextView | 82 | <TextView |
83 | android:layout_width="wrap_content" | 83 | android:layout_width="wrap_content" |
84 | android:layout_height="wrap_content" | 84 | android:layout_height="wrap_content" |
85 | android:layout_gravity="center_vertical" | 85 | android:layout_gravity="center_vertical" |
86 | android:text="查看全部" | 86 | android:text="查看全部" |
87 | android:textColor="#666666" | 87 | android:textColor="#666666" |
88 | android:textSize="12sp" /> | 88 | android:textSize="12sp" /> |
89 | 89 | ||
90 | <ImageView | 90 | <ImageView |
91 | android:layout_width="9dp" | 91 | android:layout_width="9dp" |
92 | android:layout_height="10dp" | 92 | android:layout_height="10dp" |
93 | android:layout_gravity="center_vertical" | 93 | android:layout_gravity="center_vertical" |
94 | android:layout_marginLeft="5dp" | 94 | android:layout_marginLeft="5dp" |
95 | android:src="@mipmap/ic_arrow_right" /> | 95 | android:src="@mipmap/ic_arrow_right" /> |
96 | </LinearLayout> | 96 | </LinearLayout> |
97 | </RelativeLayout> | 97 | </RelativeLayout> |
98 | 98 | ||
99 | <androidx.recyclerview.widget.RecyclerView | 99 | <androidx.recyclerview.widget.RecyclerView |
100 | android:id="@+id/recycle_subject" | 100 | android:id="@+id/recycle_subject" |
101 | android:layout_width="match_parent" | 101 | android:layout_width="match_parent" |
102 | android:layout_height="wrap_content" | 102 | android:layout_height="wrap_content" |
103 | android:layout_marginLeft="15dp" | 103 | android:layout_marginLeft="15dp" |
104 | android:layout_marginTop="15dp" | 104 | android:layout_marginTop="15dp" |
105 | android:layout_marginRight="15dp" /> | 105 | android:layout_marginRight="15dp" /> |
106 | 106 | ||
107 | <RelativeLayout | 107 | <RelativeLayout |
108 | android:layout_width="match_parent" | 108 | android:layout_width="match_parent" |
109 | android:layout_height="match_parent"> | 109 | android:layout_height="match_parent"> |
110 | 110 | ||
111 | <androidx.recyclerview.widget.RecyclerView | 111 | <androidx.recyclerview.widget.RecyclerView |
112 | android:id="@+id/recycle_error" | 112 | android:id="@+id/recycle_error" |
113 | android:layout_width="match_parent" | 113 | android:layout_width="match_parent" |
114 | android:layout_height="wrap_content" | 114 | android:layout_height="wrap_content" |
115 | android:layout_marginTop="15dp" /> | 115 | android:layout_marginTop="15dp" /> |
116 | 116 | ||
117 | <LinearLayout | 117 | <LinearLayout |
118 | android:id="@+id/ll_empty" | 118 | android:id="@+id/ll_empty" |
119 | android:layout_width="wrap_content" | 119 | android:layout_width="wrap_content" |
120 | android:layout_height="wrap_content" | 120 | android:layout_height="wrap_content" |
121 | android:layout_centerHorizontal="true" | 121 | android:layout_centerHorizontal="true" |
122 | android:layout_marginTop="30dp" | 122 | android:layout_marginTop="30dp" |
123 | android:orientation="vertical" | 123 | android:orientation="vertical" |
124 | android:visibility="gone"> | 124 | android:visibility="gone"> |
125 | 125 | ||
126 | <ImageView | 126 | <ImageView |
127 | android:layout_width="155dp" | 127 | android:layout_width="155dp" |
128 | android:layout_height="130dp" | 128 | android:layout_height="130dp" |
129 | android:src="@mipmap/ic_empty" /> | 129 | android:src="@mipmap/ic_empty" /> |
130 | 130 | ||
131 | <TextView | 131 | <TextView |
132 | android:layout_width="wrap_content" | 132 | android:layout_width="wrap_content" |
133 | android:layout_height="wrap_content" | 133 | android:layout_height="wrap_content" |
134 | android:layout_gravity="center_horizontal" | 134 | android:layout_gravity="center_horizontal" |
135 | android:text="暂无错题~" /> | 135 | android:text="暂无错题~" /> |
136 | </LinearLayout> | 136 | </LinearLayout> |
137 | </RelativeLayout> | 137 | </RelativeLayout> |
138 | 138 | ||
139 | 139 | ||
140 | </LinearLayout> | 140 | </LinearLayout> |
app/src/main/res/layout/fragment_home.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:background="#F4F6F8"> | 6 | android:background="#F4F6F8"> |
7 | 7 | ||
8 | <View | 8 | <View |
9 | android:id="@+id/view_1" | 9 | android:id="@+id/view_1" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="170dp" | 11 | android:layout_height="170dp" |
12 | android:background="@drawable/bg_home" | 12 | android:background="@drawable/bg_home" |
13 | app:layout_constraintTop_toTopOf="parent" /> | 13 | app:layout_constraintTop_toTopOf="parent" /> |
14 | 14 | ||
15 | <TextView | 15 | <TextView |
16 | android:id="@+id/tv_title" | 16 | android:id="@+id/tv_title" |
17 | android:layout_width="wrap_content" | 17 | android:layout_width="wrap_content" |
18 | android:layout_height="wrap_content" | 18 | android:layout_height="wrap_content" |
19 | android:layout_marginTop="35dp" | 19 | android:layout_marginTop="35dp" |
20 | android:text="首页" | 20 | android:text="首页" |
21 | android:textColor="@color/white" | 21 | android:textColor="@color/white" |
22 | android:textSize="20sp" | 22 | android:textSize="20sp" |
23 | android:textStyle="bold" | 23 | android:textStyle="bold" |
24 | app:layout_constraintLeft_toLeftOf="parent" | 24 | app:layout_constraintLeft_toLeftOf="parent" |
25 | app:layout_constraintRight_toRightOf="parent" | 25 | app:layout_constraintRight_toRightOf="parent" |
26 | app:layout_constraintTop_toTopOf="parent" /> | 26 | app:layout_constraintTop_toTopOf="parent" /> |
27 | 27 | ||
28 | <ImageView | 28 | <ImageView |
29 | android:id="@+id/iv_1" | 29 | android:id="@+id/iv_1" |
30 | android:layout_width="10dp" | 30 | android:layout_width="10dp" |
31 | android:layout_height="16dp" | 31 | android:layout_height="16dp" |
32 | android:layout_marginLeft="15dp" | 32 | android:layout_marginLeft="15dp" |
33 | android:background="@mipmap/icon_back" | 33 | android:background="@mipmap/icon_back" |
34 | android:visibility="gone" | 34 | android:visibility="gone" |
35 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 35 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
36 | app:layout_constraintLeft_toLeftOf="parent" | 36 | app:layout_constraintLeft_toLeftOf="parent" |
37 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 37 | app:layout_constraintTop_toTopOf="@id/view_1" /> |
38 | 38 | ||
39 | <ImageView | 39 | <ImageView |
40 | android:id="@+id/iv_2" | 40 | android:id="@+id/iv_2" |
41 | android:layout_width="55dp" | 41 | android:layout_width="55dp" |
42 | android:layout_height="55dp" | 42 | android:layout_height="55dp" |
43 | android:layout_marginLeft="25dp" | 43 | android:layout_marginLeft="25dp" |
44 | android:background="@drawable/bg_solid_white_30" | 44 | android:background="@drawable/bg_solid_white_30" |
45 | android:padding="1dp" | 45 | android:padding="1dp" |
46 | android:src="@mipmap/txz" | 46 | android:src="@mipmap/txz" |
47 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 47 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
48 | app:layout_constraintLeft_toLeftOf="parent" | 48 | app:layout_constraintLeft_toLeftOf="parent" |
49 | app:layout_constraintTop_toBottomOf="@id/tv_title" /> | 49 | app:layout_constraintTop_toBottomOf="@id/tv_title" /> |
50 | 50 | ||
51 | <TextView | 51 | <TextView |
52 | android:id="@+id/tv_name" | 52 | android:id="@+id/tv_name" |
53 | android:layout_width="wrap_content" | 53 | android:layout_width="wrap_content" |
54 | android:layout_height="wrap_content" | 54 | android:layout_height="wrap_content" |
55 | android:layout_marginLeft="20dp" | 55 | android:layout_marginLeft="20dp" |
56 | android:textColor="@color/white" | 56 | android:textColor="@color/white" |
57 | android:textSize="18sp" | 57 | android:textSize="18sp" |
58 | app:layout_constraintBottom_toBottomOf="@id/iv_2" | 58 | app:layout_constraintBottom_toBottomOf="@id/iv_2" |
59 | app:layout_constraintLeft_toRightOf="@id/iv_2" | 59 | app:layout_constraintLeft_toRightOf="@id/iv_2" |
60 | app:layout_constraintTop_toTopOf="@id/iv_2" /> | 60 | app:layout_constraintTop_toTopOf="@id/iv_2" /> |
61 | 61 | ||
62 | <ImageView | 62 | <ImageView |
63 | android:id="@+id/iv_3" | 63 | android:id="@+id/iv_3" |
64 | android:layout_width="35dp" | 64 | android:layout_width="35dp" |
65 | android:layout_height="35dp" | 65 | android:layout_height="35dp" |
66 | android:padding="5dp" | 66 | android:padding="5dp" |
67 | android:src="@mipmap/xxan" | 67 | android:src="@mipmap/xxan" |
68 | app:layout_constraintBottom_toBottomOf="@id/iv_2" | 68 | app:layout_constraintBottom_toBottomOf="@id/iv_2" |
69 | app:layout_constraintLeft_toRightOf="@id/tv_name" | 69 | app:layout_constraintLeft_toRightOf="@id/tv_name" |
70 | app:layout_constraintTop_toTopOf="@id/iv_2" /> | 70 | app:layout_constraintTop_toTopOf="@id/iv_2" /> |
71 | 71 | ||
72 | <ImageView | 72 | <ImageView |
73 | android:id="@+id/iv_sapmiao" | 73 | android:id="@+id/iv_sapmiao" |
74 | android:layout_width="35dp" | 74 | android:layout_width="35dp" |
75 | android:layout_height="35dp" | 75 | android:layout_height="35dp" |
76 | android:layout_marginRight="20dp" | 76 | android:layout_marginRight="20dp" |
77 | android:padding="5dp" | 77 | android:padding="5dp" |
78 | android:src="@mipmap/ssss" | 78 | android:src="@mipmap/ssss" |
79 | app:layout_constraintBottom_toBottomOf="@id/iv_2" | 79 | app:layout_constraintBottom_toBottomOf="@id/iv_2" |
80 | app:layout_constraintRight_toRightOf="parent" | 80 | app:layout_constraintRight_toRightOf="parent" |
81 | app:layout_constraintTop_toTopOf="@id/iv_2" /> | 81 | app:layout_constraintTop_toTopOf="@id/iv_2" /> |
82 | 82 | ||
83 | 83 | ||
84 | <LinearLayout | 84 | <LinearLayout |
85 | android:id="@+id/view_2" | 85 | android:id="@+id/view_2" |
86 | android:layout_width="match_parent" | 86 | android:layout_width="match_parent" |
87 | android:layout_height="130dp" | 87 | android:layout_height="130dp" |
88 | android:layout_marginTop="160dp" | 88 | android:layout_marginTop="160dp" |
89 | android:background="@drawable/bg_student" | 89 | android:background="@drawable/bg_student" |
90 | android:orientation="horizontal" | 90 | android:orientation="horizontal" |
91 | app:layout_constraintLeft_toLeftOf="parent" | 91 | app:layout_constraintLeft_toLeftOf="parent" |
92 | app:layout_constraintRight_toRightOf="parent" | 92 | app:layout_constraintRight_toRightOf="parent" |
93 | app:layout_constraintTop_toTopOf="parent"> | 93 | app:layout_constraintTop_toTopOf="parent"> |
94 | 94 | ||
95 | <LinearLayout | 95 | <LinearLayout |
96 | android:id="@+id/ll_app" | ||
96 | android:layout_width="0dp" | 97 | android:layout_width="0dp" |
97 | android:layout_height="wrap_content" | 98 | android:layout_height="wrap_content" |
98 | android:layout_gravity="center_vertical" | 99 | android:layout_gravity="center_vertical" |
99 | android:layout_weight="1" | 100 | android:layout_weight="1" |
100 | android:orientation="vertical"> | 101 | android:orientation="vertical"> |
101 | 102 | ||
102 | <ImageView | 103 | <ImageView |
103 | android:id="@+id/iv_21" | 104 | android:id="@+id/iv_21" |
104 | android:layout_width="50dp" | 105 | android:layout_width="50dp" |
105 | android:layout_height="50dp" | 106 | android:layout_height="50dp" |
106 | android:layout_gravity="center_horizontal" | 107 | android:layout_gravity="center_horizontal" |
107 | android:layout_marginTop="15dp" | 108 | android:layout_marginTop="15dp" |
108 | android:background="@mipmap/yyxz" /> | 109 | android:background="@mipmap/yyxz" /> |
109 | 110 | ||
110 | <TextView | 111 | <TextView |
111 | android:layout_width="wrap_content" | 112 | android:layout_width="wrap_content" |
112 | android:layout_height="wrap_content" | 113 | android:layout_height="wrap_content" |
113 | android:layout_gravity="center_horizontal" | 114 | android:layout_gravity="center_horizontal" |
114 | android:layout_marginTop="10dp" | 115 | android:layout_marginTop="10dp" |
115 | android:text="应用管理" | 116 | android:text="应用管理" |
116 | android:textColor="#333333" | 117 | android:textColor="#333333" |
117 | android:textSize="14sp" | 118 | android:textSize="14sp" |
118 | app:layout_constraintLeft_toLeftOf="@id/iv_21" | 119 | app:layout_constraintLeft_toLeftOf="@id/iv_21" |
119 | app:layout_constraintRight_toRightOf="@id/iv_21" | 120 | app:layout_constraintRight_toRightOf="@id/iv_21" |
120 | app:layout_constraintTop_toBottomOf="@id/iv_21" /> | 121 | app:layout_constraintTop_toBottomOf="@id/iv_21" /> |
121 | </LinearLayout> | 122 | </LinearLayout> |
122 | 123 | ||
123 | <LinearLayout | 124 | <LinearLayout |
124 | android:id="@+id/ll_error" | 125 | android:id="@+id/ll_error" |
125 | android:layout_width="0dp" | 126 | android:layout_width="0dp" |
126 | android:layout_height="wrap_content" | 127 | android:layout_height="wrap_content" |
127 | android:layout_gravity="center_vertical" | 128 | android:layout_gravity="center_vertical" |
128 | android:layout_weight="1" | 129 | android:layout_weight="1" |
129 | android:orientation="vertical"> | 130 | android:orientation="vertical"> |
130 | 131 | ||
131 | <ImageView | 132 | <ImageView |
132 | android:id="@+id/iv_22" | 133 | android:id="@+id/iv_22" |
133 | android:layout_width="50dp" | 134 | android:layout_width="50dp" |
134 | android:layout_height="50dp" | 135 | android:layout_height="50dp" |
135 | android:layout_gravity="center_horizontal" | 136 | android:layout_gravity="center_horizontal" |
136 | android:layout_marginTop="15dp" | 137 | android:layout_marginTop="15dp" |
137 | android:background="@mipmap/xxxt" | 138 | android:background="@mipmap/xxxt" |
138 | app:layout_constraintLeft_toLeftOf="@id/view_2" | 139 | app:layout_constraintLeft_toLeftOf="@id/view_2" |
139 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 140 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
140 | 141 | ||
141 | <TextView | 142 | <TextView |
142 | android:layout_width="wrap_content" | 143 | android:layout_width="wrap_content" |
143 | android:layout_height="wrap_content" | 144 | android:layout_height="wrap_content" |
144 | android:layout_gravity="center_horizontal" | 145 | android:layout_gravity="center_horizontal" |
145 | android:layout_marginTop="10dp" | 146 | android:layout_marginTop="10dp" |
146 | android:text="小星错题" | 147 | android:text="小星错题" |
147 | android:textColor="#333333" | 148 | android:textColor="#333333" |
148 | android:textSize="14sp" | 149 | android:textSize="14sp" |
149 | app:layout_constraintLeft_toLeftOf="@id/iv_22" | 150 | app:layout_constraintLeft_toLeftOf="@id/iv_22" |
150 | app:layout_constraintRight_toRightOf="@id/iv_22" | 151 | app:layout_constraintRight_toRightOf="@id/iv_22" |
151 | app:layout_constraintTop_toBottomOf="@id/iv_22" /> | 152 | app:layout_constraintTop_toBottomOf="@id/iv_22" /> |
152 | </LinearLayout> | 153 | </LinearLayout> |
153 | 154 | ||
154 | 155 | ||
155 | <LinearLayout | 156 | <LinearLayout |
157 | android:id="@+id/ll_device" | ||
156 | android:layout_width="0dp" | 158 | android:layout_width="0dp" |
157 | android:layout_height="wrap_content" | 159 | android:layout_height="wrap_content" |
158 | android:layout_gravity="center_vertical" | 160 | android:layout_gravity="center_vertical" |
159 | android:layout_weight="1" | 161 | android:layout_weight="1" |
160 | android:orientation="vertical"> | 162 | android:orientation="vertical"> |
161 | 163 | ||
162 | <ImageView | 164 | <ImageView |
163 | android:id="@+id/iv_24" | 165 | android:id="@+id/iv_24" |
164 | android:layout_width="50dp" | 166 | android:layout_width="50dp" |
165 | android:layout_height="50dp" | 167 | android:layout_height="50dp" |
166 | android:layout_gravity="center_horizontal" | 168 | android:layout_gravity="center_horizontal" |
167 | android:layout_marginTop="15dp" | 169 | android:layout_marginTop="15dp" |
168 | android:background="@mipmap/sbgl" | 170 | android:background="@mipmap/sbgl" |
169 | app:layout_constraintLeft_toLeftOf="@id/view_2" | 171 | app:layout_constraintLeft_toLeftOf="@id/view_2" |
170 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 172 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
171 | 173 | ||
172 | <TextView | 174 | <TextView |
173 | android:layout_width="wrap_content" | 175 | android:layout_width="wrap_content" |
174 | android:layout_height="wrap_content" | 176 | android:layout_height="wrap_content" |
175 | android:layout_gravity="center_horizontal" | 177 | android:layout_gravity="center_horizontal" |
176 | android:layout_marginTop="10dp" | 178 | android:layout_marginTop="10dp" |
177 | android:text="设备管理" | 179 | android:text="设备管理" |
178 | android:textColor="#333333" | 180 | android:textColor="#333333" |
179 | android:textSize="14sp" | 181 | android:textSize="14sp" |
180 | app:layout_constraintLeft_toLeftOf="@id/iv_24" | 182 | app:layout_constraintLeft_toLeftOf="@id/iv_24" |
181 | app:layout_constraintRight_toRightOf="@id/iv_24" | 183 | app:layout_constraintRight_toRightOf="@id/iv_24" |
182 | app:layout_constraintTop_toBottomOf="@id/iv_24" /> | 184 | app:layout_constraintTop_toBottomOf="@id/iv_24" /> |
183 | </LinearLayout> | 185 | </LinearLayout> |
184 | </LinearLayout> | 186 | </LinearLayout> |
185 | 187 | ||
186 | <RelativeLayout | 188 | <RelativeLayout |
187 | android:id="@+id/view_3" | 189 | android:id="@+id/view_3" |
188 | android:layout_width="match_parent" | 190 | android:layout_width="match_parent" |
189 | android:layout_height="match_parent" | 191 | android:layout_height="match_parent" |
190 | android:layout_marginTop="305dp" | 192 | android:layout_marginTop="305dp" |
191 | android:layout_marginBottom="20dp" | 193 | android:layout_marginBottom="20dp" |
192 | android:background="@color/white" | 194 | android:background="@color/white" |
193 | android:orientation="vertical" | 195 | android:orientation="vertical" |
194 | app:layout_constraintLeft_toLeftOf="parent" | 196 | app:layout_constraintLeft_toLeftOf="parent" |
195 | app:layout_constraintRight_toRightOf="parent" | 197 | app:layout_constraintRight_toRightOf="parent" |
196 | app:layout_constraintTop_toBottomOf="@+id/view_2"> | 198 | app:layout_constraintTop_toBottomOf="@+id/view_2"> |
197 | 199 | ||
198 | <LinearLayout | 200 | <LinearLayout |
199 | android:id="@+id/rl_schedule" | 201 | android:id="@+id/rl_schedule" |
200 | android:layout_width="wrap_content" | 202 | android:layout_width="wrap_content" |
201 | android:layout_height="wrap_content" | 203 | android:layout_height="wrap_content" |
202 | android:layout_centerHorizontal="true" | 204 | android:layout_centerHorizontal="true" |
203 | android:layout_marginTop="15dp" | 205 | android:layout_marginTop="15dp" |
204 | android:layout_marginRight="10dp" | 206 | android:layout_marginRight="10dp" |
205 | android:orientation="horizontal"> | 207 | android:orientation="horizontal"> |
206 | 208 | ||
207 | <ImageView | 209 | <ImageView |
208 | android:layout_width="25dp" | 210 | android:layout_width="25dp" |
209 | android:layout_height="22dp" | 211 | android:layout_height="22dp" |
210 | android:layout_centerVertical="true" | 212 | android:layout_centerVertical="true" |
211 | android:layout_gravity="center_vertical" | 213 | android:layout_gravity="center_vertical" |
212 | android:layout_marginRight="5dp" | 214 | android:layout_marginRight="5dp" |
213 | android:layout_toLeftOf="@+id/tv_31" | 215 | android:layout_toLeftOf="@+id/tv_31" |
214 | android:src="@mipmap/ic_schedule" /> | 216 | android:src="@mipmap/ic_schedule" /> |
215 | 217 | ||
216 | <TextView | 218 | <TextView |
217 | android:id="@+id/tv_31" | 219 | android:id="@+id/tv_31" |
218 | android:layout_width="wrap_content" | 220 | android:layout_width="wrap_content" |
219 | android:layout_height="wrap_content" | 221 | android:layout_height="wrap_content" |
220 | android:layout_gravity="center_vertical" | 222 | android:layout_gravity="center_vertical" |
221 | android:text="本周学习计划" | 223 | android:text="本周学习计划" |
222 | android:textColor="#333333" | 224 | android:textColor="#333333" |
223 | android:textSize="19sp" | 225 | android:textSize="19sp" |
224 | android:textStyle="bold" /> | 226 | android:textStyle="bold" /> |
225 | 227 | ||
226 | 228 | ||
227 | </LinearLayout> | 229 | </LinearLayout> |
228 | 230 | ||
229 | 231 | ||
230 | <ImageView | 232 | <ImageView |
231 | android:id="@+id/iv_empty" | 233 | android:id="@+id/iv_empty" |
232 | android:layout_width="103dp" | 234 | android:layout_width="103dp" |
233 | android:layout_height="66dp" | 235 | android:layout_height="66dp" |
234 | android:layout_below="@+id/rl_schedule" | 236 | android:layout_below="@+id/rl_schedule" |
235 | android:layout_centerHorizontal="true" | 237 | android:layout_centerHorizontal="true" |
236 | android:layout_gravity="center_horizontal" | 238 | android:layout_gravity="center_horizontal" |
237 | android:layout_marginTop="48dp" | 239 | android:layout_marginTop="48dp" |
238 | android:background="@mipmap/zwjh" /> | 240 | android:background="@mipmap/zwjh" /> |
239 | 241 | ||
240 | <TextView | 242 | <TextView |
241 | android:id="@+id/tv_empty" | 243 | android:id="@+id/tv_empty" |
242 | android:layout_width="wrap_content" | 244 | android:layout_width="wrap_content" |
243 | android:layout_height="wrap_content" | 245 | android:layout_height="wrap_content" |
244 | android:layout_below="@+id/iv_empty" | 246 | android:layout_below="@+id/iv_empty" |
245 | android:layout_centerHorizontal="true" | 247 | android:layout_centerHorizontal="true" |
246 | android:layout_gravity="center_horizontal" | 248 | android:layout_gravity="center_horizontal" |
247 | android:layout_marginTop="18dp" | 249 | android:layout_marginTop="18dp" |
248 | android:text="暂无学习计划" | 250 | android:text="暂无学习计划" |
249 | android:textColor="#666666" | 251 | android:textColor="#666666" |
250 | android:textSize="12dp" /> | 252 | android:textSize="12dp" /> |
251 | 253 | ||
252 | <androidx.recyclerview.widget.RecyclerView | 254 | <androidx.recyclerview.widget.RecyclerView |
253 | android:id="@+id/recycle" | 255 | android:id="@+id/recycle" |
254 | android:layout_width="match_parent" | 256 | android:layout_width="match_parent" |
255 | android:layout_height="match_parent" | 257 | android:layout_height="match_parent" |
256 | android:layout_below="@+id/rl_schedule" /> | 258 | android:layout_below="@+id/rl_schedule" /> |
257 | </RelativeLayout> | 259 | </RelativeLayout> |
258 | 260 | ||
259 | 261 | ||
260 | </androidx.constraintlayout.widget.ConstraintLayout> | 262 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/mipmap-xhdpi/ic_chinese.png
app/src/main/res/mipmap-xxhdpi/ic_chinese.png
app/src/main/res/values/strings.xml
1 | <resources> | 1 | <resources> |
2 | <string name="app_name">家长管控</string> | 2 | <string name="app_name">家长管控</string> |
3 | <string name="chinese">语文</string> | 3 | <string name="chinese">语文</string> |
4 | <string name="math">数学</string> | 4 | <string name="math">数学</string> |
5 | <string name="english">英语</string> | 5 | <string name="english">英语</string> |
6 | <string name="physics">物理</string> | 6 | <string name="physics">物理</string> |
7 | <string name="chemistry">化学</string> | 7 | <string name="chemistry">化学</string> |
8 | <string name="text_done">已掌握</string> | 8 | <string name="text_done">已掌握</string> |
9 | <string name="text_undo">未掌握</string> | 9 | <string name="text_undo">未掌握</string> |
10 | <string name="topic_start">知识点</string> | 10 | <string name="topic_start">知识点</string> |
11 | <string name="loading_text">图片处理中,请稍后。。。</string> | 11 | <string name="loading_text">图片处理中,请稍后。。。</string> |
12 | <string name="num_topic">第%1$s题</string> | 12 | <string name="num_topic">第%1$s题</string> |
13 | <string name="topic_type_in">课内</string> | 13 | <string name="topic_type_in">课内</string> |
14 | <string name="topic_type_out">课外</string> | 14 | <string name="topic_type_out">课外</string> |
15 | <string name="topic_subject"><![CDATA[<font color="#666666">科</font><font color="#FFFFFF">科目</font><font color="#666666">目:</font>%1$s]]> </string> | ||
16 | <string name="topic_grade"><![CDATA[<font color="#666666">年级学期:</font>%1$s]]> </string> | ||
17 | <string name="topic_reason"><![CDATA[<font color="#666666">错误原因:</font>%1$s]]> </string> | ||
18 | <string name="topic_manager"><![CDATA[<font color="#666666">掌握状态:</font>%1$s]]> </string> | ||
19 | <string name="topic_type"><![CDATA[<font color="#666666">来</font><font color="#FFFFFF">科目</font><font color="#666666">源:</font>%1$s]]> </string> | ||
15 | <string-array name="filter_subject"> | 20 | <string-array name="filter_subject"> |
16 | <item>@string/chinese</item> | 21 | <item>@string/chinese</item> |
17 | <item>@string/math</item> | 22 | <item>@string/math</item> |
18 | <item>@string/english</item> | 23 | <item>@string/english</item> |
19 | <item>@string/physics</item> | 24 | <item>@string/physics</item> |
20 | <item>@string/chemistry</item> | 25 | <item>@string/chemistry</item> |
21 | </string-array> | 26 | </string-array> |
22 | <string-array name="error_reason"> | 27 | <string-array name="error_reason"> |
23 | <item>审题错误</item> | 28 | <item>审题错误</item> |
24 | <item>思路错误</item> | 29 | <item>思路错误</item> |
25 | <item>运算错误</item> | 30 | <item>运算错误</item> |
26 | <item>概念模糊</item> | 31 | <item>概念模糊</item> |
27 | <item>粗心大意</item> | 32 | <item>粗心大意</item> |
28 | <item>其他错误</item> | 33 | <item>其他错误</item> |
29 | </string-array> | 34 | </string-array> |
30 | <string-array name="grade_array"> | 35 | <string-array name="grade_array"> |
31 | <item>上学期</item> | 36 | <item>上学期</item> |
32 | <item>下学期</item> | 37 | <item>下学期</item> |
33 | </string-array> | 38 | </string-array> |
34 | </resources> | 39 | </resources> |