From c42258b3bdc3527b74e05bbd917ceaa458cc205a Mon Sep 17 00:00:00 2001
From: lmw <125975490@qq.com>
Date: 星期五, 08 八月 2025 11:25:48 +0800
Subject: [PATCH] save

---
 app/src/main/java/com/dollearn/student/ui/home/ScheduleActivityNew.kt |  206 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 179 insertions(+), 27 deletions(-)

diff --git a/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivityNew.kt b/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivityNew.kt
index 9795042..e3e23ed 100644
--- a/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivityNew.kt
+++ b/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivityNew.kt
@@ -1,73 +1,225 @@
 package com.dollearn.student.ui.home
 
-import androidx.fragment.app.Fragment
+import android.widget.TextView
+import androidx.core.os.bundleOf
+import cn.sinata.xldutils.utils.myToast
+import cn.sinata.xldutils.utils.showAllowingStateLoss
 import com.dollearn.student.R
+import com.dollearn.student.dialog.GameTypeDialog
+import com.dollearn.student.dialog.TipDialog
+import com.dollearn.student.network.Apis
 import com.dollearn.student.network.HttpManager
 import com.dollearn.student.network.request
 import com.dollearn.student.ui.TransparentStatusBarActivity
 import com.dollearn.student.utils.Const
+import com.dollearn.student.utils.event.EmptyEvent
 import com.dollearn.student.utils.event.IntEvent
