Score formatting. Hide API from Anilist/Kitsu services.

This commit is contained in:
len
2016-12-21 22:39:46 +01:00
parent 091c0c0c71
commit 8d749df290
17 changed files with 573 additions and 455 deletions

View File

@@ -157,9 +157,16 @@ class TrackFragment : BaseRxFragment<TrackPresenter>() {
val view = dialog.customView
if (view != null) {
val np = view.findViewById(R.id.score_picker) as NumberPicker
np.maxValue = item.service.maxScore()
val scores = item.service.getScoreList().toTypedArray()
np.maxValue = scores.size - 1
np.displayedValues = scores
// Set initial value
np.value = item.track.score.toInt()
val displayedScore = item.service.displayScore(item.track)
if (displayedScore != "-") {
val index = scores.indexOf(displayedScore)
np.value = if (index != -1) index else 0
}
}
}

View File

@@ -30,7 +30,7 @@ class TrackHolder(private val view: View, private val fragment: TrackFragment)
track_chapters.text = "${track.last_chapter_read}/" +
if (track.total_chapters > 0) track.total_chapters else "-"
track_status.text = item.service.getStatus(track.status)
track_score.text = if (track.score == 0f) "-" else item.service.formatScore(track)
track_score.text = if (track.score == 0f) "-" else item.service.displayScore(track)
} else {
track_title.setTextAppearance(context, R.style.TextAppearance_Medium_Button)
track_title.setText(R.string.action_edit)

View File

@@ -122,9 +122,9 @@ class TrackPresenter : BasePresenter<TrackFragment>() {
updateRemote(track, item.service)
}
fun setScore(item: TrackItem, score: Int) {
fun setScore(item: TrackItem, index: Int) {
val track = item.track!!
track.score = score.toFloat()
track.score = item.service.indexToScore(index)
updateRemote(track, item.service)
}