Example usage for android.content.res Configuration ORIENTATION_LANDSCAPE

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

Introduction

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

Prototype

int ORIENTATION_LANDSCAPE

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

Click Source Link

Document

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

Usage

From source file:de.tobiasbielefeld.solitaire.ui.GameManager.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game_manager);

    mAdView = (AdView) findViewById(R.id.adView2);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);//from w w  w  .jav  a2s.  c  om

    // load stuff
    layoutGame = (RelativeLayout) findViewById(R.id.mainRelativeLayoutGame);
    mainTextViewTime = (TextView) findViewById(R.id.mainTextViewTime);
    mainTextViewScore = (TextView) findViewById(R.id.mainTextViewScore);
    mainTextViewRedeals = (TextView) findViewById(R.id.textViewRedeals);
    buttonAutoComplete = (Button) findViewById(R.id.buttonMainAutoComplete);

    //initialize my static helper stuff
    final GameManager gm = this;
    recordList = new RecordList(gm);
    movingCards = new MovingCards();
    hint = new Hint();
    scores = new Scores(gm);
    gameLogic = new GameLogic(gm);
    animate = new Animate(gm);
    autoComplete = new AutoComplete(gm);
    timer = new Timer(gm);
    currentGame = lg.loadClass(this, getIntent().getIntExtra("game", 1));
    savedGameData = getSharedPreferences(lg.getSharedPrefName(), MODE_PRIVATE);

    if (savedSharedData == null) {
        savedSharedData = PreferenceManager.getDefaultSharedPreferences(this);
    }

    updateIcons();

    //initialize cards and stacks
    for (int i = 0; i < stacks.length; i++) {
        stacks[i] = new Stack(i);
        stacks[i].view = new ImageView(this);
        stacks[i].view.setBackgroundResource(R.drawable.background_stack);
        layoutGame.addView(stacks[i].view);
    }

    for (int i = 0; i < cards.length; i++) {
        cards[i] = new Card(i);
        cards[i].view = new ImageView(this);
        cards[i].view.setId(i);
        cards[i].view.setOnTouchListener(this);
        layoutGame.addView(cards[i].view);
    }

    currentGame.addOnTouchListener(this);

    scores.output();
    loadCounter++;
    //post, because i need the dimensions of layoutGame to set the cards and stacks
    layoutGame.post(new Runnable() { //post a runnable to set the dimensions of cards and stacks when the layout has loaded
        @Override
        public void run() {
            boolean isLandscape = getResources()
                    .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

            currentGame.setStacks(layoutGame, isLandscape);

            //if left handed mode is true, mirror all stacks
            if (getSharedBoolean(getString(R.string.pref_key_left_handed_mode), false)) {
                for (Stack stack : stacks)
                    stack.view.setX(layoutGame.getWidth() - stack.view.getX() - Card.width);

                if (currentGame.hasArrow()) {
                    for (Stack stack : stacks) {
                        if (stack.hasArrow() > 0) {
                            if (stack.hasArrow() == 1) {
                                stack.view.setBackgroundResource(R.drawable.arrow_right);
                            } else {
                                stack.view.setBackgroundResource(R.drawable.arrow_left);
                            }
                        }
                    }
                }
            }

            //calculate the spacing for cards on a stack
            Stack.defaultSpacing = Card.width / 2;

            //setup how the cards on the stacks will be stacked (offset to the previous card)
            //there are 4 possible directions. By default, the tableau stacks are stacked down
            //all other stacks don't have a visible offset
            //use setDirections() in a game to change that
            if (currentGame.directions == null) {
                for (int i = 0; i <= currentGame.getLastTableauID(); i++) {
                    stacks[i].setSpacingDirection(1);
                }
            } else {
                for (int i = 0; i < currentGame.directions.length; i++) {
                    stacks[i].setSpacingDirection(currentGame.directions[i]);
                }
            }
            //if there are direction borders set (when cards should'nt overlap another stack)  use it.
            //else set the layout height/widht as maximum
            if (currentGame.directionBorders != null) {
                for (int i = 0; i < currentGame.directionBorders.length; i++) {
                    if (currentGame.directionBorders[i] != -1) //-1 means no border
                        stacks[i].setSpacingMax(currentGame.directionBorders[i]);
                    else
                        stacks[i].setSpacingMax(layoutGame);
                }
            } else {
                for (Stack stack : stacks) {
                    stack.setSpacingMax(layoutGame);
                }
            }

            //load the game
            loadCounter--;
            if (loadCounter < 1) {
                scores.load();
                LoadGameHandler loadGameHandler = new LoadGameHandler(gm);
                loadGameHandler.sendEmptyMessageDelayed(0, 200);
            }
        }
    });

}

