Fix Bangumi class formatting

This commit is contained in:
arkon 2020-01-11 22:06:23 -05:00
parent 427d2fed8c
commit 44f406b4b9
9 changed files with 383 additions and 383 deletions

View file

@ -13,6 +13,14 @@ import uy.kohesive.injekt.injectLazy
class Bangumi(private val context: Context, id: Int) : TrackService(id) {
override val name = "Bangumi"
private val gson: Gson by injectLazy()
private val interceptor by lazy { BangumiInterceptor(this, gson) }
private val api by lazy { BangumiApi(client, interceptor) }
override fun getScoreList(): List<String> {
return IntRange(0, 10).map(Int::toString)
}
@ -72,25 +80,6 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
}
}
companion object {
const val READING = 3
const val COMPLETED = 2
const val ON_HOLD = 4
const val DROPPED = 5
const val PLANNING = 1
const val DEFAULT_STATUS = READING
const val DEFAULT_SCORE = 0
}
override val name = "Bangumi"
private val gson: Gson by injectLazy()
private val interceptor by lazy { BangumiInterceptor(this, gson) }
private val api by lazy { BangumiApi(client, interceptor) }
override fun getLogo() = R.drawable.tracker_bangumi
override fun getLogoColor() = Color.rgb(0xF0, 0x91, 0x99)
@ -141,4 +130,15 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
preferences.trackToken(this).set(null)
interceptor.newAuth(null)
}
companion object {
const val READING = 3
const val COMPLETED = 2
const val ON_HOLD = 4
const val DROPPED = 5
const val PLANNING = 1
const val DEFAULT_STATUS = READING
const val DEFAULT_SCORE = 0
}
}

View file

@ -88,7 +88,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
if (responseBody.isEmpty()) {
throw Exception("Null Response")
}
if(responseBody.contains("\"code\":404")){
if (responseBody.contains("\"code\":404")) {
responseBody = "{\"results\":0,\"list\":[]}"
}
val response = parser.parse(responseBody).obj["list"]?.array