Search in sources :

Example 76 with Snackbar

use of android.support.design.widget.Snackbar in project AntennaPod by AntennaPod.

the class MediaplayerInfoActivity method onEventMainThread.

public void onEventMainThread(MessageEvent event) {
    Log.d(TAG, "onEvent(" + event + ")");
    View parentLayout = findViewById(R.id.drawer_layout);
    Snackbar snackbar = Snackbar.make(parentLayout, event.message, Snackbar.LENGTH_SHORT);
    if (event.action != null) {
        snackbar.setAction(getString(R.string.undo), v -> {
            event.action.run();
        });
    }
    snackbar.show();
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Snackbar(android.support.design.widget.Snackbar)

Example 77 with Snackbar

use of android.support.design.widget.Snackbar in project AntennaPod by AntennaPod.

the class MainActivity method onEventMainThread.

public void onEventMainThread(MessageEvent event) {
    Log.d(TAG, "onEvent(" + event + ")");
    View parentLayout = findViewById(R.id.drawer_layout);
    Snackbar snackbar = Snackbar.make(parentLayout, event.message, Snackbar.LENGTH_SHORT);
    if (event.action != null) {
        snackbar.setAction(getString(R.string.undo), v -> {
            event.action.run();
        });
    }
    snackbar.show();
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Snackbar(android.support.design.widget.Snackbar)

Example 78 with Snackbar

use of android.support.design.widget.Snackbar in project BottomNavigation by Ashok-Varma.

the class HomeActivity method onClick.

@Override
public void onClick(View v) {
    if (v.getId() == R.id.toggle_hide) {
        if (bottomNavigationBar != null) {
            bottomNavigationBar.toggle();
        }
    } else if (v.getId() == R.id.toggle_badge) {
        if (numberBadgeItem != null) {
            numberBadgeItem.toggle();
        }
    } else if (v.getId() == R.id.fab_home) {
        final Snackbar snackbar = Snackbar.make(message, "Fab Clicked", Snackbar.LENGTH_LONG);
        snackbar.setAction("dismiss", new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                snackbar.dismiss();
            }
        });
        snackbar.show();
    }
}
Also used : TextView(android.widget.TextView) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 79 with Snackbar

use of android.support.design.widget.Snackbar in project AndroidUtilCode by Blankj.

the class SnackbarUtils method showSnackbar.

/**
     * 设置snackbar文字和背景颜色
     *
     * @param parent          父视图(CoordinatorLayout或者DecorView)
     * @param text            文本
     * @param duration        显示时长
     * @param textColor       文本颜色
     * @param bgColor         背景色
     * @param actionText      事件文本
     * @param actionTextColor 事件文本颜色
     * @param listener        监听器
     */
private static void showSnackbar(View parent, CharSequence text, int duration, @ColorInt int textColor, @ColorInt int bgColor, CharSequence actionText, 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();
}
Also used : SpannableString(android.text.SpannableString) ForegroundColorSpan(android.text.style.ForegroundColorSpan) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 80 with Snackbar

use of android.support.design.widget.Snackbar in project AndroidUtilCode by Blankj.

the class SnackbarUtils method addView.

/**
     * 为snackbar添加布局
     * <p>在show...Snackbar之后调用</p>
     *
     * @param layoutId 布局文件
     * @param index    位置(the position at which to add the child or -1 to add last)
     */
public static void addView(int layoutId, int index) {
    Snackbar snackbar = snackbarWeakReference.get();
    if (snackbar != null) {
        View view = snackbar.getView();
        Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) view;
        View child = LayoutInflater.from(view.getContext()).inflate(layoutId, null);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER_VERTICAL;
        layout.addView(child, index, params);
    }
}
Also used : View(android.view.View) LinearLayout(android.widget.LinearLayout) Snackbar(android.support.design.widget.Snackbar)

Aggregations

Snackbar (android.support.design.widget.Snackbar)102 View (android.view.View)56 TextView (android.widget.TextView)25 Intent (android.content.Intent)13 RecyclerView (android.support.v7.widget.RecyclerView)13 BaseTransientBottomBar (android.support.design.widget.BaseTransientBottomBar)10 ImageView (android.widget.ImageView)10 ViewGroup (android.view.ViewGroup)8 DialogInterface (android.content.DialogInterface)7 LayoutInflater (android.view.LayoutInflater)6 AdapterView (android.widget.AdapterView)6 LinearLayout (android.widget.LinearLayout)6 ListView (android.widget.ListView)6 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)5 AlertDialog (android.app.AlertDialog)4 Context (android.content.Context)4 Nullable (android.support.annotation.Nullable)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 File (java.io.File)4 RemindyDAO (ve.com.abicelis.remindy.database.RemindyDAO)4