Java Code Examples for com.android.messaging.ui.SnackBar

Following code examples demonstrate how to use com.android.messaging.ui.SnackBarfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.messaging.ui.SnackBarand various code implementation of this class.

    public static void showToast(final int pluralsMessageId, final int count) {
        final Toast toast = Toast.makeText(getApplicationContext(),
                getApplicationContext().getResources().getQuantityString(pluralsMessageId, count),
                Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER_HORIZONTAL, 0, 0);
        toast.show();
    } 


        switch (runnableLabel) {
            case SnackBar.Action.SNACK_BAR_UNDO:
                action = SnackBar.Action.createUndoAction(runnable);
                break;
            case SnackBar.Action.SNACK_BAR_RETRY:
                action =  SnackBar.Action.createRetryAction(runnable);
                break;
            default :
                break;
        } 

        }

        showSnackBarWithCustomAction(context, parentView, message, action, interactions,
                                        null );
    }

    public static void showSnackBar(final Context context, @NonNull final View parentView,
            final String message) {
        Assert.notNull(context);
        Assert.isTrue(!TextUtils.isEmpty(message));
        SnackBarManager.get()
            .newBuilder(parentView)
            .setText(message)
            .show();
    } 

    }

    private void promptToChangeDefaultSmsApp(final boolean sending,
            final Runnable runAfterMadeDefault,
            final View composeView, final View rootView,
            final Activity activity) {
        if (composeView != null) {
            ImeUtil.hideSoftInput(activity, composeView);
        }
        mRunAfterMadeDefault = runAfterMadeDefault;

        if (rootView == null) {
            mChangeSmsAppSettingRunnable.run();
        } else {
            UiUtils.showSnackBarWithCustomAction(activity,
                    rootView,
                    activity.getString(sending ? R.string.requires_default_sms_app_to_send :
                        R.string.requires_default_sms_app),
                        SnackBar.Action.createCustomAction(mChangeSmsAppSettingRunnable,
                                activity.getString(R.string.requires_default_sms_change_button)),
                                null ,
                                SnackBar.Placement.above(composeView));
        }
    } 

    private void makeCurrentSnackBarDismissibleOnTouch() {
        mCurrentSnackBar.getRootView().setOnTouchListener(mDismissOnTouchListener);
        mCurrentSnackBar.getSnackBarView().setOnTouchListener(mDismissOnTouchListener);
    } 

Advertisement
Javadoc
Defines an action to be performed when the user clicks on the action button on the snack bar
Advertisement