Example usage for android.content.res Resources getSystem

List of usage examples for android.content.res Resources getSystem

Introduction

In this page you can find the example usage for android.content.res Resources getSystem.

Prototype

public static Resources getSystem() 

Source Link

Document

Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).

Usage

From source file:Main.java

/**
 * Returns a density independent pixel value rounded to the nearest integer
 * for the desired dimension./*from w  w w .  j a v  a2 s .  c o  m*/
 *
 * @param pixels The pixel value to be converted
 * @return A rounded DIP value
 */
public static int convertToDIP(int pixels) {
    return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, pixels,
            Resources.getSystem().getDisplayMetrics()));
}

From source file:com.mindorks.framework.mvp.utils.ViewUtils.java

public static int dpToPx(float dp) {
    float density = Resources.getSystem().getDisplayMetrics().density;
    return Math.round(dp * density);
}

From source file:Main.java

public static float pxFromDp(float dp) {
    return dp * Resources.getSystem().getDisplayMetrics().density;
}

From source file:Main.java

public static float dpFromPx(float px) {
    return px / Resources.getSystem().getDisplayMetrics().density;
}

From source file:com.calgen.udacity.lego.ui.Utils.java

/**
 * @param dp dp value//from   w ww  .ja va 2s. c o  m
 * @return converted px value
 */
public static int dpToPx(int dp) {
    DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
    return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
}

From source file:Main.java

private static String getDetailedAmPm(int i) {
    if (sAmPmIndex == null) {
        sAmPmIndex = new int[24];
        int ai[] = Resources.getSystem().getIntArray(0x606000a);
        int j = 23;
        for (int k = -1 + ai.length; j >= 0 && k >= 0; j--) {
            if (j < ai[k])
                k--;//from ww  w .j a v  a 2 s  .co  m
            sAmPmIndex[j] = k;
        }

    }
    return Resources.getSystem().getStringArray(0x606000b)[sAmPmIndex[i]];
}

From source file:com.calgen.udacity.lego.ui.Utils.java

/**
 * @param px dp value//from ww  w.ja va 2  s .c  o m
 * @return converted dp value
 */

public static int pxToDp(int px) {
    DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
    return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
}

From source file:com.oxapps.materialcountdown.view.CircularIconImageView.java

public static float convertDpToPixel(float dp) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    float px = dp * (metrics.densityDpi / 160f);
    return Math.round(px);
}

From source file:ru.tinkoff.acquiring.sdk.views.KeyView.java

private static float dpToPx(float px) {
    return px * Resources.getSystem().getDisplayMetrics().density;
}

From source file:com.landenlabs.flipanimation.Ui.java

/**
 * @return Convert dp to px, return px//from w  w  w  . ja  v  a2s.  co  m
 */
public static float dpToPx(int dp) {
    return (dp * Resources.getSystem().getDisplayMetrics().density);
}