Update the all in one manga viewer to preview
This commit is contained in:
parent
5aec696fb5
commit
2cce7d18eb
@ -330,7 +330,7 @@ class MangaAllInOneController :
|
||||
if (manga.initialized) {
|
||||
// Update view.
|
||||
setMangaInfo(manga, source, chapters, lastUpdateDate, chapterCount)
|
||||
if (fromSource && !presenter.hasRequested && chapters.isNullOrEmpty()) {
|
||||
if (!presenter.hasRequested && presenter.chapters.isEmpty()) {
|
||||
fetchMangaFromSource(fetchManga = false)
|
||||
}
|
||||
} else {
|
||||
@ -651,11 +651,13 @@ class MangaAllInOneController :
|
||||
}
|
||||
|
||||
// Sorting mode submenu
|
||||
if (presenter.manga.sorting == Manga.SORTING_SOURCE) {
|
||||
menu.findItem(R.id.sort_by_source).isChecked = true
|
||||
} else {
|
||||
menu.findItem(R.id.sort_by_number).isChecked = true
|
||||
val sortingItem = when (presenter.manga.sorting) {
|
||||
Manga.SORTING_SOURCE -> R.id.sort_by_source
|
||||
Manga.SORTING_NUMBER -> R.id.sort_by_number
|
||||
Manga.SORTING_UPLOAD_DATE -> R.id.sort_by_upload_date
|
||||
else -> throw NotImplementedError("Unimplemented sorting method")
|
||||
}
|
||||
menu.findItem(sortingItem).isChecked = true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@ -677,6 +679,10 @@ class MangaAllInOneController :
|
||||
item.isChecked = true
|
||||
presenter.setSorting(Manga.SORTING_NUMBER)
|
||||
}
|
||||
R.id.sort_by_upload_date -> {
|
||||
item.isChecked = true
|
||||
presenter.setSorting(Manga.SORTING_UPLOAD_DATE)
|
||||
}
|
||||
|
||||
R.id.download_next, R.id.download_next_5, R.id.download_next_10,
|
||||
R.id.download_custom, R.id.download_unread, R.id.download_all
|
||||
@ -761,11 +767,11 @@ class MangaAllInOneController :
|
||||
|
||||
private fun toggleSelection(position: Int) {
|
||||
val adapter = adapter ?: return
|
||||
val item = adapter.getItem(position) ?: return
|
||||
val item = adapter.getItem(position) as MangaAllInOneChapterItem? ?: return
|
||||
adapter.toggleSelection(position)
|
||||
adapter.notifyDataSetChanged()
|
||||
if (adapter.isSelected(position)) {
|
||||
selectedItems.add(item as MangaAllInOneChapterItem)
|
||||
selectedItems.add(item)
|
||||
} else {
|
||||
selectedItems.remove(item)
|
||||
}
|
||||
@ -896,10 +902,12 @@ class MangaAllInOneController :
|
||||
if (presenter.preferences.removeAfterMarkedAsRead()) {
|
||||
deleteChapters(chapters)
|
||||
}
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
private fun markAsUnread(chapters: List<MangaAllInOneChapterItem>) {
|
||||
presenter.markChaptersRead(chapters, false)
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
private fun downloadChapters(chapters: List<MangaAllInOneChapterItem>) {
|
||||
@ -912,6 +920,7 @@ class MangaAllInOneController :
|
||||
}
|
||||
}
|
||||
}
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
private fun showDeleteChaptersConfirmationDialog() {
|
||||
@ -929,16 +938,19 @@ class MangaAllInOneController :
|
||||
if (chapterPos != -1) {
|
||||
markAsRead(prevChapters.take(chapterPos))
|
||||
}
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
private fun bookmarkChapters(chapters: List<MangaAllInOneChapterItem>, bookmarked: Boolean) {
|
||||
presenter.bookmarkChapters(chapters, bookmarked)
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
fun deleteChapters(chapters: List<MangaAllInOneChapterItem>) {
|
||||
if (chapters.isEmpty()) return
|
||||
|
||||
presenter.deleteChapters(chapters)
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
fun onChaptersDeleted(chapters: List<MangaAllInOneChapterItem>) {
|
||||
@ -981,6 +993,7 @@ class MangaAllInOneController :
|
||||
if (chaptersToDownload.isNotEmpty()) {
|
||||
downloadChapters(chaptersToDownload)
|
||||
}
|
||||
destroyActionModeIfNeeded()
|
||||
}
|
||||
|
||||
private fun showCustomDownloadDialog() {
|
||||
|
@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.ui.manga.chapter.MangaAllInOneChapterItem
|
||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||
import eu.kanade.tachiyomi.util.prepUpdateCover
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import eu.kanade.tachiyomi.util.shouldDownloadNewChapters
|
||||
import exh.MERGED_SOURCE_ID
|
||||
import exh.debug.DebugToggles
|
||||
import exh.eh.EHentaiUpdateHelper
|
||||
@ -222,7 +223,11 @@ class MangaAllInOnePresenter(
|
||||
}
|
||||
try {
|
||||
if (fetchChapters) {
|
||||
syncChaptersWithSource(db, chapters, manga, source)
|
||||
val chapterLists = syncChaptersWithSource(db, chapters, manga, source)
|
||||
|
||||
if (manualFetch) {
|
||||
downloadNewChapters(chapterLists.first)
|
||||
}
|
||||
|
||||
updateChapters()
|
||||
updateChapterInfo()
|
||||
@ -443,6 +448,10 @@ class MangaAllInOnePresenter(
|
||||
true -> { c1, c2 -> c2.chapter_number.compareTo(c1.chapter_number) }
|
||||
false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
|
||||
}
|
||||
Manga.SORTING_UPLOAD_DATE -> when (sortDescending()) {
|
||||
true -> { c1, c2 -> c2.date_upload.compareTo(c1.date_upload) }
|
||||
false -> { c1, c2 -> c1.date_upload.compareTo(c2.date_upload) }
|
||||
}
|
||||
else -> { c1, c2 -> c1.source_order.compareTo(c2.source_order) }
|
||||
}
|
||||
chapters = chapters.sortedWith(Comparator(sortFunction))
|
||||
@ -502,7 +511,7 @@ class MangaAllInOnePresenter(
|
||||
* Downloads the given list of chapters with the manager.
|
||||
* @param chapters the list of chapters to download.
|
||||
*/
|
||||
fun downloadChapters(chapters: List<MangaAllInOneChapterItem>) {
|
||||
fun downloadChapters(chapters: List<Chapter>) {
|
||||
downloadManager.downloadChapters(manga, chapters)
|
||||
}
|
||||
|
||||
@ -539,6 +548,12 @@ class MangaAllInOnePresenter(
|
||||
)
|
||||
}
|
||||
|
||||
private fun downloadNewChapters(chapters: List<Chapter>) {
|
||||
if (chapters.isEmpty() || !manga.shouldDownloadNewChapters(db, preferences)) return
|
||||
|
||||
downloadChapters(chapters)
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a list of chapters from disk. This method is called in a background thread.
|
||||
* @param chapters the chapters to delete.
|
||||
|
Loading…
x
Reference in New Issue
Block a user