mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 01:11:48 +01:00
Remove unused context from sources
This commit is contained in:
parent
aebc9a3b9e
commit
876831480a
@ -22,8 +22,7 @@
|
|||||||
android:largeHeap="true"
|
android:largeHeap="true"
|
||||||
android:theme="@style/Theme.Tachiyomi" >
|
android:theme="@style/Theme.Tachiyomi" >
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.main.MainActivity"
|
android:name=".ui.main.MainActivity">
|
||||||
android:theme="@style/Theme.BrandedLaunch">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -18,20 +18,7 @@ import java.io.File
|
|||||||
|
|
||||||
open class SourceManager(private val context: Context) {
|
open class SourceManager(private val context: Context) {
|
||||||
|
|
||||||
val BATOTO = 1
|
private val sourcesMap = createSources()
|
||||||
val MANGAHERE = 2
|
|
||||||
val MANGAFOX = 3
|
|
||||||
val KISSMANGA = 4
|
|
||||||
val READMANGA = 5
|
|
||||||
val MINTMANGA = 6
|
|
||||||
val MANGACHAN = 7
|
|
||||||
val READMANGATODAY = 8
|
|
||||||
val MANGASEE = 9
|
|
||||||
val WIEMANGA = 10
|
|
||||||
|
|
||||||
val LAST_SOURCE = 10
|
|
||||||
|
|
||||||
val sourcesMap = createSources()
|
|
||||||
|
|
||||||
open fun get(sourceKey: Int): Source? {
|
open fun get(sourceKey: Int): Source? {
|
||||||
return sourcesMap[sourceKey]
|
return sourcesMap[sourceKey]
|
||||||
@ -39,24 +26,21 @@ open class SourceManager(private val context: Context) {
|
|||||||
|
|
||||||
fun getOnlineSources() = sourcesMap.values.filterIsInstance(OnlineSource::class.java)
|
fun getOnlineSources() = sourcesMap.values.filterIsInstance(OnlineSource::class.java)
|
||||||
|
|
||||||
private fun createSource(id: Int): Source? = when (id) {
|
private fun createOnlineSourceList(): List<Source> = listOf(
|
||||||
BATOTO -> Batoto(context, id)
|
Batoto(1),
|
||||||
KISSMANGA -> Kissmanga(context, id)
|
Kissmanga(2),
|
||||||
MANGAHERE -> Mangahere(context, id)
|
Mangahere(3),
|
||||||
MANGAFOX -> Mangafox(context, id)
|
Mangafox(4),
|
||||||
READMANGA -> Readmanga(context, id)
|
Readmanga(5),
|
||||||
MINTMANGA -> Mintmanga(context, id)
|
Mintmanga(6),
|
||||||
MANGACHAN -> Mangachan(context, id)
|
Mangachan(7),
|
||||||
READMANGATODAY -> Readmangatoday(context, id)
|
Readmangatoday(8),
|
||||||
MANGASEE -> Mangasee(context, id)
|
Mangasee(9),
|
||||||
WIEMANGA -> WieManga(context, id)
|
WieManga(10)
|
||||||
else -> null
|
)
|
||||||
}
|
|
||||||
|
|
||||||
private fun createSources(): Map<Int, Source> = hashMapOf<Int, Source>().apply {
|
private fun createSources(): Map<Int, Source> = hashMapOf<Int, Source>().apply {
|
||||||
for (i in 1..LAST_SOURCE) {
|
createOnlineSourceList().forEach { put(it.id, it) }
|
||||||
createSource(i)?.let { put(i, it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
val parsersDir = File(Environment.getExternalStorageDirectory().absolutePath +
|
val parsersDir = File(Environment.getExternalStorageDirectory().absolutePath +
|
||||||
File.separator + context.getString(R.string.app_name), "parsers")
|
File.separator + context.getString(R.string.app_name), "parsers")
|
||||||
@ -66,7 +50,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) }
|
||||||
YamlOnlineSource(context, map).let { put(it.id, it) }
|
YamlOnlineSource(map).let { put(it.id, it) }
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e("Error loading source from file. Bad format?")
|
Timber.e("Error loading source from file. Bad format?")
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.source.online
|
package eu.kanade.tachiyomi.data.source.online
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||||
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
|
||||||
@ -23,10 +22,8 @@ import uy.kohesive.injekt.injectLazy
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple implementation for sources from a website.
|
* A simple implementation for sources from a website.
|
||||||
*
|
|
||||||
* @param context the application context.
|
|
||||||
*/
|
*/
|
||||||
abstract class OnlineSource(context: Context) : Source {
|
abstract class OnlineSource() : Source {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Network service.
|
* Network service.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.source.online
|
package eu.kanade.tachiyomi.data.source.online
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
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.data.source.model.MangasPage
|
import eu.kanade.tachiyomi.data.source.model.MangasPage
|
||||||
@ -12,10 +11,8 @@ 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.
|
||||||
*
|
|
||||||
* @param context the application context.
|
|
||||||
*/
|
*/
|
||||||
abstract class ParsedOnlineSource(context: Context) : OnlineSource(context) {
|
abstract class ParsedOnlineSource() : OnlineSource() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the response from the site and fills [page].
|
* Parse the response from the site and fills [page].
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.source.online
|
package eu.kanade.tachiyomi.data.source.online
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
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.data.network.GET
|
import eu.kanade.tachiyomi.data.network.GET
|
||||||
@ -17,7 +16,7 @@ import org.jsoup.nodes.Element
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class YamlOnlineSource(context: Context, mappings: Map<*, *>) : OnlineSource(context) {
|
class YamlOnlineSource(mappings: Map<*, *>) : OnlineSource() {
|
||||||
|
|
||||||
val map = YamlSourceNode(mappings)
|
val map = YamlSourceNode(mappings)
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.source.online.english
|
package eu.kanade.tachiyomi.data.source.online.english
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
@ -28,7 +27,7 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(context), LoginSource {
|
class Batoto(override val id: Int) : ParsedOnlineSource(), LoginSource {
|
||||||
|
|
||||||
override val name = "Batoto"
|
override val name = "Batoto"
|
||||||
|
|
||||||
|
@ -19,7 +19,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(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Kissmanga(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Kissmanga"
|
override val name = "Kissmanga"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import java.text.ParseException
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class Mangafox(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Mangafox(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Mangafox"
|
override val name = "Mangafox"
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import java.text.ParseException
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class Mangahere(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Mangahere(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Mangahere"
|
override val name = "Mangahere"
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.jsoup.nodes.Element
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class Mangasee(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Mangasee(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Mangasee"
|
override val name = "Mangasee"
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import org.jsoup.nodes.Document
|
|||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class Readmangatoday(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Readmangatoday(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "ReadMangaToday"
|
override val name = "ReadMangaToday"
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ 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(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class WieManga(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Wie Manga!"
|
override val name = "Wie Manga!"
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import org.jsoup.nodes.Element
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class Mangachan(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Mangachan(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Mangachan"
|
override val name = "Mangachan"
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class Mintmanga(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Mintmanga(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Mintmanga"
|
override val name = "Mintmanga"
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class Readmanga(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
class Readmanga(override val id: Int) : ParsedOnlineSource() {
|
||||||
|
|
||||||
override val name = "Readmanga"
|
override val name = "Readmanga"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user