From 713ceb05bfe13676dd0fef8dbff422cbc65316dd Mon Sep 17 00:00:00 2001 From: davidoskky Date: Fri, 30 Sep 2022 15:07:17 +0200 Subject: [PATCH] Remove unnecessary data class --- .../android/HomeActivity.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 93f910c..d0a9c5e 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -95,8 +95,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar private val repository : Repository by instance() private val appSettingsService : AppSettingsService by instance() - data class DrawerData(val tags: List, val sources: List) - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityHomeBinding.inflate(layoutInflater) @@ -349,14 +347,15 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar ) CoroutineScope(Dispatchers.IO).launch { - val drawerData = DrawerData(repository.getTags(), repository.getSources()) + val tags = repository.getTags() + val sources = repository.getSources() runOnUiThread { - handleDrawerData(drawerData) + handleDrawerData(tags, sources) } } } - private fun handleDrawerData(drawerData: DrawerData) { + private fun handleDrawerData(tags: List, sources: List) { binding.mainDrawer.itemAdapter.clear() // Filters title with clear action @@ -370,24 +369,24 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } // Hidden tags - if (drawerData.tags.isNotEmpty() && appSettingsService.getHiddenTags().isNotEmpty()) { + if (tags.isNotEmpty() && appSettingsService.getHiddenTags().isNotEmpty()) { secondaryItem( withDivider = true, R.string.drawer_item_hidden_tags, DRAWER_ID_HIDDEN_TAGS ) - handleHiddenTags(drawerData.tags) + handleHiddenTags(tags) } // Tags secondaryItem(withDivider = true, R.string.drawer_item_tags, DRAWER_ID_TAGS) - if (drawerData.tags.isEmpty()) { + if (tags.isEmpty()) { binding.mainDrawer.itemAdapter.add( SecondaryDrawerItem() .apply { nameRes = R.string.drawer_error_loading_tags; isSelectable = false } ) } else { - handleTags(drawerData.tags) + handleTags(tags) } // Sources @@ -395,7 +394,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar startActivity(Intent(v!!.context, SourcesActivity::class.java)) false } - if (drawerData.sources.isEmpty()) { + if (sources.isEmpty()) { binding.mainDrawer.itemAdapter.add( SecondaryDrawerItem().apply { nameRes = R.string.drawer_error_loading_sources @@ -403,7 +402,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } ) } else { - handleSources(drawerData.sources) + handleSources(sources) } // About action