Example usage for android.content.res Configuration ORIENTATION_PORTRAIT

List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT

Introduction

In this page you can find the example usage for android.content.res Configuration ORIENTATION_PORTRAIT.

Prototype

int ORIENTATION_PORTRAIT

To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.

Click Source Link

Document

Constant for #orientation , value corresponding to the port resource qualifier.

Usage

From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java

/**
 * Loading different view when orientation is portrait or landscape.
 *//*from   www .ja va2s  .c  om*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // Selecting the different attributes in the week view, not visible in portrait day view.
    if (mMenu != null) {
        MenuItem selectAttribute = mMenu.findItem(R.id.mood_history_select_attribute);
        if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            loadPortraitView();
            selectAttribute.setVisible(false);
        } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            loadLandscapeView();
            selectAttribute.setVisible(true);

            new ShowcaseView.Builder(this, true)
                    .setTarget(new ActionItemTarget(this, R.id.mood_history_select_attribute))
                    .setContentTitle("Tlt voit valita mit kuvaajassa nytetn")
                    .setContentText("Klikkaamalla tst voit vaihtaa mit kuvaajassa nytetn.")
                    .hideOnTouchOutside().setStyle(R.style.ShowcaseView).singleShot(SELECT_ATTRIBUTE_HELP_ID)
                    .build();
        }
    }
}

From source file:com.inovex.zabbixmobile.activities.ChecksActivity.java

protected void showItemDetailsFragment() {
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    ft.hide(mHostListFragment);/*from w ww  . ja va 2s  .  co m*/
    ft.show(mItemDetailsFragment);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        // portrait
        ft.hide(mApplicationsFragment);
    } else {
        // landscape
        ft.show(mItemDetailsFragment);
    }
    ft.commit();
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    mDrawerToggle.setDrawerIndicatorEnabled(false);
    // details fragment becomes visible -> enable menu
    mItemDetailsFragment.setHasOptionsMenu(true);
}

From source file:com.thinkman.thinkutils.view.ActionSheet.java

public int getNavBarHeight(Context c) {
    int result = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey();
        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

        if (!hasMenuKey && !hasBackKey) {
            //The device has a navigation bar
            Resources resources = c.getResources();

            int orientation = getResources().getConfiguration().orientation;
            int resourceId;
            if (isTablet(c)) {
                resourceId = resources.getIdentifier(
                        orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height"
                                : "navigation_bar_height_landscape",
                        "dimen", "android");
            } else {
                resourceId = resources.getIdentifier(
                        orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height"
                                : "navigation_bar_width",
                        "dimen", "android");
            }//from ww  w .jav  a 2  s  .  co  m

            if (resourceId > 0) {
                return getResources().getDimensionPixelSize(resourceId);
            }
        }
    }
    return result;
}

From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java

protected void selectTool(ToolType toolType) {
    if (PaintroidApplication.currentTool.getToolType() == toolType) {
        scrollToToolButton(toolType);//from   w  w  w  .  ja v  a  2s . co  m
        return;

    }

    int orientation = mSolo.getCurrentActivity().getResources().getConfiguration().orientation;
    View toolButtonView = null;
    if (orientation == Configuration.ORIENTATION_PORTRAIT)
        toolButtonView = scrollToToolButton(toolType);
    else if (orientation == Configuration.ORIENTATION_LANDSCAPE)
        toolButtonView = verticalScrollToToolButton(toolType);
    mSolo.clickOnView(toolButtonView);
    waitForToolToSwitch(toolType);
}

