From 365d3d2e36a2ee849c4621622423423cd7c46270 Mon Sep 17 00:00:00 2001 From: Jun Gu <2dxgujun@gmail.com> Date: Fri, 20 Apr 2018 10:48:43 +0800 Subject: [PATCH] v1.7 release, fix onClick not working --- README.md | 2 +- span/build.gradle | 2 +- span/src/main/kotlin/me/gujun/android/span/span.kt | 6 +++--- .../me/gujun/android/span/style/SimpleClickableSpan.kt | 10 ++++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 span/src/main/kotlin/me/gujun/android/span/style/SimpleClickableSpan.kt diff --git a/README.md b/README.md index 00be531..49ef892 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ val text = span { You can grab it via Gradle: ``` -implementation 'me.gujun.android:span:1.6' +implementation 'me.gujun.android:span:1.7' ``` ### Usage diff --git a/span/build.gradle b/span/build.gradle index ca06cb2..e5d66f1 100644 --- a/span/build.gradle +++ b/span/build.gradle @@ -23,7 +23,7 @@ dependencies { def GROUP = 'me.gujun.android' def ARTIFACTID = 'span' -def VERSION = '1.6' +def VERSION = '1.7' group = GROUP version = VERSION diff --git a/span/src/main/kotlin/me/gujun/android/span/span.kt b/span/src/main/kotlin/me/gujun/android/span/span.kt index 0581aa5..d3007f2 100644 --- a/span/src/main/kotlin/me/gujun/android/span/span.kt +++ b/span/src/main/kotlin/me/gujun/android/span/span.kt @@ -11,7 +11,6 @@ import android.text.TextUtils import android.text.style.AbsoluteSizeSpan import android.text.style.AlignmentSpan import android.text.style.BackgroundColorSpan -import android.text.style.ClickableSpan import android.text.style.ForegroundColorSpan import android.text.style.ImageSpan import android.text.style.QuoteSpan @@ -23,6 +22,7 @@ import android.text.style.URLSpan import android.view.View import me.gujun.android.span.style.CustomTypefaceSpan import me.gujun.android.span.style.LineSpacingSpan +import me.gujun.android.span.style.SimpleClickableSpan import me.gujun.android.span.style.TextDecorationLineSpan import me.gujun.android.span.style.VerticalPaddingSpan @@ -102,7 +102,7 @@ class Span(val parent: Span? = null) : SpannableStringBuilder() { } if (onClick != null) { - builder.add(object : ClickableSpan() { + builder.add(object : SimpleClickableSpan() { override fun onClick(widget: View) { onClick?.invoke() } @@ -205,7 +205,7 @@ class Span(val parent: Span? = null) : SpannableStringBuilder() { if (verticalPadding == null) { verticalPadding = style.verticalPadding } - if (onClick != null) { + if (onClick == null) { onClick = style.onClick } spans.addAll(style.spans) diff --git a/span/src/main/kotlin/me/gujun/android/span/style/SimpleClickableSpan.kt b/span/src/main/kotlin/me/gujun/android/span/style/SimpleClickableSpan.kt new file mode 100644 index 0000000..491d1fc --- /dev/null +++ b/span/src/main/kotlin/me/gujun/android/span/style/SimpleClickableSpan.kt @@ -0,0 +1,10 @@ +package me.gujun.android.span.style + +import android.text.TextPaint +import android.text.style.ClickableSpan + +abstract class SimpleClickableSpan : ClickableSpan() { + override fun updateDrawState(ds: TextPaint?) { + // no-op + } +} \ No newline at end of file