lmw
2024-06-18 1f45a54dc8e149548d3a61d1228741627aa4f23e
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
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.dollearn.student.ui.home
 
import android.content.Context
import cn.sinata.xldutils.gone
import cn.sinata.xldutils.visible
import com.dollearn.student.MainActivity
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.IntEvent
import com.dollearn.student.utils.extention.clickDelay
import kotlinx.android.synthetic.main.activity_result.*
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
 
class ResultActivity:TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_result
 
    private val id by lazy { intent.getStringExtra("id") }
    private val type by lazy { intent.getIntExtra("type",0) }
    private val day by lazy { intent.getIntExtra("day",0) }
    private val week by lazy { intent.getIntExtra("week",0) }
    private val season by lazy { intent.getIntExtra("season",0) }
 
    private val total by lazy { intent.getIntExtra("total",0) }
    private val right by lazy { intent.getIntExtra("right",0) }
    private val score by lazy { intent.getIntExtra("score",0) }
    private val time by lazy { intent.getIntExtra("time",0) }
 
    private val difficulty by lazy { intent.getIntExtra("difficulty",0) } //游戏难度
 
    override fun initClick() {
        tv_last.setOnClickListener {
            startActivity<MainActivity>()
        }
 
        tv_back.setOnClickListener {
            startActivity<MainActivity>()
        }
 
        tv_exit.clickDelay {
            EventBus.getDefault().post(IntEvent(Const.EventCode.NEXT_SUBJECT,type+1))
            finish()
        }
    }
 
    override fun initView() {
        tv_score.text = "恭喜你,已完成全部答题!获得${score}积分!"
        tv_count.text = "${total}次"
        tv_right.text = "${right}次"
        tv_fault.text = "${total-right}次"
        val rate = (right * 100) / total
        tv_rate.text = "正确率:$rate%"
        when(type){
            6->{
                title = "超级听力"
                tv_back.visible()
                tv_last.gone()
                tv_exit.gone()
                HttpManager.gameAchievement(rate,difficulty,id?:"","超级听力",time).request(this){_,data->
                }
            }
            8->{
                tv_back.visible()
                tv_last.gone()
                tv_exit.gone()
                HttpManager.completeStory(rate,type,id?:"").request(this){_,data->
                }
            }
            else->{
                HttpManager.completeLearning(rate,time,day,week,season,type,id?:"").request(this){_,data->
                }
            }
        }
    }
 
    companion object{
        fun startResult(context:Context,day:Int,week:Int,season:Int,type:Int,total:Int,right:Int,score:Int,time:Int,id:String,difficulty:Int? = null){
            context.startActivity<ResultActivity>("day" to day,"week" to week,"season" to season,"type" to type,"total" to total,"right" to right,"score" to score,
                "time" to time,"id" to id,"difficulty" to difficulty)
        }
    }
}