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:br.org.funcate.dynamicforms.FormActivity.java

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // make sure the orientation can't be changed once this activity started
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {//from   w  w  w .j  av  a  2s .c o m
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        sectionName = extras.getString(LibraryConstants.PREFS_KEY_FORM_NAME);
        sectionObjectString = extras.getString(LibraryConstants.PREFS_KEY_FORM_JSON);
        latitude = extras.getDouble(LibraryConstants.LATITUDE);
        longitude = extras.getDouble(LibraryConstants.LONGITUDE);
        elevation = extras.getDouble(LibraryConstants.ELEVATION);
        noteId = extras.getLong(LibraryConstants.SELECTED_POINT_ID);
    }

    try {
        if (sectionObjectString == null) {
            sectionObject = TagsManager.getInstance(this).getSectionByName(sectionName);
            // copy the section object, which will be kept around along the activity
            sectionObjectString = sectionObject.toString();
        }

        sectionObject = new JSONObject(sectionObjectString);
        formNames4Section = TagsManager.getFormNames4Section(sectionObject);
    } catch (Exception e) {
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
    }
    setContentView(R.layout.form);

}

From source file:com.dm.material.dashboard.candybar.fragments.AboutFragment.java

private void resetRecyclerViewPadding(int orientation) {
    if (mRecyclerView == null)
        return;// w  w  w .  java2  s. co  m

    int padding = 0;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        padding = getActivity().getResources().getDimensionPixelSize(R.dimen.content_padding);
    }

    mRecyclerView.setPadding(padding, padding, 0, 0);
}

From source file:com.manning.androidhacks.hack014.MainActivity.java

private void setVideoViewPosition() {
    switch (getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE: {
        mPortraitContent.setVisibility(View.GONE);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);

        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        mVideoView.setLayoutParams(params);
        break;//ww  w .java  2 s .co m
    }

    case Configuration.ORIENTATION_SQUARE:
    case Configuration.ORIENTATION_UNDEFINED:
    case Configuration.ORIENTATION_PORTRAIT:
    default: {

        mPortraitContent.setVisibility(View.VISIBLE);

        int[] locationArray = new int[2];
        mPortraitPosition.getLocationOnScreen(locationArray);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mPortraitPosition.getWidth(),
                mPortraitPosition.getHeight());

        params.leftMargin = locationArray[0];
        params.topMargin = locationArray[1];

        mVideoView.setLayoutParams(params);

        break;
    }
    }
}

From source file:com.example.propertylist.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_project_sales_list);

    ImageView mImageView = new ImageView(this);

    DisplayMetrics metrics;// w w  w.j a v a  2s.c  om
    int mScreenWidth;
    int mScreenHeight;

    api_key = getResources().getString(R.string.key);

    metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mScreenWidth = metrics.widthPixels;
    mScreenHeight = metrics.heightPixels;

    if (mScreenWidth >= minScreenwidth) {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (mScreenWidth >= minLandScreenwidth) {
                largeScreen = true;

            }
        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            if (mScreenHeight > minLandScreenwidth) {
                largeScreen = true;
            }
        }
    } else {
        largeScreen = false;
    }

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(getResources(), R.id.daft_logo_image, options);

    mImageView.setImageBitmap( // ensure image size is 100 x 100.
            decodeSampledBitmapFromResource(getResources(), R.id.daft_logo_image, 100, 100));

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            hideProgressDialog();
            startListActivity();
        }
    };
}

From source file:com.finchuk.clock2.timers.ui.TimersFragment.java

@Nullable
@Override//from w  w  w  .j a  va  2 s  .  c  o m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    final Resources r = getResources();
    if (getOrientation(r) == Configuration.ORIENTATION_LANDSCAPE) {
        RecyclerView list = findById(view, R.id.list);
        int cardViewMargin = r.getDimensionPixelSize(R.dimen.cardview_margin);
        list.setPaddingRelative(cardViewMargin/*start*/, cardViewMargin/*top*/, 0, list.getPaddingBottom());
    }
    return view;
}

