Skip to content

Commit e4da60f

Browse files
committed
see 03/03 log
1 parent 837fdc8 commit e4da60f

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

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

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* author: Blankj
2424
* blog : http://blankj.com
2525
* time : 2016/10/16
26-
* desc : Snackbar 相关工具类
26+
* desc : utils about snackbar
2727
* </pre>
2828
*/
2929
public final class SnackbarUtils {
@@ -45,7 +45,7 @@ public final class SnackbarUtils {
4545

4646
private static WeakReference<Snackbar> sReference;
4747

48-
private View parent;
48+
private View view;
4949
private CharSequence message;
5050
private int messageColor;
5151
private int bgColor;
@@ -58,7 +58,7 @@ public final class SnackbarUtils {
5858

5959
private SnackbarUtils(final View parent) {
6060
setDefault();
61-
this.parent = parent;
61+
this.view = parent;
6262
}
6363

6464
private void setDefault() {
@@ -73,94 +73,94 @@ private void setDefault() {
7373
}
7474

7575
/**
76-
* 设置 snackbar 依赖 view
76+
* Set the view to find a parent from.
7777
*
78-
* @param parent 依赖 view
79-
* @return {@link SnackbarUtils}
78+
* @param view The view to find a parent from.
79+
* @return the single {@link SnackbarUtils} instance
8080
*/
81-
public static SnackbarUtils with(@NonNull final View parent) {
82-
return new SnackbarUtils(parent);
81+
public static SnackbarUtils with(@NonNull final View view) {
82+
return new SnackbarUtils(view);
8383
}
8484

8585
/**
86-
* 设置消息
86+
* Set the message.
8787
*
88-
* @param msg 消息
89-
* @return {@link SnackbarUtils}
88+
* @param msg The message.
89+
* @return the single {@link SnackbarUtils} instance
9090
*/
9191
public SnackbarUtils setMessage(@NonNull final CharSequence msg) {
9292
this.message = msg;
9393
return this;
9494
}
9595

9696
/**
97-
* 设置消息颜色
97+
* Set the color of message.
9898
*
99-
* @param color 颜色
100-
* @return {@link SnackbarUtils}
99+
* @param color The color of message.
100+
* @return the single {@link SnackbarUtils} instance
101101
*/
102102
public SnackbarUtils setMessageColor(@ColorInt final int color) {
103103
this.messageColor = color;
104104
return this;
105105
}
106106

107107
/**
108-
* 设置背景色
108+
* Set the color of background.
109109
*
110-
* @param color 背景色
111-
* @return {@link SnackbarUtils}
110+
* @param color The color of background.
111+
* @return the single {@link SnackbarUtils} instance
112112
*/
113113
public SnackbarUtils setBgColor(@ColorInt final int color) {
114114
this.bgColor = color;
115115
return this;
116116
}
117117

118118
/**
119-
* 设置背景资源
119+
* Set the resource of background.
120120
*
121-
* @param bgResource 背景资源
122-
* @return {@link SnackbarUtils}
121+
* @param bgResource The resource of background.
122+
* @return the single {@link SnackbarUtils} instance
123123
*/
124124
public SnackbarUtils setBgResource(@DrawableRes final int bgResource) {
125125
this.bgResource = bgResource;
126126
return this;
127127
}
128128

129129
/**
130-
* 设置显示时长
130+
* Set the duration.
131131
*
132-
* @param duration 时长
132+
* @param duration The duration.
133133
* <ul>
134-
* <li>{@link Duration#LENGTH_INDEFINITE}永久</li>
135-
* <li>{@link Duration#LENGTH_SHORT}短时</li>
136-
* <li>{@link Duration#LENGTH_LONG}长时</li>
134+
* <li>{@link Duration#LENGTH_INDEFINITE}</li>
135+
* <li>{@link Duration#LENGTH_SHORT }</li>
136+
* <li>{@link Duration#LENGTH_LONG }</li>
137137
* </ul>
138-
* @return {@link SnackbarUtils}
138+
* @return the single {@link SnackbarUtils} instance
139139
*/
140140
public SnackbarUtils setDuration(@Duration final int duration) {
141141
this.duration = duration;
142142
return this;
143143
}
144144

145145
/**
146-
* 设置行为
146+
* Set the action.
147147
*
148-
* @param text 文本
149-
* @param listener 事件
150-
* @return {@link SnackbarUtils}
148+
* @param text The text.
149+
* @param listener The click listener.
150+
* @return the single {@link SnackbarUtils} instance
151151
*/
152152
public SnackbarUtils setAction(@NonNull final CharSequence text,
153153
@NonNull final View.OnClickListener listener) {
154154
return setAction(text, COLOR_DEFAULT, listener);
155155
}
156156

157157
/**
158-
* 设置行为
158+
* Set the action.
159159
*
160-
* @param text 文本
161-
* @param color 文本颜色
162-
* @param listener 事件
163-
* @return {@link SnackbarUtils}
160+
* @param text The text.
161+
* @param color The color of text.
162+
* @param listener The click listener.
163+
* @return the single {@link SnackbarUtils} instance
164164
*/
165165

166166
public SnackbarUtils setAction(@NonNull final CharSequence text,
@@ -173,20 +173,20 @@ public SnackbarUtils setAction(@NonNull final CharSequence text,
173173
}
174174

175175
/**
176-
* 设置底边距
176+
* Set the bottom margin.
177177
*
178-
* @param bottomMargin 底边距
178+
* @param bottomMargin The size of bottom margin, in pixel.
179179
*/
180180
public SnackbarUtils setBottomMargin(@IntRange(from = 1) final int bottomMargin) {
181181
this.bottomMargin = bottomMargin;
182182
return this;
183183
}
184184

185185
/**
186-
* 显示 snackbar
186+
* Show the snackbar.
187187
*/
188188
public void show() {
189-
final View view = parent;
189+
final View view = this.view;
190190
if (view == null) return;
191191
if (messageColor != COLOR_DEFAULT) {
192192
SpannableString spannableString = new SpannableString(message);
@@ -220,7 +220,7 @@ public void show() {
220220
}
221221

222222
/**
223-
* 显示预设成功的 snackbar
223+
* Show the snackbar with success style.
224224
*/
225225
public void showSuccess() {
226226
bgColor = COLOR_SUCCESS;
@@ -230,7 +230,7 @@ public void showSuccess() {
230230
}
231231

232232
/**
233-
* 显示预设警告的 snackbar
233+
* Show the snackbar with warning style.
234234
*/
235235
public void showWarning() {
236236
bgColor = COLOR_WARNING;
@@ -240,7 +240,7 @@ public void showWarning() {
240240
}
241241

242242
/**
243-
* 显示预设错误的 snackbar
243+
* Show the snackbar with error style.
244244
*/
245245
public void showError() {
246246
bgColor = COLOR_ERROR;
@@ -250,7 +250,7 @@ public void showError() {
250250
}
251251

252252
/**
253-
* 消失 snackbar
253+
* Dismiss the snackbar.
254254
*/
255255
public static void dismiss() {
256256
if (sReference != null && sReference.get() != null) {
@@ -260,9 +260,9 @@ public static void dismiss() {
260260
}
261261

262262
/**
263-
* 获取 snackbar 视图
263+
* Return the view of snackbar.
264264
*
265-
* @return snackbar 视图
265+
* @return the view of snackbar
266266
*/
267267
public static View getView() {
268268
Snackbar snackbar = sReference.get();
@@ -271,11 +271,11 @@ public static View getView() {
271271
}
272272

273273
/**
274-
* 添加 snackbar 视图
275-
* <p>{@link #show()}之后调用</p>
274+
* Add view to the snackbar.
275+
* <p>call it after {@link #show()}</p>
276276
*
277-
* @param layoutId 布局文件
278-
* @param params 布局参数
277+
* @param layoutId The id of layout.
278+
* @param params The params.
279279
*/
280280
public static void addView(@LayoutRes final int layoutId,
281281
@NonNull final ViewGroup.LayoutParams params) {
@@ -289,11 +289,11 @@ public static void addView(@LayoutRes final int layoutId,
289289
}
290290

291291
/**
292-
* 添加 snackbar 视图
293-
* <p>{@link #show()}之后调用</p>
292+
* Add view to the snackbar.
293+
* <p>call it after {@link #show()}</p>
294294
*
295-
* @param child 要添加的 view
296-
* @param params 布局参数
295+
* @param child The child view.
296+
* @param params The params.
297297
*/
298298
public static void addView(@NonNull final View child,
299299
@NonNull final ViewGroup.LayoutParams params) {

0 commit comments

Comments
 (0)