Skip to content

Commit

Permalink
v1.7 release, fix onClick not working
Browse files Browse the repository at this point in the history
  • Loading branch information
2dxgujun committed Apr 20, 2018
1 parent 6e6eaed commit 365d3d2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion span/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions span/src/main/kotlin/me/gujun/android/span/span.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 365d3d2

Please sign in to comment.