mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Installed list to MainNav VM
This commit is contained in:
parent
506e26d0cc
commit
0e379d95ff
@ -52,6 +52,7 @@ class ExploreFragment : MainNavFragmentX() {
|
||||
viewModel.repositories.observe(viewLifecycleOwner) {
|
||||
repositories = it.associateBy { repo -> repo.id }
|
||||
}
|
||||
viewModel.installed.observe(viewLifecycleOwner) {}
|
||||
viewModel.primaryProducts.observe(viewLifecycleOwner) {
|
||||
redrawPage(it, viewModel.categories.value ?: emptyList())
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ class InstalledFragment : MainNavFragmentX() {
|
||||
viewModel.repositories.observe(viewLifecycleOwner) {
|
||||
repositories = it.associateBy { repo -> repo.id }
|
||||
}
|
||||
viewModel.installed.observe(viewLifecycleOwner) {}
|
||||
viewModel.primaryProducts.observe(viewLifecycleOwner) {
|
||||
binding.primaryComposeRecycler.setContent {
|
||||
AppTheme(
|
||||
|
@ -43,6 +43,7 @@ class LatestFragment : MainNavFragmentX() {
|
||||
viewModel.repositories.observe(viewLifecycleOwner) {
|
||||
repositories = it.associateBy { repo -> repo.id }
|
||||
}
|
||||
viewModel.installed.observe(viewLifecycleOwner) {}
|
||||
viewModel.primaryProducts.observe(viewLifecycleOwner) {
|
||||
binding.primaryComposeRecycler.setContent {
|
||||
AppTheme(
|
||||
|
@ -3,6 +3,7 @@ package com.looker.droidify.ui.viewmodels
|
||||
import androidx.lifecycle.*
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.DatabaseX
|
||||
import com.looker.droidify.database.entity.Installed
|
||||
import com.looker.droidify.database.entity.Product
|
||||
import com.looker.droidify.database.entity.Repository
|
||||
import com.looker.droidify.entity.Order
|
||||
@ -71,6 +72,7 @@ class MainNavFragmentViewModelX(
|
||||
|
||||
val repositories = MediatorLiveData<List<Repository>>()
|
||||
val categories = MediatorLiveData<List<String>>()
|
||||
val installed = MediatorLiveData<List<Installed>>()
|
||||
|
||||
init {
|
||||
primaryProducts.addSource(
|
||||
@ -99,14 +101,20 @@ class MainNavFragmentViewModelX(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (secondarySource == Source.UPDATES) {
|
||||
secondaryProducts.addSource(db.installedDao.allLive) {
|
||||
installed.addSource(db.installedDao.allLive) {
|
||||
if (primarySource == Source.INSTALLED && secondarySource == Source.UPDATES) {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
secondaryProducts.postValue(db.productDao.queryObject(secondaryRequest))
|
||||
primaryProducts.postValue(
|
||||
db.productDao.queryObject(
|
||||
primaryRequest.value ?: request(primarySource)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
installed.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user