List of usage examples for android.util DisplayMetrics DENSITY_LOW
int DENSITY_LOW
To view the source code for android.util DisplayMetrics DENSITY_LOW.
Click Source Link
From source file:ly.count.android.sdk.DeviceInfo.java
/** * Maps the current display density to a string constant. * @param context context to use to retrieve the current display metrics * @return a string constant representing the current display density, or the * empty string if the density is unknown *//*from w w w . j a v a 2 s . c o m*/ static String getDensity(final Context context) { String densityStr = ""; final int density = context.getResources().getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: densityStr = "LDPI"; break; case DisplayMetrics.DENSITY_MEDIUM: densityStr = "MDPI"; break; case DisplayMetrics.DENSITY_TV: densityStr = "TVDPI"; break; case DisplayMetrics.DENSITY_HIGH: densityStr = "HDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_260: // densityStr = "XHDPI"; // break; case DisplayMetrics.DENSITY_280: densityStr = "XHDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_300: // densityStr = "XHDPI"; // break; case DisplayMetrics.DENSITY_XHIGH: densityStr = "XHDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_340: // densityStr = "XXHDPI"; // break; case DisplayMetrics.DENSITY_360: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_400: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_420: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_XXHIGH: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_560: densityStr = "XXXHDPI"; break; case DisplayMetrics.DENSITY_XXXHIGH: densityStr = "XXXHDPI"; break; default: densityStr = "other"; break; } return densityStr; }
From source file:com.iangclifton.auid.appendixc.sections.VariousDemosFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.various_demos, container, false); final StringBuilder sb = new StringBuilder(); // Create a String for the device physical size switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) { case Configuration.SCREENLAYOUT_SIZE_XLARGE: // Extra large (most 10" tablets) sb.append(getString(R.string.configuration_xlarge)); break;// ww w . j av a2 s.com case Configuration.SCREENLAYOUT_SIZE_LARGE: // Large (most 7" tablets) sb.append(getString(R.string.configuration_large)); break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: // Normal (most phones) sb.append(getString(R.string.configuration_normal)); break; case Configuration.SCREENLAYOUT_SIZE_SMALL: // Small (very uncommon) sb.append(getString(R.string.configuration_small)); break; default: sb.append(getString(R.string.configuration_unknown)); break; } sb.append('\n'); // Create a String for the display density switch (getResources().getDisplayMetrics().densityDpi) { case DisplayMetrics.DENSITY_XXHIGH: // Display is around 480 pixels per inch sb.append(getString(R.string.density_xxhdpi)); break; case DisplayMetrics.DENSITY_XHIGH: // Display is around 320 pixels per inch sb.append(getString(R.string.density_xhdpi)); break; case DisplayMetrics.DENSITY_HIGH: // Display is around 240 pixels per inch sb.append(getString(R.string.density_hdpi)); break; case DisplayMetrics.DENSITY_MEDIUM: // Display is around 160 pixels per inch sb.append(getString(R.string.density_mdpi)); break; case DisplayMetrics.DENSITY_LOW: // Display is around 120 pixels per inch sb.append(getString(R.string.density_ldpi)); break; case DisplayMetrics.DENSITY_TV: // Display is a 720p TV screen // Sometimes also used for 1280x720 7" tablets // Rarely should you ever specifically target this density sb.append(getString(R.string.density_tv)); break; default: sb.append(getString(R.string.density_unknown)); break; } sb.append('\n'); // Create a String for the thread we're on // Obviously this method is always called on the main thread but this technique can be used anywhere. if (Utils.isUiThread()) { // UI Thread sb.append(getString(R.string.main_thread_true)); } else { // Other Thread sb.append(getString(R.string.main_thread_false)); } sb.append(" (Thread name: ").append(Thread.currentThread().getName()).append(')'); // Set text final TextView tv = (TextView) rootView.findViewById(R.id.main_text); tv.setText(sb); return rootView; }
From source file:ly.count.android.api.DeviceInfoTests.java
public void testGetDensity() { Context mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_LOW); assertEquals("LDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_MEDIUM); assertEquals("MDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_TV); assertEquals("TVDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_HIGH); assertEquals("HDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XHIGH); assertEquals("XHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXHIGH); assertEquals("XXHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXXHIGH); assertEquals("XXXHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_400); assertEquals("XMHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(0); assertEquals("", DeviceInfo.getDensity(mockContext)); }
From source file:com.lendingtree.view.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(mTitleRes);/*from w w w. ja v a 2 s .co m*/ // set the Behind View setBehindContentView(R.layout.menu_frame); if (savedInstanceState == null) { FragmentTransaction t = this.getSupportFragmentManager().beginTransaction(); mFrag = new SlidingMenuFragment(); t.replace(R.id.menu_frame, mFrag); t.commit(); } else { mFrag = (Fragment) this.getSupportFragmentManager().findFragmentById(R.id.menu_frame); } // Ramesh Gundala for Menu Icon showing ActionBar ab = getSupportActionBar(); ab.setHomeButtonEnabled(true); // ab.setDisplayHomeAsUpEnabled(true); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setFadeDegree(Constants.ZERO_POINT_THREE_FIVE); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: break; case DisplayMetrics.DENSITY_MEDIUM: sm.setTouchmodeMarginThreshold(Constants.SIXTY); break; case DisplayMetrics.DENSITY_HIGH: sm.setTouchmodeMarginThreshold(Constants.SIXTY); break; case DisplayMetrics.DENSITY_XHIGH: sm.setTouchmodeMarginThreshold(Constants.EIGHTY); break; case DisplayMetrics.DENSITY_XXHIGH: sm.setTouchmodeMarginThreshold(Constants.HUNDRED); break; default: sm.setTouchmodeMarginThreshold(Constants.SIXTY); } onStartCount = 1; if (savedInstanceState == null) // 1st time { if (sliding) { this.overridePendingTransition(0, 0); } else { this.overridePendingTransition(R.anim.anim_slide_in_left, R.anim.anim_slide_out_left); } } else // already created so reverse animation { onStartCount = 2; } // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // getSupportActionBar().setDisplayShowHomeEnabled(false); }
From source file:com.adjust.sdk.Util.java
private static String getScreenDensity(final DisplayMetrics displayMetrics) { final int density = displayMetrics.densityDpi; final int low = (DisplayMetrics.DENSITY_MEDIUM + DisplayMetrics.DENSITY_LOW) / 2; final int high = (DisplayMetrics.DENSITY_MEDIUM + DisplayMetrics.DENSITY_HIGH) / 2; if (0 == density) { return UNKNOWN; } else if (density < low) { return LOW; } else if (density > high) { return HIGH; }/* w ww . ja v a 2s . c o m*/ return MEDIUM; }
From source file:eu.inmite.apps.smsjizdenka.fragment.TicketsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { vList = (ListView) view.findViewById(android.R.id.list); vTopHelp = view.findViewById(R.id.top_help); vBottomHelp = view.findViewById(R.id.bottom_help); vBuy = (Button) view.findViewById(R.id.buy); vEmpty = view.findViewById(android.R.id.empty); vProgress = view.findViewById(android.R.id.progress); vList.setEmptyView(vEmpty);//from w w w . jav a 2s . com showProgress(); vList.setVisibility(View.GONE); if (mShowAnimation) { vList.setLayoutAnimation( new LayoutAnimationController(AnimationUtils.loadAnimation(c, android.R.anim.slide_in_left))); } vList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { collapseUncollapseTicket(id, false); } }); vBuy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(CitiesActivity.class); } }); vSwipeDismissList = new SwipeDismissList(vList, callback, SwipeDismissList.UndoMode.COLLAPSED_UNDO); vSwipeDismissList.setUndoString(c.getString(R.string.tickets_ticket_deleted)); vSwipeDismissList.setUndoMultipleString(c.getString(R.string.tickets_tickets_deleted)); // first launch animations int dpi = getResources().getDisplayMetrics().densityDpi; if (mShowAnimation && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && dpi != DisplayMetrics.DENSITY_LOW && dpi != DisplayMetrics.DENSITY_MEDIUM) { AnimationUtil.addAnimationToView(vTopHelp, R.anim.slide_in_top); AnimationUtil.addAnimationToView(vBottomHelp, R.anim.slide_in_bottom); } mShowAnimation = false; //SL.get(AnalyticsService.class).trackScreen("my-tickets"); }
From source file:org.apps8os.logger.android.manager.AppManager.java
/** * Check if the device has the smaller screen, such as HTC Widefire, etc. * //w w w . j a v a2s .co m * @param context * @return */ public static final boolean isLowDensityDevice(Context context) { return (context.getResources().getDisplayMetrics().widthPixels <= 300) && (context.getResources().getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_LOW); }
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 . co m*/ return "unknown"; } }
From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java
/** * The screen density expressed as dpi/*from w w w . j av a 2 s . c o m*/ * * @return int * * @return May be either DENSITY_LOW, DENSITY_MEDIUM, or DENSITY_HIGH. */ protected int getScreenDensity() { int screenDensity = 0; try { getWindowManager().getDefaultDisplay().getMetrics(metrics); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: PhrescoLogger.info(TAG + "DENSITY_LOW"); break; case DisplayMetrics.DENSITY_MEDIUM: PhrescoLogger.info(TAG + "DENSITY_MEDIUM"); break; case DisplayMetrics.DENSITY_HIGH: PhrescoLogger.info(TAG + "DENSITY_HIGH"); break; case DisplayMetrics.DENSITY_XHIGH: PhrescoLogger.info(TAG + "DENSITY_EXTRA_HIGH"); break; } PhrescoLogger.info(TAG + "densityDpi: " + metrics.densityDpi); PhrescoLogger.info(TAG + "density: " + metrics.density); PhrescoLogger.info(TAG + "heightPixels: " + metrics.heightPixels); PhrescoLogger.info(TAG + "widthPixels: " + metrics.widthPixels); screenDensity = metrics.densityDpi; } catch (Exception ex) { PhrescoLogger.info(TAG + "getScreenDensity: Exception: " + ex.toString()); PhrescoLogger.warning(ex); } return screenDensity; }
From source file:dentex.youtube.downloader.YTD.java
private double detectScreenDensity() { DisplayMetrics displayMetrics = new DisplayMetrics(); ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(displayMetrics); double rf = 1; int density = displayMetrics.densityDpi; switch (density) { case DisplayMetrics.DENSITY_HIGH: rf = 1.44;/*from ww w. jav a2 s . com*/ break; case DisplayMetrics.DENSITY_MEDIUM: rf = 2; break; case DisplayMetrics.DENSITY_LOW: rf = 3; } Log.d(DEBUG_TAG, "DispalyDensity: " + density + " - storing a REDUCE_FACTOR of " + rf + " into prefs"); settings.edit().putString("REDUCE_FACTOR", String.valueOf(rf)).apply(); ; return rf; }