From c48252b61c482ed8cc647954d4d0c1c9e84c3bac Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 8 Feb 2020 19:19:40 -0800 Subject: [PATCH] More fixes to D&D sorting with new presenter --- .../kanade/tachiyomi/ui/library/LibraryCategoryView.kt | 10 ++++------ .../kanade/tachiyomi/ui/library/LibraryGridHolder.kt | 6 +++--- .../eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt | 6 +++++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt index 9abba0c86f..f543fe1e0e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryView.kt @@ -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) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt index 36ba87f93c..8132eefc93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 63c68d754e..44e5cbdb6a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -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