コード例 #1
0
  /**
   * Check if there was an out of memory error, and if so, display a corresponding message.
   *
   * @param activity the triggering activity
   */
  public static void checkOutOfMemoryError(@NonNull final Activity activity) {
    boolean hadOutOfMemoryError =
        PreferenceUtil.getSharedPreferenceBoolean(R.string.key_internal_outofmemoryerror);

    if (hadOutOfMemoryError) {
      displayError(activity, R.string.message_dialog_outofmemoryerror, false);

      PreferenceUtil.setSharedPreferenceBoolean(R.string.key_internal_outofmemoryerror, false);
    }
  }
コード例 #2
0
  /**
   * Display a tip.
   *
   * @param activity the triggering activity
   * @param titleResource The resource containing the title.
   * @param iconResource The resource containing the icon.
   * @param messageResource The resource containing the text of the tip.
   * @param preferenceResource The resource for the key of the preference storing the information if
   *     the tip should be skipped later.
   */
  private static void displayTip(
      @NonNull final Activity activity,
      final int titleResource,
      final int iconResource,
      final int messageResource,
      final int preferenceResource) {
    String message = activity.getString(messageResource);

    boolean skip = PreferenceUtil.getSharedPreferenceBoolean(preferenceResource);

    if (!skip) {
      Bundle bundle = new Bundle();
      bundle.putString(PARAM_TITLE, activity.getString(titleResource));
      bundle.putInt(PARAM_ICON, iconResource);
      bundle.putString(PARAM_MESSAGE, message);
      bundle.putInt(PARAM_PREFERENCE_KEY, preferenceResource);

      DisplayTipFragment fragment = new DisplayTipFragment();
      fragment.setArguments(bundle);
      fragment.show(activity.getFragmentManager(), DisplayTipFragment.class.toString());
    }
  }