Java Code Examples for android.support.design.widget.Snackbar#show()

The following examples show how to use android.support.design.widget.Snackbar#show() . 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: AttachmentPopupFragment.java    From weMessage with GNU Affero General Public License v3.0 6 votes vote down vote up
private void showErroredSnackBar(String message){
    if (getParentFragment().getView() != null) {
        final Snackbar snackbar = Snackbar.make(getParentFragment().getView(), message, ERROR_SNACKBAR_DURATION * 1000);

        snackbar.setAction(getString(R.string.dismiss_button), new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                snackbar.dismiss();
            }
        });
        snackbar.setActionTextColor(getResources().getColor(R.color.brightRedText));

        View snackbarView = snackbar.getView();
        TextView textView = snackbarView.findViewById(android.support.design.R.id.snackbar_text);
        textView.setMaxLines(5);

        snackbar.show();
    }
}
 
Example 2
Source File: ReceiveDialogFragment.java    From nano-wallet-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void onClickCopy(View view) {
    analyticsService.track(AnalyticsEvents.NANO_ADDRESS_COPIED);

    // copy address to clipboard
    android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    android.content.ClipData clip = android.content.ClipData.newPlainText(ClipboardAlarmReceiver.CLIPBOARD_NAME, address.getAddress());
    if (clipboard != null) {
        clipboard.setPrimaryClip(clip);
    }

    Snackbar snackbar = Snackbar.make(view, Html.fromHtml(getString(R.string.receive_copy_message)), Snackbar.LENGTH_INDEFINITE);
    snackbar.setAction(R.string.receive_copy_done, view1 -> {
    });
    snackbar.show();

    setClearClipboardAlarm();
}
 
Example 3
Source File: AgentWebX5Utils.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
public static void show(View parent,
                        CharSequence text,
                        int duration,
                        @ColorInt int textColor,
                        @ColorInt int bgColor,
                        CharSequence actionText,
                        @ColorInt int actionTextColor,
                        View.OnClickListener listener) {
    SpannableString spannableString = new SpannableString(text);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(textColor);
    spannableString.setSpan(colorSpan, 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    snackbarWeakReference = new WeakReference<>(Snackbar.make(parent, spannableString, duration));
    Snackbar snackbar = snackbarWeakReference.get();
    View view = snackbar.getView();
    view.setBackgroundColor(bgColor);
    if (actionText != null && actionText.length() > 0 && listener != null) {
        snackbar.setActionTextColor(actionTextColor);
        snackbar.setAction(actionText, listener);
    }
    snackbar.show();

}
 
Example 4
Source File: DisplayUtils.java    From weMessage with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void showPositiveSnackbar(Context context, View view, int duration, String message){
    final Snackbar snackbar = Snackbar.make(view, message, duration * 1000);

    snackbar.setAction(context.getString(R.string.ok_button), new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            snackbar.dismiss();
        }
    });
    snackbar.setActionTextColor(context.getResources().getColor(R.color.colorHeader));

    View snackbarView = snackbar.getView();
    TextView textView = snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setMaxLines(5);

    snackbar.show();
}
 
Example 5
Source File: HelperActivity.java    From MultipleImageSelect with Apache License 2.0 6 votes vote down vote up
private void showAppPermissionSettings() {
    Snackbar snackbar = Snackbar.make(
            view,
            getString(R.string.permission_force),
            Snackbar.LENGTH_INDEFINITE)
            .setAction(getString(R.string.permission_settings), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Uri uri = Uri.fromParts(
                            getString(R.string.permission_package),
                            HelperActivity.this.getPackageName(),
                            null);

                    Intent intent = new Intent();
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.setData(uri);
                    startActivityForResult(intent, Constants.PERMISSION_REQUEST_CODE);
                }
            });

    /*((TextView) snackbar.getView()
            .findViewById(android.support.design.R.id.snackbar_text)).setMaxLines(maxLines);*/
    snackbar.show();
}
 
Example 6
Source File: RecordsActivity.java    From Android-Bluetooth-Fingerprint with Apache License 2.0 6 votes vote down vote up
private void showSnackBar(final int id, String msg) {
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout)
            findViewById(R.id.records_coordinator_layout);

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

    // Changing message text color
    snackbar.setActionTextColor(Color.RED);

    // Changing action button text color
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.YELLOW);
    snackbar.show();

}
 
Example 7
Source File: CommentPage.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
private void changeSubscription(Subreddit subreddit, boolean isChecked) {
    UserSubscriptions.addSubreddit(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH), getContext());

    Snackbar s = Snackbar.make(toolbar, isChecked ? getString(R.string.misc_subscribed)
            : getString(R.string.misc_unsubscribed), Snackbar.LENGTH_SHORT);
    View view = s.getView();
    TextView tv = view.findViewById(android.support.design.R.id.snackbar_text);
    tv.setTextColor(Color.WHITE);
    s.show();
}
 
Example 8
Source File: BaseFragment.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
protected final void showOperationTip(@StringRes int msgResId) {
    if (getView() != null) {
        Snackbar snackbar = Snackbar.make(getView(), msgResId, Snackbar.LENGTH_INDEFINITE)
                .setAction(R.string.ok, v -> {

                });
        snackbar.show();
    }
}
 
