Пример #1
0
  public void showThemeMenu() {
    final ThemeManager themes = game.getThemeManager();
    String[] themeMenuLabels = themes.getAvailableThemeLabels();
    Integer[] themeMenuIcons = themes.getAvailableThemeIconImageIDs();

    ListAdapter adapter =
        new ArrayAdapterWithIcons(
            this, android.R.layout.select_dialog_singlechoice, themeMenuLabels, themeMenuIcons);

    AlertDialog.Builder builder = getDialog(this);
    builder.setTitle("Themes Options");
    builder.setPositiveButton("OK", null);
    builder.setSingleChoiceItems(
        adapter,
        themes.getCurrentThemeID(),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int item) {
            Log.d(LOGGER, "Theme Selected: " + item);
            if (themes.isAvailable(item)) {
              themes.setTheme(item);
            } else {
              purchaseItem(themes.getSkuForTheme(item));
            }
          }
        });
    builder.show();
  }
Пример #2
0
 @Override
 public void onIabPurchaseFinished(IabResult result, Purchase info) {
   ThemeManager themes = game.getThemeManager();
   if (result.isFailure()) {
     Log.e(LOGGER, "Purchase failed: " + result);
     Toast.makeText(this, "In-App Purchase Failed or was cancelled.", Toast.LENGTH_LONG).show();
   } else if (RANDOM_BOT_SKU.equals(info.getSku())) {
     Log.d(LOGGER, "Purchase of RandomBot succeeded.");
     purchaseRandomBot();
   } else if (themes.purchaseTheme(info.getSku())) {
     Log.d(LOGGER, "Theme Purchased");
   }
 }
Пример #3
0
  public void testGetImage() {
    Balloon testBalloon = new Balloon(1000, 1000, -1, 0);

    assertTrue(
        "Test Failure: Balloon Image is not consistent with theme",
        theme.getBalloon(0).equals(testBalloon.getImage(theme)));
  }
Пример #4
0
  public void testGetImageWhenPopped() {
    Balloon testBalloon = new Balloon(1000, 1000, -1, 0);

    testBalloon.popped = true;

    assertTrue(
        "Test Failure: Popped Image is not consistent with theme",
        theme.getPoppedBalloon(0).equals(testBalloon.getImage(theme)));
  }
Пример #5
0
  @Override
  public void onQueryInventoryFinished(IabResult result, Inventory inv) {
    if (result.isSuccess()) {
      Log.d(LOGGER, "In app purchases query complete" + result);

      boolean randomBotPurchaseCheck = inv.hasPurchase(RANDOM_BOT_SKU);

      if (randomBotPurchaseCheck && !randomBotPurchased) {
        Log.d(LOGGER, "RandomBot Purchase Imported");
        purchaseRandomBot();
      } else if (!randomBotPurchaseCheck && randomBotPurchased) {
        Log.d(LOGGER, "RandomBot Refund Imported");
        refundRandomBot();
      }

      final ThemeManager themes = game.getThemeManager();
      themes.importPurchases(inv);
    } else {
      Log.e(LOGGER, "In app purchases could not be verified.");
    }
  }