[Android] Add snackbar with undo action
Geoffrey Métais
git at videolan.org
Wed Jan 6 16:47:24 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 6 16:35:14 2016 +0100| [377ea897e158f7303abc29d9c55c525dc98fe34d] | committer: Geoffrey Métais
Add snackbar with undo action
> https://code.videolan.org/videolan/vlc-android/commit/377ea897e158f7303abc29d9c55c525dc98fe34d
---
.../src/org/videolan/vlc/gui/helpers/UiTools.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index 902fd5a..8fe6ed0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -61,15 +61,29 @@ public class UiTools {
/** Print an on-screen message to alert the user, with undo action */
public static void snackerWithCancel(@NonNull View view, @NonNull String message, @NonNull final Runnable action) {
+ snackerWithCancel(view, message, action, null);
+ }
+
+ /** Print an on-screen message to alert the user, with undo action */
+ public static void snackerWithCancel(@NonNull View view, @NonNull String message, @NonNull final View.OnClickListener cancelAction) {
+ snackerWithCancel(view, message, null, cancelAction);
+ }
+
+ /** Print an on-screen message to alert the user, with undo action */
+ public static void snackerWithCancel(@NonNull View view, @NonNull String message, @NonNull final Runnable action, @Nullable final View.OnClickListener cancelAction) {
Snackbar.make(view, message, DELETE_DURATION)
.setAction(android.R.string.cancel, new View.OnClickListener() {
@Override
public void onClick(View v) {
- sHandler.removeCallbacks(action);
+ if (action != null)
+ sHandler.removeCallbacks(action);
+ if (cancelAction != null)
+ cancelAction.onClick(v);
}
})
.show();
- sHandler.postDelayed(action, DELETE_DURATION);
+ if (action != null)
+ sHandler.postDelayed(action, DELETE_DURATION);
}
public static int convertPxToDp(int px) {
More information about the Android
mailing list