List of usage examples for android.view Surface ROTATION_0
int ROTATION_0
To view the source code for android.view Surface ROTATION_0.
Click Source Link
From source file:com.blueverdi.rosietheriveter.MoreFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(false);//from www.j a v a 2 s . co m thisFragment = this; myTour = new MySqliteHelperMyTour(getActivity()); networkAvailable = Utils.isNetworkAvailable(getActivity()); buildSitesList(); view = inflater.inflate(R.layout.more_fragment, container, false); viewContainer = (LinearLayout) view.findViewById(R.id.view_container); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup1); // implementation without nested fragments // first initialize the gallery view // --------------------------------- listLayout = (LinearLayout) inflater.inflate(R.layout.site_gallery_view, viewContainer, false); Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); int rotation = display.getRotation(); switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: portrait = true; arrayLayout = R.layout.site_portrait; break; case Surface.ROTATION_90: case Surface.ROTATION_270: portrait = false; arrayLayout = R.layout.site_landscape; break; } ListView listview = (ListView) listLayout.findViewById(R.id.siteListView); // now initialize the map view // -------------------------- mapLayout = (LinearLayout) inflater.inflate(R.layout.site_map_view, viewContainer, false); try { MapsInitializer.initialize(this.getActivity()); } catch (Exception e) { e.printStackTrace(); } mapView = (MapView) mapLayout.findViewById(R.id.siteMap); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { map = googleMap; map.getUiSettings().setMyLocationButtonEnabled(false); if (!networkAvailable) { thisFragment.getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), getString(R.string.internet_required), Toast.LENGTH_LONG) .show(); } }); } map.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition arg0) { map.setOnCameraChangeListener(null); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(SITES, 0); if (networkAvailable) { map.animateCamera(cameraUpdate); } else { map.moveCamera(cameraUpdate); } } }); markers = new HashMap<String, Site>(); for (Site s : sites) { LatLng ll = new LatLng(Double.parseDouble(s.getString(Site.LATITUDE)), Double.parseDouble(s.getString(Site.LONGITUDE))); Marker marker = map.addMarker(new MarkerOptions().position(ll).title(s.getString(Site.NAME))); markers.put(marker.getId(), s); } map.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { Site s = markers.get(marker.getId()); Intent i = new Intent(getActivity(), SiteActivity.class); i.putExtra(Site.PARCEL_NAME, s); startActivity(i); getActivity().overridePendingTransition(R.anim.zoom_in, 0); return true; } }); } }); try { container.removeAllViews(); } catch (Exception e) { MyLog.d(TAG, "container evaporated inside onCreateView"); return view; } if (startInMapView) { RadioButton rb = (RadioButton) view.findViewById(R.id.radioMapView); rb.setChecked(true); setMap(); } else { setGallery(); } radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id.radioListView) { setGallery(); } else { Toast.makeText(getActivity(), getString(R.string.getting_map), Toast.LENGTH_LONG).show(); setMap(); } } }); return view; }
From source file:org.mitre.svmp.activities.AppRTCActivity.java
private int getDeviceDefaultOrientation() { WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); Configuration config = getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); int value = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && config.orientation == Configuration.ORIENTATION_LANDSCAPE) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && config.orientation == Configuration.ORIENTATION_PORTRAIT)) value = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; return value; }
From source file:com.brq.wallet.activity.ScanActivity.java
private int getScreenOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; int orientation; // if the device's natural orientation is portrait: if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; default:/*from w w w .j a v a2s . c om*/ // Unknown screen orientation. Defaulting to portrait. orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; } } // if the device's natural orientation is landscape or if the device is square: else { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; default: // Unknown screen orientation. Defaulting to landscape. orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; } } return orientation; }
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. java2 s .co m*/ } }); 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); } }); }
From source file:zxing.util.CaptureActivity.java
License:asdf
private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default://www . j ava2s . c o m return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } }
From source file:edu.pdx.its.portal.routelandia.ListStat.java
public int getRotation(Context context) { final int rotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getOrientation();/* w w w. ja v a 2s .c o m*/ switch (rotation) { case Surface.ROTATION_0: return 1; //portrait case Surface.ROTATION_90: return 0;//landscape case Surface.ROTATION_180: return 1;//reverse portrait default: return 0;//reverse landscape } }
From source file:org.artoolkit.ar.base.camera.CaptureCameraPreview.java
private void setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); WindowManager wMgr = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); int rotation = wMgr.getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;// w ww . ja va 2 s. c om break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation + degrees) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation - degrees + 360) % 360; } camera.setDisplayOrientation(result); }
From source file:ch.jeda.platform.android.Main.java
private int getScreenOrientation(final ViewRequest request) { if (request.getFeatures().contains(WindowFeature.ORIENTATION_LANDSCAPE)) { return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (request.getFeatures().contains(WindowFeature.ORIENTATION_PORTRAIT)) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else {/*from w ww. j a v a2 s . c o m*/ final int rotation = this.getWindowManager().getDefaultDisplay().getRotation(); if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else { return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } else { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else { return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } } } }
From source file:org.hw.parlance.ParlanceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!LinphoneManager.isInstanciated()) { Log.e("No service running: avoid crash by starting the launcher", this.getClass().getName()); // super.onCreate called earlier finish();//from www .j av a 2s . com startActivity(getIntent().setClass(this, ParlanceLauncherActivity.class)); return; } boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_wizard_at_first_start); if (useFirstLoginActivity && LinphonePreferences.instance().isFirstLaunch()) { if (LinphonePreferences.instance().getAccountCount() > 0) { LinphonePreferences.instance().firstLaunchSuccessful(); } else { startActivityForResult(new Intent().setClass(this, SetupActivity.class), FIRST_LOGIN_ACTIVITY); } } setContentView(R.layout.main); instance = this; initButtons(); int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: rotation = 0; break; case Surface.ROTATION_90: rotation = 90; break; case Surface.ROTATION_180: rotation = 180; break; case Surface.ROTATION_270: rotation = 270; break; } LinphoneManager.getLc().setDeviceRotation(rotation); mAlwaysChangingPhoneAngle = rotation; updateAnimationsState(); }
From source file:org.ormma.controller.OrmmaDisplayController.java
/** * Gets the orientation.// w w w. j a v a2s . c o m * * @return the orientation */ public int getOrientation() { int orientation = mWindowManager.getDefaultDisplay().getOrientation(); int ret = -1; switch (orientation) { case Surface.ROTATION_0: ret = 0; break; case Surface.ROTATION_90: ret = 90; break; case Surface.ROTATION_180: ret = 180; break; case Surface.ROTATION_270: ret = 270; break; } Log.d(LOG_TAG, "getOrientation: " + ret); return ret; }