Пример #1
0
 public void setCards(Card[] cards) {
   client.setCard1(cards[0]);
   client.setCard2(cards[1]);
   final ImageView cardContainer1 = (ImageView) findViewById(R.id.card1);
   final ImageView cardContainer2 = (ImageView) findViewById(R.id.card2);
   deal(cardContainer1, cardContainer2);
 }
Пример #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // client = PokerClient.getInstance();
    // client.sendHello();
    pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl =
        pm.newWakeLock(
            PowerManager.SCREEN_DIM_WAKE_LOCK, "be.infogroep.justpoker.ServerTableActivity");
    wl.acquire();

    android_id = Secure.getString(getBaseContext().getContentResolver(), Secure.ANDROID_ID);

    Intent incomingIntent = getIntent();
    String ip = incomingIntent.getStringExtra("ip");
    String name = incomingIntent.getStringExtra("name");
    setTitle("justPoker - " + name);

    flippedCard1 = flippedCard2 = false;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tap_test);

    ((TextView) findViewById(R.id.info_area)).setMovementMethod(new ScrollingMovementMethod());

    getActionBar().setDisplayHomeAsUpEnabled(true);
    cardContainer1 = (ImageView) findViewById(R.id.card1);
    cardContainer2 = (ImageView) findViewById(R.id.card2);
    initialCards(cardContainer1, cardContainer2);
    final ImageView betChip = (ImageView) findViewById(R.id.betChip);
    // final TextView betChipText = (TextView)
    // findViewById(R.id.betChipText);

    client =
        PokerClient.getInstance(
            TapTestActivity.this, name, android_id, ip, cardContainer1, cardContainer2);

    OnFlingGestureListener cardListener =
        new OnFlingGestureListener() {
          private boolean longPressed = false;

          @Override
          public void onBottomToTop() {
            client.fold(cardContainer1, cardContainer2);
          }

          @Override
          public void onDoubletap() {
            client.check(cardContainer1, cardContainer2);
          }

          @Override
          public void onLongpress() {
            if (client.inGame()) {
              cardContainer1.setImageDrawable(getDrawable(client.getCard1().toString()));
              cardContainer2.setImageDrawable(getDrawable(client.getCard2().toString()));
              longPressed = true;
            }
          }

          public void onTouchevent(MotionEvent e) {
            if (longPressed && e.getAction() == MotionEvent.ACTION_UP) {
              cardContainer1.setImageResource(R.drawable.card_backside);
              cardContainer2.setImageResource(R.drawable.card_backside);
              longPressed = false;
            }
          }
        };
    OnFlingGestureListener chipListener =
        new OnFlingGestureListener() {
          @Override
          public void onBottomToTop() {
            client.bet();
          }

          @Override
          public void onDoubletap() {
            client.bet();
          }
        };

    cardContainer2.setOnTouchListener(cardListener);
    cardContainer1.setOnTouchListener(cardListener);
    betChip.setOnTouchListener(chipListener);
    checkVoiceRecognition();
    // betChipText.setOnTouchListener(chipListener);

  }
Пример #3
0
  private void doDeal(final ImageView card, final ImageView card2) {
    final Animation myFadeInAnimation2 = AnimationUtils.loadAnimation(this, R.anim.dealcards);
    myFadeInAnimation2.setAnimationListener(
        new AnimationListener() {
          public void onAnimationEnd(Animation animation) {}

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationStart(Animation animation) {
            card2.setImageDrawable(getDrawable("card_backside"));
          }
        });
    // myFadeInAnimation2.setFillAfter(true);

    final Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.dealcards);
    myFadeInAnimation.setAnimationListener(
        new AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            card2.startAnimation(myFadeInAnimation2);
          }

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationStart(Animation animation) {
            card.setImageDrawable(getDrawable("card_backside"));
          }
        });
    Animation myFoldInAnimation = AnimationUtils.loadAnimation(this, R.anim.foldcards);
    final Animation myFoldInAnimation2 = AnimationUtils.loadAnimation(this, R.anim.foldcards);
    myFoldInAnimation.setAnimationListener(
        new AnimationListener() {

          public void onAnimationStart(Animation animation) {}

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationEnd(Animation animation) {
            card.setImageDrawable(null);
            card2.startAnimation(myFoldInAnimation2);
          }
        });
    myFoldInAnimation2.setAnimationListener(
        new AnimationListener() {

          public void onAnimationStart(Animation animation) {}

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationEnd(Animation animation) {
            card2.setImageDrawable(null);
            card.startAnimation(myFadeInAnimation);
          }
        });

    if (client.getState() == PlayerState.Fold || client.getState() == PlayerState.Unknown) {
      card.startAnimation(myFadeInAnimation);
    } else {
      card.startAnimation(myFoldInAnimation);
    }
    // myFadeInAnimation.setFillAfter(true);
  }
Пример #4
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE)

      // If Voice recognition is successful then it returns RESULT_OK
      if (resultCode == RESULT_OK) {

        ArrayList<String> textMatchList =
            data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        if (!textMatchList.isEmpty()) {
          // If first Match contains the 'search' word
          // Then start web search.
          if (textMatchList.get(0).contains("search")) {

            String searchQuery = textMatchList.get(0);
            searchQuery = searchQuery.replace("search", "");
            Intent search = new Intent(Intent.ACTION_WEB_SEARCH);
            search.putExtra(SearchManager.QUERY, searchQuery);
            startActivity(search);
          } else {
            Iterator<String> iter = textMatchList.iterator();
            while (iter.hasNext()) {
              // Toast.makeText(this, iter.next(), Toast.LENGTH_SHORT).show();
              String result = iter.next();
              if (voiceCheck(result, CHECK_OPTIONS)) {
                client.check(cardContainer1, cardContainer2);
                break;
              } else if (voiceCheck(result, FOLD_OPTIONS)) {
                client.fold(cardContainer1, cardContainer2);
                break;
              } else if (voiceCheck(result, BET_OPTIONS)) {
                client.bet();
                break;
              } else if (voiceCheck(result, CALL_OPTIONS)) {
                client.check(cardContainer1, cardContainer2);
                break;
              } else if (voiceCheck(result, RAISE_OPTIONS)) {
                client.bet();
                break;
              } else if (voiceCheck(result, ALLIN_OPTIONS)) {
                client.bet();
                break;
              }
            }
          }
        }
        // Result code for various error.
      } else if (resultCode == RecognizerIntent.RESULT_AUDIO_ERROR) {
        Toast.makeText(this, "Audio Error", Toast.LENGTH_SHORT).show();
      } else if (resultCode == RecognizerIntent.RESULT_CLIENT_ERROR) {
        Toast.makeText(this, "Client Error", Toast.LENGTH_SHORT).show();
      } else if (resultCode == RecognizerIntent.RESULT_NETWORK_ERROR) {
        Toast.makeText(this, "Network Error", Toast.LENGTH_SHORT).show();
      } else if (resultCode == RecognizerIntent.RESULT_NO_MATCH) {
        Toast.makeText(this, "No Match", Toast.LENGTH_SHORT).show();
      } else if (resultCode == RecognizerIntent.RESULT_SERVER_ERROR) {
        Toast.makeText(this, "Server Error", Toast.LENGTH_SHORT).show();
      }
    super.onActivityResult(requestCode, resultCode, data);
  }