예제 #1
2
  /**
   * Returns and shows pending/shown SuperCardToasts from orientation change and reattaches any
   * OnToastButtonClickListeners and any OnToastDismissListeners. <br>
   * IMPORTANT: Use this method to save OnToastButtonClickListeners and OnToastDismissListenerHolder
   * on devices with API < 11. Otherwise use onRestoreState(Bundle bundle, Activity activity) as
   * that method uses a retained fragment to save listeners. <br>
   *
   * @param bundle Use onCreate() bundle
   * @param activity The current activity
   * @param onToastButtonClickListeners List of any attached OnToastButtonClickListenerHolders from
   *     previous orientation
   * @param onToastDismissListeners List of any attached OnToastDismissListenerHolders from previous
   *     orientation
   */
  public static void onRestoreState(
      Bundle bundle,
      Activity activity,
      List<OnToastButtonClickListenerHolder> onToastButtonClickListeners,
      List<OnToastDismissListenerHolder> onToastDismissListeners) {

    if (bundle == null) {

      return;
    }

    Parcelable[] savedArray = bundle.getParcelableArray(BUNDLE_TAG);

    int i = 0;

    if (savedArray != null) {

      for (Parcelable parcelable : savedArray) {

        i++;

        new SuperCardToast(
            activity, (Style) parcelable, onToastButtonClickListeners, onToastDismissListeners, i);
      }
    }
  }
예제 #2
0
  /**
   * Returns and shows pending/shown SuperCardToasts from orientation change. <br>
   * IMPORTANT: On devices > API 11 this method will automatically save any OnClickListeners and
   * OnDismissListeners via retained Fragment. <br>
   *
   * @param bundle Use onCreate() bundle
   * @param activity The current activity
   */
  public static void onRestoreState(Bundle bundle, Activity activity) {

    if (bundle == null) {

      return;
    }

    Parcelable[] savedArray = bundle.getParcelableArray(BUNDLE_TAG);

    int i = 0;

    if (savedArray != null) {

      for (Parcelable parcelable : savedArray) {

        i++;

        new SuperCardToast(activity, (Style) parcelable, null, null, i);
      }
    }
  }