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:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        for (int i = 0, count = fm.getBackStackEntryCount(); i < count; i++) {
            fm.popBackStackImmediate();/*from ww w .  j  av  a2  s.c om*/
        }
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:com.near.chimerarevo.activities.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if ((newConfig.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
            isLandscapeLarge = true;/*from  w  w  w .jav a 2  s  .  co m*/
        else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
            isLandscapeLarge = false;
    }
    if (mDrawerLayout != null)
        mDrawerToggle.onConfigurationChanged(newConfig);
}

From source file:fr.matthiasbosc.translucentmap.MainActivity.java

public void setMapPadding() {
    int topPadding = actionBarHeight() + statusBarHeight();
    int orientation = this.getResources().getConfiguration().orientation;

    if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (hasTranslucentBars)) {
        mMap.setPadding(0, topPadding, 0, navBarHeight());
    } else if ((orientation == Configuration.ORIENTATION_LANDSCAPE && (deviceType()) && (hasTranslucentBars))) {
        mMap.setPadding(0, topPadding, 0, navBarHeight());
    } else if ((orientation == Configuration.ORIENTATION_LANDSCAPE && (!deviceType())
            && (hasTranslucentBars))) {
        mMap.setPadding(0, topPadding, navBarHeight(), 0);
    } else if ((orientation == Configuration.ORIENTATION_PORTRAIT && (!hasTranslucentBars))) {
        mMap.setPadding(0, actionBarHeight(), 0, 0);
    } else if ((orientation == Configuration.ORIENTATION_LANDSCAPE && (!hasTranslucentBars))) {
        mMap.setPadding(0, actionBarHeight(), 0, 0);
    }//from w  ww. j a v a 2s. com
}

From source file:org.videolan.vlc.gui.video.VideoGridFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
            || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        updateViewMode();/*from  w  ww .ja va 2 s . com*/
    }
}

From source file:com.leo.runningman.ui.ImageDetailActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Log.i(TAG, "onConfigurationChanged--->" + newConfig.orientation);
    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {

    } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

    }//from   w  w  w  .  j  a v  a2s . c  o m
}

From source file:com.farmerbb.taskbar.fragment.AdvancedFragment.java

private void updateDashboardGridSize(boolean restartTaskbar) {
    SharedPreferences pref = U.getSharedPreferences(getActivity());
    int width = pref.getInt("dashboard_width",
            getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_width));
    int height = pref.getInt("dashboard_height",
            getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_height));

    boolean isPortrait = getActivity().getApplicationContext().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    boolean isLandscape = getActivity().getApplicationContext().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    int first = -1;
    int second = -1;

    if (isPortrait) {
        first = height;/*from  ww w .  j a  v  a  2  s  . c  om*/
        second = width;
    }

    if (isLandscape) {
        first = width;
        second = height;
    }

    findPreference("dashboard_grid_size")
            .setSummary(getString(R.string.dashboard_grid_description, first, second));

    if (restartTaskbar)
        U.restartTaskbar(getActivity());
}

From source file:com.tmall.wireless.tangram.view.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;
}

From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java

public void onItemClickOnListFragment(SherlockListFragment fragment, Object data) {
    if (fragment instanceof BugsListFragment) {
        final Bug bug = (Bug) data;
        int orientation = getResources().getConfiguration().orientation;
        switch (orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            Intent intent = BugMultiPaneActivity.getIntent(getActivity(), bug.bugId, bug.summary);
            startActivity(intent);/*from w ww .  java  2  s . c om*/
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            if (!mIsBugShown) {
                collapseBugsPane();
                mBugPane.setVisibility(View.VISIBLE);
                Animation toLeft = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_right);
                toLeft.setAnimationListener(new AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                        if (mBugFragment != null) {
                            FragmentTransaction ft = getSherlockActivity().getSupportFragmentManager()
                                    .beginTransaction();
                            ft.remove(mBugFragment).commit();
                        }
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        mBugFragment = BugFragment.newInstance(bug.bugId, bug.summary);
                        FragmentTransaction ft = getSherlockActivity().getSupportFragmentManager()
                                .beginTransaction();
                        ft.replace(R.id.fragment_container_bug, mBugFragment).commit();
                    }
                });
                mBugPane.startAnimation(toLeft);
            } else {
                mBugFragment = BugFragment.newInstance(bug.bugId, bug.summary);
                FragmentTransaction ft = getSherlockActivity().getSupportFragmentManager().beginTransaction();
                ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
                ft.replace(R.id.fragment_container_bug, mBugFragment).commit();
            }

            break;
        }
    }
}

From source file:com.nextgis.maplibui.util.ControlHelper.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static void lockScreenOrientation(Activity activity) {
    WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
    Configuration configuration = activity.getResources().getConfiguration();
    int rotation = windowManager.getDefaultDisplay().getRotation();

    // Search for the natural position of the device
    if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
            || configuration.orientation == Configuration.ORIENTATION_PORTRAIT
                    && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) {
        // Natural position is Landscape
        switch (rotation) {
        case Surface.ROTATION_0:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        case Surface.ROTATION_90:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            break;
        case Surface.ROTATION_180:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            break;
        case Surface.ROTATION_270:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        }/*from www .ja va  2  s  .c  o  m*/
    } else {
        // Natural position is Portrait
        switch (rotation) {
        case Surface.ROTATION_0:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        case Surface.ROTATION_90:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        case Surface.ROTATION_180:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            break;
        case Surface.ROTATION_270:
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            break;
        }
    }
}

From source file:edu.cmu.android.restaurant.MapFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    /* menu : camera */
    case Menu.FIRST + 1:
        try {/*from ww  w  .j a  v a2s  . c o m*/
            Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
            startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER);
        } catch (Exception e) {
            Log.d("Detail", "Cemara onClick error.");
        } finally {
            if (getActivity().getResources()
                    .getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT) {
                getActivity().setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
            }
        }
        break;

    /* menu : coupon */
    case Menu.FIRST + 2:
        /* display the deal in a dialog */
        findDeal();
        dealDisplay();
        /* audio play */
        MediaPlayer mp = MediaPlayer.create(getActivity(), R.raw.coupon_audio);
        mp.seekTo(0);
        mp.start();
        break;

    /* Menu : about */
    case Menu.FIRST + 3:
        Builder builder3 = new AlertDialog.Builder(getActivity());
        builder3.setTitle("About US");
        builder3.setMessage(ABOUT_CONTENT);
        builder3.setPositiveButton("Return", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).show();
        break;
    }
    return false;

}