diff --git a/app/src/main/java/com/alexandr7035/gitstat/view/repositories_list/RepositoriesListHostFragment.kt b/app/src/main/java/com/alexandr7035/gitstat/view/repositories_list/RepositoriesListHostFragment.kt index 26ca9c82..1b35f025 100644 --- a/app/src/main/java/com/alexandr7035/gitstat/view/repositories_list/RepositoriesListHostFragment.kt +++ b/app/src/main/java/com/alexandr7035/gitstat/view/repositories_list/RepositoriesListHostFragment.kt @@ -9,6 +9,7 @@ import androidx.navigation.fragment.findNavController import androidx.navigation.navGraphViewModels import com.alexandr7035.gitstat.R import com.alexandr7035.gitstat.databinding.FragmentHostRepositoriesListBinding +import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import dagger.hilt.android.AndroidEntryPoint @@ -43,6 +44,15 @@ class RepositoriesListHostFragment : Fragment() { tab.text = tabTitles[position] }.attach() + // Update counters in the tabs + viewModel.getActiveRepositoriesLiveData().observe(viewLifecycleOwner, { + (binding!!.tabLayout.getTabAt(0) as TabLayout.Tab).text = "Active (${it.size})" + }) + + viewModel.getArchivedRepositoriesLiveData().observe(viewLifecycleOwner, { + (binding!!.tabLayout.getTabAt(1) as TabLayout.Tab).text = "Archived (${it.size})" + }) + }