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
package com.dollearn.student.ui.home
 
import android.os.CountDownTimer
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.GridLayoutManager
import com.dollearn.student.R
import com.dollearn.student.dialog.TipDialog
import com.dollearn.student.network.entity.Card
import com.dollearn.student.network.entity.MemoryBean
import com.dollearn.student.ui.TransparentStatusBarActivity
import com.dollearn.student.ui.home.adapter.CardAdapter
import kotlinx.android.synthetic.main.activity_memory.*
 
class MemoryActivity : TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_memory
 
    private val data by lazy {
        intent.getParcelableExtra<MemoryBean>("data")!!
    }
    private val list = arrayListOf<Card>()
    private val adapter = CardAdapter(list)
    private val TIME = 600*1000L
    private var timer:CountDownTimer? = null
 
    override fun initClick() {
 
    }
 
    override fun initView() {
        rv_list.layoutManager = GridLayoutManager(this,5)
        rv_list.adapter = adapter
        list.addAll(data.photoList.map { Card(it.id,1,it.photo) })
        list.addAll(data.voiceList.map { Card(it.id,2,it.voice) })
        list.shuffle()
        adapter.notifyDataSetChanged()
 
        timer = object :CountDownTimer(TIME,1000){
            override fun onTick(millisUntilFinished: Long) {
 
            }
 
            override fun onFinish() {
                val tipDialog = TipDialog()
                tipDialog.arguments = bundleOf("msg" to "答题时间已结束,停止作答!")
            }
 
        }
    }
 
}