From d750930b7a89cbc1babb0259b7123061fe48bbf2 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sun, 29 Oct 2023 11:00:27 +0530 Subject: [PATCH] show toast if download is greater than 0 --- .../dashboard/DashboardActivity.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt index 104756d..02b1df6 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt @@ -66,11 +66,14 @@ class DashboardActivity : AppCompatActivity() { val firebaseAppDistribution = FirebaseAppDistribution.getInstance() firebaseAppDistribution.updateIfNewReleaseAvailable() .addOnProgressListener { updateProgress -> - Toast.makeText( - this, - "${updateProgress.updateStatus}. ${updateProgress.apkBytesDownloaded / 1048576} /${updateProgress.apkFileTotalBytes / 1048576} MB", - Toast.LENGTH_SHORT - ).show() + + if (updateProgress.apkBytesDownloaded > 0) { + Toast.makeText( + this, + "${updateProgress.updateStatus}. ${updateProgress.apkBytesDownloaded / 1048576} /${updateProgress.apkFileTotalBytes / 1048576} MB", + Toast.LENGTH_SHORT + ).show() + } } .addOnFailureListener { e -> // (Optional) Handle errors. @@ -82,7 +85,11 @@ class DashboardActivity : AppCompatActivity() { else -> { // Handle other errors. - Toast.makeText(this, "AppDistribution error, status: ${e.errorCode}", Toast.LENGTH_SHORT).show() + Toast.makeText( + this, + "AppDistribution error, status: ${e.errorCode}", + Toast.LENGTH_SHORT + ).show() } } FirebaseCrashlytics.getInstance().recordException(e)