diff --git a/app/src/main/java/emu/skyline/MainActivity.kt b/app/src/main/java/emu/skyline/MainActivity.kt index 311107f4..d884fcb7 100644 --- a/app/src/main/java/emu/skyline/MainActivity.kt +++ b/app/src/main/java/emu/skyline/MainActivity.kt @@ -215,14 +215,14 @@ class MainActivity : AppCompatActivity() { if (appSettings.searchLocation.isEmpty()) documentPicker.launch(null) } - private fun getDataItems() = mutableListOf().apply { + private fun getDataItems() = mutableListOf().apply { if (appSettings.groupByFormat) { appEntries?.let { entries -> val formats = formatFilter?.let { listOf(it) } ?: formatOrder for (format in formats) { entries[format]?.let { - for (entry in sortGameList(it)) { - add(AppItem(entry)) + sortGameList(it).forEach { entry -> + add(AppItem(entry).toViewItem()) } } } @@ -237,8 +237,8 @@ class MainActivity : AppCompatActivity() { } } } - for (entry in sortGameList(gameList.toList())) { - add(AppItem(entry)) + sortGameList(gameList.toList()).forEach { entry -> + add(AppItem(entry).toViewItem()) } } } @@ -297,11 +297,7 @@ class MainActivity : AppCompatActivity() { binding.textTitle.text = null binding.textTitle.visibility = View.GONE val items = getDataItems() - adapter.setItems(items.map { - when (it) { - is AppItem -> it.toViewItem() - } - }) + adapter.setItems(items) if (items.isEmpty()) { binding.textTitle.visibility = View.VISIBLE binding.textTitle.text = getString(R.string.no_rom) diff --git a/app/src/main/java/emu/skyline/adapter/GenericAdapter.kt b/app/src/main/java/emu/skyline/adapter/GenericAdapter.kt index b73ab638..1cfca4c8 100644 --- a/app/src/main/java/emu/skyline/adapter/GenericAdapter.kt +++ b/app/src/main/java/emu/skyline/adapter/GenericAdapter.kt @@ -31,7 +31,6 @@ open class GenericAdapter : RecyclerView.Adapter> } private val asyncListDiffer = AsyncListDiffer(this, DIFFER) - private val headerItems = mutableListOf>() val allItems = mutableListOf>() val currentItems : List> get() = asyncListDiffer.currentList @@ -56,12 +55,6 @@ open class GenericAdapter : RecyclerView.Adapter> override fun getItemViewType(position : Int) = viewTypesMapping.getOrPut(currentItems[position].getViewBindingFactory()) { viewTypesMapping.size } - fun setHeaderItems(items : List>) { - headerItems.clear() - headerItems.addAll(items) - filter.filter(currentSearchTerm) - } - fun setItems(items : List>) { allItems.clear() allItems.addAll(items) @@ -128,8 +121,8 @@ open class GenericAdapter : RecyclerView.Adapter> filterData }) { FilterResults().apply { - values = headerItems + this@with - count = headerItems.size + size + values = this@with + count = size } } }