fix: address possible format issued

This commit is contained in:
TwistedUmbrellaX
2024-04-05 23:31:51 -04:00
parent 9f7e01a1fb
commit 47dbdc651d
3 changed files with 13 additions and 5 deletions

View File

@@ -994,7 +994,7 @@ fun sinceWhen(media: Media, view: ViewGroup) {
if (media.status != "RELEASING" && media.status != "HIATUS") return
CoroutineScope(Dispatchers.IO).launch {
MangaUpdates().search(media.name ?: media.nameRomaji, media.startDate)?.let {
val latestChapter = MangaUpdates.getLatestChapter(it)
val latestChapter = MangaUpdates.getLatestChapter(view.context, it)
val timeSince = (System.currentTimeMillis() -
(it.metadata.series.lastUpdated!!.timestamp * 1000)) / 1000

View File

@@ -1,5 +1,7 @@
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
@@ -43,9 +45,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())
}
}
}

View File

@@ -503,7 +503,8 @@
<string name="refresh_token_load_failed">Refresh Token : Failed to load Saved Token</string>
<string name="refreshing_token_failed">Refreshing Token Failed</string>
<string name="episode_release_countdown">Episode %1$d will be released in</string>
<string name="chapter_release_timeout">Chapter %1$s has been available for</string>
<string name="chapter_number">Chapter %1$d</string>
<string name="chapter_release_timeout">%1$s has been available for</string>
<string name="time_format">%1$d days %2$d hrs %3$d mins %4$d secs</string>
<string-array name="sort_by">
<item>Score</item>