mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Remove unused context from sources
This commit is contained in:
		| @@ -18,20 +18,7 @@ import java.io.File | ||||
|  | ||||
| open class SourceManager(private val context: Context) { | ||||
|  | ||||
|     val BATOTO = 1 | ||||
|     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() | ||||
|     private val sourcesMap = createSources() | ||||
|  | ||||
|     open fun get(sourceKey: Int): Source? { | ||||
|         return sourcesMap[sourceKey] | ||||
| @@ -39,24 +26,21 @@ open class SourceManager(private val context: Context) { | ||||
|  | ||||
|     fun getOnlineSources() = sourcesMap.values.filterIsInstance(OnlineSource::class.java) | ||||
|  | ||||
|     private fun createSource(id: Int): Source? = when (id) { | ||||
|         BATOTO -> Batoto(context, id) | ||||
|         KISSMANGA -> Kissmanga(context, id) | ||||
|         MANGAHERE -> Mangahere(context, id) | ||||
|         MANGAFOX -> Mangafox(context, id) | ||||
|         READMANGA -> Readmanga(context, id) | ||||
|         MINTMANGA -> Mintmanga(context, id) | ||||
|         MANGACHAN -> Mangachan(context, id) | ||||
|         READMANGATODAY -> Readmangatoday(context, id) | ||||
|         MANGASEE -> Mangasee(context, id) | ||||
|         WIEMANGA -> WieManga(context, id) | ||||
|         else -> null | ||||
|     } | ||||
|     private fun createOnlineSourceList(): List<Source> = listOf( | ||||
|         Batoto(1), | ||||
|         Kissmanga(2), | ||||
|         Mangahere(3), | ||||
|         Mangafox(4), | ||||
|         Readmanga(5), | ||||
|         Mintmanga(6), | ||||
|         Mangachan(7), | ||||
|         Readmangatoday(8), | ||||
|         Mangasee(9), | ||||
|         WieManga(10) | ||||
|     ) | ||||
|  | ||||
|     private fun createSources(): Map<Int, Source> = hashMapOf<Int, Source>().apply { | ||||
|         for (i in 1..LAST_SOURCE) { | ||||
|             createSource(i)?.let { put(i, it) } | ||||
|         } | ||||
|         createOnlineSourceList().forEach { put(it.id, it) } | ||||
|  | ||||
|         val parsersDir = File(Environment.getExternalStorageDirectory().absolutePath + | ||||
|                 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" }) { | ||||
|                 try { | ||||
|                     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) { | ||||
|                     Timber.e("Error loading source from file. Bad format?") | ||||
|                 } | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package eu.kanade.tachiyomi.data.source.online | ||||
|  | ||||
| import android.content.Context | ||||
| import eu.kanade.tachiyomi.data.cache.ChapterCache | ||||
| import eu.kanade.tachiyomi.data.database.models.Chapter | ||||
| 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. | ||||
|  * | ||||
|  * @param context the application context. | ||||
|  */ | ||||
| abstract class OnlineSource(context: Context) : Source { | ||||
| abstract class OnlineSource() : Source { | ||||
|  | ||||
|     /** | ||||
|      * Network service. | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| 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.Manga | ||||
| 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. | ||||
|  * | ||||
|  * @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]. | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| 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.Manga | ||||
| import eu.kanade.tachiyomi.data.network.GET | ||||
| @@ -17,7 +16,7 @@ import org.jsoup.nodes.Element | ||||
| import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
|  | ||||
| class YamlOnlineSource(context: Context, mappings: Map<*, *>) : OnlineSource(context) { | ||||
| class YamlOnlineSource(mappings: Map<*, *>) : OnlineSource() { | ||||
|  | ||||
|     val map = YamlSourceNode(mappings) | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package eu.kanade.tachiyomi.data.source.online.english | ||||
|  | ||||
| import android.content.Context | ||||
| import android.net.Uri | ||||
| import android.text.Html | ||||
| import eu.kanade.tachiyomi.data.database.models.Chapter | ||||
| @@ -28,7 +27,7 @@ import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
| 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" | ||||
|  | ||||
|   | ||||
| @@ -19,7 +19,7 @@ import org.jsoup.nodes.Element | ||||
| import java.text.SimpleDateFormat | ||||
| 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" | ||||
|  | ||||
|   | ||||
| @@ -15,7 +15,7 @@ import java.text.ParseException | ||||
| import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
|  | ||||
| class Mangafox(context: Context, override val id: Int) : ParsedOnlineSource(context) { | ||||
| class Mangafox(override val id: Int) : ParsedOnlineSource() { | ||||
|  | ||||
|     override val name = "Mangafox" | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,7 @@ import java.text.ParseException | ||||
| import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
|  | ||||
| class Mangahere(context: Context, override val id: Int) : ParsedOnlineSource(context) { | ||||
| class Mangahere(override val id: Int) : ParsedOnlineSource() { | ||||
|  | ||||
|     override val name = "Mangahere" | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,7 @@ import org.jsoup.nodes.Element | ||||
| import java.util.* | ||||
| 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" | ||||
|  | ||||
|   | ||||
| @@ -17,7 +17,7 @@ import org.jsoup.nodes.Document | ||||
| import org.jsoup.nodes.Element | ||||
| import java.util.* | ||||
|  | ||||
| class Readmangatoday(context: Context, override val id: Int) : ParsedOnlineSource(context) { | ||||
| class Readmangatoday(override val id: Int) : ParsedOnlineSource() { | ||||
|  | ||||
|     override val name = "ReadMangaToday" | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,7 @@ import org.jsoup.nodes.Document | ||||
| import org.jsoup.nodes.Element | ||||
| 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!" | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,7 @@ import org.jsoup.nodes.Element | ||||
| import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
|  | ||||
| class Mangachan(context: Context, override val id: Int) : ParsedOnlineSource(context) { | ||||
| class Mangachan(override val id: Int) : ParsedOnlineSource() { | ||||
|  | ||||
|     override val name = "Mangachan" | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,7 @@ import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
| 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" | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,7 @@ import java.text.SimpleDateFormat | ||||
| import java.util.* | ||||
| 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" | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user