Exemplo n.º 1
0
  @Override
  public synchronized void setMax(int max) {
    super.setMax(max);

    if ((mKeyProgressIncrement == 0) || (getMax() / mKeyProgressIncrement > 20)) {
      // It will take the user too long to change this via keys, change it
      // to something more reasonable
      setKeyProgressIncrement(Math.max(1, Math.round((float) getMax() / 20)));
    }
  }
Exemplo n.º 2
0
 @Override
 protected synchronized void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   if (mThumb != null) {
     canvas.save();
     // Translate the padding. For the x, we need to allow the thumb to
     // draw in its extra space
     canvas.translate(mPaddingLeft, mPaddingTop - mThumbOffset);
     mThumb.draw(canvas);
     canvas.restore();
   }
 }
Exemplo n.º 3
0
  @Override
  protected void drawableStateChanged() {
    super.drawableStateChanged();

    Drawable progressDrawable = getProgressDrawable();
    if (progressDrawable != null) {
      progressDrawable.setAlpha(isEnabled() ? NO_ALPHA : (int) (NO_ALPHA * mDisabledAlpha));
    }

    if (mThumb != null && mThumb.isStateful()) {
      int[] state = getDrawableState();
      mThumb.setState(state);
    }
  }
  // *************************      Initialize Question       *********************************
  private void initQuestion() {
    Log.i("fullCClassName", className);
    if (numberOfQuestionsRemaining < 1) {
      Intent intent = new Intent(NegativeCoordActivity.this, ResultActivity.class);
      intent.putExtra("Score", scoreTotal);
      intent.putExtra("ClassName", className);
      intent.putExtra("Level", 3);
      startActivity(intent);
      finish();
    } else {

      if (firstQuestion == false) {
        numberOfQuestionsRemaining--;

        Random randScore = new Random();
        int low = 0;
        int high = 0;
        if (seconds <= 5) {
          low = 40;
          high = 50;
        }
        if (seconds > 5 && seconds <= 7) {
          low = 30;
          high = 40;
        }
        if (seconds > 7) {
          low = 10;
          high = 30;
        }
        score = randScore.nextInt(high - low + 1) + low;
        scoreTotal = scoreTotal + score;
        scoreText.setText(Integer.toString(score));
        scoreText.startAnimation(scoreTextAnimmation);
        timerHandler.removeCallbacks(timerRunnable);
      }
      firstQuestion = false;
      seconds = 0;
      timerHandler.postDelayed(timerRunnable, 0);

      ProgressBarAnimation anim =
          new ProgressBarAnimation(scoreBar, scoreBar.getProgress(), scoreTotal);
      anim.setDuration(300);
      scoreBar.startAnimation(anim);

      if (STAR_ONE_ENABLED == 0) {
        if (scoreBar.getProgress() >= (scoreBar.getMax() / 2)) {
          StarView star1 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starOne.getWidth(), starOne.getHeight()),
                  starOne);
          scoreLayout.addView(star1);
          star1.translateAndShine(new ImageView(this));
          STAR_ONE_ENABLED = 1;
        }
      }
      if (STAR_TWO_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.7) - scoreBar.getMax())) {
          StarView star2 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starTwo.getWidth(), starTwo.getHeight()),
                  starTwo);
          scoreLayout.addView(star2);
          star2.translateAndShine(new ImageView(this));
          STAR_TWO_ENABLED = 1;
        }
      }
      if (STAR_THREE_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.8) - scoreBar.getMax())) {
          StarView star3 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starThree.getWidth(), starThree.getHeight()),
                  starThree);
          scoreLayout.addView(star3);
          star3.translateAndShine(new ImageView(this));
          STAR_THREE_ENABLED = 1;
        }
      }
      // *****  Type of Question  *****

      // Init question
      Random random = new Random();
      int randomCoordX = random.nextInt(8) - 4;
      int randomCoordY = random.nextInt(8) - 4;
      question = new QuestionCoord(randomCoordX, randomCoordY);

      // Move Lines
      if (numberOfQuestionsRemaining > (numberOfQuestions / 2)) {
        marker.setVisibility(View.INVISIBLE);

        // Positive
        questionCoordX.setText(question.getxString());
        questionCoordY.setText(question.getyString());

        currentLineXcoord = 0;
        currentLineYcoord = 0;
        setLinePositions(glv);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");

      }
      // Drag Number Panels Positive
      else {
        if (numberOfQuestionsRemaining == (numberOfQuestions / 2)) {
          gridLayout.removeView(lineX);
          gridLayout.removeView(lineY);

          questionCoordX.setText("x");
          questionCoordY.setText("y");

          initNumberPadAndAnswePanel();
          initSwitches();
        }

        marker.setVisibility(View.INVISIBLE);

        // Match x&y to question x&y
        AxisX x = null;
        AxisY y = null;
        for (int i = 0; i < glv.getAxisXlines().size(); i++) {
          if (glv.getAxisXlines().get(i).xNumber == question.getXNumber()) {
            x = glv.getAxisXlines().get(i);
          }
          if (glv.getAxisYlines().get(i).yNumber == question.getYNumber()) {
            y = glv.getAxisYlines().get(i);
          }
        }
        marker.setX(((int) x.x) - marker.getWidth() / 2);
        marker.setY(((int) y.y) - marker.getHeight() / 2);
        scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f);
        scaleIn.setDuration(300);
        scaleIn.setStartOffset(200);
        scaleIn.setInterpolator(new OvershootInterpolator());
        scaleIn.setFillAfter(true);
        scaleIn.setAnimationListener(
            new AnimationListener() {
              @Override
              public void onAnimationEnd(Animation arg0) {}

              @Override
              public void onAnimationRepeat(Animation animation) {}

              @Override
              public void onAnimationStart(Animation animation) {
                marker.setVisibility(View.VISIBLE);
              }
            });
        marker.startAnimation(scaleIn);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");
      }
    }
  }