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.xandy.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }//from   w  ww .j a v a  2  s. co m
    super.onCreate(icicle);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    // configureActionBar auto-selects the first tab you add, so we need to
    // call it before we set up our own fragments to make sure it doesn't
    // overwrite us
    configureActionBar(viewType);

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

/**
 * This method is responsible to handle the keyboard height based on the current orientation
 *//*from  w ww  .j av a  2 s.com*/
private void resolveKeyboardHeight() {
    Resources resources = getResources();
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    int orientation = resources.getConfiguration().orientation;

    switch (orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        mKeyboardHeight = Math.round(displayMetrics.heightPixels / PORTRAIT_HEIGHT_SCALE);
        break;
    case Configuration.ORIENTATION_LANDSCAPE:
        mKeyboardHeight = Math.round(displayMetrics.heightPixels / LANDSCAPE_HEIGHT_SCALE);
        break;
    }
}

From source file:com.saulcintero.moveon.fragments.Main.java

private void restartMap() {
    LinearLayout.LayoutParams layoutParams_1, layoutParams_2, layoutParams_3, layoutParams_4;
    if (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        layoutParams_1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutParams_1.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_1_left_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_1_top_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_1_right_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_1_bottom_portrait));

        layoutParams_2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                FunctionUtils.calculateDpFromPx(mContext, 195));
        layoutParams_2.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_2_left_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_2_top_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_2_right_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_2_bottom_portrait));

        layoutParams_3 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                FunctionUtils.calculateDpFromPx(mContext, 42));
        layoutParams_3.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_4_left_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_4_top_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_4_right_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_4_bottom_portrait));

        layoutParams_4 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                FunctionUtils.calculateDpFromPx(mContext, 42));
        layoutParams_4.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_5_left_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_5_top_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_5_right_portrait),
                (int) res.getDimension(R.dimen.practice_linearlayout_5_bottom_portrait));
    } else {/*from  ww w.  ja v  a2  s  . c  o  m*/
        layoutParams_1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT, 1.5f);
        layoutParams_1.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_1_left_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_1_top_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_1_right_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_1_bottom_landscape));

        layoutParams_2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                FunctionUtils.calculateDpFromPx(mContext, 65));
        layoutParams_2.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_2_left_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_2_top_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_2_right_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_2_bottom_landscape));

        layoutParams_3 = new LinearLayout.LayoutParams(FunctionUtils.calculateDpFromPx(mContext, 42),
                LinearLayout.LayoutParams.MATCH_PARENT, 0.0f);
        layoutParams_3.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_4_left_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_4_top_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_4_right_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_4_bottom_landscape));

        layoutParams_4 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                FunctionUtils.calculateDpFromPx(mContext, 42), 0.0f);
        layoutParams_4.setMargins((int) res.getDimension(R.dimen.practice_linearlayout_5_left_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_5_top_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_5_right_landscape),
                (int) res.getDimension(R.dimen.practice_linearlayout_5_bottom_landscape));
    }
    layout1.setLayoutParams(layoutParams_1);
    layout2.setLayoutParams(layoutParams_2);
    layout4.setLayoutParams(layoutParams_3);
    layout5.setLayoutParams(layoutParams_4);
}

From source file:com.waz.zclient.pages.main.drawing.DrawingFragment.java

@Override
public void onResume() {
    super.onResume();
    if (LayoutSpec.isTablet(getActivity())) {
        ViewUtils.lockScreenOrientation(Configuration.ORIENTATION_PORTRAIT, getActivity());
    }/*from w ww .  jav  a2  s  . c  o  m*/
}

From source file:com.tweetlanes.android.core.view.ComposeBaseFragment.java

protected void lockScreenRotation() {
    if (getActivity() != null) {
        switch (getActivity().getResources().getConfiguration().orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        }/*w  ww.  j ava 2 s  .  c o m*/
    }
}

From source file:com.gelakinetic.mtgfam.fragments.LifeCounterFragment.java

/**
 * Updates the display mode based on the current value of mDisplayMode. This updates the GridLayout's parameters
 * and draws the player's views in the fragment. It also shows and hides buttons and views relating to
 * commander mode.//from   w  w  w. jav  a  2  s .co  m
 */