Example 9
Source File: Utils.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static void showRetrySnackBar(View view, String text, View.OnClickListener listener){
    Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_INDEFINITE);
    if (null != listener) {
        snackbar.setAction("RETRY", listener)
                .setActionTextColor(SettingsActivity.getPrimaryColor(view.getContext()));
    }
    snackbar.show();
}
 
Example 10
Source File: InstallerFragment.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
private void showMessage(String message) {
  Snackbar snackbar = Snackbar.make(getViewById(R.id.main), message, Snackbar.LENGTH_LONG);
  View view = snackbar.getView();
  TextView messageText = (TextView) view.findViewById(R.id.snackbar_text);
  if (getRadiant().isDark()) {
    messageText.setTextColor(getRadiant().primaryTextColor());
    view.setBackgroundColor(getRadiant().backgroundColorDark());
  } else {
    messageText.setTextColor(Color.WHITE);
  }
  snackbar.show();
}
 
Example 11
Source File: DashBoardActivity.java    From Android-Bluetooth-Fingerprint with Apache License 2.0 5 votes vote down vote up
private void showSnackBar(String msg) {
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.dash_board_coordinator_layout);
    Snackbar snackbar = Snackbar
            .make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);
   /* if(id == 0){
        snackbar.setAction("RETRY", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (cd.isConnectingToInternet())
                    submitLogin();
                else
                    showSnackBar(0, getString(R.string.err_no_internet));
            }
        });
    }*/


    // Changing message text color
    snackbar.setActionTextColor(Color.RED);

    // Changing action button text color
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.WHITE);
    snackbar.show();

}
 
Example 12
Source File: MainActivity.java    From OneTapVideoDownload with GNU General Public License v3.0 5 votes vote down vote up
private void displaySnackbar(String text, String actionName, View.OnClickListener action) {
    Snackbar snack = Snackbar.make(findViewById(android.R.id.content), text, Snackbar.LENGTH_LONG)
            .setAction(actionName, action);

    View v = snack.getView();
    v.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.accent));
    ((TextView) v.findViewById(android.support.design.R.id.snackbar_text)).setTextColor(Color.WHITE);
    ((TextView) v.findViewById(android.support.design.R.id.snackbar_action)).setTextColor(Color.BLACK);

    snack.show();
}
 
Example 13
Source File: BaseActivity.java    From android-mvp-architecture with Apache License 2.0 5 votes vote down vote up
private void showSnackBar(String message) {
    Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content),
            message, Snackbar.LENGTH_SHORT);
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView
            .findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(ContextCompat.getColor(this, R.color.white));
    snackbar.show();
}
 
Example 14
Source File: Utils.java    From MagicalCamera with Apache License 2.0 5 votes vote down vote up
/**
 * View Snack bar for simple form
 * @param message the message to shown
 * @param view the principal view (layout)
 */
public static void viewSnackBar(String message, View view){
    Snackbar snackbar =  Snackbar.make(view, message,
            Snackbar.LENGTH_LONG).setDuration(Snackbar.LENGTH_LONG);

    View snackbarView = snackbar.getView();
    TextView tv= (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    tv.setMaxLines(5);
    snackbar.show();
}
 
Example 15
Source File: NotificationsActivity.java    From Travel-Mate with MIT License 5 votes vote down vote up
private void emptyList() {
    Snackbar snackbar = Snackbar
            .make(findViewById(R.id.notifications_id_layout),
                    R.string.no_notifications, Snackbar.LENGTH_LONG);
    snackbar.show();

    hideOptionsMenu();

    animationView.setAnimation(R.raw.no_notifications);
    animationView.playAnimation();
}
 
Example 16
Source File: RequestEtherActivity.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
public void snackError(String s) {
    if (coord == null)
        return;
    Snackbar mySnackbar = Snackbar.make(coord, s, Snackbar.LENGTH_SHORT);
    mySnackbar.show();
}
 
Example 17
Source File: BaseActivity.java    From social-app-android with Apache License 2.0 4 votes vote down vote up
@Override
public void showSnackBar(@StringRes int messageId) {
    Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content),
            messageId, Snackbar.LENGTH_LONG);
    snackbar.show();
}
 
Example 18
Source File: SnackBarUtil.java    From TouchNews with Apache License 2.0 4 votes vote down vote up
public static Snackbar showLong(@NonNull View view, @StringRes int resId) {

        Snackbar snackbar = Snackbar.make(view, resId, Snackbar.LENGTH_LONG);
        snackbar.show();
        return snackbar;
    }
 
Example 19
Source File: MainActivity.java    From syncapp with Apache License 2.0 4 votes vote down vote up
@Override
public void showSyncMessage(String message) {
    Snackbar snackbar = Snackbar
            .make(linearLayout, message, Snackbar.LENGTH_LONG);
    snackbar.show();
}
 
Example 20
Source File: AddressDetailActivity.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
public void snackError(String s) {
    if (coord == null)
        return;
    Snackbar mySnackbar = Snackbar.make(coord, s, Snackbar.LENGTH_SHORT);
    mySnackbar.show();
}