List of usage examples for android.util DisplayMetrics DENSITY_MEDIUM
int DENSITY_MEDIUM
To view the source code for android.util DisplayMetrics DENSITY_MEDIUM.
Click Source Link
From source file:com.lendingtree.view.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(mTitleRes);//from ww w.j a v a2 s. c om // 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:org.mozilla.fennec_satyanarayan.LauncherShortcuts.java
public void onListItemClick(int id) { HashMap<String, String> map = mWebappsList.get(id); String uri = map.get("uri").toString(); String title = map.get("title").toString(); String appKey = map.get("appKey").toString(); String favicon = map.get("favicon").toString(); File manifestFile = new File(mWebappsFolder, appKey + "/manifest.json"); // Parse the contents into a string String manifestJson = new String(); try {//from w w w .j a v a 2 s . c o m BufferedReader in = new BufferedReader(new FileReader(manifestFile)); String line = new String(); while ((line = in.readLine()) != null) { manifestJson += line; } } catch (IOException e) { } try { JSONObject manifest = (JSONObject) new JSONTokener(manifestJson).nextValue(); uri += manifest.getString("launch_path"); } catch (JSONException e) { } Intent shortcutintent = new Intent("org.mozilla.gecko.WEBAPP"); shortcutintent.setClass(this, App.class); shortcutintent.putExtra("args", "--webapp=" + uri); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutintent); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int size; switch (dm.densityDpi) { case DisplayMetrics.DENSITY_MEDIUM: size = 48; break; case DisplayMetrics.DENSITY_HIGH: size = 72; break; default: size = 72; } Bitmap bitmap = BitmapFactory.decodeFile(favicon); if (bitmap != null) { Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, size, size, true); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, scaledBitmap); } // Now, return the result to the launcher setResult(RESULT_OK, intent); finish(); }
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; }//from w w w . j a va2s .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 ww w. j a v a 2 s . c o m 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:com.landenlabs.all_devtool.ScreenFragment.java
void updateView() { m_displayMetrics = Utils.getDisplayMetrics(m_context); m_layout = Ui.viewById(m_rootView, R.id.screen_layout); m_screenDevice = Ui.viewById(m_rootView, R.id.screen_device); TextView screenSizeText = Ui.viewById(m_rootView, R.id.screen_size); TextView screenDensityText = Ui.viewById(m_rootView, R.id.screen_density); m_screenDevice.setText(Build.MODEL); int widthPx = m_displayMetrics.widthPixels; int heightPx = m_displayMetrics.heightPixels; String sizeStr = String.format(Locale.getDefault(), "%.0f dp x %.0f dp\n%d px x %d px\n%.1f in x %.1f in", Utils.pxToDp(widthPx), Utils.pxToDp(heightPx), widthPx, heightPx, (float) widthPx / m_displayMetrics.densityDpi, (float) heightPx / m_displayMetrics.densityDpi); screenSizeText.setText(sizeStr);/*w ww . ja va 2 s .co m*/ String densityStr = "Low"; if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_MEDIUM) densityStr = "Medium"; else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) densityStr = "High"; else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_XHIGH) densityStr = "x-High"; else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_XXHIGH) densityStr = "xx-High"; else if (m_displayMetrics.densityDpi > DisplayMetrics.DENSITY_XXHIGH) densityStr = "xxx-High"; screenDensityText.setText(String.format("Density %s(%d) px/dp=%.2f", densityStr, m_displayMetrics.densityDpi, m_displayMetrics.density)); m_horzWindowArrow = Ui.viewById(m_rootView, R.id.horz_arrow); m_vertPanelArrow = Ui.viewById(m_rootView, R.id.vert_panel_arrow); m_horzWindowText = Ui.viewById(m_rootView, R.id.horz_arrow_text); m_vertPanelText = Ui.viewById(m_rootView, R.id.vert_panel_text); TextView themeTv = Ui.viewById(m_rootView, R.id.theme); // themeTv.setRotation(-90); String themeName = GlobalInfo.s_globalInfo.themeName; if (!themeName.equals("Theme.Holo")) themeName = themeName + "\nBest with Theme.Halo"; themeTv.setText(themeName); /* * Dynamically get theme - always returns 'AppTheme' which is set in style try { PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(GlobalInfo.s_globalInfo.pkgName, 0); int themeResId = packageInfo.applicationInfo.theme; String themeName = getResources().getResourceEntryName(themeResId); themeTv.setText(themeName); } catch (Exception ex) { themeTv.setVisibility(View.GONE); } */ Message msgObj = m_handler.obtainMessage(MSG_GET_UI_SIZE); m_handler.sendMessageDelayed(msgObj, 1000); final TextView touchPos = Ui.viewById(m_rootView, R.id.touch_pos); m_drawPoints = Ui.viewById(m_rootView, R.id.drawPoints); m_drawPoints.setOnTouchInfo(new DrawView.TouchInfo() { public void onTouchInfo(MotionEvent event) { touchPos.setText(String.format("%.0f,%.0f", event.getX(), event.getY())); } }); }
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 w w w .jav a 2 s . c om*/ return "unknown"; } }
From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java
/** * The screen density expressed as dpi//from w w w. j a va 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 . j a v a2s.co m 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; }
From source file:watch.oms.omswatch.application.OMSApplication.java
/** * Checks if the device is a tablet or a phone * /*from w w w . j a v a 2s. 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"); }// w ww .j ava2 s . c om 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)); } } }