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);
}
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);
}
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;
}
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);
}
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();
}
Aggregations