Adjust snackbar durations (closes #5932)

This commit is contained in:
arkon 2021-09-18 16:17:07 -04:00
parent d7d46f4447
commit 0ec7121b8f
3 changed files with 6 additions and 4 deletions

View File

@ -195,7 +195,7 @@ class CategoryController :
(activity as? MainActivity)?.binding?.rootCoordinator!!, (activity as? MainActivity)?.binding?.rootCoordinator!!,
R.string.snack_categories_deleted, R.string.snack_categories_deleted,
R.string.action_undo, R.string.action_undo,
3000 4000
) )
mode.finish() mode.finish()

View File

@ -612,6 +612,9 @@ class MangaController :
*/ */
private fun toggleFavorite() { private fun toggleFavorite() {
val isNowFavorite = presenter.toggleFavorite() val isNowFavorite = presenter.toggleFavorite()
if (isNowFavorite) {
addSnackbar?.dismiss()
}
if (activity != null && !isNowFavorite && presenter.hasDownloads()) { if (activity != null && !isNowFavorite && presenter.hasDownloads()) {
(activity as? MainActivity)?.binding?.rootCoordinator?.snack(activity!!.getString(R.string.delete_downloads_for_manga)) { (activity as? MainActivity)?.binding?.rootCoordinator?.snack(activity!!.getString(R.string.delete_downloads_for_manga)) {
setAction(R.string.action_delete) { setAction(R.string.action_delete) {
@ -619,7 +622,6 @@ class MangaController :
} }
} }
} }
mangaInfoAdapter?.notifyDataSetChanged() mangaInfoAdapter?.notifyDataSetChanged()
} }
@ -1115,7 +1117,7 @@ class MangaController :
val manga = presenter.manga val manga = presenter.manga
presenter.downloadChapters(chapters) presenter.downloadChapters(chapters)
if (view != null && !manga.favorite) { if (view != null && !manga.favorite) {
addSnackbar = (activity as? MainActivity)?.binding?.rootCoordinator?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) { addSnackbar = (activity as? MainActivity)?.binding?.rootCoordinator?.snack(view.context.getString(R.string.snack_add_to_library)) {
setAction(R.string.action_add) { setAction(R.string.action_add) {
if (!manga.favorite) { if (!manga.favorite) {
addToLibrary(manga) addToLibrary(manga)

View File

@ -49,7 +49,7 @@ fun View.getCoordinates() = Point((left + right) / 2, (top + bottom) / 2)
*/ */
inline fun View.snack( inline fun View.snack(
message: String, message: String,
length: Int = Snackbar.LENGTH_LONG, length: Int = 10_000,
f: Snackbar.() -> Unit = {} f: Snackbar.() -> Unit = {}
): Snackbar { ): Snackbar {
val snack = Snackbar.make(this, message, length) val snack = Snackbar.make(this, message, length)