Update UploadWorker.kt
This commit is contained in:
@@ -36,10 +36,9 @@ class UploadWorker(
|
|||||||
if (response.status.value in 200..299) {
|
if (response.status.value in 200..299) {
|
||||||
showUploadSuccessNotification()
|
showUploadSuccessNotification()
|
||||||
Result.success()
|
Result.success()
|
||||||
} else {
|
} else Result.failure()
|
||||||
Result.failure()
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
Result.failure()
|
Result.failure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,14 +47,8 @@ class UploadWorker(
|
|||||||
val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
val channelId = "upload_success_channel"
|
val channelId = "upload_success_channel"
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
notificationManager.createNotificationChannel(
|
||||||
val channel = NotificationChannel(
|
NotificationChannel(channelId, "Upload Success", NotificationManager.IMPORTANCE_DEFAULT))
|
||||||
channelId,
|
|
||||||
"Upload Success",
|
|
||||||
NotificationManager.IMPORTANCE_DEFAULT
|
|
||||||
)
|
|
||||||
notificationManager.createNotificationChannel(channel)
|
|
||||||
}
|
|
||||||
|
|
||||||
val notification = NotificationCompat.Builder(applicationContext, channelId)
|
val notification = NotificationCompat.Builder(applicationContext, channelId)
|
||||||
.setContentTitle("Upload Successful")
|
.setContentTitle("Upload Successful")
|
||||||
|
|||||||
Reference in New Issue
Block a user