Loading app/src/main/java/foundation/e/apps/MainActivity.kt +5 −5 Original line number Diff line number Diff line Loading @@ -202,11 +202,6 @@ class MainActivity : AppCompatActivity() { viewModel.isAppPurchased.observe(this) { if (it.isNotEmpty()) { startInstallationOfPurchasedApp(viewModel, it) ApplicationDialogFragment( title = getString(R.string.purchase_complete), message = getString(R.string.download_automatically_message), positiveButtonText = getString(R.string.ok) ).show(supportFragmentManager, TAG) } } Loading Loading @@ -252,6 +247,11 @@ class MainActivity : AppCompatActivity() { val fusedDownload = viewModel.updateAwaitingForPurchasedApp(it) if (fusedDownload != null) { InstallWorkManager.enqueueWork(fusedDownload) ApplicationDialogFragment( title = getString(R.string.purchase_complete), message = getString(R.string.download_automatically_message), positiveButtonText = getString(R.string.ok) ).show(supportFragmentManager, TAG) } else { ApplicationDialogFragment( title = getString(R.string.purchase_error), Loading app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -297,10 +297,10 @@ class MainActivityViewModel @Inject constructor( fusedDownload ) } catch (e: ApiException.AppNotPurchased) { Log.e(TAG, e.stackTraceToString()) e.printStackTrace() return null } catch (e: Exception) { Log.e(TAG, e.stackTraceToString()) e.printStackTrace() _errorMessage.value = e return null } Loading app/src/main/java/foundation/e/apps/applicationlist/model/ApplicationListRVAdapter.kt +17 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import android.view.ViewGroup import android.widget.ImageView import androidx.core.content.ContextCompat import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.navigation.findNavController import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView Loading Loading @@ -78,7 +80,9 @@ class ApplicationListRVAdapter( .build() inner class ViewHolder(val binding: ApplicationListItemBinding) : RecyclerView.ViewHolder(binding.root) RecyclerView.ViewHolder(binding.root) { var isPurchasedLiveData: LiveData<Boolean> = MutableLiveData() } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { return ViewHolder( Loading Loading @@ -160,6 +164,7 @@ class ApplicationListRVAdapter( } else -> Log.wtf(TAG, "${searchApp.package_name} is from an unknown origin") } removeIsPurchasedObserver(holder) when (searchApp.status) { Status.INSTALLED -> { handleInstalled(view, searchApp) Loading @@ -168,7 +173,7 @@ class ApplicationListRVAdapter( handleUpdatable(view, searchApp) } Status.UNAVAILABLE -> { handleUnavailable(view, searchApp) handleUnavailable(view, searchApp, holder) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> { handleDownloading(view, searchApp) Loading @@ -188,6 +193,10 @@ class ApplicationListRVAdapter( } } private fun removeIsPurchasedObserver(holder: ViewHolder) { holder.isPurchasedLiveData.removeObservers(lifecycleOwner) } private fun ApplicationListItemBinding.handleInstallationIssue( view: View, searchApp: FusedApp, Loading Loading @@ -308,9 +317,10 @@ class ApplicationListRVAdapter( private fun ApplicationListItemBinding.handleUnavailable( view: View, searchApp: FusedApp, holder: ViewHolder, ) { installButton.apply { updateUIByPaymentType(searchApp, this, this@handleUnavailable) updateUIByPaymentType(searchApp, this, this@handleUnavailable, holder) setTextColor(context.getColor(R.color.colorAccent)) backgroundTintList = ContextCompat.getColorStateList(view.context, android.R.color.transparent) Loading @@ -331,7 +341,8 @@ class ApplicationListRVAdapter( private fun updateUIByPaymentType( searchApp: FusedApp, materialButton: MaterialButton, applicationListItemBinding: ApplicationListItemBinding applicationListItemBinding: ApplicationListItemBinding, holder: ViewHolder ) { when { mainActivityViewModel.checkUnsupportedApplication(searchApp) -> { Loading @@ -347,7 +358,8 @@ class ApplicationListRVAdapter( materialButton.isEnabled = false materialButton.text = "" applicationListItemBinding.progressBarInstall.visibility = View.VISIBLE appInfoFetchViewModel.isAppPurchased(searchApp).observe(lifecycleOwner) { holder.isPurchasedLiveData = appInfoFetchViewModel.isAppPurchased(searchApp) holder.isPurchasedLiveData.observe(lifecycleOwner) { materialButton.isEnabled = true applicationListItemBinding.progressBarInstall.visibility = View.GONE materialButton.text = Loading Loading
app/src/main/java/foundation/e/apps/MainActivity.kt +5 −5 Original line number Diff line number Diff line Loading @@ -202,11 +202,6 @@ class MainActivity : AppCompatActivity() { viewModel.isAppPurchased.observe(this) { if (it.isNotEmpty()) { startInstallationOfPurchasedApp(viewModel, it) ApplicationDialogFragment( title = getString(R.string.purchase_complete), message = getString(R.string.download_automatically_message), positiveButtonText = getString(R.string.ok) ).show(supportFragmentManager, TAG) } } Loading Loading @@ -252,6 +247,11 @@ class MainActivity : AppCompatActivity() { val fusedDownload = viewModel.updateAwaitingForPurchasedApp(it) if (fusedDownload != null) { InstallWorkManager.enqueueWork(fusedDownload) ApplicationDialogFragment( title = getString(R.string.purchase_complete), message = getString(R.string.download_automatically_message), positiveButtonText = getString(R.string.ok) ).show(supportFragmentManager, TAG) } else { ApplicationDialogFragment( title = getString(R.string.purchase_error), Loading
app/src/main/java/foundation/e/apps/MainActivityViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -297,10 +297,10 @@ class MainActivityViewModel @Inject constructor( fusedDownload ) } catch (e: ApiException.AppNotPurchased) { Log.e(TAG, e.stackTraceToString()) e.printStackTrace() return null } catch (e: Exception) { Log.e(TAG, e.stackTraceToString()) e.printStackTrace() _errorMessage.value = e return null } Loading
app/src/main/java/foundation/e/apps/applicationlist/model/ApplicationListRVAdapter.kt +17 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import android.view.ViewGroup import android.widget.ImageView import androidx.core.content.ContextCompat import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.navigation.findNavController import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView Loading Loading @@ -78,7 +80,9 @@ class ApplicationListRVAdapter( .build() inner class ViewHolder(val binding: ApplicationListItemBinding) : RecyclerView.ViewHolder(binding.root) RecyclerView.ViewHolder(binding.root) { var isPurchasedLiveData: LiveData<Boolean> = MutableLiveData() } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { return ViewHolder( Loading Loading @@ -160,6 +164,7 @@ class ApplicationListRVAdapter( } else -> Log.wtf(TAG, "${searchApp.package_name} is from an unknown origin") } removeIsPurchasedObserver(holder) when (searchApp.status) { Status.INSTALLED -> { handleInstalled(view, searchApp) Loading @@ -168,7 +173,7 @@ class ApplicationListRVAdapter( handleUpdatable(view, searchApp) } Status.UNAVAILABLE -> { handleUnavailable(view, searchApp) handleUnavailable(view, searchApp, holder) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING -> { handleDownloading(view, searchApp) Loading @@ -188,6 +193,10 @@ class ApplicationListRVAdapter( } } private fun removeIsPurchasedObserver(holder: ViewHolder) { holder.isPurchasedLiveData.removeObservers(lifecycleOwner) } private fun ApplicationListItemBinding.handleInstallationIssue( view: View, searchApp: FusedApp, Loading Loading @@ -308,9 +317,10 @@ class ApplicationListRVAdapter( private fun ApplicationListItemBinding.handleUnavailable( view: View, searchApp: FusedApp, holder: ViewHolder, ) { installButton.apply { updateUIByPaymentType(searchApp, this, this@handleUnavailable) updateUIByPaymentType(searchApp, this, this@handleUnavailable, holder) setTextColor(context.getColor(R.color.colorAccent)) backgroundTintList = ContextCompat.getColorStateList(view.context, android.R.color.transparent) Loading @@ -331,7 +341,8 @@ class ApplicationListRVAdapter( private fun updateUIByPaymentType( searchApp: FusedApp, materialButton: MaterialButton, applicationListItemBinding: ApplicationListItemBinding applicationListItemBinding: ApplicationListItemBinding, holder: ViewHolder ) { when { mainActivityViewModel.checkUnsupportedApplication(searchApp) -> { Loading @@ -347,7 +358,8 @@ class ApplicationListRVAdapter( materialButton.isEnabled = false materialButton.text = "" applicationListItemBinding.progressBarInstall.visibility = View.VISIBLE appInfoFetchViewModel.isAppPurchased(searchApp).observe(lifecycleOwner) { holder.isPurchasedLiveData = appInfoFetchViewModel.isAppPurchased(searchApp) holder.isPurchasedLiveData.observe(lifecycleOwner) { materialButton.isEnabled = true applicationListItemBinding.progressBarInstall.visibility = View.GONE materialButton.text = Loading