/** Dismisses the SuperCardToast without an animation. */ public void dismissImmediately() { ManagerSuperCardToast.getInstance().remove(this); if (mHandler != null) { mHandler.removeCallbacks(mHideRunnable); mHandler.removeCallbacks(mHideWithAnimationRunnable); mHandler = null; } if (mToastView != null && mViewGroup != null) { mViewGroup.removeView(mToastView); if (mOnDismissListener != null) { mOnDismissListener.onDismiss(getView()); } mToastView = null; } else { Log.e(TAG, ERROR_VIEWCONTAINERNULL); } }
@Override public void run() { if (mViewGroup != null) { mViewGroup.postInvalidate(); } }
/** Shows the SuperCardToast. */ public void show() { ManagerSuperCardToast.getInstance().add(this); if (!isIndeterminate) { mHandler = new Handler(); mHandler.postDelayed(mHideRunnable, mDuration); } mViewGroup.addView(mToastView); if (!showImmediate) { final Animation animation = this.getShowAnimation(); /** Invalidate the ViewGroup after the show animation completes * */ animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { /** Must use Handler to modify ViewGroup in onAnimationEnd() * */ Handler mHandler = new Handler(); mHandler.post(mInvalidateRunnable); } @Override public void onAnimationRepeat(Animation arg0) { // Do nothing } @Override public void onAnimationStart(Animation arg0) { // Do nothing } }); mToastView.startAnimation(animation); } }