|
|
|
@ -216,10 +216,14 @@ object UiTools { |
|
|
|
return DEFAULT_COVER_FOLDER_DRAWABLE_BIG!! |
|
|
|
} |
|
|
|
|
|
|
|
private fun getSnackAnchorView(activity: Activity)= |
|
|
|
if (activity is BaseActivity && activity.getSnackAnchorView() != null) activity.getSnackAnchorView() else activity.findViewById(android.R.id.content) |
|
|
|
|
|
|
|
/** |
|
|
|
* Print an on-screen message to alert the user |
|
|
|
*/ |
|
|
|
fun snacker(view: View, stringId: Int) { |
|
|
|
fun snacker(activity:Activity, stringId: Int) { |
|
|
|
val view = getSnackAnchorView(activity) ?: return |
|
|
|
val snack = Snackbar.make(view, stringId, Snackbar.LENGTH_SHORT) |
|
|
|
// snack.setAnchorView() |
|
|
|
snack.show() |
|
|
|
@ -229,7 +233,8 @@ object UiTools { |
|
|
|
* Print an on-screen message to alert the user |
|
|
|
*/ |
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
|
|
|
fun snacker(view: View, message: String) { |
|
|
|
fun snacker(activity:Activity, message: String) { |
|
|
|
val view = getSnackAnchorView(activity) ?: return |
|
|
|
val snack = Snackbar.make(view, message, Snackbar.LENGTH_SHORT) |
|
|
|
if (AndroidUtil.isLolliPopOrLater) |
|
|
|
snack.view.elevation = view.resources.getDimensionPixelSize(R.dimen.audio_player_elevation).toFloat() |
|
|
|
@ -240,7 +245,8 @@ object UiTools { |
|
|
|
* Print an on-screen message to alert the user, with undo action |
|
|
|
*/ |
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
|
|
|
fun snackerConfirm(view: View, message: String, action: Runnable) { |
|
|
|
fun snackerConfirm(activity:Activity, message: String, action: Runnable) { |
|
|
|
val view = getSnackAnchorView(activity) ?: return |
|
|
|
val snack = Snackbar.make(view, message, Snackbar.LENGTH_LONG) |
|
|
|
.setAction(R.string.ok) { action.run() } |
|
|
|
if (AndroidUtil.isLolliPopOrLater) |
|
|
|
@ -249,7 +255,8 @@ object UiTools { |
|
|
|
} |
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
|
|
|
fun CoroutineScope.snackerConfirm(view: View, message: String, action: suspend() -> Unit) { |
|
|
|
fun CoroutineScope.snackerConfirm(activity:Activity, message: String, action: suspend() -> Unit) { |
|
|
|
val view = getSnackAnchorView(activity) ?: return |
|
|
|
val snack = Snackbar.make(view, message, Snackbar.LENGTH_LONG) |
|
|
|
.setAction(R.string.ok) { launch { action.invoke() } } |
|
|
|
if (AndroidUtil.isLolliPopOrLater) |
|
|
|
@ -262,7 +269,8 @@ object UiTools { |
|
|
|
* Print an on-screen message to alert the user, with undo action |
|
|
|
*/ |
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
|
|
|
fun snackerWithCancel(view: View, message: String, action: Runnable?, cancelAction: Runnable?) { |
|
|
|
fun snackerWithCancel(activity:Activity, message: String, action: Runnable?, cancelAction: Runnable?) { |
|
|
|
val view = getSnackAnchorView(activity) ?: return |
|
|
|
@SuppressLint("WrongConstant") val snack = Snackbar.make(view, message, DELETE_DURATION) |
|
|
|
.setAction(R.string.cancel) { |
|
|
|
if (action != null) |
|
|
|
|