private void displaySuperToast ( SuperToast superToast ) { // Make sure the SuperToast isn't already showing for some reason if ( superToast . isShowing ( ) ) return ; // If the SuperToast is a SuperActivityToast, show it via the supplied ViewGroup if ( superToast instanceof SuperActivityToast ) { if ( ( ( SuperActivityToast ) superToast ) . getViewGroup ( ) == null ) { Log . e ( getClass ( ) . getName ( ) , ERROR_SAT_VIEWGROUP_NULL ) ; return ; } try { ( ( SuperActivityToast ) superToast ) . getViewGroup ( ) . addView ( superToast . getView ( ) ) ; // Do not use the show animation on the first SuperToast if from orientation change if ( ! ( ( SuperActivityToast ) superToast ) . isFromOrientationChange ( ) ) { AnimationUtils . getShowAnimation ( ( SuperActivityToast ) superToast ) . start ( ) ; } } catch ( IllegalStateException illegalStateException ) { Log . e ( getClass ( ) . getName ( ) , illegalStateException . toString ( ) ) ; } if ( ! ( ( SuperActivityToast ) superToast ) . isIndeterminate ( ) ) { // This will remove the SuperToast after the total duration sendDelayedMessage ( superToast , Messages . REMOVE_SUPERTOAST , superToast . getDuration ( ) + AnimationUtils . SHOW_DURATION ) ; } // The SuperToast is NOT a SuperActivityToast, show it via the WindowManager } else { final WindowManager windowManager = ( WindowManager ) superToast . getContext ( ) . getApplicationContext ( ) . getSystemService ( Context . WINDOW_SERVICE ) ; if ( windowManager != null ) { windowManager . addView ( superToast . getView ( ) , superToast . getWindowManagerParams ( ) ) ; } // This will remove the SuperToast after a certain duration sendDelayedMessage ( superToast , Messages . REMOVE_SUPERTOAST , superToast . getDuration ( ) + AnimationUtils . SHOW_DURATION ) ; } }
Try to show the SuperToast . SuperToasts will be shown using the WindowManager while SuperActivityToasts will be shown using their supplied ViewGroup .