/** * Returns the number of SuperToasts in the queue. * * @return The queue size */ public static int getQueueSize() { return Toaster.getInstance().getQueue().size(); }
/** * Dismissed the SuperToast if it is showing. */ public void dismiss() { Toaster.getInstance().removeSuperToast(this); }
/** * 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(); }
/** * Shows the SuperToast. If any SuperToast is already showing, this SuperToast * will be enqueued until the others have finished (depending on priority level). */ public void show() { this.onPrepareShow(); Toaster.getInstance().add(this); AccessibilityUtils.sendAccessibilityEvent(this.mView); }