コード例 #1
0
  /**
   * Write the wishlist passed as a parameter to the wishlist file
   *
   * @param mCtx A context to open the file and pop toasts with
   * @param lWishlist The wishlist to write to the file
   */
  private static void WriteWishlist(Context mCtx, ArrayList<MtgCard> lWishlist) {
    try {
      FileOutputStream fos = mCtx.openFileOutput(WISHLIST_NAME, Context.MODE_PRIVATE);

      for (MtgCard m : lWishlist) {
        fos.write(m.toWishlistString().getBytes());
      }

      fos.close();
    } catch (IOException e) {
      ToastWrapper.makeText(mCtx, e.getLocalizedMessage(), ToastWrapper.LENGTH_LONG).show();
    }
  }
コード例 #2
0
  /**
   * Write the wishlist passed as a parameter to the wishlist file
   *
   * @param mCtx A context to open the file and pop toasts with
   * @param mCompressedWishlist The wishlist to write to the file
   */
  public static void WriteCompressedWishlist(
      Context mCtx, ArrayList<CompressedWishlistInfo> mCompressedWishlist) {
    try {
      FileOutputStream fos = mCtx.openFileOutput(WISHLIST_NAME, Context.MODE_PRIVATE);

      /* For each compressed card, make an MtgCard and write it to the wishlist */
      for (CompressedWishlistInfo cwi : mCompressedWishlist) {
        MtgCard card = cwi.mCard;
        for (IndividualSetInfo isi : cwi.mInfo) {
          card.set = isi.mSet;
          card.setCode = isi.mSetCode;
          card.number = isi.mNumber;
          card.foil = isi.mIsFoil;
          card.numberOf = isi.mNumberOf;
          fos.write(card.toWishlistString().getBytes());
        }
      }

      fos.close();
    } catch (IOException e) {
      ToastWrapper.makeText(mCtx, e.getLocalizedMessage(), ToastWrapper.LENGTH_LONG).show();
    }
  }