Android Open Source - ssniper-andengine Device Util






From Project

Back to project page ssniper-andengine.

License

The source code is released under:

Apache License

If you think the Android project ssniper-andengine 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 com.cladophora.ssniper;
//from www.ja  v  a  2s.  c o m
import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
/**
 * Created by secusr on 1/25/14.
 */
public class DeviceUtil {
    public static String getScreenType(Context mContext) {
        try {
            final int densityDpi = mContext.getResources().getDisplayMetrics().densityDpi;
            switch (densityDpi) {
                case DisplayMetrics.DENSITY_LOW:
                    return "ldpi";
                case DisplayMetrics.DENSITY_MEDIUM:
                    return "mdpi";
                case DisplayMetrics.DENSITY_TV:
                    return "tv";
                case DisplayMetrics.DENSITY_HIGH:
                    return "hdpi";
                case DisplayMetrics.DENSITY_XHIGH:
                    return "xhdpi";
                case DisplayMetrics.DENSITY_XXHIGH:
                    return "xxhdpi";
                default:
                    return String.valueOf(densityDpi);
            }
        } catch (Throwable e) {
            return "unknown";
        }
    }

    public static int getWidth(final Activity a) {
        final Display display = a.getWindowManager().getDefaultDisplay();
        final Point size = new Point();
        display.getSize(size);
        return size.x;
    }

    public static int getHeight(final Activity a) {
        final Display display = a.getWindowManager().getDefaultDisplay();
        final Point size = new Point();
        display.getSize(size);
        return size.y;
    }
}




Java Source Code List

com.cladophora.ssniper.BaseActivity.java
com.cladophora.ssniper.DeviceUtil.java
com.cladophora.ssniper.EnemyPool.java
com.cladophora.ssniper.GameEffects.java
com.cladophora.ssniper.GameEvents.java
com.cladophora.ssniper.GameLoopUpdateHandler.java
com.cladophora.ssniper.GameUtil.java
com.cladophora.ssniper.HUDManager.java
com.cladophora.ssniper.HoverListener.java
com.cladophora.ssniper.ItemPool.java
com.cladophora.ssniper.LevelLoader.java
com.cladophora.ssniper.PlantPool.java
com.cladophora.ssniper.SPenHoverView.java
com.cladophora.ssniper.ScopeEngine.java
com.cladophora.ssniper.SoundManager.java
com.cladophora.ssniper.SpriteManager.java
com.cladophora.ssniper.andengine.IRandomTimerCallBack.java
com.cladophora.ssniper.andengine.RandomTimerHandler.java
com.cladophora.ssniper.entity.EnemyLayer.java
com.cladophora.ssniper.entity.Enemy.java
com.cladophora.ssniper.entity.ItemLayer.java
com.cladophora.ssniper.entity.Item.java
com.cladophora.ssniper.entity.PlantLayer.java
com.cladophora.ssniper.entity.Plant.java
com.cladophora.ssniper.entity.Reticle.java
com.cladophora.ssniper.entity.Rifle.java
com.cladophora.ssniper.entity.SPen.java
com.cladophora.ssniper.scene.GameScene.java
com.cladophora.ssniper.scene.InstructionScene.java
com.cladophora.ssniper.scene.IntroScene.java
com.cladophora.ssniper.scene.MainMenuScene.java
com.cladophora.ssniper.scene.PauseScene.java
com.cladophora.ssniper.scene.ResultScene.java
com.cladophora.ssniper.scene.ShopScene.java
com.cladophora.ssniper.scene.SplashScene.java
com.cladophora.ssniper.scene.SurvivorIntroScene.java
com.cladophora.ssniper.scene.SurvivorScene.java
com.cladophora.ssniper.scene.TutorialScene.java
com.cladophora.ssniper.scene.WeaponInfoScene.java