-import kotlinx.android.synthetic.main.activity_schedul.*
+import com.dollearn.student.utils.extention.clickDelay
+import kotlinx.android.synthetic.main.activity_schedul_new.*
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
+import org.jetbrains.anko.backgroundResource
+import org.jetbrains.anko.browse
+import org.jetbrains.anko.startActivity
+import org.jetbrains.anko.startActivityForResult
 
 class ScheduleActivityNew :TransparentStatusBarActivity(){
     override fun setContentView() = R.layout.activity_schedul_new
 
-    private val titles = arrayOf("Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "自主游戏", "听故事")
-    private val frags = arrayListOf<Fragment>()
-
     val week by lazy { intent.getIntExtra("week",0) }
     val season by lazy { intent.getIntExtra("season",0) }
 
-    var currentDay = 1
+    val dailyViews by lazy { arrayListOf(cl_1,cl_2,cl_3,cl_4,cl_5,cl_6,cl_7) }
 
     override fun initClick() {
+        cl_1.clickDelay {
+            showDialog("加载题目...")
+            HttpManager.listenSelectPicture(season, week, 1).request(this,false, {_,data->
+                startActivityForResult<ListenActivity>(1,"data" to data,"day" to 1,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+            }){_,msg->
+                handleError(msg)
+            }
+        }
+        cl_2.clickDelay {
+            showDialog("加载题目...")
+            HttpManager.pictureSelectVoice(season, week, 2).request(this,false, {_,data->
+                startActivityForResult<ChooseVoiceActivity>(1,"data" to data,"day" to 2,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
+            }){_,msg->
+                handleError(msg)
+            }
+        }
+        cl_3.clickDelay {
+            showDialog("加载题目...")
+            HttpManager.induceExclude(season, week, 3).request(this,false, {_,data->
+                startActivityForResult<IncludeActivity>(1,"data" to data,"day" to 3,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
+            }){_,msg->
+                handleError(msg)
+            }
+        }
+        cl_4.clickDelay {
+            showDialog("加载题目...")
+            HttpManager.questionsAndAnswers(season, week, 4).request(this,false, {_,data->
+                startActivityForResult<QAActivity>(1,"data" to data,"day" to 4,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
+            }){_,msg->
+                handleError(msg)
+            }
+        }
+        cl_5.clickDelay {
+            showDialog("加载题目...")
+            HttpManager.pictureMateVoice(season, week, 5).request(this,false,{_,data->
+                startActivityForResult<MatchActivity>(1,"data" to data,"day" to 5,"week" to week,"season" to season)
+                EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
+            }){_,msg->
+                handleError(msg)
+            }
+        }
+        cl_6.clickDelay {
+            val gameTypeDialog = GameTypeDialog()
+            gameTypeDialog.setCallback(object :GameTypeDialog.OnClickCallback{
+                override fun onOk(d: Int) {
+                    if (d == 1){
+                        HttpManager.userGameDifficulty(week).request(this@ScheduleActivityNew){_,data->
+                            startActivity<SuperListenActivity>("week" to week,"season" to season,"level" to (data?:0))
+                            EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+                        }
+                    }else{
+                        showDialog("加载题目...")
+                        HttpManager.gameMemory(season, week).request(this@ScheduleActivityNew){_,data->
+                            startActivity<MemoryActivity>("data" to data,"week" to week,"season" to season)
+                            EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
+                        }
+                    }
+                }
+            })
+            gameTypeDialog.show(supportFragmentManager,"game")
+        }
+        cl_7.clickDelay {
+            val gameTypeDialog = GameTypeDialog()
+            gameTypeDialog.arguments = bundleOf("isStory" to true)
+            gameTypeDialog.setCallback(object :GameTypeDialog.OnClickCallback{
+                override fun onOk(d: Int) {
+                    if (d == 1){
+                        showDialog("加载题目...")
+                        HttpManager.lookPictureDbu(season, week).request(this@ScheduleActivityNew){_,data->
+                            startActivity<LookImgActivity>("data" to data,"week" to week,"season" to season)
+                            EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+                        }
+                    }else{
+                        showDialog("加载题目...")
+                        HttpManager.frameworkMemory(season, week).request(this@ScheduleActivityNew){_,data->
+                            startActivity<ListenStoryActivity>("data" to data,"week" to week,"season" to season)
+                            EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
+
+                        }
+                    }
+                }
+            })
+            gameTypeDialog.show(supportFragmentManager,"game")
+        }
     }
 
     override fun initView() {
         title = ""
-        getSchedule()
         EventBus.getDefault().register(this)
+    }
+
+    override fun onResume() {
+        super.onResume()
+        getSchedule()
     }
 
     private fun getSchedule(){
         HttpManager.studySchedule(week,1).request(this){_,data->
             data?.apply {
-                currentDay = day
                 initTab(if (computeSchedule == 100) 7 else day)
+                tv_current.text = "当前周目:第 ${week} 周"
+                tv_progress.text = "${computeSchedule}%"
+                tv_total.text = "${totalStudy}小时"
+                tv_today.text = "${todayStudy}小时"
+                progress_bar.progress = computeSchedule
+                formatProgress(listen,tv_state)
+                formatProgress(look,tv_state_2)
+                formatProgress(induction,tv_state_3)
+                formatProgress(answer,tv_state_4)
+                formatProgress(pair,tv_state_5)
             }
         }
     }
 
     private fun initTab(day:Int) {
-        titles.forEachIndexed { index, s ->
-            if (index<5){
-                frags.add(DailyFragment.newInstance(index+1))
-            }else
-                frags.add(WeekendFragment.newInstance(index+1))
+        //设置是否可点击
+        dailyViews.forEachIndexed { index, constraintLayout ->
+            if (index in day until 6){
+                dailyViews[index].isEnabled = false
+                dailyViews[index].alpha = 0.5f
+            }else{
+                dailyViews[index].isEnabled = true
+                dailyViews[index].alpha = 1f
+            }
         }
-        tab_bar.setViewPager(view_pager, titles,this,frags)
-        tab_bar.currentTab = currentDay-1
-        view_pager.offscreenPageLimit = day
-        //设置不可点击的day
-        (day until 6).forEach {
-            tab_bar.getTitleView(it).isEnabled = false
-        }
-        if (tab_bar.currentTab == 0)
-            tab_bar.updateTabStyles()
     }
 
-    fun unLockNext(day: Int){
-        currentDay = day
-        tab_bar.getTitleView(day - 1).isEnabled = true
-        tab_bar.currentTab = currentDay-1
+    private fun formatProgress(progress:Int,tv: TextView){
+        tv.text =  when(progress){
+            -1, 0->{
+                tv.backgroundResource = R.drawable.bg_red_9dp
+                "未完成"
+            }
+            100->{
+                tv.backgroundResource = R.drawable.bg_blue_9dp
+                "已完成"
+            }
+            else->{
+                tv.backgroundResource = R.drawable.bg_pink_9dp
+                "剩余:${progress}%"
+            }
+        }
+    }
+
+    private fun handleError(msg:String){
+        if (msg.contains("会员")){
+            val tipDialog = TipDialog()
+            tipDialog.arguments = bundleOf("msg" to msg,"ok" to "成为会员")
+            tipDialog.setCallback(object : TipDialog.OnClickCallback{
+                override fun onOk() {
+                    browse(Apis.SHARE_URL,true)
+                }
+
+                override fun onCancel() {
+                }
+            })
+            tipDialog.showAllowingStateLoss(supportFragmentManager,"vip")
+        }else{
+            myToast(msg)
+        }
     }
 
     @Subscribe
     fun nextSubject(e: IntEvent){
         if (e.code == Const.EventCode.NEXT_SUBJECT){
-            (frags[view_pager.currentItem] as DailyFragment).nextSubject(e.i)
+            when(e.i){
+                2->{
+                    cl_2.callOnClick()
+                }
+                3->{
+                    cl_3.callOnClick()
+                }
+                4->{
+                    cl_4.callOnClick()
+                }
+                5->{
+                    cl_5.callOnClick()
+                }
+            }
         }
     }
 

--
Gitblit v1.7.1