Dismiss add manga snackbar when leaving controller (closes #3614)

This commit is contained in:
arkon 2020-08-06 19:05:07 -04:00
parent b1fb401f63
commit dda7e677a5

View File

@ -130,14 +130,15 @@ class MangaController :
private var chaptersHeaderAdapter: MangaChaptersHeaderAdapter? = null private var chaptersHeaderAdapter: MangaChaptersHeaderAdapter? = null
private var chaptersAdapter: ChaptersAdapter? = null private var chaptersAdapter: ChaptersAdapter? = null
/** // Sheet containing filter/sort/display items.
* Sheet containing filter/sort/display items.
*/
private var settingsSheet: ChaptersSettingsSheet? = null private var settingsSheet: ChaptersSettingsSheet? = null
private var actionFab: ExtendedFloatingActionButton? = null private var actionFab: ExtendedFloatingActionButton? = null
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
// Snackbar to add manga to library after downloading chapter(s)
private var addSnackbar: Snackbar? = null
/** /**
* Action mode for multiple selection. * Action mode for multiple selection.
*/ */
@ -316,6 +317,7 @@ class MangaController :
chaptersHeaderAdapter = null chaptersHeaderAdapter = null
chaptersAdapter = null chaptersAdapter = null
settingsSheet = null settingsSheet = null
addSnackbar?.dismiss()
updateToolbarTitleAlpha(255) updateToolbarTitleAlpha(255)
super.onDestroyView(view) super.onDestroyView(view)
} }
@ -891,7 +893,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) {
activity!!.root_coordinator?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) { addSnackbar = activity!!.root_coordinator?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
setAction(R.string.action_add) { setAction(R.string.action_add) {
addToLibrary(manga) addToLibrary(manga)
} }