android - Snackbar in Support Library doesn't include OnDismissListener()? -


i'd implement new snackbar included in latest design support library, way offered seems counter-intuitive my, , assume many others', use.

when user important action, want allow them undo via snackbar, there seems no way detect when dismissed action. makes sense me following way:

  1. user action.
  2. show snackbar , update ui if action has been completed (ie appears data sent database, isn't yet).
  3. if user pressed "undo," revert ui changes. if not, when snackbar dismissed, send data.

but because don't see accessable ondismisslistener, therefore have to:

  1. user action.
  2. send info database , update ui.
  3. if user presses "undo," send call database remove just-added data , revert ui changes.

i avoid having make 2 calls database, , send 1 when app knows it's safe (the user has avoided pressing "undo"). notice there implementation of in third-party library via eventlistener, i'd stick google library.

now does

snackbar.make(getview(), "hi there!", snackbar.length_long).setcallback( new snackbar.callback() {                 @override                 public void ondismissed(snackbar snackbar, int event) {                     switch(event) {                         case snackbar.callback.dismiss_event_action:                             toast.maketext(getactivity(), "clicked action", toast.length_long).show();                             break;                         case snackbar.callback.dismiss_event_timeout:                             toast.maketext(getactivity(), "time out", toast.length_long).show();                             break;                     }                 }                  @override                 public void onshown(snackbar snackbar) {                     toast.maketext(getactivity(), "this annoying step-brother", toast.length_long).show();                 }             }).setaction("go away!", new view.onclicklistener() {                 @override                 public void onclick(view v) {                  }             }).show(); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -