Skip to content

Commit 721ad57

Browse files
committed
Use charsequence instead of string in pickers/alerts
Signed-off-by: Kyle Corry <kylecorry31@gmail.com>
1 parent d2b41b5 commit 721ad57

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

alerts/src/main/java/com/kylecorry/andromeda/alerts/Alerts.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object Alerts {
5656

5757
fun loading(
5858
context: Context,
59-
title: String
59+
title: CharSequence
6060
): AlertDialog {
6161
val view = FrameLayout(context)
6262
val params = FrameLayout.LayoutParams(
@@ -164,7 +164,7 @@ object Alerts {
164164

165165
fun image(
166166
context: Context,
167-
title: String,
167+
title: CharSequence,
168168
@DrawableRes image: Int
169169
): AlertDialog {
170170
val view = LinearLayout(context)
@@ -191,9 +191,9 @@ object Alerts {
191191
fun snackbar(
192192
fragment: Fragment,
193193
anchorView: View,
194-
text: String,
194+
text: CharSequence,
195195
duration: Int = Snackbar.LENGTH_SHORT,
196-
action: String? = null,
196+
action: CharSequence? = null,
197197
onAction: () -> Unit = {}
198198
): Snackbar {
199199
return Snackbar.make(fragment.requireView(), text, duration).also {
@@ -210,9 +210,9 @@ object Alerts {
210210
fun snackbar(
211211
fragment: Fragment,
212212
@IdRes anchorView: Int,
213-
text: String,
213+
text: CharSequence,
214214
duration: Int = Snackbar.LENGTH_SHORT,
215-
action: String? = null,
215+
action: CharSequence? = null,
216216
onAction: () -> Unit = {}
217217
): Snackbar {
218218
return Snackbar.make(fragment.requireView(), text, duration).also {
@@ -226,7 +226,7 @@ object Alerts {
226226
}
227227
}
228228

229-
inline fun <T> withLoading(context: Context, title: String, action: () -> T): T {
229+
inline fun <T> withLoading(context: Context, title: CharSequence, action: () -> T): T {
230230
val loadingAlert = loading(context, title)
231231
try {
232232
return action()

pickers/src/main/java/com/kylecorry/andromeda/pickers/CoroutinePickers.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ object CoroutinePickers {
7676
}
7777
}
7878

79-
suspend fun menu(anchorView: View, items: List<String?>) = suspendCoroutine<Int> { cont ->
79+
suspend fun menu(anchorView: View, items: List<CharSequence?>) = suspendCoroutine<Int> { cont ->
8080
Pickers.menu(anchorView, items) {
8181
cont.resume(it)
8282
true
@@ -112,7 +112,7 @@ object CoroutinePickers {
112112
suspend fun item(
113113
context: Context,
114114
title: CharSequence,
115-
items: List<String>,
115+
items: List<CharSequence>,
116116
defaultSelectedIndex: Int = -1,
117117
okText: CharSequence? = context.getString(android.R.string.ok),
118118
cancelText: CharSequence? = context.getString(android.R.string.cancel)
@@ -125,7 +125,7 @@ object CoroutinePickers {
125125
suspend fun items(
126126
context: Context,
127127
title: CharSequence,
128-
items: List<String>,
128+
items: List<CharSequence>,
129129
defaultSelectedIndices: List<Int> = listOf(),
130130
okText: CharSequence? = context.getString(android.R.string.ok),
131131
cancelText: CharSequence? = context.getString(android.R.string.cancel)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package com.kylecorry.andromeda.pickers
22

3-
data class MenuItem(val name: String, val action: () -> Boolean)
3+
data class MenuItem(val name: CharSequence, val action: () -> Boolean)

pickers/src/main/java/com/kylecorry/andromeda/pickers/Pickers.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ object Pickers {
102102
popup.show()
103103
}
104104

105-
fun menu(anchorView: View, items: List<String?>, onSelection: (selectedIdx: Int) -> Boolean) {
105+
fun menu(anchorView: View, items: List<CharSequence?>, onSelection: (selectedIdx: Int) -> Boolean) {
106106
val popup = PopupMenu(anchorView.context, anchorView)
107107
for (i in items.indices) {
108108
if (items[i] == null) {
@@ -192,7 +192,7 @@ object Pickers {
192192
fun item(
193193
context: Context,
194194
title: CharSequence,
195-
items: List<String>,
195+
items: List<CharSequence>,
196196
defaultSelectedIndex: Int = -1,
197197
okText: CharSequence? = context.getString(android.R.string.ok),
198198
cancelText: CharSequence? = context.getString(android.R.string.cancel),
@@ -228,7 +228,7 @@ object Pickers {
228228
fun items(
229229
context: Context,
230230
title: CharSequence,
231-
items: List<String>,
231+
items: List<CharSequence>,
232232
defaultSelectedIndices: List<Int> = listOf(),
233233
okText: CharSequence? = context.getString(android.R.string.ok),
234234
cancelText: CharSequence? = context.getString(android.R.string.cancel),

0 commit comments

Comments
 (0)