diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-18 20:25:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-18 20:25:41 -0700 |
commit | f5394badad02671dc0de181ab63b9a9bfbe9fd59 (patch) | |
tree | 0d5af7a805e407a4a7daffa610d3e1d5deea91bd /app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | |
parent | ede53aff0ca989881247afead959341818f705b4 (diff) | |
download | frost-f5394badad02671dc0de181ab63b9a9bfbe9fd59.tar.gz frost-f5394badad02671dc0de181ab63b9a9bfbe9fd59.tar.bz2 frost-f5394badad02671dc0de181ab63b9a9bfbe9fd59.zip |
Misc 2 (#191)v1.4.6
* Add further checks for iab and remove generic error dialog
* Theme all snackbars
* Add dynamic media action tile
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 74e800df..469a3951 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -148,17 +148,20 @@ fun Throwable?.logFrostAnswers(text: String) { frostAnswersCustom("Errors", "text" to text, "message" to (this?.message ?: "NA")) } -fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) { - Snackbar.make(this, text, Snackbar.LENGTH_LONG).apply { - builder() - //hacky workaround, but it has proper checks and shouldn't crash - ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { - messageView.setTextColor(Prefs.textColor) - actionView.setTextColor(Prefs.accentColor) - //only set if previous text colors are set - view.setBackgroundColor(Prefs.bgColor.withAlpha(255).colorToForeground(0.1f)) - } - show() +fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) + = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) + +fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) + = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) + +private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = { + builder() + //hacky workaround, but it has proper checks and shouldn't crash + ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { + messageView.setTextColor(Prefs.textColor) + actionView.setTextColor(Prefs.accentColor) + //only set if previous text colors are set + view.setBackgroundColor(Prefs.bgColor.withAlpha(255).colorToForeground(0.1f)) } } |