Skip to content

Commit aa4640c

Browse files
authored
Merge pull request #5 from nasduck/develop
Develop
2 parents 431ac30 + 0cfed2f commit aa4640c

File tree

70 files changed

+473
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+473
-184
lines changed

README-CN.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77
LesserPandaToast 提供最简单的方法来调用各类简单的 progressHud 或 toast, 同时提供自定义方法来定义不同的样式. 用户可以手动控制消失或者自动延时消失. 如果你对 Dialog 感兴趣. 欢迎移步另外一个配套的开源项目 [GiantPandaToast](https://github.com/nasduck/GiantPandaDialog). 大熊猫和小熊猫总是搭配使用 :D
88

9+
## 目录
10+
11+
* [依赖](#依赖)
12+
* [使用方式](#使用方式)
13+
* [显示 Toast](#显示-toast)
14+
* [隐藏 Toast](#隐藏-toast)
15+
* [自定义 Toast](#自定义-toast)
16+
* [贡献](#贡献)
17+
* [License](#license)
18+
19+
920
## 依赖
1021

1122
步骤一:在项目的build.gradle中添加jitpack
@@ -38,7 +49,8 @@ dependencies {
3849
4. 警告
3950
5. 正在加载
4051

41-
### 调用文字Toast
52+
53+
### 显示 Toast
4254

4355
```java
4456
// 纯文字
@@ -61,7 +73,7 @@ DuckToast.showLoading(this); // 只有图标,不含文字
6173
DuckToast.showLoading(this, "loading"); // 包含图标和文字
6274
```
6375

64-
// todo 图片
76+
<img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/text%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/success%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/failure%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/warning%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/loading%20toast.gif?raw=true" height="300" >
6577

6678
> 在用户调用 showXXXX 方法后, Toast 将一直保持显示状态直到用户指定以何种方式消失
6779
@@ -77,7 +89,7 @@ DuckToast.dismiss(); // 立即消失
7789
DuckToast.dismiss(long delay); // 延迟 delay 时间后消失(毫秒)
7890
```
7991

80-
### 自定义
92+
### 自定义 Toast
8193

8294
自定义 Toast, 建议进行进一步封装简化调用:
8395

@@ -87,8 +99,13 @@ ToastBuilder.getInstance(this)
8799
.setAnimation(Integer animation) // 设置图片的动画
88100
.setBgColor(Integer bgColor) // 设置背景颜色
89101
.setCornerRadius(Integer cornerRadius) // 设置背景圆角
102+
.setPaddingTop(Integer paddingTop) // 设置顶部padding
103+
.setPaddingBottom(Integer paddingBottom) // 设置底部padding
104+
.setPaddingLeft(Integer paddingLeft) // 设置左边padding
105+
.setPaddingRight(Integer paddingRight) // 设置右边padding
90106
.setPaddingHorizontal(Integer paddingHorizontal) // 设置水平padding
91107
.setPaddingVertical(Integer paddingVertical) // 设置竖直padding
108+
.setPadding(Integer padding) // 设置padding
92109
.setText(String text) // 设置文字,如未设置,则文字不显示,文字相关设置不生效
93110
.setTextColor(Integer textColor) // 设置文字颜色
94111
.setTextSize(Integer textSize) // 设置文字大小

README.md

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,141 @@
1-
# DuckAndroidToast
1+
![banner](https://github.com/nasduck/LesserPandaToast/blob/develop/art/%E5%B0%8F%E7%86%8A%E7%8C%ABbanner.png?raw=true)
2+
3+
[![API](https://img.shields.io/badge/LesserPandaToast-v1.0.1-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14)&ensp;
4+
[![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14)&ensp;
5+
[![API](https://img.shields.io/badge/License-Apche2.0-brightgreen.svg?style=flat)](https://github.com/nasduck/LesserPandaToast/blob/master/LICENSE)
6+
7+
LesserPandaToast provides the simplest solution to call different types of progresshuds or toasts and dismiss them in an indicated delay. Users could also customize their own styles.
8+
9+
If you are also interested at Dialog. Please take a look at another library [GiantPandaDialog](https://github.com/nasduck/GiantPandaDialog). From these libraries' names,
10+
you will find they are used together. Please enjoy them :D
11+
12+
## Content
13+
14+
* [Setup](#setup)
15+
* [Usage](#usage)
16+
* [Show Toast](#show-toast)
17+
* [Dismiss Toast](#dismiss-toast)
18+
* [Custom Toast](#custom-toast)
19+
* [Contributer](#contributer)
20+
* [License](#license)
21+
22+
## Setup
23+
24+
### **</u>[中文文档](https://github.com/nasduck/LesserPandaToast/blob/master/README-CN.md)</u>**
25+
26+
Adding jitpack repository in your project's `build.gradle` file:
27+
28+
```
29+
allprojects {
30+
repositories {
31+
...
32+
maven { url 'https://www.jitpack.io' }
33+
}
34+
}
35+
```
36+
37+
Adding the following dependency to app `build.gradle` file:
38+
39+
40+
```
41+
dependencies {
42+
implementation 'com.github.nasduck:LesserPandaToast:1.0.1'
43+
}
44+
```
45+
46+
## Usage
47+
48+
5 types of Toast are provided by default:
49+
50+
1. Text only
51+
2. Success
52+
3. Failure
53+
4. Warning
54+
5. Loading
55+
56+
### Show Toast
57+
58+
```java
59+
// Text only
60+
DuckToast.show(this, "Toast Default");
61+
62+
// Success
63+
DuckToast.showSuccess(this); // Image only
64+
DuckToast.showSuccess(this, "success"); // Image and text
65+
66+
// Failure
67+
DuckToast.showFailure(this); // Image only
68+
DuckToast.showFailure(this, "failure"); // Image and text
69+
70+
// Warning
71+
DuckToast.showWarning(this); // Image only
72+
DuckToast.showWarning(this, "warning"); // Image and text
73+
74+
// Loading
75+
DuckToast.showLoading(this); // Image only
76+
DuckToast.showLoading(this, "loading"); // Image and text
77+
```
78+
79+
<img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/text%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/success%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/failure%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/warning%20toast.png?raw=true" height="300" > <img src="https://github.com/nasduck/LesserPandaToast/blob/develop/art/loading%20toast.gif?raw=true" height="300" >
80+
81+
> After `showXXXX` is called, Toast will keep shown until user specifies how it will be dismissed.
82+
83+
### Dismiss Toast
84+
85+
Two dismiss solution:
86+
87+
1. Dismiss immediately
88+
2. Dismiss with delay
89+
90+
```java
91+
DuckToast.dismiss(); // Dismiss immediately
92+
DuckToast.dismiss(long delay); // Dismiss with delay (ms)
93+
```
94+
95+
### Custom Toast
96+
97+
Customize Toast:
98+
99+
```java
100+
ToastBuilder.getInstance(this)
101+
.setImage(Integer image) // Image. If not set, other related image settings won't be enabled
102+
.setAnimation(Integer animation) // Image Animation
103+
.setBgColor(Integer bgColor) // Background color. #B2000000 by default
104+
.setCornerRadius(Integer cornerRadius) // Background corner radius. 6dp by default
105+
.setPaddingTop(Integer paddingTop) // 12dp by default
106+
.setPaddingBottom(Integer paddingBottom) // 12dp by default
107+
.setPaddingLeft(Integer paddingLeft) // 24dp by default
108+
.setPaddingRight(Integer paddingRight) // 24dp by default
109+
.setPaddingHorizontal(Integer paddingHorizontal)
110+
.setPaddingVertical(Integer paddingVertical)
111+
.setPadding(Integer padding)
112+
.setText(String text) // Text. If not set, other related text settings won't be enabled
113+
.setTextColor(Integer textColor) // white by default
114+
.setTextSize(Integer textSize) // 14sp by default
115+
.show();
116+
117+
ToastBuilder.dismiss(1500); // dismiss in 1.5s
118+
```
119+
120+
## Contributer
121+
122+
* [Lihao Zhou](https://github.com/redrain39)
123+
* [Chuan DONG](https://github.com/DONGChuan)
124+
* [Si Cheng]([email protected])(Art Designer)
125+
126+
## LICENSE
127+
```
128+
Copyright (2019) Chuan Dong, Lihao Zhou
129+
130+
Licensed under the Apache License, Version 2.0 (the "License");
131+
you may not use this file except in compliance with the License.
132+
You may obtain a copy of the License at
133+
134+
http://www.apache.org/licenses/LICENSE-2.0
135+
136+
Unless required by applicable law or agreed to in writing, software
137+
distributed under the License is distributed on an "AS IS" BASIS,
138+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139+
See the License for the specific language governing permissions and
140+
limitations under the License.
141+
```

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
android:allowBackup="true"
77
android:icon="@mipmap/ic_launcher"
88
android:label="@string/app_name"
9-
android:roundIcon="@mipmap/ic_launcher_round"
109
android:supportsRtl="true"
1110
android:theme="@style/AppTheme">
1211
<activity android:name=".ToastActivity">

app/src/main/java/com/nasduck/duckandroidtoast/ToastActivity.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import android.os.Bundle;
55
import android.view.View;
66

7-
import com.nasduck.lib.DuckToast;
8-
import com.nasduck.lib.builder.impl.ToastBuilder;
7+
import com.zoopark.toast.LesserPandaToast;
8+
import com.zoopark.toast.builder.impl.ToastBuilder;
99

1010
public class ToastActivity extends AppCompatActivity {
1111

@@ -16,43 +16,43 @@ protected void onCreate(Bundle savedInstanceState) {
1616
}
1717

1818
public void onDefaultClick(View view) {
19-
DuckToast.show(this, "Toast Default");
19+
LesserPandaToast.show(this, String.valueOf(getResources().getText(R.string.default_toast)));
2020
}
2121

2222
public void onSuccessClick(View view) {
23-
DuckToast.showSuccess(this);
23+
LesserPandaToast.showSuccess(this);
2424
}
2525

2626
public void onFailureClick(View view) {
27-
DuckToast.showFailure(this);
27+
LesserPandaToast.showFailure(this);
2828
}
2929

3030
public void onWarningClick(View view) {
31-
DuckToast.showWarning(this);
31+
LesserPandaToast.showWarning(this);
3232
}
3333

3434
public void onLoadingClick(View view) {
35-
DuckToast.showLoading(this);
35+
LesserPandaToast.showLoading(this);
3636
}
3737

3838
public void onSuccessTextClick(View view) {
39-
DuckToast.showSuccess(this, "success");
39+
LesserPandaToast.showSuccess(this, String.valueOf(getResources().getText(R.string.success)));
4040
}
4141

4242
public void onFailureTextClick(View view) {
43-
DuckToast.showFailure(this, "failure");
43+
LesserPandaToast.showFailure(this, String.valueOf(getResources().getText(R.string.failure)));
4444
}
4545

4646
public void onWarningTextClick(View view) {
47-
DuckToast.showWarning(this, "warning");
47+
LesserPandaToast.showWarning(this, String.valueOf(getResources().getText(R.string.warning)));
4848
}
4949

5050
public void onLoadingTextClick(View view) {
51-
DuckToast.showLoading(this, "loading");
51+
LesserPandaToast.showLoading(this, String.valueOf(getResources().getText(R.string.loading)));
5252
}
5353

5454
public void onHideToastClick(View view) {
55-
DuckToast.dismiss();
55+
LesserPandaToast.dismiss();
5656
}
5757

5858
public void onToastCustomClick(View view) {

0 commit comments

Comments
 (0)