mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 05:35:07 +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) {
|
if (s == null) {
|
||||||
s = ""
|
s = ""
|
||||||
}
|
}
|
||||||
|
isLongPressDragEnabled = view.canDrag() && s.isNullOrBlank()
|
||||||
updateDataSet(mangas.filter { it.filter(s) })
|
updateDataSet(mangas.filter { it.filter(s) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +128,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
} else {
|
} else {
|
||||||
SelectableAdapter.Mode.SINGLE
|
SelectableAdapter.Mode.SINGLE
|
||||||
}
|
}
|
||||||
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
adapter.isLongPressDragEnabled = canDrag()
|
||||||
adapter.isLongPressDragEnabled = sortingMode == LibrarySort.DRAG_AND_DROP
|
|
||||||
|
|
||||||
subscriptions += controller.searchRelay
|
subscriptions += controller.searchRelay
|
||||||
.doOnNext { adapter.setFilter(it) }
|
.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() {
|
fun onRecycle() {
|
||||||
adapter.setItems(emptyList())
|
adapter.setItems(emptyList())
|
||||||
adapter.clearSelection()
|
adapter.clearSelection()
|
||||||
@ -192,10 +200,8 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
*/
|
*/
|
||||||
fun onNextLibraryManga(event: LibraryMangaEvent) {
|
fun onNextLibraryManga(event: LibraryMangaEvent) {
|
||||||
// Get the manga list for this category.
|
// Get the manga list for this category.
|
||||||
|
|
||||||
|
|
||||||
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
||||||
adapter.isLongPressDragEnabled = sortingMode == LibrarySort.DRAG_AND_DROP
|
adapter.isLongPressDragEnabled = canDrag()
|
||||||
var mangaForCategory = event.getMangaForCategory(category).orEmpty()
|
var mangaForCategory = event.getMangaForCategory(category).orEmpty()
|
||||||
if (sortingMode == LibrarySort.DRAG_AND_DROP) {
|
if (sortingMode == LibrarySort.DRAG_AND_DROP) {
|
||||||
if (category.name == "Default")
|
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 (adapter.indexOf(event.manga) != -1) lastClickPosition = -1
|
||||||
if (controller.selectedMangas.isEmpty()) {
|
if (controller.selectedMangas.isEmpty()) {
|
||||||
adapter.mode = SelectableAdapter.Mode.SINGLE
|
adapter.mode = SelectableAdapter.Mode.SINGLE
|
||||||
adapter.isLongPressDragEnabled = preferences.librarySortingMode()
|
adapter.isLongPressDragEnabled = canDrag()
|
||||||
.getOrDefault() == LibrarySort.DRAG_AND_DROP
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is LibrarySelectionEvent.Cleared -> {
|
is LibrarySelectionEvent.Cleared -> {
|
||||||
adapter.mode = SelectableAdapter.Mode.SINGLE
|
adapter.mode = SelectableAdapter.Mode.SINGLE
|
||||||
adapter.clearSelection()
|
adapter.clearSelection()
|
||||||
lastClickPosition = -1
|
lastClickPosition = -1
|
||||||
adapter.isLongPressDragEnabled = preferences.librarySortingMode()
|
adapter.isLongPressDragEnabled = canDrag()
|
||||||
.getOrDefault() == LibrarySort.DRAG_AND_DROP
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,8 @@ class LibraryController(
|
|||||||
*/
|
*/
|
||||||
private var query = ""
|
private var query = ""
|
||||||
|
|
||||||
|
private var searchItem:MenuItem? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently selected mangas.
|
* Currently selected mangas.
|
||||||
*/
|
*/
|
||||||
@ -211,6 +213,7 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetach(view: View) {
|
override fun onDetach(view: View) {
|
||||||
|
destroyActionModeIfNeeded()
|
||||||
snack?.dismiss()
|
snack?.dismiss()
|
||||||
snack = null
|
snack = null
|
||||||
super.onDetach(view)
|
super.onDetach(view)
|
||||||
@ -322,6 +325,7 @@ class LibraryController(
|
|||||||
*/
|
*/
|
||||||
private fun onFilterChanged() {
|
private fun onFilterChanged() {
|
||||||
presenter.requestFilterUpdate()
|
presenter.requestFilterUpdate()
|
||||||
|
destroyActionModeIfNeeded()
|
||||||
activity?.invalidateOptionsMenu()
|
activity?.invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,6 +361,7 @@ class LibraryController(
|
|||||||
fun createActionModeIfNeeded() {
|
fun createActionModeIfNeeded() {
|
||||||
if (actionMode == null) {
|
if (actionMode == null) {
|
||||||
actionMode = (activity as AppCompatActivity).startSupportActionMode(this)
|
actionMode = (activity as AppCompatActivity).startSupportActionMode(this)
|
||||||
|
searchItem?.collapseActionView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +381,9 @@ class LibraryController(
|
|||||||
val searchItem = menu.findItem(R.id.action_search)
|
val searchItem = menu.findItem(R.id.action_search)
|
||||||
val searchView = searchItem.actionView as SearchView
|
val searchView = searchItem.actionView as SearchView
|
||||||
searchView.queryHint = resources?.getString(R.string.search_hint)
|
searchView.queryHint = resources?.getString(R.string.search_hint)
|
||||||
|
this.searchItem = searchItem
|
||||||
|
|
||||||
|
searchItem.collapseActionView()
|
||||||
if (!query.isEmpty()) {
|
if (!query.isEmpty()) {
|
||||||
searchItem.expandActionView()
|
searchItem.expandActionView()
|
||||||
searchView.setQuery(query, true)
|
searchView.setQuery(query, true)
|
||||||
|
@ -82,6 +82,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
|
|||||||
|
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
private fun containsGenre(tag: String, genres: List<String>?): Boolean {
|
private fun containsGenre(tag: String, genres: List<String>?): Boolean {
|
||||||
|
if (tag.trim().isEmpty()) return true
|
||||||
return if (tag.startsWith("-"))
|
return if (tag.startsWith("-"))
|
||||||
genres?.find {
|
genres?.find {
|
||||||
it.trim().toLowerCase() == tag.substringAfter("-").toLowerCase()
|
it.trim().toLowerCase() == tag.substringAfter("-").toLowerCase()
|
||||||
|
Loading…
Reference in New Issue
Block a user