LearnCompletedDialog.kt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.dlc.exam.ui.learn
  2. import android.annotation.SuppressLint
  3. import android.app.Dialog
  4. import android.content.Context
  5. import android.os.Bundle
  6. import android.view.LayoutInflater
  7. import android.view.View
  8. import com.dlc.exam.R
  9. import com.dlc.exam.databinding.DialogLearnCompletedBinding
  10. import com.rc.httpcore.vo.response.LearnBonusBean
  11. /**
  12. * 学习完成Dialog
  13. *
  14. * @author ReiChin_
  15. */
  16. class LearnCompletedDialog(
  17. context: Context,
  18. private val data: LearnBonusBean,
  19. private val endChapter: Boolean,
  20. private val assessStatus: Boolean,
  21. val listener: () -> Unit
  22. ) :
  23. Dialog(context, R.style.AlertDialogStyle) {
  24. private val viewBinding: DialogLearnCompletedBinding by lazy {
  25. DialogLearnCompletedBinding.inflate(LayoutInflater.from(context))
  26. }
  27. @SuppressLint("SetTextI18n")
  28. override fun onCreate(savedInstanceState: Bundle?) {
  29. super.onCreate(savedInstanceState)
  30. setContentView(viewBinding.root)
  31. viewBinding.close.setOnClickListener {
  32. dismiss()
  33. listener.invoke()
  34. }
  35. viewBinding.learnBonusScore.text =
  36. "已学习时长${data.durationStr ?: "0"},共获得${data.points ?: "0"}奖励分"
  37. // if (endChapter) {
  38. // viewBinding.title.text = "您已学习完最后一章节"
  39. // } else {
  40. // viewBinding.title.text = "您已学习完该章节"
  41. // }
  42. if (assessStatus) {
  43. // 需要课后考核
  44. viewBinding.nextChapter.text = "课后考核"
  45. viewBinding.nextChapter.visibility = View.VISIBLE
  46. } else {
  47. viewBinding.nextChapter.text = "学习下一章节"
  48. viewBinding.nextChapter.visibility = if (endChapter) View.GONE else View.VISIBLE
  49. }
  50. viewBinding.nextChapter.setOnClickListener {
  51. // 学习下一章节/课后考核
  52. dismiss()
  53. listener.invoke()
  54. }
  55. }
  56. }