Java Code Examples for android.content.res.Configuration#ORIENTATION_PORTRAIT
The following examples show how to use
android.content.res.Configuration#ORIENTATION_PORTRAIT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeMainActivity.java From kAndroid with Apache License 2.0 | 6 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {//横屏 llStatus.setVisibility(View.GONE); minuteChartView.setGridRows(6); minuteChartView.setGridColumns(5); minuteChartView.setGridChildRows(4); viewLeftMessage.setVisibility(View.VISIBLE); lineView.setVisibility(View.VISIBLE); } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {//竖屏 llStatus.setVisibility(View.VISIBLE); minuteChartView.setGridRows(6); minuteChartView.setGridColumns(5); minuteChartView.setGridChildRows(4);; viewLeftMessage.setVisibility(View.GONE); lineView.setVisibility(View.GONE); } }
Example 2
Source File: Gallery.java From Slide with GNU General Public License v3.0 | 6 votes |
private int getNumColumns(final int orientation) { final int numColumns; boolean singleColumnMultiWindow = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { singleColumnMultiWindow = Gallery.this.isInMultiWindowMode() && SettingValues.singleColumnMultiWindow; } if (orientation == Configuration.ORIENTATION_LANDSCAPE && SettingValues.isPro && !singleColumnMultiWindow) { numColumns = Reddit.dpWidth; } else if (orientation == Configuration.ORIENTATION_PORTRAIT && SettingValues.dualPortrait) { numColumns = 2; } else { numColumns = 1; } return numColumns; }
Example 3
Source File: ParentFragment.java From kernel_adiutor with Apache License 2.0 | 6 votes |
@Override public void resetTranslations() { parentFragment.toolbar.setBackgroundColor(Color.TRANSPARENT); parentFragment.viewContainerBackground.setBackgroundColor(Color.TRANSPARENT); parentFragment.descriptionText.setVisibility(View.GONE); int orientation = Utils.getScreenOrientation(getActivity()); float density = getResources().getDisplayMetrics().density; float tabsPadding = orientation == Configuration.ORIENTATION_PORTRAIT ? 0 : density * 48; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) parentFragment.mTabs.getLayoutParams(); layoutParams.setMargins((int) tabsPadding, 0, (int) tabsPadding, 0); parentFragment.mTabs.requestLayout(); setPaddingRecyclerview(orientation, density); if (onScrollListener != null) onScrollListener.reset(); layoutManager.scrollToPositionWithOffset(0, 0); }
Example 4
Source File: HomeAdapter.java From candybar with Apache License 2.0 | 5 votes |
private boolean isFullSpan(int viewType) { if (viewType == TYPE_HEADER) { if (mOrientation == Configuration.ORIENTATION_PORTRAIT) { return true; } else return mImageStyle.getType() == Home.Style.Type.SQUARE || mImageStyle.getType() == Home.Style.Type.LANDSCAPE; } return false; }
Example 5
Source File: LoadMoreActivity.java From KChartView with Apache License 2.0 | 5 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mLlStatus.setVisibility(View.GONE); mKChartView.setGridRows(3); mKChartView.setGridColumns(8); } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mLlStatus.setVisibility(View.VISIBLE); mKChartView.setGridRows(4); mKChartView.setGridColumns(4); } }
Example 6
Source File: SystemBarTintManager.java From monolog-android with MIT License | 5 votes |
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) { Resources res = activity.getResources(); mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); mSmallestWidthDp = getSmallestWidthDp(activity); mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); mActionBarHeight = getActionBarHeight(activity); mNavigationBarHeight = getNavigationBarHeight(activity); mNavigationBarWidth = getNavigationBarWidth(activity); mHasNavigationBar = (mNavigationBarHeight > 0); mTranslucentStatusBar = translucentStatusBar; mTranslucentNavBar = traslucentNavBar; }
Example 7
Source File: LiveVideoBroadcasterActivity.java From LiveVideoBroadcaster with Apache License 2.0 | 5 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { mLiveVideoBroadcaster.setDisplayOrientation(); } }
Example 8
Source File: BoardView.java From DragListView with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); Resources res = getResources(); boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; if (isPortrait) { mColumnWidth = (int) (res.getDisplayMetrics().widthPixels * 0.87); } else { mColumnWidth = (int) (res.getDisplayMetrics().density * 320); } mGestureDetector = new GestureDetector(getContext(), new GestureListener()); mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f)); mAutoScroller = new AutoScroller(getContext(), this); mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN : AutoScroller.AutoScrollMode .POSITION); mDragItem = new DragItem(getContext()); mDragColumn = new DragItem(getContext()); mDragColumn.setSnapToTouch(false); mRootLayout = new FrameLayout(getContext()); mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); mColumnLayout = new LinearLayout(getContext()); mColumnLayout.setOrientation(LinearLayout.HORIZONTAL); mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); mColumnLayout.setMotionEventSplittingEnabled(false); mRootLayout.addView(mColumnLayout); mRootLayout.addView(mDragItem.getDragItemView()); addView(mRootLayout); }
Example 9
Source File: SystemBarTintManager.java From meiShi with Apache License 2.0 | 5 votes |
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) { Resources res = activity.getResources(); mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); mSmallestWidthDp = getSmallestWidthDp(activity); mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); mActionBarHeight = getActionBarHeight(activity); mNavigationBarHeight = getNavigationBarHeight(activity); mNavigationBarWidth = getNavigationBarWidth(activity); mHasNavigationBar = (mNavigationBarHeight > 0); mTranslucentStatusBar = translucentStatusBar; mTranslucentNavBar = traslucentNavBar; }
Example 10
Source File: SystemBarTintManager.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) { Resources res = activity.getResources(); mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); mSmallestWidthDp = getSmallestWidthDp(activity); mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); mActionBarHeight = getActionBarHeight(activity); mNavigationBarHeight = getNavigationBarHeight(activity); mNavigationBarWidth = getNavigationBarWidth(activity); mHasNavigationBar = (mNavigationBarHeight > 0); mTranslucentStatusBar = translucentStatusBar; mTranslucentNavBar = traslucentNavBar; }
Example 11
Source File: SystemBarConfig.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
public SystemBarConfig(Activity activity) { Resources res = activity.getResources(); mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); mSmallestWidthDp = getSmallestWidthDp(activity); mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME); mActionBarHeight = getActionBarHeight(activity); mNavigationBarHeight = getNavigationBarHeight(activity); mNavigationBarWidth = getNavigationBarWidth(activity); mContentHeight = getContentHeight(activity); mContentWidth = getContentWidth(activity); mHasNavigationBar = (mNavigationBarHeight > 0); }
Example 12
Source File: VenvyUIUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** * 获取横屏屏幕宽度 * * @param context * @return */ public static int getVerticalScreenHeight(@NonNull Context context) { Display display = ((WindowManager) context .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { return display.getHeight(); } else { return display.getWidth(); } }
Example 13
Source File: Utils.java From sandriosCamera with MIT License | 5 votes |
public static int getDeviceDefaultOrientation(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Configuration config = context.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); 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)) { return Configuration.ORIENTATION_LANDSCAPE; } else { return Configuration.ORIENTATION_PORTRAIT; } }
Example 14
Source File: LinearScrollView.java From Tangram-Android with MIT License | 5 votes |
private int getScreenWidth() { Resources resources = getContext().getResources(); DisplayMetrics dm = resources.getDisplayMetrics(); Configuration configuration = resources.getConfiguration(); return configuration.orientation == Configuration.ORIENTATION_PORTRAIT ? dm.widthPixels : dm.heightPixels; }
Example 15
Source File: ParentFragment.java From kernel_adiutor with Apache License 2.0 | 4 votes |
public void setPaddingRecyclerview(int orientation, float density) { float recyclerviewPadding = orientation == Configuration.ORIENTATION_PORTRAIT ? 0 : density * 48; recyclerView.setPadding((int) recyclerviewPadding, recyclerView.getPaddingTop(), (int) recyclerviewPadding, recyclerView.getPaddingBottom()); }
Example 16
Source File: Utils.java From UTubeTV with The Unlicense | 4 votes |
public static boolean isPortrait(Context context) { return (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); }
Example 17
Source File: Form.java From appinventor-extensions with Apache License 2.0 | 4 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Log.d(LOG_TAG, "onConfigurationChanged() called"); final int newOrientation = newConfig.orientation; if (newOrientation == Configuration.ORIENTATION_LANDSCAPE || newOrientation == Configuration.ORIENTATION_PORTRAIT) { // At this point, the screen has not be resized to match the new orientation. // We use Handler.post so that we'll dispatch the ScreenOrientationChanged event after the // screen has been resized to match the new orientation. androidUIHandler.post(new Runnable() { public void run() { boolean dispatchEventNow = false; if (frameLayout != null) { if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) { if (frameLayout.getWidth() >= frameLayout.getHeight()) { dispatchEventNow = true; } } else { // Portrait if (frameLayout.getHeight() >= frameLayout.getWidth()) { dispatchEventNow = true; } } } if (dispatchEventNow) { recomputeLayout(); final FrameLayout savedLayout = frameLayout; androidUIHandler.postDelayed(new Runnable() { public void run() { if (savedLayout != null) { savedLayout.invalidate(); } } }, 100); // Redraw the whole screen in 1/10 second // we do this to avoid screen artifacts left // left by the Android runtime. ScreenOrientationChanged(); } else { // Try again later. androidUIHandler.post(this); } } }); } }
Example 18
Source File: FrequencyTableFragment.java From kernel_adiutor with Apache License 2.0 | 4 votes |
@Override public int getSpan() { return Utils.getScreenOrientation(getActivity()) == Configuration.ORIENTATION_PORTRAIT ? 1 : 2; }
Example 19
Source File: CameraSourcePreview.java From google-authenticator-android with Apache License 2.0 | 2 votes |
/** * Check if we are is in the portrait mode or not * * @return true if the we are currently in portrait mode */ private boolean isPortraitMode() { int orientation = getContext().getResources().getConfiguration().orientation; return orientation == Configuration.ORIENTATION_PORTRAIT; }
Example 20
Source File: VenvyUIUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 2 votes |
/** * 返回当前屏幕是否为竖屏。 * * @param context * @return 当且仅当当前屏幕为竖屏时返回true, 否则返回false。 */ public static boolean isScreenOriatationPortrait(@Nullable Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }