Added delete pending Downloads method
Also sources now show langauge for multi langauge users
This commit is contained in:
parent
68c3d28b4b
commit
53a44fb211
4 changed files with 22 additions and 15 deletions
|
@ -90,6 +90,7 @@ class DownloadManager(val context: Context) {
|
||||||
* @param isNotification value that determines if status is set (needed for view updates)
|
* @param isNotification value that determines if status is set (needed for view updates)
|
||||||
*/
|
*/
|
||||||
fun clearQueue(isNotification: Boolean = false) {
|
fun clearQueue(isNotification: Boolean = false) {
|
||||||
|
deletePendingDownloads(*downloader.queue.toTypedArray())
|
||||||
downloader.clearQueue(isNotification)
|
downloader.clearQueue(isNotification)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +182,19 @@ class DownloadManager(val context: Context) {
|
||||||
return cache.getDownloadCount(manga)
|
return cache.getDownloadCount(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls delete chapter, which deletes temp downloads
|
||||||
|
* @param downloads list of downloads to cancel
|
||||||
|
*/
|
||||||
|
fun deletePendingDownloads(vararg downloads: Download) {
|
||||||
|
val downloadsByManga = downloads.groupBy { it.manga.id }
|
||||||
|
downloadsByManga.map { entry ->
|
||||||
|
val manga = entry.value.first().manga
|
||||||
|
val source = entry.value.first().source
|
||||||
|
deleteChapters(entry.value.map { it.chapter }, manga, source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the directories of a list of partially downloaded chapters.
|
* Deletes the directories of a list of partially downloaded chapters.
|
||||||
*
|
*
|
||||||
|
|
|
@ -132,16 +132,6 @@ class DownloadProvider(private val context: Context) {
|
||||||
* @param chapter the chapter to query.
|
* @param chapter the chapter to query.
|
||||||
*/
|
*/
|
||||||
fun getChapterDirName(chapter: Chapter): String {
|
fun getChapterDirName(chapter: Chapter): String {
|
||||||
return DiskUtil.buildValidFilename("${chapter.id} - ${chapter.name}")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the chapter directory name for a chapter (that used the scanlator
|
|
||||||
*
|
|
||||||
* @param chapter the chapter to query.
|
|
||||||
*/
|
|
||||||
//TODO: Delete this in due time. N2Self, merging that pr was a mistake
|
|
||||||
private fun getChapterDirNameWithScanlator(chapter: Chapter): String {
|
|
||||||
return DiskUtil.buildValidFilename("${chapter.id}_${chapter.scanlator}_${chapter.name}")
|
return DiskUtil.buildValidFilename("${chapter.id}_${chapter.scanlator}_${chapter.name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +144,6 @@ class DownloadProvider(private val context: Context) {
|
||||||
return listOf(
|
return listOf(
|
||||||
getChapterDirName(chapter),
|
getChapterDirName(chapter),
|
||||||
// Legacy chapter directory name used in v0.8.4 and before
|
// Legacy chapter directory name used in v0.8.4 and before
|
||||||
getChapterDirNameWithScanlator(chapter),
|
|
||||||
DiskUtil.buildValidFilename(chapter.name)
|
DiskUtil.buildValidFilename(chapter.name)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,7 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cancelDownload(download: Download) {
|
fun cancelDownload(download: Download) {
|
||||||
downloadManager.deleteChapters(listOf(download.chapter), download.manga,
|
downloadManager.deletePendingDownloads(download)
|
||||||
download.source)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,10 +3,13 @@ package eu.kanade.tachiyomi.ui.migration.manga.design
|
||||||
import android.graphics.Paint.STRIKE_THRU_TEXT_FLAG
|
import android.graphics.Paint.STRIKE_THRU_TEXT_FLAG
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.getRound
|
import eu.kanade.tachiyomi.util.getRound
|
||||||
import kotlinx.android.synthetic.main.migration_source_item.*
|
import kotlinx.android.synthetic.main.migration_source_item.*
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter):
|
class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter):
|
||||||
BaseFlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
@ -15,9 +18,11 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter):
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
||||||
|
val preferences by injectLazy<PreferencesHelper>()
|
||||||
|
val isMultiLanguage = preferences.enabledLanguages().getOrDefault().size > 1
|
||||||
// Set capitalized title.
|
// Set capitalized title.
|
||||||
title.text = source.name.capitalize()
|
val sourceName = if (isMultiLanguage) source.toString() else source.name.capitalize()
|
||||||
|
title.text = sourceName
|
||||||
// Update circle letter image.
|
// Update circle letter image.
|
||||||
itemView.post {
|
itemView.post {
|
||||||
image.setImageDrawable(image.getRound(source.name.take(1).toUpperCase(),false))
|
image.setImageDrawable(image.getRound(source.name.take(1).toUpperCase(),false))
|
||||||
|
|
Reference in a new issue