Skip to content

Commit f63debd

Browse files
committed
see 12/01 log
1 parent d9d0bf2 commit f63debd

File tree

3 files changed

+302
-298
lines changed

3 files changed

+302
-298
lines changed

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

Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
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.v4.content.ContextCompat;
16+
import android.text.Layout;
1217
import android.text.SpannableStringBuilder;
1318
import android.text.TextPaint;
1419
import android.text.method.LinkMovementMethod;
@@ -101,90 +106,89 @@ public void updateDrawState(TextPaint ds) {
101106
textSize = tvAboutSpan.getTextSize();
102107
density = getResources().getDisplayMetrics().density;
103108

104-
tvAboutSpan.setText(new SpanUtils()
105-
.appendLine("测试图标文字顶部对齐测试图标文字顶部对齐测试图标文字顶部对齐测试图标文字顶部对齐").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
106-
// .appendLine("测试图标文字居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.GREEN)
107-
// .appendLine("测试图标文字底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.LTGRAY)
108-
// .appendLine("测试图标顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
109-
// .appendLine("测试图标居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
110-
// .appendLine("测试图标底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
111-
// .append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
112-
// .appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
113-
// .appendLine()
114-
.create());
115-
116-
117109
// tvAboutSpan.setText(new SpanUtils()
118-
// .appendLine("SpanUtils").setBackgroundColor(Color.LTGRAY).setBold().setForegroundColor(Color.YELLOW).setAlign(Layout.Alignment.ALIGN_CENTER)
119-
// .appendLine("前景色").setForegroundColor(Color.GREEN)
120-
// .appendLine("背景色").setBackgroundColor(Color.LTGRAY)
121-
// .appendLine("行高顶部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
122-
// .appendLine("行高居中对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
123-
// .appendLine("行高底部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
124-
// .appendLine("测试段落缩,首行缩进两字,其他行不缩进").setLeadingMargin((int) textSize * 2, 10).setBackgroundColor(Color.GREEN)
125-
// .appendLine("测试引用,后面的字是为了凑到两行的效果").setQuoteColor(Color.GREEN, 10, 10).setBackgroundColor(Color.LTGRAY)
126-
// .appendLine("测试列表项,后面的字是为了凑到两行的效果").setBullet(Color.GREEN, 20, 10).setBackgroundColor(Color.LTGRAY).setBackgroundColor(Color.GREEN)
127-
// .appendLine("测试图标文字顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.LTGRAY)
110+
// .appendLine("测试图标文字顶部对齐测试图标文字顶部对齐测试图标文字顶部对齐测试图标文字顶部对齐").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
128111
// .appendLine("测试图标文字居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.GREEN)
129112
// .appendLine("测试图标文字底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.LTGRAY)
130113
// .appendLine("测试图标顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
131114
// .appendLine("测试图标居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
132115
// .appendLine("测试图标底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
133-
// .appendLine("32dp 字体").setFontSize(32, true)
134-
// .appendLine("2 倍字体").setFontProportion(2)
135-
// .appendLine("横向 2 倍字体").setFontXProportion(1.5f)
136-
// .appendLine("删除线").setStrikethrough()
137-
// .appendLine("下划线").setUnderline()
138-
// .append("测试").appendLine("上标").setSuperscript()
139-
// .append("测试").appendLine("下标").setSubscript()
140-
// .appendLine("粗体").setBold()
141-
// .appendLine("斜体").setItalic()
142-
// .appendLine("粗斜体").setBoldItalic()
143-
// .appendLine("monospace 字体").setFontFamily("monospace")
144-
// .appendLine("自定义字体").setTypeface(Typeface.createFromAsset(getAssets(), "fonts/dnmbhs.ttf"))
145-
// .appendLine("相反对齐").setAlign(Layout.Alignment.ALIGN_OPPOSITE)
146-
// .appendLine("居中对齐").setAlign(Layout.Alignment.ALIGN_CENTER)
147-
// .appendLine("正常对齐").setAlign(Layout.Alignment.ALIGN_NORMAL)
148-
// .append("测试").appendLine("点击事件").setClickSpan(clickableSpan)
149-
// .append("测试").appendLine("Url").setUrl("https://github.com/Blankj/AndroidUtilCode")
150-
// .append("测试").appendLine("模糊").setBlur(3, BlurMaskFilter.Blur.NORMAL)
151-
// .appendLine("颜色渐变").setShader(new LinearGradient(0, 0,
152-
// 64 * density * 4, 0,
153-
// getResources().getIntArray(R.array.rainbow),
154-
// null,
155-
// Shader.TileMode.REPEAT)).setFontSize(64, true)
156-
// .appendLine("图片着色").setFontSize(64, true).setShader(new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.cheetah),
157-
// Shader.TileMode.REPEAT,
158-
// Shader.TileMode.REPEAT))
159-
// .appendLine("阴影效果").setFontSize(64, true).setBackgroundColor(Color.BLACK).setShadow(24, 8, 8, Color.WHITE)
160-
//
161-
// .append("测试小图对齐").setBackgroundColor(Color.LTGRAY)
162-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_TOP)
163-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_CENTER)
164-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BASELINE)
165-
// .appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BOTTOM)
166-
// .appendLine("end").setBackgroundColor(Color.LTGRAY)
167-
//
168116
// .append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
169117
// .appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
170-
// .append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
171-
// .appendLine()
172-
//
173-
// .append("测试大图字体居中对齐").setBackgroundColor(Color.LTGRAY)
174-
// .appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_CENTER)
175-
// .append("测试大图字体居中对齐").setBackgroundColor(Color.LTGRAY)
176-
// .appendLine()
177-
//
178-
// .append("测试大图字体底部对齐").setBackgroundColor(Color.GREEN)
179-
// .appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_BOTTOM)
180-
// .append("测试大图字体底部对齐").setBackgroundColor(Color.GREEN)
181118
// .appendLine()
182-
//
183-
// .append("测试空格").appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN).appendSpace(100).appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN)
184119
// .create());
185-
//
186-
// initAnimSpan();
187-
// startAnim();
120+
121+
initAnimSpan();
122+
startAnim();
123+
124+
tvAboutSpan.setText(new SpanUtils()
125+
.appendLine("SpanUtils").setBackgroundColor(Color.LTGRAY).setBold().setForegroundColor(Color.YELLOW).setAlign(Layout.Alignment.ALIGN_CENTER)
126+
.appendLine("前景色").setForegroundColor(Color.GREEN)
127+
.appendLine("背景色").setBackgroundColor(Color.LTGRAY)
128+
.appendLine("行高顶部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
129+
.appendLine("行高居中对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
130+
.appendLine("行高底部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
131+
.appendLine("测试段落缩,首行缩进两字,其他行不缩进").setLeadingMargin((int) textSize * 2, 10).setBackgroundColor(Color.GREEN)
132+
.appendLine("测试引用,后面的字是为了凑到两行的效果").setQuoteColor(Color.GREEN, 10, 10).setBackgroundColor(Color.LTGRAY)
133+
.appendLine("测试列表项,后面的字是为了凑到两行的效果").setBullet(Color.GREEN, 20, 10).setBackgroundColor(Color.LTGRAY).setBackgroundColor(Color.GREEN)
134+
.appendLine("测试图标文字顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.LTGRAY)
135+
.appendLine("测试图标文字居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.GREEN)
136+
.appendLine("测试图标文字底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.LTGRAY)
137+
.appendLine("测试图标顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
138+
.appendLine("测试图标居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
139+
.appendLine("测试图标底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
140+
.appendLine("32dp 字体").setFontSize(32, true)
141+
.appendLine("2 倍字体").setFontProportion(2)
142+
.appendLine("横向 2 倍字体").setFontXProportion(1.5f)
143+
.appendLine("删除线").setStrikethrough()
144+
.appendLine("下划线").setUnderline()
145+
.append("测试").appendLine("上标").setSuperscript()
146+
.append("测试").appendLine("下标").setSubscript()
147+
.appendLine("粗体").setBold()
148+
.appendLine("斜体").setItalic()
149+
.appendLine("粗斜体").setBoldItalic()
150+
.appendLine("monospace 字体").setFontFamily("monospace")
151+
.appendLine("自定义字体").setTypeface(Typeface.createFromAsset(getAssets(), "fonts/dnmbhs.ttf"))
152+
.appendLine("相反对齐").setAlign(Layout.Alignment.ALIGN_OPPOSITE)
153+
.appendLine("居中对齐").setAlign(Layout.Alignment.ALIGN_CENTER)
154+
.appendLine("正常对齐").setAlign(Layout.Alignment.ALIGN_NORMAL)
155+
.append("测试").appendLine("点击事件").setClickSpan(clickableSpan)
156+
.append("测试").appendLine("Url").setUrl("https://github.com/Blankj/AndroidUtilCode")
157+
.append("测试").appendLine("模糊").setBlur(3, BlurMaskFilter.Blur.NORMAL)
158+
.appendLine("颜色渐变").setShader(new LinearGradient(0, 0,
159+
64 * density * 4, 0,
160+
getResources().getIntArray(R.array.rainbow),
161+
null,
162+
Shader.TileMode.REPEAT)).setFontSize(64, true)
163+
.appendLine("图片着色").setFontSize(64, true).setShader(new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.cheetah),
164+
Shader.TileMode.REPEAT,
165+
Shader.TileMode.REPEAT))
166+
.appendLine("阴影效果").setFontSize(64, true).setBackgroundColor(Color.BLACK).setShadow(24, 8, 8, Color.WHITE)
167+
168+
.append("测试小图对齐").setBackgroundColor(Color.LTGRAY)
169+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_TOP)
170+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_CENTER)
171+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BASELINE)
172+
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BOTTOM)
173+
.appendLine("end").setBackgroundColor(Color.LTGRAY)
174+
175+
.append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
176+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
177+
.append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
178+
.appendLine()
179+
180+
.append("测试大图字体居中对齐").setBackgroundColor(Color.LTGRAY)
181+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_CENTER)
182+
.append("测试大图字体居中对齐").setBackgroundColor(Color.LTGRAY)
183+
.appendLine()
184+
185+
.append("测试大图字体底部对齐").setBackgroundColor(Color.GREEN)
186+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_BOTTOM)
187+
.append("测试大图字体底部对齐").setBackgroundColor(Color.GREEN)
188+
.appendLine()
189+
190+
.append("测试空格").appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN).appendSpace(100).appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN)
191+
.create());
188192
}
189193

