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