mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 06:39:06 +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) {
|
||||
if (lastItemPosition == toPosition)
|
||||
lastItemPosition = null
|
||||
else if (lastItemPosition == null)
|
||||
lastItemPosition = fromPosition
|
||||
}
|
||||
|
||||
override fun onItemReleased(position: Int) {
|
||||
@ -472,6 +474,9 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
return
|
||||
}
|
||||
destroyActionModeIfNeeded()
|
||||
// if nothing moved
|
||||
if (lastItemPosition == null)
|
||||
return
|
||||
val item = adapter.getItem(position) as? LibraryItem ?: return
|
||||
val newHeader = adapter.getSectionHeader(position) as? LibraryHeaderItem
|
||||
val libraryItems = adapter.getSectionItems(adapter.getSectionHeader(position))
|
||||
@ -482,7 +487,9 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
} else {
|
||||
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
||||
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
|
||||
}
|
||||
if (newHeader?.category?.mangaSort == null) {
|
||||
@ -539,13 +546,15 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
return false
|
||||
val inQueue = LibraryUpdateService.categoryInQueue(category.id)
|
||||
snack?.dismiss()
|
||||
snack = snackbar_layout.snack(resources!!.getString(
|
||||
snack = view?.snack(resources!!.getString(
|
||||
when {
|
||||
inQueue -> R.string.category_already_in_queue
|
||||
LibraryUpdateService.isRunning() ->
|
||||
R.string.adding_category_to_queue
|
||||
else -> R.string.updating_category_x
|
||||
}, category.name))
|
||||
}, category.name)) {
|
||||
anchorView = bottom_sheet
|
||||
}
|
||||
if (!inQueue)
|
||||
LibraryUpdateService.start(view!!.context, category)
|
||||
return true
|
||||
|
@ -90,7 +90,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
||||
pager = pagerView
|
||||
val shadow2:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
|
||||
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) {
|
||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||
}
|
||||
@ -115,7 +115,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
||||
else
|
||||
shadow.alpha = 1f
|
||||
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||
snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||
// snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||
if (!phoneLandscape)
|
||||
preferences.hideFiltersAtStart().set(false)
|
||||
}
|
||||
@ -128,7 +128,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
||||
reSortViews()
|
||||
shadow.alpha = 0f
|
||||
pager?.updatePaddingRelative(bottom = 0)
|
||||
snackbarLayout.updatePaddingRelative(bottom = 0)
|
||||
// snackbarLayout.updatePaddingRelative(bottom = 0)
|
||||
if (!phoneLandscape)
|
||||
preferences.hideFiltersAtStart().set(true)
|
||||
}
|
||||
@ -142,7 +142,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
|
||||
}
|
||||
else {
|
||||
pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||
snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||
// snackbarLayout.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0)
|
||||
}
|
||||
if (phoneLandscape && shadow2.visibility != View.GONE) {
|
||||
shadow2.gone()
|
||||
|
@ -314,7 +314,8 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||
container: ViewGroup, handler: ControllerChangeHandler) {
|
||||
|
||||
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,
|
||||
|
@ -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.main.MainActivity
|
||||
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.recently_read.RecentlyReadController
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import kotlinx.android.synthetic.main.recent_chapters_controller.*
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@ -102,7 +102,10 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
swipe_refresh.refreshes().subscribeUntilDestroy {
|
||||
if (!LibraryUpdateService.isRunning()) {
|
||||
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.
|
||||
swipe_refresh.isRefreshing = false
|
||||
|
@ -23,11 +23,6 @@
|
||||
app:fastScrollerBubbleEnabled="false"
|
||||
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
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
x
Reference in New Issue
Block a user