mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 08:09:21 +01:00
Showing a snack item when updating library from recents
so you can now cancel an update from recents as well
This commit is contained in:
parent
b95009052f
commit
ddcd4a51bf
@ -4,6 +4,7 @@ import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
@ -30,6 +31,8 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
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.databinding.RecentsControllerBinding
|
import eu.kanade.tachiyomi.databinding.RecentsControllerBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseCoroutineController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseCoroutineController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
@ -325,6 +328,27 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
||||||
binding.swipeRefresh.setOnRefreshListener {
|
binding.swipeRefresh.setOnRefreshListener {
|
||||||
if (!LibraryUpdateService.isRunning()) {
|
if (!LibraryUpdateService.isRunning()) {
|
||||||
|
snack?.dismiss()
|
||||||
|
snack = view.snack(R.string.updating_library) {
|
||||||
|
anchorView = binding.downloadBottomSheet.root
|
||||||
|
setAction(R.string.cancel) {
|
||||||
|
LibraryUpdateService.stop(context)
|
||||||
|
Handler().post {
|
||||||
|
NotificationReceiver.dismissNotification(
|
||||||
|
context,
|
||||||
|
Notifications.ID_LIBRARY_PROGRESS
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addCallback(
|
||||||
|
object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
|
||||||
|
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
||||||
|
super.onDismissed(transientBottomBar, event)
|
||||||
|
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
LibraryUpdateService.start(view.context)
|
LibraryUpdateService.start(view.context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user