mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-25 01:00:55 +01:00
Avoid lazy blocks
This commit is contained in:
parent
1978a180ff
commit
e321e20dc2
@ -68,7 +68,7 @@ class JitsiCallViewModel @AssistedInject constructor(
|
||||
val jitsiWidget = it.firstOrNull()
|
||||
if (jitsiWidget != null) {
|
||||
val ppt = widgetService.getWidgetComputedUrl(jitsiWidget, themeProvider.isLightTheme())
|
||||
?.let { url -> JitsiWidgetProperties(url, stringProvider) }
|
||||
?.let { url -> JitsiWidgetProperties.fromUrl(url, stringProvider) }
|
||||
setState {
|
||||
copy(
|
||||
widget = Success(jitsiWidget),
|
||||
|
@ -19,22 +19,32 @@ package im.vector.app.features.call.conference
|
||||
import android.net.Uri
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import java.net.URLDecoder
|
||||
|
||||
class JitsiWidgetProperties(private val uriString: String, val stringProvider: StringProvider) {
|
||||
val domain: String by lazy { configs["conferenceDomain"] ?: stringProvider.getString(R.string.preferred_jitsi_domain) }
|
||||
val confId: String? by lazy { configs["conferenceId"] }
|
||||
val displayName: String? by lazy { configs["displayName"] }
|
||||
val avatarUrl: String? by lazy { configs["avatarUrl"] }
|
||||
data class JitsiWidgetProperties(
|
||||
val domain: String,
|
||||
val confId: String?,
|
||||
val displayName: String?,
|
||||
val avatarUrl: String?
|
||||
) {
|
||||
companion object {
|
||||
fun fromUrl(url: String, stringProvider: StringProvider): JitsiWidgetProperties {
|
||||
val configString: String? = tryOrNull { Uri.parse(url) }?.fragment
|
||||
|
||||
private val configString: String? by lazy { Uri.parse(uriString).fragment }
|
||||
val configs: Map<String, String?> = configString?.split("&")
|
||||
?.map { it.split("=") }
|
||||
?.filter { it.size == 2 }
|
||||
?.map { (key, value) -> key to URLDecoder.decode(value, "UTF-8") }
|
||||
?.toMap()
|
||||
.orEmpty()
|
||||
|
||||
private val configs: Map<String, String?> by lazy {
|
||||
configString?.split("&")
|
||||
?.map { it.split("=") }
|
||||
?.filter { it.size == 2 }
|
||||
?.map { (key, value) -> key to URLDecoder.decode(value, "UTF-8") }
|
||||
?.toMap()
|
||||
.orEmpty()
|
||||
return JitsiWidgetProperties(
|
||||
domain = configs["conferenceDomain"] ?: stringProvider.getString(R.string.preferred_jitsi_domain),
|
||||
confId = configs["conferenceId"],
|
||||
displayName = configs["displayName"],
|
||||
avatarUrl = configs["avatarUrl"]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user