mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 11:51:50 +01:00
Fixed being able to drag & drop while searching or with filters on
Also destroy action mode when leaving library controller or setting a filter
This commit is contained in:
parent
f7e867219c
commit
8332a45028
@ -64,6 +64,7 @@ class LibraryCategoryAdapter(val view: LibraryCategoryView) :
|
||||
if (s == null) {
|
||||
s = ""
|
||||
}
|
||||
isLongPressDragEnabled = view.canDrag() && s.isNullOrBlank()
|
||||
updateDataSet(mangas.filter { it.filter(s) })
|
||||
}
|
||||
|
||||
|
@ -128,8 +128,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
} else {
|
||||
SelectableAdapter.Mode.SINGLE
|
||||
}
|
||||
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
||||
adapter.isLongPressDragEnabled = sortingMode == LibrarySort.DRAG_AND_DROP
|
||||
adapter.isLongPressDragEnabled = canDrag()
|
||||
|
||||
subscriptions += controller.searchRelay
|
||||
.doOnNext { adapter.setFilter(it) }
|
||||
@ -174,6 +173,15 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
}
|
||||
}
|
||||
|
||||
fun canDrag(): Boolean {
|
||||
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
||||
val filterOff = preferences.filterCompleted().getOrDefault() +
|
||||
preferences.filterUnread().getOrDefault() +
|
||||
preferences.filterCompleted().getOrDefault() == 0
|
||||
return sortingMode == LibrarySort.DRAG_AND_DROP && filterOff &&
|
||||
adapter.mode != SelectableAdapter.Mode.MULTI
|
||||
}
|
||||
|
||||
fun onRecycle() {
|
||||
adapter.setItems(emptyList())
|
||||
adapter.clearSelection()
|
||||
@ -192,10 +200,8 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
*/
|
||||
fun onNextLibraryManga(event: LibraryMangaEvent) {
|
||||
// Get the manga list for this category.
|
||||
|
||||
|
||||
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
||||
adapter.isLongPressDragEnabled = sortingMode == LibrarySort.DRAG_AND_DROP
|
||||
adapter.isLongPressDragEnabled = canDrag()
|
||||
var mangaForCategory = event.getMangaForCategory(category).orEmpty()
|
||||
if (sortingMode == LibrarySort.DRAG_AND_DROP) {
|
||||
if (category.name == "Default")
|
||||
@ -238,16 +244,14 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
if (adapter.indexOf(event.manga) != -1) lastClickPosition = -1
|
||||
if (controller.selectedMangas.isEmpty()) {
|
||||
adapter.mode = SelectableAdapter.Mode.SINGLE
|
||||
adapter.isLongPressDragEnabled = preferences.librarySortingMode()
|
||||
.getOrDefault() == LibrarySort.DRAG_AND_DROP
|
||||
adapter.isLongPressDragEnabled = canDrag()
|
||||
}
|
||||
}
|
||||
is LibrarySelectionEvent.Cleared -> {
|
||||
adapter.mode = SelectableAdapter.Mode.SINGLE
|
||||
adapter.clearSelection()
|
||||
lastClickPosition = -1
|
||||
adapter.isLongPressDragEnabled = preferences.librarySortingMode()
|
||||
.getOrDefault() == LibrarySort.DRAG_AND_DROP
|
||||
adapter.isLongPressDragEnabled = canDrag()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ class LibraryController(
|
||||
*/
|
||||
private var query = ""
|
||||
|
||||
private var searchItem:MenuItem? = null
|
||||
|
||||
/**
|
||||
* Currently selected mangas.
|
||||
*/
|
||||
@ -211,6 +213,7 @@ class LibraryController(
|
||||
}
|
||||
|
||||
override fun onDetach(view: View) {
|
||||
destroyActionModeIfNeeded()
|
||||
snack?.dismiss()
|
||||
snack = null
|
||||
super.onDetach(view)
|
||||
@ -322,6 +325,7 @@ class LibraryController(
|
||||
*/
|
||||
private fun onFilterChanged() {
|
||||
presenter.requestFilterUpdate()
|
||||
destroyActionModeIfNeeded()
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
@ -357,6 +361,7 @@ class LibraryController(
|
||||
fun createActionModeIfNeeded() {
|
||||
if (actionMode == null) {
|
||||
actionMode = (activity as AppCompatActivity).startSupportActionMode(this)
|
||||
searchItem?.collapseActionView()
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,7 +381,9 @@ class LibraryController(
|
||||
val searchItem = menu.findItem(R.id.action_search)
|
||||
val searchView = searchItem.actionView as SearchView
|
||||
searchView.queryHint = resources?.getString(R.string.search_hint)
|
||||
this.searchItem = searchItem
|
||||
|
||||
searchItem.collapseActionView()
|
||||
if (!query.isEmpty()) {
|
||||
searchItem.expandActionView()
|
||||
searchView.setQuery(query, true)
|
||||
|
@ -82,6 +82,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
private fun containsGenre(tag: String, genres: List<String>?): Boolean {
|
||||
if (tag.trim().isEmpty()) return true
|
||||
return if (tag.startsWith("-"))
|
||||
genres?.find {
|
||||
it.trim().toLowerCase() == tag.substringAfter("-").toLowerCase()
|
||||
|
Loading…
Reference in New Issue
Block a user