Java Code Examples for android.support.design.widget.Snackbar#Callback

The following examples show how to use android.support.design.widget.Snackbar#Callback . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfileActivity.java    From redgram-for-reddit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void showSnackBar(String msg, int length, @Nullable String actionText, @Nullable View.OnClickListener onClickListener, @Nullable Snackbar.Callback callback) {
    if(coordinatorLayout() != null){

        Snackbar snackbar = Snackbar.make(coordinatorLayout(), msg, length);

        if(actionText != null && onClickListener != null){
            snackbar.setAction(actionText, onClickListener);
        }

        if(callback != null) {
            snackbar.setCallback(callback);
        }
        //hide the panel before showing the snack bar
        snackbar.show();
    }
}
 
Example 2
Source File: MainActivity.java    From redgram-for-reddit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void showSnackBar(String msg, int length, @Nullable String actionText, @Nullable View.OnClickListener onClickListener, @Nullable Snackbar.Callback callback) {
    if(coordinatorLayout() != null){

        Snackbar snackbar = Snackbar.make(coordinatorLayout(), msg, length);

        if(actionText != null && onClickListener != null){
            snackbar.setAction(actionText, onClickListener);
        }

        if(callback != null) {
            snackbar.setCallback(callback);
        }else{
            snackbar.setCallback(new PanelSnackBarCallback());
        }
        //hide the panel before showing the snack bar
        setPanelHeight(0);
        snackbar.show();
    }
}
 
Example 3
Source File: ThreadActivity.java    From redgram-for-reddit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void showSnackBar(String msg, int length, @Nullable String actionText, @Nullable View.OnClickListener onClickListener, @Nullable Snackbar.Callback callback) {
    if(coordinatorLayout() != null){

        Snackbar snackbar = Snackbar.make(coordinatorLayout(), msg, length);

        if(actionText != null && onClickListener != null){
            snackbar.setAction(actionText, onClickListener);
        }

        if(callback != null) {
            snackbar.setCallback(callback);
        }
        //hide the panel before showing the snack bar
        snackbar.show();
    }
}
 
Example 4
Source File: Alert.java    From outlay with Apache License 2.0 5 votes vote down vote up
public static void info(View view, String message, View.OnClickListener clickListener, Snackbar.Callback callback) {
    Context context = view.getContext();
    Snackbar bar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
    if (clickListener != null) {
        bar.setAction(context.getString(app.outlay.R.string.label_undo), clickListener);
        bar.setActionTextColor(ContextCompat.getColor(context, app.outlay.R.color.red));
    }
    if(callback != null) {
        bar.addCallback(callback);
    }
    bar.show();
}
 
Example 5
Source File: SnackbarWrapperTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenAddCallbacks_thenCallbacksAdded() {
  List<Snackbar.Callback> callbacks = new ArrayList<>();
  callbacks.add(callback);
  callbacks.add(snackbarCallback);

  wrapper.addCallbacks(callbacks);
  wrapper.show();

  wrapper.dismiss();
  verify(callback).onDismissed(snackbar, Callback.DISMISS_EVENT_MANUAL);
  verify(snackbarCallback).onSnackbarManuallyDismissed(snackbar);
}
 
Example 6
Source File: CoordinatorLayoutInterface.java    From redgram-for-reddit with GNU General Public License v3.0 votes vote down vote up
void showSnackBar(String msg, int length, @Nullable String actionText, @Nullable View.OnClickListener onClickListener, @Nullable Snackbar.Callback callback);