List of usage examples for android.view Display getRotation
@Surface.Rotation public int getRotation()
From source file:org.chromium.ChromeSystemDisplay.java
private int getRotation(final Display display) { final int rotation = display.getRotation(); final int DEFAULT_ROTATION = 0; if (rotation == Surface.ROTATION_0) { return 0; } else if (rotation == Surface.ROTATION_90) { return 90; } else if (rotation == Surface.ROTATION_180) { return 180; } else if (rotation == Surface.ROTATION_270) { return 270; }//from ww w .j a v a 2s . co m return DEFAULT_ROTATION; }
From source file:com.google.android.apps.santatracker.games.SplashActivity.java
@Override protected void onStart() { super.onStart(); // Orientation boolean gameIsLandscape = getIntent().getBooleanExtra(EXTRA_LANDSCAPE, false); boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); // Figure out how many degrees to rotate // Landscape always wants to be at 90degrees, portrait always wants to be at 0degrees float degreesToRotate = 0f; if (rotation == Surface.ROTATION_0) { degreesToRotate = gameIsLandscape && !isLandscape ? 90.0f : 0.0f; } else if (rotation == Surface.ROTATION_90) { degreesToRotate = gameIsLandscape && isLandscape ? 0f : -90f; } else if (rotation == Surface.ROTATION_180) { degreesToRotate = gameIsLandscape && !isLandscape ? -90f : -180f; } else if (rotation == Surface.ROTATION_270) { degreesToRotate = gameIsLandscape && isLandscape ? -180f : -270f; }/*from w ww. j av a2 s . co m*/ // On a TV, should always be 0 if (isRunningOnTV()) { degreesToRotate = 0f; } // Rotate, if necessary if (degreesToRotate != 0) { Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { display.getRealSize(size); } else { display.getSize(size); } int w = size.x; int h = size.y; View mainLayout = findViewById(R.id.splash_layout); mainLayout.setRotation(degreesToRotate); mainLayout.setTranslationX((w - h) / 2); mainLayout.setTranslationY((h - w) / 2); ViewGroup.LayoutParams lp = mainLayout.getLayoutParams(); lp.height = w; lp.width = h; mainLayout.requestLayout(); } }
From source file:com.nextgis.mobile.forms.CameraFragment.java
public int getDeviceRotation() { if (getActivity() == null) return 0; if (getActivity().getWindowManager() == null) return 0; Display display = getActivity().getWindowManager().getDefaultDisplay(); if (display != null) { if (display.getRotation() == Surface.ROTATION_90) { return 90; } else if (display.getRotation() == Surface.ROTATION_180) { return 180; } else if (display.getRotation() == Surface.ROTATION_270) { return 270; }//from w ww . j ava 2 s . c o m } return 0; }
From source file:io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.java
private void addDisplayInfo() throws IOException { Display display = UiAutomatorBridge.getInstance().getDefaultDisplay(); Point size = new Point(); display.getSize(size);// w w w .j a v a 2 s. com serializer.attribute(NAMESPACE, "rotation", Integer.toString(display.getRotation())); serializer.attribute(NAMESPACE, "width", Integer.toString(size.x)); serializer.attribute(NAMESPACE, "height", Integer.toString(size.y)); }
From source file:de.gebatzens.ggvertretungsplan.fragment.MensaFragment.java
@Override public void createView(LayoutInflater inflater, ViewGroup view) { Display display = ((WindowManager) getActivity().getApplicationContext() .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); Log.d("Screen orientation", String.valueOf(rotation)); if ((rotation == 3) || (rotation == 1)) { screen_orientation_horizotal = true; } else {/* w w w . ja va 2 s . c om*/ screen_orientation_horizotal = false; } final ScrollView sv = new ScrollView(getActivity()); sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setTag("mensa_scroll"); ((LinearLayout) view.findViewById(R.id.mensa_content)).addView(sv); final LinearLayout l = new LinearLayout(getActivity()); l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setOrientation(LinearLayout.VERTICAL); int p = toPixels(6); l.setPadding(p, p, p, p); sv.addView(l); for (Mensa.MensaItem item : GGApp.GG_APP.mensa) { if (!item.isPast()) l.addView(createCardItem(item, inflater)); } }
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
public int getDeviceRotation() { Display display = getActivity().getWindowManager().getDefaultDisplay(); final int rotation = display.getRotation(); if (rotation == Surface.ROTATION_90) { return 90; } else if (rotation == Surface.ROTATION_180) { return 180; } else if (rotation == Surface.ROTATION_270) { return 270; }/*w w w .j a v a2s .c o m*/ return 0; }
From source file:com.nextgis.mobile.forms.CompassFragment.java
public int getDeviceRotation() { Display display = getActivity().getWindowManager().getDefaultDisplay(); final int rotation = display.getRotation(); if (rotation == Surface.ROTATION_90) { return 90; } else if (rotation == Surface.ROTATION_180) { return 180; } else if (rotation == Surface.ROTATION_270) { return 270; }//from w ww .j a v a2s . c o m return 0; }
From source file:com.metinkale.prayerapp.compass.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.compass_main); PermissionUtils.get(this).needLocation(this); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); mDisplayRotation = display.getRotation(); // sensor listeners mMagAccel = new MagAccelListener(this); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); mFrag2D = new Frag2D(); mList = mFrag2D;/* w w w . ja v a2 s . co m*/ fragmentTransaction.add(R.id.frag2D, mFrag2D, "2d"); fragmentTransaction.commit(); }
From source file:com.projecttango.examples.java.floorplanreconstruction.FloorPlanReconstructionActivity.java
/** * Set the display rotation./*from w ww . j a va 2 s.c o m*/ */ private void setDisplayRotation() { Display display = getWindowManager().getDefaultDisplay(); mDisplayRotation = display.getRotation(); }
From source file:de.uulm.graphicalpasswords.openmiba.MIBALoginActivity.java
private void setViews() { tableLayout = (TableLayout) findViewById(R.id.tableLayout); btnBack = (Button) findViewById(R.id.miba_btnBack); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { back();//from w w w . j a v a2 s .c om } }); tvRound = (TextView) this.findViewById(R.id.tvRound); tvRound.setText(getString(R.string.label_round) + " 1"); linlGrid = new LinearLayout[2][4]; linlGrid[0][0] = (LinearLayout) this.findViewById(R.id.square1); linlGrid[1][0] = (LinearLayout) this.findViewById(R.id.square2); linlGrid[0][1] = (LinearLayout) this.findViewById(R.id.square3); linlGrid[1][1] = (LinearLayout) this.findViewById(R.id.square4); linlGrid[0][2] = (LinearLayout) this.findViewById(R.id.square5); linlGrid[1][2] = (LinearLayout) this.findViewById(R.id.square6); linlGrid[0][3] = (LinearLayout) this.findViewById(R.id.square7); linlGrid[1][3] = (LinearLayout) this.findViewById(R.id.square8); for (int y = 0; y < 4; y++) { for (int x = 0; x < 2; x++) { linlGrid[x][y].setBackgroundColor(colors_off[x][y]); } } // get width and height from mainpanel // can not use display width/height because of notification bar ViewTreeObserver vto = tableLayout.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // get values of portrait mode Display display = getWindowManager().getDefaultDisplay(); if (display.getRotation() == Surface.ROTATION_0) { width = tableLayout.getWidth(); height = tableLayout.getHeight(); } else { height = tableLayout.getWidth(); width = tableLayout.getHeight(); } Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ccp000); bmp = Bitmap.createScaledBitmap(bmp, width, height, true); Drawable d = new BitmapDrawable(getResources(), bmp); bmp = null; // prevent outofmemor tableLayout.setBackgroundDrawable(d); touchlistener = new TouchListener(linlGrid, width, height, handler); tableLayout.setOnTouchListener(touchlistener); // remove listener again otherwise it gets called twice tableLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); }