Update: Replace item with toItem to include installed info

This commit is contained in:
machiav3lli 2022-04-06 03:40:20 +02:00
parent 865664cad2
commit f49e3cdeab
4 changed files with 10 additions and 10 deletions

View File

@ -47,18 +47,18 @@ open class Product {
val versionCode: Long val versionCode: Long
get() = selectedReleases.firstOrNull()?.versionCode ?: 0L get() = selectedReleases.firstOrNull()?.versionCode ?: 0L
val item: ProductItem fun toItem(installed: Installed? = null): ProductItem =
get() = ProductItem( ProductItem(
repository_id, repositoryId,
package_name, packageName,
name, name,
summary, summary,
icon, icon,
metadataIcon, metadataIcon,
version, version,
"", "",
compatible != 0, compatible,
false, canUpdate(installed),
0 0
) )
} }

View File

@ -399,7 +399,7 @@ class SyncService : ConnectionService<SyncService.Binder>() {
searchQuery = "", searchQuery = "",
section = Section.All, section = Section.All,
order = Order.NAME order = Order.NAME
).map { it.item } ).map { it.toItem() }
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())

View File

@ -35,7 +35,7 @@ fun ProductsVerticalRecycler(
onInstallClick: (ProductItem) -> Unit = {} onInstallClick: (ProductItem) -> Unit = {}
) { ) {
VerticalItemList(list = productsList) { VerticalItemList(list = productsList) {
it.item.let { item -> it.toItem().let { item ->
ProductsListItem( ProductsListItem(
item, item,
repositories[item.repositoryId], repositories[item.repositoryId],
@ -58,7 +58,7 @@ fun ProductsHorizontalRecycler(
horizontalArrangement = spacedBy(2.dp) horizontalArrangement = spacedBy(2.dp)
) { ) {
items(productsList ?: emptyList()) { product -> items(productsList ?: emptyList()) { product ->
product.item.let { item -> product.toItem().let { item ->
ProductCard(item, repositories[item.repositoryId], onUserClick) ProductCard(item, repositories[item.repositoryId], onUserClick)
} }
} }

View File

@ -108,7 +108,7 @@ class InstalledFragment : MainNavFragmentX() {
} }
binding.buttonUpdateAll.setOnClickListener { binding.buttonUpdateAll.setOnClickListener {
viewModel.secondaryProducts.value?.let { viewModel.secondaryProducts.value?.let {
mainActivityX.syncConnection.binder?.updateApps(it.map(Product::item)) mainActivityX.syncConnection.binder?.updateApps(it.map(Product::toItem))
} }
} }
mainActivityX.menuSetup.observe(viewLifecycleOwner) { mainActivityX.menuSetup.observe(viewLifecycleOwner) {