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

下面列出了android.content.res.Configuration#ORIENTATION_LANDSCAPE 实例代码,或者点击链接到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 项目: KickAssSlidingMenu   文件: Utils.java
public static int getDrawerWidth(Resources res, int ownDP) {
    if (ownDP == 0) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {

            if (res.getConfiguration().smallestScreenWidthDp >= 600 || res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                // device is a tablet
                return (int) (320 * res.getDisplayMetrics().density);
            } else {
                return (int) (res.getDisplayMetrics().widthPixels - (56 * res.getDisplayMetrics().density));
            }
        } else { // for devices without smallestScreenWidthDp reference calculate if device screen is over 600 dp
            if ((res.getDisplayMetrics().widthPixels / res.getDisplayMetrics().density) >= 600 || res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                return (int) (320 * res.getDisplayMetrics().density);
            else
                return (int) (res.getDisplayMetrics().widthPixels - (56 * res.getDisplayMetrics().density));
        }
    } else {
        return ownDP;
    }
}
 
源代码3 项目: Yahala-Messenger   文件: ActionBarLayer.java
private void positionLogoImage(int height) {
    if (logoImageView != null) {
        LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            layoutParams.width = (int) (logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
            layoutParams.height = (int) (logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
            layoutParams.setMargins(OSUtilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
        } else {
            layoutParams.width = logoImageView.getDrawable().getIntrinsicWidth();
            layoutParams.height = logoImageView.getDrawable().getIntrinsicHeight();
            layoutParams.setMargins(OSUtilities.dp(12), (height - layoutParams.width) / 2, 0, 0);
        }
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        logoImageView.setLayoutParams(layoutParams);
    }
}
 
源代码4 项目: FairEmail   文件: DrawerLayoutEx.java
void setup(Configuration config, View drawerContainer, ActionBarDrawerToggle drawerToggle) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
    boolean landscape = prefs.getBoolean("landscape", true);
    boolean landscape3 = prefs.getBoolean("landscape3", false);

    if (normal && landscape && landscape3 &&
            config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setScrimColor(Color.TRANSPARENT);
        openDrawer(drawerContainer, false);
        drawerToggle.onDrawerOpened(drawerContainer);
    } else {
        setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim));
        closeDrawer(drawerContainer, false);
        drawerToggle.onDrawerClosed(drawerContainer);
    }
}
 
源代码5 项目: PlayerBase   文件: ListPlayActivity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    isLandScape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE;
    if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
        mPlayerContainer.setBackgroundColor(Color.BLACK);
        ListPlayer.get().attachContainer(mPlayerContainer, false);
        ListPlayer.get().setReceiverConfigState(this, ISPayer.RECEIVER_GROUP_CONFIG_FULL_SCREEN_STATE);
    }else{
        mPlayerContainer.setBackgroundColor(Color.TRANSPARENT);
        mRecycler.post(new Runnable() {
            @Override
            public void run() {
                ListAdapter.VideoItemHolder currentHolder = mAdapter.getCurrentHolder();
                if(currentHolder!=null){
                    ListPlayer.get().attachContainer(currentHolder.layoutContainer, false);
                    ListPlayer.get().setReceiverConfigState(
                            ListPlayActivity.this, ISPayer.RECEIVER_GROUP_CONFIG_LIST_STATE);
                }
            }
        });
    }
    ListPlayer.get().updateGroupValue(DataInter.Key.KEY_CONTROLLER_TOP_ENABLE, isLandScape);
    ListPlayer.get().updateGroupValue(DataInter.Key.KEY_IS_LANDSCAPE, isLandScape);
}
 
源代码6 项目: MonthAndYearPicker   文件: MonthPickerDialog.java
@Override
public void show() {

    if (view != null) {
        if (this.getContext().getResources().getConfiguration().orientation ==
                Configuration.ORIENTATION_LANDSCAPE) {
            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            if (getWindow() != null) {
                lp.copyFrom(getWindow().getAttributes());
                lp.width = (int) (this.getContext().getResources().getDisplayMetrics().widthPixels * 0.94);
                lp.height = (int) (this.getContext().getResources().getDisplayMetrics().heightPixels * 0.94);
                // show the dialog as per super implementation
                super.show();
                // now dialog attached to window so apply the size
                getWindow().setLayout(lp.width, lp.height);
            }

            return;
        }else {
            dismiss();
        }
    }
    super.show();
}
 
@Override
public int getSpanCount() {
    int span = Utils.isTablet(getActivity()) ? Utils.getOrientation(getActivity()) ==
            Configuration.ORIENTATION_LANDSCAPE ? 4 : 3 : Utils.getOrientation(getActivity()) ==
            Configuration.ORIENTATION_LANDSCAPE ? 3 : 2;
    if (itemsSize() != 0 && span > itemsSize()) {
        span = itemsSize();
    }
    return span;
}
 
