Android Open Source - FallingBall Results View






From Project

Back to project page FallingBall.

License

The source code is released under:

GNU General Public License

If you think the Android project FallingBall listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.fmi.android.brickpong.view;
//from  ww w  .  j a v a2  s .  com
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class ResultsView extends View {

  /**
   * {@value}
   */
  private static final String TEXT_SCORE = "Score: ";

  /**
   * {@value}
   */
  private static final int SIZE_TEXT = 16;

  /**
   * {@value}
   */
  private static final int RESULTS_Y = 20;

  /**
   * {@value}
   */
  private static final int RESULTS_X = 10;

  private final Paint resultsPaint;

  private int result;

  public ResultsView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    resultsPaint = new Paint();
    resultsPaint.setColor(Color.WHITE);
    resultsPaint.setTextSize(SIZE_TEXT);
  }

  public ResultsView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
  }

  public ResultsView(Context context) {
    this(context, null);
  }

  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawText(getScoreText(), RESULTS_X, RESULTS_Y, resultsPaint);
  }

  public void updateResult() {
    ++result;
  }

  private String getScoreText() {
    return TEXT_SCORE + Integer.toString(result);
  }

}




Java Source Code List

edu.fmi.android.brickpong.GameActivity.java
edu.fmi.android.brickpong.GameItem.java
edu.fmi.android.brickpong.HomeActivity.java
edu.fmi.android.brickpong.SplashActivity.java
edu.fmi.android.brickpong.listeners.OnGameEventsListener.java
edu.fmi.android.brickpong.listeners.OnPositionChangedListener.java
edu.fmi.android.brickpong.utils.Direction.java
edu.fmi.android.brickpong.utils.ScreenUtil.java
edu.fmi.android.brickpong.utils.Vector.java
edu.fmi.android.brickpong.view.BallView.java
edu.fmi.android.brickpong.view.BorderView.java
edu.fmi.android.brickpong.view.CellView.java
edu.fmi.android.brickpong.view.FinishedGameView.java
edu.fmi.android.brickpong.view.GameLayout.java
edu.fmi.android.brickpong.view.PadView.java
edu.fmi.android.brickpong.view.ResultsView.java