Skip to content

Commit

Permalink
#121 / updateSparkle() 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
l2zh authored and taeheeL committed Feb 18, 2024
1 parent e982c2a commit fd733d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
15 changes: 7 additions & 8 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ 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
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
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit fd733d0

Please sign in to comment.