[feat] Comic Reader
This commit is contained in:
@@ -1,8 +1,50 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
data class Comic(
|
||||
val comic_name: String,
|
||||
val page_count: Int,
|
||||
val bookmarks: List<BookMark>,
|
||||
val pages: List<String>
|
||||
)
|
||||
import com.acitelight.aether.service.ApiClient
|
||||
|
||||
class Comic(
|
||||
val comic: ComicResponse,
|
||||
val id: String,
|
||||
val token: String
|
||||
)
|
||||
{
|
||||
fun getPage(pageNumber: Int): String
|
||||
{
|
||||
return "${ApiClient.base}api/image/$id/${comic.list[pageNumber]}?token=$token"
|
||||
}
|
||||
|
||||
fun getPage(pageName: String): String?
|
||||
{
|
||||
val v = comic.list.indexOf(pageName)
|
||||
if(v >= 0)
|
||||
{
|
||||
return getPage(v)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getPageIndex(pageName: String): Int
|
||||
{
|
||||
return comic.list.indexOf(pageName)
|
||||
}
|
||||
|
||||
fun getChapterLength(pageName: String): Int
|
||||
{
|
||||
var v = comic.list.indexOf(pageName)
|
||||
if(v >= 0)
|
||||
{
|
||||
var r: Int = 1
|
||||
v+=1
|
||||
while(v < comic.list.size && !comic.bookmarks.any{
|
||||
x -> x.page == comic.list[v]
|
||||
}){
|
||||
r++
|
||||
v+=1
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
data class ComicResponse(
|
||||
val comic_name: String,
|
||||
val page_count: Int,
|
||||
val bookmarks: List<BookMark>,
|
||||
val list: List<String>,
|
||||
val author: String
|
||||
)
|
||||
Reference in New Issue
Block a user