mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Use class from common module
This commit is contained in:
parent
1c42df7752
commit
a38a03c980
4 changed files with 11 additions and 37 deletions
|
@ -42,6 +42,8 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":library:core-utils")
|
||||
|
||||
implementation libs.androidx.appCompat
|
||||
implementation libs.androidx.core
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.View
|
|||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.Success
|
||||
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
||||
import me.gujun.android.span.Span
|
||||
import me.gujun.android.span.span
|
||||
|
||||
|
@ -40,7 +41,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
is Fail -> {
|
||||
valueItem {
|
||||
id("fail")
|
||||
text(async.error.localizedMessage?.toSafeCharSequence())
|
||||
text(async.error.localizedMessage?.toEpoxyCharSequence())
|
||||
}
|
||||
}
|
||||
is Success -> {
|
||||
|
@ -94,7 +95,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
+"{+${model.keys.size}}"
|
||||
textColor = host.styleProvider.baseColor
|
||||
}
|
||||
}.toSafeCharSequence()
|
||||
}.toEpoxyCharSequence()
|
||||
)
|
||||
itemClickListener(View.OnClickListener { host.itemClicked(model) })
|
||||
}
|
||||
|
@ -133,7 +134,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
+"[+${model.items.size}]"
|
||||
textColor = host.styleProvider.baseColor
|
||||
}
|
||||
}.toSafeCharSequence()
|
||||
}.toEpoxyCharSequence()
|
||||
)
|
||||
itemClickListener(View.OnClickListener { host.itemClicked(model) })
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
}
|
||||
}
|
||||
append(host.valueToSpan(model))
|
||||
}.toSafeCharSequence()
|
||||
}.toEpoxyCharSequence()
|
||||
)
|
||||
copyValue(model.stringRes)
|
||||
}
|
||||
|
@ -233,7 +234,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
span("{".takeIf { isObject } ?: "[") {
|
||||
textColor = host.styleProvider.baseColor
|
||||
}
|
||||
}.toSafeCharSequence()
|
||||
}.toEpoxyCharSequence()
|
||||
)
|
||||
itemClickListener(View.OnClickListener { host.itemClicked(composed) })
|
||||
}
|
||||
|
@ -253,7 +254,7 @@ internal class JSonViewerEpoxyController(private val context: Context) :
|
|||
span {
|
||||
text = "}".takeIf { isObject } ?: "]"
|
||||
textColor = host.styleProvider.baseColor
|
||||
}.toSafeCharSequence()
|
||||
}.toEpoxyCharSequence()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.billcarsonfr.jsonviewer
|
||||
|
||||
/**
|
||||
* Wrapper for a CharSequence, which support mutation of the CharSequence, which can happen during rendering
|
||||
* TODO Mutualize
|
||||
*/
|
||||
internal class SafeCharSequence(val charSequence: CharSequence) {
|
||||
private val hash = charSequence.toString().hashCode()
|
||||
|
||||
override fun hashCode() = hash
|
||||
override fun equals(other: Any?) = other is SafeCharSequence && other.hash == hash
|
||||
}
|
||||
|
||||
internal fun CharSequence.toSafeCharSequence() = SafeCharSequence(this)
|
|
@ -28,12 +28,13 @@ import com.airbnb.epoxy.EpoxyAttribute
|
|||
import com.airbnb.epoxy.EpoxyHolder
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import com.airbnb.epoxy.EpoxyModelWithHolder
|
||||
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
|
||||
|
||||
@EpoxyModelClass(layout = R2.layout.item_jv_base_value)
|
||||
internal abstract class ValueItem : EpoxyModelWithHolder<ValueItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute
|
||||
var text: SafeCharSequence? = null
|
||||
var text: EpoxyCharSequence? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var depth: Int = 0
|
||||
|
|
Loading…
Reference in a new issue