fix: address possible format issues (#331)
* fix: address possible format issued * fix: improve results and logging * fix: not everything is a title Fixed the book title style of capitalization Toast and Snackbar messages appear for less than 3 seconds. Why are they paragraphs? * Fix: the other half of the file Probably missed a few, but this fixes the rest of the obvious ones (including a double negative)
This commit is contained in:
parent
29e115ce41
commit
a51e025c03
3 changed files with 50 additions and 30 deletions
|
@ -1,8 +1,15 @@
|
|||
package ani.dantotsu.connections.bakaupdates
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import ani.dantotsu.util.Logger
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import okio.ByteString.Companion.encode
|
||||
|
@ -34,6 +41,13 @@ class MangaUpdates {
|
|||
}
|
||||
}
|
||||
val res = client.post(apiUrl, json = query).parsed<MangaUpdatesResponse>()
|
||||
coroutineScope {
|
||||
res.results?.map {
|
||||
async(Dispatchers.IO) {
|
||||
Logger.log(it.toString())
|
||||
}
|
||||
}
|
||||
}?.awaitAll()
|
||||
res.results?.first {
|
||||
it.metadata.series.lastUpdated?.timestamp != null
|
||||
&& (it.metadata.series.latestChapter != null
|
||||
|
@ -43,9 +57,14 @@ class MangaUpdates {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun getLatestChapter(results: MangaUpdatesResponse.Results): String {
|
||||
return results.metadata.series.latestChapter?.toString()
|
||||
?: results.record.chapter!!.substringAfterLast("-").trim()
|
||||
fun getLatestChapter(context: Context, results: MangaUpdatesResponse.Results): String {
|
||||
return results.metadata.series.latestChapter?.let {
|
||||
context.getString(R.string.chapter_number, it)
|
||||
} ?: results.record.chapter!!.substringAfterLast("-").trim().let { chapter ->
|
||||
chapter.takeIf {
|
||||
it.toIntOrNull() == null
|
||||
} ?: context.getString(R.string.chapter_number, chapter.toInt())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue