Remove non-functional pages - EditorChoise, Library, PurchaseHistory
- Will adapt GPlayApi to new API & re-implement
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package com.aurora.store.data.model
|
||||
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
|
||||
data class PaginatedAppList(
|
||||
val appList: MutableList<App> = mutableListOf(),
|
||||
var hasMore: Boolean
|
||||
)
|
||||
@@ -65,8 +65,6 @@ class AppsGamesFragment : BaseFragment<FragmentGenericWithPagerBinding>() {
|
||||
) { tab: TabLayout.Tab, position: Int ->
|
||||
when (position) {
|
||||
0 -> tab.text = getString(R.string.title_installed)
|
||||
1 -> tab.text = getString(R.string.title_library)
|
||||
2 -> tab.text = getString(R.string.title_purchase_history)
|
||||
else -> {}
|
||||
}
|
||||
}.attach()
|
||||
@@ -81,14 +79,12 @@ class AppsGamesFragment : BaseFragment<FragmentGenericWithPagerBinding>() {
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return when (position) {
|
||||
0 -> InstalledAppsFragment.newInstance()
|
||||
1 -> LibraryAppsFragment.newInstance()
|
||||
2 -> PurchasedAppsFragment.newInstance()
|
||||
else -> Fragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return if (isAnonymous) 1 else 3
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.view.ui.all
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.aurora.gplayapi.data.models.StreamCluster
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.databinding.FragmentAppsBinding
|
||||
import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener
|
||||
import com.aurora.store.view.epoxy.views.AppProgressViewModel_
|
||||
import com.aurora.store.view.epoxy.views.HeaderViewModel_
|
||||
import com.aurora.store.view.epoxy.views.app.AppListViewModel_
|
||||
import com.aurora.store.view.epoxy.views.shimmer.AppListViewShimmerModel_
|
||||
import com.aurora.store.view.ui.commons.BaseFragment
|
||||
import com.aurora.store.viewmodel.all.LibraryAppsViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class LibraryAppsFragment : BaseFragment<FragmentAppsBinding>() {
|
||||
private val viewModel: LibraryAppsViewModel by viewModels()
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): LibraryAppsFragment {
|
||||
return LibraryAppsFragment().apply {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val endlessRecyclerOnScrollListener = object : EndlessRecyclerOnScrollListener() {
|
||||
override fun onLoadMore(currentPage: Int) {
|
||||
viewModel.observe()
|
||||
}
|
||||
}
|
||||
binding.recycler.addOnScrollListener(endlessRecyclerOnScrollListener)
|
||||
|
||||
viewModel.liveData.observe(viewLifecycleOwner) {
|
||||
updateController(it)
|
||||
}
|
||||
|
||||
updateController(null)
|
||||
}
|
||||
|
||||
private fun updateController(streamCluster: StreamCluster?) {
|
||||
binding.recycler.withModels {
|
||||
setFilterDuplicates(true)
|
||||
if (streamCluster == null) {
|
||||
for (i in 1..10) {
|
||||
add(
|
||||
AppListViewShimmerModel_()
|
||||
.id(i)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
add(
|
||||
HeaderViewModel_()
|
||||
.id("header")
|
||||
.title(
|
||||
if (streamCluster.clusterTitle.isEmpty())
|
||||
getString(R.string.title_apps_library)
|
||||
else
|
||||
streamCluster.clusterTitle
|
||||
)
|
||||
)
|
||||
streamCluster.clusterAppList.forEach { app ->
|
||||
add(
|
||||
AppListViewModel_()
|
||||
.id(app.id)
|
||||
.app(app)
|
||||
.click { _ -> openDetailsFragment(app.packageName, app) }
|
||||
)
|
||||
}
|
||||
|
||||
if (streamCluster.hasNext()) {
|
||||
add(
|
||||
AppProgressViewModel_()
|
||||
.id("progress")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.view.ui.all
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.databinding.FragmentAppsBinding
|
||||
import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener
|
||||
import com.aurora.store.view.epoxy.views.AppProgressViewModel_
|
||||
import com.aurora.store.view.epoxy.views.app.AppListViewModel_
|
||||
import com.aurora.store.view.epoxy.views.shimmer.AppListViewShimmerModel_
|
||||
import com.aurora.store.view.ui.commons.BaseFragment
|
||||
import com.aurora.store.viewmodel.all.PaginatedAppList
|
||||
import com.aurora.store.viewmodel.all.PurchasedViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class PurchasedAppsFragment : BaseFragment<FragmentAppsBinding>() {
|
||||
private val viewModel: PurchasedViewModel by viewModels()
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): PurchasedAppsFragment {
|
||||
return PurchasedAppsFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val endlessRecyclerOnScrollListener = object : EndlessRecyclerOnScrollListener(8) {
|
||||
override fun onLoadMore(currentPage: Int) {
|
||||
viewModel.observe()
|
||||
}
|
||||
}
|
||||
|
||||
binding.recycler.addOnScrollListener(endlessRecyclerOnScrollListener)
|
||||
|
||||
viewModel.liveData.observe(viewLifecycleOwner) {
|
||||
updateController(it)
|
||||
}
|
||||
|
||||
updateController(null)
|
||||
}
|
||||
|
||||
private fun updateController(paginatedAppList: PaginatedAppList?) {
|
||||
binding.recycler.withModels {
|
||||
setFilterDuplicates(true)
|
||||
if (paginatedAppList == null) {
|
||||
for (i in 1..10) {
|
||||
add(
|
||||
AppListViewShimmerModel_()
|
||||
.id(i)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
paginatedAppList.appList.forEach { app ->
|
||||
add(
|
||||
AppListViewModel_()
|
||||
.id(app.id)
|
||||
.app(app)
|
||||
.click { _ -> openDetailsFragment(app.packageName, app) }
|
||||
.longClick { _ ->
|
||||
openAppMenuSheet(app)
|
||||
false
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (paginatedAppList.hasMore) {
|
||||
add(
|
||||
AppProgressViewModel_()
|
||||
.id("progress")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ import com.aurora.store.databinding.FragmentAppsGamesBinding
|
||||
import com.aurora.store.util.Preferences
|
||||
import com.aurora.store.view.ui.commons.BaseFragment
|
||||
import com.aurora.store.view.ui.commons.CategoryFragment
|
||||
import com.aurora.store.view.ui.commons.EditorChoiceFragment
|
||||
import com.aurora.store.view.ui.commons.ForYouFragment
|
||||
import com.aurora.store.view.ui.commons.TopChartContainerFragment
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
@@ -92,10 +91,6 @@ class AppsContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
|
||||
|
||||
add(getString(R.string.tab_top_charts))
|
||||
add(getString(R.string.tab_categories))
|
||||
|
||||
if (!authProvider.isAnonymous) {
|
||||
add(getString(R.string.tab_editor_choice))
|
||||
}
|
||||
}
|
||||
|
||||
TabLayoutMediator(
|
||||
@@ -130,10 +125,6 @@ class AppsContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
|
||||
}
|
||||
add(TopChartContainerFragment.newInstance(0))
|
||||
add(CategoryFragment.newInstance(0))
|
||||
|
||||
if (isGoogleAccount) {
|
||||
add(EditorChoiceFragment.newInstance(0))
|
||||
}
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.view.ui.commons
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.aurora.Constants
|
||||
import com.aurora.gplayapi.data.models.editor.EditorChoiceCluster
|
||||
import com.aurora.gplayapi.helpers.contracts.StreamContract
|
||||
import com.aurora.store.databinding.FragmentForYouBinding
|
||||
import com.aurora.store.view.epoxy.controller.EditorChoiceController
|
||||
import com.aurora.store.viewmodel.editorschoice.EditorChoiceViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class EditorChoiceFragment : BaseFragment<FragmentForYouBinding>(),
|
||||
EditorChoiceController.Callbacks {
|
||||
private val viewModel: EditorChoiceViewModel by viewModels()
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(pageType: Int): EditorChoiceFragment {
|
||||
return EditorChoiceFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putInt(Constants.PAGE_TYPE, pageType)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
var pageType = 0
|
||||
val bundle = arguments
|
||||
if (bundle != null) {
|
||||
pageType = bundle.getInt(Constants.PAGE_TYPE, 0)
|
||||
}
|
||||
|
||||
val editorChoiceController = EditorChoiceController(this)
|
||||
binding.recycler.setController(editorChoiceController)
|
||||
|
||||
when (pageType) {
|
||||
0 -> viewModel.getEditorChoiceStream(StreamContract.Category.APPLICATION)
|
||||
1 -> viewModel.getEditorChoiceStream(StreamContract.Category.GAME)
|
||||
}
|
||||
|
||||
viewModel.liveData.observe(viewLifecycleOwner) {
|
||||
editorChoiceController.setData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(editorChoiceCluster: EditorChoiceCluster) {
|
||||
openEditorStreamBrowseFragment(
|
||||
editorChoiceCluster.clusterBrowseUrl,
|
||||
editorChoiceCluster.clusterTitle
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.view.ui.commons
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import com.airbnb.epoxy.EpoxyModel
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.store.databinding.FragmentGenericWithToolbarBinding
|
||||
import com.aurora.store.view.epoxy.groups.CarouselHorizontalModel_
|
||||
import com.aurora.store.view.epoxy.views.EditorHeadViewModel_
|
||||
import com.aurora.store.view.epoxy.views.HorizontalDividerViewModel_
|
||||
import com.aurora.store.view.epoxy.views.app.AppListViewModel_
|
||||
import com.aurora.store.view.epoxy.views.details.MiniScreenshotView
|
||||
import com.aurora.store.view.epoxy.views.details.MiniScreenshotViewModel_
|
||||
import com.aurora.store.view.epoxy.views.shimmer.AppListViewShimmerModel_
|
||||
import com.aurora.store.viewmodel.editorschoice.EditorBrowseViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class EditorStreamBrowseFragment : BaseFragment<FragmentGenericWithToolbarBinding>() {
|
||||
private val args: EditorStreamBrowseFragmentArgs by navArgs()
|
||||
private val viewModel: EditorBrowseViewModel by viewModels()
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
// Toolbar
|
||||
binding.layoutToolbarAction.apply {
|
||||
txtTitle.text = args.title
|
||||
imgActionPrimary.setOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.liveData.observe(viewLifecycleOwner) {
|
||||
updateController(it)
|
||||
}
|
||||
|
||||
viewModel.getEditorStreamBundle(args.browseUrl)
|
||||
updateController(null)
|
||||
}
|
||||
|
||||
private fun updateController(appList: MutableList<App>?) {
|
||||
binding.recycler.withModels {
|
||||
setFilterDuplicates(true)
|
||||
if (appList == null) {
|
||||
for (i in 1..6) {
|
||||
add(
|
||||
AppListViewShimmerModel_()
|
||||
.id(i)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
appList.forEach { app ->
|
||||
val screenshotsViewModels = mutableListOf<EpoxyModel<*>>()
|
||||
|
||||
for ((position, artwork) in app.screenshots.withIndex()) {
|
||||
screenshotsViewModels.add(
|
||||
MiniScreenshotViewModel_()
|
||||
.id(artwork.url)
|
||||
.position(position)
|
||||
.artwork(artwork)
|
||||
.callback(object : MiniScreenshotView.ScreenshotCallback {
|
||||
override fun onClick(position: Int) {
|
||||
openScreenshotFragment(app, position)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
add(
|
||||
AppListViewModel_()
|
||||
.id("app_${app.id}")
|
||||
.app(app)
|
||||
.click { _ -> openDetailsFragment(app.packageName, app) }
|
||||
)
|
||||
|
||||
app.editorReason?.let { editorReason ->
|
||||
add(
|
||||
EditorHeadViewModel_()
|
||||
.id("bulletin_${app.id}")
|
||||
.title(
|
||||
editorReason.bulletins
|
||||
.joinToString(transform = { "\n• $it" })
|
||||
.substringAfter(delimiter = "\n")
|
||||
)
|
||||
.click { _ -> openDetailsFragment(app.packageName, app) }
|
||||
)
|
||||
}
|
||||
|
||||
if (screenshotsViewModels.isNotEmpty()) {
|
||||
add(
|
||||
CarouselHorizontalModel_()
|
||||
.id("screenshots_${app.id}")
|
||||
.models(screenshotsViewModels)
|
||||
)
|
||||
}
|
||||
|
||||
app.editorReason?.let { editorReason ->
|
||||
if (editorReason.description.isNotEmpty()) {
|
||||
add(
|
||||
EditorHeadViewModel_()
|
||||
.id("description_${app.id}")
|
||||
.title(editorReason.description)
|
||||
.click { _ -> openDetailsFragment(app.packageName, app) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
add(
|
||||
HorizontalDividerViewModel_()
|
||||
.id("divider_${app.id}")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ import com.aurora.store.databinding.FragmentAppsGamesBinding
|
||||
import com.aurora.store.util.Preferences
|
||||
import com.aurora.store.view.ui.commons.BaseFragment
|
||||
import com.aurora.store.view.ui.commons.CategoryFragment
|
||||
import com.aurora.store.view.ui.commons.EditorChoiceFragment
|
||||
import com.aurora.store.view.ui.commons.ForYouFragment
|
||||
import com.aurora.store.view.ui.commons.TopChartContainerFragment
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
@@ -91,10 +90,6 @@ class GamesContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
|
||||
|
||||
add(getString(R.string.tab_top_charts))
|
||||
add(getString(R.string.tab_categories))
|
||||
|
||||
if (!authProvider.isAnonymous) {
|
||||
add(getString(R.string.tab_editor_choice))
|
||||
}
|
||||
}
|
||||
|
||||
TabLayoutMediator(
|
||||
@@ -129,10 +124,6 @@ class GamesContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
|
||||
|
||||
add(TopChartContainerFragment.newInstance(1))
|
||||
add(CategoryFragment.newInstance(1))
|
||||
|
||||
if (isGoogleAccount) {
|
||||
add(EditorChoiceFragment.newInstance(1))
|
||||
}
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.model.PaginatedAppList
|
||||
import com.aurora.store.databinding.FragmentGenericWithToolbarBinding
|
||||
import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener
|
||||
import com.aurora.store.view.epoxy.views.AppProgressViewModel_
|
||||
@@ -32,7 +33,6 @@ import com.aurora.store.view.epoxy.views.app.AppListViewModel_
|
||||
import com.aurora.store.view.epoxy.views.app.NoAppViewModel_
|
||||
import com.aurora.store.view.epoxy.views.shimmer.AppListViewShimmerModel_
|
||||
import com.aurora.store.view.ui.commons.BaseFragment
|
||||
import com.aurora.store.viewmodel.all.PaginatedAppList
|
||||
import com.aurora.store.viewmodel.sale.AppSalesViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.viewmodel.all
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.aurora.gplayapi.data.models.StreamCluster
|
||||
import com.aurora.gplayapi.helpers.ClusterHelper
|
||||
import com.aurora.store.data.network.HttpClient
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
|
||||
class LibraryAppsViewModel @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val authProvider: AuthProvider
|
||||
) : ViewModel() {
|
||||
|
||||
private val clusterHelper: ClusterHelper = ClusterHelper(authProvider.authData)
|
||||
.using(HttpClient.getPreferredClient(context))
|
||||
|
||||
val liveData: MutableLiveData<StreamCluster> = MutableLiveData()
|
||||
var streamCluster: StreamCluster = StreamCluster()
|
||||
|
||||
fun observe() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
supervisorScope {
|
||||
try {
|
||||
when {
|
||||
streamCluster.clusterAppList.isEmpty() -> {
|
||||
val newCluster =
|
||||
clusterHelper.getCluster(ClusterHelper.Type.MY_APPS_LIBRARY)
|
||||
updateCluster(newCluster)
|
||||
liveData.postValue(streamCluster)
|
||||
}
|
||||
streamCluster.hasNext() -> {
|
||||
val newCluster = clusterHelper.next(streamCluster.clusterNextPageUrl)
|
||||
updateCluster(newCluster)
|
||||
liveData.postValue(streamCluster)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCluster(newCluster: StreamCluster) {
|
||||
streamCluster.apply {
|
||||
clusterAppList.addAll(newCluster.clusterAppList)
|
||||
clusterNextPageUrl = newCluster.clusterNextPageUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.viewmodel.all
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.gplayapi.helpers.PurchaseHelper
|
||||
import com.aurora.store.data.network.HttpClient
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import javax.inject.Inject
|
||||
|
||||
data class PaginatedAppList(
|
||||
var appList: MutableList<App> = mutableListOf(),
|
||||
var hasMore: Boolean
|
||||
)
|
||||
|
||||
@HiltViewModel
|
||||
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
|
||||
class PurchasedViewModel @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val authProvider: AuthProvider
|
||||
) : ViewModel() {
|
||||
|
||||
private val purchaseHelper = PurchaseHelper(authProvider.authData)
|
||||
.using(HttpClient.getPreferredClient(context))
|
||||
|
||||
private var appList: MutableList<App> = mutableListOf()
|
||||
|
||||
val liveData: MutableLiveData<PaginatedAppList> = MutableLiveData()
|
||||
|
||||
fun observe() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
supervisorScope {
|
||||
try {
|
||||
val nextAppList = purchaseHelper.getPurchaseHistory(appList.size)
|
||||
.filter { it.displayName.isNotEmpty() }
|
||||
|
||||
if (nextAppList.isEmpty()) {
|
||||
liveData.postValue(PaginatedAppList(
|
||||
appList,
|
||||
false
|
||||
))
|
||||
} else {
|
||||
appList.addAll(nextAppList)
|
||||
liveData.postValue(
|
||||
PaginatedAppList(
|
||||
appList,
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.viewmodel.editorschoice
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.gplayapi.helpers.StreamHelper
|
||||
import com.aurora.store.data.network.HttpClient
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
|
||||
class EditorBrowseViewModel @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val authProvider: AuthProvider
|
||||
) : ViewModel() {
|
||||
|
||||
private val streamHelper: StreamHelper = StreamHelper(authProvider.authData)
|
||||
.using(HttpClient.getPreferredClient(context))
|
||||
|
||||
val liveData: MutableLiveData<MutableList<App>> = MutableLiveData()
|
||||
val appList: MutableList<App> = mutableListOf()
|
||||
|
||||
fun getEditorStreamBundle(browseUrl: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
supervisorScope {
|
||||
try {
|
||||
val browseResponse = streamHelper.getBrowseStreamResponse(browseUrl)
|
||||
val listResponse =
|
||||
streamHelper.getNextStreamResponse(browseResponse.browseTab.listUrl)
|
||||
|
||||
listResponse.itemList.forEach {
|
||||
it?.let {
|
||||
it.subItemList.forEach {
|
||||
appList.addAll(streamHelper.getAppsFromItem(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
liveData.postValue(appList)
|
||||
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.viewmodel.editorschoice
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.aurora.gplayapi.data.models.editor.EditorChoiceBundle
|
||||
import com.aurora.gplayapi.helpers.StreamHelper
|
||||
import com.aurora.gplayapi.helpers.contracts.StreamContract
|
||||
import com.aurora.store.data.network.HttpClient
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@SuppressLint("StaticFieldLeak") // false positive, see https://github.com/google/dagger/issues/3253
|
||||
class EditorChoiceViewModel @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val authProvider: AuthProvider
|
||||
) : ViewModel() {
|
||||
|
||||
private val TAG = EditorChoiceViewModel::class.java.simpleName
|
||||
|
||||
private val streamHelper: StreamHelper = StreamHelper(authProvider.authData)
|
||||
.using(HttpClient.getPreferredClient(context))
|
||||
|
||||
val liveData: MutableLiveData<List<EditorChoiceBundle>> = MutableLiveData()
|
||||
|
||||
fun getEditorChoiceStream(category: StreamContract.Category) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
supervisorScope {
|
||||
try {
|
||||
val editorChoiceBundle = streamHelper.getEditorChoiceStream(category)
|
||||
liveData.postValue(editorChoiceBundle)
|
||||
} catch (exception: Exception) {
|
||||
Log.e(TAG, "Failed fetching list of categories", exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.gplayapi.helpers.AppSalesHelper
|
||||
import com.aurora.store.data.model.PaginatedAppList
|
||||
import com.aurora.store.data.network.HttpClient
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import com.aurora.store.viewmodel.all.PaginatedAppList
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
Reference in New Issue
Block a user