From source file:com.swisscom.safeconnect.activity.TutorialActivity.java

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

    final boolean invokedFromMenu = getIntent().getBooleanExtra(KEY_INVOKED_FROM_MENU, false);
    if (!invokedFromMenu && !Config.getInstance().isShowTutorial()) {
        proceed();// w ww .j  a  va 2s  . c  o m
        return;
    }

    landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    setContentView(R.layout.tutorial);

    textureScrollView = (HorizontalScrollView) findViewById(R.id.textureScrollView);
    secondPlanScrollView = (HorizontalScrollView) findViewById(R.id.secondPlanScrollView);
    firstPlanScrollView = (HorizontalScrollView) findViewById(R.id.firstPlanScrollView);

    textureImageView = (ImageView) findViewById(R.id.textureImageView);
    secondPlanImages = (LinearLayout) findViewById(R.id.imgs_second_plan);
    firstPlanImages = (FrameLayout) findViewById(R.id.imgs_first_plan);

    imgSet = (HideShowImgSet) findViewById(R.id.img_set);

    visitor1 = (ImageView) findViewById(R.id.visitor1);
    visitor2 = (ImageView) findViewById(R.id.visitor2);
    messages = (ImageView) findViewById(R.id.msgs);
    victim = (ImageView) findViewById(R.id.victim);
    logo = (ImageView) findViewById(R.id.img_logo);

    viewPager = (ViewPager) findViewById(R.id.viewPager);
    paginator = (ViewGroup) findViewById(R.id.paginator);

    butSkip = (Button) findViewById(R.id.but_tutorial);

    butSkip.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // start the main activity if not invoked from menu
            if (!invokedFromMenu) {
                Config.getInstance().setShowTutorial(false);
                proceed();
            } else {
                finish();
            }
        }
    });

    setUpPaginator();

    int width = getResources().getDisplayMetrics().widthPixels;
    int height = getResources().getDisplayMetrics().heightPixels;

    Size size = setUpTextureImageView(width, height);
    setUpSecondPlanScrollView(width);
    setUpFirstPlanScrollView(width, height);
    setUpViewPagers(size, width);
    setUpContent(width);
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.CustomAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Log.d(LOG_TAG, "onCreateViewHolder: ");
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_movie, parent, false);
    ImageView posterImageView = (ImageView) view.findViewById(R.id.poster);
    boolean isTablet = Utility.isTabletPreference(mContext);
    if (mMinWidth == 0) {
        if (isTablet && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
            mMinHeight = mRecyclerView.getHeight();
            mMinWidth = (int) (((double) mMinHeight / 278) * 185);
        } else {//from ww  w .  j av a 2 s. co  m
            mMinWidth = mRecyclerView.getWidth()
                    / (mOrientation == Configuration.ORIENTATION_LANDSCAPE || isTablet ? 3 : 2);
            mMinHeight = (int) (((double) mMinWidth / 185) * 278);
        }
    }
    posterImageView.setMinimumWidth(mMinWidth);
    posterImageView.setMinimumHeight(mMinHeight);
    return new ViewHolder(view);
}

From source file:com.brayanarias.alarmproject.fragment.AlarmListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View layout = inflater.inflate(R.layout.fragment_alarm_list, container, false);
    RecyclerView recyclerView = (RecyclerView) layout.findViewById(R.id.alarmList);
    AlarmListAdapter alarmListAdapter = new AlarmListAdapter(getData(), (MainActivity) getActivity());
    recyclerView.setAdapter(alarmListAdapter);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    linearLayoutManager.scrollToPosition(0);
    recyclerView.setLayoutManager(linearLayoutManager);
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        GridLayoutManager gridLayoutManager;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            gridLayoutManager = new GridLayoutManager(getActivity().getBaseContext(), 3);
            recyclerView.setLayoutManager(gridLayoutManager);
        } else {/*from   w  ww .jav a2  s .c  om*/
            gridLayoutManager = new GridLayoutManager(getActivity().getBaseContext(), 2);
            recyclerView.setLayoutManager(gridLayoutManager);
        }
        recyclerView.setLayoutManager(gridLayoutManager);
    }
    FloatingActionButton fab = (FloatingActionButton) layout.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    return layout;
}

From source file:com.android.contacts.list.ContactsUnavailableFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.contacts_unavailable_fragment, null);

    mImageView = (ImageView) mView.findViewById(R.id.empty_image);

    mMessageView = (TextView) mView.findViewById(R.id.message);
    mAddAccountButton = (Button) mView.findViewById(R.id.add_account_button);
    mAddAccountButton.setOnClickListener(this);
    mAddAccountButton.getBackground().setColorFilter(
            ContextCompat.getColor(getContext(), R.color.primary_color), PorterDuff.Mode.SRC_ATOP);
    mImportContactsButton = (Button) mView.findViewById(R.id.import_contacts_button);
    mImportContactsButton.setOnClickListener(this);
    mImportContactsButton.getBackground().setColorFilter(
            ContextCompat.getColor(getContext(), R.color.primary_color), PorterDuff.Mode.SRC_ATOP);
    mProgress = (ProgressBar) mView.findViewById(R.id.progress);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mButtonsContainer = mView.findViewById(R.id.buttons_container);
    }//ww  w .  j  a v a  2 s.  c o m

    if (mProviderStatus != null) {
        updateStatus(mProviderStatus);
    }

    return mView;
}

From source file:com.grarak.kerneladiutor.fragments.tools.BackupFragment.java

@Override
public int getSpanCount() {
    int span = Utils.isTablet(getActivity())
            ? Utils.getOrientation(getActivity()) == Configuration.ORIENTATION_LANDSCAPE ? 4 : 3
            : Utils.getOrientation(getActivity()) == Configuration.ORIENTATION_LANDSCAPE ? 3 : 2;
    if (itemsSize() != 0 && span > itemsSize()) {
        span = itemsSize();//from w ww . j a  v a2s  .c  o m
    }
    return span;
}