update without app distribution done

This commit is contained in:
chandrashekhar reddy
2024-02-27 14:18:46 +05:30
parent 97cc281752
commit c48c5a1ae3

View File

@@ -1,5 +1,6 @@
package com.example.hpostesting.presentation.dashboard
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.app.DownloadManager
import android.content.BroadcastReceiver
@@ -1049,6 +1050,7 @@ class HomeFragment : Fragment() {
val matchResult = regex.find(receivedData)
return matchResult?.groups?.get(1)?.value ?: ""
}
@SuppressLint("SuspiciousIndentation")
private fun checkForUpdate() {
try {
val db = Firebase.firestore
@@ -1076,10 +1078,11 @@ class HomeFragment : Fragment() {
val globalUpdateIgnore = documentIn!!.globalUpdateIgnore
val deviceUpdateAvailable = documentIn.deviceUpdateAvailable
val globalUpdateDone = documentIn.globalUpdateDone
val updatePath = documentIn.updatePath
if(globalUpdateIgnore){
if(deviceUpdateAvailable){
val update = db.collection("devices").document(it.id).update("deviceUpdateAvailable","false")
val update = db.collection("devices").document(it.id).update("deviceUpdateAvailable",false)
update.addOnSuccessListener {
Log.d("HomeFragmentUpdate","Device local update done")
@@ -1091,13 +1094,15 @@ class HomeFragment : Fragment() {
Log.d("HomeFragmentUpdate","Device update not available")
}
}else{
val update = db.collection("devices").document(it.id).update("globalUpdateDone","true")
update.addOnSuccessListener {
Log.d("HomeFragmentUpdate","Device global update done")
if(!globalUpdateDone){
val update = db.collection("devices").document(it.id).update("globalUpdateDone",true)
update.addOnSuccessListener {
Log.d("HomeFragmentUpdate","Device global update done")
initiateUpdate(updatePathGlobal)
}.addOnFailureListener{
Log.e("fetchDeviceUpdate", "update fail.")
initiateUpdate(updatePathGlobal)
}.addOnFailureListener{
Log.e("fetchDeviceUpdate", "update fail.")
}
}
}
}