From source file:com.bydavy.card.receipts.activities.ReceiptListActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_receipt_list);
    mLoadingView = findViewById(R.id.loading_container);
    mContentView = findViewById(R.id.content_container);
    setupActionBar();//from ww w  . j  a  va 2 s.co  m

    final View detailFrame = findViewById(FRAGMENT_PAGER_FRAGMENT_ID);
    mDualPane = (detailFrame != null) && (detailFrame.getVisibility() == View.VISIBLE);

    if (savedInstanceState != null) {
        mReceiptListFragment = (ReceiptListFragment) getSupportFragmentManager()
                .findFragmentById(FRAGMENT_RECEIPT_LIST_ID);
        if (mDualPane) {
            mPagerFragment = (ReceiptPagerFragment) getSupportFragmentManager()
                    .findFragmentById(FRAGMENT_PAGER_FRAGMENT_ID);
        }

        final int navListIndex = savedInstanceState.getInt(SAVED_STATE_NAVIGATION_LIST_INDEX);
        // We are going to recreate fragments accordingly to navListIndex
        // saved (Easier to handle that reusing)
        getSupportActionBar().setSelectedNavigationItem(navListIndex);

        if ((getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)
                && AndroidUtils.isScreenSizeBiggerOrEqual(getResources(),
                        Configuration.SCREENLAYOUT_SIZE_LARGE)) {
            final int index = savedInstanceState.getInt(SAVED_STATE_LIST_INDEX);

            // In this case we need open the receipt pager
            startActivityReceiptPager(index, mReceiptListFragment.getCursorSelection(),
                    mReceiptListFragment.getCursorSelectionArgs(), mReceiptListFragment.getCursorSortOrder());
        }
    }

    // sampleData();
}

From source file:com.jpventura.popularmovies.app.OverviewActivity.java

private boolean isOrientationLandscape() {
    return Configuration.ORIENTATION_LANDSCAPE == getResources().getConfiguration().orientation;
}

From source file:com.klinker.android.twitter.ui.profile_viewer.ProfilePager.java

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

    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);

    mCache = App.getInstance(this).getBitmapCache();
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    settings = AppSettings.getInstance(this);

    try {/*from   ww w .  ja va2s  .c om*/
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    if (getIntent().getBooleanExtra("from_widget", false)
            || ((settings.advanceWindowed && !getIntent().getBooleanExtra("long_click", false))
                    || !settings.advanceWindowed && getIntent().getBooleanExtra("long_click", false))) {
        setUpWindow();
    }

    setUpTheme();

    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    getFromIntent();

    setContentView(R.layout.tweet_pager);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter(getFragmentManager(), context, name, screenName,
            proPic, tweetId, isRetweet, isMyProfile);
    pager.setAdapter(mPagerAdapter);
    pager.setOffscreenPageLimit(3);

    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);

        if (!settings.showTitleStrip) {
            strip.setVisibility(View.GONE);
        }
    }

    Utils.setActionBar(context, !settings.advanceWindowed);

    // set it to the profile
    pager.setCurrentItem(1);
}

From source file:dev.ronlemire.samplestemplate.MainActivity.java

public void StartSampleFragment() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {
        Fragment sampleFragment = (Fragment) fm.findFragmentById(R.id.detail_replacer);
        sampleFragment = SampleFragment.newInstance("Sample");

        FragmentTransaction transaction = fm.beginTransaction().replace(R.id.detail_replacer, sampleFragment);
        transaction.addToBackStack(null);
        transaction.commit();//  w w  w .  j a  v  a2 s .c  o  m
    } else {
        SampleFragment sampleFragment = SampleFragment.newInstance("Sample");
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction()
                .replace(MainActivity.sampleListView.getId(), sampleFragment);
        transaction.addToBackStack(null);
        transaction.commit();
    }
}

From source file:dev.ronlemire.samplestemplate.MainActivity.java

 public void StartSampleFragment() {
   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {//from  ww w . j  a v  a 2s  . c  om
      Fragment sampleFragment = (Fragment) fm
            .findFragmentById(R.id.detail_replacer);
      sampleFragment = SampleFragment.newInstance("Sample");

      FragmentTransaction transaction = fm.beginTransaction()
         .replace(R.id.detail_replacer, sampleFragment);
      transaction.addToBackStack(null);
      transaction.commit();
   } else {
      SampleFragment sampleFragment = SampleFragment
            .newInstance("Sample");
      FragmentTransaction transaction = getSupportFragmentManager()
         .beginTransaction()
         .replace(MainActivity.sampleListView.getId(), sampleFragment);
      transaction.addToBackStack(null);
      transaction.commit();
   }
}

From source file:com.example.ok.kom_argeopouchobj.camera.CameraSourcePreview.java

private boolean isPortraitMode() {
    int orientation = mContext.getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        return false;
    }/*from w ww  .  j  ava  2 s. co  m*/
    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        return true;
    }

    Log.d(TAG, "isPortraitMode returning false by default");
    return false;
}

From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // Getting the width on orientation changed
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from   ww w  .  j  av  a 2  s  .  com
    int width = size.x;

    /**
     * Getting the orientation of the device. Set margin for pages as a
     * negative number, so a part of next and previous pages will be showed
     */
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        pager.setPageMargin(-width / 2);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        pager.setPageMargin(-width / 3);
    }
    pager.refreshDrawableState();
}

From source file:com.rubengees.introduction.IntroductionFragment.java

private int getLineCountForTitle() {
    return getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
            ? 2
            : 3;
}

From source file:com.owncloud.android.ui.activity.FirstRunActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setSlideshowSize(true);// w w  w  .  j  a v  a  2 s.c o m
    } else {
        setSlideshowSize(false);
    }
}