public void changeDisplayMode(boolean shouldDefaultLives) {
    /* update the preference */
    PreferenceAdapter.setDisplayMode(getContext(), String.valueOf(mDisplayMode));

    mGridLayout.removeAllViews();

    if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        switch (mDisplayMode) {
        case DISPLAY_NORMAL:
            mGridLayout.setOrientation(GridLayout.HORIZONTAL);
            mGridLayout.setColumnCount(1);
            mGridLayout.setRowCount(GridLayout.UNDEFINED);
            break;
        case DISPLAY_COMPACT:
            mGridLayout.setOrientation(GridLayout.HORIZONTAL);
            mGridLayout.setColumnCount(2);
            mGridLayout.setRowCount(GridLayout.UNDEFINED);
            break;
        case DISPLAY_COMMANDER:
            mGridLayout.setOrientation(GridLayout.HORIZONTAL);
            mGridLayout.setColumnCount(2);
            mGridLayout.setRowCount(GridLayout.UNDEFINED);
            break;
        }
    } else {
        switch (mDisplayMode) {
        case DISPLAY_NORMAL:
            mGridLayout.setOrientation(GridLayout.HORIZONTAL);
            mGridLayout.setColumnCount(GridLayout.UNDEFINED);
            mGridLayout.setRowCount(1);
            break;
        case DISPLAY_COMPACT:
            mGridLayout.setOrientation(GridLayout.HORIZONTAL);
            mGridLayout.setColumnCount(GridLayout.UNDEFINED);
            mGridLayout.setRowCount(1);
            break;
        case DISPLAY_COMMANDER:
            mGridLayout.setOrientation(GridLayout.VERTICAL);
            mGridLayout.setColumnCount(GridLayout.UNDEFINED);
            if (mListSizeHeight != -1) {
                float height = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48,
                        getActivity().getResources().getDisplayMetrics());
                mGridLayout.setRowCount((int) (mListSizeHeight / height));
            } else {
                mGridLayout.setRowCount(GridLayout.UNDEFINED);
            }
            break;
        }
    }

    boolean areLivesDefault = true;
    for (LcPlayer player : mPlayers) {
        /* Only reset a player's default life / life if that player is unaltered and doesn't have a noticeably
         * custom default life */
        if (!(player.mLifeHistory.size() == 0 && player.mPoisonHistory.size() == 0
                && player.mLife == player.mDefaultLifeTotal && (player.mDefaultLifeTotal == DEFAULT_LIFE
                        || player.mDefaultLifeTotal == DEFAULT_LIFE_COMMANDER))) {
            areLivesDefault = false;
        }
    }

    if (areLivesDefault && shouldDefaultLives) {
        for (LcPlayer player : mPlayers) {
            player.mDefaultLifeTotal = getDefaultLife();
            player.mLife = player.mDefaultLifeTotal;
        }
    }

    for (LcPlayer player : mPlayers) {
        /* Draw the player's view */
        addPlayerView(player);
    }

    if (mDisplayMode == DISPLAY_COMMANDER) {
        mCommanderButton.setVisibility(View.VISIBLE);
        mCommanderPlayerView.setVisibility(View.VISIBLE);
        mCommanderPlayerView.removeAllViews();
        if (mPlayers.size() > 0 && null != mPlayers.get(0).mView) {
            mCommanderPlayerView.addView(mPlayers.get(0).mView);
            mPlayers.get(0).setSize(mListSizeWidth, mListSizeHeight, mDisplayMode, getActivity().getResources()
                    .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
        }
    } else {
        mCommanderPlayerView.setVisibility(View.GONE);
        mCommanderButton.setVisibility(View.GONE);
        if (mStatDisplaying == STAT_COMMANDER) {
            setStatDisplaying(STAT_LIFE);
        }
    }
}

