From a036ac0c6c8d87f36e68f88f05231c3be23fcc4b Mon Sep 17 00:00:00 2001 From: lmw <125975490@qq.com> Date: 星期四, 01 八月 2024 13:32:55 +0800 Subject: [PATCH] 修改bug --- app/src/main/java/com/dollearn/student/ui/home/ScheduleActivity.kt | 38 ++++++++++++++++++++------------------ 1 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivity.kt b/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivity.kt index 512e2ea..5923ef4 100644 --- a/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivity.kt +++ b/app/src/main/java/com/dollearn/student/ui/home/ScheduleActivity.kt @@ -1,18 +1,15 @@ package com.dollearn.student.ui.home -import androidx.constraintlayout.widget.ConstraintLayout import androidx.fragment.app.Fragment import com.dollearn.student.R 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 org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe -import org.jetbrains.anko.browse class ScheduleActivity :TransparentStatusBarActivity(){ override fun setContentView() = R.layout.activity_schedul @@ -35,31 +32,36 @@ } private fun getSchedule(){ - initTab(7) //todo test - -// HttpManager.studySchedule(week,1).request(this){_,data-> -// data?.apply { -// initTab(if (computeSchedule == 100) 7 else day) -// currentDay = day -// } -// } + HttpManager.studySchedule(week,1).request(this){_,data-> + data?.apply { + currentDay = day + initTab(if (computeSchedule == 100) 7 else day) + } + } } private fun initTab(day:Int) { - val title = titles.take(day) - title.forEachIndexed { index, s -> + titles.forEachIndexed { index, s -> if (index<5){ frags.add(DailyFragment.newInstance(index+1)) }else frags.add(WeekendFragment.newInstance(index+1)) } - val layoutParams = tab_bar.layoutParams as ConstraintLayout.LayoutParams - val anchors = listOf(R.id.tv_1,R.id.tv_2,R.id.tv_3,R.id.tv_4,R.id.tv_5,R.id.tv_6,R.id.tv_7,R.id.tv_8) - layoutParams.endToStart = anchors[day] - tab_bar.layoutParams = layoutParams - tab_bar.setViewPager(view_pager, title.toTypedArray(),this,frags) + 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 } @Subscribe -- Gitblit v1.7.1