/** * Dismisses every SuperToast and SuperActivityToast that is showing and * cancels everything in the queue. */ public static void cancelAllSuperToasts() { Toaster.getInstance().cancelAllSuperToasts(); }
/** * Saves the state of all SuperToasts that are showing and/or pending. * * This should be called in the {@link android.app.Activity#onSaveInstanceState(android.os.Bundle)} * method of your Activity. * * @param bundle The Bundle provided in onSaveInstanceState() */ @SuppressWarnings("unchecked") public static void onSaveState(Bundle bundle) { final ArrayList<Style> styleList = new ArrayList(); // Create a list of every Style used by a SuperToast in the queue for (SuperToast superToast : Toaster.getInstance().getQueue()) { if (superToast instanceof SuperActivityToast) { superToast.getStyle().isSuperActivityToast = true; } styleList.add(superToast.getStyle()); } bundle.putParcelableArrayList(BUNDLE_KEY, styleList); // Let's avoid any erratic behavior and cancel any showing/pending SuperActivityToasts manually Toaster.getInstance().cancelAllSuperToasts(); }