mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add support for passing UiText to showSnackbar
This commit is contained in:
parent
c861cf9e42
commit
0319557683
2 changed files with 20 additions and 6 deletions
|
@ -1230,9 +1230,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
|
||||||
this@MainActivity,
|
this@MainActivity,
|
||||||
R.string.jsdelivr_enabled,
|
R.string.jsdelivr_enabled,
|
||||||
Snackbar.LENGTH_LONG,
|
Snackbar.LENGTH_LONG,
|
||||||
getString(R.string.revert)) {
|
R.string.revert
|
||||||
setKey(getString(R.string.jsdelivr_proxy_key), false)
|
) { setKey(getString(R.string.jsdelivr_proxy_key), false) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.google.android.material.snackbar.Snackbar
|
||||||
import com.lagradost.api.Log
|
import com.lagradost.api.Log
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
import com.lagradost.cloudstream3.ui.result.UiText
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||||
|
|
||||||
object SnackbarHelper {
|
object SnackbarHelper {
|
||||||
|
@ -18,13 +19,27 @@ object SnackbarHelper {
|
||||||
@MainThread
|
@MainThread
|
||||||
fun showSnackbar(
|
fun showSnackbar(
|
||||||
act: Activity?,
|
act: Activity?,
|
||||||
@StringRes message: Int,
|
message: UiText,
|
||||||
duration: Int = Snackbar.LENGTH_SHORT,
|
duration: Int = Snackbar.LENGTH_SHORT,
|
||||||
actionText: String? = null,
|
actionText: UiText? = null,
|
||||||
actionCallback: (() -> Unit)? = null
|
actionCallback: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
if (act == null) return
|
if (act == null) return
|
||||||
showSnackbar(act, act.getString(message), duration, actionText, actionCallback)
|
showSnackbar(act, message.asString(act), duration,
|
||||||
|
actionText?.asString(act), actionCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainThread
|
||||||
|
fun showSnackbar(
|
||||||
|
act: Activity?,
|
||||||
|
@StringRes message: Int,
|
||||||
|
duration: Int = Snackbar.LENGTH_SHORT,
|
||||||
|
@StringRes actionText: Int? = null,
|
||||||
|
actionCallback: (() -> Unit)? = null
|
||||||
|
) {
|
||||||
|
if (act == null) return
|
||||||
|
showSnackbar(act, act.getString(message), duration,
|
||||||
|
actionText?.let { act.getString(it) }, actionCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue