Skip to content

Commit 62afc3f

Browse files
committed
see 12/21 log
1 parent cbb0b3d commit 62afc3f

File tree

12 files changed

+425
-157
lines changed

12 files changed

+425
-157
lines changed

app/src/main/java/com/blankj/androidutilcode/core/app/AppActivity.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.blankj.androidutilcode.R;
1111
import com.blankj.androidutilcode.base.BaseBackActivity;
1212
import com.blankj.utilcode.util.AppUtils;
13+
import com.blankj.utilcode.util.LogUtils;
1314
import com.blankj.utilcode.util.SpanUtils;
1415
import com.blankj.utilcode.util.ToastUtils;
1516

@@ -51,15 +52,14 @@ public void initView(Bundle savedInstanceState, View view) {
5152
findViewById(R.id.btn_exit_app).setOnClickListener(this);
5253
findViewById(R.id.btn_get_app_details_settings).setOnClickListener(this);
5354
TextView tvAboutApp = findViewById(R.id.tv_about_app);
54-
tvAboutApp.setText(
55-
new SpanUtils()
56-
.append("app icon: ").appendImage(AppUtils.getAppIcon(), SpanUtils.ALIGN_CENTER).appendLine()
57-
.appendLine(AppUtils.getAppInfo().toString())
58-
.appendLine("isAppRoot: " + AppUtils.isAppRoot())
59-
.appendLine("isAppDebug: " + AppUtils.isAppDebug())
60-
.appendLine("AppSignatureSHA1: " + AppUtils.getAppSignatureSHA1())
61-
.append("isAppForeground: " + AppUtils.isAppForeground())
62-
.create());
55+
tvAboutApp.setText(new SpanUtils()
56+
.append("app icon: ").appendImage(AppUtils.getAppIcon(), SpanUtils.ALIGN_CENTER).appendLine()
57+
.appendLine(AppUtils.getAppInfo().toString())
58+
.appendLine("isAppRoot: " + AppUtils.isAppRoot())
59+
.appendLine("isAppDebug: " + AppUtils.isAppDebug())
60+
.appendLine("AppSignatureSHA1: " + AppUtils.getAppSignatureSHA1())
61+
.append("isAppForeground: " + AppUtils.isAppForeground())
62+
.create());
6363
}
6464

6565
@Override
@@ -122,4 +122,10 @@ public void run() {
122122
break;
123123
}
124124
}
125+
126+
@Override
127+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
128+
super.onActivityResult(requestCode, resultCode, data);
129+
LogUtils.d(requestCode, resultCode);
130+
}
125131
}