源代码8 项目: BLEConnect   文件: DeviceControlActivity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
	super.onConfigurationChanged(newConfig);
	// setContentView(R.layout.heartrate);
	if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
		Log.i(TAG, "ORIENTATION_LANDSCAPE");
	} else {
		Log.i(TAG, "ORIENTATION_PORTRAIT");
	}
}
 
源代码9 项目: NClientV2   文件: TagFilterActivity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        changeLayout(true);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        changeLayout(false);
    }
}
 
源代码10 项目: mollyim-android   文件: DeviceLinkFragment.java
@Override
public void onConfigurationChanged(Configuration newConfiguration) {
  super.onConfigurationChanged(newConfiguration);
  if (newConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
    container.setOrientation(LinearLayout.HORIZONTAL);
  } else {
    container.setOrientation(LinearLayout.VERTICAL);
  }
}
 
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    WindowManager.LayoutParams params = getWindow().getAttributes();
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (landscape_content.getVisibility() == View.VISIBLE) {
                    landscape_content.setVisibility(View.GONE);
                    hideStatusBar();
                    isPanelShowing_Landscape = false;
                }
            }
        }, 5000);
        params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        getWindow().setAttributes(params);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        showLandscapePanel();
        ViewTreeObserver vto2 = content.getViewTreeObserver();
        vto2.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                content.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                full_screen_height = content.getHeight();
                full_screen_width = content.getWidth();
            }
        });
        currentState = 1;
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setAttributes(params);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        showPortraitPanel();
        Display.setLight(this, currentBrighrness, this.getWindow().getAttributes());
        full_screen_height = 0;
        full_screen_width = 0;
        currentState = 0;
    }
}
 
源代码12 项目: dynamic-support   文件: DynamicAppWidgetProvider.java
/**
 * Update widget width and height according to the current orientation.
 *
 * @param context The context associated with this widget provider.
 * @param appWidgetManager The app widget manager.
 * @param appWidgetId The app widget id to update the dimensions.
 */
protected void updateWidgetDimensions(@NonNull Context context,
        @NonNull AppWidgetManager appWidgetManager, int appWidgetId) {
    if (DynamicSdkUtils.is16()) {
        Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
        if (context.getResources().getConfiguration().orientation
                == Configuration.ORIENTATION_LANDSCAPE) {
            mWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH);
            mHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
        } else {
            mWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
            mHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);
        }
    }
}
 
源代码13 项目: QuranAndroid   文件: HighlightImageView.java
/**
 * Function fire in repaint
 *
 * @param canvas View canvas
 */
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    //show popup in touch selection mood if there is no running activities
    if (mRects.size() != 0
            && selectionFromTouch
            && !Settings.isMyServiceRunning(context, AudioService.class)) {
        //check the display configuration
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            displayPopupWindow((int) (xImageOffset + (float) (mRects.get(0).left * scaleRatio))
                    , (int) (yImageOffset + (float) (mRects.get(0).top * scaleRatio)));
        } else {
            displayPopupWindow((int) (xImageOffset + (float) (mRects.get(mRects.size() - 1).left * scaleRatio))
                    , (int) (yImageOffset + (float) (mRects.get(mRects.size() - 1).bottom * scaleRatio)));
        }
    }

    //Draw rectangles on image
    for (RectF rect : mRects) {
        float rTop = yImageOffset + (float) (rect.top * scaleRatio);
        float rBottom = yImageOffset + (float) (rect.bottom * scaleRatio);
        float rLeft = xImageOffset + (float) (rect.left * scaleRatio);
        float rRight = xImageOffset + (float) (rect.right * scaleRatio);
        canvas.drawRect(new RectF(rLeft, rTop, rRight, rBottom), mPaint);
    }
}
 
源代码14 项目: Pixiv-Shaft   文件: BaseFragment.java
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = requireContext();
    mActivity = requireActivity();

    Bundle bundle = getArguments();
    if (bundle != null) {
        initBundle(bundle);
    }

    Intent intent = mActivity.getIntent();
    if (intent != null) {
        Bundle activityBundle = intent.getExtras();
        if (activityBundle != null) {
            initActivityBundle(bundle);
        }
    }


    if (eventBusEnable()) {
        EventBus.getDefault().register(this);
    }

    //获取屏幕方向
    int ori = getResources().getConfiguration().orientation;
    if (ori == Configuration.ORIENTATION_LANDSCAPE) {
        isVertical = false;
    } else if (ori == Configuration.ORIENTATION_PORTRAIT) {
        isVertical = true;
    }
}
 
源代码15 项目: KernelAdiutor   文件: RecyclerViewFragment.java
public int getSpanCount() {
    Activity activity;
    if ((activity = getActivity()) != null) {
        int span = Utils.isTablet(activity) ? Utils.getOrientation(activity) ==
                Configuration.ORIENTATION_LANDSCAPE ? 3 : 2 : Utils.getOrientation(activity) ==
                Configuration.ORIENTATION_LANDSCAPE ? 2 : 1;
        if (itemsSize() != 0 && span > itemsSize()) {
            span = itemsSize();
        }
        return span;
    }
    return 1;
}
 
