Search in sources :

Example 31 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project EhViewer by seven332.

the class MainActivity method checkClipboardUrlInternal.

private void checkClipboardUrlInternal() {
    String text = getTextFromClipboard();
    int hashCode = text != null ? text.hashCode() : 0;
    if (text != null && hashCode != 0 && Settings.getClipboardTextHashCode() != hashCode) {
        Announcer announcer = createAnnouncerFromClipboardUrl(text);
        if (announcer != null && mDrawerLayout != null) {
            Snackbar snackbar = Snackbar.make(mDrawerLayout, R.string.clipboard_gallery_url_snack_message, Snackbar.LENGTH_INDEFINITE);
            snackbar.setAction(R.string.clipboard_gallery_url_snack_action, v -> startScene(announcer));
            snackbar.show();
        }
    }
    Settings.putClipboardTextHashCode(hashCode);
}
Also used : Announcer(com.hippo.scene.Announcer) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 32 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project apps-android-commons by commons-app.

the class NotificationActivity method removeNotification.

/**
 * If this is unread section of the notifications, removeNotification method
 *  Marks the notification as read,
 *  Removes the notification from unread,
 *  Displays the Snackbar.
 *
 * Otherwise returns (read section).
 *
 * @param notification
 */
@SuppressLint("CheckResult")
public void removeNotification(Notification notification) {
    if (isRead) {
        return;
    }
    Disposable disposable = Observable.defer((Callable<ObservableSource<Boolean>>) () -> controller.markAsRead(notification)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        if (result) {
            notificationList.remove(notification);
            setItems(notificationList);
            adapter.notifyDataSetChanged();
            Snackbar snackbar = Snackbar.make(relativeLayout, getString(R.string.notification_mark_read), Snackbar.LENGTH_LONG);
            snackbar.show();
            if (notificationList.size() == 0) {
                setEmptyView();
                relativeLayout.setVisibility(View.GONE);
                no_notification.setVisibility(View.VISIBLE);
            }
        } else {
            adapter.notifyDataSetChanged();
            setItems(notificationList);
            Toast.makeText(NotificationActivity.this, getString(R.string.some_error), Toast.LENGTH_SHORT).show();
        }
    }, throwable -> {
        Timber.e(throwable, "Error occurred while loading notifications");
        throwable.printStackTrace();
        ViewUtil.showShortSnackbar(relativeLayout, R.string.error_notifications);
        progressBar.setVisibility(View.GONE);
    });
    compositeDisposable.add(disposable);
}
Also used : Disposable(io.reactivex.disposables.Disposable) Callable(java.util.concurrent.Callable) Snackbar(com.google.android.material.snackbar.Snackbar) SuppressLint(android.annotation.SuppressLint)

Example 33 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project AmazeFileManager by TeamAmaze.

the class Utils method showCutCopySnackBar.

public static Snackbar showCutCopySnackBar(MainActivity mainActivity, CharSequence text, int length, @StringRes int actionTextId, Runnable actionCallback, Runnable cancelCallback) {
    final Snackbar snackbar = Snackbar.make(mainActivity.findViewById(R.id.content_frame), "", length);
    View customSnackView = View.inflate(mainActivity.getApplicationContext(), R.layout.snackbar_view, null);
    snackbar.getView().setBackgroundColor(Color.TRANSPARENT);
    Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
    snackBarLayout.setPadding(0, 0, 0, 0);
    Button actionButton = customSnackView.findViewById(R.id.snackBarActionButton);
    Button cancelButton = customSnackView.findViewById(R.id.snackBarCancelButton);
    TextView textView = customSnackView.findViewById(R.id.snackBarTextTV);
    actionButton.setText(actionTextId);
    textView.setText(text);
    actionButton.setOnClickListener(v -> actionCallback.run());
    cancelButton.setOnClickListener(v -> cancelCallback.run());
    snackBarLayout.addView(customSnackView, 0);
    ((CardView) snackBarLayout.findViewById(R.id.snackBarCardView)).setCardBackgroundColor(mainActivity.getAccent());
    snackbar.show();
    return snackbar;
}
Also used : Button(android.widget.Button) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) View(android.view.View) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 34 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project Rocket by mozilla-tw.

the class ViewUtils method showBrandedSnackbar.

/**
 * Create a snackbar with Focus branding (See #193).
 */
public static void showBrandedSnackbar(View view, @StringRes int resId, int delayMillis) {
    final Context context = view.getContext();
    final Snackbar snackbar = Snackbar.make(view, resId, Snackbar.LENGTH_LONG);
    final View snackbarView = snackbar.getView();
    snackbarView.setBackgroundColor(ContextCompat.getColor(context, R.color.snackbarBackground));
    final TextView snackbarTextView = (TextView) snackbarView.findViewById(com.google.android.material.R.id.snackbar_text);
    snackbarTextView.setTextColor(ContextCompat.getColor(context, R.color.snackbarTextColor));
    snackbarTextView.setGravity(Gravity.CENTER);
    snackbarTextView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
    view.postDelayed(new Runnable() {

        @Override
        public void run() {
            snackbar.show();
        }
    }, delayMillis);
}
Also used : Context(android.content.Context) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 35 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project zype-android by zype.

the class UiUtils method showErrorIndefiniteSnackbar.

public static void showErrorIndefiniteSnackbar(@Nullable final View view, @NonNull final String text) {
    if (view == null) {
        return;
    }
    Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_INDEFINITE);
    View snackView = snackbar.getView();
    snackView.setBackgroundColor(view.getContext().getResources().getColor(R.color.snackbar_error));
    snackbar.show();
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) Snackbar(com.google.android.material.snackbar.Snackbar)

Aggregations

Snackbar (com.google.android.material.snackbar.Snackbar)110 View (android.view.View)61 Intent (android.content.Intent)46 TextView (android.widget.TextView)41 AlertDialog (androidx.appcompat.app.AlertDialog)29 Context (android.content.Context)28 ImageView (android.widget.ImageView)28 LayoutInflater (android.view.LayoutInflater)24 ArrayList (java.util.ArrayList)23 RecyclerView (androidx.recyclerview.widget.RecyclerView)22 Bundle (android.os.Bundle)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 DialogInterface (android.content.DialogInterface)19 List (java.util.List)19 CreateCardView (me.ccrama.redditslide.Views.CreateCardView)18 Submission (net.dean.jraw.models.Submission)18 SubredditView (me.ccrama.redditslide.Activities.SubredditView)17 ApiException (net.dean.jraw.ApiException)17 Activity (android.app.Activity)16 OnSingleClickListener (me.ccrama.redditslide.util.OnSingleClickListener)16