mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 13:08:56 +01:00
Now uses glide for notification
This commit is contained in:
@@ -47,8 +47,6 @@ class DownloadManager(
|
||||
private val threadsSubject = BehaviorSubject.create<Int>()
|
||||
private var threadsSubscription: Subscription? = null
|
||||
|
||||
private var notificationSubscription: Subscription? = null
|
||||
|
||||
val queue = DownloadQueue()
|
||||
|
||||
val imageFilenameRegex = "[^\\sa-zA-Z0-9.-]".toRegex()
|
||||
@@ -68,12 +66,6 @@ class DownloadManager(
|
||||
downloadNotifier.multipleDownloadThreads = it > 1
|
||||
}
|
||||
|
||||
notificationSubscription = preferences.showMangaDownloadNotification().asObservable()
|
||||
.subscribe {
|
||||
downloadNotifier.onClear()
|
||||
downloadNotifier.showNotification = it
|
||||
}
|
||||
|
||||
downloadsSubscription = downloadsQueueSubject.flatMap { Observable.from(it) }
|
||||
.lift(DynamicConcurrentMergeOperator<Download, Download>({ downloadChapter(it) }, threadsSubject))
|
||||
.onBackpressureBuffer()
|
||||
@@ -115,10 +107,6 @@ class DownloadManager(
|
||||
threadsSubscription?.unsubscribe()
|
||||
}
|
||||
|
||||
if (notificationSubscription != null) {
|
||||
notificationSubscription?.unsubscribe()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create a download object for every chapter and add them to the downloads queue
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package eu.kanade.tachiyomi.data.download
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import eu.kanade.tachiyomi.Constants
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.decodeSampledBitmap
|
||||
import eu.kanade.tachiyomi.util.notificationManager
|
||||
import java.io.File
|
||||
|
||||
@@ -61,8 +64,27 @@ class ImageNotifier(private val context: Context) {
|
||||
}
|
||||
setContentTitle(context.getString(R.string.picture_saved))
|
||||
setSmallIcon(R.drawable.ic_insert_photo_black_24dp)
|
||||
setLargeIcon(file.decodeSampledBitmap(100, 100))
|
||||
setStyle(NotificationCompat.BigPictureStyle().bigPicture(file.decodeSampledBitmap(1024, 1024)))
|
||||
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(100, 100) {
|
||||
/**
|
||||
* The method that will be called when the resource load has finished.
|
||||
* @param resource the loaded resource.
|
||||
*/
|
||||
override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {
|
||||
setLargeIcon(resource)
|
||||
context.notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
})
|
||||
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(512, 384) {
|
||||
/**
|
||||
* The method that will be called when the resource load has finished.
|
||||
* @param resource the loaded resource.
|
||||
*/
|
||||
override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {
|
||||
setStyle(NotificationCompat.BigPictureStyle().bigPicture(resource))
|
||||
context.notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
})
|
||||
|
||||
setAutoCancel(true)
|
||||
|
||||
// Clear old actions if they exist
|
||||
|
||||
@@ -72,10 +72,6 @@ class PreferenceKeys(context: Context) {
|
||||
|
||||
val removeAfterMarkedAsRead = context.getString(R.string.pref_remove_after_marked_as_read_key)
|
||||
|
||||
val showMangaDownloadNotification = context.getString(R.string.pref_notifications_manga_download_key)
|
||||
|
||||
val showSavePageNotification = context.getString(R.string.pref_notifications_single_page_key)
|
||||
|
||||
val libraryUpdateInterval = context.getString(R.string.pref_library_update_interval_key)
|
||||
|
||||
val libraryUpdateRestriction = context.getString(R.string.pref_library_update_restriction_key)
|
||||
|
||||
@@ -122,10 +122,6 @@ class PreferencesHelper(context: Context) {
|
||||
|
||||
fun removeAfterMarkedAsRead() = prefs.getBoolean(keys.removeAfterMarkedAsRead, false)
|
||||
|
||||
fun showMangaDownloadNotification() = rxPrefs.getBoolean(keys.showMangaDownloadNotification, true)
|
||||
|
||||
fun showSavePageNotification() = prefs.getBoolean(keys.showSavePageNotification, false)
|
||||
|
||||
fun libraryUpdateInterval() = rxPrefs.getInteger(keys.libraryUpdateInterval, 0)
|
||||
|
||||
fun libraryUpdateRestriction() = prefs.getStringSet(keys.libraryUpdateRestriction, emptySet())
|
||||
|
||||
Reference in New Issue
Block a user