From 23230ddeb7f9ff0cfb872584ca0bcee151c86ef6 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 3 May 2020 01:00:52 -0400 Subject: [PATCH] Cancel library update from updating library snackbar --- .../kanade/tachiyomi/ui/library/LibraryController.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 6aed3cff02..3e1d0448ab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -5,6 +5,7 @@ import android.app.Activity import android.content.Context import android.graphics.Color import android.os.Bundle +import android.os.Handler import android.util.TypedValue import android.view.LayoutInflater import android.view.Menu @@ -42,6 +43,8 @@ import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.DownloadService import eu.kanade.tachiyomi.data.library.LibraryServiceListener import eu.kanade.tachiyomi.data.library.LibraryUpdateService +import eu.kanade.tachiyomi.data.notification.NotificationReceiver +import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.ui.base.controller.BaseController @@ -462,6 +465,10 @@ class LibraryController( LibraryUpdateService.start(view.context, category) snack = view.snack(R.string.updating_library) { anchorView = filter_bottom_sheet + setAction(R.string.cancel) { + LibraryUpdateService.stop(context) + Handler().post { NotificationReceiver.dismissNotification(context, Notifications.ID_LIBRARY_PROGRESS) } + } } } @@ -913,6 +920,10 @@ class LibraryController( ), Snackbar.LENGTH_LONG ) { anchorView = filter_bottom_sheet + setAction(R.string.cancel) { + LibraryUpdateService.stop(context) + Handler().post { NotificationReceiver.dismissNotification(context, Notifications.ID_LIBRARY_PROGRESS) } + } } if (!inQueue) LibraryUpdateService.start(view!!.context, category) return true