From 981774dce3348514b3ebc4a582a0dff92e51ce6d Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 31 Oct 2023 17:11:08 +0530 Subject: [PATCH] EarlyAccess*: Drop unused fragment and viewmodel classes Signed-off-by: Aayush Gupta --- .../view/ui/commons/EarlyAccessFragment.kt | 139 ------------------ .../homestream/EarlyAccessViewModel.kt | 45 ------ 2 files changed, 184 deletions(-) delete mode 100644 app/src/main/java/com/aurora/store/view/ui/commons/EarlyAccessFragment.kt delete mode 100644 app/src/main/java/com/aurora/store/viewmodel/homestream/EarlyAccessViewModel.kt diff --git a/app/src/main/java/com/aurora/store/view/ui/commons/EarlyAccessFragment.kt b/app/src/main/java/com/aurora/store/view/ui/commons/EarlyAccessFragment.kt deleted file mode 100644 index d63e1fbe6..000000000 --- a/app/src/main/java/com/aurora/store/view/ui/commons/EarlyAccessFragment.kt +++ /dev/null @@ -1,139 +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.commons - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.Toast -import androidx.lifecycle.ViewModelProvider -import com.aurora.Constants -import com.aurora.gplayapi.data.models.App -import com.aurora.gplayapi.data.models.StreamBundle -import com.aurora.gplayapi.data.models.StreamCluster -import com.aurora.store.R -import com.aurora.store.data.ViewState -import com.aurora.store.databinding.FragmentForYouBinding -import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener -import com.aurora.store.view.epoxy.controller.EarlyAccessCarouselController -import com.aurora.store.view.epoxy.controller.GenericCarouselController -import com.aurora.store.viewmodel.homestream.BaseClusterViewModel -import com.aurora.store.viewmodel.homestream.EarlyAccessAppsViewModel -import com.aurora.store.viewmodel.homestream.EarlyAccessGamesViewModel - - -class EarlyAccessFragment : BaseFragment(), GenericCarouselController.Callbacks { - - private lateinit var B: FragmentForYouBinding - private lateinit var C: GenericCarouselController - private lateinit var VM: BaseClusterViewModel - - private var pageType = 0 - - companion object { - @JvmStatic - fun newInstance(pageType: Int): EarlyAccessFragment { - return EarlyAccessFragment().apply { - arguments = Bundle().apply { - putInt(Constants.PAGE_TYPE, pageType) - } - } - } - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - B = FragmentForYouBinding.bind( - inflater.inflate( - R.layout.fragment_for_you, - container, - false - ) - ) - - C = EarlyAccessCarouselController(this) - - val bundle = arguments - if (bundle != null) { - pageType = bundle.getInt(Constants.PAGE_TYPE, 0) - } - - when (pageType) { - 0 -> VM = ViewModelProvider(this)[EarlyAccessAppsViewModel::class.java] - 1 -> VM = ViewModelProvider(this)[EarlyAccessGamesViewModel::class.java] - } - - return B.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - B.recycler.setController(C) - - VM.liveData.observe(viewLifecycleOwner) { - when (it) { - is ViewState.Empty -> { - } - is ViewState.Loading -> { - } - is ViewState.Error -> { - } - is ViewState.Success<*> -> { - updateController(it.data as StreamBundle) - } - else -> { - - } - } - } - - B.recycler.addOnScrollListener(object : EndlessRecyclerOnScrollListener() { - override fun onLoadMore(currentPage: Int) { - VM.observe() - } - }) - } - - private fun updateController(streamBundle: StreamBundle) { - C.setData(streamBundle) - } - - override fun onHeaderClicked(streamCluster: StreamCluster) { - if (streamCluster.clusterBrowseUrl.isNotEmpty()) - openStreamBrowseFragment(streamCluster.clusterBrowseUrl) - } - - override fun onClusterScrolled(streamCluster: StreamCluster) { - VM.observeCluster(streamCluster) - } - - override fun onAppClick(app: App) { - openDetailsFragment(app.packageName, app) - } - - override fun onAppLongClick(app: App) { - Toast.makeText(requireContext(), app.displayName, Toast.LENGTH_SHORT).show() - } -} diff --git a/app/src/main/java/com/aurora/store/viewmodel/homestream/EarlyAccessViewModel.kt b/app/src/main/java/com/aurora/store/viewmodel/homestream/EarlyAccessViewModel.kt deleted file mode 100644 index 162112b53..000000000 --- a/app/src/main/java/com/aurora/store/viewmodel/homestream/EarlyAccessViewModel.kt +++ /dev/null @@ -1,45 +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.homestream - -import android.app.Application -import com.aurora.gplayapi.helpers.StreamHelper -import com.aurora.store.data.ViewState - -class EarlyAccessAppsViewModel(application: Application) : BaseClusterViewModel(application) { - - init { - category = StreamHelper.Category.APPLICATION - type = StreamHelper.Type.EARLY_ACCESS - liveData.postValue(ViewState.Loading) - observe() - } -} - -class EarlyAccessGamesViewModel(application: Application) : - BaseClusterViewModel(application) { - - init { - category = StreamHelper.Category.GAME - type = StreamHelper.Type.EARLY_ACCESS - liveData.postValue(ViewState.Loading) - observe() - } -} \ No newline at end of file