Skip to content

Commit b20421e

Browse files
committed
see 11/01 log
1 parent cf13a09 commit b20421e

File tree

14 files changed

+93
-22
lines changed

14 files changed

+93
-22
lines changed

README-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ showShortSnackbar : 显示短时snackbar
366366
showLongSnackbar : 显示长时snackbar
367367
showIndefiniteSnackbar : 显示自定义时长snackbar
368368
addView : 为SnackBar添加布局
369+
dismissSnackbar : 取消snackbar显示
369370
```
370371

371372
> - **SP相关→[SPUtils.java][sp.java][Test][sp.test]**
@@ -471,7 +472,7 @@ getEntries : 获取压缩文件中的文件对象
471472
***
472473
Gradle:
473474
``` groovy
474-
compile 'com.blankj:utilcode:1.3.2'
475+
compile 'com.blankj:utilcode:1.3.3'
475476
```
476477

477478
### Proguard

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ showShortSnackbar
366366
showLongSnackbar
367367
showIndefiniteSnackbar
368368
addView
369+
dismissSnackbar
369370
```
370371

371372
> - **About SP→[SPUtils.java][sp.java][Test][sp.test]**
@@ -471,7 +472,7 @@ getEntries
471472
***
472473
Gradle:
473474
``` groovy
474-
compile 'com.blankj:utilcode:1.3.2'
475+
compile 'com.blankj:utilcode:1.3.3'
475476
```
476477

477478
### Proguard

app/src/main/java/com/blankj/androidutilcode/activities/SnackbarActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void onClick(View view) {
4343
SnackbarUtils.showShortSnackbar(getWindow().getDecorView(), "short snackbar", Color.WHITE, Color.BLUE);
4444
break;
4545
case R.id.btn_short_snackbar_with_action:
46-
SnackbarUtils.showLongSnackbar(getWindow().getDecorView(), "short snackbar", Color.WHITE, Color.BLUE,
46+
SnackbarUtils.showShortSnackbar(getWindow().getDecorView(), "short snackbar", Color.WHITE, Color.BLUE,
4747
"Short", Color.YELLOW, new View.OnClickListener() {
4848
@Override
4949
public void onClick(View v) {
@@ -89,6 +89,9 @@ public void onClick(View v) {
8989
});
9090
SnackbarUtils.addView(R.layout.snackbar_add, 0);
9191
break;
92+
case R.id.btn_cancel_snackbar:
93+
SnackbarUtils.dismissSnackbar();
94+
break;
9295
}
9396
}
9497
}

app/src/main/res/layout/activity_snackbar.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,14 @@
7575
android:text="@string/snackbar.add_view_with_action"
7676
/>
7777

78+
79+
<Button
80+
android:id="@+id/btn_cancel_snackbar"
81+
style="@style/BtnFont"
82+
android:layout_width="match_parent"
83+
android:layout_height="wrap_content"
84+
android:text="@string/snackbar.cancel"
85+
/>
86+
7887
</LinearLayout>
7988
</ScrollView>

app/src/main/res/values/string.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<string name="snackbar.show_indefinite_with_action">Show Indefinite Snackbar With Action</string>
6363
<string name="snackbar.add_view">Add View</string>
6464
<string name="snackbar.add_view_with_action">Add View With Action</string>
65+
<string name="snackbar.cancel">Cancel Snackbar</string>
6566

6667
<!--Toast相关-->
6768
<string name="toast.toggle_is_jump_when_more">Toggle Is Jump When More</string>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ allprojects {
2222

2323
task clean(type: Delete) {
2424
delete rootProject.buildDir
25-
}
25+
}

config.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ ext {
1010
buildToolsVersion : "24.0.3",
1111
minSdkVersion : 11,
1212
targetSdkVersion : 24,
13-
versionCode : 11,
14-
versionName : "1.3.2"
13+
versionCode : 12,
14+
versionName : "1.3.3"
1515
]
1616

1717
depsVersion = [
@@ -21,6 +21,7 @@ ext {
2121
deps = [
2222
// ------------- Android -------------
2323
supportV4 : "com.android.support:support-v4:${depsVersion.support}",
24+
supportV7 : "com.android.support:appcompat-v7:${depsVersion.support}",
2425
design : "com.android.support:design:${depsVersion.support}",
2526

2627

utilcode/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 11
99
targetSdkVersion 24
10-
versionCode 11
11-
versionName "1.3.2"
10+
versionCode 12
11+
versionName "1.3.3"
1212
}
1313
buildTypes {
1414
release {

utilcode/src/main/java/com/blankj/utilcode/utils/SnackbarUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private static void showSnackbar(View parent, CharSequence text, int duration, i
148148
}
149149

150150
/**
151-
* 为SnackBar添加布局
151+
* 为snackbar添加布局
152152
* <p>在show...Snackbar之后调用</p>
153153
*
154154
* @param layoutId 布局文件
@@ -164,4 +164,14 @@ public static void addView(int layoutId, int index) {
164164
params.gravity = Gravity.CENTER_VERTICAL;
165165
layout.addView(child, index, params);
166166
}
167+
168+
/**
169+
* 取消snackbar显示
170+
*/
171+
public static void dismissSnackbar() {
172+
if (snackbar != null) {
173+
snackbar.dismiss();
174+
snackbar = null;
175+
}
176+
}
167177
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2014 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
18+
<item android:state_focused="true" android:drawable="@drawable/snackbar_action_bg_focused"/>
19+
<item android:state_pressed="true" android:drawable="@drawable/snackbar_action_bg_focused"/>
20+
<item android:drawable="@android:color/transparent"/>
21+
</selector>
22+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2014 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<!-- Used as the canonical button shape. -->
18+
19+
<inset xmlns:android="http://schemas.android.com/apk/res/android"
20+
android:insetBottom="6dp"
21+
android:insetLeft="4dp"
22+
android:insetRight="4dp"
23+
android:insetTop="6dp">
24+
<shape android:shape="rectangle">
25+
<corners android:radius="2dp"/>
26+
<solid android:color="@android:color/white"/>
27+
<padding
28+
android:bottom="4dp"
29+
android:left="8dp"
30+
android:right="8dp"
31+
android:top="4dp"/>
32+
</shape>
33+
</inset>

utilcode/src/main/res/layout/design_layout_snackbar_include.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:paddingLeft="12dp"
2727
android:paddingRight="12dp"
2828
android:textSize="14sp"
29-
android:textColor="?android:textColorPrimary"
29+
android:textColor="#000000"
3030
android:maxLines="2"
3131
android:layout_gravity="center_vertical|left|start"
3232
android:ellipsize="end"
@@ -44,6 +44,6 @@
4444
android:paddingLeft="12dp"
4545
android:paddingRight="12dp"
4646
android:visibility="gone"
47-
android:textColor="?attr/colorAccent"
48-
style="?attr/borderlessButtonStyle"/>
47+
android:textColor="#000000"
48+
android:background="@drawable/snackbar_action_bg"/>
4949
</merge>

utilcode/src/main/res/values/strings.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

utilcode/src/main/res/values/values.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)