app/src/main/java/com/blankj/androidutilcode/core/snackbar/SnackbarActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ public void onClick(View v) {
154154
.setBgColor(Color.TRANSPARENT)
155155
.setDuration(SnackbarUtils.LENGTH_INDEFINITE)
156156
.show();
157-
params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
157+
params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
158+
ViewGroup.LayoutParams.MATCH_PARENT);
158159
SnackbarUtils.addView(R.layout.snackbar_custom, params);
159160
View snackbarView = SnackbarUtils.getView();
160161
if (snackbarView != null) {
161-
TextView tvSnackbarCustom = (TextView) snackbarView.findViewById(R.id.tv_snackbar_custom);
162+
TextView tvSnackbarCustom = snackbarView.findViewById(R.id.tv_snackbar_custom);
162163
tvSnackbarCustom.setText("点我可消失");
163164
snackbarView.setOnClickListener(new View.OnClickListener() {
164165
@Override
@@ -195,10 +196,9 @@ public void onClick(View v) {
195196

196197
private SpannableStringBuilder getMsg(@StringRes int resId) {
197198
return new SpanUtils()
198-
.appendLine(getString(resId))
199-
.setFontSize(24, true)
200-
.setIconMargin(R.mipmap.ic_launcher, 32, SpanUtils.ALIGN_CENTER)
201-
.append(" ").setFontSize(0)
199+
.appendImage(R.mipmap.ic_launcher, SpanUtils.ALIGN_CENTER)
200+
.appendSpace(32)
201+
.append(getString(resId)).setFontSize(24, true)
202202
.create();
203203
}
204204
}

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

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public class SpanActivity extends BaseBackActivity {
6161
float density;
6262
TextView tvAboutSpan;
6363
TextView tvAboutAnimRainbow;
64-
TextView tvAboutAnimBlur;
64+
TextView tvAboutSpan1;
65+
TextView tvAboutAnimRainbow1;
6566

6667
public static void start(Context context) {
6768
Intent starter = new Intent(context, SpanActivity.class);
@@ -106,18 +107,6 @@ public void updateDrawState(TextPaint ds) {
106107
textSize = tvAboutSpan.getTextSize();
107108
density = getResources().getDisplayMetrics().density;
108109

109-
// tvAboutSpan.setText(new SpanUtils()
110-
// .appendLine("测试图标文字顶部对齐测试图标文字顶部对齐测试图标文字顶部对齐测试图标文字顶部对齐").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
111-
// .appendLine("测试图标文字居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.GREEN)
112-
// .appendLine("测试图标文字底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.LTGRAY)
113-
// .appendLine("测试图标顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
114-
// .appendLine("测试图标居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
115-
// .appendLine("测试图标底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
116-
// .append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
117-
// .appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
118-
// .appendLine()
119-
// .create());
120-
121110
initAnimSpan();
122111
startAnim();
123112

@@ -131,12 +120,15 @@ public void updateDrawState(TextPaint ds) {
131120
.appendLine("测试段落缩,首行缩进两字,其他行不缩进").setLeadingMargin((int) textSize * 2, 10).setBackgroundColor(Color.GREEN)
132121
.appendLine("测试引用,后面的字是为了凑到两行的效果").setQuoteColor(Color.GREEN, 10, 10).setBackgroundColor(Color.LTGRAY)
133122
.appendLine("测试列表项,后面的字是为了凑到两行的效果").setBullet(Color.GREEN, 20, 10).setBackgroundColor(Color.LTGRAY).setBackgroundColor(Color.GREEN)
123+
134124
.appendLine("测试图标文字顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.LTGRAY)
135125
.appendLine("测试图标文字居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.GREEN)
136126
.appendLine("测试图标文字底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_high, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.LTGRAY)
127+
137128
.appendLine("测试图标顶部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_TOP).setBackgroundColor(Color.GREEN)
138129
.appendLine("测试图标居中对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_CENTER).setBackgroundColor(Color.LTGRAY)
139130
.appendLine("测试图标底部对齐,后面的字是为了凑到两行的效果").setIconMargin(R.drawable.shape_spannable_block_low, 20, SpanUtils.ALIGN_BOTTOM).setBackgroundColor(Color.GREEN)
131+
140132
.appendLine("32dp 字体").setFontSize(32, true)
141133
.appendLine("2 倍字体").setFontProportion(2)
142134
.appendLine("横向 2 倍字体").setFontXProportion(1.5f)
@@ -165,27 +157,36 @@ public void updateDrawState(TextPaint ds) {
165157
Shader.TileMode.REPEAT))
166158
.appendLine("阴影效果").setFontSize(64, true).setBackgroundColor(Color.BLACK).setShadow(24, 8, 8, Color.WHITE)
167159

168-
.append("测试小图对齐").setBackgroundColor(Color.LTGRAY)
160+
.append("小图").setBackgroundColor(Color.GREEN)
169161
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_TOP)
162+
.append("顶部").setBackgroundColor(Color.GREEN)
170163
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_CENTER)
164+
.append("居中").setBackgroundColor(Color.GREEN)
171165
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BASELINE)
166+
.append("底部").setBackgroundColor(Color.GREEN)
172167
.appendImage(R.drawable.shape_spannable_block_low, SpanUtils.ALIGN_BOTTOM)
173-
.appendLine("end").setBackgroundColor(Color.LTGRAY)
168+
.appendLine("对齐").setBackgroundColor(Color.GREEN)
174169

175-
.append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
176170
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
177-
.append("测试大图字体顶部对齐").setBackgroundColor(Color.GREEN)
178-
.appendLine()
171+
.append("大图").setBackgroundColor(Color.LTGRAY)
172+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
173+
.append("顶部").setBackgroundColor(Color.LTGRAY)
174+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_TOP)
175+
.appendLine("对齐").setBackgroundColor(Color.LTGRAY)
179176

180-
.append("测试大图字体居中对齐").setBackgroundColor(Color.LTGRAY)
181177
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_CENTER)
182-
.append("测试大图字体居中对齐").setBackgroundColor(Color.LTGRAY)
183-
.appendLine()
178+
.append("大图").setBackgroundColor(Color.GREEN)
179+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_CENTER)
180+
.append("居中").setBackgroundColor(Color.GREEN)
181+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_CENTER)
182+
.appendLine("对齐").setBackgroundColor(Color.GREEN)
184183

185-
.append("测试大图字体底部对齐").setBackgroundColor(Color.GREEN)
186184
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_BOTTOM)
187-
.append("测试大图字体底部对齐").setBackgroundColor(Color.GREEN)
188-
.appendLine()
185+
.append("大图").setBackgroundColor(Color.LTGRAY)
186+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_BOTTOM)
187+
.append("底部").setBackgroundColor(Color.LTGRAY)
188+
.appendImage(R.drawable.shape_spannable_block_high, SpanUtils.ALIGN_BOTTOM)
189+
.appendLine("对齐").setBackgroundColor(Color.LTGRAY)
189190

190191
.append("测试空格").appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN).appendSpace(100).appendSpace(30, Color.LTGRAY).appendSpace(50, Color.GREEN)
191192
.create());

app/src/main/java/com/blankj/androidutilcode/core/toast/ToastActivity.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ public void run() {
9797
break;
9898
case R.id.btn_show_span:
9999
ToastUtils.showLong(new SpanUtils()
100-
.appendLine(getString(R.string.toast_span))
101-
.setFontSize(24, true)
102-
.setIconMargin(R.mipmap.ic_launcher, 32, SpanUtils.ALIGN_CENTER)
103-
.append(" ").setFontSize(0)
100+
.appendImage(R.mipmap.ic_launcher, SpanUtils.ALIGN_CENTER).appendSpace(32)
101+
.append(getString(R.string.toast_span)).setFontSize(24, true)
104102
.create()
105103
);
106104
break;

app/src/main/res_core/layout/activity_app.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
android:id="@+id/tv_about_app"
1212
style="@style/TextStyle"
1313
android:layout_width="match_parent"
14-
android:layout_height="wrap_content"
15-
android:paddingTop="16dp" />
14+
android:layout_height="wrap_content" />
1615

1716
<Button
1817
android:id="@+id/btn_install_app"

app/src/main/res_core/layout/activity_span.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
android:layout_width="match_parent"
2222
android:layout_height="wrap_content"
2323
android:clickable="true"
24-
android:gravity="start" />
24+
android:focusable="true"
25+
android:gravity="start|center_vertical" />
2526

2627
</LinearLayout>

app/src/main/res_core/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,6 @@
222222
<string name="toast_green_font">Green Font</string>
223223
<string name="toast_bg_color">Bg Color</string>
224224
<string name="toast_custom_bg">Custom Bg</string>
225-
<string name="toast_span">Span</string>
225+
<string name="toast_span">Spannable String</string>
226226
<string name="toast_middle">Middle</string>
227227
</resources>

0 commit comments

Comments
 (0)