List of usage examples for android.view Surface ROTATION_90
int ROTATION_90
To view the source code for android.view Surface ROTATION_90.
Click Source Link
From source file:io.github.msc42.masterthemaze.SearchDeviceActivity.java
private void lockScreenOrientation() { int orientation = getResources().getConfiguration().orientation; int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (orientation == Configuration.ORIENTATION_LANDSCAPE) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else {//from w w w .j av a 2 s . c o m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }
From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java
private void fitDecorChild(View view) { ViewGroup contentView = (ViewGroup) view.findViewById(R.id.actionbar_content_view); if (contentView != null) { ViewGroup decorChild = (ViewGroup) contentView.getChildAt(0); if (decorChild != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) decorChild.getLayoutParams(); switch (manager.getDefaultDisplay().getRotation()) { case Surface.ROTATION_90: layoutParams.rightMargin = 0; break; case Surface.ROTATION_180: layoutParams.topMargin = 0; break; case Surface.ROTATION_270: layoutParams.leftMargin = 0; break; default: layoutParams.bottomMargin = 0; }/*from ww w .ja va 2 s . c o m*/ decorChild.setLayoutParams(layoutParams); } } } }
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 a v a 2 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:mobi.cangol.mobile.navigation.SlidingMenuLayout.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 w w w. jav a 2 s . c om*/ rect.bottom += getNavBarHeight(); } } mContentView.setPadding(rect.left, rect.top, rect.right, rect.bottom); mMenuView.setPadding(rect.left, rect.top, rect.right, rect.bottom); }
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:/* w w w . ja v a2s .com*/ 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:com.blueverdi.rosietheriveter.SitesFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { thisFragment = this; setRetainInstance(false);//from w ww .j a v a 2s .c om 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. jav a 2 s.c o 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 ww . 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; }/* w w w . jav a 2s . co m*/ } return 0; }