Android Open Source - DemiGod Pixel Unit Converter






From Project

Back to project page DemiGod.

License

The source code is released under:

GNU General Public License

If you think the Android project DemiGod 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 high.caliber.productions.demigod.utils;
//ww  w  .  jav  a2s .  c o  m
import android.content.Context;
import android.util.DisplayMetrics;
import android.util.TypedValue;

public class PixelUnitConverter {

  Context context;
  DisplayMetrics displayMetrics;

  public PixelUnitConverter(Context context) {
    this.context = context;
    this.displayMetrics = context.getResources().getDisplayMetrics();
  }

  public int dpToPx(int dp) {
    int valueInDp = (int) TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources()
            .getDisplayMetrics());
    return valueInDp;
  }

  public int pxToDp(int px) {
    int valueInDp = (int) TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_PX, px, context.getResources()
            .getDisplayMetrics());
    return valueInDp;
  }

}




Java Source Code List

high.caliber.productions.demigod.Enemy.java
high.caliber.productions.demigod.Hero.java
high.caliber.productions.demigod.Item.java
high.caliber.productions.demigod.Map.java
high.caliber.productions.demigod.Tile.java
high.caliber.productions.demigod.XmlActivityTest.java
high.caliber.productions.demigod.activity.BattleLog.java
high.caliber.productions.demigod.activity.Battle_Activity.java
high.caliber.productions.demigod.activity.CreateHero.java
high.caliber.productions.demigod.activity.HomeTown.java
high.caliber.productions.demigod.activity.Home.java
high.caliber.productions.demigod.activity.Inventory.java
high.caliber.productions.demigod.activity.Status.java
high.caliber.productions.demigod.activity.TitleScreen.java
high.caliber.productions.demigod.database.EnemyDB.java
high.caliber.productions.demigod.database.HeroDB.java
high.caliber.productions.demigod.database.ItemDB.java
high.caliber.productions.demigod.settings.DpadPosition.java
high.caliber.productions.demigod.settings.DpadSizePref.java
high.caliber.productions.demigod.settings.SettingsMain.java
high.caliber.productions.demigod.utils.AnimationUtils.java
high.caliber.productions.demigod.utils.InventoryAdapter.java
high.caliber.productions.demigod.utils.LevelUpWorker.java
high.caliber.productions.demigod.utils.PixelUnitConverter.java
high.caliber.productions.demigod.utils.SharedPrefsManager.java
high.caliber.productions.demigod.utils.XmlMapAdapter.java