Skip to content

Commit 72e3d99

Browse files
committed
see 10/24 log
1 parent 1fca9b5 commit 72e3d99

File tree

5 files changed

+58
-76
lines changed

5 files changed

+58
-76
lines changed

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

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
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;
96
import android.graphics.Color;
107
import android.graphics.LinearGradient;
118
import android.graphics.Matrix;
129
import android.graphics.Shader;
13-
import android.graphics.Typeface;
1410
import android.os.Bundle;
1511
import android.support.annotation.Nullable;
1612
import android.support.v4.content.ContextCompat;
17-
import android.text.Layout;
1813
import android.text.SpannableStringBuilder;
1914
import android.text.TextPaint;
2015
import android.text.method.LinkMovementMethod;
@@ -106,57 +101,57 @@ public void updateDrawState(TextPaint ds) {
106101
textSize = tvAboutSpan.getTextSize();
107102
density = getResources().getDisplayMetrics().density;
108103

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

112107

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

161156
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
162157
.append("大图").setBackgroundColor(Color.LTGRAY)

config.gradle

Lines changed: 2 additions & 2 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_000,
10-
versionName : '1.21.0'// E.g. 1.9.72 => 1,009,072
9+
versionCode : 1_021_001,
10+
versionName : '1.21.1'// E.g. 1.9.72 => 1,009,072
1111
]
1212

1313
versionConfig = [

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* `18/10/24` [fix] SpanUtils#appendImage on VIVO. Publish v1.21.1.
12
* `18/10/16` [add] BusUtils, DeviceUtils#isAdbEnabled. Publish v1.21.0.
23
* `18/09/29` [fix] ToastUtils which causes crash in the some devices of Xiaomi. Publish v1.20.4.
34
* `18/09/13` 修复 ToastUtils 在小米手机显示 Toast 带有 App 名,发布 1.20.3

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,16 @@ public final class SpanUtils {
130130

131131
private SpannableStringBuilder mBuilder;
132132

133-
private int mType;
133+
private int mType;
134134
private final int mTypeCharSequence = 0;
135135
private final int mTypeImage = 1;
136136
private final int mTypeSpace = 2;
137137

138-
private CharSequence fontSizeTagCS = "[SpanUtils]";
139-
140-
141138
public SpanUtils() {
142139
mBuilder = new SpannableStringBuilder();
143140
mText = "";
141+
mType = -1;
144142
setDefault();
145-
append(fontSizeTagCS);
146143
}
147144

148145
private void setDefault() {
@@ -181,17 +178,6 @@ private void setDefault() {
181178
spaceSize = -1;
182179
}
183180

184-
/**
185-
* The character used to get the font size (span start with image)
186-
*
187-
* @param fontSizeTagCS The character
188-
* @return the single {@link SpanUtils} instance
189-
*/
190-
public SpanUtils setFontSizeTagCS(CharSequence fontSizeTagCS) {
191-
this.fontSizeTagCS = fontSizeTagCS;
192-
return this;
193-
}
194-
195181
/**
196182
* Set the span of flag.
197183
*
@@ -765,7 +751,7 @@ private void apply(final int type) {
765751
*/
766752
public SpannableStringBuilder create() {
767753
applyLast();
768-
return mBuilder.delete(0, fontSizeTagCS.length());
754+
return mBuilder;
769755
}
770756

771757
private void applyLast() {
@@ -885,6 +871,10 @@ private void updateCharCharSequence() {
885871

886872
private void updateImage() {
887873
int start = mBuilder.length();
874+
if (start == 0) {
875+
mBuilder.append(Character.toString((char) 2));
876+
start = 1;
877+
}
888878
mBuilder.append("<img>");
889879
int end = start + 5;
890880
if (imageBitmap != null) {

utilcode/src/test/java/com/blankj/utilcode/util/BaseTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
import org.robolectric.RuntimeEnvironment;
77
import org.robolectric.annotation.Config;
88

9-
import java.beans.PropertyChangeEvent;
10-
import java.beans.PropertyChangeListener;
11-
import java.beans.PropertyChangeSupport;
12-
139
/**
1410
* <pre>
1511
* author: Blankj

0 commit comments

Comments
 (0)