mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 05:25:04 +01:00
Fixed snackbars and dialogs
This commit is contained in:
parent
dace5b4de7
commit
0c81459143
@ -464,6 +464,8 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
override fun onItemMove(fromPosition: Int, toPosition: Int) {
|
override fun onItemMove(fromPosition: Int, toPosition: Int) {
|
||||||
if (lastItemPosition == toPosition)
|
if (lastItemPosition == toPosition)
|
||||||
lastItemPosition = null
|
lastItemPosition = null
|
||||||
|
else if (lastItemPosition == null)
|
||||||
|
lastItemPosition = fromPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemReleased(position: Int) {
|
override fun onItemReleased(position: Int) {
|
||||||
@ -472,6 +474,9 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
|
// if nothing moved
|
||||||
|
if (lastItemPosition == null)
|
||||||
|
return
|
||||||
val item = adapter.getItem(position) as? LibraryItem ?: return
|
val item = adapter.getItem(position) as? LibraryItem ?: return
|
||||||
val newHeader = adapter.getSectionHeader(position) as? LibraryHeaderItem
|
val newHeader = adapter.getSectionHeader(position) as? LibraryHeaderItem
|
||||||
val libraryItems = adapter.getSectionItems(adapter.getSectionHeader(position))
|
val libraryItems = adapter.getSectionItems(adapter.getSectionHeader(position))
|
||||||
@ -482,7 +487,9 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
} else {
|
} else {
|
||||||
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
||||||
adapter.moveItem(position, lastItemPosition!!)
|
adapter.moveItem(position, lastItemPosition!!)
|
||||||
snack = snackbar_layout?.snack(R.string.already_in_category)
|
snack = view?.snack(R.string.already_in_category) {
|
||||||
|
anchorView = bottom_sheet
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (newHeader?.category?.mangaSort == null) {
|
if (newHeader?.category?.mangaSort == null) {
|
||||||
@ -539,13 +546,15 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
return false
|
return false
|
||||||
val inQueue = LibraryUpdateService.categoryInQueue(category.id)
|
val inQueue = LibraryUpdateService.categoryInQueue(category.id)
|
||||||
snack?.dismiss()
|
snack?.dismiss()
|
||||||
snack = snackbar_layout.snack(resources!!.getString(
|
snack = view?.snack(resources!!.getString(
|
||||||
when {
|
when {
|
||||||
inQueue -> R.string.category_already_in_queue
|
inQueue -> R.string.category_already_in_queue
|
||||||
LibraryUpdateService.isRunning() ->
|
LibraryUpdateService.isRunning() ->
|
||||||
R.string.adding_category_to_queue
|
R.string.adding_category_to_queue
|
||||||
else -> R.string.updating_category_x
|
else -> R.string.updating_category_x
|
||||||
}, category.name))
|
}, category.name)) {
|
||||||
|
anchorView = bottom_sheet
|
||||||
|
}
|
||||||
if (!inQueue)
|
if (!inQueue)
|
||||||
LibraryUpdateService.start(view!!.context, category)
|
LibraryUpdateService.start(view!!.context, category)
|
||||||
return true
|
return true
|
||||||
|
@ -90,7 +90,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
pager = pagerView
|
pager = pagerView
|
||||||
val shadow2:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
|
val shadow2:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
|
||||||
val shadow:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow)
|
val shadow:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow)
|
||||||
val snackbarLayout:View = (pagerView.parent as ViewGroup).findViewById(R.id.snackbar_layout)
|
// val snackbarLayout:View = (pagerView.parent as ViewGroup).findViewById(R.id.snackbar_layout)
|
||||||
if (phoneLandscape) {
|
if (phoneLandscape) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
else
|
else
|
||||||
shadow.alpha = 1f
|
shadow.alpha = 1f
|
||||||
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||||
snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
// snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||||
if (!phoneLandscape)
|
if (!phoneLandscape)
|
||||||
preferences.hideFiltersAtStart().set(false)
|
preferences.hideFiltersAtStart().set(false)
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
reSortViews()
|
reSortViews()
|
||||||
shadow.alpha = 0f
|
shadow.alpha = 0f
|
||||||
pager?.updatePaddingRelative(bottom = 0)
|
pager?.updatePaddingRelative(bottom = 0)
|
||||||
snackbarLayout.updatePaddingRelative(bottom = 0)
|
// snackbarLayout.updatePaddingRelative(bottom = 0)
|
||||||
if (!phoneLandscape)
|
if (!phoneLandscape)
|
||||||
preferences.hideFiltersAtStart().set(true)
|
preferences.hideFiltersAtStart().set(true)
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||||
snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
// snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||||
}
|
}
|
||||||
if (phoneLandscape && shadow2.visibility != View.GONE) {
|
if (phoneLandscape && shadow2.visibility != View.GONE) {
|
||||||
shadow2.gone()
|
shadow2.gone()
|
||||||
|
@ -314,7 +314,8 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
container: ViewGroup, handler: ControllerChangeHandler) {
|
container: ViewGroup, handler: ControllerChangeHandler) {
|
||||||
|
|
||||||
syncActivityViewWithController(to, from)
|
syncActivityViewWithController(to, from)
|
||||||
navigationView.visibility = if (router.backstackSize > 1) View.GONE else View.VISIBLE
|
if (to !is DialogController)
|
||||||
|
navigationView.visibility = if (router.backstackSize > 1) View.GONE else View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeCompleted(to: Controller?, from: Controller?, isPush: Boolean,
|
override fun onChangeCompleted(to: Controller?, from: Controller?, isPush: Boolean,
|
||||||
|
@ -25,12 +25,12 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaChaptersController
|
import eu.kanade.tachiyomi.ui.manga.MangaChaptersController
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
||||||
import eu.kanade.tachiyomi.util.view.snack
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
|
import kotlinx.android.synthetic.main.main_activity.*
|
||||||
import kotlinx.android.synthetic.main.recent_chapters_controller.*
|
import kotlinx.android.synthetic.main.recent_chapters_controller.*
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -102,7 +102,10 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
|||||||
swipe_refresh.refreshes().subscribeUntilDestroy {
|
swipe_refresh.refreshes().subscribeUntilDestroy {
|
||||||
if (!LibraryUpdateService.isRunning()) {
|
if (!LibraryUpdateService.isRunning()) {
|
||||||
LibraryUpdateService.start(view.context)
|
LibraryUpdateService.start(view.context)
|
||||||
view.snack(R.string.updating_library)
|
view.snack(R.string.updating_library) {
|
||||||
|
anchorView = (this@RecentChaptersController.activity as? MainActivity)
|
||||||
|
?.navigationView
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// It can be a very long operation, so we disable swipe refresh and show a snackbar.
|
// It can be a very long operation, so we disable swipe refresh and show a snackbar.
|
||||||
swipe_refresh.isRefreshing = false
|
swipe_refresh.isRefreshing = false
|
||||||
|
@ -23,11 +23,6 @@
|
|||||||
app:fastScrollerBubbleEnabled="false"
|
app:fastScrollerBubbleEnabled="false"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
android:id="@+id/snackbar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.EmptyView
|
<eu.kanade.tachiyomi.widget.EmptyView
|
||||||
android:id="@+id/empty_view"
|
android:id="@+id/empty_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user