Skip to content

Commit 3155dcd

Browse files
committed
see 10/25 log
1 parent b9b1a1a commit 3155dcd

File tree

8 files changed

+83
-77
lines changed

8 files changed

+83
-77
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.21.1-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.21.2-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.21.1-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.21.2-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/src/main/java/com/blankj/androidutilcode/feature/core/span/SpanActivity.java

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
import android.animation.ValueAnimator;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.graphics.BitmapFactory;
7+
import android.graphics.BitmapShader;
8+
import android.graphics.BlurMaskFilter;
69
import android.graphics.Color;
710
import android.graphics.LinearGradient;
811
import android.graphics.Matrix;
912
import android.graphics.Shader;
13+
import android.graphics.Typeface;
1014
import android.os.Bundle;
1115
import android.support.annotation.Nullable;
1216
import android.support.v4.content.ContextCompat;
17+
import android.text.Layout;
1318
import android.text.SpannableStringBuilder;
1419
import android.text.TextPaint;
1520
import android.text.method.LinkMovementMethod;
@@ -56,7 +61,7 @@ public class SpanActivity extends BaseBackActivity {
5661

5762
float density;
5863
TextView tvAboutSpan;
59-
TextView tvAboutAnimRainbow;
64+
TextView tvAboutAnimSpan;
6065

6166
public static void start(Context context) {
6267
Intent starter = new Intent(context, SpanActivity.class);
@@ -91,7 +96,7 @@ public void updateDrawState(TextPaint ds) {
9196
};
9297

9398
tvAboutSpan = findViewById(R.id.tv_about_span);
94-
tvAboutAnimRainbow = findViewById(R.id.tv_about_anim_span);
99+
tvAboutAnimSpan = findViewById(R.id.tv_about_anim_span);
95100

96101
// 响应点击事件的话必须设置以下属性
97102
tvAboutSpan.setMovementMethod(LinkMovementMethod.getInstance());
@@ -101,58 +106,11 @@ public void updateDrawState(TextPaint ds) {
101106
textSize = tvAboutSpan.getTextSize();
102107
density = getResources().getDisplayMetrics().density;
103108

104-
// initAnimSpan();
105-
// startAnim();
109+
initAnimSpan();
110+
startAnim();
106111

107112

108113
tvAboutSpan.setText(new SpanUtils()
109-
// .appendLine("SpanUtils").setBackgroundColor(Color.LTGRAY).setBold().setForegroundColor(Color.YELLOW).setAlign(Layout.Alignment.ALIGN_CENTER)
110-
// .appendLine("前景色").setForegroundColor(Color.GREEN)
111-
// .appendLine("背景色").setBackgroundColor(Color.LTGRAY)
112-
// .appendLine("行高顶部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
113-
// .appendLine("行高居中对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
114-
// .appendLine("行高底部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
115-
// .appendLine("测试段落缩,首行缩进两字,其他行不缩进").setLeadingMargin((int) textSize * 2, 10).setBackgroundColor(Color.GREEN)
116-
// .appendLine("测试引用,后面的字是为了凑到两行的效果").setQuoteColor(Color.GREEN, 10, 10).setBackgroundColor(Color.LTGRAY)
117-
// .appendLine("测试列表项,后面的字是为了凑到两行的效果").setBullet(Color.GREEN, 20, 10).setBackgroundColor(Color.LTGRAY).setBackgroundColor(Color.GREEN)
118-
// .appendLine("32dp 字体").setFontSize(32, true)
119-
// .appendLine("2 倍字体").setFontProportion(2)
120-
// .appendLine("横向 2 倍字体").setFontXProportion(1.5f)
121-
// .appendLine("删除线").setStrikethrough()
122-
// .appendLine("下划线").setUnderline()
123-
// .append("测试").appendLine("上标").setSuperscript()
124-
// .append("测试").appendLine("下标").setSubscript()
125-
// .appendLine("粗体").setBold()
126-
// .appendLine("斜体").setItalic()
127-
// .appendLine("粗斜体").setBoldItalic()
128-
// .appendLine("monospace 字体").setFontFamily("monospace")
129-
// .appendLine("自定义字体").setTypeface(Typeface.createFromAsset(getAssets(), "fonts/dnmbhs.ttf"))
130-
// .appendLine("相反对齐").setAlign(Layout.Alignment.ALIGN_OPPOSITE)
131-
// .appendLine("居中对齐").setAlign(Layout.Alignment.ALIGN_CENTER)
132-
// .appendLine("正常对齐").setAlign(Layout.Alignment.ALIGN_NORMAL)
133-
// .append("测试").appendLine("点击事件").setClickSpan(clickableSpan)
134-
// .append("测试").appendLine("Url").setUrl("https://github.com/Blankj/AndroidUtilCode")
135-
// .append("测试").appendLine("模糊").setBlur(3, BlurMaskFilter.Blur.NORMAL)
136-
// .appendLine("颜色渐变").setShader(new LinearGradient(0, 0,
137-
// 64 * density * 4, 0,
138-
// getResources().getIntArray(R.array.rainbow),
139-
// null,
140-
// Shader.TileMode.REPEAT)).setFontSize(64, true)
141-
// .appendLine("图片着色").setFontSize(64, true).setShader(new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.span_cheetah),
142-
// Shader.TileMode.REPEAT,
143-
// Shader.TileMode.REPEAT))
144-
// .appendLine("阴影效果").setFontSize(64, true).setBackgroundColor(Color.BLACK).setShadow(24, 8, 8, Color.WHITE)
145-
//
146-
// .append("小图").setBackgroundColor(Color.GREEN)
147-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_TOP)
148-
// .append("顶部").setBackgroundColor(Color.GREEN)
149-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_CENTER)
150-
// .append("居中").setBackgroundColor(Color.GREEN)
151-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BASELINE)
152-
// .append("底部").setBackgroundColor(Color.GREEN)
153-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BOTTOM)
154-
// .appendLine("对齐").setBackgroundColor(Color.GREEN)
155-
156114
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
157115
.append("大图").setBackgroundColor(Color.LTGRAY)
158116
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
@@ -174,6 +132,53 @@ public void updateDrawState(TextPaint ds) {
174132
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_BOTTOM)
175133
.appendLine("对齐").setBackgroundColor(Color.LTGRAY)
176134

135+
.appendLine("SpanUtils").setBackgroundColor(Color.LTGRAY).setBold().setForegroundColor(Color.YELLOW).setAlign(Layout.Alignment.ALIGN_CENTER)
136+
.appendLine("前景色").setForegroundColor(Color.GREEN)
137+
.appendLine("背景色").setBackgroundColor(Color.LTGRAY)
138+
.appendLine("行高顶部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
139+
.appendLine("行高居中对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
140+
.appendLine("行高底部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
141+
.appendLine("测试段落缩,首行缩进两字,其他行不缩进").setLeadingMargin((int) textSize * 2, 10).setBackgroundColor(Color.GREEN)
142+
.appendLine("测试引用,后面的字是为了凑到两行的效果").setQuoteColor(Color.GREEN, 10, 10).setBackgroundColor(Color.LTGRAY)
143+
.appendLine("测试列表项,后面的字是为了凑到两行的效果").setBullet(Color.GREEN, 20, 10).setBackgroundColor(Color.LTGRAY).setBackgroundColor(Color.GREEN)
144+
.appendLine("32dp 字体").setFontSize(32, true)
145+
.appendLine("2 倍字体").setFontProportion(2)
146+
.appendLine("横向 2 倍字体").setFontXProportion(1.5f)
147+
.appendLine("删除线").setStrikethrough()
148+
.appendLine("下划线").setUnderline()
149+
.append("测试").appendLine("上标").setSuperscript()
150+
.append("测试").appendLine("下标").setSubscript()
151+
.appendLine("粗体").setBold()
152+
.appendLine("斜体").setItalic()
153+
.appendLine("粗斜体").setBoldItalic()
154+
.appendLine("monospace 字体").setFontFamily("monospace")
155+
.appendLine("自定义字体").setTypeface(Typeface.createFromAsset(getAssets(), "fonts/dnmbhs.ttf"))
156+
.appendLine("相反对齐").setAlign(Layout.Alignment.ALIGN_OPPOSITE)
157+
.appendLine("居中对齐").setAlign(Layout.Alignment.ALIGN_CENTER)
158+
.appendLine("正常对齐").setAlign(Layout.Alignment.ALIGN_NORMAL)
159+
.append("测试").appendLine("点击事件").setClickSpan(clickableSpan)
160+
.append("测试").appendLine("Url").setUrl("https://github.com/Blankj/AndroidUtilCode")
161+
.append("测试").appendLine("模糊").setBlur(3, BlurMaskFilter.Blur.NORMAL)
162+
.appendLine("颜色渐变").setShader(new LinearGradient(0, 0,
163+
64 * density * 4, 0,
164+
getResources().getIntArray(R.array.rainbow),
165+
null,
166+
Shader.TileMode.REPEAT)).setFontSize(64, true)
167+
.appendLine("图片着色").setFontSize(64, true).setShader(new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.span_cheetah),
168+
Shader.TileMode.REPEAT,
169+
Shader.TileMode.REPEAT))
170+
.appendLine("阴影效果").setFontSize(64, true).setBackgroundColor(Color.BLACK).setShadow(24, 8, 8, Color.WHITE)
171+
172+
.append("小图").setBackgroundColor(Color.GREEN)
173+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_TOP)
174+
.append("顶部").setBackgroundColor(Color.GREEN)
175+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_CENTER)
176+
.append("居中").setBackgroundColor(Color.GREEN)
177+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BASELINE)
178+
.append("底部").setBackgroundColor(Color.GREEN)
179+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BOTTOM)
180+
.appendLine("对齐").setBackgroundColor(Color.GREEN)
181+
177182
.append("测试空格").appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN).appendSpace(100).appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN)
178183
.create());
179184
}
@@ -234,7 +239,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
234239
mForegroundAlphaColorSpanGroup.setAlpha((Float) animation.getAnimatedValue());
235240

236241
// update
237-
tvAboutAnimRainbow.setText(animSsb);
242+
tvAboutAnimSpan.setText(animSsb);
238243
}
239244
});
240245

config.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ext {
66
compileSdkVersion: 27,
77
minSdkVersion : 14,
88
targetSdkVersion : 27,
9-
versionCode : 1_021_001,
10-
versionName : '1.21.1'// E.g. 1.9.72 => 1,009,072
9+
versionCode : 1_021_002,
10+
versionName : '1.21.2'// E.g. 1.9.72 => 1,009,072
1111
]
1212

1313
versionConfig = [
@@ -177,7 +177,7 @@ def configAppDependencies(Project pro) {
177177
// LeakCanary
178178
debugImplementation depConfig.leakcanary.android
179179
releaseImplementation depConfig.leakcanary.android_no_op
180-
// implementation 'com.blankj:utilcode:1.21.1'
180+
// implementation 'com.blankj:utilcode:1.21.2'
181181
}
182182
}
183183

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* `18/10/25` [fix] SpanUtils#setLineHeight bug of multi lines. Publish v1.21.2.
12
* `18/10/24` [fix] SpanUtils#appendImage on VIVO. Publish v1.21.1.
23
* `18/10/16` [add] BusUtils, DeviceUtils#isAdbEnabled. Publish v1.21.0.
34
* `18/09/29` [fix] ToastUtils which causes crash in the some devices of Xiaomi. Publish v1.20.4.

utilcode/README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.21.1'
5+
implementation 'com.blankj:utilcode:1.21.2'
66
```
77

88

utilcode/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.21.1'
5+
implementation 'com.blankj:utilcode:1.21.2'
66
```
77

88

utilcode/src/main/java/com/blankj/utilcode/util/SpanUtils.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -915,27 +915,27 @@ class CustomLineHeightSpan extends CharacterStyle
915915
public void chooseHeight(final CharSequence text, final int start, final int end,
916916
final int spanstartv, final int v, final Paint.FontMetricsInt fm) {
917917
int need = height - (v + fm.descent - fm.ascent - spanstartv);
918-
// if (need > 0) {
919-
if (mVerticalAlignment == ALIGN_TOP) {
920-
fm.descent += need;
921-
} else if (mVerticalAlignment == ALIGN_CENTER) {
922-
fm.descent += need / 2;
923-
fm.ascent -= need / 2;
924-
} else {
925-
fm.ascent -= need;
918+
if (need > 0) {
919+
if (mVerticalAlignment == ALIGN_TOP) {
920+
fm.descent += need;
921+
} else if (mVerticalAlignment == ALIGN_CENTER) {
922+
fm.descent += need / 2;
923+
fm.ascent -= need / 2;
924+
} else {
925+
fm.ascent -= need;
926+
}
926927
}
927-
// }
928928
need = height - (v + fm.bottom - fm.top - spanstartv);
929-
// if (need > 0) {
930-
if (mVerticalAlignment == ALIGN_TOP) {
931-
fm.top += need;
932-
} else if (mVerticalAlignment == ALIGN_CENTER) {
933-
fm.bottom += need / 2;
934-
fm.top -= need / 2;
935-
} else {
936-
fm.top -= need;
929+
if (need > 0) {
930+
if (mVerticalAlignment == ALIGN_TOP) {
931+
fm.top += need;
932+
} else if (mVerticalAlignment == ALIGN_CENTER) {
933+
fm.bottom += need / 2;
934+
fm.top -= need / 2;
935+
} else {
936+
fm.top -= need;
937+
}
937938
}
938-
// }
939939
}
940940

941941
@Override

0 commit comments

Comments
 (0)