Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DashboardActivity : AppCompatActivity() {
- private lateinit var binding: ActivityDashboardBinding
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- binding = ActivityDashboardBinding.inflate(layoutInflater)
- val view = binding.root
- setContentView(view)
- initNavMenu()
- initHeader()
- initRecycleViewInspiration()
- }
- private fun initNavMenu() {
- binding.ivIconMenuDoa.setOnClickListener {
- startActivity(Intent(this, MenuDoaActivity::class.java))
- }
- binding.ivIconMenuDzikir.setOnClickListener {
- startActivity(Intent(this, MenuDzikirActivity::class.java))
- }
- binding.ivIconMenuJadwalSholat.setOnClickListener {
- startActivity(Intent(this, MenuJadwalSholatActivity::class.java))
- }
- binding.ivIconMenuZakat.setOnClickListener {
- startActivity(Intent(this, MenuZakatActivity::class.java))
- }
- binding.ivIconMenuVideoKajian.setOnClickListener {
- startActivity(Intent(this, MenuVideoKajianActivity::class.java))
- }
- }
- private fun initHeader() {
- val timeNow = Calendar.getInstance().time
- val timeFormat = SimpleDateFormat("HH")
- val time = timeFormat.format(timeNow)
- when(time.toInt()) {
- in 0..6 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_night)
- in 7..12 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_morning)
- in 13..18 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_afternoon)
- in 19..23 -> binding.ivHeader.setBackgroundResource(R.drawable.bg_header_dashboard_night)
- }
- }
- private fun initRecycleViewInspiration() {
- val list: ArrayList<InspirationModel> = arrayListOf()
- binding.rvInspiration.setHasFixedSize(true)
- list.addAll(InspirationData.listData)
- binding.rvInspiration.layoutManager = LinearLayoutManager(this)
- val listInspirationAdapter = InspirationListAdapter(list)
- binding.rvInspiration.adapter = listInspirationAdapter
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement