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

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

Loading…
Cancel
Save