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:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Called when the device configuration changes.
 *///from   w ww . j av  a 2 s.co  m
@Override
public void onConfigurationChanged(Configuration newConfig) {
    Log.d(LOG, LOG + ".onConfigurationChanged");
    super.onConfigurationChanged(newConfig);

    // Signal to the Governor that a runtime change has occurred.
    governor.onRuntimeChange();

    // Change the orientation of the PanelsLayout accordingly.
    LinearLayout panelsLayout = (LinearLayout) findViewById(R.id.PanelsLayout);
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        panelsLayout.setOrientation(LinearLayout.VERTICAL);
    } else {
        panelsLayout.setOrientation(LinearLayout.HORIZONTAL);
    }

    // Set the divider again, because it needs to be redrawn due to the orientation change.
    panelsLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_panels));

    // Inform ActionBar Drawer Toggle of the change.
    actionBarDrawerToggle.onConfigurationChanged(newConfig);
}

From source file:com.ferdi2005.secondgram.AndroidUtilities.java

public static void lockOrientation(Activity activity) {
    if (activity == null || prevOrientation != -10) {
        return;//from  ww w . ja va 2 s . c o  m
    }
    try {
        prevOrientation = activity.getRequestedOrientation();
        WindowManager manager = (WindowManager) activity.getSystemService(Activity.WINDOW_SERVICE);
        if (manager != null && manager.getDefaultDisplay() != null) {
            int rotation = manager.getDefaultDisplay().getRotation();
            int orientation = activity.getResources().getConfiguration().orientation;

            if (rotation == Surface.ROTATION_270) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_90) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_0) {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                }
            } else {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                }
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}

From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java

private void populateActionBar(final ActionBar actionBar) {
    MBViewManager.getInstance().runOnUiThread(new Runnable() {
        @Override//www .  j a  va 2  s . co  m
        public void run() {
            MBTabBar tabBar = new MBTabBar(_context);

            for (String dialogName : MBViewManager.getInstance().getDialogManager().getSortedDialogNames()) {
                MBDialogDefinition dialogDefinition = MBMetadataService.getInstance()
                        .getDefinitionForDialogName(dialogName);

                if (dialogDefinition.isPreConditionValid() && dialogDefinition.isShowAsTab()) {
                    if (dialogDefinition.getDomain() != null) {
                        MBDomainDefinition domainDef = MBMetadataService.getInstance()
                                .getDefinitionForDomainName(dialogDefinition.getDomain());

                        final MBTabSpinnerAdapter tabSpinnerAdapter = new MBTabSpinnerAdapter(_context,
                                android.R.layout.simple_spinner_dropdown_item);

                        for (MBDomainValidatorDefinition domDef : domainDef.getDomainValidators()) {
                            tabSpinnerAdapter.add(domDef.getTitle());
                        }

                        Drawable drawable = MBResourceService.getInstance().getImageByID("tab-spinner-leaf");

                        MBTab tab = new MBTab(_context);
                        tab.setAdapter(tabSpinnerAdapter);
                        tab.setSelectedBackground(drawable);
                        if (dialogDefinition.getIcon() != null) {
                            tab.setIcon(
                                    MBResourceService.getInstance().getImageByID(dialogDefinition.getIcon()));
                        }
                        setTabText(dialogDefinition, tab, tabBar);

                        tab.setName(dialogName);
                        tab.setListener(new MBTabListener(dialogName));

                        tabBar.addTab(tab);

                        if (ComparisonUtil.safeEquals(dialogName,
                                MBViewManager.getInstance().getActiveDialogName()))
                            tabBar.selectTab(tab, true);
                    } else {
                        MBTab tab = new MBTab(_context);
                        setTabText(dialogDefinition, tab, tabBar);

                        tab.setListener(new MBTabListener(dialogName));
                        tab.setName(dialogName);

                        if (dialogDefinition.getIcon() != null) {
                            tab.setIcon(
                                    MBResourceService.getInstance().getImageByID(dialogDefinition.getIcon()));
                        }
                        tabBar.addTab(tab);

                        if (ComparisonUtil.safeEquals(dialogName,
                                MBViewManager.getInstance().getActiveDialogName()))
                            tabBar.selectTab(tab, true);
                    }
                }
            }

            MBStyleHandler styleHandler = MBViewBuilderFactory.getInstance().getStyleHandler();

            //fix the Home icon padding
            View homeIcon = null;
            if (DeviceUtil.getInstance().hasNativeActionBarSupport()) {
                homeIcon = MBViewManager.getInstance().findViewById(R.id.home);
            } else {
                homeIcon = MBViewManager.getInstance().findViewById(android.support.v7.appcompat.R.id.home);
            }

            if (homeIcon != null) {
                styleHandler.styleHomeIcon(homeIcon);
                actionBar.setHomeButtonEnabled(true);
            }

            styleHandler.styleActionBar(actionBar);

            int actionBarDisplayOptions = ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME
                    | ActionBar.DISPLAY_USE_LOGO;
            actionBar.setDisplayOptions(actionBarDisplayOptions);

            final View customView;
            if (!tabBar.isEmpty()) {
                customView = tabBar;
            } else {
                //          LinearLayout linearLayout = new LinearLayout(MBNextGenViewManager.this);
                //          linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                //
                //          TextView textView = new TextView(MBNextGenViewManager.this);
                //          textView.setText(getTitle());
                //          linearLayout.addView(textView);

                MBHeader header = new MBHeader(_context);
                header.setTitleText((String) MBViewManager.getInstance().getTitle());

                styleHandler.styleActionBarHeader(header);
                styleHandler.styleActionBarHeaderTitle(header.getTitleView());

                customView = header;
            }

            actionBar.setCustomView(customView, new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
                    ActionBar.LayoutParams.MATCH_PARENT, Gravity.LEFT));
        }

        private void setTabText(MBDialogDefinition dialogDefinition, MBTab tab, MBTabBar tabBar) {
            String title;

            if (_context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                title = dialogDefinition.getTitlePortrait();
            } else {
                title = dialogDefinition.getTitle();
            }

            if (StringUtil.isNotBlank(title)) {
                tab.setText(title);
                tabBar.setTabPadding(0, 0, ScreenConstants.SIXTEEN, 0);
            } else {
                tabBar.setTabPadding(0, 0, 0, 0);
            }
        }
    });
}

