Remove need for SQLDelight primitive adapters

This commit is contained in:
arkon
2023-07-29 16:14:23 -04:00
parent 6a558ad119
commit cd91ea9b77
31 changed files with 67 additions and 83 deletions

View File

@@ -11,7 +11,7 @@ data class Chapter(
val url: String,
val name: String,
val dateUpload: Long,
val chapterNumber: Float,
val chapterNumber: Double,
val scanlator: String?,
val lastModifiedAt: Long,
) {
@@ -30,7 +30,7 @@ data class Chapter(
url = "",
name = "",
dateUpload = -1,
chapterNumber = -1f,
chapterNumber = -1.0,
scanlator = null,
lastModifiedAt = 0,
)

View File

@@ -11,7 +11,7 @@ data class ChapterUpdate(
val url: String? = null,
val name: String? = null,
val dateUpload: Long? = null,
val chapterNumber: Float? = null,
val chapterNumber: Double? = null,
val scanlator: String? = null,
)

View File

@@ -30,9 +30,9 @@ object ChapterRecognition {
*/
private val unwantedWhiteSpace = Regex("""\s(?=extra|special|omake)""")
fun parseChapterNumber(mangaTitle: String, chapterName: String, chapterNumber: Float? = null): Float {
fun parseChapterNumber(mangaTitle: String, chapterName: String, chapterNumber: Double? = null): Double {
// If chapter number is known return.
if (chapterNumber != null && (chapterNumber == -2f || chapterNumber > -1f)) {
if (chapterNumber != null && (chapterNumber == -2.0 || chapterNumber > -1.0)) {
return chapterNumber
}
@@ -57,7 +57,7 @@ object ChapterRecognition {
// Take the first number encountered.
number.find(name)?.let { return getChapterNumberFromMatch(it) }
return chapterNumber ?: -1f
return chapterNumber ?: -1.0
}
/**
@@ -65,9 +65,9 @@ object ChapterRecognition {
* @param match result of regex
* @return chapter number if found else null
*/
private fun getChapterNumberFromMatch(match: MatchResult): Float {
private fun getChapterNumberFromMatch(match: MatchResult): Double {
return match.let {
val initial = it.groups[1]?.value?.toFloat()!!
val initial = it.groups[1]?.value?.toDouble()!!
val subChapterDecimal = it.groups[2]?.value
val subChapterAlpha = it.groups[3]?.value
val addition = checkForDecimal(subChapterDecimal, subChapterAlpha)

View File

@@ -3,16 +3,16 @@ package tachiyomi.domain.chapter.service
import tachiyomi.domain.chapter.model.Chapter
import kotlin.math.floor
fun List<Float>.missingChaptersCount(): Int {
fun List<Double>.missingChaptersCount(): Int {
if (this.isEmpty()) {
return 0
}
val chapters = this
// Ignore unknown chapter numbers
.filterNot { it == -1f }
.filterNot { it == -1.0 }
// Convert to integers, as we cannot check if 16.5 is missing
.map(Float::toInt)
.map(Double::toInt)
// Only keep unique chapters so that -1 or 16 are not counted multiple times
.distinct()
.sorted()
@@ -43,7 +43,7 @@ fun calculateChapterGap(higherChapter: Chapter?, lowerChapter: Chapter?): Int {
return calculateChapterGap(higherChapter.chapterNumber, lowerChapter.chapterNumber)
}
fun calculateChapterGap(higherChapterNumber: Float, lowerChapterNumber: Float): Int {
if (higherChapterNumber < 0f || lowerChapterNumber < 0f) return 0
fun calculateChapterGap(higherChapterNumber: Double, lowerChapterNumber: Double): Int {
if (higherChapterNumber < 0.0 || lowerChapterNumber < 0.0) return 0
return floor(higherChapterNumber).toInt() - floor(lowerChapterNumber).toInt() - 1
}

View File

@@ -8,7 +8,7 @@ data class HistoryWithRelations(
val chapterId: Long,
val mangaId: Long,
val title: String,
val chapterNumber: Float,
val chapterNumber: Double,
val readAt: Date?,
val readDuration: Long,
val coverData: MangaCover,

View File

@@ -10,7 +10,7 @@ data class Track(
val lastChapterRead: Double,
val totalChapters: Long,
val status: Long,
val score: Float,
val score: Double,
val remoteUrl: String,
val startDate: Long,
val finishDate: Long,