Dynamic sources support
parent
77bb5c2fcd
commit
0d8820bcab
@ -0,0 +1,15 @@
|
|||||||
|
package org.koitharu.kotatsu.core.model.parcelable
|
||||||
|
|
||||||
|
import android.os.Parcel
|
||||||
|
import kotlinx.parcelize.Parceler
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
|
||||||
|
class MangaSourceParceler : Parceler<MangaSource> {
|
||||||
|
|
||||||
|
override fun create(parcel: Parcel): MangaSource = MangaSource(parcel.readString())
|
||||||
|
|
||||||
|
override fun MangaSource.write(parcel: Parcel, flags: Int) {
|
||||||
|
parcel.writeString(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,38 +1,52 @@
|
|||||||
package org.koitharu.kotatsu.core.parser
|
package org.koitharu.kotatsu.core.parser
|
||||||
|
|
||||||
import org.koitharu.kotatsu.core.exceptions.UnsupportedSourceException
|
import org.koitharu.kotatsu.core.exceptions.UnsupportedSourceException
|
||||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
import org.koitharu.kotatsu.parsers.model.ContentRating
|
||||||
import org.koitharu.kotatsu.parsers.MangaParser
|
|
||||||
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaListFilter
|
import org.koitharu.kotatsu.parsers.model.MangaListFilter
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaState
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
import org.koitharu.kotatsu.parsers.model.SortOrder
|
import org.koitharu.kotatsu.parsers.model.SortOrder
|
||||||
import java.util.EnumSet
|
import java.util.EnumSet
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This parser is just for parser development, it should not be used in releases
|
* This parser is just for parser development, it should not be used in releases
|
||||||
*/
|
*/
|
||||||
class EmptyParser(context: MangaLoaderContext) : MangaParser(context, MangaSource.DUMMY) {
|
class EmptyMangaRepository(override val source: MangaSource) : MangaRepository {
|
||||||
|
|
||||||
override val configKeyDomain: ConfigKey.Domain
|
override val sortOrders: Set<SortOrder>
|
||||||
get() = ConfigKey.Domain("localhost")
|
|
||||||
|
|
||||||
override val availableSortOrders: Set<SortOrder>
|
|
||||||
get() = EnumSet.allOf(SortOrder::class.java)
|
get() = EnumSet.allOf(SortOrder::class.java)
|
||||||
|
override val states: Set<MangaState>
|
||||||
override suspend fun getDetails(manga: Manga): Manga = stub(manga)
|
get() = emptySet()
|
||||||
|
override val contentRatings: Set<ContentRating>
|
||||||
|
get() = emptySet()
|
||||||
|
override var defaultSortOrder: SortOrder
|
||||||
|
get() = SortOrder.NEWEST
|
||||||
|
set(value) = Unit
|
||||||
|
override val isMultipleTagsSupported: Boolean
|
||||||
|
get() = false
|
||||||
|
override val isTagsExclusionSupported: Boolean
|
||||||
|
get() = false
|
||||||
|
override val isSearchSupported: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
override suspend fun getList(offset: Int, filter: MangaListFilter?): List<Manga> = stub(null)
|
override suspend fun getList(offset: Int, filter: MangaListFilter?): List<Manga> = stub(null)
|
||||||
|
|
||||||
|
override suspend fun getDetails(manga: Manga): Manga = stub(manga)
|
||||||
|
|
||||||
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> = stub(null)
|
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> = stub(null)
|
||||||
|
|
||||||
override suspend fun getAvailableTags(): Set<MangaTag> = stub(null)
|
override suspend fun getPageUrl(page: MangaPage): String = stub(null)
|
||||||
|
|
||||||
|
override suspend fun getTags(): Set<MangaTag> = stub(null)
|
||||||
|
|
||||||
|
override suspend fun getLocales(): Set<Locale> = stub(null)
|
||||||
|
|
||||||
override suspend fun getRelatedManga(seed: Manga): List<Manga> = stub(seed)
|
override suspend fun getRelated(seed: Manga): List<Manga> = stub(seed)
|
||||||
|
|
||||||
private fun stub(manga: Manga?): Nothing {
|
private fun stub(manga: Manga?): Nothing {
|
||||||
throw UnsupportedSourceException("This manga source is not supported", manga)
|
throw UnsupportedSourceException("This manga source is not supported", manga)
|
||||||
@ -1,12 +1,10 @@
|
|||||||
package org.koitharu.kotatsu.favourites.domain.model
|
package org.koitharu.kotatsu.favourites.domain.model
|
||||||
|
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.core.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.util.find
|
|
||||||
|
|
||||||
data class Cover(
|
data class Cover(
|
||||||
val url: String,
|
val url: String,
|
||||||
val source: String,
|
val source: String,
|
||||||
) {
|
) {
|
||||||
val mangaSource: MangaSource?
|
val mangaSource by lazy { MangaSource(source) }
|
||||||
get() = if (source.isEmpty()) null else MangaSource.entries.find(source)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue