Example usage for android.content.res Resources getDimensionPixelSize

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

Introduction

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

Prototype

public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.

Usage

From source file:me.selinali.tribbble.utils.ViewUtils.java

private static int getInternalDimension(String name) {
    Resources res = TribbbleApp.context().getResources();
    int resId = res.getIdentifier(name, "dimen", "android");
    return resId != 0 ? res.getDimensionPixelSize(resId) : 0;
}

From source file:Main.java

public static int getStatusBarHeight(Context context) {
    int statusBarHeight = 0;
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = resources.getDimensionPixelSize(resourceId);
    }//from   w  w  w  .  j  a  v a2  s  . c om
    return statusBarHeight;
}

From source file:Main.java

public static int getStatusBarHeight(Context context) {
    Resources resources = context.getResources();

    int result = 0;
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = resources.getDimensionPixelSize(resourceId);
    }//from w  ww.j  av a2s  . c  o  m

    return result;
}

From source file:Main.java

/**
 * Get navigation bar height.//www  . ja v  a 2 s .  c  o m
 */
public static int getNavigationBarHeight(Context context) {
    if (hasNavigationBar(context)) {
        Resources resources = context.getResources();
        int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
    }
    return 0;
}

From source file:Main.java

@SuppressLint("NewApi")
public static int getNBarHeight(@NonNull Activity activity) {
    //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    //            DisplayMetrics metrics = new DisplayMetrics();
    //            activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    //            int usableHeight = metrics.heightPixels;
    //            activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
    //            int realHeight = metrics.heightPixels;
    //            if (realHeight > usableHeight)
    //                return realHeight - usableHeight;
    //            else
    //                return 0;
    //        }/*from  w w  w.  j  a va2s.co  m*/
    //        return 0;
    Resources resources = activity.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

From source file:Main.java

public static int getNavigationBarHeight(Context context) {
    int navigationBarHeight = 0;
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
    if (!hasBackKey && !hasHomeKey) {
        // 99% sure there is a navigation bar
        Resources resources = context.getResources();
        int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            navigationBarHeight = resources.getDimensionPixelSize(resourceId);
        }//  w  w  w. j a  v a2s .  c o  m
    }
    return navigationBarHeight;
}

From source file:com.achep.acdisplay.graphics.IconFactory.java

public static Bitmap generate(final @NonNull Context context, final @NonNull OpenNotification notification) {
    Resources res = context.getResources();

    int iconRes = notification.getNotification().icon;
    Drawable drawable = NotificationUtils.getDrawable(context, notification, iconRes);

    final int size = res.getDimensionPixelSize(R.dimen.notification_icon_size);
    return drawable == null ? createEmptyIcon(res, size) : createIcon(drawable, size);
}

From source file:com.bullmobi.message.graphics.IconFactory.java

public static Bitmap generate(final @NonNull Context context, final @NonNull OpenNotification notification) {
    final int iconRes = notification.getNotification().icon;
    String packageName = notification.getPackageName();
    String cacheKey = packageName + "<drawable>" + iconRes;

    // Check the cache before generating the new icon
    Bitmap bitmap = ICONS_CACHE.get(cacheKey);
    if (bitmap != null) {
        if (DEBUG)
            Log.d(TAG, "Got the icon of notification from cache: key=" + cacheKey);
        return bitmap;
    }//from  w  w  w.ja v a 2 s  .c o m

    Resources res = context.getResources();
    Drawable drawable = NotificationUtils.getDrawable(context, notification, iconRes);
    final int size = res.getDimensionPixelSize(R.dimen.notification_icon_size);
    if (drawable != null) {
        bitmap = createIcon(drawable, size);
        ICONS_CACHE.put(cacheKey, bitmap);
        if (DEBUG)
            Log.d(TAG, "Put the icon of notification to cache: key=" + cacheKey);
    } else {
        bitmap = createEmptyIcon(context, size);
    }

    return bitmap;
}

From source file:com.chromium.fontinstaller.util.ViewUtils.java

public static int getStatusBarHeight(Context context) {
    final Resources resources = context.getResources();
    final int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    return resourceId > 0 ? resources.getDimensionPixelSize(resourceId) : 0;
}

From source file:despotoski.nikola.github.com.bottomnavigationlayout.Util.java

public static int getNavigationBarHeight(Context context) {
    Resources res = context.getResources();
    int navBarIdentifier = res.getIdentifier("navigation_bar_height", "dimen", "android");
    int navBarHeight = 0;
    if (navBarIdentifier > 0) {
        navBarHeight = res.getDimensionPixelSize(navBarIdentifier);
    }//from w w  w . jav a 2s.  co  m
    return navBarHeight;
}