From source file:com.koushikdutta.superuser.FragmentMain.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    context = getActivity();/*from  ww w.j a va2s  .c  o m*/

    pref = PreferenceManager.getDefaultSharedPreferences(context);

    callback = (MainCallback) getActivity();

    LocalBroadcastManager.getInstance(context).registerReceiver(receiver,
            new IntentFilter(Common.INTENT_FILTER_MAIN));

    gridMode = pref.getBoolean("grid_mode", true);

    coordinatorLayout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content);

    //tabLayout = (TabLayout) getActivity().findViewById(R.id.tabs);

    //viewPager = (ViewPager) getActivity().findViewById(R.id.container);

    int span = 0;

    if (gridMode) {
        layoutManager = new RecyclerViewSwipeable.LayoutManagerSwipeable(context, 1);

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            span = pref.getInt("grid_size_port", 3);
            layoutManager.setSpanCount(span);

        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            span = pref.getInt("grid_size_land", 4);
            layoutManager.setSpanCount(span);
        }

        Drawable divider = ContextCompat.getDrawable(context, R.drawable.divider_grid);
        divider.setColorFilter(new PorterDuffColorFilter(ATHUtil.resolveColor(context, R.attr.dividerGrid),
                PorterDuff.Mode.SRC_ATOP));

        recycler.setLayoutManager(layoutManager);

        recycler.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(context, R.anim.grid_layout_animation));

        recycler.addItemDecoration(new GridDividerItemDecoration(divider, divider, span));

        recycler.addItemDecoration(new GridTopOffsetItemDecoration(Util.toPx(context, 5), span));

    } else {
        recycler.setLayoutManager(new LinearLayoutManager(context));

        recycler.addItemDecoration(new StartOffsetItemDecoration(Util.toPx(context, 10)));
    }

    //recycler.setListener(clickListener);
    //recycler.setViewPager(viewPager);
    //recycler.setFragment(this);

    setData();
}

From source file:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        this.setContentView(R.layout.activity_zhibo);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        screen_direction = SCREEN_LAND;//from  ww w .j  a  v  a  2  s . c  o m
        initLandView();
        setLandOnClick();
        isShowLayout = true;
        if (isPlayed) {
            player.leave();
            player.setGSVideoView(mGSzhiboLand);
            initplayer();
            mivPlayLand.setVisibility(View.GONE);
        }
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        this.setContentView(R.layout.activity_zhibo);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        screen_direction = SCREEN_PORT;
        initView();
        zhibo_viewpager.addOnPageChangeListener(new ZhiboOnPageChangeListener());
        initClickListener();
        zhiboVPAdapter = new ZhiboVPAdapter(getSupportFragmentManager(), mFragments);
        zhibo_viewpager.setAdapter(zhiboVPAdapter);
        setOnClick();
        isShowLayout = true;
        if (isPlayed) {
            mIvplayer.setVisibility(View.GONE);
            player.leave();
            player.setGSVideoView(mGSzhibo);
            initplayer();
        }
    }
}

From source file:net.bible.service.common.CommonUtils.java

public static boolean isPortrait() {
    return BibleApplication.getApplication().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}

From source file:me.drakeet.meizhi.ui.GankFragment.java

private void setVideoViewPosition(Configuration newConfig) {
    switch (newConfig.orientation) {
    case Configuration.ORIENTATION_LANDSCAPE: {
        if (mIsVideoViewInflated) {
            mVideoViewStub.setVisibility(View.VISIBLE);
        } else {//from  www. ja va  2  s.c  o  m
            mVideoView = (LoveVideoView) mVideoViewStub.inflate();
            mIsVideoViewInflated = true;
            String tip = getString(R.string.tip_video_play);
            // @formatter:off
            new Once(mVideoView.getContext()).show(tip, () -> Snackbar
                    .make(mVideoView, tip, Snackbar.LENGTH_INDEFINITE).setAction(R.string.i_know, v -> {
                    }).show());
            // @formatter:on
        }
        if (mGankList.size() > 0 && mGankList.get(0).type.equals("?")) {
            mVideoView.loadUrl(mGankList.get(0).url);
        }
        break;
    }
    case Configuration.ORIENTATION_PORTRAIT:
    case Configuration.ORIENTATION_UNDEFINED:
    default: {
        mVideoViewStub.setVisibility(View.GONE);
        break;
    }
    }
}

From source file:org.zakky.memopad.PadActivity.java

