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 "答题时间已结束,停止作答!")
|
}
|
|
}
|
}
|
|
}
|