Code example for Resources

Methods: getConfigurationgetDisplayMetrics

0
    } 
 
    private void initializeSlop(Context context) {
        if (sScaledTouchSlop == -1) {
            final Resources res = context.getResources();
            final Configuration config = res.getConfiguration();
            final float density = res.getDisplayMetrics().density;
            final float sizeAndDensity;
            // TODO Pre Honeycomb devices will FC on the second condition, hence 
            // the addition of the first. Not quite sure how this 
            // code now treats pre-Honecomb large screen devices (like the fire) 
            // but it probably isn't good. Need a way to safely determine 
            // screen size. 
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
                    && config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
                sizeAndDensity = density * 1.5f;
            } else { 
                sizeAndDensity = density;
            } 
            sScaledTouchSlop = (int)(sizeAndDensity * TOUCH_SLOP + 0.5f);
        }