Android Open Source - DroidSweeper Field Drawables






From Project

Back to project page DroidSweeper.

License

The source code is released under:

MIT License

If you think the Android project DroidSweeper 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 de.nisble.droidsweeper.gui.grid;
//w  w w .  j  a va  2s.com
import de.nisble.droidsweeper.R;
import de.nisble.droidsweeper.game.jni.FieldStatus;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;

/** Class that holds images for the {@link FieldView}.
 * @author Moritz Nisbl moritz.nisble@gmx.de */
public class FieldDrawables {
  // private static final String CLASSNAME =
  // FieldDrawables.class.getSimpleName();

  private static final Drawable[] mImages = new Drawable[13];

  /** Load standard {@link FieldView} theme.
   * @param context Application context. */
  public static void loadGrayback(Context context) {
    Resources res = context.getResources();

    mImages[0] = res.getDrawable(R.drawable.empty_grayback_round_1);
    mImages[1] = res.getDrawable(R.drawable.n1_grayback_round_1);
    mImages[2] = res.getDrawable(R.drawable.n2_grayback_round_1);
    mImages[3] = res.getDrawable(R.drawable.n3_grayback_round_1);
    mImages[4] = res.getDrawable(R.drawable.n4_grayback_round_1);
    mImages[5] = res.getDrawable(R.drawable.n5_grayback_round_1);
    mImages[6] = res.getDrawable(R.drawable.n6_grayback_round_1);
    mImages[7] = res.getDrawable(R.drawable.n7_grayback_round_1);
    mImages[8] = res.getDrawable(R.drawable.n8_grayback_round_1);

    mImages[9] = res.getDrawable(R.drawable.unpushed_grayback_round_1);
    mImages[10] = res.getDrawable(R.drawable.bang_grayback_round_1);
    mImages[11] = res.getDrawable(R.drawable.query_grayback_round_1);
    mImages[12] = res.getDrawable(R.drawable.pushedbomb_grayback_round_1);
  }

  /** Get an image corresponding to a specific {@link FieldStatus}.
   * If {@link FieldStatus#UNHIDDEN} is passed, the adjacentBombs argument
   * specifies the number shown on the revealed field.
   * @param status The field status.
   * @param adjacentBombs The count of adjacent bombs.
   * @return A Drawable. */
  public static Drawable getDrawable(FieldStatus status, int adjacentBombs) {
    switch (status) {
    case HIDDEN:
      return mImages[9];
    case UNHIDDEN:
      return mImages[adjacentBombs];
    case MARKED:
      return mImages[10];
    case QUERIED:
      return mImages[11];
    case BOMB:
      return mImages[12];
    default:
      return mImages[9];
    }
  }
}




Java Source Code List

de.nisble.droidsweeper.config.ApplicationConfig.java
de.nisble.droidsweeper.config.Constants.java
de.nisble.droidsweeper.config.GameConfig.java
de.nisble.droidsweeper.config.Level.java
de.nisble.droidsweeper.game.Field.java
de.nisble.droidsweeper.game.GameObserver.java
de.nisble.droidsweeper.game.Game.java
de.nisble.droidsweeper.game.Position.java
de.nisble.droidsweeper.game.database.DSDBAdapter.java
de.nisble.droidsweeper.game.database.DSDBContract.java
de.nisble.droidsweeper.game.database.DSDBGameEntry.java
de.nisble.droidsweeper.game.database.DSDBHelper.java
de.nisble.droidsweeper.game.jni.FieldListener.java
de.nisble.droidsweeper.game.jni.FieldStatus.java
de.nisble.droidsweeper.game.jni.GameStatus.java
de.nisble.droidsweeper.game.jni.MatrixObserver.java
de.nisble.droidsweeper.game.jni.MineSweeperMatrix.java
de.nisble.droidsweeper.game.replay.PlayerObserver.java
de.nisble.droidsweeper.game.replay.Player.java
de.nisble.droidsweeper.game.replay.Recorder.java
de.nisble.droidsweeper.game.replay.Replay.java
de.nisble.droidsweeper.game.replay.TimeStep.java
de.nisble.droidsweeper.gui.DroidSweeperActivity.java
de.nisble.droidsweeper.gui.HighScoreActivity.java
de.nisble.droidsweeper.gui.HighScoreListAdapter.java
de.nisble.droidsweeper.gui.SettingsActivity.java
de.nisble.droidsweeper.gui.grid.FieldDrawables.java
de.nisble.droidsweeper.gui.grid.FieldView.java
de.nisble.droidsweeper.gui.grid.GameGridView.java
de.nisble.droidsweeper.utilities.LogDog.java
de.nisble.droidsweeper.utilities.Timer.java