From 9d2a1b1683bea08cf368f54b7220dc38ac3d22c2 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期一, 18 一月 2021 17:47:53 +0800 Subject: [PATCH] 灯光考试项目 DB --- app/src/main/res/drawable/ic_add.xml | 4 app/src/main/assets/lightallanswers.json | 149 +++ app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjRepository.java | 10 app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java | 2 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerDao.java | 35 app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java | 8 app/src/main/res/drawable/aliyun_svideo_icon_upload_success.png | 0 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestions.java | 52 + app/src/main/java/safeluck/drive/evaluation/DB/lightdb/InjectUtils.kt | 39 + app/src/main/res/drawable/ic_select_no.xml | 9 app/src/main/res/layout/light_exam_select_item.xml | 113 ++ app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjViewModel.java | 4 app/src/main/java/safeluck/drive/evaluation/Constant.java | 3 app/src/main/java/safeluck/drive/evaluation/adapter/LightExamUseAdapter.java | 97 ++ app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestRepository.kt | 29 app/src/main/res/values/strings.xml | 3 app/src/main/res/drawable/ic_add_selector.xml | 5 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestionsDao.java | 36 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseInitWorker.java | 52 + app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestionsDao.java | 29 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestVMFactory.kt | 16 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestsViewModel.kt | 23 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultViewModel.kt | 39 + app/src/main/res/layout/fragment_light_exam_list.xml | 84 ++ app/src/main/java/safeluck/drive/evaluation/adapter/LightExamSelectAdapter.java | 189 ++++ app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestInitWorker.java | 52 + app/src/main/res/drawable/divider.xml | 6 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersViewModel.kt | 34 app/src/main/res/values/styles.xml | 2 app/src/main/java/safeluck/drive/evaluation/DB/failitems/LuKaoFailedProj.java | 2 app/src/main/assets/lightdefault.json | 111 ++ app/src/main/res/layout/light_exam_use_item.xml | 33 app/src/main/java/safeluck/drive/evaluation/bean/Question2Answers.java | 53 + app/src/main/res/drawable/ic_select_yes.xml | 12 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerVMFactory.kt | 16 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswers.java | 51 + app/src/main/java/safeluck/drive/evaluation/customview/MyDecoration.java | 101 ++ app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultRepository.kt | 51 + app/src/main/res/drawable/radiobutton_selector.xml | 5 app/src/main/res/drawable/umeng_socialize_delete.png | 0 app/src/main/res/drawable/ic_add_disable.xml | 9 app/src/main/java/safeluck/drive/evaluation/fragment/SysExamSettingFragment.java | 7 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersRepository.kt | 36 app/src/main/assets/lightAlldefault.json | 94 ++ /dev/null | 28 app/src/main/java/safeluck/drive/evaluation/bean/AnswerStatus.java | 41 + app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultVMFactory.kt | 16 app/src/main/java/safeluck/drive/evaluation/fragment/LightExamFragment.java | 313 ++++++++ app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java | 33 app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestion.java | 46 + app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerInitWorker.java | 55 + 51 files changed, 2,174 insertions(+), 63 deletions(-) diff --git a/app/src/main/assets/lightAlldefault.json b/app/src/main/assets/lightAlldefault.json new file mode 100644 index 0000000..60a1bc0 --- /dev/null +++ b/app/src/main/assets/lightAlldefault.json @@ -0,0 +1,94 @@ +[ + + { + + "id":0, + "question": "璇峰紑鍚墠鐓х伅", + "flag":1 + + }, + { + "id":1, + "question": "澶滈棿鍦ㄦ病鏈夎矾鐏紝鐓ф槑涓嶈壇鏉′欢涓嬭椹�", + "flag":0 + }, + { + "id":2, + "question": "璇峰皢鍓嶇収鐏彉鎹㈡垚杩滃厜", + "flag":0 + }, + { + + "id":3, + "question": "澶滈棿鍦ㄧ獎璺笌闈炴満鍔ㄨ溅浼氳溅", + "flag":0 + }, + { + + "id":4, + "question": "澶滈棿鍚屾柟鍚戣繎璺濈璺熻溅琛岄┒", + "flag":0 + }, + { + "id":5, + "question": "澶滈棿鍦ㄩ亾璺笂鍙戠敓鏁呴殰锛屽Θ纰嶄氦閫氬張闅句互绉诲姩", + "flag":0 + }, + { + "id":6, + "question": "澶滈棿鍦ㄧ獎妗ヤ笌闈炴満鍔ㄨ溅浼氳溅", + "flag":0 + }, + { + "id":7, + "question": "闆惧ぉ琛岄┒", + "flag":0 + }, + + { + "id":8, + "question": "澶滈棿涓庢満鍔ㄨ溅浼氳溅", + "flag":0 + }, + { + "id":9, + "question": "澶滈棿閫氳繃娌℃湁浜ら�氫俊鍙风伅鎺у埗鐨勮矾鍙�", + "flag":0 + }, + { + + "id":10, + "question": "澶滈棿閫氳繃鎬ュ集銆佸潯璺�", + "flag":0 + }, + { + "id":11, + "question": "澶滈棿瓒呰秺鍓嶆柟杞﹁締", + "flag":0 + }, + { + "id":12, + "question": "鍦ㄨ矾杈逛复鏃跺仠杞�", + "flag":0 + }, + { + "id":13, + "question": "澶滈棿璺彛宸﹁浆寮�", + "flag":0 + }, + { + "id":14, + "question": "澶滈棿璺彛鍙宠浆寮�", + "flag":0 + }, + { + "id":15, + "question": "澶滈棿鍦ㄧ収鏄庤壇濂界殑閬撹矾涓婅椹�", + "flag":0 + }, + { + "id":16, + "question": "澶滈棿鐩磋閫氳繃璺彛", + "flag":0 + } +] \ No newline at end of file diff --git a/app/src/main/assets/lightallanswers.json b/app/src/main/assets/lightallanswers.json new file mode 100644 index 0000000..e6628db --- /dev/null +++ b/app/src/main/assets/lightallanswers.json @@ -0,0 +1,149 @@ +[ + + { + "id":0, + "question_id":0, + "answer": "寮�鍚ぇ鐏紝娉ㄦ剰鏄繎鍏�", + "choose":1 + }, + { + "id":1, + "question_id":0, + "answer": "寮�鍚ぇ鐏紝杩滆繎鍏夌伅閮藉彲浠�", + "choose":0 + }, + { + "id":2, + "question_id":1, + "answer": "寮�鍚繙鍏夌伅", + "choose":1 + }, + { + "id":3, + "question_id":2, + "answer": "寮�鍚繙鍏夌伅", + "choose":1 + }, + { + "id":4, + "question_id":3, + "answer": "寮�鍚繎鍏夌伅", + "choose":1 + }, + { + "id":5, + "question_id":4, + "answer": "寮�鍚繎鍏夌伅", + "choose":1 + }, + { + "id":6, + "question_id":5, + "answer": "寮�鍚ず瀹界伅鍜屽嵄闄╄绀虹伅", + "choose":1 + }, + { + "id":7, + "question_id":5, + "answer": "寮�鍚嵄闄╄绀虹伅", + "choose":0 + }, + { + "id":8, + "question_id":6, + "answer": "寮�鍚繎鍏夌伅", + "choose":1 + }, + { + "id":9, + "question_id":7, + "answer": "澶х伅(杩戝厜鐏級+鍗遍櫓璀︾ず鐏�+闆剧伅", + "choose":1 + }, + { + "id":10, + "question_id":7, + "answer": "灏忕伅(绀哄鐏級+鍗遍櫓璀︾ず鐏�+闆剧伅", + "choose":0 + }, + + { + "id":11, + "question_id":8, + "answer": "寮�鍚繎鍏夌伅", + "choose":1 + }, + { + "id":12, + "question_id":9, + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "choose":1 +}, + { + "id":13, + "question_id":10, + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "choose":1 + }, + { + "id":14, + "question_id":11, + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "choose":1 + }, + { + "id":15, + "question_id":11, + "answer": "鍏堝紑宸﹁浆鍚戠伅锛屽悗鍙樻崲杩滆繎鍏夌伅", + "choose":0 + }, + { + "id":16, + "question_id":12, + "answer": "寮�鍚皬鐏�(绀哄鐏級+鍗遍櫓璀︾ず鐏�", + "choose":1 + }, + { + "id":17, + "question_id":13, + "answer": "寮�鍚皬鐏�(绀哄鐏級+宸﹁浆鍚戠伅", + "choose":1 + }, + { + "id":18, + "question_id":13, + "answer": "寮�鍚繎鍏夌伅", + "choose":0 + }, + { + "id":19, + "question_id":14, + "answer": "寮�鍚皬鐏�(绀哄鐏級+鍙宠浆鍚戠伅", + "choose":1 + }, + { + "id":20, + "question_id":14, + "answer": "寮�鍚繎鍏夌伅", + "choose":0 + }, + { + "id":21, + "question_id":15, + "answer": "寮�鍚繎鍏夌伅", + "choose":1 + }, + { + "id":22, + "question_id":16, + "answer": "寮�鍚繎鍏夌伅", + "choose":1 + }, + { + "id":23, + "question_id":16, + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "choose":0 + } + +] \ No newline at end of file diff --git a/app/src/main/assets/lightdefault.json b/app/src/main/assets/lightdefault.json new file mode 100644 index 0000000..7c2962b --- /dev/null +++ b/app/src/main/assets/lightdefault.json @@ -0,0 +1,111 @@ +[ + + { + + "id":0, + "question": "璇峰紑鍚墠鐓х伅", + "answer": "寮�鍚ぇ鐏紝娉ㄦ剰鏄繎鍏�", + "flag":1 + + }, + { + "id":1, + "question": "澶滈棿鍦ㄦ病鏈夎矾鐏紝鐓ф槑涓嶈壇鏉′欢涓嬭椹�", + "answer": "寮�鍚繙鍏夌伅", + "flag":0 + }, + { + "id":2, + "question": "璇峰皢鍓嶇収鐏彉鎹㈡垚杩滃厜", + "answer": "寮�鍚繙鍏夌伅", + "flag":0 + }, + { + + "id":3, + "question": "澶滈棿鍦ㄧ獎璺笌闈炴満鍔ㄨ溅浼氳溅", + "answer": "寮�鍚繎鍏夌伅", + "flag":0 + }, + { + + "id":4, + "question": "澶滈棿鍚屾柟鍚戣繎璺濈璺熻溅琛岄┒", + "answer": "寮�鍚繎鍏夌伅", + "flag":0 + }, + { + "id":5, + "question": "澶滈棿鍦ㄩ亾璺笂鍙戠敓鏁呴殰锛屽Θ纰嶄氦閫氬張闅句互绉诲姩", + "answer": "寮�鍚ず瀹界伅鍜屽嵄闄╄绀虹伅", + "flag":0 + }, + { + "id":6, + "question": "澶滈棿鍦ㄧ獎妗ヤ笌闈炴満鍔ㄨ溅浼氳溅", + "answer": "寮�鍚繎鍏夌伅", + "flag":0 + }, + { + "id":7, + "question": "闆惧ぉ琛岄┒", + "answer": "澶х伅(杩戝厜鐏級+鍗遍櫓璀︾ず鐏�+闆剧伅", + "flag":0 + }, + + { + "id":8, + "question": "澶滈棿涓庢満鍔ㄨ溅浼氳溅", + "answer": "寮�鍚繎鍏夌伅", + "flag":0 + }, + { + "id":9, + "question": "澶滈棿閫氳繃娌℃湁浜ら�氫俊鍙风伅鎺у埗鐨勮矾鍙�", + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "flag":0 + }, + { + + "id":10, + "question": "澶滈棿閫氳繃鎬ュ集銆佸潯璺�", + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "flag":0 + }, + { + "id":11, + "question": "澶滈棿瓒呰秺鍓嶆柟杞﹁締", + "answer": "鍙樻崲杩滆繎鍏夌伅锛屽畬鎴愭搷浣滃悗浠嶄负杩戝厜", + "flag":0 + }, + { + "id":12, + "question": "鍦ㄨ矾杈逛复鏃跺仠杞�", + "answer": "寮�鍚皬鐏�(绀哄鐏級+鍗遍櫓璀︾ず鐏�", + "flag":0 + }, + { + "id":13, + "question": "澶滈棿璺彛宸﹁浆寮�", + "answer": "寮�鍚皬鐏�(绀哄鐏級+宸﹁浆鍚戠伅", + "flag":0 + }, + { + "id":14, + "question": "澶滈棿璺彛鍙宠浆寮�", + "answer": "寮�鍚皬鐏�(绀哄鐏級+鍙宠浆鍚戠伅", + "flag":0 + }, + { + "id":15, + "question": "澶滈棿鍦ㄧ収鏄庤壇濂界殑閬撹矾涓婅椹�", + "answer": "寮�鍚繎鍏夌伅", + "flag":0 + }, + { + "id":16, + "question": "澶滈棿鐩磋閫氳繃璺彛", + "answer": "寮�鍚繎鍏夌伅", + "flag":0 + } +] \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/Constant.java b/app/src/main/java/safeluck/drive/evaluation/Constant.java index 5ca34b6..769a789 100644 --- a/app/src/main/java/safeluck/drive/evaluation/Constant.java +++ b/app/src/main/java/safeluck/drive/evaluation/Constant.java @@ -112,6 +112,9 @@ public static final Integer BLUETOOTH_CONNECT = 3; public static final String OUR_SYS_IMAGE = "qcom/msm8909/msm8909:7.1.2/N2G47H/yy"; public static final String BIND_EXAM_STATUS_TOPIC = "BIND_EXAM_STATUS_TOPIC"; + public static final String LIGHT_DEFAULT_JSON = "lightdefault.json"; + public static final String LIGHT_ALL_ANSWER_JSON = "lightallanswers.json"; + public static final String LIGHT_ALL_DEFAULT_JSON = "lightAlldefault.json"; public static String exam_enter_exitdata="exam_enter_exitdata"; public static int Chang_di = 2; public static int DaoLu_night = 3; diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java b/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java index 352721b..51de27d 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java @@ -7,7 +7,6 @@ import androidx.room.Database; import androidx.room.Room; import androidx.room.RoomDatabase; -import androidx.room.migration.Migration; import androidx.sqlite.db.SupportSQLiteDatabase; import androidx.work.OneTimeWorkRequest; import androidx.work.WorkContinuation; @@ -17,20 +16,16 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import okhttp3.Route; import safeluck.drive.evaluation.DB.appstatusdb.AppStatus; import safeluck.drive.evaluation.DB.appstatusdb.AppStatusDao; import safeluck.drive.evaluation.DB.appstatusdb.AppStatusInitWork; import safeluck.drive.evaluation.DB.criterias.Criteria; import safeluck.drive.evaluation.DB.criterias.CriteriaDao; import safeluck.drive.evaluation.DB.criterias.CriteriaForI; -import safeluck.drive.evaluation.DB.criterias.CriteriaForII; import safeluck.drive.evaluation.DB.criterias.CriteriaForIII; import safeluck.drive.evaluation.DB.criterias.CriteriaForIIIWorker; -import safeluck.drive.evaluation.DB.criterias.CriteriaForIIWorker; import safeluck.drive.evaluation.DB.criterias.CriteriaForIWorker; import safeluck.drive.evaluation.DB.criterias.CriteriaIDao; -import safeluck.drive.evaluation.DB.criterias.CriteriaIIDao; import safeluck.drive.evaluation.DB.criterias.CriteriaIIIDao; import safeluck.drive.evaluation.DB.criterias.CriteriaInitWorker; import safeluck.drive.evaluation.DB.exam_status.ExamStatus; @@ -43,6 +38,15 @@ import safeluck.drive.evaluation.DB.failitems.LuKaoFailedProj; import safeluck.drive.evaluation.DB.gps.GPSInfo; import safeluck.drive.evaluation.DB.gps.GpsInfoDao; +import safeluck.drive.evaluation.DB.lightdb.LightAllAnswerDao; +import safeluck.drive.evaluation.DB.lightdb.LightAllAnswerInitWorker; +import safeluck.drive.evaluation.DB.lightdb.LightAllQuestInitWorker; +import safeluck.drive.evaluation.DB.lightdb.LightAllQuestionsDao; +import safeluck.drive.evaluation.DB.lightdb.LightAnswers; +import safeluck.drive.evaluation.DB.lightdb.LightQuestion; +import safeluck.drive.evaluation.DB.lightdb.LightUseInitWorker; +import safeluck.drive.evaluation.DB.lightdb.LightUseQuestions; +import safeluck.drive.evaluation.DB.lightdb.LightUseQuestionsDao; import safeluck.drive.evaluation.DB.route.RouteBean; import safeluck.drive.evaluation.DB.route.RouteBeanDao; import safeluck.drive.evaluation.DB.route.RouteCross; @@ -64,8 +68,8 @@ * 閭锛�632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ -@Database(entities = {Student.class, CriteriaForI.class, FailedProj.class,LuKaoFailedProj.class, CriteriaForII.class, CriteriaForIII.class,RTKConfig.class, GPSInfo.class, AppStatus.class, ExamStatus.class, SingalConfig.class - , Criteria.class,RouteBean.class, RouteCross.class, RouteTriggerLine.class},version = 1,exportSchema = false) +@Database(entities = {Student.class, CriteriaForI.class, FailedProj.class,LuKaoFailedProj.class, LightUseQuestions.class, CriteriaForIII.class,RTKConfig.class, GPSInfo.class, AppStatus.class, ExamStatus.class, SingalConfig.class + , Criteria.class,RouteBean.class, RouteCross.class, RouteTriggerLine.class, LightAnswers.class, LightQuestion.class},version = 1,exportSchema = false) public abstract class WorkRoomDataBase extends RoomDatabase { private static final String TAG = "WorkRoomDataBase"; public abstract StudentDao getstudentDao(); @@ -77,8 +81,9 @@ public abstract CriteriaIDao getCriteriaIDao(); //鑰冨満璇勫垽琛� public abstract CriteriaDao getCriteriaDao(); - //绉戠洰浜� II绫昏�冨満璇勫垽琛� - public abstract CriteriaIIDao getCriteriaIIDao(); + //鑰冨満璇勫垽琛� + public abstract LightUseQuestionsDao getLightUseQuestionsDao(); + public abstract FailProjDao getFailProjDao(); private static volatile WorkRoomDataBase workRoomDataBase; @@ -109,7 +114,9 @@ OneTimeWorkRequest oneTimeWorkRequest = OneTimeWorkRequest.from(SeedDatabaseWorker.class); OneTimeWorkRequest oneTimeWorkRequest1 = OneTimeWorkRequest.from(CriteriaForIWorker.class); OneTimeWorkRequest criteriaInitWorkRequest = OneTimeWorkRequest.from(CriteriaInitWorker.class); -// OneTimeWorkRequest oneTimeWorkRequest3 = OneTimeWorkRequest.from(CriteriaForIIWorker.class); + OneTimeWorkRequest oneTimeWorkRequest3 = OneTimeWorkRequest.from(LightUseInitWorker.class); + OneTimeWorkRequest lightAllQuestInitWorker = OneTimeWorkRequest.from(LightAllQuestInitWorker.class); + OneTimeWorkRequest lightAllAnswerInitWorker = OneTimeWorkRequest.from(LightAllAnswerInitWorker.class); OneTimeWorkRequest mCriteriaForIIIWorker= OneTimeWorkRequest.from(CriteriaForIIIWorker.class); OneTimeWorkRequest oneTimeWorkRequest2 = OneTimeWorkRequest.from(FailedProjWorker.class); OneTimeWorkRequest RTKConfigWorkRequest = OneTimeWorkRequest.from(RTKConfigWork.class); @@ -130,7 +137,7 @@ //鍗曡矾寰勬墽琛岋紝鍙互瀹炵幇鏇村姞澶嶆潅鐨勫璺緞鎵ц鏂瑰紡 WorkContinuation chain1= WorkManager.getInstance(mContext).beginWith(Arrays.asList(oneTimeWorkRequest,oneTimeWorkRequest1,criteriaInitWorkRequest)) - .then(mCriteriaForIIIWorker); + .then(mCriteriaForIIIWorker).then(oneTimeWorkRequest3).then(lightAllAnswerInitWorker).then(lightAllQuestInitWorker); WorkContinuation chain2 = WorkManager.getInstance(mContext).beginWith(Arrays.asList(RTKConfigWorkRequest,appStatusInitWork,signalConigInitWorker,routeInitWorker)) .then(oneTimeWorkRequest2).then(examStatusInitWorker); @@ -170,4 +177,8 @@ public abstract CriteriaIIIDao getCriteriaIIIDao(); public abstract LuKaoFailProjDao getLuKaoFailProjDao(); + + public abstract LightAllAnswerDao getLightAllAnswersDao(); + + public abstract LightAllQuestionsDao getLightAllQuestionsDao(); } diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaForII.java b/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaForII.java deleted file mode 100644 index 825366c..0000000 --- a/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaForII.java +++ /dev/null @@ -1,79 +0,0 @@ -package safeluck.drive.evaluation.DB.criterias; - -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -/** - * MyApplication2 - * Created by lzw on 2019/11/26. 10:15:55 - * 閭锛�632393724@qq.com - * All Rights Saved! Chongqing AnYun Tech co. LTD - * - * 绉戠洰浜� II绫昏�冨満璇勫垽鏍囧噯琛� - */ -@Entity(tableName = "criteria_two") -public class CriteriaForII { -/************** - * item_id item_content deducting_reason score_deducting required _precision - 23 璧锋 杞﹂棬鏈畬鍏ㄥ叧闂捣姝� 涓嶅悎鏍� 琛岄┒璺濈澶т簬1m 鏃� - **************/ - @PrimaryKey - @ColumnInfo(name = "item_id") - @NonNull - private int item_id; - - @ColumnInfo(name = "item_content") - private String item_content; - - @ColumnInfo(name = "deducting_reason") - private String deducting_reason; - - - @NonNull @ColumnInfo(name = "score_deducting") - private int score_deducting; - - @ColumnInfo(name = "required_precision") - private String required_precision; - - public int getItem_id() { - return item_id; - } - - public void setItem_id(int item_id) { - this.item_id = item_id; - } - - public String getItem_content() { - return item_content; - } - - public void setItem_content(String item_content) { - this.item_content = item_content; - } - - public String getDeducting_reason() { - return deducting_reason; - } - - public void setDeducting_reason(String deducting_reason) { - this.deducting_reason = deducting_reason; - } - - public int getScore_deducting() { - return score_deducting; - } - - public void setScore_deducting(int score_deducting) { - this.score_deducting = score_deducting; - } - - public String getRequired_precision() { - return required_precision; - } - - public void setRequired_precision(String required_precision) { - this.required_precision = required_precision; - } -} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaForIIWorker.java b/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaForIIWorker.java deleted file mode 100644 index 16155e8..0000000 --- a/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaForIIWorker.java +++ /dev/null @@ -1,59 +0,0 @@ -package safeluck.drive.evaluation.DB.criterias; - -import android.content.Context; - -import androidx.annotation.NonNull; -import androidx.work.Worker; -import androidx.work.WorkerParameters; - -import com.anyun.basecommonlib.MyLog; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Type; -import java.util.List; - -import safeluck.drive.evaluation.DB.Constant; -import safeluck.drive.evaluation.DB.WorkRoomDataBase; - -/** - * MyApplication2 - * Created by lzw on 2019/11/26. 11:59:25 - * 閭锛�632393724@qq.com - * All Rights Saved! Chongqing AnYun Tech co. LTD - */ -public class CriteriaForIIWorker extends Worker { - - private static final String TAG = "CriteriaForIWorker"; - - public CriteriaForIIWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { - super(context, workerParams); - } - - @NonNull - @Override - public Result doWork() { - InputStream inputStream = null; - try { - inputStream = getApplicationContext().getAssets() - .open(Constant.CRITERIAFOR_II_JSON); - InputStreamReader inputStreamReader = new InputStreamReader(inputStream); - JsonReader jsonReader = new JsonReader(inputStreamReader); - Gson gson = new Gson(); - Type type = new TypeToken<List<CriteriaForII>>(){}.getType(); - - List<CriteriaForII> criteriaForIIS = gson.fromJson(jsonReader,type); - MyLog.i(TAG,"鎻掑叆绉戠洰浜岋紝II绫昏�冨満璇勫垽琛�"); - WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getCriteriaIIDao().insertAllCriteriaII(criteriaForIIS); - return Result.success(); - } catch (IOException e) { - e.printStackTrace(); - return Result.failure(); - } - - } -} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaIIDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaIIDao.java deleted file mode 100644 index 7df5f01..0000000 --- a/app/src/main/java/safeluck/drive/evaluation/DB/criterias/CriteriaIIDao.java +++ /dev/null @@ -1,28 +0,0 @@ -package safeluck.drive.evaluation.DB.criterias; - -import androidx.lifecycle.LiveData; -import androidx.room.Dao; -import androidx.room.Insert; -import androidx.room.OnConflictStrategy; -import androidx.room.Query; - -import java.util.List; - - -/** - * MyApplication2 - * Created by lzw on 2019/11/26. 11:12:18 - * 閭锛�632393724@qq.com - * All Rights Saved! Chongqing AnYun Tech co. LTD - */ -@Dao -public interface CriteriaIIDao { - @Insert(onConflict = OnConflictStrategy.IGNORE) - void insertCriteriaII(CriteriaForII criteriaForII); - - @Insert(onConflict = OnConflictStrategy.REPLACE) - void insertAllCriteriaII(List<CriteriaForII> criteriaForII); - - @Query( "SELECT * FROM criteria_two WHERE item_id =:item_id") - LiveData<CriteriaForII > queryItemForCriteriaII(int item_id); -} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java index 9711b5b..d3edd38 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java @@ -34,13 +34,7 @@ */ @Query("SELECT emp_id,stu_id, utc ,sn ,deducting_reason,score_deducting,item_content from criteria INNER JOIN fail_projects ON criteria.item_id= fail_projects.emp_id where fail_projects.stu_id=:stu_id and fail_projects.subject=999") LiveData<List<FailedProj_select>> getFailedProjects(long stu_id); - /** - * 鏌ヨ 绉戠洰浜� II绫昏�冨満鐨勫け璐ラ」鐩� 锛堝琛ㄦ煡璇級 - * 濡傛灉瑕佹坊鍔� 绉戠洰浜孖I III绫昏�冨満澶辫触椤圭洰锛岄渶瑕佸缓绔嬬浉搴旂殑璇勫垽鏍囧噯琛ㄦ暟鎹〃 - * @return - */ - @Query("SELECT emp_id,stu_id,utc,sn,deducting_reason,score_deducting,item_content from criteria_two INNER JOIN fail_projects ON criteria_two.item_id= fail_projects.emp_id where fail_projects.stu_id=:stu_id and fail_projects.subject=2") - LiveData<List<FailedProj_select>> getFailedProjectsForII(long stu_id); + /** * 鏌ヨ 绉戠洰涓� 璺�冭�冨満鐨勫け璐ラ」鐩� 锛堝琛ㄦ煡璇級 * 濡傛灉瑕佹坊鍔� 绉戠洰浜孖I III绫昏�冨満澶辫触椤圭洰锛岄渶瑕佸缓绔嬬浉搴旂殑璇勫垽鏍囧噯琛ㄦ暟鎹〃 diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java index 26ee63a..2a89a41 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java @@ -8,8 +8,6 @@ import safeluck.drive.evaluation.DB.criterias.Criteria; import safeluck.drive.evaluation.DB.criterias.CriteriaForI; -import safeluck.drive.evaluation.DB.criterias.CriteriaForII; -import safeluck.drive.evaluation.DB.criterias.CriteriaForIII; import static androidx.room.ForeignKey.CASCADE; diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjRepository.java b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjRepository.java index f294f3a..16433f6 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjRepository.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjRepository.java @@ -81,15 +81,7 @@ return failProjDao.getFailedProjects(stu_id); } - /** - * 鑾峰緱绉戠洰浜� II绫昏�冨満澶辫触椤圭洰鎵e垎椤� - * - * @param stu_id - * @return - */ - public LiveData<List<FailedProj_select>> getFailedProjectsForII(long stu_id) { - return failProjDao.getFailedProjectsForII(stu_id); - } /** + /** * 鑾峰緱绉戠洰涓� 璺�冭�冨満澶辫触椤圭洰鎵e垎椤� * * @param stu_id diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjViewModel.java b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjViewModel.java index 427b442..503d2b9 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjViewModel.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProjViewModel.java @@ -29,9 +29,7 @@ public LiveData<List<FailedProj_select>> getFailedProjectsForI(long stu_id){ return failedProjRepository.getFailedProjectsForI(stu_id); } - public LiveData<List<FailedProj_select>> getFailedProjectsForII(long stu_id){ - return failedProjRepository.getFailedProjectsForII(stu_id); - } + public LiveData<List<FailedProj_select>> getFailedProjectsForIII(long stu_id){ return failedProjRepository.getFailedProjectsForIII(stu_id); } diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/LuKaoFailedProj.java b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/LuKaoFailedProj.java index 431c6e0..876c4cf 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/failitems/LuKaoFailedProj.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/failitems/LuKaoFailedProj.java @@ -6,8 +6,6 @@ import androidx.room.Index; import androidx.room.PrimaryKey; -import safeluck.drive.evaluation.DB.criterias.CriteriaForI; -import safeluck.drive.evaluation.DB.criterias.CriteriaForII; import safeluck.drive.evaluation.DB.criterias.CriteriaForIII; import static androidx.room.ForeignKey.CASCADE; diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/InjectUtils.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/InjectUtils.kt new file mode 100644 index 0000000..e5b292a --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/InjectUtils.kt @@ -0,0 +1,39 @@ +package safeluck.drive.evaluation.DB.lightdb + +import android.content.Context +import safeluck.drive.evaluation.DB.WorkRoomDataBase + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:27:19 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +object InjectUtils{ + fun provideLightDefaultViewModelFactory(context:Context):LightDefaultVMFactory { + val repository = getLightDefaultRepository(context) + return LightDefaultVMFactory(repository) + } + + private fun getLightDefaultRepository(context: Context): LightDefaultRepository { + return LightDefaultRepository.getInstance(WorkRoomDataBase.getWorkRoomDataBase(context).lightUseQuestionsDao) + } + + private fun getLightAllQuestsRepository(context: Context): LightAllQuestRepository { + return LightAllQuestRepository.getInstance(WorkRoomDataBase.getWorkRoomDataBase(context).lightAllQuestionsDao) + } + + fun provideLightAllQuestionViewModelFactory(context:Context):LightAllQuestVMFactory { + val repository = getLightAllQuestsRepository(context) + return LightAllQuestVMFactory(repository) + } + + + fun provideLightAllAnswerViewModelFactory(context:Context):LightAllAnswerVMFactory { + val repository = getLightAllAnswerRepository(context) + return LightAllAnswerVMFactory(repository) + } + + private fun getLightAllAnswerRepository(context: Context): LightAnswersRepository { + return LightAnswersRepository.getInstance(WorkRoomDataBase.getWorkRoomDataBase(context).lightAllAnswersDao) + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerDao.java new file mode 100644 index 0000000..44a07fc --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerDao.java @@ -0,0 +1,35 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 09:47:02 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface LightAllAnswerDao { + @Insert(onConflict=OnConflictStrategy.REPLACE) + void insertQuestion(LightAnswers lightAnswers); + + @Insert(onConflict=OnConflictStrategy.REPLACE) + void insertAll(List<LightAnswers> answersList); + + @Query("SELECT * from light_all_answers where question_id=:question_id") + List<LightAnswers> getCurrQuest2Answers(int question_id); + + @Query("UPDATE light_all_answers SET choose =:flag WHERE id = :id") + void updateAnswerChoose(int id, int flag); + + @Query("SELECT * from light_all_answers ") + LiveData<List<LightAnswers>> getAllAnswers(); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerInitWorker.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerInitWorker.java new file mode 100644 index 0000000..3e53df3 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerInitWorker.java @@ -0,0 +1,55 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import android.content.Context; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.work.Worker; +import androidx.work.WorkerParameters; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; + +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 10:40:42 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class LightAllAnswerInitWorker extends Worker { + + private static final String TAG = "LightAllAnswInitWorker"; + public LightAllAnswerInitWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { + super(context, workerParams); + } + + @NonNull + @Override + public Result doWork() { + + InputStream inputStream = null; + try { + inputStream = getApplicationContext().getAssets().open(Constant.LIGHT_ALL_ANSWER_JSON); + } catch (IOException e) { + e.printStackTrace(); + } + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + JsonReader jsonReader = new JsonReader(inputStreamReader); + Gson gson = new Gson(); + Type type =new TypeToken<List<LightAnswers>>(){}.getType(); + List<LightAnswers> questionsList = gson.fromJson(jsonReader,type); + Log.i(TAG,"doWork"); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getLightAllAnswersDao().insertAll(questionsList); + return Result.success(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerVMFactory.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerVMFactory.kt new file mode 100644 index 0000000..a9cf5f0 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllAnswerVMFactory.kt @@ -0,0 +1,16 @@ +package safeluck.drive.evaluation.DB.lightdb + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:29:00 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightAllAnswerVMFactory(private val resp:LightAnswersRepository): + ViewModelProvider.NewInstanceFactory() { + override fun <T : ViewModel?> create(modelClass: Class<T>): T { + return LightAnswersViewModel(resp) as T + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestInitWorker.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestInitWorker.java new file mode 100644 index 0000000..50eb508 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestInitWorker.java @@ -0,0 +1,52 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.work.Worker; +import androidx.work.WorkerParameters; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; + +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 10:40:42 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class LightAllQuestInitWorker extends Worker { + + public LightAllQuestInitWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { + super(context, workerParams); + } + + @NonNull + @Override + public Result doWork() { + + InputStream inputStream = null; + try { + inputStream = getApplicationContext().getAssets().open(Constant.LIGHT_ALL_DEFAULT_JSON); + } catch (IOException e) { + e.printStackTrace(); + } + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + JsonReader jsonReader = new JsonReader(inputStreamReader); + Gson gson = new Gson(); + Type type =new TypeToken<List<LightQuestion>>(){}.getType(); + List<LightQuestion> questionsList = gson.fromJson(jsonReader,type); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getLightAllQuestionsDao().insertAll(questionsList); + return Result.success(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestRepository.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestRepository.kt new file mode 100644 index 0000000..6ad7c96 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestRepository.kt @@ -0,0 +1,29 @@ +package safeluck.drive.evaluation.DB.lightdb + +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.withContext + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:01:31 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightAllQuestRepository private constructor( + private val lightdefaulDao: LightAllQuestionsDao +){ + + + + + fun getLightAllQuestions() = lightdefaulDao.allLightQuestions + + + companion object{ + @Volatile + private var instance:LightAllQuestRepository ?= null + + fun getInstance(lightdefaulDao: LightAllQuestionsDao)= instance?: synchronized(this){ + instance?: LightAllQuestRepository(lightdefaulDao).also { instance = it } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestVMFactory.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestVMFactory.kt new file mode 100644 index 0000000..8de5314 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestVMFactory.kt @@ -0,0 +1,16 @@ +package safeluck.drive.evaluation.DB.lightdb + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:29:00 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightAllQuestVMFactory(private val resp:LightAllQuestRepository): + ViewModelProvider.NewInstanceFactory() { + override fun <T : ViewModel?> create(modelClass: Class<T>): T { + return LightQuestsViewModel(resp) as T + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestionsDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestionsDao.java new file mode 100644 index 0000000..3e7420c --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAllQuestionsDao.java @@ -0,0 +1,29 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 09:47:02 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface LightAllQuestionsDao { + @Insert(onConflict=OnConflictStrategy.REPLACE) + void insertQuestion(LightQuestion lightQuestions); + + @Insert(onConflict=OnConflictStrategy.REPLACE) + void insertAll(List<LightQuestion> questionsList); + + @Query("SELECT * FROM alllight_question") + List<LightQuestion> getAllLightQuestions(); + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswers.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswers.java new file mode 100644 index 0000000..66313e3 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswers.java @@ -0,0 +1,51 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 13:32:56 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity(tableName = "light_all_answers") +public class LightAnswers { + @ PrimaryKey + private int id; + private int question_id; + private String answer; + private int choose; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getQuestion_id() { + return question_id; + } + + public void setQuestion_id(int question_id) { + this.question_id = question_id; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public int getChoose() { + return choose; + } + + public void setChoose(int choose) { + this.choose = choose; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersRepository.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersRepository.kt new file mode 100644 index 0000000..4f67835 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersRepository.kt @@ -0,0 +1,36 @@ +package safeluck.drive.evaluation.DB.lightdb + +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.withContext + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:01:31 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightAnswersRepository private constructor( + private val lightdefaulDao: LightAllAnswerDao +){ + + + + + fun getLightAllQuestions(question_id:Int) =lightdefaulDao.getCurrQuest2Answers(question_id) + suspend fun updateAnswerChoose(id: Int, flag: Int) { + withContext(IO){ + lightdefaulDao.updateAnswerChoose(id,flag); + } + } + + fun getLightAllAnswers()=lightdefaulDao.getAllAnswers() + + + companion object{ + @Volatile + private var instance:LightAnswersRepository ?= null + + fun getInstance(lightdefaulDao: LightAllAnswerDao)= instance?: synchronized(this){ + instance?: LightAnswersRepository(lightdefaulDao).also { instance = it } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersViewModel.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersViewModel.kt new file mode 100644 index 0000000..b85e448 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightAnswersViewModel.kt @@ -0,0 +1,34 @@ +package safeluck.drive.evaluation.DB.lightdb + +import androidx.lifecycle.LiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch + +/**DriveJudge + * Created by lzw on 2021/1/15. 09:46:49 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightAnswersViewModel internal constructor(private val lightDefaultRepository: LightAnswersRepository): ViewModel() { + fun getQustion2Answer(quest_id:Int) =lightDefaultRepository.getLightAllQuestions(quest_id) + + + + + @ExperimentalCoroutinesApi + override fun onCleared() { + super.onCleared() + viewModelScope.cancel() + } + + fun updateAnswerChoose(id: Int, i: Int) { + viewModelScope.launch { + lightDefaultRepository.updateAnswerChoose(id,i) + } + } + + fun getAllAnswers() =lightDefaultRepository.getLightAllAnswers() +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultRepository.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultRepository.kt new file mode 100644 index 0000000..5e5957b --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultRepository.kt @@ -0,0 +1,51 @@ +package safeluck.drive.evaluation.DB.lightdb + +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.withContext + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:01:31 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightDefaultRepository private constructor( + private val lightdefaulDao: LightUseQuestionsDao +){ + suspend fun removeItem(lightusequest:LightUseQuestions){ + withContext(IO){ + lightdefaulDao.deleteItem(lightusequest) + } + } + + + + fun getLightUseQuestions() = lightdefaulDao.getLightUseQuestions() + suspend fun updateQuest2Answer(questionId: Int, answ: String) { + withContext(IO){ + + lightdefaulDao.updateAnswer(questionId,answ) + } + } + + suspend fun addItem(questionId: Int, question: String, flag: Int,answ:String) { + withContext(IO){ + + var lightquest = LightUseQuestions() + lightquest.question = question + lightquest.id = questionId + lightquest.flag = flag + lightquest.answer = answ + lightdefaulDao.insertQuestion(lightquest) + } + } + + + companion object{ + @Volatile + private var instance:LightDefaultRepository ?= null + + fun getInstance(lightdefaulDao: LightUseQuestionsDao)= instance?: synchronized(this){ + instance?: LightDefaultRepository(lightdefaulDao).also { instance = it } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultVMFactory.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultVMFactory.kt new file mode 100644 index 0000000..f557169 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultVMFactory.kt @@ -0,0 +1,16 @@ +package safeluck.drive.evaluation.DB.lightdb + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider + +/**DriveJudge + * Created by lzw on 2021/1/15. 10:29:00 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightDefaultVMFactory(private val resp:LightDefaultRepository): + ViewModelProvider.NewInstanceFactory() { + override fun <T : ViewModel?> create(modelClass: Class<T>): T { + return LightDefaultViewModel(resp) as T + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultViewModel.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultViewModel.kt new file mode 100644 index 0000000..19e4744 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightDefaultViewModel.kt @@ -0,0 +1,39 @@ +package safeluck.drive.evaluation.DB.lightdb + +import androidx.lifecycle.LiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch + +/**DriveJudge + * Created by lzw on 2021/1/15. 09:46:49 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightDefaultViewModel internal constructor(private val lightDefaultRepository: LightDefaultRepository): ViewModel() { + var allDefaultQuestion2Answers = lightDefaultRepository.getLightUseQuestions() + fun deleteItem(lightUseQuestions: LightUseQuestions){ + viewModelScope.launch { + lightDefaultRepository.removeItem(lightUseQuestions) + } + } + @ExperimentalCoroutinesApi + override fun onCleared() { + super.onCleared() + viewModelScope.cancel() + } + + fun updateQuestion2Answer(questionId: Int, answ: String) { + viewModelScope.launch { + lightDefaultRepository.updateQuest2Answer(questionId,answ) + } + } + + fun addItem(questionId: Int, Question: String, flag: Int,answer:String) { + viewModelScope.launch { + lightDefaultRepository.addItem(questionId,Question,flag,answer) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestion.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestion.java new file mode 100644 index 0000000..b28cc79 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestion.java @@ -0,0 +1,46 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 13:31:11 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity(tableName = "alllight_question") +public class LightQuestion { + @PrimaryKey + private int id; + + private String question; + + private int flag; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getQuestion() { + return question; + } + + public void setQuestion(String question) { + this.question = question; + } + + + + public int getFlag() { + return flag; + } + + public void setFlag(int flag) { + this.flag = flag; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestsViewModel.kt b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestsViewModel.kt new file mode 100644 index 0000000..4700c0f --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightQuestsViewModel.kt @@ -0,0 +1,23 @@ +package safeluck.drive.evaluation.DB.lightdb + +import androidx.lifecycle.LiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch + +/**DriveJudge + * Created by lzw on 2021/1/15. 09:46:49 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +class LightQuestsViewModel internal constructor(private val lightDefaultRepository: LightAllQuestRepository): ViewModel() { + var allDefaultQuestion2Answers = lightDefaultRepository.getLightAllQuestions() + + @ExperimentalCoroutinesApi + override fun onCleared() { + super.onCleared() + viewModelScope.cancel() + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseInitWorker.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseInitWorker.java new file mode 100644 index 0000000..9276e7d --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseInitWorker.java @@ -0,0 +1,52 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.work.Worker; +import androidx.work.WorkerParameters; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; + +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 10:40:42 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class LightUseInitWorker extends Worker { + + public LightUseInitWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { + super(context, workerParams); + } + + @NonNull + @Override + public Result doWork() { + + InputStream inputStream = null; + try { + inputStream = getApplicationContext().getAssets().open(Constant.LIGHT_DEFAULT_JSON); + } catch (IOException e) { + e.printStackTrace(); + } + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + JsonReader jsonReader = new JsonReader(inputStreamReader); + Gson gson = new Gson(); + Type type =new TypeToken<List<LightUseQuestions>>(){}.getType(); + List<LightUseQuestions> questionsList = gson.fromJson(jsonReader,type); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getLightUseQuestionsDao().insertAll(questionsList); + return Result.success(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestions.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestions.java new file mode 100644 index 0000000..7dff663 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestions.java @@ -0,0 +1,52 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 09:44:23 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity(tableName = "lightUseQuest") +public class LightUseQuestions { + @PrimaryKey + private int id; + + private String question; + private String answer; + private int flag;// 1-涓嶅彲鍒犻櫎 0-鍙垹闄� + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getQuestion() { + return question; + } + + public void setQuestion(String question) { + this.question = question; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public int getFlag() { + return flag; + } + + public void setFlag(int flag) { + this.flag = flag; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestionsDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestionsDao.java new file mode 100644 index 0000000..2aeed11 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/lightdb/LightUseQuestionsDao.java @@ -0,0 +1,36 @@ +package safeluck.drive.evaluation.DB.lightdb; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 09:47:02 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface LightUseQuestionsDao { + @Insert(onConflict=OnConflictStrategy.REPLACE) + void insertQuestion(LightUseQuestions lightUseQuestions); + @Query("Update lightUseQuest set answer=:ans where id=:id") + void updateAnswer(int id,String ans); + @Insert(onConflict=OnConflictStrategy.REPLACE) + void insertAll(List<LightUseQuestions> questionsList); + + @Delete + void deleteItem(LightUseQuestions lightUseQuestions); + + @Query("SELECT * FROM lightUseQuest") + LiveData<List<LightUseQuestions>> getLightUseQuestions(); + + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/adapter/LightExamSelectAdapter.java b/app/src/main/java/safeluck/drive/evaluation/adapter/LightExamSelectAdapter.java new file mode 100644 index 0000000..7f3f2f5 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/adapter/LightExamSelectAdapter.java @@ -0,0 +1,189 @@ +package safeluck.drive.evaluation.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import safeluck.drive.evaluation.R; +import safeluck.drive.evaluation.bean.AnswerStatus; +import safeluck.drive.evaluation.bean.Question2Answers; + +/** + * DriveJudge + * Created by lzw on 2021/1/13. 14:42:59 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class LightExamSelectAdapter extends RecyclerView.Adapter<LightExamSelectAdapter.MyViewHolder> { + + private LayoutInflater inflater; + private Context mContext; + + OnCheckedListener onCheckedListener; + OnAddItemListener onAddItemListener; + //璁板綍RadioButton鐨勭姸鎬� + public HashMap<Integer, String> state_boolean = new HashMap<>(); + private List<Question2Answers> question2AnswersList = new ArrayList<>(); + + public LightExamSelectAdapter(Context context) { + this.inflater = LayoutInflater.from(context); + this.mContext = context; + } + + public void setOnCheckedListener(OnCheckedListener checkedListener){ + this.onCheckedListener = checkedListener; + } + + public void setOnAddItemListener(OnAddItemListener onAddItemListener){ + this.onAddItemListener = onAddItemListener; + } + + public interface OnCheckedListener{ + //position 璺焣uestion鍏宠仈 涔熷氨鏄痲uestion_id; + void checked(int position,int whichAnswer); + } + + public interface OnAddItemListener{ + void add(int pos); + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = inflater.inflate(R.layout.light_exam_select_item,parent,false); + MyViewHolder myViewHolder = new MyViewHolder(view); + return myViewHolder; + } + + public void setDatas(List<Question2Answers> answers){ + question2AnswersList.clear(); + question2AnswersList.addAll(answers); + notifyDataSetChanged(); + } + + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + Question2Answers question2Answers = question2AnswersList.get(position); + holder.tv_question.setText(question2Answers.getQuestion()); + List<AnswerStatus> answerList = question2Answers.getAnswerStatusList(); + + holder.linearLayout2.setVisibility(View.GONE);holder.linearLayout3.setVisibility(View.GONE); + holder.rb1.setOnCheckedChangeListener(null); + + + holder.tv_answer1.setText(String.format(mContext.getResources().getString(R.string.answer),question2Answers.getAnswerStatusList().get(0).getAnswer())); + holder.rb1.setChecked(question2Answers.getAnswerStatusList().get(0).getChoose_flag()==1?true:false); + + + + switch (answerList.size()){ + case 2: + holder.linearLayout2.setVisibility(View.VISIBLE); + AnswerStatus answerStatus1 = answerList.get(1); + holder.rb2.setOnCheckedChangeListener(null); + holder.tv_answer2.setText(String.format(mContext.getResources().getString(R.string.answer),answerStatus1.getAnswer())); + holder.rb2.setChecked(answerStatus1.getChoose_flag()==1?true:false); + break; + case 3: + holder.linearLayout2.setVisibility(View.VISIBLE);holder.linearLayout3.setVisibility(View.VISIBLE); + AnswerStatus answerStatus2= answerList.get(1); + AnswerStatus answerStatus3= answerList.get(2); + holder.rb2.setOnCheckedChangeListener(null); holder.rb3.setOnCheckedChangeListener(null); + holder.tv_answer2.setText(String.format(mContext.getResources().getString(R.string.answer),answerStatus2.getAnswer())); + holder.tv_answer3.setText(String.format(mContext.getResources().getString(R.string.answer),answerStatus3.getAnswer())); + + holder.rb2.setChecked(answerStatus2.getChoose_flag()==1?true:false); + holder.rb3.setChecked(answerStatus3.getChoose_flag()==1?true:false); + break; + } + + holder.imageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onAddItemListener != null){ + onAddItemListener.add(position); + } + } + }); + holder.rb1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked){ + holder.rb2.setChecked(false); + holder.rb3.setChecked(false); + if (onCheckedListener!=null){ + onCheckedListener.checked(position,0); + } + } + } + }); holder.rb2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked){ + holder.rb1.setChecked(false); + holder.rb3.setChecked(false); + onCheckedListener.checked(position,1); + } + } + }); holder.rb3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked){ + holder.rb1.setChecked(false); + holder.rb2.setChecked(false); + onCheckedListener.checked(position,2); + } + } + }); + + } + + @Override + public int getItemCount() { + return question2AnswersList.size(); + } + + public class MyViewHolder extends RecyclerView.ViewHolder { + + TextView tv_question; + TextView tv_answer1; + TextView tv_answer2; + TextView tv_answer3; + + ImageView imageView; + + RadioButton rb1,rb2,rb3; + + LinearLayout linearLayout2,linearLayout3; + + public MyViewHolder(@NonNull View itemView) { + super(itemView); + linearLayout2 = itemView.findViewById(R.id.ll_light_container2); + linearLayout3 = itemView.findViewById(R.id.ll_light_container3); + imageView = itemView.findViewById(R.id.iv_delete_item); + + tv_question = itemView.findViewById(R.id.tv_question); + tv_answer1 = itemView.findViewById(R.id.tv_answer1); + tv_answer2 = itemView.findViewById(R.id.tv_answer2); + tv_answer3 = itemView.findViewById(R.id.tv_answer3); + + rb1 = itemView.findViewById(R.id.rb1_light); + rb2 = itemView.findViewById(R.id.rb2_light); + rb3 = itemView.findViewById(R.id.rb3_light); + } + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/adapter/LightExamUseAdapter.java b/app/src/main/java/safeluck/drive/evaluation/adapter/LightExamUseAdapter.java new file mode 100644 index 0000000..411a46a --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/adapter/LightExamUseAdapter.java @@ -0,0 +1,97 @@ +package safeluck.drive.evaluation.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.List; + +import safeluck.drive.evaluation.DB.lightdb.LightUseQuestions; +import safeluck.drive.evaluation.R; + +/** + * DriveJudge + * Created by lzw on 2021/1/13. 14:42:59 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class LightExamUseAdapter extends RecyclerView.Adapter<LightExamUseAdapter.MyViewHolder> { + + private LayoutInflater mLayoutInflater; + private Context mContext; + private List<LightUseQuestions> examsBeans = new ArrayList<>(); + public LightExamUseAdapter(Context context) { + this.mContext = context; + mLayoutInflater = LayoutInflater.from(context); + } + + private OnDeleteListener onDeleteListener; + + public interface OnDeleteListener{ + void delete(int position); + } + + public void setOnDeleteListener(OnDeleteListener deleteListener){ + this.onDeleteListener = deleteListener; + } + + @NonNull + @Override + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = mLayoutInflater.inflate(R.layout.light_exam_use_item,parent,false); + MyViewHolder myViewHolder = new MyViewHolder(view); + return myViewHolder; + } + + public void setDatas(List<LightUseQuestions> lightExamsBeanList){ + this.examsBeans.clear(); + this.examsBeans.addAll(lightExamsBeanList); + notifyDataSetChanged(); + } + @Override + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { + LightUseQuestions bean = examsBeans.get(position); + holder.tv_answer.setText(String.format(mContext.getResources().getString(R.string.answer),bean.getAnswer())); + holder.tv_question.setText(bean.getQuestion()); + holder.imageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (bean.getFlag() == 1){ + + }else{ + if (onDeleteListener != null){ + Toast.makeText(mContext, String.format("绗�%d涓鐩鍒犻櫎!",position), Toast.LENGTH_SHORT).show(); + onDeleteListener.delete(position); + } + } + + } + }); + + } + + @Override + public int getItemCount() { + return examsBeans.size(); + } + + public class MyViewHolder extends RecyclerView.ViewHolder { + TextView tv_question; + TextView tv_answer; + ImageView imageView ; + public MyViewHolder(@NonNull View itemView) { + super(itemView); + tv_answer = itemView.findViewById(R.id.tv_answer); + tv_question = itemView.findViewById(R.id.tv_question); + imageView = itemView.findViewById(R.id.iv_delete_item); + } + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/AnswerStatus.java b/app/src/main/java/safeluck/drive/evaluation/bean/AnswerStatus.java new file mode 100644 index 0000000..bc0b0d8 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/bean/AnswerStatus.java @@ -0,0 +1,41 @@ +package safeluck.drive.evaluation.bean; + +/** + * DriveJudge + * Created by lzw on 2021/1/15. 15:17:18 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class AnswerStatus { + // 1- xuanzhong + + private int choose_flag; + + private int id; + + private String answer; + + public int getChoose_flag() { + return choose_flag; + } + + public void setChoose_flag(int choose_flag) { + this.choose_flag = choose_flag; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public void setId(int id) { + this.id = id; + } + + public int getId() { + return id; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/Question2Answers.java b/app/src/main/java/safeluck/drive/evaluation/bean/Question2Answers.java new file mode 100644 index 0000000..fe212af --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/bean/Question2Answers.java @@ -0,0 +1,53 @@ +package safeluck.drive.evaluation.bean; + +import java.util.List; + +/** + * DriveJudge + * Created by lzw on 2021/1/14. 14:58:26 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class Question2Answers { + + private String question; + private int question_id; + private List<AnswerStatus> answerStatusList; + //1-宸茬粡娣诲姞鍒� 浣跨敤鐨勯鐩� 0-鏄病鏈夌敯闂� + + private int add_flag; + + public List<AnswerStatus> getAnswerStatusList() { + return answerStatusList; + } + + + public int getQuestion_id() { + return question_id; + } + + public void setQuestion_id(int question_id) { + this.question_id = question_id; + } + + public void setAnswerStatusList(List<AnswerStatus> answerStatusList) { + this.answerStatusList = answerStatusList; + } + + public int getAdd_flag() { + return add_flag; + } + + public void setAdd_flag(int add_flag) { + this.add_flag = add_flag; + } + + public String getQuestion() { + return question; + } + + public void setQuestion(String question) { + this.question = question; + } + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/MyDecoration.java b/app/src/main/java/safeluck/drive/evaluation/customview/MyDecoration.java new file mode 100644 index 0000000..901eb70 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/customview/MyDecoration.java @@ -0,0 +1,101 @@ +package safeluck.drive.evaluation.customview; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.view.View; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +/** + * DriveJudge + * Created by lzw on 2021/1/13. 17:09:58 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class MyDecoration extends RecyclerView.ItemDecoration{ + + private Context mContext; + private Drawable mDivider; + private int mOrientation; + public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; + public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; + + //鎴戜滑閫氳繃鑾峰彇绯荤粺灞炴�т腑鐨刲istDivider鏉ユ坊鍔狅紝鍦ㄧ郴缁熶腑鐨凙ppTheme涓缃� + public static final int[] ATRRS = new int[]{ + android.R.attr.listDivider + }; + + public MyDecoration(Context context, int orientation) { + this.mContext = context; + final TypedArray ta = context.obtainStyledAttributes(ATRRS); + this.mDivider = ta.getDrawable(0); + ta.recycle(); + setOrientation(orientation); + } + + //璁剧疆灞忓箷鐨勬柟鍚� + public void setOrientation(int orientation){ + if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST){ + throw new IllegalArgumentException("invalid orientation"); } mOrientation = orientation; + } + + @Override + public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { + if (mOrientation == HORIZONTAL_LIST){ + drawVerticalLine(c, parent, state); + }else { + drawHorizontalLine(c, parent, state); + } + } + + //鐢绘í绾�, 杩欓噷鐨刾arent鍏跺疄鏄樉绀哄湪灞忓箷鏄剧ず鐨勮繖閮ㄥ垎 + public void drawHorizontalLine(Canvas c, RecyclerView parent, RecyclerView.State state){ + int left = parent.getPaddingLeft(); + int right = parent.getWidth() - parent.getPaddingRight(); + final int childCount = parent.getChildCount(); + for (int i = 0; i < childCount; i++){ + final View child = parent.getChildAt(i); + + //鑾峰緱child鐨勫竷灞�淇℃伅 + final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)child.getLayoutParams(); + final int top = child.getBottom() + params.bottomMargin; + final int bottom = top + mDivider.getIntrinsicHeight(); + mDivider.setBounds(left, top, right, bottom); + mDivider.draw(c); + //Log.d("wnw", left + " " + top + " "+right+" "+bottom+" "+i); + } + } + + //鐢荤珫绾� + public void drawVerticalLine(Canvas c, RecyclerView parent, RecyclerView.State state){ + int top = parent.getPaddingTop(); + int bottom = parent.getHeight() - parent.getPaddingBottom(); + final int childCount = parent.getChildCount(); + for (int i = 0; i < childCount; i++){ + final View child = parent.getChildAt(i); + + //鑾峰緱child鐨勫竷灞�淇℃伅 + final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)child.getLayoutParams(); + final int left = child.getRight() + params.rightMargin; + final int right = left + mDivider.getIntrinsicWidth(); + mDivider.setBounds(left, top, right, bottom); + mDivider.draw(c); + } + } + + //鐢变簬Divider涔熸湁闀垮楂橈紝姣忎竴涓狪tem闇�瑕佸悜涓嬫垨鑰呭悜鍙冲亸绉� + @Override + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + if(mOrientation == HORIZONTAL_LIST){ + //鐢绘í绾匡紝灏辨槸寰�涓嬪亸绉讳竴涓垎鍓茬嚎鐨勯珮搴� + outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); + }else { + //鐢荤珫绾匡紝灏辨槸寰�鍙冲亸绉讳竴涓垎鍓茬嚎鐨勫搴� + outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/LightExamFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/LightExamFragment.java new file mode 100644 index 0000000..f5053dc --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/LightExamFragment.java @@ -0,0 +1,313 @@ +package safeluck.drive.evaluation.fragment; + +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProviders; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.work.OneTimeWorkRequest; +import androidx.work.WorkManager; + +import com.anyun.exam.lib.AYSdk; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import me.yokeyword.fragmentation.SupportFragment; +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; +import safeluck.drive.evaluation.DB.lightdb.InjectUtils; + +import safeluck.drive.evaluation.DB.lightdb.LightAllAnswerDao; +import safeluck.drive.evaluation.DB.lightdb.LightAllAnswerVMFactory; +import safeluck.drive.evaluation.DB.lightdb.LightAnswers; +import safeluck.drive.evaluation.DB.lightdb.LightAnswersViewModel; +import safeluck.drive.evaluation.DB.lightdb.LightDefaultVMFactory; +import safeluck.drive.evaluation.DB.lightdb.LightDefaultViewModel; +import safeluck.drive.evaluation.DB.lightdb.LightQuestion; +import safeluck.drive.evaluation.DB.lightdb.LightQuestsViewModel; +import safeluck.drive.evaluation.DB.lightdb.LightUseInitWorker; +import safeluck.drive.evaluation.DB.lightdb.LightUseQuestions; +import safeluck.drive.evaluation.MainActivity; +import safeluck.drive.evaluation.R; +import safeluck.drive.evaluation.adapter.LightExamSelectAdapter; +import safeluck.drive.evaluation.adapter.LightExamUseAdapter; +import safeluck.drive.evaluation.bean.AnswerStatus; +import safeluck.drive.evaluation.bean.Question2Answers; +import safeluck.drive.evaluation.customview.MyDecoration; + +import safeluck.drive.evaluation.util.CThreadPoolExecutor; + +/** + * DriveJudge + * Created by lzw on 2020/9/1. 11:40:50 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class LightExamFragment extends SupportFragment implements View.OnClickListener { + + public static int UPGRADE_17_FRONT = 1; + public static int UPGRADE_17_AFTER = 0; + + + private final static String TAG = LightExamFragment.class.getSimpleName(); + private Toolbar mToolbar; + private RecyclerView recyclerView_use; + private RecyclerView recyclerView_select; + + private LightExamUseAdapter lightExamUseAdapter; + + private LightDefaultViewModel lightDefaultViewModel; + + private LightAnswersViewModel lightAnswersViewModel; + private List<LightUseQuestions> lightExamsBeans = new ArrayList<>(); + private List<Question2Answers> answersList = new ArrayList<>(); + private LightExamSelectAdapter lightExamSelectAdapter; + + private List<LightAnswers> lightAnswerList = new ArrayList<>(); + + + public static LightExamFragment newInstance() { + LightExamFragment bleScanFragment = new LightExamFragment(); + return bleScanFragment; + } + + private void initListView() { + // listView 鏄剧ず + + lightExamUseAdapter = new LightExamUseAdapter(_mActivity); + lightExamUseAdapter.setOnDeleteListener(new LightExamUseAdapter.OnDeleteListener() { + @Override + public void delete(int position) { + lightDefaultViewModel.deleteItem(lightExamsBeans.get(position)); + } + }); + lightExamSelectAdapter = new LightExamSelectAdapter(_mActivity); + + + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(_mActivity); + LinearLayoutManager linearLayoutManager_use = new LinearLayoutManager(_mActivity); + recyclerView_use.setLayoutManager(linearLayoutManager_use); + recyclerView_select.setLayoutManager(linearLayoutManager); + + lightExamSelectAdapter.setOnCheckedListener(new LightExamSelectAdapter.OnCheckedListener() { + @Override + public void checked(int position, int whichAnswer) { + Log.i(TAG, "閫変腑鐨刾osition=" + position + " whick answer=" + whichAnswer); + Question2Answers question2Answer = answersList.get(position); + int questionId = question2Answer.getQuestion_id(); + List<AnswerStatus> answerStatusList = question2Answer.getAnswerStatusList(); + AnswerStatus answerStatus = answerStatusList.get(whichAnswer); + String answ = answerStatus.getAnswer(); + Log.i(TAG, String.format("闂[%s]閫変腑鐨勭瓟妗�=%s", question2Answer.getQuestion(), answ)); + lightDefaultViewModel.updateQuestion2Answer(questionId, answ); + + lightAnswersViewModel.updateAnswerChoose(answerStatus.getId(), 1); + for (int i = 0; i < answerStatusList.size(); i++) { + if (i != whichAnswer) { + int id = answerStatusList.get(i).getId(); + lightAnswersViewModel.updateAnswerChoose(id, 0); + } + } + } + }); + lightExamSelectAdapter.setOnAddItemListener(new LightExamSelectAdapter.OnAddItemListener() { + @Override + public void add(int pos) { + boolean flag = false; + for (int i = 0; i < lightExamsBeans.size(); i++) { + LightUseQuestions li =lightExamsBeans.get(i); + if (li!=null && li.getId()==pos){ + flag =true; + break; + } + } + if (flag){ + Toast.makeText(_mActivity, "宸茬粡娣诲姞锛屾棤闇�鍐嶆娣诲姞", Toast.LENGTH_SHORT).show(); + }else{ + List<AnswerStatus> answerList = answersList.get(pos).getAnswerStatusList(); + String answer=""; + for (int j = 0; j < answerList.size(); j++) { + AnswerStatus an = answerList.get(j); + LightAnswers lightAnswers = lightAnswerList.get(an.getId()); + if ( lightAnswers .getChoose()==1){ + answer = lightAnswers.getAnswer(); + break; + } + } + + lightDefaultViewModel.addItem(pos,answersList.get(pos).getQuestion(),0,answer); + } + + } + }); + recyclerView_select.setAdapter(lightExamSelectAdapter); + recyclerView_use.setAdapter(lightExamUseAdapter); + recyclerView_select.addItemDecoration(new MyDecoration(_mActivity, MyDecoration.VERTICAL_LIST)); + recyclerView_use.addItemDecoration(new MyDecoration(_mActivity, MyDecoration.VERTICAL_LIST)); + + + } + + /** + * 鍒濆鍖栧垪琛� + */ + private void initView(View view) { + mToolbar = (Toolbar) view.findViewById(R.id.toolbar); + mToolbar.setTitle("鐏厜鑰冭瘯棰樼洰"); + recyclerView_select = view.findViewById(R.id.recyclerview_select); + recyclerView_use = view.findViewById(R.id.recyclerview_useexams); + view.findViewById(R.id.btn_light_cancle).setOnClickListener(this); + view.findViewById(R.id.btn_light_sure).setOnClickListener(this); + view.findViewById(R.id.btn_light_default).setOnClickListener(this); + initListView(); + LightDefaultVMFactory lightDefaultVMFactory = InjectUtils.INSTANCE.provideLightDefaultViewModelFactory(requireContext()); + LightAllAnswerVMFactory lightAllAnswerVMFactory = InjectUtils.INSTANCE.provideLightAllAnswerViewModelFactory(requireContext()); + lightDefaultViewModel = ViewModelProviders.of(this, lightDefaultVMFactory).get(LightDefaultViewModel.class); + lightAnswersViewModel = ViewModelProviders.of(this, lightAllAnswerVMFactory).get(LightAnswersViewModel.class); + lightAnswersViewModel.getAllAnswers().observe(this, new Observer<List<LightAnswers>>() { + @Override + public void onChanged(List<LightAnswers> lightAnswers) { + lightAnswerList.clear(); + lightAnswerList.addAll(lightAnswers); + } + }); + CThreadPoolExecutor.runInBackground(new Runnable() { + @Override + public void run() { + List<LightQuestion> lightQuestions = WorkRoomDataBase.getWorkRoomDataBase(_mActivity).getLightAllQuestionsDao().getAllLightQuestions(); + LightAllAnswerDao lightAllAnswerDao = WorkRoomDataBase.getWorkRoomDataBase(_mActivity).getLightAllAnswersDao(); + for (int i = 0; i < lightQuestions.size(); i++) { + LightQuestion lightQuestion = lightQuestions.get(i); + int question_id = lightQuestion.getId(); + String question = lightQuestion.getQuestion(); + Question2Answers question2Answers = new Question2Answers(); + question2Answers.setQuestion_id(question_id); + question2Answers.setQuestion(question); + + List<LightAnswers> lightAnswers = lightAllAnswerDao.getCurrQuest2Answers(question_id); + + List<AnswerStatus> answerStatusList = new ArrayList<>(); + + for (int j = 0; j < lightAnswers.size(); j++) { + AnswerStatus answerStatus = new AnswerStatus(); + LightAnswers lightAnswers1 = lightAnswers.get(j); + String str = lightAnswers1.getAnswer(); + answerStatus.setAnswer(str); + answerStatus.setChoose_flag(lightAnswers1.getChoose()); + answerStatus.setId(lightAnswers1.getId()); + answerStatusList.add(answerStatus); + } + question2Answers.setAnswerStatusList(answerStatusList); + answersList.add(question2Answers); + + } + CThreadPoolExecutor.runOnMainThread(new Runnable() { + @Override + public void run() { + lightExamSelectAdapter.setDatas(answersList); + } + }); + } + }); + + lightDefaultViewModel.getAllDefaultQuestion2Answers().observe(this, new Observer<List<LightUseQuestions>>() { + @Override + public void onChanged(List<LightUseQuestions> lightUseQuestions) { + lightExamsBeans.clear(); + lightExamsBeans.addAll(lightUseQuestions); + lightExamUseAdapter.setDatas(lightExamsBeans); + } + }); + + + if (HomeFragment.class.getSimpleName().equals(getTopFragment().getClass().getSimpleName())) { + ((MainActivity) _mActivity).viewtitle.setVisibility(View.VISIBLE); + ((MainActivity) _mActivity).btn_return.setVisibility(View.VISIBLE); + + } else { + ((MainActivity) _mActivity).viewtitle.setVisibility(View.GONE); + ((MainActivity) _mActivity).btn_return.setVisibility(View.GONE); + } + initToolbarNav(mToolbar); + + + } + + protected void initToolbarNav(Toolbar toolbar) { + toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + pop(); + } + }); + } + + @Override + public void onDetach() { + super.onDetach(); + ((MainActivity) _mActivity).viewtitle.setVisibility(View.VISIBLE); + ((MainActivity) _mActivity).btn_return.setVisibility(View.VISIBLE); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_light_exam_list, container, false); + initView(view); + return view; + } + + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.btn_light_cancle: + pop(); + break; + case R.id.btn_light_default: + OneTimeWorkRequest oneTimeWorkRequest = OneTimeWorkRequest.from(LightUseInitWorker.class); + WorkManager.getInstance(_mActivity).enqueue(oneTimeWorkRequest); + break; + case R.id.btn_sure: + break; + } + } + + @Override + public void onResume() { + super.onResume(); + Log.i(TAG, "onResume"); + + } + + @Override + public void onStop() { + super.onStop(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/SysExamSettingFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/SysExamSettingFragment.java index c3f15ea..11fab49 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/SysExamSettingFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/SysExamSettingFragment.java @@ -73,6 +73,13 @@ } break; + case 2: + Toast.makeText(_mActivity, "鐏厜棰樼洰璁剧疆", Toast.LENGTH_SHORT).show(); + if (getParentFragment() instanceof BaseSettingFragment){ + ((BaseSettingFragment)getParentFragment()).start( LightExamFragment.newInstance()); + } + + break; } } diff --git a/app/src/main/res/drawable/aliyun_svideo_icon_upload_success.png b/app/src/main/res/drawable/aliyun_svideo_icon_upload_success.png new file mode 100644 index 0000000..fbfa69b --- /dev/null +++ b/app/src/main/res/drawable/aliyun_svideo_icon_upload_success.png Binary files differ diff --git a/app/src/main/res/drawable/divider.xml b/app/src/main/res/drawable/divider.xml new file mode 100644 index 0000000..0e326ce --- /dev/null +++ b/app/src/main/res/drawable/divider.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <solid android:color="#FF4081"/> + <size android:height="1dp"/> +</shape> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml new file mode 100644 index 0000000..287004a --- /dev/null +++ b/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,4 @@ +<vector android:height="60dp" android:viewportHeight="1024" + android:viewportWidth="1024" android:width="60dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#81C1ED" android:pathData="M512,65C265.1,65 65,265.1 65,512s200.1,447 447,447 447,-200.1 447,-447S758.9,65 512,65zM778.3,498c0,17.6 -14.4,32 -32,32L558,530v188.3c0,17.6 -14.4,32 -32,32s-32,-14.4 -32,-32L494,530L305.7,530c-17.6,0 -32,-14.4 -32,-32s14.4,-32 32,-32L494,466L494,277.7c0,-17.6 14.4,-32 32,-32s32,14.4 32,32L558,466h188.3c17.6,0 32,14.4 32,32z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_add_disable.xml b/app/src/main/res/drawable/ic_add_disable.xml new file mode 100644 index 0000000..a52e0a4 --- /dev/null +++ b/app/src/main/res/drawable/ic_add_disable.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="200dp" + android:height="200dp" + android:viewportWidth="1024" + android:viewportHeight="1024"> + <path + android:pathData="M512,65C265.1,65 65,265.1 65,512s200.1,447 447,447 447,-200.1 447,-447S758.9,65 512,65zM778.3,498c0,17.6 -14.4,32 -32,32L558,530v188.3c0,17.6 -14.4,32 -32,32s-32,-14.4 -32,-32L494,530L305.7,530c-17.6,0 -32,-14.4 -32,-32s14.4,-32 32,-32L494,466L494,277.7c0,-17.6 14.4,-32 32,-32s32,14.4 32,32L558,466h188.3c17.6,0 32,14.4 32,32z" + android:fillColor="#cdcdcd"/> +</vector> diff --git a/app/src/main/res/drawable/ic_add_selector.xml b/app/src/main/res/drawable/ic_add_selector.xml new file mode 100644 index 0000000..c99d2c6 --- /dev/null +++ b/app/src/main/res/drawable/ic_add_selector.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> +<item android:state_enabled="true" android:state_pressed="true" android:drawable="@drawable/ic_add"/> +<item android:state_enabled="false" android:state_pressed="false" android:drawable="@drawable/ic_add_disable"/> +</selector> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_select_no.xml b/app/src/main/res/drawable/ic_select_no.xml new file mode 100644 index 0000000..d387ca3 --- /dev/null +++ b/app/src/main/res/drawable/ic_select_no.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="60dp" + android:height="60dp" + android:viewportWidth="1024" + android:viewportHeight="1024"> + <path + android:pathData="M512,96C283.2,96 96,283.2 96,512s187.2,416 416,416 416,-187.2 416,-416S740.8,96 512,96zM512,844.8c-183.04,0 -332.8,-149.76 -332.8,-332.8S328.96,179.2 512,179.2 844.8,328.96 844.8,512 695.04,844.8 512,844.8z" + android:fillColor="#1296db"/> +</vector> diff --git a/app/src/main/res/drawable/ic_select_yes.xml b/app/src/main/res/drawable/ic_select_yes.xml new file mode 100644 index 0000000..a46bae6 --- /dev/null +++ b/app/src/main/res/drawable/ic_select_yes.xml @@ -0,0 +1,12 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="60dp" + android:height="60dp" + android:viewportWidth="1024" + android:viewportHeight="1024"> + <path + android:pathData="M512,152c96.2,0 186.6,37.4 254.6,105.4S872,415.8 872,512s-37.4,186.6 -105.4,254.6S608.2,872 512,872c-96.2,0 -186.6,-37.4 -254.6,-105.4S152,608.2 152,512s37.4,-186.6 105.4,-254.6S415.8,152 512,152m0,-56C282.2,96 96,282.2 96,512s186.2,416 416,416 416,-186.2 416,-416S741.8,96 512,96z" + android:fillColor="#1296db"/> + <path + android:pathData="M727,297C669.6,239.6 593.2,208 512,208c-81.2,0 -157.6,31.6 -215,89C239.6,354.4 208,430.8 208,512s31.6,157.6 89,215C354.4,784.4 430.8,816 512,816c81.2,0 157.6,-31.6 215,-89C784.4,669.6 816,593.2 816,512s-31.6,-157.6 -89,-215z" + android:fillColor="#1296db"/> +</vector> diff --git a/app/src/main/res/drawable/radiobutton_selector.xml b/app/src/main/res/drawable/radiobutton_selector.xml new file mode 100644 index 0000000..b3587d0 --- /dev/null +++ b/app/src/main/res/drawable/radiobutton_selector.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> +<item android:state_checked="true" android:drawable="@drawable/ic_select_yes" android:state_enabled="true"/> +<item android:state_checked="false" android:drawable="@drawable/ic_select_no" android:state_enabled="false"/> +</selector> \ No newline at end of file diff --git a/app/src/main/res/drawable/umeng_socialize_delete.png b/app/src/main/res/drawable/umeng_socialize_delete.png new file mode 100644 index 0000000..0abe441 --- /dev/null +++ b/app/src/main/res/drawable/umeng_socialize_delete.png Binary files differ diff --git a/app/src/main/res/layout/fragment_light_exam_list.xml b/app/src/main/res/layout/fragment_light_exam_list.xml new file mode 100644 index 0000000..d1c0f37 --- /dev/null +++ b/app/src/main/res/layout/fragment_light_exam_list.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8"?> + + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <include layout="@layout/toolbar"/> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/ic_bground" + android:orientation="horizontal" + > + + <LinearLayout + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:paddingLeft="@dimen/ui_margin_10dp" + android:orientation="vertical" + > + +<TextView + android:layout_width="match_parent" + android:layout_height="@dimen/ui_margin_50dp" + android:textColor="@android:color/white" + android:textSize="28sp" + android:text="鐩墠浣跨敤鐨勯鐩�"/> +<androidx.recyclerview.widget.RecyclerView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:id="@+id/recyclerview_useexams"/> + <LinearLayout + android:layout_width="match_parent" + android:gravity="center_vertical" + android:layout_height="@dimen/ui_margin_60dp" + android:orientation="horizontal"> + <Button + android:layout_width="0dp" + android:layout_height="@dimen/ui_margin_50dp" + android:text="鍙栨秷" + android:id="@+id/btn_light_cancle" + android:layout_weight="1"/> + <Button + android:layout_width="0dp" + android:layout_height="@dimen/ui_margin_50dp" + android:text="鎭㈠榛樿" + android:id="@+id/btn_light_default" + android:layout_weight="1"/> + <Button + android:layout_width="0dp" + android:layout_height="@dimen/ui_margin_50dp" + android:id="@+id/btn_light_sure" + android:text="纭" + android:layout_weight="1"/> + </LinearLayout> + </LinearLayout> + <LinearLayout + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:paddingRight="@dimen/ui_margin_10dp" + android:paddingLeft="@dimen/ui_margin_10dp" + android:orientation="vertical" + > + + <TextView + android:layout_width="match_parent" + android:layout_height="@dimen/ui_margin_50dp" + android:textColor="@android:color/white" + android:textSize="28sp" + android:text="鍙互鏇存崲鐨勯鐩�"/> + <androidx.recyclerview.widget.RecyclerView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/recyclerview_select"/> + + </LinearLayout> + +</LinearLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/light_exam_select_item.xml b/app/src/main/res/layout/light_exam_select_item.xml new file mode 100644 index 0000000..efdbbdc --- /dev/null +++ b/app/src/main/res/layout/light_exam_select_item.xml @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" + android:layout_height="wrap_content" + + android:padding="@dimen/ui_margin_10dp"> + <TextView + android:layout_width="wrap_content" + android:layout_height="@dimen/ui_margin_50dp" + android:textSize="25sp" + android:layout_marginLeft="@dimen/ui_margin_60dp" + android:gravity="center_vertical" + android:textColor="@android:color/white" + android:drawablePadding="@dimen/ui_margin_10dp" + android:drawableLeft="@drawable/aliyun_svideo_icon_upload_success" + android:text="璇峰紑璧峰墠鐓х伅" + android:id="@+id/tv_question"/> + + <RadioGroup + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@+id/tv_question" + android:layout_marginLeft="@dimen/ui_margin_60dp" + android:layout_marginTop="@dimen/ui_margin_10dp" + android:orientation="vertical"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tv_answer1" + android:layout_width="wrap_content" + android:layout_height="@dimen/ui_margin_40dp" + + android:layout_weight="1" + android:text="@string/answer" + android:textColor="@android:color/white" + android:textSize="20sp" /> + + <RadioButton + android:layout_width="@dimen/ui_margin_60dp" + android:layout_height="@dimen/ui_margin_60dp" + android:id="@+id/rb1_light" + android:background="@null" + android:button="@drawable/radiobutton_selector" + android:textSize="22sp" /> + </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" + android:layout_marginTop="@dimen/ui_margin_10dp" + android:id="@+id/ll_light_container2" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tv_answer2" + android:layout_width="wrap_content" + android:layout_height="@dimen/ui_margin_40dp" + + android:layout_weight="1" + android:text="@string/answer" + android:textColor="@android:color/white" + android:textSize="20sp" /> + + <RadioButton + android:layout_width="@dimen/ui_margin_60dp" + android:layout_height="@dimen/ui_margin_60dp" + android:id="@+id/rb2_light" + android:background="@null" + android:button="@drawable/radiobutton_selector" + android:textSize="22sp" /> + </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/ui_margin_10dp" + android:visibility="gone" + android:id="@+id/ll_light_container3" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tv_answer3" + android:layout_width="wrap_content" + android:layout_height="@dimen/ui_margin_40dp" + + android:layout_weight="1" + android:text="@string/answer" + android:textColor="@android:color/white" + android:textSize="20sp" /> + + <RadioButton + android:layout_width="@dimen/ui_margin_60dp" + android:layout_height="@dimen/ui_margin_60dp" + android:id="@+id/rb3_light" + android:background="@null" + android:button="@drawable/radiobutton_selector" + android:textSize="22sp" /> + </LinearLayout> + + </RadioGroup> + + + <ImageView + android:layout_width="@dimen/ui_margin_50dp" + android:layout_height="@dimen/ui_margin_50dp" + android:src="@drawable/ic_add_selector" + android:layout_alignParentStart="true" + android:id="@+id/iv_delete_item" + android:layout_centerVertical="true"/> +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/light_exam_use_item.xml b/app/src/main/res/layout/light_exam_use_item.xml new file mode 100644 index 0000000..b3819de --- /dev/null +++ b/app/src/main/res/layout/light_exam_use_item.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" + android:layout_height="110dp" + android:padding="@dimen/ui_margin_10dp"> +<TextView + android:layout_width="wrap_content" + android:layout_height="@dimen/ui_margin_50dp" + android:textSize="25sp" + android:gravity="center_vertical" + android:textColor="@android:color/white" + android:drawablePadding="@dimen/ui_margin_10dp" + android:drawableLeft="@drawable/aliyun_svideo_icon_upload_success" + android:text="璇峰紑璧峰墠鐓х伅" + android:id="@+id/tv_question"/> + <TextView + android:layout_width="wrap_content" + android:textSize="20sp" + android:id="@+id/tv_answer" + android:layout_marginTop="@dimen/ui_margin_10dp" + android:layout_below="@+id/tv_question" + android:textColor="@android:color/white" + android:layout_height="@dimen/ui_margin_40dp" + android:text="@string/answer"/> + + <ImageView + android:layout_width="@dimen/ui_margin_50dp" + android:layout_height="@dimen/ui_margin_50dp" + android:src="@drawable/umeng_socialize_delete" + android:layout_alignParentEnd="true" + android:id="@+id/iv_delete_item" + android:layout_centerVertical="true"/> +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ef41d1b..7ab4ec8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -74,9 +74,9 @@ </string-array> <string-array name="array_large_item_menu"> -<!-- <item>鐏厜璁剧疆</item>--> <item>瑙勫垯璁剧疆</item> <item>钃濈墮鎵弿</item> + <item>鐏厜闅忔満棰樼洰</item> <!-- <item>鎸囦护璁剧疆</item> <item>绯荤粺璁剧疆</item> <item>鏁欏绯荤粺璁剧疆</item> @@ -101,5 +101,6 @@ <string name="auto_act_to_select">璇烽�夋嫨闇�瑕佽繛鎺ョ殑钃濈墮璁惧</string> <string name="auto_act_to_refresh">璇峰皾璇曚笅鎷夊埛鏂�,杩涜鎵弿鍛ㄥ洿钃濈墮璁惧</string> + <string name="answer">绛旀锛�%1$s</string> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2c137f2..8321838 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -11,6 +11,8 @@ <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> + <item name="android:listDivider">@drawable/divider</item> + </style> <style name="AppTheme.NoActionBar.AppBarOverlay" -- Gitblit v1.8.0