From 442124baa483f8d1c4aaca7ff81e15dd3f122363 Mon Sep 17 00:00:00 2001
From: 罗明文 <125975490@qq.com>
Date: 星期四, 22 五月 2025 13:14:36 +0800
Subject: [PATCH] save

---
 app/src/main/java/com/dollearn/student/ui/home/DailyFragment.kt |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/app/src/main/java/com/dollearn/student/ui/home/DailyFragment.kt b/app/src/main/java/com/dollearn/student/ui/home/DailyFragment.kt
index b305906..7d53594 100644
--- a/app/src/main/java/com/dollearn/student/ui/home/DailyFragment.kt
+++ b/app/src/main/java/com/dollearn/student/ui/home/DailyFragment.kt
@@ -12,8 +12,12 @@
 import com.dollearn.student.network.Apis
 import com.dollearn.student.network.HttpManager
 import com.dollearn.student.network.requestByF
+import com.dollearn.student.utils.Const
+import com.dollearn.student.utils.event.EmptyEvent
 import com.dollearn.student.utils.extention.clickDelay
+import com.dollearn.student.utils.extention.formatToChinese
 import kotlinx.android.synthetic.main.fragment_daily.*
+import org.greenrobot.eventbus.EventBus
 import org.jetbrains.anko.backgroundResource
 import org.jetbrains.anko.support.v4.browse
 import org.jetbrains.anko.support.v4.startActivityForResult
@@ -31,9 +35,7 @@
     private val week by lazy {
         (requireActivity() as ScheduleActivity).week
     }
-    private val current by lazy {
-        (requireActivity() as ScheduleActivity).currentDay
-    }
+
 
     override fun onFirstVisibleToUser() {
         getProgress()
@@ -41,6 +43,7 @@
             showDialog("加载题目...")
             HttpManager.listenSelectPicture(season, week, day).requestByF(this,false, {_,data->
                 startActivityForResult<ListenActivity>(1,"data" to data,"day" to day,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
             }){_,msg->
                 handleError(msg)
             }
@@ -49,6 +52,8 @@
             showDialog("加载题目...")
             HttpManager.pictureSelectVoice(season, week, day).requestByF(this,false, {_,data->
                 startActivityForResult<ChooseVoiceActivity>(1,"data" to data,"day" to day,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
             }){_,msg->
                 handleError(msg)
             }
@@ -57,6 +62,8 @@
             showDialog("加载题目...")
             HttpManager.induceExclude(season, week, day).requestByF(this,false, {_,data->
                 startActivityForResult<IncludeActivity>(1,"data" to data,"day" to day,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
             }){_,msg->
                 handleError(msg)
             }
@@ -65,6 +72,8 @@
             showDialog("加载题目...")
             HttpManager.questionsAndAnswers(season, week, day).requestByF(this,false, {_,data->
                 startActivityForResult<QAActivity>(1,"data" to data,"day" to day,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
             }){_,msg->
                 handleError(msg)
             }
@@ -73,6 +82,8 @@
             showDialog("加载题目...")
             HttpManager.pictureMateVoice(season, week, day).requestByF(this,false,{_,data->
                 startActivityForResult<MatchActivity>(1,"data" to data,"day" to day,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
             }){_,msg->
                 handleError(msg)
             }
@@ -100,13 +111,17 @@
     private fun getProgress(){
         HttpManager.studySchedule(week,day).requestByF(this){ _, data->
             data?.apply {
-                tv_current.text = "当前周目:${week}周目"
+                val scheduleActivity = activity as ScheduleActivity
+                if (day != scheduleActivity.currentDay){ //解锁了后一天
+                    scheduleActivity.unLockNext(day)
+                }
+                tv_current.text = "当前周目:${week.formatToChinese()}周目"
                 tv_progress.text = "${computeSchedule}%"
                 tv_total.text = "${totalStudy}小时"
                 tv_today.text = "${todayStudy}小时"
                 progress_bar.progress = computeSchedule
 
-                if (this@DailyFragment.day == current){
+                if (this@DailyFragment.day == scheduleActivity.currentDay){
                     formatProgress(listen,tv_state)
                     formatProgress(look,tv_state_2)
                     formatProgress(induction,tv_state_3)
@@ -167,7 +182,6 @@
 
     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
-        if (resultCode == Activity.RESULT_OK)
-            getProgress()
+        getProgress()
     }
 }

--
Gitblit v1.7.1