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?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
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) {
|
appsItemAdapter = PagedModelAdapter<Product, VAppItem>(PRODUCT_ASYNC_DIFFER_CONFIG) {
|
||||||
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
||||||
}
|
}
|
||||||
@ -57,14 +65,9 @@ class ExploreFragment : MainNavFragmentX() {
|
|||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
adapter = appsFastAdapter
|
adapter = appsFastAdapter
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.db.repositoryDao.allFlowable
|
override fun setupLayout() {
|
||||||
.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 }
|
|
||||||
|
|
||||||
viewModel.productsList.observe(requireActivity()) {
|
viewModel.productsList.observe(requireActivity()) {
|
||||||
appsItemAdapter.submitList(it)
|
appsItemAdapter.submitList(it)
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,15 @@ class InstalledFragment : MainNavFragmentX() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
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) {
|
installedItemAdapter = PagedModelAdapter<Product, VAppItem>(PRODUCT_ASYNC_DIFFER_CONFIG) {
|
||||||
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
||||||
}
|
}
|
||||||
@ -70,15 +78,18 @@ class InstalledFragment : MainNavFragmentX() {
|
|||||||
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
|
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
|
||||||
adapter = updatedFastAdapter
|
adapter = updatedFastAdapter
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.db.repositoryDao.allFlowable
|
override fun setupLayout() {
|
||||||
.observeOn(Schedulers.io())
|
binding.buttonUpdated.setOnClickListener {
|
||||||
.flatMapSingle { list -> RxUtils.querySingle { list.mapNotNull { it.trueData } } }
|
binding.updatedRecycler.apply {
|
||||||
.map { list -> list.asSequence().map { Pair(it.id, it) }.toMap() }
|
visibility = if (visibility == View.VISIBLE) View.GONE else View.VISIBLE
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
}
|
||||||
.subscribe { repositories = it }
|
}
|
||||||
|
|
||||||
viewModel.productsList.observe(requireActivity()) {
|
viewModel.productsList.observe(requireActivity()) {
|
||||||
|
binding.updatedBar.visibility =
|
||||||
|
if (it.any { item -> item.data_item?.canUpdate == true }) View.VISIBLE else View.GONE
|
||||||
updatedItemAdapter.submitList(it)
|
updatedItemAdapter.submitList(it)
|
||||||
installedItemAdapter.submitList(it)
|
installedItemAdapter.submitList(it)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,15 @@ class LatestFragment : MainNavFragmentX() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
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) {
|
updatedItemAdapter = PagedModelAdapter<Product, VAppItem>(PRODUCT_ASYNC_DIFFER_CONFIG) {
|
||||||
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
it.data_item?.let { item -> VAppItem(item, repositories[it.repository_id]) }
|
||||||
}
|
}
|
||||||
@ -71,14 +79,9 @@ class LatestFragment : MainNavFragmentX() {
|
|||||||
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
|
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
|
||||||
adapter = newFastAdapter
|
adapter = newFastAdapter
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.db.repositoryDao.allFlowable
|
override fun setupLayout() {
|
||||||
.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 }
|
|
||||||
|
|
||||||
viewModel.productsList.observe(requireActivity()) {
|
viewModel.productsList.observe(requireActivity()) {
|
||||||
newItemAdapter.submitList(it)
|
newItemAdapter.submitList(it)
|
||||||
updatedItemAdapter.submitList(it)
|
updatedItemAdapter.submitList(it)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.looker.droidify.ui.fragments
|
package com.looker.droidify.ui.fragments
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.looker.droidify.R
|
import com.looker.droidify.R
|
||||||
import com.looker.droidify.entity.ProductItem
|
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) {
|
enum class Source(val sections: Boolean, val order: Boolean) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user