Search in sources :

Example 1 with Snackbar

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;
}
Also used : View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 2 with 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();
    }
}
Also used : ComposeActivity(io.github.hidroh.materialistic.ComposeActivity) Context(android.content.Context) Bundle(android.os.Bundle) MaterialisticProvider(io.github.hidroh.materialistic.data.MaterialisticProvider) LongSparseArray(android.support.v4.util.LongSparseArray) Uri(android.net.Uri) Intent(android.content.Intent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) AppUtils(io.github.hidroh.materialistic.AppUtils) ContentResolver(android.content.ContentResolver) Handler(android.os.Handler) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) Toast(android.widget.Toast) Map(java.util.Map) ActivityModule(io.github.hidroh.materialistic.ActivityModule) View(android.view.View) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic) Named(javax.inject.Named) WeakReference(java.lang.ref.WeakReference) Preferences(io.github.hidroh.materialistic.Preferences) Save(io.github.hidroh.materialistic.Preferences.SwipeAction.Save) ContextCompat(android.support.v4.content.ContextCompat) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) Item(io.github.hidroh.materialistic.data.Item) ViewGroup(android.view.ViewGroup) ResponseListener(io.github.hidroh.materialistic.data.ResponseListener) ContentObserver(android.database.ContentObserver) UserServices(io.github.hidroh.materialistic.accounts.UserServices) RecyclerView(android.support.v7.widget.RecyclerView) Gravity(android.view.Gravity) List(java.util.List) R(io.github.hidroh.materialistic.R) UserActivity(io.github.hidroh.materialistic.UserActivity) ItemManager(io.github.hidroh.materialistic.data.ItemManager) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) FavoriteManager(io.github.hidroh.materialistic.data.FavoriteManager) SessionManager(io.github.hidroh.materialistic.data.SessionManager) Snackbar(android.support.design.widget.Snackbar)

Example 3 with Snackbar

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();
    }
}
Also used : Intent(android.content.Intent) Snackbar(android.support.design.widget.Snackbar)

Example 4 with Snackbar

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;
}
Also used : ViewGroup(android.view.ViewGroup) Snackbar(android.support.design.widget.Snackbar)

Example 5 with 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();
}
Also used : Snackbar(android.support.design.widget.Snackbar)

Aggregations

Snackbar (android.support.design.widget.Snackbar)94 View (android.view.View)50 TextView (android.widget.TextView)23 RecyclerView (android.support.v7.widget.RecyclerView)14 Intent (android.content.Intent)13 BaseTransientBottomBar (android.support.design.widget.BaseTransientBottomBar)9 ListView (android.widget.ListView)8 DialogInterface (android.content.DialogInterface)7 ImageView (android.widget.ImageView)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)5 ViewGroup (android.view.ViewGroup)5 AdapterView (android.widget.AdapterView)5 LinearLayout (android.widget.LinearLayout)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Bitmap (android.graphics.Bitmap)4 Nullable (android.support.annotation.Nullable)4 LayoutInflater (android.view.LayoutInflater)4 RemindyDAO (ve.com.abicelis.remindy.database.RemindyDAO)4