Replace StringJoiner with joinToString()

pull/443/head
Isira Seneviratne 3 years ago
parent 73e6f730e1
commit 00fe44b724

@ -42,7 +42,6 @@ import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import okio.IOException import okio.IOException
import org.json.JSONException import org.json.JSONException
import org.jsoup.internal.StringUtil.StringJoiner
import org.koitharu.kotatsu.BuildConfig import org.koitharu.kotatsu.BuildConfig
import org.koitharu.kotatsu.R import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
@ -173,14 +172,12 @@ fun scaleUpActivityOptionsOf(view: View): Bundle? = if (view.context.isAnimation
} }
fun Resources.getLocalesConfig(): LocaleListCompat { fun Resources.getLocalesConfig(): LocaleListCompat {
val tagsList = StringJoiner(",") val tagsList = mutableListOf<String>()
try { try {
val xpp: XmlPullParser = getXml(R.xml.locales) val xpp = getXml(R.xml.locales)
while (xpp.eventType != XmlPullParser.END_DOCUMENT) { while (xpp.eventType != XmlPullParser.END_DOCUMENT) {
if (xpp.eventType == XmlPullParser.START_TAG) { if (xpp.eventType == XmlPullParser.START_TAG && xpp.name == "locale") {
if (xpp.name == "locale") { tagsList.add(xpp.getAttributeValue(0))
tagsList.add(xpp.getAttributeValue(0))
}
} }
xpp.next() xpp.next()
} }
@ -189,7 +186,7 @@ fun Resources.getLocalesConfig(): LocaleListCompat {
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTraceDebug() e.printStackTraceDebug()
} }
return LocaleListCompat.forLanguageTags(tagsList.complete()) return LocaleListCompat.forLanguageTags(tagsList.joinToString(","))
} }
fun Context.findActivity(): Activity? = when (this) { fun Context.findActivity(): Activity? = when (this) {

@ -2,7 +2,6 @@ package org.koitharu.kotatsu.scrobbling.common.data
import android.content.Context import android.content.Context
import androidx.core.content.edit import androidx.core.content.edit
import org.jsoup.internal.StringUtil.StringJoiner
import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerService import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerService
import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerUser import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerUser
@ -40,12 +39,8 @@ class ScrobblerStorage(context: Context, service: ScrobblerService) {
remove(KEY_USER) remove(KEY_USER)
return@edit return@edit
} }
val str = StringJoiner("\n") val str = listOf(value.id, value.nickname, value.avatar, value.service.name)
.add(value.id) .joinToString("\n")
.add(value.nickname)
.add(value.avatar)
.add(value.service.name)
.complete()
putString(KEY_USER, str) putString(KEY_USER, str)
} }

Loading…
Cancel
Save