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.gelakinetic.mtgfam.fragments.LifeCounterFragment.java

/**
 * Get UI element references, set onClickListeners for the toolbar, clear the measurement data and attach a
 * ViewTreeObserver to measure the UI when it is drawn. Get the life/poison mode from the savedInstanceState if the
 * fragment is persisting. Save the current brightness. Players are not added here.
 *
 * @param inflater           The LayoutInflater object that can be used to inflate any views in the fragment,
 * @param container          If non-null, this is the parent view that the fragment's UI should be attached to. The
 *                           fragment should not add the view itself, but this can be used to generate the
 *                           LayoutParams of the view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous saved state as given
 *                           here.//  ww w  .  j av  a2  s  .c  o m
 * @return The inflated view
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mListSizeWidth = -1;
    mListSizeHeight = -1;

    View myFragmentView = inflater.inflate(R.layout.life_counter_frag, container, false);
    assert myFragmentView != null;
    mGridLayout = myFragmentView.findViewById(R.id.playerList);

    mDisplayMode = Integer.parseInt(PreferenceAdapter.getDisplayMode(getContext()));

    mCommanderPlayerView = myFragmentView.findViewById(R.id.commander_player);

    if (null != myFragmentView.findViewById(R.id.playerScrollView_horz)) {
        mScrollView = myFragmentView.findViewById(R.id.playerScrollView_horz);
    } else {
        mScrollView = myFragmentView.findViewById(R.id.playerScrollView_vert);
    }
    ViewTreeObserver viewTreeObserver = mScrollView.getViewTreeObserver();
    assert viewTreeObserver != null;
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            if (isVisible()) {
                boolean changed = false;
                if (mListSizeHeight < mScrollView.getHeight()) {
                    mListSizeHeight = mScrollView.getHeight();
                    changed = true;
                }
                if (mListSizeWidth < mScrollView.getWidth()) {
                    mListSizeWidth = mScrollView.getWidth();
                    changed = true;
                }
                if (changed) {
                    if (getActivity().getResources()
                            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                        if (mDisplayMode == DISPLAY_COMMANDER) {
                            /* Conveniently takes care of re-adding the sized views in the right number of rows */
                            changeDisplayMode(false);
                        }
                    }
                    for (LcPlayer player : mPlayers) {
                        player.setSize(mListSizeWidth, mListSizeHeight, mDisplayMode,
                                getActivity().getResources()
                                        .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
                    }
                }
            }
        }
    });

    mPoisonButton = myFragmentView.findViewById(R.id.poison_button);
    mPoisonButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            setStatDisplaying(STAT_POISON);
        }
    });

    mLifeButton = myFragmentView.findViewById(R.id.life_button);
    mLifeButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            setStatDisplaying(STAT_LIFE);
        }
    });

    mCommanderButton = myFragmentView.findViewById(R.id.commander_button);
    mCommanderButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            setStatDisplaying(STAT_COMMANDER);
        }
    });

    myFragmentView.findViewById(R.id.reset_button).setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            showDialog(LifeCounterDialogFragment.DIALOG_RESET_CONFIRM);
        }
    });

    if (savedInstanceState != null) {
        mStatDisplaying = savedInstanceState.getInt(DISPLAY_MODE, STAT_LIFE);
    }

    return myFragmentView;
}

From source file:aws.apps.underthehood.Main.java

private void mLockScreenRotation() {
    // Stop the screen orientation changing during an event
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;//from w  w  w .  j  ava 2 s.c  om
    case Configuration.ORIENTATION_LANDSCAPE:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    }
}

From source file:com.android.gallery3d.app.AbstractGalleryActivity.java

private void toggleStatusBarByOrientation() {
    if (mDisableToggleStatusBar)
        return;// ww  w .ja  v  a  2  s  . c  o m

    Window win = getWindow();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}

From source file:org.solovyev.android.calculator.App.java

@SuppressWarnings("deprecation")
public static int getScreenOrientation(@Nonnull Activity activity) {
    final android.view.Display display = activity.getWindowManager().getDefaultDisplay();
    if (display.getWidth() <= display.getHeight()) {
        return Configuration.ORIENTATION_PORTRAIT;
    } else {//from   w w w  . j a  v a  2s .  co m
        return Configuration.ORIENTATION_LANDSCAPE;
    }
}

From source file:org.mariotaku.twidere.activity.support.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  w  ww  . j  av  a2 s.  co m*/
        fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    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.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Get orientation of device//from  ww  w. j  a v a2  s.com
 */
public int getOrientation() {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);

    if (metrics.widthPixels < metrics.heightPixels) {
        return Configuration.ORIENTATION_PORTRAIT;
    } else {
        return Configuration.ORIENTATION_LANDSCAPE;
    }
}

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

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

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

    /* debug GA */
    tracker.setDebug(false);/*from w w w  . j a  va 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:org.apps8os.motivator.ui.MoodHistoryActivity.java

/**
 * Loading the action bar menu/*from w w w . jav  a 2s . c o m*/
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.mood_history, menu);
    mMenu = menu;
    MenuItem selectAttribute = mMenu.findItem(R.id.mood_history_select_attribute);
    if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        selectAttribute.setVisible(false);
    } else {
        selectAttribute.setVisible(true);
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.bellman.bible.service.common.CommonUtils.java

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

From source file:com.mooshim.mooshimeter.main.DeviceActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (Configuration.ORIENTATION_PORTRAIT == this.getResources().getConfiguration().orientation) {
        // If we're in Portrait, continue as normal
        // If we're in landscape, handleOrientation will have started the trend activity
        Intent intent = getIntent();//from w w  w  . ja  va 2 s . c  om
        mMeter = ScanActivity.getDeviceWithAddress(intent.getStringExtra("addr"));
        onMeterInitialized();
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}