mirror of
https://github.com/tateisu/SubwayTooter
synced 2024-12-26 17:03:21 +01:00
クラッシュレポート対応
This commit is contained in:
parent
5c3417b8e4
commit
0fdb544d65
@ -68,6 +68,7 @@
|
||||
<w>tateisu</w>
|
||||
<w>thru</w>
|
||||
<w>timelines</w>
|
||||
<w>tissot</w>
|
||||
<w>tootsearch</w>
|
||||
<w>unarist</w>
|
||||
<w>unboost</w>
|
||||
@ -79,6 +80,7 @@
|
||||
<w>userkey</w>
|
||||
<w>utoken</w>
|
||||
<w>workarea</w>
|
||||
<w>xiaomi</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
@ -6,9 +6,12 @@ import android.text.method.Touch
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.MotionEvent
|
||||
import android.widget.TextView
|
||||
import jp.juggler.subwaytooter.util.LogCategory
|
||||
|
||||
object MyLinkMovementMethod : LinkMovementMethod() {
|
||||
|
||||
private val log = LogCategory("MyLinkMovementMethod")
|
||||
|
||||
// 改行より右をタッチしても反応しないようにする
|
||||
override fun onTouchEvent(widget : TextView, buffer : Spannable, event : MotionEvent) : Boolean {
|
||||
|
||||
@ -36,18 +39,26 @@ object MyLinkMovementMethod : LinkMovementMethod() {
|
||||
val line_right = layout.getLineRight(line)
|
||||
if(line_left <= x && x <= line_right) {
|
||||
|
||||
val offset = layout.getOffsetForHorizontal(line, x.toFloat())
|
||||
|
||||
val link = buffer.getSpans(offset, offset, ClickableSpan::class.java)
|
||||
if(link != null && link.isNotEmpty()) {
|
||||
|
||||
if(action == MotionEvent.ACTION_UP) {
|
||||
link[0].onClick(widget)
|
||||
val offset = try{
|
||||
layout.getOffsetForHorizontal(line, x.toFloat())
|
||||
}catch(ex:Throwable){
|
||||
// getOffsetForHorizontal raises error on Xiaomi Mi A1(tissot_sprout), Android 8.1
|
||||
log.trace(ex,"getOffsetForHorizontal failed.")
|
||||
null
|
||||
}
|
||||
|
||||
if( offset != null){
|
||||
val link = buffer.getSpans(offset, offset, ClickableSpan::class.java)
|
||||
if(link != null && link.isNotEmpty()) {
|
||||
|
||||
if(action == MotionEvent.ACTION_UP) {
|
||||
link[0].onClick(widget)
|
||||
}
|
||||
if(widget is MyTextView) {
|
||||
widget.linkHit = true
|
||||
}
|
||||
return true
|
||||
}
|
||||
if(widget is MyTextView) {
|
||||
widget.linkHit = true
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user