android.content.res.Configuration#ORIENTATION_PORTRAIT源码实例Demo

下面列出了android.content.res.Configuration#ORIENTATION_PORTRAIT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: kAndroid   文件: TimeMainActivity.java
@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);
    }
}
 
源代码2 项目: kernel_adiutor   文件: ParentFragment.java
@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);
}
 
源代码3 项目: Slide   文件: Gallery.java
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;
}
 
源代码4 项目: Tok-Android   文件: SystemBarConfig.java
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);
}
 
源代码5 项目: candybar   文件: HomeAdapter.java
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;
}
 
源代码6 项目: monolog-android   文件: SystemBarTintManager.java
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;
}
 
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        mLiveVideoBroadcaster.setDisplayOrientation();
    }

}
 
源代码8 项目: DragListView   文件: BoardView.java
@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);
}
 
源代码9 项目: meiShi   文件: SystemBarTintManager.java
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;
}
 
源代码10 项目: 4pdaClient-plus   文件: SystemBarTintManager.java
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;
}
 
源代码11 项目: sandriosCamera   文件: Utils.java
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;
    }
}
 
源代码12 项目: Tangram-Android   文件: LinearScrollView.java
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;
}
 
源代码13 项目: VideoOS-Android-SDK   文件: VenvyUIUtil.java
/**
 * 获取横屏屏幕宽度
 *
 * @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();
    }
}
 
源代码14 项目: KChartView   文件: LoadMoreActivity.java
@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);
    }
}
 
源代码15 项目: kernel_adiutor   文件: FrequencyTableFragment.java
@Override
public int getSpan() {
    return Utils.getScreenOrientation(getActivity()) == Configuration.ORIENTATION_PORTRAIT ? 1 : 2;
}
 
源代码16 项目: kernel_adiutor   文件: ParentFragment.java
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());
}
 
源代码17 项目: appinventor-extensions   文件: Form.java
@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);
        }
      }
    });
  }
}
 
源代码18 项目: UTubeTV   文件: Utils.java
public static boolean isPortrait(Context context) {
  return (context.getResources()
      .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
}
 
源代码19 项目: VideoOS-Android-SDK   文件: VenvyUIUtil.java
/**
 * 返回当前屏幕是否为竖屏。
 *
 * @param context
 * @return 当且仅当当前屏幕为竖屏时返回true, 否则返回false。
 */
public static boolean isScreenOriatationPortrait(@Nullable Context context) {
    return context.getResources().getConfiguration().orientation ==
            Configuration.ORIENTATION_PORTRAIT;
}
 
/**
 * 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;
}