More fixes to D&D sorting with new presenter

This commit is contained in:
Jay 2020-02-08 19:19:40 -08:00
parent d4153a9f41
commit c48252b61c
3 changed files with 12 additions and 10 deletions

View File

@ -81,8 +81,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
private var lastClickPosition = -1
private var justDraggedAndDropped = false
fun onCreate(controller: LibraryController) {
this.controller = controller
@ -239,10 +237,10 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
val mangaForCategory = event.getMangaForCategory(category).orEmpty()
// Update the category with its manga.
if (!justDraggedAndDropped)
// if (!justDraggedAndDropped)
adapter.setItems(mangaForCategory)
else
justDraggedAndDropped = false
// else
// justDraggedAndDropped = false
swipe_refresh.isEnabled = !preferences.hideCategories().getOrDefault()
@ -366,7 +364,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
preferences.defaultMangaOrder().set(mangaIds.joinToString("/"))
else
db.insertCategory(category).asRxObservable().subscribe()
justDraggedAndDropped = true
//justDraggedAndDropped = true
controller.onCatSortChanged(category.id)
controller.enableReorderItems(category)
}

View File

@ -60,9 +60,9 @@ class LibraryGridHolder(
local_text.visibility = if (item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE
// Update the cover.
GlideApp.with(view.context).clear(thumbnail)
GlideApp.with(view.context)
.load(item.manga)
if (item.manga.thumbnail_url == null)
GlideApp.with(view.context).clear(thumbnail)
else GlideApp.with(view.context).load(item.manga)
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString()))
.centerCrop().into(thumbnail)

View File

@ -211,7 +211,11 @@ class LibraryPresenter(
private fun applySort(map: LibraryMap, catId: Int?): LibraryMap {
if (catId == null) return map
val category = allCategories.find { it.id == catId } ?: return map
val category = db.getCategories().executeAsBlocking().find { it.id == catId } ?: return map
allCategories.find { it.id == catId }?.apply {
mangaOrder = category.mangaOrder
mangaSort = category.mangaSort
}
val lastReadManga by lazy {
var counter = 0