Skip to content

Commit

Permalink
re-organize methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Jul 4, 2024
1 parent 1e72dfc commit 119a7e4
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.source
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.SManga
import rx.Observable

@Suppress("unused")
interface CatalogueSource : Source {
Expand All @@ -19,27 +18,30 @@ interface CatalogueSource : Source {
val supportsLatest: Boolean

/**
* Returns an observable containing a page with a list of manga.
* Get a page with a list of manga.
*
* @since extensions-lib 1.5
* @param page the page number to retrieve.
*/
fun fetchPopularManga(page: Int): Observable<MangasPage>
suspend fun getPopularManga(page: Int): MangasPage

/**
* Returns an observable containing a page with a list of manga.
* Get a page with a list of manga.
*
* @since extensions-lib 1.5
* @param page the page number to retrieve.
* @param query the search query.
* @param filters the list of filters to apply.
*/
fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage>
suspend fun getSearchManga(page: Int, query: String, filters: FilterList): MangasPage

/**
* Returns an observable containing a page with a list of latest manga updates.
* Get a page with a list of latest manga updates.
*
* @since extensions-lib 1.5
* @param page the page number to retrieve.
*/
fun fetchLatestUpdates(page: Int): Observable<MangasPage>
suspend fun getLatestUpdates(page: Int): MangasPage

/**
* Returns the list of filters for the source.
Expand Down Expand Up @@ -106,8 +108,7 @@ interface CatalogueSource : Source {
* @return the related mangas for the current manga.
* @throws UnsupportedOperationException if a source doesn't support related mangas.
*/
suspend fun fetchRelatedMangaList(manga: SManga): List<SManga> =
throw Exception("Stub!")
suspend fun fetchRelatedMangaList(manga: SManga): List<SManga> = throw UnsupportedOperationException("Unsupported!")

/**
* Slit & strip manga's title into separate searchable keywords.
Expand Down
41 changes: 14 additions & 27 deletions library/src/main/java/eu/kanade/tachiyomi/source/Source.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ package eu.kanade.tachiyomi.source
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import rx.Observable

/**
* A basic interface for creating a source. It could be an online source, a local source, etc...
*/
@Suppress("unused")
interface Source {

/**
* Id for the source. Must be unique.
* ID for the source. Must be unique.
*/
val id: Long

Expand All @@ -28,7 +26,7 @@ interface Source {
* @param manga the manga to update.
* @return the updated manga.
*/
suspend fun getMangaDetails(manga: SManga): SManga = throw Exception("Stub!")
suspend fun getMangaDetails(manga: SManga): SManga

/**
* Get all the available chapters for a manga.
Expand All @@ -37,7 +35,17 @@ interface Source {
* @param manga the manga to update.
* @return the chapters for the manga.
*/
suspend fun getChapterList(manga: SManga): List<SChapter> = throw Exception("Stub!")
suspend fun getChapterList(manga: SManga): List<SChapter>

/**
* Get the list of pages a chapter has. Pages should be returned
* in the expected order; the index is ignored.
*
* @since komikku/extensions-lib 1.7
* @param chapter the chapter.
* @return the pages for the chapter.
*/
suspend fun getPageList(chapter: SChapter): List<Page>

// KMK -->
/**
Expand All @@ -51,27 +59,6 @@ interface Source {
manga: SManga,
exceptionHandler: (Throwable) -> Unit,
pushResults: suspend (relatedManga: Pair<String, List<SManga>>, completed: Boolean) -> Unit,
): Unit = throw Exception("Stub!")
// KMK <--

/**
* Get the list of pages a chapter has. Pages should be returned
* in the expected order; the index is ignored.
*
* @param chapter the chapter.
* @return the pages for the chapter.
*/
fun fetchPageList(chapter: SChapter): Observable<List<Page>>

@Deprecated(
"Use the non-RxJava API instead",
ReplaceWith("getMangaDetails"),
)
fun fetchMangaDetails(manga: SManga): Observable<SManga> = throw Exception("Stub!")

@Deprecated(
"Use the non-RxJava API instead",
ReplaceWith("getChapterList"),
)
fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = throw Exception("Stub!")
// KMK <--
}
Loading

0 comments on commit 119a7e4

Please sign in to comment.