From source file:com.vonglasow.michael.satstat.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    defaultUEH = Thread.getDefaultUncaughtExceptionHandler();

    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            Context c = getApplicationContext();
            File dumpDir = c.getExternalFilesDir(null);
            DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT);
            fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
            String fileName = String.format("satstat-%s.log", fmt.format(new Date(System.currentTimeMillis())));

            File dumpFile = new File(dumpDir, fileName);
            PrintStream s;/*from   w  ww. j  av a2 s.c  o  m*/
            try {
                InputStream buildInStream = getResources().openRawResource(R.raw.build);
                s = new PrintStream(dumpFile);
                s.append("SatStat build: ");

                int i;
                try {
                    i = buildInStream.read();
                    while (i != -1) {
                        s.write(i);
                        i = buildInStream.read();
                    }
                    buildInStream.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }

                s.append("\n\n");
                e.printStackTrace(s);
                s.flush();
                s.close();

                Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                Uri contentUri = Uri.fromFile(dumpFile);
                mediaScanIntent.setData(contentUri);
                c.sendBroadcast(mediaScanIntent);
            } catch (FileNotFoundException e2) {
                e2.printStackTrace();
            }
            defaultUEH.uncaughtException(t, e);
        }
    });

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
    prefUnitType = mSharedPreferences.getBoolean(Const.KEY_PREF_UNIT_TYPE, prefUnitType);
    prefKnots = mSharedPreferences.getBoolean(Const.KEY_PREF_KNOTS, prefKnots);
    prefCoord = Integer
            .valueOf(mSharedPreferences.getString(Const.KEY_PREF_COORD, Integer.toString(prefCoord)));
    prefUtc = mSharedPreferences.getBoolean(Const.KEY_PREF_UTC, prefUtc);
    prefCid = mSharedPreferences.getBoolean(Const.KEY_PREF_CID, prefCid);
    prefCid2 = mSharedPreferences.getBoolean(Const.KEY_PREF_CID2, prefCid2);
    prefWifiSort = Integer
            .valueOf(mSharedPreferences.getString(Const.KEY_PREF_WIFI_SORT, Integer.toString(prefWifiSort)));
    prefMapOffline = mSharedPreferences.getBoolean(Const.KEY_PREF_MAP_OFFLINE, prefMapOffline);
    prefMapPath = mSharedPreferences.getString(Const.KEY_PREF_MAP_PATH, prefMapPath);

    ActionBar actionBar = getSupportActionBar();

    setContentView(R.layout.activity_main);

    // Find out default screen orientation
    Configuration config = getResources().getConfiguration();
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    int rot = wm.getDefaultDisplay().getRotation();
    isWideScreen = (config.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (rot == Surface.ROTATION_0 || rot == Surface.ROTATION_180)
            || config.orientation == Configuration.ORIENTATION_PORTRAIT
                    && (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270));
    Log.d(TAG, "isWideScreen=" + Boolean.toString(isWideScreen));

    // Create the adapter that will return a fragment for each of the
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    Context ctx = new ContextThemeWrapper(getApplication(), R.style.AppTheme);
    mTabLayout = new TabLayout(ctx);
    LinearLayout.LayoutParams mTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    mTabLayout.setLayoutParams(mTabLayoutParams);

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        TabLayout.Tab newTab = mTabLayout.newTab();
        newTab.setIcon(mSectionsPagerAdapter.getPageIcon(i));
        mTabLayout.addTab(newTab);
    }

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(mTabLayout);

    mTabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
    mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));

    // This is needed by the mapsforge library.
    AndroidGraphicFactory.createInstance(this.getApplication());

    // Get system services for event delivery
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mOrSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    mAccSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mGyroSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    mMagSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    mLightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    mProximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    mPressureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);
    mHumiditySensor = sensorManager.getDefaultSensor(Sensor.TYPE_RELATIVE_HUMIDITY);
    mTempSensor = sensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE);
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
}

From source file:com.dm.wallpaper.board.activities.WallpaperBoardActivity.java

private void resetNavigationView(int orientation) {
    int index = mNavigationView.getMenu().size() - 1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            mNavigationView.getMenu().getItem(index).setVisible(true);
            mNavigationView.getMenu().getItem(index).setEnabled(false);
            return;
        }// w ww.j  a va  2 s .c o m
    }
    mNavigationView.getMenu().getItem(index).setVisible(false);
}

From source file:com.example.SimpleTestClient.Activities.TestMainActivity.java

private ShowMode getShowMode() {
    if (this.getResources().getBoolean(R.bool.has_two_panes) == true) {
        return ShowMode.Landscape;
    }/*from  w w  w .  j av  a2 s.co  m*/
    if (this.getResources().getBoolean(R.bool.has_two_panes) == false) {
        return ShowMode.Portrait;
    }

    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (findViewById(R.id.activity_test_main_drawer_layout) != null) {
            return ShowMode.Landscape_mini;
        } else {
            return ShowMode.Landscape;
        }
    }
    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        return ShowMode.Portrait;
    }
    return ShowMode.Landscape;
}

From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_columns:
        if (getResources() != null) {
            Configuration config = getResources().getConfiguration();
            if (config != null) {
                switch (config.orientation) {
                case android.content.res.Configuration.ORIENTATION_LANDSCAPE:
                    mPrefUtilities.setMultipleColumnsLandscape(!mPrefUtilities.useMultipleColumnsLandscape());
                    break;
                case android.content.res.Configuration.ORIENTATION_PORTRAIT:
                    mPrefUtilities.setMultipleColumnsPortrait(!mPrefUtilities.useMultipleColumnsPortrait());
                    break;
                }/*from  w w  w.  ja  va 2s  .c  o  m*/
            }
        }

        updateMenu();
        break;
    case android.R.id.home:
        goBackPageOverview();
        break;
    }
    return super.onOptionsItemSelected(item);
}