Fix for crash on rendering media items
07-19 19:28:53.039 E/AndroidRuntime(12141): java.lang.NoSuchMethodError: No virtual method updateMessageBubble(Landroid/content/Context;Lim/vector/app/features/home/room/detail/timeline/item/AbsMessageItem$Holder;)V in class Lim/vector/app/features/home/room/detail/timeline/item/MessageImageVideoItem; or its super classes (declaration of 'im.vector.app.features.home.room.detail.timeline.item.MessageImageVideoItem' appears in base.apk) 07-19 19:28:53.039 E/AndroidRuntime(12141): at im.vector.app.features.home.room.detail.timeline.item.MessageImageVideoItem$bind$onImageSizeListener$1.onImageSizeUpdated(MessageImageVideoItem.kt:6) 07-19 19:28:53.039 E/AndroidRuntime(12141): at im.vector.app.features.media.ImageContentRenderer.render(ImageContentRenderer.kt:20) 07-19 19:28:53.039 E/AndroidRuntime(12141): at im.vector.app.features.home.room.detail.timeline.item.MessageImageVideoItem.bind(MessageImageVideoItem.kt:12) 07-19 19:28:53.039 E/AndroidRuntime(12141): at im.vector.app.features.home.room.detail.timeline.item.MessageImageVideoItem.bind(MessageImageVideoItem.kt:6) 07-19 19:28:53.039 E/AndroidRuntime(12141): at com.airbnb.epoxy.BaseEpoxyAdapter.onBindViewHolder(BaseEpoxyAdapter.java:25) Change-Id: Ic803b3bfb328ed3a56202df789500b162886250d
This commit is contained in:
parent
a5db52fe62
commit
045f95326a
|
@ -7,27 +7,6 @@ import im.vector.app.features.themes.BubbleThemeUtils
|
|||
|
||||
interface BubbleDependentView<H> {
|
||||
|
||||
fun updateMessageBubble(context: Context, holder: H) {
|
||||
val bubbleStyleSetting = BubbleThemeUtils.getBubbleStyle(context)
|
||||
val bubbleStyle = when {
|
||||
messageBubbleAllowed(context) -> {
|
||||
bubbleStyleSetting
|
||||
}
|
||||
bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_BOTH && pseudoBubbleAllowed() -> {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN
|
||||
}
|
||||
bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_START && pseudoBubbleAllowed() -> {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN
|
||||
}
|
||||
else -> {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_NONE
|
||||
}
|
||||
}
|
||||
val reverseBubble = shouldReverseBubble() && BubbleThemeUtils.drawsDualSide(bubbleStyle)
|
||||
|
||||
setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble)
|
||||
}
|
||||
|
||||
fun messageBubbleAllowed(context: Context): Boolean {
|
||||
return false
|
||||
}
|
||||
|
@ -41,15 +20,38 @@ interface BubbleDependentView<H> {
|
|||
}
|
||||
|
||||
fun setBubbleLayout(holder: H, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean)
|
||||
}
|
||||
|
||||
fun setFlatRtl(layout: ViewGroup, direction: Int, childDirection: Int, depth: Int = 1) {
|
||||
layout.layoutDirection = direction
|
||||
for (child in layout.children) {
|
||||
if (depth > 1 && child is ViewGroup) {
|
||||
setFlatRtl(child, direction, childDirection, depth-1)
|
||||
} else {
|
||||
child.layoutDirection = childDirection
|
||||
}
|
||||
// This function belongs to BubbleDependentView, but turned out to raise a NoSuchMethodError since recently
|
||||
// when called from an onImageSizeUpdated listener
|
||||
fun <H>updateMessageBubble(context: Context, view: BubbleDependentView<H>, holder: H) {
|
||||
val bubbleStyleSetting = BubbleThemeUtils.getBubbleStyle(context)
|
||||
val bubbleStyle = when {
|
||||
view.messageBubbleAllowed(context) -> {
|
||||
bubbleStyleSetting
|
||||
}
|
||||
bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_BOTH && view.pseudoBubbleAllowed() -> {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN
|
||||
}
|
||||
bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_START && view.pseudoBubbleAllowed() -> {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN
|
||||
}
|
||||
else -> {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_NONE
|
||||
}
|
||||
}
|
||||
val reverseBubble = view.shouldReverseBubble() && BubbleThemeUtils.drawsDualSide(bubbleStyle)
|
||||
|
||||
view.setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble)
|
||||
}
|
||||
|
||||
fun setFlatRtl(layout: ViewGroup, direction: Int, childDirection: Int, depth: Int = 1) {
|
||||
layout.layoutDirection = direction
|
||||
for (child in layout.children) {
|
||||
if (depth > 1 && child is ViewGroup) {
|
||||
setFlatRtl(child, direction, childDirection, depth-1)
|
||||
} else {
|
||||
child.layoutDirection = childDirection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.ui.views.SendStateImageView
|
||||
import im.vector.app.core.ui.views.setFlatRtl
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||
|
|
|
@ -32,6 +32,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
|
|||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.platform.CheckableView
|
||||
import im.vector.app.core.ui.views.BubbleDependentView
|
||||
import im.vector.app.core.ui.views.updateMessageBubble
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.features.themes.BubbleThemeUtils
|
||||
|
||||
|
@ -129,4 +130,8 @@ abstract class BaseEventItem<H : BaseEventItem.BaseHolder> : VectorEpoxyModel<H>
|
|||
*/
|
||||
}
|
||||
|
||||
|
||||
fun updateMessageBubble(context: Context, holder: H) {
|
||||
return updateMessageBubble(context, this, holder)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.home.room.detail.timeline.item
|
||||
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
|
@ -30,6 +31,8 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
|
|||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.ui.views.BubbleDependentView
|
||||
import im.vector.app.core.ui.views.ReadReceiptsView
|
||||
import im.vector.app.core.ui.views.setFlatRtl
|
||||
import im.vector.app.core.ui.views.updateMessageBubble
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.themes.BubbleThemeUtils
|
||||
import timber.log.Timber
|
||||
|
@ -105,4 +108,9 @@ abstract class ReadReceiptsItem : EpoxyModelWithHolder<ReadReceiptsItem.Holder>(
|
|||
// Also set rtl to have members fill from the natural side
|
||||
setFlatRtl(holder.readReceiptsView, if (dualBubbles) reverseDirection else defaultDirection, defaultDirection)
|
||||
}
|
||||
|
||||
fun updateMessageBubble(context: Context, holder: Holder) {
|
||||
return updateMessageBubble(context, this, holder)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue