mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
MangaUpdates tweaks + fixing the scorelist from main
Since 0.1-0.9 aren't valid of mangaupdates Fixes #1324 Co-Authored-By: Andreas <6576096+ghostbear@users.noreply.github.com>
This commit is contained in:
parent
9e0ebb2ddc
commit
e157edf740
6 changed files with 22 additions and 8 deletions
|
@ -66,9 +66,14 @@ class MangaUpdates(private val context: Context, id: Int) : TrackService(id) {
|
|||
else -> ""
|
||||
}
|
||||
}
|
||||
override fun getScoreList(): List<String> = (0..10).map(Int::toString)
|
||||
|
||||
override fun displayScore(track: Track): String = track.score.toInt().toString()
|
||||
private val _scoreList = listOf("0.0") + (10..100).map { String.format("%.1f", it / 10f) }
|
||||
|
||||
override fun getScoreList(): List<String> = _scoreList
|
||||
|
||||
override fun indexToScore(index: Int): Float = _scoreList[index].toFloat()
|
||||
|
||||
override fun displayScore(track: Track): String = track.score.toString()
|
||||
|
||||
override suspend fun add(track: Track): Track {
|
||||
track.score = DEFAULT_SCORE.toFloat()
|
||||
|
|
|
@ -123,7 +123,7 @@ class MangaUpdatesApi(
|
|||
private suspend fun updateSeriesRating(track: Track) {
|
||||
if (track.score != 0f) {
|
||||
val body = buildJsonObject {
|
||||
put("rating", track.score.toInt())
|
||||
put("rating", track.score)
|
||||
}
|
||||
authClient.newCall(
|
||||
PUT(
|
||||
|
|
|
@ -5,11 +5,11 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
@Serializable
|
||||
data class Rating(
|
||||
val rating: Int? = null,
|
||||
val rating: Float? = null,
|
||||
)
|
||||
|
||||
fun Rating.copyTo(track: Track): Track {
|
||||
return track.apply {
|
||||
this.score = rating?.toFloat() ?: 0f
|
||||
this.score = rating ?: 0f
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.kanade.tachiyomi.data.track.mangaupdates.dto
|
||||
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import eu.kanade.tachiyomi.util.lang.htmlDecode
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
@ -25,10 +26,10 @@ data class Record(
|
|||
fun Record.toTrackSearch(id: Int): TrackSearch {
|
||||
return TrackSearch.create(id).apply {
|
||||
media_id = this@toTrackSearch.seriesId ?: 0L
|
||||
title = this@toTrackSearch.title ?: ""
|
||||
title = this@toTrackSearch.title?.htmlDecode() ?: ""
|
||||
total_chapters = 0
|
||||
cover_url = this@toTrackSearch.image?.url?.original ?: ""
|
||||
summary = this@toTrackSearch.description ?: ""
|
||||
summary = this@toTrackSearch.description?.htmlDecode() ?: ""
|
||||
tracking_url = this@toTrackSearch.url ?: ""
|
||||
publishing_status = ""
|
||||
publishing_type = this@toTrackSearch.type.toString()
|
||||
|
|
|
@ -491,6 +491,7 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) :
|
|||
return
|
||||
}
|
||||
|
||||
val scores = item.service.getScoreList().toTypedArray()
|
||||
val binding = TrackScoreDialogBinding.inflate(activity.layoutInflater)
|
||||
val dialog = activity.materialAlertDialog()
|
||||
.setTitle(R.string.score)
|
||||
|
@ -504,7 +505,6 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) :
|
|||
}
|
||||
|
||||
val np = binding.scorePicker
|
||||
val scores = item.service.getScoreList().toTypedArray()
|
||||
np.maxValue = scores.size - 1
|
||||
np.displayedValues = scores
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import androidx.core.text.bold
|
|||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.text.color
|
||||
import androidx.core.text.inSpans
|
||||
import androidx.core.text.parseAsHtml
|
||||
import androidx.core.text.scale
|
||||
import androidx.core.text.superscript
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -197,3 +198,10 @@ fun String.getUrlWithoutDomain(): String {
|
|||
this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML-decode the string
|
||||
*/
|
||||
fun String.htmlDecode(): String {
|
||||
return this.parseAsHtml().toString()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue