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