Advertisement
AzisMM

DasboardActivity.kt

Oct 6th, 2021
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 2.21 KB | None | 0 0
  1. class DashboardActivity : AppCompatActivity() {
  2.     private lateinit var binding: ActivityDashboardBinding
  3.  
  4.     override fun onCreate(savedInstanceState: Bundle?) {
  5.         super.onCreate(savedInstanceState)
  6.         binding = ActivityDashboardBinding.inflate(layoutInflater)
  7.         val view = binding.root
  8.         setContentView(view)
  9.  
  10.         initNavMenu()
  11.         initHeader()
  12.         initRecycleViewInspiration()
  13.     }
  14.  
  15.     private fun initNavMenu() {
  16.         binding.ivIconMenuDoa.setOnClickListener {
  17.             startActivity(Intent(this, MenuDoaActivity::class.java))
  18.         }
  19.         binding.ivIconMenuDzikir.setOnClickListener {
  20.             startActivity(Intent(this, MenuDzikirActivity::class.java))
  21.         }
  22.         binding.ivIconMenuJadwalSholat.setOnClickListener {
  23.             startActivity(Intent(this, MenuJadwalSholatActivity::class.java))
  24.         }
  25.         binding.ivIconMenuZakat.setOnClickListener {
  26.             startActivity(Intent(this, MenuZakatActivity::class.java))
  27.         }
  28.         binding.ivIconMenuVideoKajian.setOnClickListener {
  29.             startActivity(Intent(this, MenuVideoKajianActivity::class.java))
  30.         }
  31.     }
  32.  
  33.     private fun initHeader() {
  34.         val timeNow = Calendar.getInstance().time
  35.         val timeFormat = SimpleDateFormat("HH")
  36.         val time = timeFormat.format(timeNow)
  37.  
  38.         when(time.toInt()) {
  39.             in 0..6 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_night)
  40.             in 7..12 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_morning)
  41.             in 13..18 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_afternoon)
  42.             in 19..23 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_night)
  43.         }
  44.     }
  45.  
  46.     private fun initRecycleViewInspiration() {
  47.         val list: ArrayList<InspirationModel> = arrayListOf()
  48.         binding.rvInspiration.setHasFixedSize(true)
  49.         list.addAll(InspirationData.listData)
  50.         binding.rvInspiration.layoutManager = LinearLayoutManager(this)
  51.         val listInspirationAdapter = InspirationListAdapter(list)
  52.         binding.rvInspiration.adapter = listInspirationAdapter
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement