diff --git a/.idea/dictionaries/tateisu.xml b/.idea/dictionaries/tateisu.xml
index 00a5ea3a..c966e073 100644
--- a/.idea/dictionaries/tateisu.xml
+++ b/.idea/dictionaries/tateisu.xml
@@ -68,6 +68,7 @@
tateisu
thru
timelines
+ tissot
tootsearch
unarist
unboost
@@ -79,6 +80,7 @@
userkey
utoken
workarea
+ xiaomi
\ No newline at end of file
diff --git a/app/src/main/java/jp/juggler/subwaytooter/view/MyLinkMovementMethod.kt b/app/src/main/java/jp/juggler/subwaytooter/view/MyLinkMovementMethod.kt
index e13b9ad4..d192d591 100644
--- a/app/src/main/java/jp/juggler/subwaytooter/view/MyLinkMovementMethod.kt
+++ b/app/src/main/java/jp/juggler/subwaytooter/view/MyLinkMovementMethod.kt
@@ -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
}
}
}