package com.dmc.callcrm.ui import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import com.dmc.callcrm.R import com.google.android.material.bottomnavigation.BottomNavigationView /** Employee home: Call History, Analytics, Contacts, More. */ class HomeActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_home) val nav = findViewById(R.id.bottomNav) if (savedInstanceState == null) show(CallHistoryFragment()) nav.setOnItemSelectedListener { item -> val f: Fragment = when (item.itemId) { R.id.nav_history -> CallHistoryFragment() R.id.nav_analytics -> AnalyticsFragment() R.id.nav_contacts -> ContactsFragment() else -> MoreFragment() } show(f); true } } private fun show(f: Fragment) { supportFragmentManager.beginTransaction().replace(R.id.container, f).commit() } }