Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiaoxuan_i809
AndroidUtilCode
提交
72e3d996
A
AndroidUtilCode
项目概览
xiaoxuan_i809
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
72e3d996
编写于
10月 24, 2018
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 10/24 log
上级
1fca9b5c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
76 deletion
+58
-76
app/src/main/java/com/blankj/androidutilcode/feature/core/span/SpanActivity.java
...lankj/androidutilcode/feature/core/span/SpanActivity.java
+48
-53
config.gradle
config.gradle
+2
-2
update_log.md
update_log.md
+1
-0
utilcode/src/main/java/com/blankj/utilcode/util/SpanUtils.java
...ode/src/main/java/com/blankj/utilcode/util/SpanUtils.java
+7
-17
utilcode/src/test/java/com/blankj/utilcode/util/BaseTest.java
...code/src/test/java/com/blankj/utilcode/util/BaseTest.java
+0
-4
未找到文件。
app/src/main/java/com/blankj/androidutilcode/feature/core/span/SpanActivity.java
浏览文件 @
72e3d996
...
...
@@ -3,18 +3,13 @@ package com.blankj.androidutilcode.feature.core.span;
import
android.animation.ValueAnimator
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.BitmapFactory
;
import
android.graphics.BitmapShader
;
import
android.graphics.BlurMaskFilter
;
import
android.graphics.Color
;
import
android.graphics.LinearGradient
;
import
android.graphics.Matrix
;
import
android.graphics.Shader
;
import
android.graphics.Typeface
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v4.content.ContextCompat
;
import
android.text.Layout
;
import
android.text.SpannableStringBuilder
;
import
android.text.TextPaint
;
import
android.text.method.LinkMovementMethod
;
...
...
@@ -106,57 +101,57 @@ public class SpanActivity extends BaseBackActivity {
textSize
=
tvAboutSpan
.
getTextSize
();
density
=
getResources
().
getDisplayMetrics
().
density
;
initAnimSpan
();
startAnim
();
//
initAnimSpan();
//
startAnim();
tvAboutSpan
.
setText
(
new
SpanUtils
()
.
appendLine
(
"SpanUtils"
).
setBackgroundColor
(
Color
.
LTGRAY
).
setBold
().
setForegroundColor
(
Color
.
YELLOW
).
setAlign
(
Layout
.
Alignment
.
ALIGN_CENTER
)
.
appendLine
(
"前景色"
).
setForegroundColor
(
Color
.
GREEN
)
.
appendLine
(
"背景色"
).
setBackgroundColor
(
Color
.
LTGRAY
)
.
appendLine
(
"行高顶部对齐"
).
setLineHeight
(
2
*
lineHeight
,
SpanUtils
.
ALIGN_TOP
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendLine
(
"行高居中对齐"
).
setLineHeight
(
2
*
lineHeight
,
SpanUtils
.
ALIGN_CENTER
).
setBackgroundColor
(
Color
.
LTGRAY
)
.
appendLine
(
"行高底部对齐"
).
setLineHeight
(
2
*
lineHeight
,
SpanUtils
.
ALIGN_BOTTOM
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendLine
(
"测试段落缩,首行缩进两字,其他行不缩进"
).
setLeadingMargin
((
int
)
textSize
*
2
,
10
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendLine
(
"测试引用,后面的字是为了凑到两行的效果"
).
setQuoteColor
(
Color
.
GREEN
,
10
,
10
).
setBackgroundColor
(
Color
.
LTGRAY
)
.
appendLine
(
"测试列表项,后面的字是为了凑到两行的效果"
).
setBullet
(
Color
.
GREEN
,
20
,
10
).
setBackgroundColor
(
Color
.
LTGRAY
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendLine
(
"32dp 字体"
).
setFontSize
(
32
,
true
)
.
appendLine
(
"2 倍字体"
).
setFontProportion
(
2
)
.
appendLine
(
"横向 2 倍字体"
).
setFontXProportion
(
1.5f
)
.
appendLine
(
"删除线"
).
setStrikethrough
()
.
appendLine
(
"下划线"
).
setUnderline
()
.
append
(
"测试"
).
appendLine
(
"上标"
).
setSuperscript
()
.
append
(
"测试"
).
appendLine
(
"下标"
).
setSubscript
()
.
appendLine
(
"粗体"
).
setBold
()
.
appendLine
(
"斜体"
).
setItalic
()
.
appendLine
(
"粗斜体"
).
setBoldItalic
()
.
appendLine
(
"monospace 字体"
).
setFontFamily
(
"monospace"
)
.
appendLine
(
"自定义字体"
).
setTypeface
(
Typeface
.
createFromAsset
(
getAssets
(),
"fonts/dnmbhs.ttf"
))
.
appendLine
(
"相反对齐"
).
setAlign
(
Layout
.
Alignment
.
ALIGN_OPPOSITE
)
.
appendLine
(
"居中对齐"
).
setAlign
(
Layout
.
Alignment
.
ALIGN_CENTER
)
.
appendLine
(
"正常对齐"
).
setAlign
(
Layout
.
Alignment
.
ALIGN_NORMAL
)
.
append
(
"测试"
).
appendLine
(
"点击事件"
).
setClickSpan
(
clickableSpan
)
.
append
(
"测试"
).
appendLine
(
"Url"
).
setUrl
(
"https://github.com/Blankj/AndroidUtilCode"
)
.
append
(
"测试"
).
appendLine
(
"模糊"
).
setBlur
(
3
,
BlurMaskFilter
.
Blur
.
NORMAL
)
.
appendLine
(
"颜色渐变"
).
setShader
(
new
LinearGradient
(
0
,
0
,
64
*
density
*
4
,
0
,
getResources
().
getIntArray
(
R
.
array
.
rainbow
),
null
,
Shader
.
TileMode
.
REPEAT
)).
setFontSize
(
64
,
true
)
.
appendLine
(
"图片着色"
).
setFontSize
(
64
,
true
).
setShader
(
new
BitmapShader
(
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
span_cheetah
),
Shader
.
TileMode
.
REPEAT
,
Shader
.
TileMode
.
REPEAT
))
.
appendLine
(
"阴影效果"
).
setFontSize
(
64
,
true
).
setBackgroundColor
(
Color
.
BLACK
).
setShadow
(
24
,
8
,
8
,
Color
.
WHITE
)
.
append
(
"小图"
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendImage
(
R
.
drawable
.
shape_spannable_block_low
,
SpanUtils
.
ALIGN_TOP
)
.
append
(
"顶部"
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendImage
(
R
.
drawable
.
shape_spannable_block_low
,
SpanUtils
.
ALIGN_CENTER
)
.
append
(
"居中"
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendImage
(
R
.
drawable
.
shape_spannable_block_low
,
SpanUtils
.
ALIGN_BASELINE
)
.
append
(
"底部"
).
setBackgroundColor
(
Color
.
GREEN
)
.
appendImage
(
R
.
drawable
.
shape_spannable_block_low
,
SpanUtils
.
ALIGN_BOTTOM
)
.
appendLine
(
"对齐"
).
setBackgroundColor
(
Color
.
GREEN
)
//
.appendLine("SpanUtils").setBackgroundColor(Color.LTGRAY).setBold().setForegroundColor(Color.YELLOW).setAlign(Layout.Alignment.ALIGN_CENTER)
//
.appendLine("前景色").setForegroundColor(Color.GREEN)
//
.appendLine("背景色").setBackgroundColor(Color.LTGRAY)
//
.appendLine("行高顶部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
//
.appendLine("行高居中对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
//
.appendLine("行高底部对齐").setLineHeight(2 * lineHeight, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
//
.appendLine("测试段落缩,首行缩进两字,其他行不缩进").setLeadingMargin((int) textSize * 2, 10).setBackgroundColor(Color.GREEN)
//
.appendLine("测试引用,后面的字是为了凑到两行的效果").setQuoteColor(Color.GREEN, 10, 10).setBackgroundColor(Color.LTGRAY)
//
.appendLine("测试列表项,后面的字是为了凑到两行的效果").setBullet(Color.GREEN, 20, 10).setBackgroundColor(Color.LTGRAY).setBackgroundColor(Color.GREEN)
//
.appendLine("32dp 字体").setFontSize(32, true)
//
.appendLine("2 倍字体").setFontProportion(2)
//
.appendLine("横向 2 倍字体").setFontXProportion(1.5f)
//
.appendLine("删除线").setStrikethrough()
//
.appendLine("下划线").setUnderline()
//
.append("测试").appendLine("上标").setSuperscript()
//
.append("测试").appendLine("下标").setSubscript()
//
.appendLine("粗体").setBold()
//
.appendLine("斜体").setItalic()
//
.appendLine("粗斜体").setBoldItalic()
//
.appendLine("monospace 字体").setFontFamily("monospace")
//
.appendLine("自定义字体").setTypeface(Typeface.createFromAsset(getAssets(), "fonts/dnmbhs.ttf"))
//
.appendLine("相反对齐").setAlign(Layout.Alignment.ALIGN_OPPOSITE)
//
.appendLine("居中对齐").setAlign(Layout.Alignment.ALIGN_CENTER)
//
.appendLine("正常对齐").setAlign(Layout.Alignment.ALIGN_NORMAL)
//
.append("测试").appendLine("点击事件").setClickSpan(clickableSpan)
//
.append("测试").appendLine("Url").setUrl("https://github.com/Blankj/AndroidUtilCode")
//
.append("测试").appendLine("模糊").setBlur(3, BlurMaskFilter.Blur.NORMAL)
//
.appendLine("颜色渐变").setShader(new LinearGradient(0, 0,
//
64 * density * 4, 0,
//
getResources().getIntArray(R.array.rainbow),
//
null,
//
Shader.TileMode.REPEAT)).setFontSize(64, true)
//
.appendLine("图片着色").setFontSize(64, true).setShader(new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.span_cheetah),
//
Shader.TileMode.REPEAT,
//
Shader.TileMode.REPEAT))
//
.appendLine("阴影效果").setFontSize(64, true).setBackgroundColor(Color.BLACK).setShadow(24, 8, 8, Color.WHITE)
//
//
.append("小图").setBackgroundColor(Color.GREEN)
//
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_TOP)
//
.append("顶部").setBackgroundColor(Color.GREEN)
//
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_CENTER)
//
.append("居中").setBackgroundColor(Color.GREEN)
//
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BASELINE)
//
.append("底部").setBackgroundColor(Color.GREEN)
//
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BOTTOM)
//
.appendLine("对齐").setBackgroundColor(Color.GREEN)
.
appendImage
(
R
.
drawable
.
shape_spannable_block_high
,
SpanUtils
.
ALIGN_TOP
)
.
append
(
"大图"
).
setBackgroundColor
(
Color
.
LTGRAY
)
...
...
config.gradle
浏览文件 @
72e3d996
...
...
@@ -6,8 +6,8 @@ ext {
compileSdkVersion:
27
,
minSdkVersion
:
14
,
targetSdkVersion
:
27
,
versionCode
:
1
_021_00
0
,
versionName
:
'1.21.
0
'
// E.g. 1.9.72 => 1,009,072
versionCode
:
1
_021_00
1
,
versionName
:
'1.21.
1
'
// E.g. 1.9.72 => 1,009,072
]
versionConfig
=
[
...
...
update_log.md
浏览文件 @
72e3d996
*
`18/10/24`
[fix] SpanUtils#appendImage on VIVO. Publish v1.21.1.
*
`18/10/16`
[add] BusUtils, DeviceUtils#isAdbEnabled. Publish v1.21.0.
*
`18/09/29`
[fix] ToastUtils which causes crash in the some devices of Xiaomi. Publish v1.20.4.
*
`18/09/13`
修复 ToastUtils 在小米手机显示 Toast 带有 App 名,发布 1.20.3
...
...
utilcode/src/main/java/com/blankj/utilcode/util/SpanUtils.java
浏览文件 @
72e3d996
...
...
@@ -130,19 +130,16 @@ public final class SpanUtils {
private
SpannableStringBuilder
mBuilder
;
private
int
mType
;
private
int
mType
;
private
final
int
mTypeCharSequence
=
0
;
private
final
int
mTypeImage
=
1
;
private
final
int
mTypeSpace
=
2
;
private
CharSequence
fontSizeTagCS
=
"[SpanUtils]"
;
public
SpanUtils
()
{
mBuilder
=
new
SpannableStringBuilder
();
mText
=
""
;
mType
=
-
1
;
setDefault
();
append
(
fontSizeTagCS
);
}
private
void
setDefault
()
{
...
...
@@ -181,17 +178,6 @@ public final class SpanUtils {
spaceSize
=
-
1
;
}
/**
* The character used to get the font size (span start with image)
*
* @param fontSizeTagCS The character
* @return the single {@link SpanUtils} instance
*/
public
SpanUtils
setFontSizeTagCS
(
CharSequence
fontSizeTagCS
)
{
this
.
fontSizeTagCS
=
fontSizeTagCS
;
return
this
;
}
/**
* Set the span of flag.
*
...
...
@@ -765,7 +751,7 @@ public final class SpanUtils {
*/
public
SpannableStringBuilder
create
()
{
applyLast
();
return
mBuilder
.
delete
(
0
,
fontSizeTagCS
.
length
())
;
return
mBuilder
;
}
private
void
applyLast
()
{
...
...
@@ -885,6 +871,10 @@ public final class SpanUtils {
private
void
updateImage
()
{
int
start
=
mBuilder
.
length
();
if
(
start
==
0
)
{
mBuilder
.
append
(
Character
.
toString
((
char
)
2
));
start
=
1
;
}
mBuilder
.
append
(
"<img>"
);
int
end
=
start
+
5
;
if
(
imageBitmap
!=
null
)
{
...
...
utilcode/src/test/java/com/blankj/utilcode/util/BaseTest.java
浏览文件 @
72e3d996
...
...
@@ -6,10 +6,6 @@ import org.robolectric.RobolectricTestRunner;
import
org.robolectric.RuntimeEnvironment
;
import
org.robolectric.annotation.Config
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeSupport
;
/**
* <pre>
* author: Blankj
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录