updated content text view
This commit is contained in:
parent
b89d3c198e
commit
a383fb5e47
|
@ -29,6 +29,7 @@ import android.view.MotionEvent
|
|||
import android.widget.TextView
|
||||
import org.mariotaku.chameleon.view.ChameleonTextView
|
||||
import org.mariotaku.twidere.extension.setupEmojiFactory
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
/**
|
||||
* Returns true when not clicking links
|
||||
|
@ -85,11 +86,9 @@ class TimelineContentTextView(
|
|||
}
|
||||
|
||||
internal class InternalMovementMethod : BaseMovementMethod() {
|
||||
private var targetSpan: ClickableSpan? = null
|
||||
private var targetSpan: WeakReference<ClickableSpan?>? = null
|
||||
|
||||
override fun initialize(widget: TextView, text: Spannable) {
|
||||
|
||||
}
|
||||
override fun canSelectArbitrarily() = true
|
||||
|
||||
override fun onTouchEvent(widget: TextView, text: Spannable, event: MotionEvent): Boolean {
|
||||
when (event.actionMasked) {
|
||||
|
@ -100,22 +99,22 @@ class TimelineContentTextView(
|
|||
val line = layout.getLineForVertical(Math.round(y))
|
||||
val offset = layout.getOffsetForHorizontal(line, x)
|
||||
if (x <= layout.getLineWidth(line)) {
|
||||
targetSpan = text.getSpans(offset, offset, ClickableSpan::class.java).firstOrNull()
|
||||
targetSpan = WeakReference(text.getSpans(offset, offset, ClickableSpan::class.java).firstOrNull())
|
||||
} else {
|
||||
targetSpan = null
|
||||
}
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
targetSpan?.onClick(widget)
|
||||
val handled = targetSpan != null
|
||||
val span = targetSpan?.get() ?: return false
|
||||
span.onClick(widget)
|
||||
targetSpan = null
|
||||
return handled
|
||||
return true
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
targetSpan = null
|
||||
}
|
||||
}
|
||||
return targetSpan != null
|
||||
return targetSpan?.get() != null
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue