Skip to content

Commit

Permalink
sync: smoother download dialog (fixes #3253) (#3256)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Mar 15, 2024
1 parent 94927ef commit 914cf2b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1419
versionName "0.14.19"
versionCode 1420
versionName "0.14.20"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ole.planet.myplanet.ui.sync

import android.app.Dialog
import android.app.ProgressDialog
import android.content.BroadcastReceiver
import android.content.Context
Expand Down Expand Up @@ -60,15 +61,29 @@ abstract class ProcessUserDataActivity : PermissionActivity(), SuccessListener {
}

fun checkDownloadResult(download: Download?, progressDialog: ProgressDialog?) {
if (!download?.failed!!) {
progressDialog?.setMessage("${getString(R.string.downloading)}${download.progress}% ${getString(R.string.complete)}")
if (download.completeAll) {
progressDialog?.dismiss()
installApk(this, download.fileUrl)
progressDialog?.let { pd ->
if (download != null && !isFinishing) {
if (!download.failed) {
pd.setMessage("${getString(R.string.downloading)}${download.progress}% ${getString(R.string.complete)}")
if (download.completeAll) {
safelyDismissDialog(pd)
installApk(this, download.fileUrl)
}
} else {
safelyDismissDialog(pd)
showError(progressDialog, download.message)
}
}
}
}

private fun safelyDismissDialog(dialog: Dialog) {
if (dialog.isShowing && !isFinishing) {
try {
dialog.dismiss()
} catch (e: IllegalArgumentException) {
e.printStackTrace()
}
} else {
progressDialog?.dismiss()
showError(progressDialog, download.message)
}
}

Expand Down Expand Up @@ -140,9 +155,7 @@ abstract class ProcessUserDataActivity : PermissionActivity(), SuccessListener {
progressDialog?.setMessage(getString(R.string.uploading_data_to_server_please_wait))
progressDialog?.show()
Utilities.log("Upload : upload started")
UploadToShelfService.instance?.uploadUserData {
UploadToShelfService.instance?.uploadHealth()
}
UploadToShelfService.instance?.uploadUserData { UploadToShelfService.instance?.uploadHealth() }
UploadManager.instance?.uploadUserActivities(this)
UploadManager.instance?.uploadExamResult(this)
UploadManager.instance?.uploadFeedback(this)
Expand Down

0 comments on commit 914cf2b

Please sign in to comment.