List of usage examples for android.util DisplayMetrics DENSITY_TV
int DENSITY_TV
To view the source code for android.util DisplayMetrics DENSITY_TV.
Click Source Link
From source file:com.actionbarsherlock.ActionBarSherlock.java
/** * Wrap an activity with an action bar abstraction which will enable the * use of a custom implementation on platforms where a native version does * not exist./*from w w w. j ava2 s .co m*/ * * @param activity Owning activity. * @param flags Option flags to control behavior. * @return Instance to interact with the action bar. */ public static ActionBarSherlock wrap(Activity activity, int flags) { //Create a local implementation map we can modify HashMap<Implementation, Class<? extends ActionBarSherlock>> impls = new HashMap<Implementation, Class<? extends ActionBarSherlock>>( IMPLEMENTATIONS); boolean hasQualfier; /* DPI FILTERING */ hasQualfier = false; for (Implementation key : impls.keySet()) { //Only honor TVDPI as a specific qualifier if (key.dpi() == DisplayMetrics.DENSITY_TV) { hasQualfier = true; break; } } if (hasQualfier) { final boolean isTvDpi = activity.getResources() .getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_TV; for (Iterator<Implementation> keys = impls.keySet().iterator(); keys.hasNext();) { int keyDpi = keys.next().dpi(); if ((isTvDpi && keyDpi != DisplayMetrics.DENSITY_TV) || (!isTvDpi && keyDpi == DisplayMetrics.DENSITY_TV)) { keys.remove(); } } } /* API FILTERING */ hasQualfier = false; for (Implementation key : impls.keySet()) { if (key.api() != Implementation.DEFAULT_API) { hasQualfier = true; break; } } if (hasQualfier) { final int runtimeApi = Build.VERSION.SDK_INT; int bestApi = 0; for (Iterator<Implementation> keys = impls.keySet().iterator(); keys.hasNext();) { int keyApi = keys.next().api(); if (keyApi > runtimeApi) { keys.remove(); } else if (keyApi > bestApi) { bestApi = keyApi; } } for (Iterator<Implementation> keys = impls.keySet().iterator(); keys.hasNext();) { if (keys.next().api() != bestApi) { keys.remove(); } } } if (impls.size() > 1) { throw new IllegalStateException("More than one implementation matches configuration."); } if (impls.isEmpty()) { throw new IllegalStateException("No implementations match configuration."); } Class<? extends ActionBarSherlock> impl = impls.values().iterator().next(); if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); try { Constructor<? extends ActionBarSherlock> ctor = impl.getConstructor(CONSTRUCTOR_ARGS); return ctor.newInstance(activity, flags); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java
private static String getDensityString(DisplayMetrics displayMetrics) { switch (displayMetrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: return "ldpi"; case DisplayMetrics.DENSITY_MEDIUM: return "mdpi"; case DisplayMetrics.DENSITY_HIGH: return "hdpi"; case DisplayMetrics.DENSITY_XHIGH: return "xhdpi"; case DisplayMetrics.DENSITY_XXHIGH: return "xxhdpi"; case DisplayMetrics.DENSITY_XXXHIGH: return "xxxhdpi"; case DisplayMetrics.DENSITY_TV: return "tvdpi"; default://from ww w . j a v a2 s . c o m return "unknown"; } }
From source file:watch.oms.omswatch.application.OMSApplication.java
/** * Checks if the device is a tablet or a phone * //w w w. ja va2 s.c o m * @param * * @return Returns true if the device is a Tablet */ public boolean isTabletDevice() { // Verifies if the Generalized Size of the device is XLARGE to be // considered a Tablet boolean xlarge = ((activity.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE); // If XLarge, checks if the Generalized Density is at least MDPI // (160dpi) if (xlarge) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); // MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160, // DENSITY_TV=213, DENSITY_XHIGH=320 if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM || metrics.densityDpi == DisplayMetrics.DENSITY_TV || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) { // Yes, this is a tablet! return true; } } return false; }
From source file:org.solovyev.android.calculator.ActivityUi.java
private void addHelpInfo(@Nonnull Activity activity, @Nonnull View root) { if (CalculatorApplication.isMonkeyRunner(activity)) { if (root instanceof ViewGroup) { final TextView helperTextView = new TextView(activity); final DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); helperTextView.setTextSize(15); helperTextView.setTextColor(Color.WHITE); final Configuration c = activity.getResources().getConfiguration(); final StringBuilder helpText = new StringBuilder(); helpText.append("Size: "); if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) { helpText.append("xlarge"); } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) { helpText.append("large"); } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) { helpText.append("normal"); } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) { helpText.append("small"); } else { helpText.append("unknown"); }/*from w w w. ja va 2 s. c o m*/ helpText.append(" (").append(dm.widthPixels).append("x").append(dm.heightPixels).append(")"); helpText.append(" Density: "); switch (dm.densityDpi) { case DisplayMetrics.DENSITY_LOW: helpText.append("ldpi"); break; case DisplayMetrics.DENSITY_MEDIUM: helpText.append("mdpi"); break; case DisplayMetrics.DENSITY_HIGH: helpText.append("hdpi"); break; case DisplayMetrics.DENSITY_XHIGH: helpText.append("xhdpi"); break; case DisplayMetrics.DENSITY_TV: helpText.append("tv"); break; } helpText.append(" (").append(dm.densityDpi).append(")"); helperTextView.setText(helpText); ((ViewGroup) root).addView(helperTextView, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } } }
From source file:com.linkbubble.util.Util.java
private static int getAlertIconDensityDpi(Context context) { if (sDensityDpi == null) { sDensityDpi = context.getResources().getDisplayMetrics().densityDpi; }//from w w w. ja va 2 s. co m switch (sDensityDpi) { case DisplayMetrics.DENSITY_LOW: case DisplayMetrics.DENSITY_MEDIUM: return DisplayMetrics.DENSITY_LOW; case DisplayMetrics.DENSITY_TV: case DisplayMetrics.DENSITY_HIGH: return DisplayMetrics.DENSITY_MEDIUM; case DisplayMetrics.DENSITY_XHIGH: return DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_XXHIGH: case DisplayMetrics.DENSITY_XXXHIGH: return DisplayMetrics.DENSITY_XHIGH; } return sDensityDpi; }