private void fixOrientation() {
    final Configuration config = getResources().getConfiguration();
    if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
        // TODO SCREEN_ORIENTATION_REVERSE_PORTRAIT ?
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {/*from  w ww. j a va2  s.  co m*/
        // TODO SCREEN_ORIENTATION_REVERSE_LADSCAPE ?
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:com.cw.litenote.util.video.UtilVideo.java

public static void setVideoViewDimensions(BitmapDrawable bitmapDrawable) {
    int screenHeight = UtilImage.getScreenHeight(mAct);
    int screenWidth = UtilImage.getScreenWidth(mAct);
    //        System.out.println("UtilVideo / _setVideoViewDimensions / screenHeight = " + screenHeight + ", screenWidth = " + screenWidth);

    int bitmapHeight = 0, bitmapWidth = 0;
    int config_orientation = mAct.getResources().getConfiguration().orientation;

    Bitmap bitmap = bitmapDrawable.getBitmap();
    boolean bitmapIsLandScape = false;
    boolean bitmapIsPortrait = false;

    if (bitmap != null) {
        bitmapHeight = bitmap.getHeight();
        bitmapWidth = bitmap.getWidth();
        System.out.println("UtilVideo / _setVideoViewDimensions / bitmapHeight = " + bitmapHeight
                + ", bitmapWidth = " + bitmapWidth);
        bitmapIsLandScape = (bitmapWidth > bitmapHeight) ? true : false;
        bitmapIsPortrait = (bitmapHeight > bitmapWidth) ? true : false;
        //             System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsLandScape 1 = " + bitmapIsLandScape);
        //             System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsPortrait 1 = " + bitmapIsPortrait);
    } else {/*from   w  ww  .j  ava 2 s .  com*/
        // for remote video which there is no way to get bitmap yet
        // default dimension
        bitmapWidth = screenWidth;
        bitmapHeight = screenHeight / 2;
        // default orientation is landscape
        AsyncTaskVideoBitmapPager.mRotationStr = "0"; //
    }

    String rotDeg = AsyncTaskVideoBitmapPager.mRotationStr;
    if (rotDeg != null) {
        System.out.println("UtilVideo / _setVideoViewDimensions / rotDeg = " + rotDeg);
        if (rotDeg.equalsIgnoreCase("0")) {
            bitmapIsLandScape = true;
            bitmapIsPortrait = false;
        } else if (rotDeg.equalsIgnoreCase("90")) {
            bitmapIsLandScape = false;
            bitmapIsPortrait = true;
        }
    }
    //         System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsLandScape 2 = " + bitmapIsLandScape);
    //         System.out.println("UtilVideo / _setVideoViewDimensions / bitmapIsPortrait 2 = " + bitmapIsPortrait);

    int dimWidth = 0;
    int dimHeight = 0;
    // for landscape screen
    if (config_orientation == Configuration.ORIENTATION_LANDSCAPE) {
        // for landscape bitmap
        if (bitmapIsLandScape) {
            System.out.println("UtilVideo / _setVideoViewDimensions / L_scr L_bmp");
            dimWidth = screenWidth;
            dimHeight = screenHeight;
        } // for portrait bitmap
        else if (bitmapIsPortrait) {
            System.out.println("UtilVideo / _setVideoViewDimensions / L_scr P_bmp");
            // set screen height to be constant, and set screen width by proportional
            int propotionalWidth = 0;
            if (bitmap != null) {
                propotionalWidth = (bitmapWidth > bitmapHeight)
                        ? Math.round(screenHeight * bitmapHeight / bitmapWidth)
                        : Math.round(screenHeight * bitmapWidth / bitmapHeight);
            } else
                propotionalWidth = Math.round(screenHeight * screenHeight / screenWidth);

            dimWidth = propotionalWidth;
            dimHeight = screenHeight;
        }
    } // for portrait screen
    else if (config_orientation == Configuration.ORIENTATION_PORTRAIT) {
        // for landscape bitmap
        if (bitmapIsLandScape) {
            System.out.println("UtilVideo / _setVideoViewDimensions / P_scr L_bmp");
            // set screen width to be constant, and set screen height by proportional
            int propotiaonalHeight = 0;
            if (bitmap != null) {

                propotiaonalHeight = (bitmapWidth > bitmapHeight)
                        ? Math.round(screenWidth * bitmapHeight / bitmapWidth)
                        : Math.round(screenWidth * bitmapWidth / bitmapHeight);
            } else
                propotiaonalHeight = Math.round(screenWidth * screenWidth / screenHeight);

            dimWidth = screenWidth;
            dimHeight = propotiaonalHeight;
        } // for portrait bitmap
        else if (bitmapIsPortrait) {
            System.out.println("UtilVideo / _setVideoViewDimensions / P_scr P_bmp");

            dimWidth = screenWidth;
            dimHeight = screenHeight;
        }
    }

    // set dimensions
    if (UtilVideo.mVideoView != null) {
        UtilVideo.mVideoView.setDimensions(dimWidth, dimHeight);
        UtilVideo.mVideoView.getHolder().setFixedSize(dimWidth, dimHeight);
        System.out.println("UtilVideo / _setVideoViewDimensions / dim Width = " + dimWidth + ", dim Height = "
                + dimHeight);
    }

}