Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 4671683

Browse files
hanggrian4u7
authored andcommitted
Snackbar View receiver and annotate string resources (#643)
1 parent c4c15da commit 4671683

File tree

1 file changed

+151
-24
lines changed

1 file changed

+151
-24
lines changed

anko/library/static/design/src/main/java/Snackbar.kt

Lines changed: 151 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
@file:Suppress("NOTHING_TO_INLINE")
1919
package org.jetbrains.anko.design
2020

21+
import android.support.annotation.StringRes
2122
import android.support.design.widget.Snackbar
2223
import android.view.View
2324

@@ -26,6 +27,7 @@ import android.view.View
2627
*
2728
* @param message the message text resource.
2829
*/
30+
@Deprecated("Use 'View.snackbar(Int)' instead.", ReplaceWith("view.snackbar(message)"))
2931
inline fun snackbar(view: View, message: Int) = Snackbar
3032
.make(view, message, Snackbar.LENGTH_SHORT)
3133
.apply { show() }
@@ -35,6 +37,7 @@ inline fun snackbar(view: View, message: Int) = Snackbar
3537
*
3638
* @param message the message text resource.
3739
*/
40+
@Deprecated("Use 'View.longSnackbar(Int)' instead.", ReplaceWith("view.longSnackbar(message)"))
3841
inline fun longSnackbar(view: View, message: Int) = Snackbar
3942
.make(view, message, Snackbar.LENGTH_LONG)
4043
.apply { show() }
@@ -44,6 +47,7 @@ inline fun longSnackbar(view: View, message: Int) = Snackbar
4447
*
4548
* @param message the message text resource.
4649
*/
50+
@Deprecated("Use 'View.indefiniteSnackbar(Int)' instead.", ReplaceWith("view.indefiniteSnackbar(message)"))
4751
inline fun indefiniteSnackbar(view: View, message: Int) = Snackbar
4852
.make(view, message, Snackbar.LENGTH_INDEFINITE)
4953
.apply { show() }
@@ -53,6 +57,7 @@ inline fun indefiniteSnackbar(view: View, message: Int) = Snackbar
5357
*
5458
* @param message the message text.
5559
*/
60+
@Deprecated("Use 'View.snackbar(String)' instead.", ReplaceWith("view.snackbar(message)"))
5661
inline fun snackbar(view: View, message: String) = Snackbar
5762
.make(view, message, Snackbar.LENGTH_SHORT)
5863
.apply { show() }
@@ -62,6 +67,7 @@ inline fun snackbar(view: View, message: String) = Snackbar
6267
*
6368
* @param message the message text.
6469
*/
70+
@Deprecated("Use 'View.longSnackbar(String)' instead.", ReplaceWith("view.longSnackbar(message)"))
6571
inline fun longSnackbar(view: View, message: String) = Snackbar
6672
.make(view, message, Snackbar.LENGTH_LONG)
6773
.apply { show() }
@@ -71,6 +77,7 @@ inline fun longSnackbar(view: View, message: String) = Snackbar
7177
*
7278
* @param message the message text.
7379
*/
80+
@Deprecated("Use 'View.indefiniteSnackbar(String)' instead.", ReplaceWith("view.indefiniteSnackbar(message)"))
7481
inline fun indefiniteSnackbar(view: View, message: String) = Snackbar
7582
.make(view, message, Snackbar.LENGTH_INDEFINITE)
7683
.apply { show() }
@@ -80,69 +87,189 @@ inline fun indefiniteSnackbar(view: View, message: String) = Snackbar
8087
*
8188
* @param message the message text resource.
8289
*/
90+
@Deprecated("Use 'View.snackbar(Int, Int, (View) -> Unit)' instead.", ReplaceWith("view.snackbar(message, actionText, action)"))
8391
inline fun snackbar(view: View, message: Int, actionText: Int, noinline action: (View) -> Unit) = Snackbar
8492
.make(view, message, Snackbar.LENGTH_SHORT)
85-
.apply {
86-
setAction(actionText, action)
87-
show()
88-
}
93+
.setAction(actionText, action)
94+
.apply { show() }
8995

9096
/**
9197
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
9298
*
9399
* @param message the message text resource.
94100
*/
101+
@Deprecated("Use 'View.longSnackbar(Int, Int, (View) -> Unit)' instead.", ReplaceWith("view.longSnackbar(message, actionText, action)"))
95102
inline fun longSnackbar(view: View, message: Int, actionText: Int, noinline action: (View) -> Unit) = Snackbar
96103
.make(view, message, Snackbar.LENGTH_LONG)
97-
.apply {
98-
setAction(actionText, action)
99-
show()
100-
}
104+
.setAction(actionText, action)
105+
.apply { show() }
101106

102107
/**
103108
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
104109
*
105110
* @param message the message text resource.
106111
*/
112+
@Deprecated("Use 'View.indefiniteSnackbar(Int, Int, (View) -> Unit)' instead.", ReplaceWith("view.indefiniteSnackbar(message, actionText, action)"))
107113
inline fun indefiniteSnackbar(view: View, message: Int, actionText: Int, noinline action: (View) -> Unit) = Snackbar
108114
.make(view, message, Snackbar.LENGTH_INDEFINITE)
109-
.apply {
110-
setAction(actionText, action)
111-
show()
112-
}
115+
.setAction(actionText, action)
116+
.apply { show() }
113117

114118
/**
115119
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
116120
*
117121
* @param message the message text.
118122
*/
123+
@Deprecated("Use 'View.snackbar(String, String, (View) -> Unit)' instead.", ReplaceWith("view.snackbar(message, actionText, action)"))
119124
inline fun snackbar(view: View, message: String, actionText: String, noinline action: (View) -> Unit) = Snackbar
120125
.make(view, message, Snackbar.LENGTH_SHORT)
121-
.apply {
122-
setAction(actionText, action)
123-
show()
124-
}
126+
.setAction(actionText, action)
127+
.apply { show() }
125128

126129
/**
127130
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
128131
*
129132
* @param message the message text.
130133
*/
134+
@Deprecated("Use 'View.longSnackbar(String, String, (View) -> Unit)' instead.", ReplaceWith("view.longSnackbar(message, actionText, action)"))
131135
inline fun longSnackbar(view: View, message: String, actionText: String, noinline action: (View) -> Unit) = Snackbar
132136
.make(view, message, Snackbar.LENGTH_LONG)
133-
.apply {
134-
setAction(actionText, action)
135-
show()
136-
}
137+
.setAction(actionText, action)
138+
.apply { show() }
137139

138140
/**
139141
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
140142
*
141143
* @param message the message text.
142144
*/
145+
@Deprecated("Use 'View.indefiniteSnackbar(String, String, (View) -> Unit)' instead.", ReplaceWith("view.indefiniteSnackbar(message, actionText, action)"))
143146
inline fun indefiniteSnackbar(view: View, message: String, actionText: String, noinline action: (View) -> Unit) = Snackbar
144147
.make(view, message, Snackbar.LENGTH_INDEFINITE)
145-
.apply {
146-
setAction(actionText, action)
147-
show()
148-
}
148+
.setAction(actionText, action)
149+
.apply { show() }
150+
151+
/**
152+
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
153+
*
154+
* @param message the message text resource.
155+
*/
156+
@JvmName("snackbar2")
157+
inline fun View.snackbar(@StringRes message: Int) = Snackbar
158+
.make(this, message, Snackbar.LENGTH_SHORT)
159+
.apply { show() }
160+
161+
/**
162+
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
163+
*
164+
* @param message the message text resource.
165+
*/
166+
@JvmName("longSnackbar2")
167+
inline fun View.longSnackbar(@StringRes message: Int) = Snackbar
168+
.make(this, message, Snackbar.LENGTH_LONG)
169+
.apply { show() }
170+
171+
/**
172+
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
173+
*
174+
* @param message the message text resource.
175+
*/
176+
@JvmName("indefiniteSnackbar2")
177+
inline fun View.indefiniteSnackbar(@StringRes message: Int) = Snackbar
178+
.make(this, message, Snackbar.LENGTH_INDEFINITE)
179+
.apply { show() }
180+
181+
/**
182+
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
183+
*
184+
* @param message the message text.
185+
*/
186+
@JvmName("snackbar2")
187+
inline fun View.snackbar(message: String) = Snackbar
188+
.make(this, message, Snackbar.LENGTH_SHORT)
189+
.apply { show() }
190+
191+
/**
192+
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
193+
*
194+
* @param message the message text.
195+
*/
196+
@JvmName("longSnackbar2")
197+
inline fun View.longSnackbar(message: String) = Snackbar
198+
.make(this, message, Snackbar.LENGTH_LONG)
199+
.apply { show() }
200+
201+
/**
202+
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
203+
*
204+
* @param message the message text.
205+
*/
206+
@JvmName("indefiniteSnackbar2")
207+
inline fun View.indefiniteSnackbar(message: String) = Snackbar
208+
.make(this, message, Snackbar.LENGTH_INDEFINITE)
209+
.apply { show() }
210+
211+
/**
212+
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
213+
*
214+
* @param message the message text resource.
215+
*/
216+
@JvmName("snackbar2")
217+
inline fun View.snackbar(message: Int, @StringRes actionText: Int, noinline action: (View) -> Unit) = Snackbar
218+
.make(this, message, Snackbar.LENGTH_SHORT)
219+
.setAction(actionText, action)
220+
.apply { show() }
221+
222+
/**
223+
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
224+
*
225+
* @param message the message text resource.
226+
*/
227+
@JvmName("longSnackbar2")
228+
inline fun View.longSnackbar(@StringRes message: Int, @StringRes actionText: Int, noinline action: (View) -> Unit) = Snackbar
229+
.make(this, message, Snackbar.LENGTH_LONG)
230+
.setAction(actionText, action)
231+
.apply { show() }
232+
233+
/**
234+
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
235+
*
236+
* @param message the message text resource.
237+
*/
238+
@JvmName("indefiniteSnackbar2")
239+
inline fun View.indefiniteSnackbar(@StringRes message: Int, @StringRes actionText: Int, noinline action: (View) -> Unit) = Snackbar
240+
.make(this, message, Snackbar.LENGTH_INDEFINITE)
241+
.setAction(actionText, action)
242+
.apply { show() }
243+
244+
/**
245+
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
246+
*
247+
* @param message the message text.
248+
*/
249+
@JvmName("snackbar2")
250+
inline fun View.snackbar(message: String, actionText: String, noinline action: (View) -> Unit) = Snackbar
251+
.make(this, message, Snackbar.LENGTH_SHORT)
252+
.setAction(actionText, action)
253+
.apply { show() }
254+
255+
/**
256+
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
257+
*
258+
* @param message the message text.
259+
*/
260+
@JvmName("longSnackbar2")
261+
inline fun View.longSnackbar(message: String, actionText: String, noinline action: (View) -> Unit) = Snackbar
262+
.make(this, message, Snackbar.LENGTH_LONG)
263+
.setAction(actionText, action)
264+
.apply { show() }
265+
266+
/**
267+
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
268+
*
269+
* @param message the message text.
270+
*/
271+
@JvmName("indefiniteSnackbar2")
272+
inline fun View.indefiniteSnackbar(message: String, actionText: String, noinline action: (View) -> Unit) = Snackbar
273+
.make(this, message, Snackbar.LENGTH_INDEFINITE)
274+
.setAction(actionText, action)
275+
.apply { show() }

0 commit comments

Comments
 (0)