190194
private void initAnimSpan() {

subutil/README-CN.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
```
1010
copyText : 复制文本到剪贴板
1111
getText : 获取剪贴板的文本
12-
copyUri : 复制 uri 到剪贴板
13-
getUri : 获取剪贴板的 uri
12+
copyUri : 复制uri到剪贴板
13+
getUri : 获取剪贴板的uri
1414
copyIntent: 复制意图到剪贴板
1515
getIntent : 获取剪贴板的意图
1616
```
1717

1818
* ### 定位相关 -> [LocationUtils.java][location.java] -> [Demo][location.demo]
1919
```
20-
isGpsEnabled : 判断 Gps 是否可用
20+
isGpsEnabled : 判断Gps是否可用
2121
isLocationEnabled: 判断定位是否可用
22-
openGpsSettings : 打开 Gps 设置界面
22+
openGpsSettings : 打开Gps设置界面
2323
register : 注册
2424
unregister : 注销
2525
getAddress : 根据经纬度获取地理位置
@@ -42,19 +42,19 @@ getSurnameFirstLetter: 根据名字获取姓氏的首字母
4242

4343
* ### 线程池相关 -> [ThreadPoolUtils.java][thread_pool.java]
4444
```
45-
ThreadPoolUtils : ThreadPoolUtils 构造函数
45+
ThreadPoolUtils : ThreadPoolUtils构造函数
4646
execute : 在未来某个时间执行给定的命令
4747
execute : 在未来某个时间执行给定的命令链表
4848
shutDown : 待以前提交的任务执行完毕后关闭线程池
4949
shutDownNow : 试图停止所有正在执行的活动任务
5050
isShutDown : 判断线程池是否已关闭
5151
isTerminated : 关闭线程池后判断所有任务是否都已完成
5252
awaitTermination : 请求关闭、发生超时或者当前线程中断
53-
submit : 提交一个 Callable 任务用于执行
54-
submit : 提交一个 Runnable 任务用于执行
53+
submit : 提交一个Callable任务用于执行
54+
submit : 提交一个Runnable任务用于执行
5555
invokeAll, invokeAny : 执行给定的任务
56-
schedule : 延迟执行 Runnable 命令
57-
schedule : 延迟执行 Callable 命令
56+
schedule : 延迟执行Runnable命令
57+
schedule : 延迟执行Callable命令
5858
scheduleWithFixedRate : 延迟并循环执行命令
5959
scheduleWithFixedDelay: 延迟并以固定休息时间循环执行命令
6060
```

0 commit comments

Comments
 (0)