@Override @SuppressWarnings("ResourceType") public void onClick(View view) { new SuperToast(getActivity()) .setText("SuperToast") .setDuration(AttributeUtils.getDuration(getActivity())) .setFrame(AttributeUtils.getFrame(getActivity())) .setColor(AttributeUtils.getColor(getActivity())) .setAnimations(AttributeUtils.getAnimations(getActivity())) .setColor(AttributeUtils.getColor(getActivity())).show(); } });
@Override public void onClick(View view, Parcelable token) { SuperToast.create(view.getContext(), "OnClick!", Style.DURATION_SHORT) .setPriorityLevel(Style.PRIORITY_HIGH).show(); } };
/** * Returns the dismiss tag of the SuperActivityToast. * * @return The dismiss tag */ @Override public String getDismissTag() { return super.getDismissTag(); }
/** * Creates a simple SuperToast. Don't forget to call {@link SuperToast#show()}. * * @param context A valid Context * @param text The desired text to be shown * @param duration The desired duration of the SuperToast * * @return The newly created SuperToast */ public static SuperToast create(@NonNull Context context, @NonNull String text, @Style.Duration int duration) { return new SuperToast(context) .setText(text) .setDuration(duration); }
final SuperToast superToast = new SuperToast(Playground.this); superToast.setText("SuperToast"); case 1: superToast.setTypefaceStyle(Typeface.BOLD); break; case 2: superToast.setTypefaceStyle(Typeface.BOLD_ITALIC); break; case 3: superToast.setTypefaceStyle(Typeface.ITALIC); break; default: superToast.setTypefaceStyle(Typeface.NORMAL); case 1: superToast.setAnimations(Style.ANIMATIONS_FADE); break; case 2: superToast.setAnimations(Style.ANIMATIONS_FLY); break; case 3: superToast.setAnimations(Style.ANIMATIONS_POP); break; default: superToast.setAnimations(Style.ANIMATIONS_SCALE); int blue = random.nextInt(255); int green = random.nextInt(255); superToast.setColor(Color.argb(255, red, blue, green)); case 1: superToast.setFrame(Style.FRAME_KITKAT); break; case 2: superToast.setFrame(Style.FRAME_LOLLIPOP); break; default: superToast.setFrame(Style.FRAME_STANDARD); break; blue = random.nextInt(255); green = random.nextInt(255); superToast.setPriorityColor(Color.argb(255, red, blue, green)); case 1: superToast.setGravity(Gravity.TOP); break; case 2: superToast.setGravity(Gravity.START); break; case 3: superToast.setGravity(Gravity.END); break; default: break;
@Override @SuppressWarnings("ResourceType") public void onClick(View view) { final int containerId = AttributeUtils.getFrame(getActivity()) == Style.FRAME_LOLLIPOP || AttributeUtils.getType(getActivity()) == Style.TYPE_BUTTON ? R.id.toast_container : 0; SuperActivityToast.create(getActivity(), new Style(), AttributeUtils.getType(getActivity()), containerId) .setButtonText("UNDO") .setButtonIconResource(R.drawable.ic_undo) .setOnButtonClickListener("good_tag_name", null, onButtonClickListener) .setProgressBarColor(Color.WHITE) .setText("SuperActivityToast") .setDuration(AttributeUtils.getDuration(getActivity())) .setFrame(AttributeUtils.getFrame(getActivity())) .setColor(AttributeUtils.getColor(getActivity())) .setAnimations(AttributeUtils.getAnimations(getActivity())).show(); } });
if (!style.isSuperActivityToast) new SuperToast(context, style).show(); else {
if (!superToast.isShowing()) { this.superToastPriorityQueue.remove(superToast); return; final WindowManager windowManager = (WindowManager) superToast.getContext() .getSystemService(Context.WINDOW_SERVICE); windowManager.removeView(superToast.getView()); } catch (IllegalArgumentException illegalArgumentException) { Log.e(getClass().getName(), illegalArgumentException.toString()); if (superToast.getOnDismissListener() != null) { superToast.getOnDismissListener().onDismiss(superToast.getView(), superToast.getStyle().dismissToken);
if (superToast.isShowing()) return; ((SuperActivityToast) superToast).getViewGroup().addView(superToast.getView()); superToast.getDuration() + AnimationUtils.SHOW_DURATION); final WindowManager windowManager = (WindowManager) superToast.getContext() .getApplicationContext().getSystemService(Context.WINDOW_SERVICE); if (windowManager != null) { windowManager.addView(superToast.getView(), superToast.getWindowManagerParams()); superToast.getDuration() + AnimationUtils.SHOW_DURATION);
/** * Creates a simple SuperActivityToast. Don't forget to call {@link SuperToast#show()}. * * @param context An Activity Context * @param text The desired text to be shown * @param duration The desired duration of the SuperActivityToast * @return The newly created SuperActivityToast */ public static SuperActivityToast create(@NonNull Context context, @NonNull String text, @Style.Duration int duration) { return (SuperActivityToast) new SuperActivityToast(context) .setText(text) .setDuration(duration); }
@Override public void onClick(View view) { getRandomSuperToast().show(); } });
if (superToast.isShowing()) { try{ ((SuperActivityToast) superToast).getViewGroup().removeView(superToast.getView()); ((SuperActivityToast) superToast).getViewGroup().invalidate(); } catch (NullPointerException|IllegalStateException exception) { final WindowManager windowManager = (WindowManager) superToast.getContext() .getApplicationContext().getSystemService(Context.WINDOW_SERVICE); if (superToast.isShowing()) { try{ windowManager.removeView(superToast.getView()); } catch (NullPointerException|IllegalArgumentException exception) { Log.e(getClass().getName(), exception.toString());
/** * Creates a simple SuperToast. Don't forget to call {@link SuperToast#show()}. * * @param context A valid Context * @param text The desired text to be shown * @param duration The desired duration of the SuperToast * @param style The desired Style of the SuperToast * * @return The newly created SuperToast */ public static SuperToast create(@NonNull Context context, @NonNull String text, @Style.Duration int duration, @NonNull Style style) { return new SuperToast(context, style) .setText(text) .setDuration(duration); } }
if (!style.isSuperActivityToast) new SuperToast(context, style).show(); else { final SuperActivityToast superActivityToast = new SuperActivityToast(context, style);
/** * Creates a simple SuperActivityToast. Don't forget to call {@link SuperToast#show()}. * * @param context An Activity Context * @param text The desired text to be shown * @param duration The desired duration of the SuperActivityToast * @param style The desired Style of the SuperToast * @return The newly created SuperActivityToast */ public static SuperActivityToast create(@NonNull Context context, @NonNull String text, @Style.Duration int duration, @NonNull Style style) { return (SuperActivityToast) new SuperActivityToast(context, style) .setText(text) .setDuration(duration); }
@Override public void whenFails(String msg) { new SuperToast(RegisterNextActivity.this) .setText(msg) .setDuration(Style.DURATION_LONG) .setColor(PaletteUtils.getTransparentColor(PaletteUtils.MATERIAL_RED)) .setAnimations(Style.ANIMATIONS_FLY) .show(); }
@Override public void onClick(View view, Parcelable token) { SuperToast.create(view.getContext(), "OnClick!", Style.DURATION_SHORT) .setPriorityLevel(Style.PRIORITY_HIGH).show(); } };
/** * Creates a simple SuperActivityToast. Don't forget to call {@link SuperToast#show()}. * * @param context An Activity Context * @param text The desired text to be shown * @param duration The desired duration of the SuperActivityToast * @param style The desired Style of the SuperToast * @param viewGroup The ViewGroup to attach the SuperActivityToast to * @return The newly created SuperActivityToast */ public static SuperActivityToast create(@NonNull Context context, @NonNull String text, @Style.Duration int duration, @NonNull Style style, @IdRes int viewGroup) { return (SuperActivityToast) new SuperActivityToast(context, style, Style.TYPE_STANDARD, viewGroup) .setText(text) .setDuration(duration); } }
@Override public void whenFail(String errorMsg) { new SuperToast(TeamAddActivity.this) .setText(errorMsg) .setDuration(Style.DURATION_LONG) .setColor(PaletteUtils.getTransparentColor(PaletteUtils.MATERIAL_RED)) .setAnimations(Style.ANIMATIONS_FLY) .show(); }
@Override public void whenLoadDataFail(String errorMsg) { new SuperToast(TradeTagDetailActivity.this) .setText(errorMsg) .setDuration(Style.DURATION_LONG) .setColor(PaletteUtils.getTransparentColor(PaletteUtils.MATERIAL_RED)) .setAnimations(Style.ANIMATIONS_POP) .show(); } }