List of usage examples for android.view Display getHeight
@Deprecated public int getHeight()
From source file:mobisocial.musubi.social.QRInviteDialog.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Activity context = getActivity();//from w ww . j ava 2 s . c om getDialog().setTitle("Exchange Info"); // This assumes the view is full screen, which is a bad assumption WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); int smallerDimension = width < height ? width : height; Uri uri = EmailInviteActivity.getInvitationUrl(context); if (uri.getQueryParameter("n") == null) { Toast.makeText(getActivity(), "You must set up an account and a enter a name to connect with friends.", Toast.LENGTH_LONG).show(); dismiss(); return; } if (uri.getQueryParameter("t") == null) { dismiss(); Toast.makeText(getActivity(), "No identities to share", Toast.LENGTH_SHORT).show(); return; } Intent intent = new Intent(Intents.Encode.ACTION); intent.setClass(getActivity(), QRInviteDialog.class); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, uri.toString()); try { qrCodeEncoder = new QRCodeEncoder(context, intent, smallerDimension); //setTitle(getString(R.string.app_name) + " - " + qrCodeEncoder.getTitle()); Bitmap bitmap = qrCodeEncoder.encodeAsBitmap(); ImageView image = (ImageView) view.findViewById(R.id.image_view); image.setImageBitmap(bitmap); TextView contents = (TextView) view.findViewById(R.id.contents_text_view); contents.setText(qrCodeEncoder.getDisplayContents()); view.findViewById(R.id.ok_button).setOnClickListener(mCameraListener); } catch (WriterException e) { Log.e(TAG, "Could not encode barcode", e); showErrorMessage(R.string.msg_encode_contents_failed); qrCodeEncoder = null; } catch (IllegalArgumentException e) { Log.e(TAG, "Could not encode barcode", e); showErrorMessage(R.string.msg_encode_contents_failed); qrCodeEncoder = null; } }
From source file:com.drjane.promise.ui.fragment.CalendarFragment.java
private void initGridView() { // ??/*from ww w .ja va 2 s . c o m*/ WindowManager windowManager = getActivity().getWindowManager(); Display display = windowManager.getDefaultDisplay(); int Width = display.getWidth(); int Height = display.getHeight(); mGridView = new CustomGridView(getActivity()); mGridView.setNumColumns(7); mGridView.setColumnWidth(40); // gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); if (Width == 720 && Height == 1280) { mGridView.setColumnWidth(40); } mGridView.setGravity(Gravity.CENTER_VERTICAL); mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); // gridView mGridView.setVerticalSpacing(1); mGridView.setHorizontalSpacing(1); mHandler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub mGridView.setAdapter(calendarGridViewAdapter); } }); }
From source file:it.sasabz.android.sasabus.classes.dialogs.SelectFavoritenDialog.java
/** Called with the activity is first created. */ @Override//from w w w .j a v a2s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.favoriten_listview); this.setTitle(R.string.mode_favoriten); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; getWindow().setAttributes(lp); Display dm = getWindow().getWindowManager().getDefaultDisplay(); int width = dm.getWidth(); int height = dm.getHeight(); getWindow().setLayout(width / 5 * 4, height / 2); fillData(); }
From source file:de.akquinet.android.androlog.reporter.Report.java
/** * Adds the device data to the report./* w w w. j a va 2 s . c o m*/ * @param context * @throws JSONException if the device data cannot be added */ private void buildDeviceData(Context context) throws JSONException { device = new JSONObject(); device.put("device", Build.DEVICE); device.put("brand", Build.BRAND); Object windowService = context.getSystemService(Context.WINDOW_SERVICE); if (windowService instanceof WindowManager) { Display display = ((WindowManager) windowService).getDefaultDisplay(); device.put("resolution", display.getWidth() + "x" + display.getHeight()); device.put("orientation", display.getOrientation()); } device.put("display", Build.DISPLAY); device.put("manufacturer", Build.MANUFACTURER); device.put("model", Build.MODEL); device.put("product", Build.PRODUCT); device.put("build.type", Build.TYPE); device.put("android.version", Build.VERSION.SDK_INT); }
From source file:org.solovyev.android.calculator.floating.FloatingCalculatorService.java
private void createView() { if (view != null) { return;/*from w w w . j a v a 2s . c o m*/ } final WindowManager wm = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)); final DisplayMetrics dm = getResources().getDisplayMetrics(); final android.view.Display dd = wm.getDefaultDisplay(); //noinspection deprecation final int maxWidth = 2 * Math.min(dd.getWidth(), dd.getHeight()) / 3; final int desiredWidth = App.toPixels(dm, 300); final int width = Math.min(maxWidth, desiredWidth); final int height = getHeight(width); final FloatingCalculatorView.State state = new FloatingCalculatorView.State(width, height, -1, -1); view = new FloatingCalculatorView(this, state, this); view.show(); view.updateEditorState(editor.getState()); view.updateDisplayState(display.getState()); bus.register(this); preferences.registerOnSharedPreferenceChangeListener(this); }
From source file:com.example.examplescroll.MainActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void getDisplaySize(Point displaySize) { Display display = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(displaySize);/*from ww w. j a v a 2 s. c o m*/ } else { displaySize.x = display.getWidth(); displaySize.y = display.getHeight(); } }
From source file:com.javielinux.utils.PopupLinks.java
private void init(FragmentActivity activity) { this.activity = activity; Display display = activity.getWindowManager().getDefaultDisplay(); widthScreen = display.getWidth();//from w w w . j av a 2 s . c o m heightScreen = display.getHeight(); }
From source file:de.cellular.lib.lightlib.ui.fragment.LLRequestingFragment.java
protected void startRotate3dAnimationOut() { // Initialize the animations. Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();// w w w . jav a 2s. c om int h2 = display.getHeight() / 2; int w2 = display.getWidth() / 2; Rotate3dAnimation outAnim = new Rotate3dAnimation(0, 90, w2, h2, 0.0f, false); outAnim.setDuration(FLIP_ANIMATION_DURATION_OUT); outAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation _animation) { } @Override public void onAnimationRepeat(Animation _animation) { } @Override public void onAnimationEnd(Animation _animation) { if (getView() != null) getView().setVisibility(View.GONE); } }); Rotate3dAnimation inAnim = new Rotate3dAnimation(-90, 0, w2, h2, 0.0f, false); inAnim.setDuration(FLIP_ANIMATION_DURATION_IN); inAnim.setStartOffset(FLIP_ANIMATION_DURATION_OUT); inAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.decelerate_interpolator)); outAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.accelerate_interpolator)); if (getView() != null) getView().startAnimation(outAnim); }
From source file:de.cellular.lib.lightlib.ui.fragment.LLRequestingFragment.java
protected void startRotate3dAnimationIn() { // Initialize the animations. Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();/* ww w . j ava 2 s . com*/ int h2 = display.getHeight() / 2; int w2 = display.getWidth() / 2; Rotate3dAnimation outAnim = new Rotate3dAnimation(0, 90, w2, h2, 0.0f, false); outAnim.setDuration(FLIP_ANIMATION_DURATION_OUT); outAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation _animation) { } @Override public void onAnimationRepeat(Animation _animation) { } @Override public void onAnimationEnd(Animation _animation) { if (getView() != null) getView().setVisibility(View.VISIBLE); } }); Rotate3dAnimation inAnim = new Rotate3dAnimation(-90, 0, w2, h2, 0.0f, false); inAnim.setDuration(FLIP_ANIMATION_DURATION_IN); inAnim.setStartOffset(FLIP_ANIMATION_DURATION_OUT); inAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.decelerate_interpolator)); outAnim.setInterpolator( AnimationUtils.loadInterpolator(getActivity(), android.R.anim.accelerate_interpolator)); if (getView() != null) getView().startAnimation(inAnim); }
From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case SELECT_PICTURE: if (resultCode == RESULT_OK) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst();/*from w w w. ja v a2 s . c o m*/ int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); Bitmap bkgImg = BitmapFactory.decodeFile(filePath); Display disp = getWindowManager().getDefaultDisplay(); int w = disp.getWidth(); int h = disp.getHeight(); double scaleX = (w * 1.0) / bkgImg.getWidth(); double scaleY = (h * 1.0) / bkgImg.getHeight(); double scale = Math.min(scaleX, scaleY); double sw = w * scaleX; double sh = h * scaleY; // System.out.println("Scale X ["+scaleX+"] - Scale Y ["+scaleY+"] - Scale ["+scale+"]"); bkgImg = Bitmap.createBitmap(bkgImg, 0, 0, w, h); pinTableFrag.setBackground(bkgImg); } } }