Rename OnlineSource to HttpSource

This commit is contained in:
len 2017-01-20 21:27:53 +01:00
parent 706163e7a6
commit f807447de1
28 changed files with 69 additions and 69 deletions

View File

@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
/** /**
@ -93,7 +93,7 @@ class DownloadStore(context: Context) {
val manga = cachedManga.getOrPut(mangaId) { val manga = cachedManga.getOrPut(mangaId) {
db.getManga(mangaId).executeAsBlocking() db.getManga(mangaId).executeAsBlocking()
} ?: continue } ?: continue
val source = sourceManager.get(manga.source) as? OnlineSource ?: continue val source = sourceManager.get(manga.source) as? HttpSource ?: continue
val chapter = db.getChapter(chapterId).executeAsBlocking() ?: continue val chapter = db.getChapter(chapterId).executeAsBlocking() ?: continue
downloads.add(Download(source, manga, chapter)) downloads.add(Download(source, manga, chapter))
} }

View File

@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.data.download.model.DownloadQueue
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList
import eu.kanade.tachiyomi.util.DynamicConcurrentMergeOperator import eu.kanade.tachiyomi.util.DynamicConcurrentMergeOperator
import eu.kanade.tachiyomi.util.RetryWithDelay import eu.kanade.tachiyomi.util.RetryWithDelay
@ -220,7 +220,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
* @param chapters the list of chapters to download. * @param chapters the list of chapters to download.
*/ */
fun queueChapters(manga: Manga, chapters: List<Chapter>) { fun queueChapters(manga: Manga, chapters: List<Chapter>) {
val source = sourceManager.get(manga.source) as? OnlineSource ?: return val source = sourceManager.get(manga.source) as? HttpSource ?: return
val chaptersToQueue = chapters val chaptersToQueue = chapters
// Avoid downloading chapters with the same name. // Avoid downloading chapters with the same name.
@ -373,7 +373,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
* @param tmpDir the temporary directory of the download. * @param tmpDir the temporary directory of the download.
* @param filename the filename of the image. * @param filename the filename of the image.
*/ */
private fun downloadImage(page: Page, source: OnlineSource, tmpDir: UniFile, filename: String): Observable<UniFile> { private fun downloadImage(page: Page, source: HttpSource, tmpDir: UniFile, filename: String): Observable<UniFile> {
page.status = Page.DOWNLOAD_IMAGE page.status = Page.DOWNLOAD_IMAGE
page.progress = 0 page.progress = 0
return source.fetchImage(page) return source.fetchImage(page)

View File

@ -3,10 +3,10 @@ package eu.kanade.tachiyomi.data.download.model
import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import rx.subjects.PublishSubject import rx.subjects.PublishSubject
class Download(val source: OnlineSource, val manga: Manga, val chapter: Chapter) { class Download(val source: HttpSource, val manga: Manga, val chapter: Chapter) {
var pages: List<Page>? = null var pages: List<Page>? = null

View File

@ -9,7 +9,7 @@ import com.bumptech.glide.load.model.stream.StreamModelLoader
import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
@ -102,7 +102,7 @@ class MangaModelLoader(context: Context) : StreamModelLoader<Manga> {
* @param manga the model. * @param manga the model.
*/ */
fun getHeaders(manga: Manga): Headers { fun getHeaders(manga: Manga): Headers {
val source = sourceManager.get(manga.source) as? OnlineSource ?: return LazyHeaders.DEFAULT val source = sourceManager.get(manga.source) as? HttpSource ?: return LazyHeaders.DEFAULT
return cachedHeaders.getOrPut(manga.source) { return cachedHeaders.getOrPut(manga.source) {
LazyHeaders.Builder().apply { LazyHeaders.Builder().apply {
val nullStr: String? = null val nullStr: String? = null

View File

@ -22,7 +22,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.util.* import eu.kanade.tachiyomi.util.*
import rx.Observable import rx.Observable
@ -300,7 +300,7 @@ class LibraryUpdateService : Service() {
* @return a pair of the inserted and removed chapters. * @return a pair of the inserted and removed chapters.
*/ */
fun updateManga(manga: Manga): Observable<Pair<List<Chapter>, List<Chapter>>> { fun updateManga(manga: Manga): Observable<Pair<List<Chapter>, List<Chapter>>> {
val source = sourceManager.get(manga.source) as? OnlineSource ?: return Observable.empty() val source = sourceManager.get(manga.source) as? HttpSource ?: return Observable.empty()
return source.fetchChapterList(manga) return source.fetchChapterList(manga)
.map { syncChaptersWithSource(db, it, manga, source) } .map { syncChaptersWithSource(db, it, manga, source) }
} }
@ -324,7 +324,7 @@ class LibraryUpdateService : Service() {
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size, cancelPendingIntent) } .doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size, cancelPendingIntent) }
// Update the details of the manga. // Update the details of the manga.
.concatMap { manga -> .concatMap { manga ->
val source = sourceManager.get(manga.source) as? OnlineSource val source = sourceManager.get(manga.source) as? HttpSource
?: return@concatMap Observable.empty<Manga>() ?: return@concatMap Observable.empty<Manga>()
source.fetchMangaDetails(manga) source.fetchMangaDetails(manga)

View File

@ -7,8 +7,8 @@ import android.content.pm.PackageManager
import android.os.Environment import android.os.Environment
import dalvik.system.PathClassLoader import dalvik.system.PathClassLoader
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.online.YamlOnlineSource import eu.kanade.tachiyomi.source.online.YamlHttpSource
import eu.kanade.tachiyomi.source.online.english.* import eu.kanade.tachiyomi.source.online.english.*
import eu.kanade.tachiyomi.source.online.german.WieManga import eu.kanade.tachiyomi.source.online.german.WieManga
import eu.kanade.tachiyomi.source.online.russian.Mangachan import eu.kanade.tachiyomi.source.online.russian.Mangachan
@ -31,7 +31,7 @@ open class SourceManager(private val context: Context) {
return sourcesMap[sourceKey] return sourcesMap[sourceKey]
} }
fun getOnlineSources() = sourcesMap.values.filterIsInstance<OnlineSource>() fun getOnlineSources() = sourcesMap.values.filterIsInstance<HttpSource>()
fun getCatalogueSources() = sourcesMap.values.filterIsInstance<CatalogueSource>() fun getCatalogueSources() = sourcesMap.values.filterIsInstance<CatalogueSource>()
@ -71,7 +71,7 @@ open class SourceManager(private val context: Context) {
for (file in parsersDir.listFiles().filter { it.extension == "yml" }) { for (file in parsersDir.listFiles().filter { it.extension == "yml" }) {
try { try {
val map = file.inputStream().use { yaml.loadAs(it, Map::class.java) } val map = file.inputStream().use { yaml.loadAs(it, Map::class.java) }
sources.add(YamlOnlineSource(map)) sources.add(YamlHttpSource(map))
} catch (e: Exception) { } catch (e: Exception) {
Timber.e("Error loading source from file. Bad format?") Timber.e("Error loading source from file. Bad format?")
} }
@ -80,13 +80,13 @@ open class SourceManager(private val context: Context) {
return sources return sources
} }
private fun createExtensionSources(): List<OnlineSource> { private fun createExtensionSources(): List<HttpSource> {
val pkgManager = context.packageManager val pkgManager = context.packageManager
val flags = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES val flags = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
val installedPkgs = pkgManager.getInstalledPackages(flags) val installedPkgs = pkgManager.getInstalledPackages(flags)
val extPkgs = installedPkgs.filter { it.reqFeatures.orEmpty().any { it.name == FEATURE } } val extPkgs = installedPkgs.filter { it.reqFeatures.orEmpty().any { it.name == FEATURE } }
val sources = mutableListOf<OnlineSource>() val sources = mutableListOf<HttpSource>()
for (pkgInfo in extPkgs) { for (pkgInfo in extPkgs) {
val appInfo = pkgManager.getApplicationInfo(pkgInfo.packageName, val appInfo = pkgManager.getApplicationInfo(pkgInfo.packageName,
PackageManager.GET_META_DATA) ?: continue PackageManager.GET_META_DATA) ?: continue
@ -121,12 +121,12 @@ open class SourceManager(private val context: Context) {
return true return true
} }
private fun loadExtension(ext: Extension, pkgManager: PackageManager): OnlineSource? { private fun loadExtension(ext: Extension, pkgManager: PackageManager): HttpSource? {
return try { return try {
val classLoader = PathClassLoader(ext.appInfo.sourceDir, null, context.classLoader) val classLoader = PathClassLoader(ext.appInfo.sourceDir, null, context.classLoader)
val resources = pkgManager.getResourcesForApplication(ext.appInfo) val resources = pkgManager.getResourcesForApplication(ext.appInfo)
Class.forName(ext.sourceClass, false, classLoader).newInstance() as? OnlineSource Class.forName(ext.sourceClass, false, classLoader).newInstance() as? HttpSource
} catch (e: Exception) { } catch (e: Exception) {
null null
} catch (e: LinkageError) { } catch (e: LinkageError) {

View File

@ -1,10 +1,10 @@
package eu.kanade.tachiyomi.source.online package eu.kanade.tachiyomi.source.online
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.network.newCallWithProgress import eu.kanade.tachiyomi.network.newCallWithProgress
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import okhttp3.Headers import okhttp3.Headers
@ -20,7 +20,7 @@ import java.security.MessageDigest
/** /**
* A simple implementation for sources from a website. * A simple implementation for sources from a website.
*/ */
abstract class OnlineSource : CatalogueSource { abstract class HttpSource : CatalogueSource {
/** /**
* Network service. * Network service.

View File

@ -21,7 +21,7 @@ private val chapterCache: ChapterCache by injectLazy()
* *
* @param chapter the chapter whose page list has to be fetched. * @param chapter the chapter whose page list has to be fetched.
*/ */
fun OnlineSource.fetchPageListFromCacheThenNet(chapter: Chapter): Observable<List<Page>> { fun HttpSource.fetchPageListFromCacheThenNet(chapter: Chapter): Observable<List<Page>> {
return chapterCache return chapterCache
.getPageListFromCache(chapter) .getPageListFromCache(chapter)
.onErrorResumeNext { fetchPageList(chapter) } .onErrorResumeNext { fetchPageList(chapter) }
@ -32,14 +32,14 @@ fun OnlineSource.fetchPageListFromCacheThenNet(chapter: Chapter): Observable<Lis
* *
* @param page the page whose source image has to be downloaded. * @param page the page whose source image has to be downloaded.
*/ */
fun OnlineSource.fetchImageFromCacheThenNet(page: Page): Observable<Page> { fun HttpSource.fetchImageFromCacheThenNet(page: Page): Observable<Page> {
return if (page.imageUrl.isNullOrEmpty()) return if (page.imageUrl.isNullOrEmpty())
getImageUrl(page).flatMap { getCachedImage(it) } getImageUrl(page).flatMap { getCachedImage(it) }
else else
getCachedImage(page) getCachedImage(page)
} }
fun OnlineSource.getImageUrl(page: Page): Observable<Page> { fun HttpSource.getImageUrl(page: Page): Observable<Page> {
page.status = Page.LOAD_PAGE page.status = Page.LOAD_PAGE
return fetchImageUrl(page) return fetchImageUrl(page)
.doOnError { page.status = Page.ERROR } .doOnError { page.status = Page.ERROR }
@ -54,7 +54,7 @@ fun OnlineSource.getImageUrl(page: Page): Observable<Page> {
* *
* @param page the page. * @param page the page.
*/ */
fun OnlineSource.getCachedImage(page: Page): Observable<Page> { fun HttpSource.getCachedImage(page: Page): Observable<Page> {
val imageUrl = page.imageUrl ?: return Observable.just(page) val imageUrl = page.imageUrl ?: return Observable.just(page)
return Observable.just(page) return Observable.just(page)
@ -78,20 +78,20 @@ fun OnlineSource.getCachedImage(page: Page): Observable<Page> {
* *
* @param page the page. * @param page the page.
*/ */
private fun OnlineSource.cacheImage(page: Page): Observable<Page> { private fun HttpSource.cacheImage(page: Page): Observable<Page> {
page.status = Page.DOWNLOAD_IMAGE page.status = Page.DOWNLOAD_IMAGE
return fetchImage(page) return fetchImage(page)
.doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it) } .doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it) }
.map { page } .map { page }
} }
fun OnlineSource.fetchAllImageUrlsFromPageList(pages: List<Page>): Observable<Page> { fun HttpSource.fetchAllImageUrlsFromPageList(pages: List<Page>): Observable<Page> {
return Observable.from(pages) return Observable.from(pages)
.filter { !it.imageUrl.isNullOrEmpty() } .filter { !it.imageUrl.isNullOrEmpty() }
.mergeWith(fetchRemainingImageUrlsFromPageList(pages)) .mergeWith(fetchRemainingImageUrlsFromPageList(pages))
} }
fun OnlineSource.fetchRemainingImageUrlsFromPageList(pages: List<Page>): Observable<Page> { fun HttpSource.fetchRemainingImageUrlsFromPageList(pages: List<Page>): Observable<Page> {
return Observable.from(pages) return Observable.from(pages)
.filter { it.imageUrl.isNullOrEmpty() } .filter { it.imageUrl.isNullOrEmpty() }
.concatMap { getImageUrl(it) } .concatMap { getImageUrl(it) }

View File

@ -12,7 +12,7 @@ import org.jsoup.nodes.Element
/** /**
* A simple implementation for sources from a website using Jsoup, an HTML parser. * A simple implementation for sources from a website using Jsoup, an HTML parser.
*/ */
abstract class ParsedOnlineSource : OnlineSource() { abstract class ParsedHttpSource : HttpSource() {
/** /**
* Parses the response from the site and returns a [MangasPage] object. * Parses the response from the site and returns a [MangasPage] object.

View File

@ -12,7 +12,7 @@ import org.jsoup.nodes.Element
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
class YamlOnlineSource(mappings: Map<*, *>) : OnlineSource() { class YamlHttpSource(mappings: Map<*, *>) : HttpSource() {
val map = YamlSourceNode(mappings) val map = YamlSourceNode(mappings)

View File

@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.asObservable import eu.kanade.tachiyomi.network.asObservable
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.LoginSource import eu.kanade.tachiyomi.source.online.LoginSource
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import eu.kanade.tachiyomi.util.selectText import eu.kanade.tachiyomi.util.selectText
import okhttp3.FormBody import okhttp3.FormBody
@ -22,7 +22,7 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
class Batoto : ParsedOnlineSource(), LoginSource { class Batoto : ParsedHttpSource(), LoginSource {
override val id: Long = 1 override val id: Long = 1

View File

@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.source.online.english
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
@ -13,7 +13,7 @@ import org.jsoup.nodes.Element
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.regex.Pattern import java.util.regex.Pattern
class Kissmanga : ParsedOnlineSource() { class Kissmanga : ParsedHttpSource() {
override val id: Long = 4 override val id: Long = 4

View File

@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.english
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.Request import okhttp3.Request
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
@ -11,7 +11,7 @@ import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
class Mangafox : ParsedOnlineSource() { class Mangafox : ParsedHttpSource() {
override val id: Long = 3 override val id: Long = 3

View File

@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.english
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.Request import okhttp3.Request
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
@ -11,7 +11,7 @@ import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
class Mangahere : ParsedOnlineSource() { class Mangahere : ParsedHttpSource() {
override val id: Long = 2 override val id: Long = 2

View File

@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.english
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.Request import okhttp3.Request
@ -11,7 +11,7 @@ import org.jsoup.nodes.Element
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.regex.Pattern import java.util.regex.Pattern
class Mangasee : ParsedOnlineSource() { class Mangasee : ParsedHttpSource() {
override val id: Long = 9 override val id: Long = 9

View File

@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.source.online.english
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.Headers import okhttp3.Headers
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
@ -11,7 +11,7 @@ import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.util.* import java.util.*
class Readmangatoday : ParsedOnlineSource() { class Readmangatoday : ParsedHttpSource() {
override val id: Long = 8 override val id: Long = 8

View File

@ -5,13 +5,13 @@ import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.Request import okhttp3.Request
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
class WieManga : ParsedOnlineSource() { class WieManga : ParsedHttpSource() {
override val id: Long = 10 override val id: Long = 10

View File

@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.russian
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
@ -11,7 +11,7 @@ import org.jsoup.nodes.Element
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
class Mangachan : ParsedOnlineSource() { class Mangachan : ParsedHttpSource() {
override val id: Long = 7 override val id: Long = 7

View File

@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.russian
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
@ -11,7 +11,7 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
class Mintmanga : ParsedOnlineSource() { class Mintmanga : ParsedHttpSource() {
override val id: Long = 6 override val id: Long = 6

View File

@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.russian
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedOnlineSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
@ -11,7 +11,7 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
class Readmanga : ParsedOnlineSource() { class Readmanga : ParsedHttpSource() {
override val id: Long = 5 override val id: Long = 5

View File

@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
import eu.kanade.tachiyomi.ui.manga.MangaActivity import eu.kanade.tachiyomi.ui.manga.MangaActivity
import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.getResourceColor
@ -164,7 +164,7 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
* Open the manga in browser. * Open the manga in browser.
*/ */
fun openInBrowser() { fun openInBrowser() {
val source = presenter.source as? OnlineSource ?: return val source = presenter.source as? HttpSource ?: return
try { try {
val url = Uri.parse(source.baseUrl + presenter.manga.url) val url = Uri.parse(source.baseUrl + presenter.manga.url)
val intent = CustomTabsIntent.Builder() val intent = CustomTabsIntent.Builder()
@ -180,7 +180,7 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
* Called to run Intent with [Intent.ACTION_SEND], which show share dialog. * Called to run Intent with [Intent.ACTION_SEND], which show share dialog.
*/ */
private fun shareManga() { private fun shareManga() {
val source = presenter.source as? OnlineSource ?: return val source = presenter.source as? HttpSource ?: return
try { try {
val url = source.mangaDetailsRequest(presenter.manga).url().toString() val url = source.mangaDetailsRequest(presenter.manga).url().toString()
val sharingIntent = Intent(Intent.ACTION_SEND).apply { val sharingIntent = Intent(Intent.ACTION_SEND).apply {

View File

@ -4,7 +4,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.online.fetchImageFromCacheThenNet import eu.kanade.tachiyomi.source.online.fetchImageFromCacheThenNet
import eu.kanade.tachiyomi.source.online.fetchPageListFromCacheThenNet import eu.kanade.tachiyomi.source.online.fetchPageListFromCacheThenNet
import eu.kanade.tachiyomi.util.plusAssign import eu.kanade.tachiyomi.util.plusAssign
@ -39,7 +39,7 @@ class ChapterLoader(
} }
private fun prepareOnlineReading() { private fun prepareOnlineReading() {
if (source !is OnlineSource) return if (source !is HttpSource) return
subscriptions += Observable.defer { Observable.just(queue.take().page) } subscriptions += Observable.defer { Observable.just(queue.take().page) }
.filter { it.status == Page.QUEUE } .filter { it.status == Page.QUEUE }
@ -85,7 +85,7 @@ class ChapterLoader(
// Fetch the page list from disk. // Fetch the page list from disk.
downloadManager.buildPageList(source, manga, chapter) downloadManager.buildPageList(source, manga, chapter)
} else { } else {
(source as? OnlineSource)?.fetchPageListFromCacheThenNet(chapter) (source as? HttpSource)?.fetchPageListFromCacheThenNet(chapter)
?: source.fetchPageList(chapter) ?: source.fetchPageList(chapter)
} }
} }

View File

@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.track.TrackUpdateService import eu.kanade.tachiyomi.data.track.TrackUpdateService
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
@ -348,7 +348,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
* @param page the page that failed. * @param page the page that failed.
*/ */
fun retryPage(page: Page?) { fun retryPage(page: Page?) {
if (page != null && source is OnlineSource) { if (page != null && source is HttpSource) {
page.status = Page.QUEUE page.status = Page.QUEUE
val uri = page.uri val uri = page.uri
if (uri != null && !page.chapter.isDownloaded) { if (uri != null && !page.chapter.isDownloaded) {
@ -372,7 +372,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
// Cache current page list progress for online chapters to allow a faster reopen // Cache current page list progress for online chapters to allow a faster reopen
if (!chapter.isDownloaded) { if (!chapter.isDownloaded) {
source.let { source.let {
if (it is OnlineSource) chapterCache.putPageListToCache(chapter, pages) if (it is HttpSource) chapterCache.putPageListToCache(chapter, pages)
} }
} }

View File

@ -8,7 +8,7 @@ import android.view.View
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.widget.preference.LoginCheckBoxPreference import eu.kanade.tachiyomi.widget.preference.LoginCheckBoxPreference
import eu.kanade.tachiyomi.widget.preference.SourceLoginDialog import eu.kanade.tachiyomi.widget.preference.SourceLoginDialog
import eu.kanade.tachiyomi.widget.preference.SwitchPreferenceCategory import eu.kanade.tachiyomi.widget.preference.SwitchPreferenceCategory
@ -87,7 +87,7 @@ class SettingsSourcesFragment : SettingsFragment() {
* *
* @param group the language category. * @param group the language category.
*/ */
private fun addLanguageSources(group: SwitchPreferenceCategory, sources: List<OnlineSource>) { private fun addLanguageSources(group: SwitchPreferenceCategory, sources: List<HttpSource>) {
val hiddenCatalogues = preferences.hiddenCatalogues().getOrDefault() val hiddenCatalogues = preferences.hiddenCatalogues().getOrDefault()
sources.forEach { source -> sources.forEach { source ->

View File

@ -5,7 +5,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import java.util.* import java.util.*
/** /**
@ -42,7 +42,7 @@ fun syncChaptersWithSource(db: DatabaseHelper,
// Recognize number for new chapters. // Recognize number for new chapters.
toAdd.forEach { toAdd.forEach {
if (source is OnlineSource) { if (source is HttpSource) {
source.prepareNewChapter(it, manga) source.prepareNewChapter(it, manga)
} }
ChapterRecognition.parseChapterNumber(it, manga) ChapterRecognition.parseChapterNumber(it, manga)

View File

@ -7,7 +7,7 @@ import android.util.AttributeSet
import android.view.View import android.view.View
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.online.LoginSource import eu.kanade.tachiyomi.source.online.LoginSource
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.getResourceColor
import eu.kanade.tachiyomi.util.setVectorCompat import eu.kanade.tachiyomi.util.setVectorCompat
import kotlinx.android.synthetic.main.pref_item_source.view.* import kotlinx.android.synthetic.main.pref_item_source.view.*
@ -15,7 +15,7 @@ import net.xpece.android.support.preference.CheckBoxPreference
class LoginCheckBoxPreference @JvmOverloads constructor( class LoginCheckBoxPreference @JvmOverloads constructor(
context: Context, context: Context,
val source: OnlineSource, val source: HttpSource,
attrs: AttributeSet? = null attrs: AttributeSet? = null
) : CheckBoxPreference(context, attrs) { ) : CheckBoxPreference(context, attrs) {

View File

@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.online.OnlineSource import eu.kanade.tachiyomi.source.online.HttpSource
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
@ -35,7 +35,7 @@ class LibraryUpdateServiceTest {
lateinit var app: Application lateinit var app: Application
lateinit var context: Context lateinit var context: Context
lateinit var service: LibraryUpdateService lateinit var service: LibraryUpdateService
lateinit var source: OnlineSource lateinit var source: HttpSource
@Before @Before
fun setup() { fun setup() {
@ -51,7 +51,7 @@ class LibraryUpdateServiceTest {
Injekt.importModule(module) Injekt.importModule(module)
service = Robolectric.setupService(LibraryUpdateService::class.java) service = Robolectric.setupService(LibraryUpdateService::class.java)
source = mock(OnlineSource::class.java) source = mock(HttpSource::class.java)
`when`(service.sourceManager.get(anyLong())).thenReturn(source) `when`(service.sourceManager.get(anyLong())).thenReturn(source)
} }