mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-27 01:05:28 +03:00
Remove HeaderItem as a DataItem type
This commit is contained in:
parent
1841727c56
commit
b82452f8f8
@ -215,14 +215,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (appSettings.searchLocation.isEmpty()) documentPicker.launch(null)
|
if (appSettings.searchLocation.isEmpty()) documentPicker.launch(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDataItems() = mutableListOf<DataItem>().apply {
|
private fun getDataItems() = mutableListOf<AppViewItem>().apply {
|
||||||
if (appSettings.groupByFormat) {
|
if (appSettings.groupByFormat) {
|
||||||
appEntries?.let { entries ->
|
appEntries?.let { entries ->
|
||||||
val formats = formatFilter?.let { listOf(it) } ?: formatOrder
|
val formats = formatFilter?.let { listOf(it) } ?: formatOrder
|
||||||
for (format in formats) {
|
for (format in formats) {
|
||||||
entries[format]?.let {
|
entries[format]?.let {
|
||||||
for (entry in sortGameList(it)) {
|
sortGameList(it).forEach { entry ->
|
||||||
add(AppItem(entry))
|
add(AppItem(entry).toViewItem())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,8 +237,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (entry in sortGameList(gameList.toList())) {
|
sortGameList(gameList.toList()).forEach { entry ->
|
||||||
add(AppItem(entry))
|
add(AppItem(entry).toViewItem())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,11 +297,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
binding.textTitle.text = null
|
binding.textTitle.text = null
|
||||||
binding.textTitle.visibility = View.GONE
|
binding.textTitle.visibility = View.GONE
|
||||||
val items = getDataItems()
|
val items = getDataItems()
|
||||||
adapter.setItems(items.map {
|
adapter.setItems(items)
|
||||||
when (it) {
|
|
||||||
is AppItem -> it.toViewItem()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
binding.textTitle.visibility = View.VISIBLE
|
binding.textTitle.visibility = View.VISIBLE
|
||||||
binding.textTitle.text = getString(R.string.no_rom)
|
binding.textTitle.text = getString(R.string.no_rom)
|
||||||
|
@ -31,7 +31,6 @@ open class GenericAdapter : RecyclerView.Adapter<GenericViewHolder<ViewBinding>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val asyncListDiffer = AsyncListDiffer(this, DIFFER)
|
private val asyncListDiffer = AsyncListDiffer(this, DIFFER)
|
||||||
private val headerItems = mutableListOf<GenericListItem<out ViewBinding>>()
|
|
||||||
val allItems = mutableListOf<GenericListItem<out ViewBinding>>()
|
val allItems = mutableListOf<GenericListItem<out ViewBinding>>()
|
||||||
val currentItems : List<GenericListItem<in ViewBinding>> get() = asyncListDiffer.currentList
|
val currentItems : List<GenericListItem<in ViewBinding>> get() = asyncListDiffer.currentList
|
||||||
|
|
||||||
@ -56,12 +55,6 @@ open class GenericAdapter : RecyclerView.Adapter<GenericViewHolder<ViewBinding>>
|
|||||||
|
|
||||||
override fun getItemViewType(position : Int) = viewTypesMapping.getOrPut(currentItems[position].getViewBindingFactory()) { viewTypesMapping.size }
|
override fun getItemViewType(position : Int) = viewTypesMapping.getOrPut(currentItems[position].getViewBindingFactory()) { viewTypesMapping.size }
|
||||||
|
|
||||||
fun setHeaderItems(items : List<GenericListItem<*>>) {
|
|
||||||
headerItems.clear()
|
|
||||||
headerItems.addAll(items)
|
|
||||||
filter.filter(currentSearchTerm)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setItems(items : List<GenericListItem<*>>) {
|
fun setItems(items : List<GenericListItem<*>>) {
|
||||||
allItems.clear()
|
allItems.clear()
|
||||||
allItems.addAll(items)
|
allItems.addAll(items)
|
||||||
@ -128,8 +121,8 @@ open class GenericAdapter : RecyclerView.Adapter<GenericViewHolder<ViewBinding>>
|
|||||||
filterData
|
filterData
|
||||||
}) {
|
}) {
|
||||||
FilterResults().apply {
|
FilterResults().apply {
|
||||||
values = headerItems + this@with
|
values = this@with
|
||||||
count = headerItems.size + size
|
count = size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user