From 41c53fabc4637663d77965a89523406cdbdb8343 Mon Sep 17 00:00:00 2001 From: Sohyun Date: Sat, 9 Nov 2024 16:43:01 +0900 Subject: [PATCH] #103 [FIX] : set up install update listener --- .../main/java/com/teamwable/main/MainActivity.kt | 16 ++++++++++++---- feature/main/src/main/res/values/strings.xml | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/feature/main/src/main/java/com/teamwable/main/MainActivity.kt b/feature/main/src/main/java/com/teamwable/main/MainActivity.kt index d17644c7..2bf687b3 100644 --- a/feature/main/src/main/java/com/teamwable/main/MainActivity.kt +++ b/feature/main/src/main/java/com/teamwable/main/MainActivity.kt @@ -57,10 +57,12 @@ class MainActivity : AppCompatActivity(), Navigation { } private val installStateUpdatedListener = InstallStateUpdatedListener { state -> - if (state.installStatus() == InstallStatus.DOWNLOADED) Timber.i("Download Complete") - lifecycleScope.launch { - delay(5000) - appUpdateManager.completeUpdate() + if (state.installStatus() == InstallStatus.DOWNLOADED) { + Timber.i("Download Complete") + lifecycleScope.launch { + delay(5000) + appUpdateManager.completeUpdate() + } } } @@ -74,7 +76,13 @@ class MainActivity : AppCompatActivity(), Navigation { requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT } + override fun onDestroy() { + super.onDestroy() + appUpdateManager.unregisterListener(installStateUpdatedListener) + } + private fun setInAppUpdate() { + appUpdateManager.registerListener(installStateUpdatedListener) appUpdateHelper = AppUpdateHandler(appUpdateManager).apply { checkForAppUpdate { appUpdateInfo -> showUpdateDialog(appUpdateInfo) } } diff --git a/feature/main/src/main/res/values/strings.xml b/feature/main/src/main/res/values/strings.xml index edd6ce1d..22e5444a 100644 --- a/feature/main/src/main/res/values/strings.xml +++ b/feature/main/src/main/res/values/strings.xml @@ -18,5 +18,5 @@ 와블이 새롭게 업그레이드 되었어요. 업데이트를 통해 최신 버전으로 즐겨보세요. 업데이트 하기 다음에 - 업데이트 중 입니다. + 업데이트 진행 중 : 화면 이탈 시 업데이트가 취소 될 수 있습니다.