コード例 #1
0
  /**
   * Saves pending/shown SuperCardToasts to a bundle. <br>
   *
   * @param bundle Use onSaveInstanceState() bundle
   */
  public static void onSaveState(Bundle bundle) {

    Style[] list = new Style[ManagerSuperCardToast.getInstance().getList().size()];

    LinkedList<SuperCardToast> lister = ManagerSuperCardToast.getInstance().getList();

    for (int i = 0; i < list.length; i++) {

      list[i] = new Style(lister.get(i));
    }

    bundle.putParcelableArray(BUNDLE_TAG, list);

    SuperCardToast.cancelAllSuperCardToasts();
  }
コード例 #2
0
  /** 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);
    }
  }
コード例 #3
0
  /** 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);
    }
  }
コード例 #4
0
  /** Dismisses the SuperCardToast with an animation. */
  public void dismiss() {

    ManagerSuperCardToast.getInstance().remove(this);

    dismissWithAnimation();
  }
コード例 #5
0
  /** Dismisses and removes all showing/pending SuperCardToasts. */
  public static void cancelAllSuperCardToasts() {

    ManagerSuperCardToast.getInstance().clearQueue();
  }