Use a string builder instead of a list to make chapter names
This commit is contained in:
parent
7e1389ef05
commit
428a9e82f3
@ -252,6 +252,8 @@ class ApiMangaParser(val client: OkHttpClient, private val lang: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun StringBuilder.appends(string: String) = append("$string ")
|
||||||
|
|
||||||
private fun mapChapter(
|
private fun mapChapter(
|
||||||
networkChapter: ChapterResponse,
|
networkChapter: ChapterResponse,
|
||||||
groups: Map<String, String>,
|
groups: Map<String, String>,
|
||||||
@ -259,36 +261,36 @@ class ApiMangaParser(val client: OkHttpClient, private val lang: String) {
|
|||||||
val chapter = SChapter.create()
|
val chapter = SChapter.create()
|
||||||
val attributes = networkChapter.data.attributes
|
val attributes = networkChapter.data.attributes
|
||||||
val key = MdUtil.chapterSuffix + networkChapter.data.id
|
val key = MdUtil.chapterSuffix + networkChapter.data.id
|
||||||
val chapterName = mutableListOf<String>()
|
val chapterName = StringBuilder()
|
||||||
// Build chapter name
|
// Build chapter name
|
||||||
|
|
||||||
if (attributes.volume != null) {
|
if (attributes.volume != null) {
|
||||||
val vol = "Vol." + attributes.volume
|
val vol = "Vol." + attributes.volume
|
||||||
chapterName.add(vol)
|
chapterName.appends(vol)
|
||||||
// todo
|
// todo
|
||||||
// chapter.vol = vol
|
// chapter.vol = vol
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes.chapter.isNullOrBlank().not()) {
|
if (attributes.chapter.isNullOrBlank().not()) {
|
||||||
if (chapterName.isNotEmpty()) {
|
if (chapterName.isNotEmpty()) {
|
||||||
chapterName.add("-")
|
chapterName.appends("-")
|
||||||
}
|
}
|
||||||
val chp = "Ch.${attributes.chapter}"
|
val chp = "Ch.${attributes.chapter}"
|
||||||
chapterName.add(chp)
|
chapterName.appends(chp)
|
||||||
// chapter.chapter_txt = chp
|
// chapter.chapter_txt = chp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes.title.isNullOrBlank().not()) {
|
if (attributes.title.isNullOrBlank().not()) {
|
||||||
if (chapterName.isNotEmpty()) {
|
if (chapterName.isNotEmpty()) {
|
||||||
chapterName.add("-")
|
chapterName.appends("-")
|
||||||
}
|
}
|
||||||
chapterName.add(attributes.title!!)
|
chapterName.append(attributes.title!!)
|
||||||
chapter.name = MdUtil.cleanString(attributes.title)
|
chapter.name = MdUtil.cleanString(attributes.title)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if volume, chapter and title is empty its a oneshot
|
// if volume, chapter and title is empty its a oneshot
|
||||||
if (chapterName.isEmpty()) {
|
if (chapterName.isEmpty()) {
|
||||||
chapterName.add("Oneshot")
|
chapterName.append("Oneshot")
|
||||||
}
|
}
|
||||||
/*if ((status == 2 || status == 3)) {
|
/*if ((status == 2 || status == 3)) {
|
||||||
if (finalChapterNumber != null) {
|
if (finalChapterNumber != null) {
|
||||||
@ -300,7 +302,7 @@ class ApiMangaParser(val client: OkHttpClient, private val lang: String) {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
val name = MdUtil.cleanString(chapterName.joinToString(" "))
|
val name = MdUtil.cleanString(chapterName.toString())
|
||||||
// Convert from unix time
|
// Convert from unix time
|
||||||
val dateUpload = MdUtil.parseDate(attributes.publishAt)
|
val dateUpload = MdUtil.parseDate(attributes.publishAt)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user