lmw
1 天以前 967492f43278adf716cb3cb39d209ad9ae59590f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.dollearn.student.ui.home
 
import androidx.core.os.bundleOf
import cn.sinata.xldutils.fragment.BaseFragment
import com.dollearn.student.R
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 kotlinx.android.synthetic.main.fragment_weekend.*
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.support.v4.startActivity
 
class WeekendFragment : BaseFragment() {
    override fun contentViewId() = R.layout.fragment_weekend
 
    private val day by lazy {
        arguments?.getInt("day")?:0
    }
    private val week by lazy {
        (requireActivity() as ScheduleActivity).week
    }
    private val season by lazy {
        (requireActivity() as ScheduleActivity).season
    }
 
    override fun onFirstVisibleToUser() {
        if (day == 7){
            tv_name_1.text = "自主故事1—看图配音"
            tv_name_2.text = "自主故事2—框架记忆"
            cl_1.setOnClickListener {
                showDialog("加载题目...")
                HttpManager.lookPictureDbu(season, week).requestByF(this){_,data->
                    startActivity<LookImgActivity>("data" to data,"week" to week,"season" to season)
                    EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
                }
            }
            cl_2.setOnClickListener {
                showDialog("加载题目...")
                HttpManager.frameworkMemory(season, week).requestByF(this){_,data->
                    startActivity<ListenStoryActivity>("data" to data,"week" to week,"season" to season)
                    EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
 
                }
            }
        }
        if (day == 6){
            cl_1.setOnClickListener {
                HttpManager.userGameDifficulty(week).requestByF(this){_,data->
                    startActivity<SuperListenActivity>("week" to week,"season" to season,"level" to (data?:0))
                    EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
                }
            }
            cl_2.setOnClickListener {
                showDialog("加载题目...")
                HttpManager.gameMemory(season, week).requestByF(this){_,data->
                    startActivity<MemoryActivity>("data" to data,"week" to week,"season" to season)
                    EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_TIMER))
 
                }
            }
        }
    }
 
    companion object{
        fun newInstance(day:Int):WeekendFragment{
            val dailyFragment = WeekendFragment()
            dailyFragment.arguments = bundleOf("day" to day)
            return dailyFragment
        }
    }
}