List of usage examples for android.view Surface ROTATION_180
int ROTATION_180
To view the source code for android.view Surface ROTATION_180.
Click Source Link
From source file:com.blueverdi.rosietheriveter.SitesFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { thisFragment = this; setRetainInstance(false);/* w w w .j a va 2s . c o m*/ myTour = new MySqliteHelperMyTour(getActivity()); networkAvailable = Utils.isNetworkAvailable(getActivity()); buildSitesList(); view = inflater.inflate(R.layout.sites_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; } // 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) { Toast.makeText(thisFragment.getActivity(), thisFragment.getActivity().getString(R.string.internet_required), Toast.LENGTH_LONG) .show(); } // map.setMyLocationEnabled(true); // CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(SITES, 0); // map.animateCamera(cameraUpdate); 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); SiteDetails sd = s.getDetails(); if (sd != null) { i.putExtra(SiteDetails.PARCEL_NAME, sd); } 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:com.blueverdi.rosietheriveter.MoreFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(false);// ww w.j a v a 2s. c om 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:mobi.cangol.mobile.navigation.DrawerMenuLayout.java
private void fitPadding(Rect rect) { boolean hasNavigationBar = checkDeviceHasNavigationBar(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && hasNavigationBar) { WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); switch (manager.getDefaultDisplay().getRotation()) { case Surface.ROTATION_90: rect.right += getNavBarWidth(); break; case Surface.ROTATION_180: rect.top += getNavBarHeight(); break; case Surface.ROTATION_270: rect.left += getNavBarWidth(); break; default://from www . jav a 2 s. c o m rect.bottom += getNavBarHeight(); } } mContentView.setPadding(rect.left, rect.top, rect.right, rect.bottom); mMenuView.setPadding(rect.left, rect.top, rect.right, rect.bottom); mMaskView.setPadding(rect.left, rect.top, rect.right, rect.bottom); }
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://www .j a v a 2 s . c o m // 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: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 w w . j a v a2s. c o m } return 0; }
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();//from w w w . ja v a 2 s. 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;//from ww w .j av a 2s .co m 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:org.ormma.controller.OrmmaDisplayController.java
/** * Gets the orientation./*from w w w .j a va 2 s .co 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; }
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 w w w .j a v a2 s . 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(); }