List of usage examples for android.view Display getSize
public void getSize(Point outSize)
From source file:opensource.zeocompanion.ZeoCompanionApplication.java
public static void postToErrorLog(String method, Throwable theException, String extra, String threadName, boolean noAlert) { String eMsg = "Exception"; if (method != null) { if (!method.isEmpty()) { eMsg = eMsg + " in " + method; }/* w w w . j a v a 2 s. c o m*/ } if (threadName != null) { if (!threadName.isEmpty()) { eMsg = eMsg + " in Thread " + threadName; } } if (extra != null) { if (!extra.isEmpty()) { eMsg = eMsg + " (" + extra + ")"; } } eMsg = eMsg + ": " + theException.toString(); Log.e(_CTAG + ".postToErrorLog", eMsg); theException.printStackTrace(); int r = checkExternalStorage(); if (r != 0) { Log.e(_CTAG + ".postToErrorLog", "Cannot write to external storage code " + r); return; } FileWriter wrt = null; try { // pull the stack trace StackTraceElement[] traces = theException.getStackTrace(); // ensure the directory structure is present and compose the file name File internalsDir = new File(mBaseExtStorageDir + File.separator + "internals"); internalsDir.mkdirs(); File errLogFile = new File(internalsDir + File.separator + "error.log"); // create and append to the file wrt = new FileWriter(errLogFile, true); // append if file already exists wrt.write(new Date().toString() + "\n"); if (threadName != null) { if (!threadName.isEmpty()) { wrt.write(" in Thread " + threadName + " "); } } wrt.write("AppVerName " + BuildConfig.VERSION_NAME + " AppVerCode " + BuildConfig.VERSION_CODE); if (mDatabaseHandler != null) { wrt.write(" with DBver " + mDatabaseHandler.mVersion); } wrt.write("\n"); if (mZeoAppHandler != null) { if (mZeoAppHandler.mZeoApp_versionName == null) { wrt.write("Zeo App not installed\n"); } else { wrt.write("Zeo App version " + mZeoAppHandler.mZeoApp_versionName + " build " + mZeoAppHandler.mZeoApp_versionCode + "\n"); } } wrt.write("Android Version " + android.os.Build.VERSION.RELEASE + " API " + android.os.Build.VERSION.SDK_INT + "\n"); wrt.write("Platform Manf " + Build.MANUFACTURER + " Model " + Build.MODEL + "\n"); WindowManager windowManager = (WindowManager) mApp.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point screenSize = new Point(); display.getSize(screenSize); wrt.write("Platform Screen Orientation X,Y " + screenSize.x + "," + screenSize.y + ", Density=" + mScreenDensity + "\n"); if (method != null) { if (!method.isEmpty()) { wrt.write(method + "\n"); } } if (extra != null) { if (!extra.isEmpty()) { wrt.write(extra + "\n"); } } wrt.write(theException.toString() + "\n"); for (StackTraceElement st : traces) { wrt.write(st.toString() + "\n"); } wrt.write("=====\n"); wrt.write("=====\n"); wrt.flush(); wrt.close(); // force it to be shown and post an alert forceShowOnPC(errLogFile); if (!noAlert) { postAlert("An abort occured; details are in \'internals/error.log\'; contact the Developer"); } // noAlert is only needed when an Alert itself was being posted to the database and it failed to post // must send the toast indirectly in case this is being called from a utility thread Message msg = new Message(); msg.what = ZeoCompanionApplication.MESSAGE_APP_SEND_TOAST; msg.obj = "Abort successfully logged to \'internals/error.log\'"; mAppHandler.sendMessage(msg); } catch (Exception e) { if (wrt != null) { try { wrt.close(); } catch (Exception ignored) { } } Log.e(_CTAG + ".postToErrLog", "Cannot write to error.log: " + e.toString()); e.printStackTrace(); } }
From source file:com.itime.team.itime.fragments.QRCodeFragment.java
@NonNull @Override// w ww .ja v a 2 s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.fragment_profile_qrcode); ImageView imageView = (ImageView) dialog.findViewById(R.id.setting_profile_qrcode_img); final Bundle arguments = getArguments(); if (!arguments.isEmpty()) { mUserId = arguments.getString(QRCODE_STRING); } Bitmap qrCodeBitmap; // method1: change a fix dip to pixel //final int dim = DensityUtil.dip2px(getContext(), 600); // method2: get the display size and scale into 7/8 // This assumes the view is full screen, which is a good assumption WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point displaySize = new Point(); display.getSize(displaySize); int width = displaySize.x; int height = displaySize.y; int smallerDimension = width < height ? width : height; final int dim = smallerDimension * 7 / 8; try { qrCodeBitmap = barcodeEncoder.encodeBitmap(mUserId, BarcodeFormat.QR_CODE, dim, dim); imageView.setImageBitmap(qrCodeBitmap); } catch (WriterException e) { Toast.makeText(getActivity(), "QRCode text can not be empty", Toast.LENGTH_SHORT).show(); } return dialog; }
From source file:com.pimp.instincts.adapters.GalleryAdapter.java
public GalleryAdapter(Context context, ArrayList<String> imagesList) { this.context = context; this.imagesList = imagesList; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x;/* ww w.j a v a 2s .co m*/ }
From source file:com.uob.achohan.hdr.HDR.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWL = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.FULL_WAKE_LOCK, "WakeLock"); mWL.acquire();// ww w. ja v a 2 s.co m setContentView(R.layout.main); Display display = getWindowManager().getDefaultDisplay(); Point displayDim = new Point(); display.getSize(displayDim); final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); final ListView navList = (ListView) findViewById(R.id.drawer); List<DrawerItem> dataList = new ArrayList<DrawerItem>(); dataList.add(new DrawerItem("HDR", new String[] { "On", "Off" })); CustomDrawerAdapter adapter = new CustomDrawerAdapter(this, R.layout.custom_drawer_item, dataList); navList.setAdapter(adapter); navList.setOnItemClickListener(new ListView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } }); drawer.closeDrawer(navList); } }); mView = (MyGLSurfaceView) findViewById(R.id.surfaceviewclass); mView.setDisplayDim(displayDim); }
From source file:be.ac.ucl.lfsab1509.bouboule.MyLevelFragment.java
private Point getDisplayVector() { Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size;//from ww w . j a v a2 s . c o m }
From source file:com.fallahpoor.infocenter.fragments.ScreenFragment.java
private ArrayList<String> getSubItemsArrayList() { ArrayList<String> subItems = new ArrayList<>(); Point displaySize = new Point(); DisplayMetrics displayMetrics = new DisplayMetrics(); Display display = getActivity().getWindowManager().getDefaultDisplay(); display.getSize(displaySize); display.getMetrics(displayMetrics);/*from www. j a v a2s.c o m*/ subItems.add(getDisplaySize(displaySize)); subItems.add(getOrientation(displaySize)); subItems.add(getRefreshRate(display)); subItems.add(getDpi(displayMetrics)); subItems.add(getHorizontalDpi(displayMetrics)); subItems.add(getVerticalDpi(displayMetrics)); return subItems; }
From source file:com.klinker.android.launcher.addons.settings.page_picker.PagePickerActivity.java
public void setUpWindow() { //requestWindowFeature(Window.FEATURE_ACTION_BAR); getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Params for the window. // You can easily set the alpha and the dim behind the window from here WindowManager.LayoutParams params = getWindow().getAttributes(); params.alpha = 1.0f; // lower than one makes it more transparent params.dimAmount = .87f; // set it higher if you want to dim behind the window getWindow().setAttributes(params);/*from w w w.j a va2 s . c o m*/ // Gets the display size so that you can set the window to a percent of that Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; // You could also easily used an integer value from the shared preferences to set the percent if (height > width) { getWindow().setLayout((int) (width * .85), (int) (height * .7)); } else { getWindow().setLayout((int) (width * .5), (int) (height * .8)); } }
From source file:com.gm.goldencity.util.Utils.java
/** * Get Display Width//from w ww.j av a2s.com * * @param context Application context * @return */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") public static int getDisplayWidth(Context context) { Activity activity = (Activity) context; if (Integer.valueOf(Build.VERSION.SDK_INT) < 13) { Display display = activity.getWindowManager().getDefaultDisplay(); return display.getWidth(); } else { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size.x; } }
From source file:com.gm.goldencity.util.Utils.java
/** * Get display height/* w ww. ja v a 2 s. c o m*/ * * @param context Application context * @return */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") public static int getDisplayHeight(Context context) { Activity activity = (Activity) context; if (Integer.valueOf(Build.VERSION.SDK_INT) < 13) { Display display = activity.getWindowManager().getDefaultDisplay(); return display.getHeight(); } else { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size.y; } }
From source file:com.klinker.android.twitter.ui.tweet_viewer.users_popup.ViewUsersPopup.java
public void setUpWindow() { requestWindowFeature(Window.FEATURE_ACTION_BAR); getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Params for the window. // You can easily set the alpha and the dim behind the window from here WindowManager.LayoutParams params = getWindow().getAttributes(); params.alpha = 1.0f; // lower than one makes it more transparent params.dimAmount = .75f; // set it higher if you want to dim behind the window getWindow().setAttributes(params);/*w ww .j a v a 2 s. c om*/ // Gets the display size so that you can set the window to a percent of that Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; // You could also easily used an integer value from the shared preferences to set the percent if (height > width) { getWindow().setLayout((int) (width * .9), (int) (height * .8)); } else { getWindow().setLayout((int) (width * .7), (int) (height * .8)); } }