From 0af93474ed43c467c076a67cafb6f338b18a0ada Mon Sep 17 00:00:00 2001 From: Rahul Patel Date: Fri, 12 Jul 2024 21:47:35 +0530 Subject: [PATCH] Remove AppsOnsale page Why? - Unecessary bloat, lets stick to only what is important --- .../store/view/ui/commons/BaseFragment.kt | 6 - .../view/ui/commons/MoreDialogFragment.kt | 5 - .../store/view/ui/sale/AppSalesFragment.kt | 113 ------------------ .../store/viewmodel/sale/AppSalesViewModel.kt | 95 --------------- .../main/res/navigation/mobile_navigation.xml | 18 --- 5 files changed, 237 deletions(-) delete mode 100644 app/src/main/java/com/aurora/store/view/ui/sale/AppSalesFragment.kt delete mode 100644 app/src/main/java/com/aurora/store/viewmodel/sale/AppSalesViewModel.kt diff --git a/app/src/main/java/com/aurora/store/view/ui/commons/BaseFragment.kt b/app/src/main/java/com/aurora/store/view/ui/commons/BaseFragment.kt index 454460917..9104bbe43 100644 --- a/app/src/main/java/com/aurora/store/view/ui/commons/BaseFragment.kt +++ b/app/src/main/java/com/aurora/store/view/ui/commons/BaseFragment.kt @@ -103,12 +103,6 @@ abstract class BaseFragment : Fragment() { } } - fun openEditorStreamBrowseFragment(browseUrl: String, title: String = "") { - findNavController().navigate( - MobileNavigationDirections.actionGlobalEditorStreamBrowseFragment(title, browseUrl) - ) - } - fun openScreenshotFragment(app: App, position: Int) { findNavController().navigate( MobileNavigationDirections.actionGlobalScreenshotFragment( diff --git a/app/src/main/java/com/aurora/store/view/ui/commons/MoreDialogFragment.kt b/app/src/main/java/com/aurora/store/view/ui/commons/MoreDialogFragment.kt index 7a7d51f94..16bdbed8d 100644 --- a/app/src/main/java/com/aurora/store/view/ui/commons/MoreDialogFragment.kt +++ b/app/src/main/java/com/aurora/store/view/ui/commons/MoreDialogFragment.kt @@ -270,11 +270,6 @@ class MoreDialogFragment : DialogFragment() { icon = R.drawable.ic_apps, destinationID = R.id.appsGamesFragment ), - Option( - title = R.string.title_apps_sale, - icon = R.drawable.ic_sale, - destinationID = R.id.appSalesFragment - ), Option( title = R.string.title_blacklist_manager, icon = R.drawable.ic_blacklist, diff --git a/app/src/main/java/com/aurora/store/view/ui/sale/AppSalesFragment.kt b/app/src/main/java/com/aurora/store/view/ui/sale/AppSalesFragment.kt deleted file mode 100644 index 50dedacb2..000000000 --- a/app/src/main/java/com/aurora/store/view/ui/sale/AppSalesFragment.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Aurora Store - * Copyright (C) 2021, Rahul Kumar Patel - * - * 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 . - * - */ - -package com.aurora.store.view.ui.sale - -import android.os.Bundle -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_ -import com.aurora.store.view.epoxy.views.HeaderViewModel_ -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.sale.AppSalesViewModel -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class AppSalesFragment : BaseFragment() { - - private val viewModel: AppSalesViewModel by viewModels() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - binding.layoutToolbarAction.txtTitle.text = getString(R.string.title_apps_sale) - binding.layoutToolbarAction.imgActionPrimary.setOnClickListener { - findNavController().navigateUp() - } - - val endlessRecyclerOnScrollListener = object : EndlessRecyclerOnScrollListener() { - override fun onLoadMore(currentPage: Int) { - viewModel.observe() - } - } - binding.recycler.addOnScrollListener(endlessRecyclerOnScrollListener) - updateController(null) - - viewModel.liveData.observe(viewLifecycleOwner) { - updateController(it) - } - } - - private fun updateController(paginatedAppList: PaginatedAppList?) { - binding.recycler - .withModels { - setFilterDuplicates(true) - if (paginatedAppList == null) { - for (i in 1..6) { - add( - AppListViewShimmerModel_() - .id(i) - ) - } - } else { - add( - HeaderViewModel_() - .id("header") - .title(getString(R.string.title_apps_sale_provider)) - ) - - paginatedAppList.appList - .filter { it.packageName.isNotEmpty() } - .forEach { - add( - AppListViewModel_() - .id(it.packageName.hashCode()) - .app(it) - .click { _ -> openDetailsFragment(it.packageName, it) } - ) - setFilterDuplicates(true) - } - - if (paginatedAppList.hasMore) { - add( - AppProgressViewModel_() - .id("progress") - ) - } - - if (!paginatedAppList.hasMore && paginatedAppList.appList.isEmpty()) { - add( - NoAppViewModel_() - .id("no_app_sale") - .icon(R.drawable.ic_apps) - .message(getString(R.string.details_no_apps_on_sale)) - ) - } - } - } - } -} diff --git a/app/src/main/java/com/aurora/store/viewmodel/sale/AppSalesViewModel.kt b/app/src/main/java/com/aurora/store/viewmodel/sale/AppSalesViewModel.kt deleted file mode 100644 index e7b7bb911..000000000 --- a/app/src/main/java/com/aurora/store/viewmodel/sale/AppSalesViewModel.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Aurora Store - * Copyright (C) 2021, Rahul Kumar Patel - * - * 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 . - * - */ - -package com.aurora.store.viewmodel.sale - -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.AppSalesHelper -import com.aurora.store.data.model.PaginatedAppList -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 AppSalesViewModel @Inject constructor( - @ApplicationContext private val context: Context, - private val authProvider: AuthProvider -) : ViewModel() { - - private val appSalesHelper: AppSalesHelper = AppSalesHelper(authProvider.authData) - .using(HttpClient.getPreferredClient(context)) - - private var page: Int = 0 - private val appList: MutableList = mutableListOf() - - val liveData: MutableLiveData = MutableLiveData() - - init { - observe() - } - - fun observe() { - viewModelScope.launch(Dispatchers.IO) { - supervisorScope { - try { - val nextAppList = getSearchResults() - - if (nextAppList.isEmpty()) { - liveData.postValue( - PaginatedAppList( - appList, - hasMore = false - ) - ) - } else { - appList.addAll(nextAppList) - liveData.postValue( - PaginatedAppList( - appList, - hasMore = true - ) - ) - } - - } catch (_: Exception) { - } - } - } - } - - private fun getSearchResults(): List { - return try { - appSalesHelper.getAppsOnSale(page = page++, offer = 100) - } catch (e: Exception) { - e.printStackTrace() - emptyList() - } - } -} diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index e3621f9fa..29974aa58 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -29,9 +29,6 @@ - @@ -78,11 +75,6 @@ android:name="com.aurora.store.view.ui.all.AppsGamesFragment" android:label="@string/title_apps_games" tools:layout="@layout/fragment_generic_with_pager" /> - - - - -