mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-27 01:35:28 +03:00
Remove header rom filter
This commit is contained in:
parent
d3d36c6fa0
commit
1841727c56
@ -16,9 +16,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.use
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
@ -32,7 +30,6 @@ import emu.skyline.adapter.*
|
||||
import emu.skyline.data.AppItem
|
||||
import emu.skyline.data.AppItemTag
|
||||
import emu.skyline.data.DataItem
|
||||
import emu.skyline.data.HeaderItem
|
||||
import emu.skyline.databinding.MainActivityBinding
|
||||
import emu.skyline.loader.AppEntry
|
||||
import emu.skyline.loader.LoaderResult
|
||||
@ -117,12 +114,6 @@ class MainActivity : AppCompatActivity() {
|
||||
PreferenceManager.setDefaultValues(this, R.xml.emulation_preferences, false)
|
||||
|
||||
adapter.apply {
|
||||
setHeaderItems(listOf(HeaderRomFilterItem(formatOrder, if (appSettings.romFormatFilter == 0) null else formatOrder[appSettings.romFormatFilter - 1]) { romFormat ->
|
||||
appSettings.romFormatFilter = romFormat?.let { formatOrder.indexOf(romFormat) + 1 } ?: 0
|
||||
formatFilter = romFormat
|
||||
populateAdapter()
|
||||
}))
|
||||
|
||||
setOnFilterPublishedListener {
|
||||
binding.appList.post { binding.appList.smoothScrollToPosition(0) }
|
||||
}
|
||||
@ -230,7 +221,6 @@ class MainActivity : AppCompatActivity() {
|
||||
val formats = formatFilter?.let { listOf(it) } ?: formatOrder
|
||||
for (format in formats) {
|
||||
entries[format]?.let {
|
||||
add(HeaderItem(format.name))
|
||||
for (entry in sortGameList(it)) {
|
||||
add(AppItem(entry))
|
||||
}
|
||||
@ -304,14 +294,18 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun populateAdapter() {
|
||||
binding.textTitle.text = null
|
||||
binding.textTitle.visibility = View.GONE
|
||||
val items = getDataItems()
|
||||
adapter.setItems(items.map {
|
||||
when (it) {
|
||||
is HeaderItem -> HeaderViewItem(it.title)
|
||||
is AppItem -> it.toViewItem()
|
||||
}
|
||||
})
|
||||
if (items.isEmpty()) adapter.setItems(listOf(HeaderViewItem(getString(R.string.no_rom))))
|
||||
if (items.isEmpty()) {
|
||||
binding.textTitle.visibility = View.VISIBLE
|
||||
binding.textTitle.text = getString(R.string.no_rom)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
* Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||
*/
|
||||
|
||||
package emu.skyline.adapter
|
||||
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.chip.Chip
|
||||
import emu.skyline.R
|
||||
import emu.skyline.databinding.HeaderRomFilterBinding
|
||||
import emu.skyline.loader.RomFormat
|
||||
|
||||
object HeaderRomFilterBindingFactory : ViewBindingFactory {
|
||||
override fun createBinding(parent : ViewGroup) = HeaderRomFilterBinding.inflate(parent.inflater(), parent, false)
|
||||
}
|
||||
|
||||
typealias OnFilterClickedListener = (format : RomFormat?) -> Unit
|
||||
|
||||
class HeaderRomFilterItem(private val formats : List<RomFormat>, selectedFormat : RomFormat?, private val onFilterClickedListener : OnFilterClickedListener) : GenericListItem<HeaderRomFilterBinding>() {
|
||||
private var selection = selectedFormat?.let { formats.indexOf(it) + 1 } ?: 0
|
||||
|
||||
override fun getViewBindingFactory() = HeaderRomFilterBindingFactory
|
||||
|
||||
override fun bind(holder : GenericViewHolder<HeaderRomFilterBinding>, position : Int) {
|
||||
val binding = holder.binding
|
||||
binding.chipGroup.removeViews(1, binding.chipGroup.childCount - 1)
|
||||
for (format in formats) {
|
||||
binding.chipGroup.addView(Chip(binding.root.context, null, R.attr.chipChoiceStyle).apply { text = format.name })
|
||||
}
|
||||
binding.chipGroup.setOnCheckedChangeListener { group, checkedId ->
|
||||
for (i in 0 until group.childCount) {
|
||||
if (group.getChildAt(i).id == checkedId) {
|
||||
selection = i
|
||||
onFilterClickedListener(if (i == 0) null else formats[i - 1])
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.chipGroup.check(binding.chipGroup.getChildAt(selection).id)
|
||||
}
|
||||
|
||||
override val fullSpan = true
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||
*/
|
||||
|
||||
package emu.skyline.adapter
|
||||
|
||||
import android.view.ViewGroup
|
||||
import emu.skyline.databinding.SectionItemBinding
|
||||
|
||||
object HeaderBindingFactory : ViewBindingFactory {
|
||||
override fun createBinding(parent : ViewGroup) = SectionItemBinding.inflate(parent.inflater(), parent, false)
|
||||
}
|
||||
|
||||
class HeaderViewItem(private val text : String) : GenericListItem<SectionItemBinding>() {
|
||||
override fun getViewBindingFactory() = HeaderBindingFactory
|
||||
|
||||
override fun bind(holder : GenericViewHolder<SectionItemBinding>, position : Int) {
|
||||
holder.binding.textTitle.text = text
|
||||
}
|
||||
|
||||
override fun toString() = ""
|
||||
|
||||
override fun areItemsTheSame(other : GenericListItem<SectionItemBinding>) = other is HeaderViewItem && text == other.text
|
||||
|
||||
override val fullSpan = true
|
||||
}
|
@ -25,8 +25,6 @@ private val missingIcon by lazy { ContextCompat.getDrawable(SkylineApplication.i
|
||||
|
||||
sealed class DataItem : Serializable
|
||||
|
||||
class HeaderItem(val title : String) : DataItem()
|
||||
|
||||
/**
|
||||
* This class is a wrapper around [AppEntry], it is used for passing around game metadata
|
||||
*/
|
||||
|
@ -7,13 +7,11 @@ package emu.skyline.input
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.content.res.use
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.marginTop
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
|
@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<HorizontalScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:scrollbars="none"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/chip_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="4dp"
|
||||
app:checkedChip="@id/all_chip"
|
||||
app:chipSpacingHorizontal="16dp"
|
||||
app:selectionRequired="true"
|
||||
app:singleLine="true"
|
||||
app:singleSelection="true">
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/all_chip"
|
||||
style="?attr/chipChoiceStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/all" />
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
</HorizontalScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -113,6 +113,16 @@
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/sub_text"
|
||||
app:shapeAppearance="@style/ShapeAppearance.Material3.Corner.ExtraLarge" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_title"
|
||||
style="?attr/textAppearanceTitleLarge"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:textAlignment="viewStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/search_bar"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/text_title"
|
||||
style="?attr/textAppearanceTitleLarge"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:textAlignment="viewStart"
|
||||
tools:text="NSP" />
|
Loading…
Reference in New Issue
Block a user