use of android.support.design.widget.Snackbar in project FlexibleAdapter by davideas.
the class UndoHelper method remove.
/**
* Performs the action on the specified positions and displays a SnackBar to Undo
* the operation. To customize the UPDATE event, please set a custom listener with
* {@link #withAction(int, OnActionListener)} method.
* <p>By default the DELETE action will be performed.</p>
*
* @param positions the position to delete or update
* @param mainView the view to find a parent from
* @param message the text to show. Can be formatted text
* @param actionText the action text to display
* @param undoTime How long to display the message. Either {@link Snackbar#LENGTH_SHORT} or
* {@link Snackbar#LENGTH_LONG} or any custom Integer.
* @return The SnackBar instance
* @see #remove(List, View, int, int, int)
*/
@SuppressWarnings("WrongConstant")
public Snackbar remove(List<Integer> positions, @NonNull View mainView, CharSequence message, CharSequence actionText, @IntRange(from = -1) int undoTime) {
this.mPositions = positions;
Snackbar snackbar;
if (!mAdapter.isPermanentDelete()) {
snackbar = Snackbar.make(mainView, message, undoTime > 0 ? undoTime + 400 : undoTime).setAction(actionText, new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mUndoListener != null)
mUndoListener.onUndoConfirmed(mAction);
}
});
} else {
snackbar = Snackbar.make(mainView, message, undoTime);
}
if (mActionTextColor != Color.TRANSPARENT) {
snackbar.setActionTextColor(mActionTextColor);
}
snackbar.addCallback(this);
snackbar.show();
return snackbar;
}
use of android.support.design.widget.Snackbar in project materialistic by hidroh.
the class StoryRecyclerViewAdapter method notifyUpdated.
private void notifyUpdated() {
if (mShowAll) {
Snackbar.make(mRecyclerView, mContext.getResources().getQuantityString(R.plurals.new_stories_count, mUpdated.size(), mUpdated.size()), Snackbar.LENGTH_LONG).setAction(R.string.show_me, v -> {
setShowAll(false);
notifyUpdated();
notifyDataSetChanged();
}).show();
} else {
final Snackbar snackbar = Snackbar.make(mRecyclerView, mContext.getResources().getQuantityString(R.plurals.showing_new_stories, mUpdated.size(), mUpdated.size()), Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.show_all, v -> {
snackbar.dismiss();
mUpdated.clear();
setShowAll(true);
notifyDataSetChanged();
}).show();
}
}
use of android.support.design.widget.Snackbar in project materialistic by hidroh.
the class BaseListActivity method onPostCreate.
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (!Preferences.isReleaseNotesSeen(this)) {
Snackbar snackbar = Snackbar.make(findViewById(R.id.content_frame), R.string.hint_update, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.title_activity_release, v -> {
snackbar.dismiss();
startActivity(new Intent(BaseListActivity.this, ReleaseNotesActivity.class));
}).setActionTextColor(ContextCompat.getColor(this, R.color.orange500)).show();
}
}
use of android.support.design.widget.Snackbar in project Android-Boilerplate by hitherejoe.
the class SnackbarFactory method createSnackbar.
public static Snackbar createSnackbar(Context context, View view, String message) {
Snackbar snackbar = Snackbar.make(view, message, Snackbar.LENGTH_SHORT);
ViewGroup group = (ViewGroup) snackbar.getView();
group.setBackgroundColor(context.getResources().getColor(R.color.primary));
return snackbar;
}
use of android.support.design.widget.Snackbar in project android by owncloud.
the class Preferences method showSnackMessage.
/**
* Show a temporary message in a Snackbar bound to the content view
*
* @param messageResource Message to show.
*/
private void showSnackMessage(int messageResource) {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), messageResource, Snackbar.LENGTH_LONG);
snackbar.show();
}
Aggregations