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.landenlabs.all_devtool.ScreenFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Ui.viewById(m_layout, R.id.touch_pos).setVisibility(View.INVISIBLE);
        Ui.viewById(m_layout, R.id.grid_size).setVisibility(View.INVISIBLE);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        Ui.viewById(m_layout, R.id.touch_pos).setVisibility(View.VISIBLE);
        Ui.viewById(m_layout, R.id.grid_size).setVisibility(View.VISIBLE);
    }/*  www. j  a v a 2s  .co  m*/
    updateView();
}

From source file:com.ameerhamza6733.xmlpullparser.RecyclerViewFragment.java

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

    Log.e(TAG, "onCreateView");

    this.view = rootView;
    // BEGIN_INCLUDE(initializeRecyclerView)
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.myRecylerView);
    progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);

    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    // mRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).color(Color.RED).sizeResId(R.dimen.divider).marginResId(R.dimen.leftmargin, R.dimen.rightmargin).build());

    mLayoutManager = new LinearLayoutManager(getActivity());
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        Log.e(TAG, "getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT");
        mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
    } else {/*  www  .java  2s. co  m*/
        Log.e(TAG, "getResources().getConfiguration().orientation == Configuration.Land");
        mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;
    }

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        //            mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState
        //                  .getSerializable(KEY_LAYOUT_MANAGER);
        Log.e(TAG, "savedInstanceState ! =null");
        progressBar.setVisibility(View.VISIBLE);

        mAdapter = new CustomAdapter(mDataset);
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.notifyDataSetChanged();

    } else {

        if (mDataset.isEmpty()) {
            Log.e(TAG, "mdata.isRaplty");
            progressBar.setVisibility(View.VISIBLE);
            initDataset();
        }
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    return rootView;
}

From source file:com.woxthebox.draglistview.KanbanBoardView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getResources();
    boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortrait) {
        mColumnWidth = (int) (res.getDisplayMetrics().widthPixels);
    } else {//  w ww .  j  av a  2  s .  c  om
        mColumnWidth = (int) (res.getDisplayMetrics().density * 320);
    }

    mGestureDetector = new GestureDetector(getContext(), new GestureListener());
    mColumnGestureListener = new ColumnGestureListener();
    mColumnGestureDetector = new GestureDetector(getContext(), mColumnGestureListener);
    mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f));
    mAutoScroller = new AutoScroller(getContext(), this);
    mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN
            : AutoScroller.AutoScrollMode.POSITION);
    mDragItem = new DragItem(getContext());

    mRootLayout = new FrameLayout(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    mColumnLayout = new LinearLayout(getContext());
    mColumnLayout.setOrientation(LinearLayout.HORIZONTAL);
    mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mColumnLayout.setMotionEventSplittingEnabled(false);

    mRootLayout.addView(mColumnLayout);
    mRootLayout.addView(mDragItem.getDragItemView());
    addView(mRootLayout);
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getResources();
    boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortrait) {
        mColumnWidth = (int) (res.getDisplayMetrics().widthPixels * 0.87);
    } else {//w  ww.  java  2 s . c o m
        mColumnWidth = (int) (res.getDisplayMetrics().density * 320);
    }

    mGestureDetector = new GestureDetector(getContext(), new GestureListener());
    mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f));
    mAutoScroller = new AutoScroller(getContext(), this);
    mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN
            : AutoScroller.AutoScrollMode.POSITION);
    mDragItem = new DragItem(getContext());

    mRootLayout = new FrameLayout(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    mColumnLayout = new LinearLayout(getContext());
    mColumnLayout.setOrientation(LinearLayout.HORIZONTAL);
    mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mColumnLayout.setMotionEventSplittingEnabled(false);

    mRootLayout.addView(mColumnLayout);
    mRootLayout.addView(mDragItem.getDragItemView());
    addView(mRootLayout);
}

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

private void toggleTitle(@Nonnull Activity activity, @Nonnull ActionBar actionBar, boolean showTitle) {
    if (activity instanceof CalculatorActivity) {
        if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
            actionBar.setDisplayShowTitleEnabled(true);
        } else {//from   ww w  .j  a v a 2s  .co  m
            actionBar.setDisplayShowTitleEnabled(false);
        }
    } else {
        actionBar.setDisplayShowTitleEnabled(showTitle);
    }
}

From source file:org.saydroid.tether.usb.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        String message = "Now Screen Changes to Portrait";
        Log.d(TAG, message);//from   w ww.ja  va2  s .c o  m
        // Sending message
        Message msg = new Message();
        msg.obj = message;
        //((Engine)Engine.getInstance()).displayMessageHandler.sendMessage(msg);
    }
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        String message = "Now Screen Changes to Landscape";
        Log.d(TAG, message);
        // Sending message
        Message msg = new Message();
        msg.obj = message;
        //((Engine)Engine.getInstance()).displayMessageHandler.sendMessage(msg);
    }
    super.onConfigurationChanged(newConfig);
}

