Пример #1
0
 @Test
 public void shouldSetCustomTitle() {
   CustomTitleActivity activity = create(CustomTitleActivity.class);
   assertThat(activity.customTitleText).isNotNull();
   assertThat(activity.customTitleText.getText().toString())
       .isEqualTo(activity.getString(R.string.hello));
 }
  @Override
  protected void onResume() {
    super.onResume();
    LinearLayout layout = (LinearLayout) findViewById(R.id.layoutAchievements);
    layout.removeAllViews();
    // List<PlayerAchievementInfo> playerAchievements =
    // Arrays.asList(MNDirect.getAchievementsProvider().getPlayerAchievementsList());
    // MNDirect.getAchievementsProvider().getAchievementImageURL(id);
    List<GameAchievementInfo> achievements =
        Arrays.asList(MNDirect.getAchievementsProvider().getGameAchievementsList());

    for (GameAchievementInfo achievement : achievements) {
      String textToSet =
          "ID"
              + String.valueOf(achievement.id)
              + "   "
              + achievement.name
              + "   "
              + String.valueOf(achievement.points);
      TextView txtAchievement = new TextView(this);
      txtAchievement.setText(textToSet);
      layout.addView(txtAchievement);
    }
    layout.invalidate();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.post_virtual_items);

    Button btnUpload = (Button) findViewById(R.id.btnUpload);
    btnUpload.setOnClickListener(this);

    txtResult = (TextView) findViewById(R.id.txtResult);

    Button btnBack = (Button) findViewById(R.id.btnBack);
    btnBack.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            finish();
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.achievement_home);

    // set the breadcrumbs text
    TextView txtBreadCrumbs = (TextView) findViewById(R.id.txtBreadCrumbs);
    txtBreadCrumbs.setText("Home > Achievements");

    Button btnLeaderboard = (Button) findViewById(R.id.btnUnlockAchievement);
    btnLeaderboard.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent =
                new Intent(AchievementsHomeActivity.this, PostAchievementActivity.class);
            startActivity(intent);
          }
        });
  }
 @Override
 protected void onResume() {
   super.onResume();
   MNDirectUIHelper.setHostActivity(this);
 }
 @Override
 protected void onPause() {
   super.onPause();
   MNDirectUIHelper.setHostActivity(null);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.buy_items);

    txtTitle = (TextView) findViewById(R.id.textView1);

    // Button btnUpload = (Button) findViewById(R.id.btnUpload);
    // btnUpload.setOnClickListener(this);

    MNDirect.getVItemsProvider()
        .addEventHandler(
            new MNVItemsProvider.EventHandlerAbstract() {
              public void onVItemsTransactionCompleted(TransactionInfo transaction) {
                // transaction succeeded, update the application
                Log.d(
                    "playphone", "Transaction " + transaction.clientTransactionId + " succeeded.");
                Message msg = new Message();
                Bundle bundle = new Bundle();
                bundle.putInt("updateField", R.id.textView1);
                msg.setData(bundle);
                BuyItemsActivity.this.handler.sendMessage(msg);
              }

              public void onVItemsTransactionFailed(TransactionError error) {

                // transaction failed, error contains client and server identifiers of the failed
                // transaction and the error message
              }
            });

    MNDirect.getVShopProvider()
        .addEventHandler(
            new MNVShopProvider.EventHandlerAbstract() {
              public void showDashboard() {
                // application-specific code which shows dashboard
                MNDirectUIHelper.showDashboard();
              }

              public void hideDashboard() {
                // application-specific code which hides dashboard
                MNDirectUIHelper.hideDashboard();
              }

              public void onCheckoutVShopPackSuccess(final CheckoutVShopPackSuccessInfo result) {
                // purchase operation finished successfully, details of transaction
                // can be accessed via result.getTransaction() call
                Log.d(
                    "playphone",
                    "Transaction "
                        + Long.toString(result.getTransaction().clientTransactionId)
                        + " finished");
                Message msg = new Message();
                Bundle bundle = new Bundle();
                bundle.putString("message", "Transaction successful, enjoy your items!");
                msg.setData(bundle);
                handler.sendMessage(msg);
              }

              public void onCheckoutVShopPackFail(final CheckoutVShopPackFailInfo result) {
                // purchase operation was not completed successfully
                if (result.getErrorCode() == ERROR_CODE_USER_CANCEL) {
                  Log.d("playphone", "Player cancelled operation");
                  Message msg = new Message();
                  Bundle bundle = new Bundle();
                  bundle.putString("message", "You successfully cancelled the transaction");
                  msg.setData(bundle);
                  handler.sendMessage(msg);
                } else {
                  Log.e(
                      "playphone",
                      "Purchase failed with error message " + result.getErrorMessage());
                  Message msg = new Message();
                  Bundle bundle = new Bundle();
                  bundle.putString(
                      "message",
                      "Purchase failed, please mention this error message: "
                          + result.getErrorMessage());
                  msg.setData(bundle);
                  handler.sendMessage(msg);
                }
              }
            });

    if (MNDirect.isUserLoggedIn()) updateGameItemsOnScreen();

    Button btnGetFreePotion = (Button) findViewById(R.id.btnGetFreePotion);
    btnGetFreePotion.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (MNDirect.isUserLoggedIn()) {
              if (MNDirect.getVItemsProvider().getPlayerVItemCountById(HEALTH_POTION) > 2) {
                Toast.makeText(
                        v.getContext(),
                        "You cannot get any more new potions, try buying some!",
                        Toast.LENGTH_SHORT)
                    .show();
                return;
              }
              MNDirect.getVItemsProvider()
                  .reqAddPlayerVItem(
                      HEALTH_POTION, 1, MNDirect.getVItemsProvider().getNewClientTransactionId());
              Toast.makeText(
                      v.getContext(), "Added a new potion to your inventory!", Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    Button btnUsePotion = (Button) findViewById(R.id.btnUsePotion);
    btnUsePotion.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (MNDirect.isUserLoggedIn()) {
              if (MNDirect.getVItemsProvider().getPlayerVItemCountById(HEALTH_POTION) == 0) {
                Toast.makeText(
                        v.getContext(), "You do not have any potions to use!", Toast.LENGTH_SHORT)
                    .show();
                return;
              }
              MNDirect.getVItemsProvider()
                  .reqAddPlayerVItem(
                      HEALTH_POTION, -1, MNDirect.getVItemsProvider().getNewClientTransactionId());
              Toast.makeText(v.getContext(), "You have just used a potion!", Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    Button btnBuy = (Button) findViewById(R.id.btnBuy);
    btnBuy.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (MNDirect.isUserLoggedIn()) {
              final int[] packs = {HEALTH_POTION_PACK};
              final int[] amounts = {1};

              MNDirect.getVShopProvider()
                  .execCheckoutVShopPacks(
                      packs, amounts, MNDirect.getVItemsProvider().getNewClientTransactionId());
              // Toast.makeText(v.getContext(), "You have just used a potion!",
              // Toast.LENGTH_SHORT).show();
            }
          }
        });

    Button btnBack = (Button) findViewById(R.id.btnBack);
    btnBack.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            finish();
          }
        });
  }