Skip to content

Commit

Permalink
#103 [FIX] : set up install update listener
Browse files Browse the repository at this point in the history
  • Loading branch information
sohyun127 committed Nov 9, 2024
1 parent 803fc80 commit 41c53fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions feature/main/src/main/java/com/teamwable/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}

Expand All @@ -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) }
}
Expand Down
2 changes: 1 addition & 1 deletion feature/main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
<string name="label_in_app_update_content">와블이 새롭게 업그레이드 되었어요. 업데이트를 통해 최신 버전으로 즐겨보세요.</string>
<string name="label_in_app_update_yes">업데이트 하기</string>
<string name="label_in_app_update_next">다음에</string>
<string name="label_in_app_update_success">업데이트 중 입니다.</string>
<string name="label_in_app_update_success">업데이트 진행 중 : 화면 이탈 시 업데이트가 취소 될 수 있습니다.</string>
</resources>

0 comments on commit 41c53fa

Please sign in to comment.