Run default Android Studio formatter on code
This commit is contained in:
parent
a1fadce7c6
commit
3ecc883944
@ -1,4 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.backup
|
package eu.kanade.tachiyomi.data.backup
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID
|
import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,10 +217,14 @@ class BackupRestoreService : Service() {
|
|||||||
.concatMap {
|
.concatMap {
|
||||||
val obj = it.asJsonObject
|
val obj = it.asJsonObject
|
||||||
val manga = backupManager.parser.fromJson<MangaImpl>(obj.get(MANGA))
|
val manga = backupManager.parser.fromJson<MangaImpl>(obj.get(MANGA))
|
||||||
val chapters = backupManager.parser.fromJson<List<ChapterImpl>>(obj.get(CHAPTERS) ?: JsonArray())
|
val chapters = backupManager.parser.fromJson<List<ChapterImpl>>(obj.get(CHAPTERS)
|
||||||
val categories = backupManager.parser.fromJson<List<String>>(obj.get(CATEGORIES) ?: JsonArray())
|
?: JsonArray())
|
||||||
val history = backupManager.parser.fromJson<List<DHistory>>(obj.get(HISTORY) ?: JsonArray())
|
val categories = backupManager.parser.fromJson<List<String>>(obj.get(CATEGORIES)
|
||||||
val tracks = backupManager.parser.fromJson<List<TrackImpl>>(obj.get(TRACK) ?: JsonArray())
|
?: JsonArray())
|
||||||
|
val history = backupManager.parser.fromJson<List<DHistory>>(obj.get(HISTORY)
|
||||||
|
?: JsonArray())
|
||||||
|
val tracks = backupManager.parser.fromJson<List<TrackImpl>>(obj.get(TRACK)
|
||||||
|
?: JsonArray())
|
||||||
|
|
||||||
val observable = getMangaRestoreObservable(manga, chapters, categories, history, tracks)
|
val observable = getMangaRestoreObservable(manga, chapters, categories, history, tracks)
|
||||||
if (observable != null) {
|
if (observable != null) {
|
||||||
|
@ -20,8 +20,8 @@ class CoverCache(private val context: Context) {
|
|||||||
/**
|
/**
|
||||||
* Cache directory used for cache management.
|
* Cache directory used for cache management.
|
||||||
*/
|
*/
|
||||||
private val cacheDir = context.getExternalFilesDir("covers") ?:
|
private val cacheDir = context.getExternalFilesDir("covers")
|
||||||
File(context.filesDir, "covers").also { it.mkdirs() }
|
?: File(context.filesDir, "covers").also { it.mkdirs() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cover from cache.
|
* Returns the cover from cache.
|
||||||
|
@ -161,7 +161,8 @@ internal class DownloadNotifier(private val context: Context) {
|
|||||||
fun onError(error: String? = null, chapter: String? = null) {
|
fun onError(error: String? = null, chapter: String? = null) {
|
||||||
// Create notification
|
// Create notification
|
||||||
with(notificationBuilder) {
|
with(notificationBuilder) {
|
||||||
setContentTitle(chapter ?: context.getString(R.string.download_notifier_downloader_title))
|
setContentTitle(chapter
|
||||||
|
?: context.getString(R.string.download_notifier_downloader_title))
|
||||||
setContentText(error ?: context.getString(R.string.download_notifier_unkown_error))
|
setContentText(error ?: context.getString(R.string.download_notifier_unkown_error))
|
||||||
setSmallIcon(android.R.drawable.stat_sys_warning)
|
setSmallIcon(android.R.drawable.stat_sys_warning)
|
||||||
clearActions()
|
clearActions()
|
||||||
|
@ -131,7 +131,8 @@ class DownloadService : Service() {
|
|||||||
subscriptions += ReactiveNetwork.observeNetworkConnectivity(applicationContext)
|
subscriptions += ReactiveNetwork.observeNetworkConnectivity(applicationContext)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ state -> onNetworkStateChanged(state)
|
.subscribe({ state ->
|
||||||
|
onNetworkStateChanged(state)
|
||||||
}, {
|
}, {
|
||||||
toast(R.string.download_queue_error)
|
toast(R.string.download_queue_error)
|
||||||
stopSelf()
|
stopSelf()
|
||||||
@ -156,7 +157,9 @@ class DownloadService : Service() {
|
|||||||
DISCONNECTED -> {
|
DISCONNECTED -> {
|
||||||
downloadManager.stopDownloads(getString(R.string.download_notifier_no_network))
|
downloadManager.stopDownloads(getString(R.string.download_notifier_no_network))
|
||||||
}
|
}
|
||||||
else -> { /* Do nothing */ }
|
else -> {
|
||||||
|
/* Do nothing */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,8 @@ class Downloader(
|
|||||||
/**
|
/**
|
||||||
* Whether the downloader is running.
|
* Whether the downloader is running.
|
||||||
*/
|
*/
|
||||||
@Volatile private var isRunning: Boolean = false
|
@Volatile
|
||||||
|
private var isRunning: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
launchNow {
|
launchNow {
|
||||||
@ -175,7 +176,8 @@ class Downloader(
|
|||||||
.concatMap { downloadChapter(it).subscribeOn(Schedulers.io()) }
|
.concatMap { downloadChapter(it).subscribeOn(Schedulers.io()) }
|
||||||
.onBackpressureBuffer()
|
.onBackpressureBuffer()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ completeDownload(it)
|
.subscribe({
|
||||||
|
completeDownload(it)
|
||||||
}, { error ->
|
}, { error ->
|
||||||
DownloadService.stop(context)
|
DownloadService.stop(context)
|
||||||
Timber.e(error)
|
Timber.e(error)
|
||||||
|
@ -10,17 +10,24 @@ class Download(val source: HttpSource, val manga: Manga, val chapter: Chapter) {
|
|||||||
|
|
||||||
var pages: List<Page>? = null
|
var pages: List<Page>? = null
|
||||||
|
|
||||||
@Volatile @Transient var totalProgress: Int = 0
|
@Volatile
|
||||||
|
@Transient
|
||||||
|
var totalProgress: Int = 0
|
||||||
|
|
||||||
@Volatile @Transient var downloadedImages: Int = 0
|
@Volatile
|
||||||
|
@Transient
|
||||||
|
var downloadedImages: Int = 0
|
||||||
|
|
||||||
@Volatile @Transient var status: Int = 0
|
@Volatile
|
||||||
|
@Transient
|
||||||
|
var status: Int = 0
|
||||||
set(status) {
|
set(status) {
|
||||||
field = status
|
field = status
|
||||||
statusSubject?.onNext(this)
|
statusSubject?.onNext(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient private var statusSubject: PublishSubject<Download>? = null
|
@Transient
|
||||||
|
private var statusSubject: PublishSubject<Download>? = null
|
||||||
|
|
||||||
fun setStatusSubject(subject: PublishSubject<Download>?) {
|
fun setStatusSubject(subject: PublishSubject<Download>?) {
|
||||||
statusSubject = subject
|
statusSubject = subject
|
||||||
|
@ -42,7 +42,9 @@ class DownloadQueue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun remove(chapters: List<Chapter>) {
|
fun remove(chapters: List<Chapter>) {
|
||||||
for (chapter in chapters) { remove(chapter) }
|
for (chapter in chapters) {
|
||||||
|
remove(chapter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(manga: Manga) {
|
fun remove(manga: Manga) {
|
||||||
|
@ -250,7 +250,8 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||||||
private fun jsonToALManga(struct: JsonObject): ALManga {
|
private fun jsonToALManga(struct: JsonObject): ALManga {
|
||||||
val date = try {
|
val date = try {
|
||||||
val date = Calendar.getInstance()
|
val date = Calendar.getInstance()
|
||||||
date.set(struct["startDate"]["year"].nullInt ?: 0, (struct["startDate"]["month"].nullInt ?: 0) - 1,
|
date.set(struct["startDate"]["year"].nullInt ?: 0, (struct["startDate"]["month"].nullInt
|
||||||
|
?: 0) - 1,
|
||||||
struct["startDate"]["day"].nullInt ?: 0)
|
struct["startDate"]["day"].nullInt ?: 0)
|
||||||
date.timeInMillis
|
date.timeInMillis
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
|
@ -96,7 +96,8 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|||||||
last_chapter_read = trackForm.select("#add_manga_num_read_chapters").`val`().toInt()
|
last_chapter_read = trackForm.select("#add_manga_num_read_chapters").`val`().toInt()
|
||||||
total_chapters = trackForm.select("#totalChap").text().toInt()
|
total_chapters = trackForm.select("#totalChap").text().toInt()
|
||||||
status = trackForm.select("#add_manga_status > option[selected]").`val`().toInt()
|
status = trackForm.select("#add_manga_status > option[selected]").`val`().toInt()
|
||||||
score = trackForm.select("#add_manga_score > option[selected]").`val`().toFloatOrNull() ?: 0f
|
score = trackForm.select("#add_manga_score > option[selected]").`val`().toFloatOrNull()
|
||||||
|
?: 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
|
|||||||
/**
|
/**
|
||||||
* Returns the intent filter this receiver should subscribe to.
|
* Returns the intent filter this receiver should subscribe to.
|
||||||
*/
|
*/
|
||||||
private val filter get() = IntentFilter().apply {
|
private val filter
|
||||||
|
get() = IntentFilter().apply {
|
||||||
addAction(Intent.ACTION_PACKAGE_ADDED)
|
addAction(Intent.ACTION_PACKAGE_ADDED)
|
||||||
addAction(Intent.ACTION_PACKAGE_REPLACED)
|
addAction(Intent.ACTION_PACKAGE_REPLACED)
|
||||||
addAction(Intent.ACTION_PACKAGE_REMOVED)
|
addAction(Intent.ACTION_PACKAGE_REMOVED)
|
||||||
@ -61,7 +62,8 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
|
|||||||
when (result) {
|
when (result) {
|
||||||
is LoadResult.Success -> listener.onExtensionUpdated(result.extension)
|
is LoadResult.Success -> listener.onExtensionUpdated(result.extension)
|
||||||
// Not needed as a package can't be upgraded if the signature is different
|
// Not needed as a package can't be upgraded if the signature is different
|
||||||
is LoadResult.Untrusted -> {}
|
is LoadResult.Untrusted -> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +94,8 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
|
|||||||
* @param intent The intent containing the package name of the extension.
|
* @param intent The intent containing the package name of the extension.
|
||||||
*/
|
*/
|
||||||
private suspend fun getExtensionFromIntent(context: Context, intent: Intent?): LoadResult {
|
private suspend fun getExtensionFromIntent(context: Context, intent: Intent?): LoadResult {
|
||||||
val pkgName = getPackageNameFromIntent(intent) ?:
|
val pkgName = getPackageNameFromIntent(intent)
|
||||||
return LoadResult.Error("Package name not found")
|
?: return LoadResult.Error("Package name not found")
|
||||||
return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT) { ExtensionLoader.loadExtensionFromPkgName(context, pkgName) }.await()
|
return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT) { ExtensionLoader.loadExtensionFromPkgName(context, pkgName) }.await()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ internal object ExtensionLoader {
|
|||||||
return LoadResult.Error(error)
|
return LoadResult.Error(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
val extName = pkgManager.getApplicationLabel(appInfo)?.toString()
|
val extName = pkgManager.getApplicationLabel(appInfo).toString()
|
||||||
.orEmpty().substringAfter("Tachiyomi: ")
|
.orEmpty().substringAfter("Tachiyomi: ")
|
||||||
val versionName = pkgInfo.versionName
|
val versionName = pkgInfo.versionName
|
||||||
val versionCode = pkgInfo.versionCode
|
val versionCode = pkgInfo.versionCode
|
||||||
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.network
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.webkit.WebResourceRequest
|
import android.webkit.WebResourceRequest
|
||||||
|
@ -17,6 +17,7 @@ sealed class Filter<T>(val name: String, var state: T) {
|
|||||||
const val STATE_EXCLUDE = 2
|
const val STATE_EXCLUDE = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class Group<V>(name: String, state: List<V>) : Filter<List<V>>(name, state)
|
abstract class Group<V>(name: String, state: List<V>) : Filter<List<V>>(name, state)
|
||||||
|
|
||||||
abstract class Sort(name: String, val values: Array<String>, state: Selection? = null)
|
abstract class Sort(name: String, val values: Array<String>, state: Selection? = null)
|
||||||
|
@ -14,15 +14,20 @@ open class Page(
|
|||||||
val number: Int
|
val number: Int
|
||||||
get() = index + 1
|
get() = index + 1
|
||||||
|
|
||||||
@Transient @Volatile var status: Int = 0
|
@Transient
|
||||||
|
@Volatile
|
||||||
|
var status: Int = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
statusSubject?.onNext(value)
|
statusSubject?.onNext(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient @Volatile var progress: Int = 0
|
@Transient
|
||||||
|
@Volatile
|
||||||
|
var progress: Int = 0
|
||||||
|
|
||||||
@Transient private var statusSubject: Subject<Int, Int>? = null
|
@Transient
|
||||||
|
private var statusSubject: Subject<Int, Int>? = null
|
||||||
|
|
||||||
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
|
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
|
||||||
progress = if (contentLength > 0) {
|
progress = if (contentLength > 0) {
|
||||||
|
@ -69,7 +69,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
/**
|
/**
|
||||||
* Headers builder for requests. Implementations can override this method for custom headers.
|
* Headers builder for requests. Implementations can override this method for custom headers.
|
||||||
*/
|
*/
|
||||||
open protected fun headersBuilder() = Headers.Builder().apply {
|
protected open fun headersBuilder() = Headers.Builder().apply {
|
||||||
add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)")
|
add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,14 +97,14 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param page the page number to retrieve.
|
* @param page the page number to retrieve.
|
||||||
*/
|
*/
|
||||||
abstract protected fun popularMangaRequest(page: Int): Request
|
protected abstract fun popularMangaRequest(page: Int): Request
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns a [MangasPage] object.
|
* Parses the response from the site and returns a [MangasPage] object.
|
||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun popularMangaParse(response: Response): MangasPage
|
protected abstract fun popularMangaParse(response: Response): MangasPage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable containing a page with a list of manga. Normally it's not needed to
|
* Returns an observable containing a page with a list of manga. Normally it's not needed to
|
||||||
@ -129,14 +129,14 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
* @param query the search query.
|
* @param query the search query.
|
||||||
* @param filters the list of filters to apply.
|
* @param filters the list of filters to apply.
|
||||||
*/
|
*/
|
||||||
abstract protected fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request
|
protected abstract fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns a [MangasPage] object.
|
* Parses the response from the site and returns a [MangasPage] object.
|
||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun searchMangaParse(response: Response): MangasPage
|
protected abstract fun searchMangaParse(response: Response): MangasPage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable containing a page with a list of latest manga updates.
|
* Returns an observable containing a page with a list of latest manga updates.
|
||||||
@ -156,14 +156,14 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param page the page number to retrieve.
|
* @param page the page number to retrieve.
|
||||||
*/
|
*/
|
||||||
abstract protected fun latestUpdatesRequest(page: Int): Request
|
protected abstract fun latestUpdatesRequest(page: Int): Request
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns a [MangasPage] object.
|
* Parses the response from the site and returns a [MangasPage] object.
|
||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun latestUpdatesParse(response: Response): MangasPage
|
protected abstract fun latestUpdatesParse(response: Response): MangasPage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable with the updated details for a manga. Normally it's not needed to
|
* Returns an observable with the updated details for a manga. Normally it's not needed to
|
||||||
@ -194,7 +194,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun mangaDetailsParse(response: Response): SManga
|
protected abstract fun mangaDetailsParse(response: Response): SManga
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable with the updated chapter list for a manga. Normally it's not needed to
|
* Returns an observable with the updated chapter list for a manga. Normally it's not needed to
|
||||||
@ -220,7 +220,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param manga the manga to look for chapters.
|
* @param manga the manga to look for chapters.
|
||||||
*/
|
*/
|
||||||
open protected fun chapterListRequest(manga: SManga): Request {
|
protected open fun chapterListRequest(manga: SManga): Request {
|
||||||
return GET(baseUrl + manga.url, headers)
|
return GET(baseUrl + manga.url, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun chapterListParse(response: Response): List<SChapter>
|
protected abstract fun chapterListParse(response: Response): List<SChapter>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable with the page list for a chapter.
|
* Returns an observable with the page list for a chapter.
|
||||||
@ -250,7 +250,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param chapter the chapter whose page list has to be fetched.
|
* @param chapter the chapter whose page list has to be fetched.
|
||||||
*/
|
*/
|
||||||
open protected fun pageListRequest(chapter: SChapter): Request {
|
protected open fun pageListRequest(chapter: SChapter): Request {
|
||||||
return GET(baseUrl + chapter.url, headers)
|
return GET(baseUrl + chapter.url, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun pageListParse(response: Response): List<Page>
|
protected abstract fun pageListParse(response: Response): List<Page>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable with the page containing the source url of the image. If there's any
|
* Returns an observable with the page containing the source url of the image. If there's any
|
||||||
@ -279,7 +279,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param page the chapter whose page list has to be fetched
|
* @param page the chapter whose page list has to be fetched
|
||||||
*/
|
*/
|
||||||
open protected fun imageUrlRequest(page: Page): Request {
|
protected open fun imageUrlRequest(page: Page): Request {
|
||||||
return GET(page.url, headers)
|
return GET(page.url, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param response the response from the site.
|
* @param response the response from the site.
|
||||||
*/
|
*/
|
||||||
abstract protected fun imageUrlParse(response: Response): String
|
protected abstract fun imageUrlParse(response: Response): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable with the response of the source image.
|
* Returns an observable with the response of the source image.
|
||||||
@ -306,7 +306,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
*
|
*
|
||||||
* @param page the chapter whose page list has to be fetched
|
* @param page the chapter whose page list has to be fetched
|
||||||
*/
|
*/
|
||||||
open protected fun imageRequest(page: Page): Request {
|
protected open fun imageRequest(page: Page): Request {
|
||||||
return GET(page.imageUrl!!, headers)
|
return GET(page.imageUrl!!, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns a list of [Element] corresponding to each manga.
|
* Returns the Jsoup selector that returns a list of [Element] corresponding to each manga.
|
||||||
*/
|
*/
|
||||||
abstract protected fun popularMangaSelector(): String
|
protected abstract fun popularMangaSelector(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a manga from the given [element]. Most sites only show the title and the url, it's
|
* Returns a manga from the given [element]. Most sites only show the title and the url, it's
|
||||||
@ -44,13 +44,13 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
*
|
*
|
||||||
* @param element an element obtained from [popularMangaSelector].
|
* @param element an element obtained from [popularMangaSelector].
|
||||||
*/
|
*/
|
||||||
abstract protected fun popularMangaFromElement(element: Element): SManga
|
protected abstract fun popularMangaFromElement(element: Element): SManga
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns the <a> tag linking to the next page, or null if
|
* Returns the Jsoup selector that returns the <a> tag linking to the next page, or null if
|
||||||
* there's no next page.
|
* there's no next page.
|
||||||
*/
|
*/
|
||||||
abstract protected fun popularMangaNextPageSelector(): String?
|
protected abstract fun popularMangaNextPageSelector(): String?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns a [MangasPage] object.
|
* Parses the response from the site and returns a [MangasPage] object.
|
||||||
@ -74,7 +74,7 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns a list of [Element] corresponding to each manga.
|
* Returns the Jsoup selector that returns a list of [Element] corresponding to each manga.
|
||||||
*/
|
*/
|
||||||
abstract protected fun searchMangaSelector(): String
|
protected abstract fun searchMangaSelector(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a manga from the given [element]. Most sites only show the title and the url, it's
|
* Returns a manga from the given [element]. Most sites only show the title and the url, it's
|
||||||
@ -82,13 +82,13 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
*
|
*
|
||||||
* @param element an element obtained from [searchMangaSelector].
|
* @param element an element obtained from [searchMangaSelector].
|
||||||
*/
|
*/
|
||||||
abstract protected fun searchMangaFromElement(element: Element): SManga
|
protected abstract fun searchMangaFromElement(element: Element): SManga
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns the <a> tag linking to the next page, or null if
|
* Returns the Jsoup selector that returns the <a> tag linking to the next page, or null if
|
||||||
* there's no next page.
|
* there's no next page.
|
||||||
*/
|
*/
|
||||||
abstract protected fun searchMangaNextPageSelector(): String?
|
protected abstract fun searchMangaNextPageSelector(): String?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns a [MangasPage] object.
|
* Parses the response from the site and returns a [MangasPage] object.
|
||||||
@ -112,7 +112,7 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns a list of [Element] corresponding to each manga.
|
* Returns the Jsoup selector that returns a list of [Element] corresponding to each manga.
|
||||||
*/
|
*/
|
||||||
abstract protected fun latestUpdatesSelector(): String
|
protected abstract fun latestUpdatesSelector(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a manga from the given [element]. Most sites only show the title and the url, it's
|
* Returns a manga from the given [element]. Most sites only show the title and the url, it's
|
||||||
@ -120,13 +120,13 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
*
|
*
|
||||||
* @param element an element obtained from [latestUpdatesSelector].
|
* @param element an element obtained from [latestUpdatesSelector].
|
||||||
*/
|
*/
|
||||||
abstract protected fun latestUpdatesFromElement(element: Element): SManga
|
protected abstract fun latestUpdatesFromElement(element: Element): SManga
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns the <a> tag linking to the next page, or null if
|
* Returns the Jsoup selector that returns the <a> tag linking to the next page, or null if
|
||||||
* there's no next page.
|
* there's no next page.
|
||||||
*/
|
*/
|
||||||
abstract protected fun latestUpdatesNextPageSelector(): String?
|
protected abstract fun latestUpdatesNextPageSelector(): String?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns the details of a manga.
|
* Parses the response from the site and returns the details of a manga.
|
||||||
@ -142,7 +142,7 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
*
|
*
|
||||||
* @param document the parsed document.
|
* @param document the parsed document.
|
||||||
*/
|
*/
|
||||||
abstract protected fun mangaDetailsParse(document: Document): SManga
|
protected abstract fun mangaDetailsParse(document: Document): SManga
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns a list of chapters.
|
* Parses the response from the site and returns a list of chapters.
|
||||||
@ -157,14 +157,14 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
/**
|
/**
|
||||||
* Returns the Jsoup selector that returns a list of [Element] corresponding to each chapter.
|
* Returns the Jsoup selector that returns a list of [Element] corresponding to each chapter.
|
||||||
*/
|
*/
|
||||||
abstract protected fun chapterListSelector(): String
|
protected abstract fun chapterListSelector(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a chapter from the given element.
|
* Returns a chapter from the given element.
|
||||||
*
|
*
|
||||||
* @param element an element obtained from [chapterListSelector].
|
* @param element an element obtained from [chapterListSelector].
|
||||||
*/
|
*/
|
||||||
abstract protected fun chapterFromElement(element: Element): SChapter
|
protected abstract fun chapterFromElement(element: Element): SChapter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the response from the site and returns the page list.
|
* Parses the response from the site and returns the page list.
|
||||||
@ -180,7 +180,7 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
*
|
*
|
||||||
* @param document the parsed document.
|
* @param document the parsed document.
|
||||||
*/
|
*/
|
||||||
abstract protected fun pageListParse(document: Document): List<Page>
|
protected abstract fun pageListParse(document: Document): List<Page>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the response from the site and returns the absolute url to the source image.
|
* Parse the response from the site and returns the absolute url to the source image.
|
||||||
@ -196,5 +196,5 @@ abstract class ParsedHttpSource : HttpSource() {
|
|||||||
*
|
*
|
||||||
* @param document the parsed document.
|
* @param document the parsed document.
|
||||||
*/
|
*/
|
||||||
abstract protected fun imageUrlParse(document: Document): String
|
protected abstract fun imageUrlParse(document: Document): String
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr
|
|||||||
* Issue link: https://issuetracker.google.com/issues/37657375
|
* Issue link: https://issuetracker.google.com/issues/37657375
|
||||||
*/
|
*/
|
||||||
var expandActionViewFromInteraction = false
|
var expandActionViewFromInteraction = false
|
||||||
|
|
||||||
fun MenuItem.fixExpand(onExpand: ((MenuItem) -> Boolean)? = null, onCollapse: ((MenuItem) -> Boolean)? = null) {
|
fun MenuItem.fixExpand(onExpand: ((MenuItem) -> Boolean)? = null, onCollapse: ((MenuItem) -> Boolean)? = null) {
|
||||||
setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||||
|
@ -23,8 +23,7 @@ open class BasePresenter<V> : RxPresenter<V>() {
|
|||||||
* @param onNext function to execute when the observable emits an item.
|
* @param onNext function to execute when the observable emits an item.
|
||||||
* @param onError function to execute when the observable throws an error.
|
* @param onError function to execute when the observable throws an error.
|
||||||
*/
|
*/
|
||||||
fun <T> Observable<T>.subscribeFirst(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null)
|
fun <T> Observable<T>.subscribeFirst(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null) = compose(deliverFirst<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
||||||
= compose(deliverFirst<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes an observable with [deliverLatestCache] and adds it to the presenter's lifecycle
|
* Subscribes an observable with [deliverLatestCache] and adds it to the presenter's lifecycle
|
||||||
@ -33,8 +32,7 @@ open class BasePresenter<V> : RxPresenter<V>() {
|
|||||||
* @param onNext function to execute when the observable emits an item.
|
* @param onNext function to execute when the observable emits an item.
|
||||||
* @param onError function to execute when the observable throws an error.
|
* @param onError function to execute when the observable throws an error.
|
||||||
*/
|
*/
|
||||||
fun <T> Observable<T>.subscribeLatestCache(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null)
|
fun <T> Observable<T>.subscribeLatestCache(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null) = compose(deliverLatestCache<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
||||||
= compose(deliverLatestCache<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes an observable with [deliverReplay] and adds it to the presenter's lifecycle
|
* Subscribes an observable with [deliverReplay] and adds it to the presenter's lifecycle
|
||||||
@ -43,8 +41,7 @@ open class BasePresenter<V> : RxPresenter<V>() {
|
|||||||
* @param onNext function to execute when the observable emits an item.
|
* @param onNext function to execute when the observable emits an item.
|
||||||
* @param onError function to execute when the observable throws an error.
|
* @param onError function to execute when the observable throws an error.
|
||||||
*/
|
*/
|
||||||
fun <T> Observable<T>.subscribeReplay(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null)
|
fun <T> Observable<T>.subscribeReplay(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null) = compose(deliverReplay<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
||||||
= compose(deliverReplay<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes an observable with [DeliverWithView] and adds it to the presenter's lifecycle
|
* Subscribes an observable with [DeliverWithView] and adds it to the presenter's lifecycle
|
||||||
@ -53,8 +50,7 @@ open class BasePresenter<V> : RxPresenter<V>() {
|
|||||||
* @param onNext function to execute when the observable emits an item.
|
* @param onNext function to execute when the observable emits an item.
|
||||||
* @param onError function to execute when the observable throws an error.
|
* @param onError function to execute when the observable throws an error.
|
||||||
*/
|
*/
|
||||||
fun <T> Observable<T>.subscribeWithView(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null)
|
fun <T> Observable<T>.subscribeWithView(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null) = compose(DeliverWithView<V, T>(view())).subscribe(split(onNext, onError)).apply { add(this) }
|
||||||
= compose(DeliverWithView<V, T>(view())).subscribe(split(onNext, onError)).apply { add(this) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A deliverable that only emits to the view if attached, otherwise the event is ignored.
|
* A deliverable that only emits to the view if attached, otherwise the event is ignored.
|
||||||
|
@ -347,7 +347,8 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
snack?.dismiss()
|
snack?.dismiss()
|
||||||
|
|
||||||
if (catalogue_view != null) {
|
if (catalogue_view != null) {
|
||||||
val message = if (error is NoResultsException) catalogue_view.context.getString(R.string.no_results_found) else (error.message ?: "")
|
val message = if (error is NoResultsException) catalogue_view.context.getString(R.string.no_results_found) else (error.message
|
||||||
|
?: "")
|
||||||
|
|
||||||
snack = catalogue_view.snack(message, Snackbar.LENGTH_INDEFINITE) {
|
snack = catalogue_view.snack(message, Snackbar.LENGTH_INDEFINITE) {
|
||||||
setAction(R.string.action_retry) {
|
setAction(R.string.action_retry) {
|
||||||
@ -497,7 +498,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
0 -> {
|
0 -> {
|
||||||
presenter.changeMangaFavorite(manga)
|
presenter.changeMangaFavorite(manga)
|
||||||
adapter?.notifyItemChanged(position)
|
adapter?.notifyItemChanged(position)
|
||||||
activity?.toast(activity?.getString(R.string.manga_removed_library))
|
activity.toast(activity.getString(R.string.manga_removed_library))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.show()
|
}.show()
|
||||||
@ -522,7 +523,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
.showDialog(router)
|
.showDialog(router)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activity?.toast(activity?.getString(R.string.manga_added_library))
|
activity.toast(activity.getString(R.string.manga_added_library))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,11 +74,12 @@ open class CatalogueSearchPresenter(
|
|||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
super.onCreate(savedState)
|
super.onCreate(savedState)
|
||||||
|
|
||||||
extensionFilter = savedState?.getString(CatalogueSearchPresenter::extensionFilter.name) ?:
|
extensionFilter = savedState?.getString(CatalogueSearchPresenter::extensionFilter.name)
|
||||||
initialExtensionFilter
|
?: initialExtensionFilter
|
||||||
|
|
||||||
// Perform a search with previous or initial state
|
// Perform a search with previous or initial state
|
||||||
search(savedState?.getString(BrowseCataloguePresenter::query.name) ?: initialQuery.orEmpty())
|
search(savedState?.getString(BrowseCataloguePresenter::query.name)
|
||||||
|
?: initialQuery.orEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -67,9 +67,11 @@ open class ExtensionPresenter(
|
|||||||
val untrustedSorted = untrusted.sortedBy { it.pkgName }
|
val untrustedSorted = untrusted.sortedBy { it.pkgName }
|
||||||
val availableSorted = available
|
val availableSorted = available
|
||||||
// Filter out already installed extensions and disabled languages
|
// Filter out already installed extensions and disabled languages
|
||||||
.filter { avail -> installed.none { it.pkgName == avail.pkgName }
|
.filter { avail ->
|
||||||
|
installed.none { it.pkgName == avail.pkgName }
|
||||||
&& untrusted.none { it.pkgName == avail.pkgName }
|
&& untrusted.none { it.pkgName == avail.pkgName }
|
||||||
&& (avail.lang in activeLangs || avail.lang == "all")}
|
&& (avail.lang in activeLangs || avail.lang == "all")
|
||||||
|
}
|
||||||
.sortedBy { it.pkgName }
|
.sortedBy { it.pkgName }
|
||||||
|
|
||||||
if (updatesSorted.isNotEmpty()) {
|
if (updatesSorted.isNotEmpty()) {
|
||||||
|
@ -89,14 +89,14 @@ class LibraryPresenter(
|
|||||||
fun subscribeLibrary() {
|
fun subscribeLibrary() {
|
||||||
if (librarySubscription.isNullOrUnsubscribed()) {
|
if (librarySubscription.isNullOrUnsubscribed()) {
|
||||||
librarySubscription = getLibraryObservable()
|
librarySubscription = getLibraryObservable()
|
||||||
.combineLatest(downloadTriggerRelay.observeOn(Schedulers.io())) {
|
.combineLatest(downloadTriggerRelay.observeOn(Schedulers.io())) { lib, _ ->
|
||||||
lib, _ -> lib.apply { setDownloadCount(mangaMap) }
|
lib.apply { setDownloadCount(mangaMap) }
|
||||||
}
|
}
|
||||||
.combineLatest(filterTriggerRelay.observeOn(Schedulers.io())) {
|
.combineLatest(filterTriggerRelay.observeOn(Schedulers.io())) { lib, _ ->
|
||||||
lib, _ -> lib.copy(mangaMap = applyFilters(lib.mangaMap))
|
lib.copy(mangaMap = applyFilters(lib.mangaMap))
|
||||||
}
|
}
|
||||||
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io())) {
|
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io())) { lib, _ ->
|
||||||
lib, _ -> lib.copy(mangaMap = applySort(lib.mangaMap))
|
lib.copy(mangaMap = applySort(lib.mangaMap))
|
||||||
}
|
}
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeLatestCache({ view, (categories, mangaMap) ->
|
.subscribeLatestCache({ view, (categories, mangaMap) ->
|
||||||
@ -231,8 +231,7 @@ class LibraryPresenter(
|
|||||||
* @return an observable of the categories and its manga.
|
* @return an observable of the categories and its manga.
|
||||||
*/
|
*/
|
||||||
private fun getLibraryObservable(): Observable<Library> {
|
private fun getLibraryObservable(): Observable<Library> {
|
||||||
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) {
|
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga ->
|
||||||
dbCategories, libraryManga ->
|
|
||||||
val categories = if (libraryManga.containsKey(0))
|
val categories = if (libraryManga.containsKey(0))
|
||||||
arrayListOf(Category.createDefault()) + dbCategories
|
arrayListOf(Category.createDefault()) + dbCategories
|
||||||
else
|
else
|
||||||
|
@ -6,5 +6,5 @@ sealed class LibrarySelectionEvent {
|
|||||||
|
|
||||||
class Selected(val manga: Manga) : LibrarySelectionEvent()
|
class Selected(val manga: Manga) : LibrarySelectionEvent()
|
||||||
class Unselected(val manga: Manga) : LibrarySelectionEvent()
|
class Unselected(val manga: Manga) : LibrarySelectionEvent()
|
||||||
class Cleared() : LibrarySelectionEvent()
|
class Cleared : LibrarySelectionEvent()
|
||||||
}
|
}
|
@ -17,9 +17,12 @@ class ChapterItem(val chapter: Chapter, val manga: Manga) : AbstractFlexibleItem
|
|||||||
|
|
||||||
var status: Int
|
var status: Int
|
||||||
get() = download?.status ?: _status
|
get() = download?.status ?: _status
|
||||||
set(value) { _status = value }
|
set(value) {
|
||||||
|
_status = value
|
||||||
|
}
|
||||||
|
|
||||||
@Transient var download: Download? = null
|
@Transient
|
||||||
|
var download: Download? = null
|
||||||
|
|
||||||
val isDownloaded: Boolean
|
val isDownloaded: Boolean
|
||||||
get() = status == Download.DOWNLOADED
|
get() = status == Download.DOWNLOADED
|
||||||
|
@ -139,11 +139,11 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
menuFilterDownloaded.isChecked = presenter.onlyDownloaded()
|
menuFilterDownloaded.isChecked = presenter.onlyDownloaded()
|
||||||
menuFilterBookmarked.isChecked = presenter.onlyBookmarked()
|
menuFilterBookmarked.isChecked = presenter.onlyBookmarked()
|
||||||
|
|
||||||
if (presenter.onlyRead())
|
|
||||||
// Disable unread filter option if read filter is enabled.
|
// Disable unread filter option if read filter is enabled.
|
||||||
|
if (presenter.onlyRead())
|
||||||
menuFilterUnread.isEnabled = false
|
menuFilterUnread.isEnabled = false
|
||||||
if (presenter.onlyUnread())
|
|
||||||
// Disable read filter option if unread filter is enabled.
|
// Disable read filter option if unread filter is enabled.
|
||||||
|
if (presenter.onlyUnread())
|
||||||
menuFilterRead.isEnabled = false
|
menuFilterRead.isEnabled = false
|
||||||
|
|
||||||
// Display mode submenu
|
// Display mode submenu
|
||||||
|
@ -109,8 +109,8 @@ class ChaptersPresenter(
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.filter { download -> download.manga.id == manga.id }
|
.filter { download -> download.manga.id == manga.id }
|
||||||
.doOnNext { onDownloadStatusChange(it) }
|
.doOnNext { onDownloadStatusChange(it) }
|
||||||
.subscribeLatestCache(ChaptersController::onChapterStatusChange) {
|
.subscribeLatestCache(ChaptersController::onChapterStatusChange) { _, error ->
|
||||||
_, error -> Timber.e(error)
|
Timber.e(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +176,7 @@ class ChaptersPresenter(
|
|||||||
var observable = Observable.from(chapters).subscribeOn(Schedulers.io())
|
var observable = Observable.from(chapters).subscribeOn(Schedulers.io())
|
||||||
if (onlyUnread()) {
|
if (onlyUnread()) {
|
||||||
observable = observable.filter { !it.read }
|
observable = observable.filter { !it.read }
|
||||||
}
|
} else if (onlyRead()) {
|
||||||
else if (onlyRead()) {
|
|
||||||
observable = observable.filter { it.read }
|
observable = observable.filter { it.read }
|
||||||
}
|
}
|
||||||
if (onlyDownloaded()) {
|
if (onlyDownloaded()) {
|
||||||
|
@ -86,7 +86,8 @@ class HttpPageLoader(
|
|||||||
.getPageListFromCache(chapter.chapter)
|
.getPageListFromCache(chapter.chapter)
|
||||||
.onErrorResumeNext { source.fetchPageList(chapter.chapter) }
|
.onErrorResumeNext { source.fetchPageList(chapter.chapter) }
|
||||||
.map { pages ->
|
.map { pages ->
|
||||||
pages.mapIndexed { index, page -> // Don't trust sources and use our own indexing
|
pages.mapIndexed { index, page ->
|
||||||
|
// Don't trust sources and use our own indexing
|
||||||
ReaderPage(index, page.url, page.imageUrl)
|
ReaderPage(index, page.url, page.imageUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ sealed class ChapterTransition {
|
|||||||
class Prev(
|
class Prev(
|
||||||
override val from: ReaderChapter, override val to: ReaderChapter?
|
override val from: ReaderChapter, override val to: ReaderChapter?
|
||||||
) : ChapterTransition()
|
) : ChapterTransition()
|
||||||
|
|
||||||
class Next(
|
class Next(
|
||||||
override val from: ReaderChapter, override val to: ReaderChapter?
|
override val from: ReaderChapter, override val to: ReaderChapter?
|
||||||
) : ChapterTransition()
|
) : ChapterTransition()
|
||||||
|
@ -144,7 +144,8 @@ class PagerTransitionHolder(
|
|||||||
.subscribe { state ->
|
.subscribe { state ->
|
||||||
pagesContainer.removeAllViews()
|
pagesContainer.removeAllViews()
|
||||||
when (state) {
|
when (state) {
|
||||||
is ReaderChapter.State.Wait -> {}
|
is ReaderChapter.State.Wait -> {
|
||||||
|
}
|
||||||
is ReaderChapter.State.Loading -> setLoading()
|
is ReaderChapter.State.Loading -> setLoading()
|
||||||
is ReaderChapter.State.Error -> setError(state.error)
|
is ReaderChapter.State.Error -> setError(state.error)
|
||||||
is ReaderChapter.State.Loaded -> setLoaded()
|
is ReaderChapter.State.Loaded -> setLoaded()
|
||||||
|
@ -147,7 +147,8 @@ class WebtoonTransitionHolder(
|
|||||||
.subscribe { state ->
|
.subscribe { state ->
|
||||||
pagesContainer.removeAllViews()
|
pagesContainer.removeAllViews()
|
||||||
when (state) {
|
when (state) {
|
||||||
is ReaderChapter.State.Wait -> {}
|
is ReaderChapter.State.Wait -> {
|
||||||
|
}
|
||||||
is ReaderChapter.State.Loading -> setLoading()
|
is ReaderChapter.State.Loading -> setLoading()
|
||||||
is ReaderChapter.State.Error -> setError(state.error, transition)
|
is ReaderChapter.State.Error -> setError(state.error, transition)
|
||||||
is ReaderChapter.State.Loaded -> setLoaded()
|
is ReaderChapter.State.Loaded -> setLoaded()
|
||||||
|
@ -17,9 +17,12 @@ class RecentChapterItem(val chapter: Chapter, val manga: Manga, header: DateItem
|
|||||||
|
|
||||||
var status: Int
|
var status: Int
|
||||||
get() = download?.status ?: _status
|
get() = download?.status ?: _status
|
||||||
set(value) { _status = value }
|
set(value) {
|
||||||
|
_status = value
|
||||||
|
}
|
||||||
|
|
||||||
@Transient var download: Download? = null
|
@Transient
|
||||||
|
var download: Download? = null
|
||||||
|
|
||||||
val isDownloaded: Boolean
|
val isDownloaded: Boolean
|
||||||
get() = status == Download.DOWNLOADED
|
get() = status == Download.DOWNLOADED
|
||||||
|
@ -38,8 +38,8 @@ class RecentChaptersPresenter(
|
|||||||
.subscribeLatestCache(RecentChaptersController::onNextRecentChapters)
|
.subscribeLatestCache(RecentChaptersController::onNextRecentChapters)
|
||||||
|
|
||||||
getChapterStatusObservable()
|
getChapterStatusObservable()
|
||||||
.subscribeLatestCache(RecentChaptersController::onChapterStatusChange) {
|
.subscribeLatestCache(RecentChaptersController::onChapterStatusChange) { _, error ->
|
||||||
_, error -> Timber.e(error)
|
Timber.e(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,8 @@ class RecentlyReadPresenter : BasePresenter<RecentlyReadController>() {
|
|||||||
|
|
||||||
((currChapterIndex + 1) until chapters.size)
|
((currChapterIndex + 1) until chapters.size)
|
||||||
.map { chapters[it] }
|
.map { chapters[it] }
|
||||||
.firstOrNull { it.chapter_number > chapterNumber &&
|
.firstOrNull {
|
||||||
|
it.chapter_number > chapterNumber &&
|
||||||
it.chapter_number <= chapterNumber + 1
|
it.chapter_number <= chapterNumber + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,8 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
defaultValue = "-1"
|
defaultValue = "-1"
|
||||||
|
|
||||||
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
|
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
|
||||||
summary = selectedCategory?.name ?: context.getString(R.string.default_category_summary)
|
summary = selectedCategory?.name
|
||||||
|
?: context.getString(R.string.default_category_summary)
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
summary = categories.find {
|
summary = categories.find {
|
||||||
it.id == (newValue as String).toInt()
|
it.id == (newValue as String).toInt()
|
||||||
|
@ -53,7 +53,8 @@ class WebViewActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource ?: return
|
val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource
|
||||||
|
?: return
|
||||||
val url = intent.extras!!.getString(URL_KEY) ?: return
|
val url = intent.extras!!.getString(URL_KEY) ?: return
|
||||||
val headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
val headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
||||||
|
|
||||||
|
@ -88,28 +88,42 @@ inline fun Preference.onChange(crossinline block: (Any?) -> Boolean) {
|
|||||||
|
|
||||||
var Preference.defaultValue: Any?
|
var Preference.defaultValue: Any?
|
||||||
get() = null // set only
|
get() = null // set only
|
||||||
set(value) { setDefaultValue(value) }
|
set(value) {
|
||||||
|
setDefaultValue(value)
|
||||||
|
}
|
||||||
|
|
||||||
var Preference.titleRes: Int
|
var Preference.titleRes: Int
|
||||||
get() = 0 // set only
|
get() = 0 // set only
|
||||||
set(value) { setTitle(value) }
|
set(value) {
|
||||||
|
setTitle(value)
|
||||||
|
}
|
||||||
|
|
||||||
var Preference.iconRes: Int
|
var Preference.iconRes: Int
|
||||||
get() = 0 // set only
|
get() = 0 // set only
|
||||||
set(value) { icon = VectorDrawableCompat.create(context.resources, value, context.theme) }
|
set(value) {
|
||||||
|
icon = VectorDrawableCompat.create(context.resources, value, context.theme)
|
||||||
|
}
|
||||||
|
|
||||||
var Preference.summaryRes: Int
|
var Preference.summaryRes: Int
|
||||||
get() = 0 // set only
|
get() = 0 // set only
|
||||||
set(value) { setSummary(value) }
|
set(value) {
|
||||||
|
setSummary(value)
|
||||||
|
}
|
||||||
|
|
||||||
var Preference.iconTint: Int
|
var Preference.iconTint: Int
|
||||||
get() = 0 // set only
|
get() = 0 // set only
|
||||||
set(value) { DrawableCompat.setTint(icon, value) }
|
set(value) {
|
||||||
|
DrawableCompat.setTint(icon, value)
|
||||||
|
}
|
||||||
|
|
||||||
var ListPreference.entriesRes: Array<Int>
|
var ListPreference.entriesRes: Array<Int>
|
||||||
get() = emptyArray() // set only
|
get() = emptyArray() // set only
|
||||||
set(value) { entries = value.map { context.getString(it) }.toTypedArray() }
|
set(value) {
|
||||||
|
entries = value.map { context.getString(it) }.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
var MultiSelectListPreference.entriesRes: Array<Int>
|
var MultiSelectListPreference.entriesRes: Array<Int>
|
||||||
get() = emptyArray() // set only
|
get() = emptyArray() // set only
|
||||||
set(value) { entries = value.map { context.getString(it) }.toTypedArray() }
|
set(value) {
|
||||||
|
entries = value.map { context.getString(it) }.toTypedArray()
|
||||||
|
}
|
||||||
|
@ -90,8 +90,7 @@ fun Context.getFilePicker(currentDir: String): Intent {
|
|||||||
* @param permission the permission to check.
|
* @param permission the permission to check.
|
||||||
* @return true if it has permissions.
|
* @return true if it has permissions.
|
||||||
*/
|
*/
|
||||||
fun Context.hasPermission(permission: String)
|
fun Context.hasPermission(permission: String) = ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
|
||||||
= ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the color for the given attribute.
|
* Returns the color for the given attribute.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.widget
|
package eu.kanade.tachiyomi.widget
|
||||||
|
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
|
|
||||||
open class SimpleSeekBarListener : SeekBar.OnSeekBarChangeListener {
|
open class SimpleSeekBarListener : SeekBar.OnSeekBarChangeListener {
|
||||||
|
@ -51,7 +51,7 @@ class LoginCheckBoxPreference @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make method public
|
// Make method public
|
||||||
override public fun notifyChanged() {
|
public override fun notifyChanged() {
|
||||||
super.notifyChanged()
|
super.notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
R.drawable.ic_done_green_24dp)
|
R.drawable.ic_done_green_24dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
override public fun notifyChanged() {
|
public override fun notifyChanged() {
|
||||||
super.notifyChanged()
|
super.notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user