From source file:net.niyonkuru.koodroid.MainActivity.java

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

    mHandler = new Handler();

    Settings settings = App.getSettings();

    int selectedPage = settings.page();
    String subscriber = settings.preferredSubscriber();
    String email = settings.email();

    loadPages(selectedPage, subscriber, email);

    mAdapter = new SimpleCursorAdapter(this, R.layout.spinner_item, null,
            new String[] { Subscribers.SUBSCRIBER_ID }, new int[] { android.R.id.text1 }, 0);
    mAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

    getSupportLoaderManager().initLoader(0, null, this);

    View detailsFrame = findViewById(R.id.details);
    mDualPaneMode = detailsFrame != null;

    Configuration configuration = getResources().getConfiguration();
    mPortraitMode = configuration.orientation == Configuration.ORIENTATION_PORTRAIT;

    if (savedInstanceState != null && savedInstanceState.getBoolean("details_mode")) {
        showDetails(savedInstanceState.getInt("what"), subscriber);
    }//www  .ja v a 2 s.  co  m
}

From source file:tech.salroid.filmy.fragment.WatchList.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_watch_movies, container, false);
    ButterKnife.bind(this, view);

    /*GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
    my_saved_movies_recycler.setLayoutManager(gridLayoutManager);*/

    boolean tabletSize = getResources().getBoolean(R.bool.isTablet);

    if (tabletSize) {

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        } else {//from  w  w  w  .j  a va2s . c  om
            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        }

    } else {

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        } else {
            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        }

    }

    mainActivityAdapter = new SavedMoviesAdapter(getActivity(), null);
    my_saved_movies_recycler.setAdapter(mainActivityAdapter);
    mainActivityAdapter.setClickListener(this);
    mainActivityAdapter.setLongClickListener(this);

    return view;
}

From source file:com.synox.android.ui.fragment.ExtendedListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateView");
    setRetainInstance(true);//from w w  w. j a v a2s  .co m

    mAppPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());

    View v = inflater.inflate(R.layout.list_fragment, container, false);
    mCurrentListView = (CustomRecyclerView) (v.findViewById(R.id.list_root));

    layout = mAppPreferences.getInt("viewLayout", R.layout.list_item);
    switch (layout) {
    case R.layout.list_item:
        mLayoutManager = new CustomLinearLayoutManager(getActivity(), CustomLinearLayoutManager.VERTICAL,
                false);
        break;
    case R.layout.grid_item:
        if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            mLayoutManager = new GridLayoutManager(getActivity(), NUMBER_OF_GRID_COLUMNS,
                    GridLayoutManager.VERTICAL, false);
        } else {
            mLayoutManager = new GridLayoutManager(getActivity(), NUMBER_OF_GRID_COLUMNS_LANDSCAPE,
                    GridLayoutManager.VERTICAL, false);
        }
        break;
    }

    // Fix for the bug when updating applications
    if (mLayoutManager == null) {
        if (mAppPreferences != null) {
            mAppPreferences.edit().clear().commit();
        }
        mLayoutManager = new CustomLinearLayoutManager(getActivity(), CustomLinearLayoutManager.VERTICAL,
                false);
    }

    mCurrentListView.setLayoutManager(mLayoutManager);

    // Floating action button
    fabMenu = (FloatingActionMenu) v.findViewById(R.id.fab_menu);
    newFileFab = (FloatingActionButton) v.findViewById(R.id.fab);
    newFolderFab = (FloatingActionButton) v.findViewById(R.id.fab2);

    mEmptyListMessage = (TextView) v.findViewById(R.id.empty_view);
    mCurrentListView.setEmptyView(mEmptyListMessage);
    mCurrentListView.setItemAnimator(new DefaultItemAnimator());
    mCurrentListView.setHasFixedSize(true);

    RecyclerView.ItemAnimator animator = mCurrentListView.getItemAnimator();

    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }

    mCurrentListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);

            if (Math.abs(dy) > 6 && fabMenu != null) {
                if (dy > 0) {
                    fabMenu.hideMenu(true);
                } else {
                    fabMenu.showMenu(true);
                }
            }
        }
    });

    // Swipe to refresh list
    mRefreshListLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_containing_list);
    onCreateSwipeToRefresh(mRefreshListLayout);

    return v;
}

From source file:tech.salroid.filmy.fragment.Favorite.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_fav_movies, container, false);
    ButterKnife.bind(this, view);

    /*GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
    my_saved_movies_recycler.setLayoutManager(gridLayoutManager);*/

    boolean tabletSize = getResources().getBoolean(R.bool.isTablet);

    if (tabletSize) {

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        } else {/*w  w w . j a  v a  2s .  c om*/
            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        }

    } else {

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        } else {
            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        }

    }

    mainActivityAdapter = new SavedMoviesAdapter(getActivity(), null);
    my_saved_movies_recycler.setAdapter(mainActivityAdapter);
    mainActivityAdapter.setClickListener(this);
    mainActivityAdapter.setLongClickListener(this);

    return view;
}