List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:com.example.android.weatherapp.view.MainActivity.java
/** * to prevent crash on screen orientation in middle of network operation * we will be locking orientation of the screen temporarily. * * @author swapnil/*ww w . j av a2s .com*/ */ private void lockScreenOrientation() { int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } }
From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.profile_control, container, false); relativeLayout = (RelativeLayout) rootView.findViewById(R.id.gatt_service_carousel); pager = (ViewPager) rootView.findViewById(R.id.myviewpager); application = (CySmartApplication) getActivity().getApplication(); PAGES = 0;/*from w w w. j a v a 2s.c o m*/ mpdia = new ProgressDialog(getActivity()); mpdia.setCancelable(false); setCarouselView(); setHasOptionsMenu(true); /** * Getting the orientation of the device. Set margin for pages as a * negative number, so a part of next and previous pages will be showed */ if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { pager.setPageMargin(-width / 3); } else if (getActivity().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { pager.setPageMargin(-width / 2); } return rootView; }
From source file:org.openremote.android.console.GroupActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); Log.i("OpenRemote-ORIENTATION", "onCreate:" + display.getOrientation()); if (display != null && display.getOrientation() == 1) { isLandscape = true;//from w w w. j a va2s . c om lastConfigurationOrientation = Configuration.ORIENTATION_LANDSCAPE; } else { isLandscape = false; lastConfigurationOrientation = Configuration.ORIENTATION_PORTRAIT; } this.gestureScanner = new GestureDetector(this); if (groupViews == null) { groupViews = new HashMap<Integer, GroupView>(); } if (navigationHistory == null) { navigationHistory = new ArrayList<Navigate>(); } recoverLastGroupScreen(); addControllerRefreshEventListener(); initOrientationListener(); }
From source file:nl.hnogames.domoticz.app.DomoticzRecyclerFragment.java
public void setGridViewLayout() { try {// w w w .ja v a2s . c o m boolean isTablet = false; float screenWidth = 0; boolean isPortrait = false; if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) isPortrait = true; if (getActivity() instanceof MainActivity) { isTablet = !((MainActivity) getActivity()).onPhone; } gridView.setHasFixedSize(true); if (isTablet) { if (isPortrait) { GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 1); gridView.setLayoutManager(mLayoutManager); } else { GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 2); gridView.setLayoutManager(mLayoutManager); } } else { GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 1); gridView.setLayoutManager(mLayoutManager); } gridView.setItemAnimator(new SlideInUpAnimator(new OvershootInterpolator(1f))); } catch (Exception ex) { } }
From source file:oly.netpowerctrl.main.MainActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT || newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { assignContentView();//from ww w .j a v a 2 s . co m } // now the fragments super.onConfigurationChanged(newConfig); }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_video_view.AbstractSignVideoFragment.java
private void setVideoViewDimensionToMatchVideoMetadata(VideoView videoView, Uri uri) { String metadataVideoWidth;//ww w.jav a 2s .c o m String metadataVideoHeight; try { final MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); metaRetriever.setDataSource(getActivity(), uri); metadataVideoWidth = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH); metadataVideoHeight = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); metaRetriever.release(); Validate.notEmpty(metadataVideoWidth); Validate.notEmpty(metadataVideoHeight); } catch (NullPointerException | IllegalArgumentException ex) { throw new VideoSetupException(getActivity().getString(R.string.ASVF_2) + ex.getLocalizedMessage(), ex); } if (null == metadataVideoWidth) { throw new VideoSetupException(getActivity().getString(R.string.ASVF_3)); } if (null == metadataVideoHeight) { throw new VideoSetupException(getActivity().getString(R.string.ASVF_4)); } final double videoWidth = Double.valueOf(metadataVideoWidth); final double videoHeight = Double.valueOf(metadataVideoHeight); final double videoRatio = videoWidth / videoHeight; Log.d(TAG, String.format("videoWidth: %s, videoHeight: %s, videoRatio: %s", videoWidth, videoHeight, videoRatio)); boolean isOrientationPortrait = Configuration.ORIENTATION_PORTRAIT == getResources() .getConfiguration().orientation; int displayHeight = getResources().getDisplayMetrics().heightPixels; int displayWidth = getResources().getDisplayMetrics().widthPixels; Log.d(TAG, String.format("displayHeight: %s, displayWidth: %s", displayHeight, displayWidth)); final double desiredVideoWidth, desiredVideoHeight; if (isOrientationPortrait) { desiredVideoWidth = displayWidth * MAXIMUM_VIDEO_WIDTH_ON_PORTRAIT; desiredVideoHeight = 1 / (videoRatio / desiredVideoWidth); Log.d(TAG, String.format("OrientationPortrait: desiredVideoWidth: %s, desiredVideoHeight: %s", desiredVideoWidth, desiredVideoHeight)); } else { // orientation is Landscape desiredVideoHeight = displayHeight * MAXMIMUM_VIDEO_HEIGHT_ON_LANDSCAPE; desiredVideoWidth = desiredVideoHeight * videoRatio; Log.d(TAG, String.format("OrientationLandscape: desiredVideoWidth: %s, desiredVideoHeight: %s", desiredVideoWidth, desiredVideoHeight)); } final ViewGroup.LayoutParams layoutParams = videoView.getLayoutParams(); layoutParams.width = (int) desiredVideoWidth; layoutParams.height = (int) desiredVideoHeight; }
From source file:com.example.android.wifidirect.WiFiDirectActivity.java
public void onConfigurationChanged(Configuration newConfig) { Configuration newConfig1 = getResources().getConfiguration(); if (newConfig1.orientation == Configuration.ORIENTATION_LANDSCAPE) { //?// www.j a v a 2s. c o m } else if (newConfig1.orientation == Configuration.ORIENTATION_PORTRAIT) { //? //setContentView(R.id.portrait); } }
From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java
public void toggleVisibleTitles() { // Use these for custom animations. final FragmentManager fm = getSupportFragmentManager(); final TitlesFragment f = (TitlesFragment) fm.findFragmentById(R.id.frag_title); final View titlesView = f.getView(); mLabelIndex = 1 - mLabelIndex;/*w ww .ja v a2 s .com*/ // Determine if we're in portrait, and whether we're showing or hiding the titles // with this toggle. final boolean isPortrait = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; final boolean shouldShow = f.isHidden() || mCurrentTitlesAnimator != null; // Cancel the current titles animation if there is one. if (mCurrentTitlesAnimator != null) mCurrentTitlesAnimator.cancel(); // Begin setting up the object animator. We'll animate the bottom or right edge of the // titles view, as well as its alpha for a fade effect. ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(titlesView, PropertyValuesHolder.ofInt(isPortrait ? "bottom" : "right", shouldShow ? getResources().getDimensionPixelSize(R.dimen.titles_size) : 0), PropertyValuesHolder.ofFloat("alpha", shouldShow ? 1 : 0)); // At each step of the animation, we'll perform layout by calling setLayoutParams. final ViewGroup.LayoutParams lp = titlesView.getLayoutParams(); objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator valueAnimator) { // *** WARNING ***: triggering layout at each animation frame highly impacts // performance so you should only do this for simple layouts. More complicated // layouts can be better served with individual animations on child views to // avoid the performance penalty of layout. if (isPortrait) { lp.height = (Integer) valueAnimator.getAnimatedValue(); } else { lp.width = (Integer) valueAnimator.getAnimatedValue(); } titlesView.setLayoutParams(lp); } }); if (shouldShow) { fm.beginTransaction().show(f).commit(); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mCurrentTitlesAnimator = null; } }); } else { objectAnimator.addListener(new AnimatorListenerAdapter() { boolean canceled; @Override public void onAnimationCancel(Animator animation) { canceled = true; super.onAnimationCancel(animation); } @Override public void onAnimationEnd(Animator animator) { if (canceled) return; mCurrentTitlesAnimator = null; fm.beginTransaction().hide(f).commit(); } }); } // Start the animation. objectAnimator.start(); mCurrentTitlesAnimator = objectAnimator; invalidateOptionsMenu(); // Manually trigger onNewIntent to check for ACTION_DIALOG. onNewIntent(getIntent()); }
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
private void loadImage(ImageView view, String image) { int width = 0, height = 0; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) width = view.getRootView().getMeasuredWidth(); else/* w w w .j a v a 2 s . c o m*/ height = view.getRootView().getMeasuredHeight(); InputStream is = null; try { is = getContext().getAssets().open(image); BitmapFactory.Options options = ControlHelper.getOptions(is, width, height); is = getContext().getAssets().open(image); Bitmap bitmap = ControlHelper.getBitmap(is, options); view.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } }
From source file:nl.hnogames.domoticz.app.DomoticzDashboardFragment.java
public void setGridViewLayout() { try {//w w w . j av a 2 s . c o m boolean isTablet = false; float screenWidth = 0; boolean isPortrait = false; if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) isPortrait = true; if (getActivity() instanceof MainActivity) { isTablet = !((MainActivity) getActivity()).onPhone; } gridView.setHasFixedSize(true); if (!mSharedPrefs.showDashboardAsList()) { if (isTablet) { if (isPortrait) { GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 1); gridView.setLayoutManager(mLayoutManager); } else { GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 2); gridView.setLayoutManager(mLayoutManager); } } else { GridLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 1); gridView.setLayoutManager(mLayoutManager); } } else { if (isTablet) { if (isPortrait) { StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); gridView.setLayoutManager(mLayoutManager); } else { StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.VERTICAL); gridView.setLayoutManager(mLayoutManager); } } else { if (isPortrait) { StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); gridView.setLayoutManager(mLayoutManager); } else { StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); gridView.setLayoutManager(mLayoutManager); } } } gridView.setItemAnimator(new SlideInUpAnimator(new OvershootInterpolator(1f))); } catch (Exception ignored) { } }