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.pyamsoft.dontsuckmp.artist.AllArtistListFragment.java
private void setupRecyclerView() { fastAdapter.withSelectable(true);//from w w w . j av a 2 s . c o m fastAdapter.withOnClickListener((v, adapter, item, position) -> { Album album = item.getModel(); Timber.d("Show album track list focus for: %s", album); DialogUtil.guaranteeSingleDialogFragment(getActivity(), AlbumDialog.newInstance(album), AlbumDialog.TAG); return true; }); binding.artistList.setAdapter(fastAdapter); final int currentOrientation = getActivity().getResources().getConfiguration().orientation; final int columnCount; switch (currentOrientation) { case Configuration.ORIENTATION_PORTRAIT: columnCount = 2; break; case Configuration.ORIENTATION_LANDSCAPE: columnCount = 3; break; default: columnCount = 2; } binding.artistList.setLayoutManager(new GridLayoutManager(getContext(), columnCount)); }
From source file:com.shipdream.lib.android.mvc.samples.note.view.fragment.MainFragment.java
private AppController.Orientation convertOrientation(int orientation) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { return AppController.Orientation.PORTRAIT; } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { return AppController.Orientation.LANDSCAPE; } else {//from www . ja v a2s .c o m return AppController.Orientation.UNSPECIFIED; } }
From source file:tech.salroid.filmy.activities.SavedMovies.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); nightMode = sp.getBoolean("dark", false); if (nightMode) setTheme(R.style.AppTheme_Base_Dark); else/* w w w . j a v a 2 s .c o m*/ setTheme(R.style.AppTheme_Base); setContentView(R.layout.activity_saved_movies); ButterKnife.bind(this); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(""); } Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/canaro_extra_bold.otf"); logo.setTypeface(typeface); if (nightMode) allThemeLogic(); /*GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3); my_saved_movies_recycler.setLayoutManager(gridLayoutManager);*/ boolean tabletSize = getResources().getBoolean(R.bool.isTablet); if (tabletSize) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6, StaggeredGridLayoutManager.VERTICAL); my_saved_movies_recycler.setLayoutManager(gridLayoutManager); } else { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8, StaggeredGridLayoutManager.VERTICAL); my_saved_movies_recycler.setLayoutManager(gridLayoutManager); } } else { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); my_saved_movies_recycler.setLayoutManager(gridLayoutManager); } else { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.VERTICAL); my_saved_movies_recycler.setLayoutManager(gridLayoutManager); } } mainActivityAdapter = new SavedMoviesAdapter(this, null); my_saved_movies_recycler.setAdapter(mainActivityAdapter); mainActivityAdapter.setClickListener(this); mainActivityAdapter.setLongClickListener(this); getSupportLoaderManager().initLoader(SAVED_DETAILS_LOADER, null, this); }
From source file:org.kontalk.util.SystemUtils.java
/** * Returns the correct screen orientation based on the supposedly preferred * position of the device.//w ww.ja v a 2 s. com * http://stackoverflow.com/a/16585072/1045199 */ public static int getScreenOrientation(Activity activity) { WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); Configuration configuration = activity.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); // Search for the natural position of the device if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) || configuration.orientation == Configuration.ORIENTATION_PORTRAIT && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) { // Natural position is Landscape switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case Surface.ROTATION_180: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } } else { // Natural position is Portrait switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_180: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; }
From source file:org.cocos2dx.lib.Cocos2dxAccelerometer.java
@Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER) { return;//from w ww .j a v a 2 s .c o m } float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; /* * Because the axes are not swapped when the device's screen orientation changes. * So we should swap it here. * In tablets such as Motorola Xoom, the default orientation is landscape, so should * consider this. */ int orientation = mContext.getResources().getConfiguration().orientation; if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)) { float tmp = x; x = -y; y = tmp; } else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0)) { float tmp = x; x = y; y = -tmp; } onSensorChanged(x, y, z, event.timestamp); // Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]); }
From source file:nf.frex.android.FrexActivity.java
/** * Called when the activity is first created. */// w w w. j a va2 s. com @Override public void onCreate(Bundle savedInstanceState) { //Log.d(TAG, "onCreate(savedInstanceState=" + savedInstanceState + ")"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY); if (PRE_SDK14) { requestWindowFeature(Window.FEATURE_NO_TITLE); // Fix: Frex to stop working on screen orientation changes (Android 2.3.x only) if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else { getActionBar().setBackgroundDrawable(new PaintDrawable(Color.argb(128, 0, 0, 0))); } view = new FractalView(this); setContentView(view); if (!tryReadingFrexDocIntent(getIntent())) { if (savedInstanceState != null) { view.restoreInstanceState(new BundlePropertySet(savedInstanceState)); } else { PropertySet propertySet = (PropertySet) getLastNonConfigurationInstance(); if (propertySet != null) { view.restoreInstanceState(propertySet); } } } }
From source file:com.tapcentive.sdk.actions.TapMessageFragment.java
@Override public void onResume() { super.onResume(); Log.d(TAG, "====> Message Fragment resumed"); // Determines the current display metrics of the view - width, height etc. getDisplayMetrics();/*w w w. j a v a 2 s . co m*/ // If the fragment has not just been created from the main activity, don't try and // replay the game. if (!fragmentCreated) { return; } Log.d(TAG, "====> Message: Trying to Start Game."); if (isAdded() && getActivity() != null) { // Setup and starts the game int orientation = getActivity().getResources().getConfiguration().orientation; // If orientation is not portrait, game play does not start and it waits for onConfigurationChange to occur. if (orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d(TAG, "====> Message: Start Game"); // Game will not be replayed until fragment is actually created again fragmentCreated = false; startGame(this.gameView); } else { Log.d(TAG, "=======> Message - game not played onResume, orientation is not portrait"); } } else { Log.d(TAG, "=======> Message - game not played onResume, not added or activity is null"); } }
From source file:com.experiment.chickenjohn.materialdemo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { portLoading();// w w w . j a va 2 s. co m } else { landLoading(); } ecgDatabaseManager = new EcgDatabaseManager(this); }
From source file:org.mariotaku.twidere.activity.DualPaneActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); super.onCreate(savedInstanceState); final Resources res = getResources(); final int orientation = res.getConfiguration().orientation; final int layout; mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, false); mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, false); switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: layout = mDualPaneInLandscape ? getDualPaneLayoutRes() : getNormalLayoutRes(); break;/*from w w w .ja va 2 s .c o m*/ case Configuration.ORIENTATION_PORTRAIT: layout = mDualPaneInPortrait ? getDualPaneLayoutRes() : getNormalLayoutRes(); break; default: layout = getNormalLayoutRes(); break; } setContentView(layout); final View pane_right = findViewById(PANE_RIGHT); if (pane_right != null) { pane_right.setBackgroundResource(getPaneBackground()); } getSupportFragmentManager().addOnBackStackChangedListener(this); }
From source file:kookmin.cs.sympathymusiz.VideoListDemoActivity.java
/** * Sets up the layout programatically for the three different states. Portrait, landscape or * fullscreen+landscape. This has to be done programmatically because we handle the orientation * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources * do not get reloaded./* www . j a v a 2 s. c o m*/ */ private void layout() { boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; //ArrayList<ArrayList<String>> list = (ArrayList<ArrayList<String>>) getIntent("exIntent""); listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE); listFragment.setLabelVisibility(isPortrait); closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE); if (isFullscreen) { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT); } else if (isPortrait) { setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM); } else { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp); setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT); int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP); setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL); } }