mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Check the selected category on launch/resume
This commit is contained in:
parent
555bf1f14f
commit
e7295d90d6
@ -6,9 +6,11 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material.Scaffold
|
||||
import androidx.core.view.children
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.entity.Category
|
||||
import com.looker.droidify.database.entity.Repository
|
||||
import com.looker.droidify.databinding.FragmentExploreXBinding
|
||||
import com.looker.droidify.entity.Section
|
||||
@ -64,14 +66,23 @@ class ExploreFragment : MainNavFragmentX() {
|
||||
}
|
||||
}
|
||||
viewModel.categories.observe(viewLifecycleOwner) {
|
||||
binding.categories.removeAllViews()
|
||||
binding.categories.addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
||||
setText(R.string.all_applications)
|
||||
})
|
||||
it.forEach {
|
||||
binding.categories.addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
||||
text = it
|
||||
binding.categories.apply {
|
||||
removeAllViews()
|
||||
addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
||||
setText(R.string.all_applications)
|
||||
id = R.id.SHOW_ALL
|
||||
})
|
||||
it.forEach {
|
||||
addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
||||
text = it
|
||||
})
|
||||
}
|
||||
val selectedSection = viewModel.sections.value
|
||||
check(
|
||||
children.filterNotNull()
|
||||
.find { it is Chip && selectedSection is Category && it.text == selectedSection.name }?.id
|
||||
?: R.id.SHOW_ALL
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.categories.setOnCheckedChangeListener { group, checkedId ->
|
||||
|
@ -19,9 +19,12 @@ class MainNavFragmentViewModelX(
|
||||
secondarySource: Source
|
||||
) : ViewModel() {
|
||||
|
||||
private val order = MutableLiveData(Order.LAST_UPDATE)
|
||||
private val sections = MutableLiveData<Section>(Section.All)
|
||||
private val searchQuery = MutableLiveData("")
|
||||
var order = MutableLiveData(Order.LAST_UPDATE)
|
||||
private set
|
||||
var sections = MutableLiveData<Section>(Section.All)
|
||||
private set
|
||||
var searchQuery = MutableLiveData("")
|
||||
private set
|
||||
|
||||
fun request(source: Source): Request {
|
||||
var mSearchQuery = ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user