Fixed app crashing between android version 5.0 and 5.1

This commit is contained in:
tom5079
2020-08-02 17:45:24 +09:00
parent 132b3b9be1
commit 828d3de020
5 changed files with 8 additions and 8 deletions

View File

@@ -130,7 +130,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
* Float.POSITIVE_INFINITY -> Download completed
*/
val progress = SparseArray<MutableList<Float>?>()
val notification = SparseArray<NotificationCompat.Builder>()
val notification = SparseArray<NotificationCompat.Builder?>()
private val loop = loop()
private val worker = SparseArray<Job?>()
@@ -255,7 +255,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
if (notification[galleryID] == null)
initNotification(galleryID)
notification[galleryID].setContentTitle(reader.galleryInfo.title)
notification[galleryID]?.setContentTitle(reader.galleryInfo.title)
notify(galleryID)
if (isCompleted(galleryID)) {
@@ -345,7 +345,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
?.setContentText("$progress/$max")
if (Cache(this).isDownloading(galleryID) && notification[galleryID] != null)
notificationManager.notify(galleryID, notification[galleryID].build())
notification[galleryID]?.let { notificationManager.notify(galleryID, it.build()) }
else
notificationManager.cancel(galleryID)
}
@@ -383,7 +383,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
initNotification(galleryID)
if (Cache(this@DownloadWorker).isDownloading(galleryID))
notificationManager.notify(galleryID, notification[galleryID].build())
notification[galleryID]?.let { notificationManager.notify(galleryID, it.build()) }
worker.put(galleryID, download(galleryID))
queue.poll()