源代码16 项目: SublimePicker   文件: ButtonHandler.java
public ButtonHandler(@NonNull SublimePicker sublimePicker) {
    Context context = sublimePicker.getContext();

    mIsInLandscapeMode = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    if (mIsInLandscapeMode) {
        initializeForLandscape(sublimePicker);
    } else {
        // Takes care of initialization
        mPortraitButtonHandler = (ButtonLayout) sublimePicker.findViewById(R.id.button_layout);
    }
}
 
源代码17 项目: NanoIconPack   文件: ReqMenuDialog.java
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);

    Bundle bundle = getArguments();
    pos = bundle.getInt("pos");
    bean = (AppBean) bundle.getSerializable("bean");

    contentView = View.inflate(getContext(), R.layout.fragment_req_menu, null);
    dialog.setContentView(contentView);

    ((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel());
    if (bean.isMark()) {
        contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE);
        contentView.findViewById(R.id.view_menu_undo_mark).setOnClickListener(this);
        contentView.findViewById(R.id.view_hint_undo_mark)
                .setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE);
    } else {
        contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE);
        contentView.findViewById(R.id.view_menu_mark).setOnClickListener(this);
        contentView.findViewById(R.id.view_hint_mark)
                .setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE);
    }
    contentView.findViewById(R.id.view_hint_lost)
            .setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE);
    contentView.findViewById(R.id.view_menu_goto_market).setOnClickListener(this);
    contentView.findViewById(R.id.view_menu_copy_code).setOnClickListener(this);

    BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior
            .from((View) contentView.getParent());
    if (bean.isHintLost()) {
        // In landscape, STATE_EXPANDED doesn't make sheet expanded.
        // Maybe it's a bug. So do this to fix it.
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            contentView.measure(0, 0);
            bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
        }
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
        bottomSheetBehavior.setPeekHeight(getResources()
                .getDimensionPixelSize(R.dimen.req_bottom_menu_height));
    }
}
 
源代码18 项目: edslite   文件: UserSettingsCommon.java
public static boolean isWideScreenLayout(SettingsCommon settings, Activity activity)
{
	return !settings.disableLargeSceenLayouts() && activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
 
源代码19 项目: PercentageChartView   文件: ScreenUtil.java
/**
 * @param context Context instance
 * @return [true] if the device is in landscape orientation, [false] otherwise.
 */
public static boolean isInLandscapeOrientation(Context context) {
    Configuration configuration = context.getResources().getConfiguration();
    return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE;
}
 
源代码20 项目: InviZible   文件: MainFragment.java
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.main_fragment, container, false);

    btnStartMainFragment = view.findViewById(R.id.btnStartMainFragment);
    btnStartMainFragment.setOnClickListener(this);

    chbHideIpMainFragment = view.findViewById(R.id.chbHideIpMainFragment);

    chbProtectDnsMainFragment = view.findViewById(R.id.chbProtectDnsMainFragment);

    chbAccessITPMainFragment = view.findViewById(R.id.chbAccessITPMainFragment);

    tvDNSMainFragment = view.findViewById(R.id.tvDNSMainFragment);
    tvTorMainFragment = view.findViewById(R.id.tvTorMainFragment);
    tvITPDMainFragment = view.findViewById(R.id.tvITPDMainFragment);

    pbDNSMainFragment = view.findViewById(R.id.pbDNSMainFragment);
    pbTorMainFragment = view.findViewById(R.id.pbTorMainFragment);
    pbITPDMainFragment = view.findViewById(R.id.pbITPDMainFragment);

    if (getActivity() == null) {
        return view;
    }

    orientationLandscape = Utils.INSTANCE.getScreenOrientation(getActivity()) == Configuration.ORIENTATION_LANDSCAPE;

    boolean hideIp = new PrefManager(getActivity()).getBoolPref("HideIp");
    boolean protectDns = new PrefManager(getActivity()).getBoolPref("ProtectDns");
    boolean accessITP = new PrefManager(getActivity()).getBoolPref("AccessITP");

    if (!hideIp && !protectDns && !accessITP) {
        new PrefManager(getActivity()).setBoolPref("HideIp", true);
        new PrefManager(getActivity()).setBoolPref("ProtectDns", true);
        new PrefManager(getActivity()).setBoolPref("AccessITP", false);
    } else {
        chbHideIpMainFragment.setChecked(hideIp);
        chbProtectDnsMainFragment.setChecked(protectDns);
        chbAccessITPMainFragment.setChecked(accessITP);
    }

    chbHideIpMainFragment.setOnCheckedChangeListener(this);
    chbProtectDnsMainFragment.setOnCheckedChangeListener(this);
    chbAccessITPMainFragment.setOnCheckedChangeListener(this);

    return view;
}