From source file:org.bottiger.podcast.utils.UIUtils.java

public static int NavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int orientation = resources.getConfiguration().orientation;

    int id = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height"
            : "navigation_bar_height_landscape", "dimen", "android");
    if (id > 0) {
        return resources.getDimensionPixelSize(id);
    }/*from  w  w  w .  j a  v a 2  s .c om*/
    return 0;
}

From source file:com.flipzu.flipzu.ListingsFragment.java

private void initGATracker() {
    /* get analytics singleton */
    tracker = GoogleAnalyticsTracker.getInstance();

    /* start tracker. Dispatch every 30 seconds. */
    tracker.startNewSession("UA-20341887-1", 30, getSupportActivity().getApplicationContext());

    /* debug GA */
    tracker.setDebug(false);/*  ww w. ja v  a  2 s .  c om*/
    tracker.setDryRun(false);

    // Determine the screen orientation and set it in a custom variable.
    String orientation = "unknown";
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        orientation = "landscape";
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        orientation = "portrait";
        break;
    }
    tracker.setCustomVar(3, "Screen Orientation", orientation, 2);
}

From source file:com.dtech.uniqilm.activities.ActivityHome.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.//from   w  w w  . j  ava 2s.c o m
 */
private void layout() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    if (isFullscreen) {
        mToolbar.setVisibility(View.GONE);
        frmLayoutList.setVisibility(View.GONE);
        setLayoutSize(mFragmentVideo.getView(), MATCH_PARENT, MATCH_PARENT);
    } else if (isPortrait) {
        mToolbar.setVisibility(View.VISIBLE);
        frmLayoutList.setVisibility(View.VISIBLE);
        setLayoutSize(mFragmentVideo.getView(), WRAP_CONTENT, WRAP_CONTENT);
    } else {
        mToolbar.setVisibility(View.VISIBLE);
        frmLayoutList.setVisibility(View.VISIBLE);
        int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp);
        int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP);
        setLayoutSize(mFragmentVideo.getView(), videoWidth, WRAP_CONTENT);
    }
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

private boolean snapToColumnWhenScrolling() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    return mSnapToColumnWhenScrolling && isPortrait;
}

From source file:com.binomed.showtime.android.screen.results.tablet.CineShowTimeResultsTabletActivity.java

@Override
protected void initContentView() {
    Log.i(getTAG(), "initContentView");
    fragmentResult = (CineShowTimeResultsFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragmentResults);
    Fragment recycleFragment = getSupportFragmentManager().findFragmentById(R.id.fragmentInfo);
    if (recycleFragment == null) {
        fragmentFrame = new CineShowTimeFrameFragment();
        getSupportFragmentManager().beginTransaction().add(R.id.fragmentInfo, fragmentFrame).commit();
    } else if (recycleFragment.getClass() == CineShowTimeFrameFragment.class) {
        fragmentFrame = (CineShowTimeFrameFragment) getSupportFragmentManager()
                .findFragmentById(R.id.fragmentInfo);
    }//from   ww w.  j av  a 2 s . c om

    // We check if we're in portrait mode in order to manage specific expand
    Configuration conf = getResources().getConfiguration();
    portraitMode = conf.orientation == Configuration.ORIENTATION_PORTRAIT;
    if (portraitMode) {
        infoLayout = (LinearLayout) findViewById(R.id.fragmentInfo);

        fragmentResult.setNonExpendable(true);
        showtimeList = (ListView) findViewById(R.id.showtimesResults);
        showtimeList.setOnItemClickListener(this);
        adapter = new CineShowTimeShowTimesListAdapter(this);
        if ((movieList != null) && (movieList.size() > 0) && (theater != null)) {
            adapter.setShowTimesList(movieList, theater);
            getModelActivity().getGroupExpanded()
                    .add(getModelActivity().getNearResp().getTheaterList().indexOf(theater));
        }
        showtimeList.setAdapter(adapter);
    }

}

From source file:com.hplasplas.cam_capture.activitys.CamCapture.java

private void loadMainBitmap(String fileName, int requestedHeight, int requestedWidth) {

    int orientation = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
            ? Configuration.ORIENTATION_PORTRAIT
            : Configuration.ORIENTATION_LANDSCAPE;
    mainProgressBar.setVisibility(View.VISIBLE);
    MainExecutor.getInstance().execute(new BitmapInThreadLoader(this,
            createBundleBitmap(fileName, MAIN_PICTURE_INDEX, requestedHeight, requestedWidth, 0, orientation)));
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

private boolean snapToColumnWhenDragging() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    return mSnapToColumnWhenDragging && isPortrait;
}