From 17bca48ef846b75882738cc3701028c2d6bac94e Mon Sep 17 00:00:00 2001 From: l2zh Date: Mon, 29 Jan 2024 22:55:00 +0900 Subject: [PATCH] =?UTF-8?q?#121=20/=20updateSparkle()=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 15 +++++++------- .../presentation/home/UpdateDialogFragment.kt | 20 ++++++++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 4e2d52b..5acfade 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,10 +1,9 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/app/src/main/java/sopt/uni/presentation/home/UpdateDialogFragment.kt b/app/src/main/java/sopt/uni/presentation/home/UpdateDialogFragment.kt index a7f6a04..ae07702 100644 --- a/app/src/main/java/sopt/uni/presentation/home/UpdateDialogFragment.kt +++ b/app/src/main/java/sopt/uni/presentation/home/UpdateDialogFragment.kt @@ -8,6 +8,7 @@ import androidx.activity.result.contract.ActivityResultContracts import com.google.android.play.core.appupdate.AppUpdateManager import com.google.android.play.core.appupdate.AppUpdateOptions import com.google.android.play.core.install.model.AppUpdateType +import com.google.android.play.core.install.model.UpdateAvailability import dagger.hilt.android.AndroidEntryPoint import sopt.uni.R import sopt.uni.data.datasource.local.SparkleStorage @@ -15,6 +16,7 @@ import sopt.uni.databinding.TitleAction2DialogBinding import sopt.uni.util.binding.BindingDialogFragment import sopt.uni.util.extension.setOnSingleClickListener import sopt.uni.util.extension.showSnackbar +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -45,11 +47,19 @@ class UpdateDialogFragment : } private fun updateSparkle() { - appUpdateManager.startUpdateFlowForResult( - appUpdateManager.appUpdateInfo.result, - startForResult, - AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build(), - ) + appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo -> + if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && + appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) + ) { + appUpdateManager.startUpdateFlowForResult( + appUpdateInfo, + startForResult, + AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build(), + ) + } + }.addOnFailureListener { + Timber.tag("updateSparkleFail").e("업뎃실패ㅠ") + } } private val startForResult =