Example usage for android.util DisplayMetrics widthPixels

List of usage examples for android.util DisplayMetrics widthPixels

Introduction

In this page you can find the example usage for android.util DisplayMetrics widthPixels.

Prototype

int widthPixels

To view the source code for android.util DisplayMetrics widthPixels.

Click Source Link

Document

The absolute width of the available display size in pixels.

Usage

From source file:com.lt.adamlee.aagame.GameView.java

public GameView(Context context, AttributeSet attrs) {
    super(context, attrs);
    ctx = context;/*w  ww. j a v a2  s  .c om*/
    getHolder().addCallback(this);
    setFocusable(true);
    DisplayMetrics DisplayMetrics = new DisplayMetrics();
    DisplayMetrics = context.getResources().getDisplayMetrics();
    screenW = DisplayMetrics.widthPixels;
    screenH = DisplayMetrics.heightPixels;
    this.mainpageimage = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.mainpageimage);
    this.mainpageimage = Bitmap.createScaledBitmap(this.mainpageimage, screenW, screenH, true);
    this.play = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.play);
    this.play = Bitmap.createScaledBitmap(this.play, (int) F.wf(90.0f), (int) F.wf(90.0f), true);
    this.cartoonbomb = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.cartoonbomb);
    this.cartoonbomb = Bitmap.createScaledBitmap(this.cartoonbomb, (int) F.hf(20.0f), (int) F.hf(20.0f), true);
    this.leaderboard = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.leaderboard);
    this.leaderboard = Bitmap.createScaledBitmap(this.leaderboard, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.moreapps = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.moreapps);
    this.moreapps = Bitmap.createScaledBitmap(this.moreapps, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.help = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.help);
    this.help = Bitmap.createScaledBitmap(this.help, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.about = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.about);
    this.about = Bitmap.createScaledBitmap(this.about, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.localAd = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.addimagebottom);
    view = new Circle();
    paint2 = new Paint();
    paint3 = new Paint();
    paint4 = new Paint();
    paint5 = new Paint();
    paint6 = new Paint();
    paint7 = new Paint();
    paint13 = new Paint();
    this.paint10 = new Paint();
    this.level = new LevelPage();
    circledrawboolean = new boolean[100];
    this.innercircletext = new Paint();
    this.innercircletext.setColor(-1);
    this.textsizetext = 10.0f;
    this.innercircletext.setTextSize(F.hf(this.textsizetext));
    this.innercircletext.setTypeface(tf);
    this.innercircletext.setTextAlign(Paint.Align.CENTER);
    this.innercircletext.setAntiAlias(true);
    this.innercircletext.setFilterBitmap(true);
    this.p9 = new Paint();
    this.paint20 = new Paint();
    this.paint21 = new Paint();
    this.pp = new Paint();
    this.eg = new ExitGame();
    paint4.setColor(ViewCompat.MEASURED_STATE_MASK);
    paint4.setAntiAlias(true);
    paint4.setFilterBitmap(true);
    paint4.setPathEffect(new DashPathEffect(new float[] { 30.0f, 0.0f }, 0.0f));
    paint4.setStrokeWidth(2.0f);
    paint4.setColor(ViewCompat.MEASURED_STATE_MASK);
    paint3.setColor(ViewCompat.MEASURED_STATE_MASK);
    paint3.setAntiAlias(true);
    paint3.setFilterBitmap(true);
    counter = 0;
    linecounter = -1;
    blinedraw = new boolean[100];
    blinedraw1 = new boolean[100];
    circleanimation = new boolean[100];
    savex = new int[100];
    savey = new int[100];
    rotation = new float[100];
    textsize = 20;
    a2 = 1200;
    tf = Typeface.createFromAsset(ctx.getAssets(), "Russo_One.ttf");
    textsize4 = 20;
    this.paint21.setTextSize(F.hf((float) textsize4));
    paint2.setTextSize(F.hf((float) textsize));
    textsize = 25;
    tf = Typeface.createFromAsset(ctx.getAssets(), "Russo_One.ttf");
    paint6.setTextSize(F.hf((float) textsize));
    this.textsize3 = 22;
    tf = Typeface.createFromAsset(ctx.getAssets(), "Russo_One.ttf");
    this.pp.setTextSize(F.hf((float) this.textsize3));
    a1 = MotionEventCompat.ACTION_MASK;
    changeangle = 2.0d;
    this.directioncounter = 1;
    NoOfInitialLines = 6;
    holdcounter = 0;
    hcm = 0;
    this.anim = new Levelfailedanimation();
    levelcounter = 1;
    textdisplayboolean = true;
    if (levelcounter > 0 && levelcounter < 4) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 3 && levelcounter < 7) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 6 && levelcounter < 10) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 9 && levelcounter < 13) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 12 && levelcounter < 16) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 15 && levelcounter < 19) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 18 && levelcounter < 22) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 21 && levelcounter < 25) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 24 && levelcounter < 28) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 27 && levelcounter < 31) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 30 && levelcounter < 34) {
        NoOfInitialLines = 1;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 33 && levelcounter < 37) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 36 && levelcounter < 40) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 39 && levelcounter < 43) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 42 && levelcounter < 46) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 45 && levelcounter < 49) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 48 && levelcounter < 52) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 51 && levelcounter < 55) {
        NoOfInitialLines = 7;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 54 && levelcounter < 58) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 57 && levelcounter < 61) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 606 && levelcounter < 64) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 63 && levelcounter < 67) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 66 && levelcounter < 70) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 69 && levelcounter < 73) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 72 && levelcounter < 76) {
        NoOfInitialLines = 9;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 75 && levelcounter < 79) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 78 && levelcounter < 82) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 81 && levelcounter < 85) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 84 && levelcounter < 88) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 87 && levelcounter < 91) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 90 && levelcounter < 94) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 93 && levelcounter < 97) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 96 && levelcounter < 101) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 100 && levelcounter < 105) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 104 && levelcounter < 108) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 107 && levelcounter < 111) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 110 && levelcounter < 114) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 113 && levelcounter < 117) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 116 && levelcounter < 121) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 120 && levelcounter < 124) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 123 && levelcounter < TransportMediator.KEYCODE_MEDIA_PAUSE) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > TransportMediator.KEYCODE_MEDIA_PLAY && levelcounter < 131) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > TransportMediator.KEYCODE_MEDIA_RECORD && levelcounter < 134) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 133 && levelcounter < 137) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 136 && levelcounter < 140) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 139 && levelcounter < 144) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 143 && levelcounter < 146) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 146 && levelcounter < 151) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 150 && levelcounter < 155) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 154 && levelcounter < 158) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 157 && levelcounter < 161) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 160 && levelcounter < 164) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 163 && levelcounter < 167) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 166 && levelcounter < 171) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 170 && levelcounter < 174) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 173 && levelcounter < 177) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 176 && levelcounter < 180) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 179 && levelcounter < 184) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 183 && levelcounter < 187) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 186 && levelcounter < 191) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 190 && levelcounter < 194) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 193 && levelcounter < 197) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 196 && levelcounter < 202) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
}