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.da_sense.moses.client.DetailActivity.java

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

    // check orientation and screen size
    // only for devices with API Level 11 or higher
    if (isAtLeastHoneycomb()
            && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
            && getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)) {
        Log.d("DetailActivity", "orientation = landscape");
        Log.d("DetailActivity", "layout at least size large");
        // If the screen is now in landscape mode, we can show the
        // dialog in-line with the list so we don't need this activity.
        finish();//from  ww  w .  j  a v  a2  s. c  o m
        return;
    }

    // get the Detail Fragment to check later if it is null or not
    DetailFragment details = null;

    Log.d("DetailActivity", "savedInstanceState == null || details == null");
    // during initial setup plug in the detail fragment
    details = new DetailFragment();
    details.setRetainInstance(true);
    details.setArguments(getIntent().getExtras());
    getSupportFragmentManager().beginTransaction().add(android.R.id.content, details).commit();

    // get ActionBar and set AppIcon to direct to the "home screen"
    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
}

From source file:com.waz.zclient.utils.ViewUtils.java

public static boolean isInLandscape(@NonNull Configuration configuration) {
    return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE;
}

From source file:com.near.chimerarevo.fragments.WebFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.webview_layout, container, false);

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;/*from ww  w.  j a v  a  2 s .  c o  m*/
    } else
        isLandscapeLarge = false;

    if (!isLandscapeLarge)
        v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0);

    mWebView = (WebView) v.findViewById(R.id.webview);
    mProgressContainer = v.findViewById(R.id.progressContainer);
    mWebContainer = v.findViewById(R.id.webViewContainer);

    return v;
}

From source file:com.tizianobasile.multipanerecipes.DescriptionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        finish();// ww  w .j a  v  a 2 s.c om
        return;
    } else
        setContentView(R.layout.activity_description);

    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        String recipe = extras.getString("recipe");
        DescriptionFragment descriptionFragment = (DescriptionFragment) getSupportFragmentManager()
                .findFragmentById(R.id.descriptionFragment);
        if (descriptionFragment != null && descriptionFragment.isInLayout()) {
            descriptionFragment.setDescriptionIntoFragment(recipe);
        }
    }
}

From source file:com.hustunique.jianguo.materialsearchview.SearchViewUtil.java

public static boolean isLandscapeMode(Context context) {
    return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}

From source file:com.luskprog.doubledpager.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // see the orientation of the screen
    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? true
            : false;/*  w ww. j a  v a2  s  . co m*/
    mPortraitPager = (ViewPager) findViewById(R.id.portraitPager);
    mLandscapePager = (ViewPager) findViewById(R.id.landscapePager);
    CustomAdapter adapter = new CustomAdapter(getSupportFragmentManager());
    // setup the right ViewPager based on the orientation and kill the
    // other.
    if (mIsLandscape) {
        mPortraitPager.setVisibility(View.GONE);
        mLandscapePager.setAdapter(adapter);
        mPortraitPager.setAdapter(null);
    } else {
        mLandscapePager.setVisibility(View.GONE);
        mPortraitPager.setAdapter(adapter);
        mLandscapePager.setAdapter(null);
    }
    // simulate the data
    for (int i = 0; i < 30; i++) {
        mBookPages.add("Book Page no." + i);
    }
}

From source file:com.simplaapliko.util.sample.MainFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.get_screen_orientation:

        switch (Screen.getOrientation(getActivity())) {
        case Configuration.ORIENTATION_PORTRAIT:
            mMessage.setText(R.string.portrait);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            mMessage.setText(R.string.landscape);
            break;
        case Configuration.ORIENTATION_SQUARE:
            mMessage.setText(R.string.square);
            break;
        }/*from   www .  j  av a2  s.co m*/

        break;
    }
}

From source file:com.shipdream.lib.android.mvc.samples.note.view.fragment.NoteTabletLandscape.java

@Override
public void onResume() {
    super.onResume();
    if (getCurrentOrientation() == Configuration.ORIENTATION_LANDSCAPE) {
        getToolBar().setTitle("My Notes - LargeView");
    }// w  ww .  j  a  v  a2  s.  c  o m
}

From source file:com.duinopeak.balanbot.ViewPagerAdapter.java

@Override
public float getPageWidth(int position) {
    if (context.getResources().getBoolean(R.bool.isTablet)
            && context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        return 0.5f; // On tablets in landscape mode two fragments are shown side by side
    else//from   w  w w. j av a  2 s  .c o m
        return 1.0f;
}

From source file:com.swisscom.safeconnect.fragment.LogoFragment.java

protected void adjustLogoOnKeyboardShow(final View v) {
    final int tablet = (getResources().getBoolean(R.bool.isTablet) ? 1 : 0);
    v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override/*from www  .j  a  va2  s  .c  om*/
        public void onGlobalLayout() {
            Rect r = new Rect();
            v.getWindowVisibleDisplayFrame(r);
            int heightDiff = v.getRootView().getHeight() - (r.bottom - r.top);
            // keyboard detection
            if (heightDiff > 100) {
                int orientation = getActivity().getResources().getConfiguration().orientation;
                // Remove logo tablet landscape and phone portrait
                if ((getActivity() != null && orientation == Configuration.ORIENTATION_LANDSCAPE)
                        || (tablet == 0 && orientation == Configuration.ORIENTATION_PORTRAIT)) {
                    if (imgLogo != null) {
                        imgLogo.setVisibility(View.GONE);
                    }
                }
            } else {
                if (imgLogo != null) {
                    imgLogo.setVisibility(View.VISIBLE);
                }
            }
        }
    });
}