More FlowPreference migration
This commit is contained in:
@@ -5,7 +5,6 @@ import android.graphics.Color
|
||||
import com.google.gson.Gson
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import rx.Completable
|
||||
@@ -75,7 +74,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
||||
override fun getCompletionStatus(): Int = COMPLETED
|
||||
|
||||
override fun getScoreList(): List<String> {
|
||||
return when (scorePreference.getOrDefault()) {
|
||||
return when (scorePreference.get()) {
|
||||
// 10 point
|
||||
POINT_10 -> IntRange(0, 10).map(Int::toString)
|
||||
// 100 point
|
||||
@@ -91,7 +90,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
||||
}
|
||||
|
||||
override fun indexToScore(index: Int): Float {
|
||||
return when (scorePreference.getOrDefault()) {
|
||||
return when (scorePreference.get()) {
|
||||
// 10 point
|
||||
POINT_10 -> index * 10f
|
||||
// 100 point
|
||||
@@ -115,7 +114,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
||||
override fun displayScore(track: Track): String {
|
||||
val score = track.score
|
||||
|
||||
return when (scorePreference.getOrDefault()) {
|
||||
return when (scorePreference.get()) {
|
||||
POINT_5 -> when (score) {
|
||||
0f -> "0 ★"
|
||||
else -> "${((score + 10) / 20).toInt()} ★"
|
||||
@@ -193,7 +192,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
||||
|
||||
override fun logout() {
|
||||
super.logout()
|
||||
preferences.trackToken(this).set(null)
|
||||
preferences.trackToken(this).delete()
|
||||
interceptor.setAuth(null)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.track.anilist
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -80,7 +79,7 @@ fun Track.toAnilistStatus() = when (status) {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
fun Track.toAnilistScore(): String = when (preferences.anilistScoreType().getOrDefault()) {
|
||||
fun Track.toAnilistScore(): String = when (preferences.anilistScoreType().get()) {
|
||||
// 10 point
|
||||
"POINT_10" -> (score.toInt() / 10).toString()
|
||||
// 100 point
|
||||
|
||||
@@ -126,7 +126,7 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
||||
|
||||
override fun logout() {
|
||||
super.logout()
|
||||
preferences.trackToken(this).set(null)
|
||||
preferences.trackToken(this).delete()
|
||||
interceptor.newAuth(null)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.Context
|
||||
import android.graphics.Color
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
@@ -145,7 +144,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
||||
getCSRF().isNotEmpty() &&
|
||||
checkCookies()
|
||||
|
||||
fun getCSRF(): String = preferences.trackToken(this).getOrDefault()
|
||||
fun getCSRF(): String = preferences.trackToken(this).get()
|
||||
|
||||
private fun saveCSRF(csrf: String) = preferences.trackToken(this).set(csrf)
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
||||
|
||||
override fun logout() {
|
||||
super.logout()
|
||||
preferences.trackToken(this).set(null)
|
||||
preferences.trackToken(this).delete()
|
||||
interceptor.newAuth(null)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user