Skip to content

Commit

Permalink
v1.2 release, fix line height bug
Browse files Browse the repository at this point in the history
  • Loading branch information
2dxgujun committed Jan 18, 2018
1 parent 028c674 commit 3cc8913
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 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.1'
implementation 'me.gujun.android:span:1.2'
```

### 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.1'
def VERSION = '1.2'

group = GROUP
version = VERSION
Expand Down
1 change: 1 addition & 0 deletions span/src/main/kotlin/me/gujun/android/span/span.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import me.gujun.android.span.style.LineSpacingSpan
import me.gujun.android.span.style.TextDecorationLineSpan
import me.gujun.android.span.style.VerticalPaddingSpan

// TODO Save styles
class Span(val parent: Span? = null) : SpannableStringBuilder() {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ class LineSpacingSpan(private val add: Int) : LineHeightSpan {
val spanStart = text.getSpanStart(this)
val spanEnd = text.getSpanEnd(this)

if (start >= spanStart && end <= spanEnd) {
// Log.d("DEBUG", "text: \n$text")
// Log.d("DEBUG", "spanStart: $spanStart")
// Log.d("DEBUG", "spanEnd: $spanEnd")
// Log.d("DEBUG", "start: $start")
// Log.d("DEBUG", "end: $end") // end may include the \n character
// Log.d("DEBUG", "spanstartv: $spanstartv")
// Log.d("DEBUG", "v: $v")
// Log.d("DEBUG", "-----------------------")

if (start >= spanStart && end < spanEnd) {
fm.descent += add
fm.bottom += add
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ class VerticalPaddingSpan(private val paddingTop: Int,
val spanStart = text.getSpanStart(this)
val spanEnd = text.getSpanEnd(this)

// Log.d("DEBUG", "text: $text")
// Log.d("DEBUG", "text: \n$text")
// Log.d("DEBUG", "spanStart: $spanStart")
// Log.d("DEBUG", "spanEnd: $spanEnd")
// Log.d("DEBUG", "start: $start")
// Log.d("DEBUG", "end: $end")
// Log.d("DEBUG", "end: $end") // end may include the \n character
// Log.d("DEBUG", "spanstartv: $spanstartv")
// Log.d("DEBUG", "v: $v")
// Log.d("DEBUG", "-----------------------")

if (spanStart == start) {
fm.top -= paddingTop
fm.ascent -= paddingTop
}
if (spanEnd == end - 1) {
if (spanEnd == end || spanEnd == end - 1) {
fm.bottom += paddingBottom
fm.descent += paddingBottom
}
}
Expand Down

0 comments on commit 3cc8913

Please sign in to comment.