mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 03:42:15 +00:00
Add: Setup methods to MainNav fragments
This commit is contained in:
parent
e559f19529
commit
61c4996277
@ -46,7 +46,15 @@ class ExploreFragment : MainNavFragmentX() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewModel.db.repositoryDao.allFlowable
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { repositories = it }
|
||||
}
|
||||
|
||||
override fun setupAdapters() {
|
||||
appsItemAdapter = PagedModelAdapter<Product, VAppItem>(PRODUCT_ASYNC_DIFFER_CONFIG) {
|
||||
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
||||
}
|
||||
@ -57,14 +65,9 @@ class ExploreFragment : MainNavFragmentX() {
|
||||
setHasFixedSize(true)
|
||||
adapter = appsFastAdapter
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.db.repositoryDao.allFlowable
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { repositories = it }
|
||||
|
||||
override fun setupLayout() {
|
||||
viewModel.productsList.observe(requireActivity()) {
|
||||
appsItemAdapter.submitList(it)
|
||||
}
|
||||
|
@ -50,7 +50,15 @@ class InstalledFragment : MainNavFragmentX() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewModel.db.repositoryDao.allFlowable
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { repositories = it }
|
||||
}
|
||||
|
||||
override fun setupAdapters() {
|
||||
installedItemAdapter = PagedModelAdapter<Product, VAppItem>(PRODUCT_ASYNC_DIFFER_CONFIG) {
|
||||
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
||||
}
|
||||
@ -70,15 +78,18 @@ class InstalledFragment : MainNavFragmentX() {
|
||||
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
|
||||
adapter = updatedFastAdapter
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.db.repositoryDao.allFlowable
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { repositories = it }
|
||||
override fun setupLayout() {
|
||||
binding.buttonUpdated.setOnClickListener {
|
||||
binding.updatedRecycler.apply {
|
||||
visibility = if (visibility == View.VISIBLE) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.productsList.observe(requireActivity()) {
|
||||
binding.updatedBar.visibility =
|
||||
if (it.any { item -> item.data_item?.canUpdate == true }) View.VISIBLE else View.GONE
|
||||
updatedItemAdapter.submitList(it)
|
||||
installedItemAdapter.submitList(it)
|
||||
}
|
||||
|
@ -51,7 +51,15 @@ class LatestFragment : MainNavFragmentX() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewModel.db.repositoryDao.allFlowable
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { repositories = it }
|
||||
}
|
||||
|
||||
override fun setupAdapters() {
|
||||
updatedItemAdapter = PagedModelAdapter<Product, VAppItem>(PRODUCT_ASYNC_DIFFER_CONFIG) {
|
||||
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
||||
}
|
||||
@ -71,14 +79,9 @@ class LatestFragment : MainNavFragmentX() {
|
||||
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
|
||||
adapter = newFastAdapter
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.db.repositoryDao.allFlowable
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { repositories = it }
|
||||
|
||||
override fun setupLayout() {
|
||||
viewModel.productsList.observe(requireActivity()) {
|
||||
newItemAdapter.submitList(it)
|
||||
updatedItemAdapter.submitList(it)
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.looker.droidify.ui.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.entity.ProductItem
|
||||
@ -37,6 +39,15 @@ abstract class MainNavFragmentX : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setupAdapters()
|
||||
setupLayout()
|
||||
}
|
||||
|
||||
abstract fun setupAdapters()
|
||||
abstract fun setupLayout()
|
||||
}
|
||||
|
||||
enum class Source(val sections: Boolean, val order: Boolean) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user