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:org.iisgcp.waterwalk.fragment.FactFragment.java

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

    mImageId = getArguments().getInt(Constants.INTENT_IMAGE_ID);

    mFactText.setText(Html.fromHtml(getArguments().getString(Constants.INTENT_DESCRIPTION)));
    mFactText.setMovementMethod(LinkMovementMethod.getInstance());

    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;/*from   w  w  w  . j av a  2  s  . c om*/
    BitmapFactory.decodeResource(getResources(), mImageId, options);

    int maxWidth;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        maxWidth = getResources().getDisplayMetrics().widthPixels;
    } else {
        maxWidth = getResources().getDisplayMetrics().heightPixels;
    }

    final int targetWidth = maxWidth;
    double scale = (double) maxWidth / (double) options.outWidth;
    final int targetHeight = (int) (options.outHeight * scale);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        mImageView = new ImageView(getActivity());
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(targetWidth, targetHeight);
        mImageView.setLayoutParams(layoutParams);
        mLayout.addView(mImageView);
    }

    mImageView.setImageDrawable(null);
    mImageView.setBackgroundColor(getResources().getColor(R.color.gray));

    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = ((FactViewPagerFragment) getParentFragment()).getImageFetcher();
    mImageFetcher.setImageSize(targetWidth, targetHeight);
}

From source file:de.gebatzens.ggvertretungsplan.fragment.SubstFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    bundle = ((MainActivity) getActivity()).savedState;
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mGGFrag = new SubstAdapter(this, savedInstanceState, (MainActivity) getActivity());
    if (bundle != null) {
        mGGFrag.heute.spinnerPos = bundle.getInt("ggvp_frag_today_spinner");
        mGGFrag.morgen.spinnerPos = bundle.getInt("ggvp_frag_tomorrow_spinner");
    }//w  ww.jav a  2 s .com
    mViewPager.setAdapter(mGGFrag);
    mViewPager.setOffscreenPageLimit(3);
    if (bundle != null)
        mViewPager.setCurrentItem(bundle.getInt("ggvp_tab"));

    mToolbar = (Toolbar) ((MainActivity) this.getActivity()).mToolbar;
    ColorDrawable mToolbarColor = (ColorDrawable) mToolbar.getBackground();
    int mToolbarColorId = mToolbarColor.getColor();

    mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setBackgroundColor(mToolbarColorId);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mSlidingTabLayout.setPadding(toPixels(48), 0, toPixels(48), 0);
    } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        mSlidingTabLayout.setPadding(toPixels(8), 0, toPixels(8), 0);
    }
    mSlidingTabLayout.setViewPager(mViewPager);

    swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.refresh);
    // Setup refresh listener which triggers new data loading
    swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            GGApp.GG_APP.refreshAsync(new Runnable() {
                @Override
                public void run() {
                    swipeContainer.post(new Runnable() {
                        @Override
                        public void run() {
                            swipeContainer.setRefreshing(false);
                        }
                    });

                }
            }, true, GGApp.FragmentType.PLAN);
        }
    });
    // Configure the refreshing colors
    swipeContainer.setColorSchemeResources(R.color.custom_material_green, R.color.custom_material_red,
            R.color.custom_material_blue, R.color.custom_material_orange);

    FrameLayout contentFrame = (FrameLayout) getActivity().findViewById(R.id.content_fragment);
    contentFrame.setVisibility(View.VISIBLE);
    LinearLayout fragmentLayout = (LinearLayout) getActivity().findViewById(R.id.fragment_layout);
    Animation fadeIn = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.fade_in);
    fragmentLayout.startAnimation(fadeIn);

}

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

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

    View view = inflater.inflate(R.layout.fragment_saved_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  ww  .ja va  2 s  .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:pedroscott.com.popularmoviesapp.app.ui.home.HomeFragment.java

private void intViews() {
    layoutManager = new GridLayoutManager(getActivity(),
            getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
                    ? 2/*from www  .jav a2s  . c o  m*/
                    : 3);
    scrollListener = new EndlessRecyclerOnScrollListener(layoutManager) {
        @Override
        public void onLoadMore(int currentPage) {
            page = currentPage;
            if (finalPage >= currentPage) {
                loadMovies(selectSort);
            }

        }
    };
    rVHome.setHasFixedSize(true);
    rVHome.setLayoutManager(layoutManager);
    rVHome.setAdapter(adapter);
    if (!isFavoriteScream) {
        rVHome.addOnScrollListener(scrollListener);
    }
}

From source file:de.gebatzens.sia.fragment.SubstFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bundle = ((MainActivity) getActivity()).savedState;
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    substAdapter = new SubstAdapter(this, savedInstanceState, mViewPager);
    /*if(bundle != null) {
    for(int i = 0; i < substAdapter.fragments.size(); i++)
        substAdapter.fragments.get(i).spinnerPos = bundle.getInt("ggvp_frag_spinner_" + i);
    }*//* w w  w  .j av a 2 s  . c o m*/
    mViewPager.setAdapter(substAdapter);
    mViewPager.setOffscreenPageLimit(2);
    if (bundle != null)
        mViewPager.setCurrentItem(bundle.getInt("ggvp_tab"));

    mTabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
    mTabLayout.setupWithViewPager(mViewPager);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mTabLayout.setPadding(toPixels(48), 0, toPixels(48), 0);
        mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    }

    FrameLayout contentFrame = (FrameLayout) getActivity().findViewById(R.id.content_fragment);
    contentFrame.setVisibility(View.VISIBLE);

}

From source file:com.ruesga.rview.fragments.PageableFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mAdapter = new PageFragmentAdapter(getChildFragmentManager());
    mBinding.viewPager.setSwipeable(isSwipeable());
    mBinding.viewPager.setOffscreenPageLimit(getOffscreenPageLimit());
    mBinding.viewPager.setAdapter(mAdapter);
    boolean fixedMode = getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT
            || getPages().length <= 3;
    ((BaseActivity) getActivity()).configureTabs(mBinding.viewPager, fixedMode);
}

From source file:ubc.cs.cpsc210.sustainabilityapp.UBCSustainabilityAppActivity.java

/**
 * Determine tag for first tab to be displayed - restore from previous instance, if available.
 * //from w  w w.  j  av a 2s  .  c o  m
 * @param savedInstanceState  the saved instance state
 * @param res   the application's resources
 * @return  the tag of the tab to be displayed when activity is (re)created.
 */
private String findInitialTabTag(Bundle savedInstanceState, Resources res) {
    if (savedInstanceState != null) {
        if (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
            initialTabTag = savedInstanceState.getString("tab");
        else if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
                && !savedInstanceState.getString("tab").equals(MAP))
            initialTabTag = savedInstanceState.getString("tab");
        else
            // we are in landscape mode and saved tab tag is "map", so need to switch to another tab 
            // (let's arbitrarily choose POI).
            initialTabTag = "poi";
    } else
        initialTabTag = "poi";

    return initialTabTag;
}

From source file:com.dm.wallpaper.board.fragments.AboutFragment.java

private void resetRecyclerViewPadding(int orientation) {
    if (mRecyclerView == null)
        return;/*  w  w w .  j av a2s  .  com*/

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        boolean tabletMode = getActivity().getResources().getBoolean(R.bool.android_helpers_tablet_mode);
        if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) {
            navBar = WindowHelper.getNavigationBarHeight(getActivity());
        }

        navBar += WindowHelper.getStatusBarHeight(getContext());
    }

    navBar += ViewHelper.getToolbarHeight(getActivity());
    mRecyclerView.setPadding(padding, padding, 0, navBar);
}

From source file:com.cssweb.android.quote.KLine2Activity.java

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

    HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD");
    mHandlerThread.start();//  www . j  a  v  a 2  s.  c  om
    mHandler = new MessageHandler(mHandlerThread.getLooper());

    this.activityKind = Global.QUOTE_KLINE;

    Bundle bundle = getIntent().getExtras();
    this.exchange = bundle.getString("exchange");
    this.stockcode = bundle.getString("stockcode");
    this.stockname = bundle.getString("stockname");
    CssSystem.exchange = bundle.getString("exchange");
    CssSystem.stockcode = bundle.getString("stockcode");
    CssSystem.stockname = bundle.getString("stockname");

    cssStock = new CssStock();
    cssStock.setMarket(this.exchange);
    cssStock.setStkcode(this.stockcode);
    cssStock.setStkname(this.stockname);

    setContentView(R.layout.zr_klineview2);

    //      toolbarname = new String[]{ 
    //            Global.TOOLBAR_MENU, Global.TOOLBAR_ZHIBIAO, 
    //            Global.TOOLBAR_ZHOUQI, Global.TOOLBAR_F10, 
    //            Global.TOOLBAR_ZOOMOUT, Global.TOOLBAR_ZOOMIN };
    toolbarname = new String[] { Global.TOOLBAR_MENU, Global.TOOLBAR_FENSHI, Global.TOOLBAR_ZHOUQI,
            Global.TOOLBAR_ZHIBIAO, Global.TOOLBAR_F10, Global.TOOLBAR_REFRESH };

    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setToolbarByScreen(2);
    } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        setToolbarByScreen(1);
    }

    initTitle(R.drawable.njzq_title_left_back, 0, "K");

    setTitleText(stockname + " " + peroidN);

    initKlineView();

    getZhibiao();
    getZhouqi();
}

From source file:com.woodblockwithoutco.quickcontroldock.ui.factory.ServiceViewFactory.java

@SuppressWarnings("deprecation")
public View getServiceView() {

    boolean sameLayout = GeneralResolver.isSameLayoutForLandscape(mContext);
    int inflateId = 0;
    if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT || sameLayout) {
        inflateId = R.layout.panel_layout;
    } else {/*www .  j a  v  a2 s .  com*/
        inflateId = R.layout.panel_layout_land;
    }

    View view = LayoutInflater.from(mContext).inflate(inflateId, null, false);

    final DragViewGroup dragView = (DragViewGroup) view.findViewById(R.id.panel_drag_handler);
    dragView.setBackgroundDrawable(ColorsResolver.getBackgroundDrawable(mContext));

    if (ConstantHolder.getIsDebug()) {
        initTestVersionText(dragView);
    }

    ViewGroup viewToHide;
    if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT || sameLayout) {
        LinearLayout panelsContainer = (LinearLayout) dragView.findViewById(R.id.panels_container);
        viewToHide = panelsContainer;
        if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT) {
            panelsContainer.setTranslationY(GeneralResolver.getPanelsOffset(mContext));
        }

        List<String> panelsOrder = PanelsOrderResolver.getPanelsOrder(mContext);
        if (ShortcutsResolver.isShortcutsEnabled(mContext)) {
            ShortcutsViewFactory svFactory = new ShortcutsViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.SHORTCUTS.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(svFactory.getShortcutsSectionView());
        }

        if (MusicResolver.isMusicPanelEnabled(mContext)) {
            MusicViewFactory mvFactory = new MusicViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.MUSIC.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(mvFactory.getMusicView());
        }

        if (TogglesResolver.isTogglesEnabled(mContext)) {
            TogglesViewFactory tvFactory = new TogglesViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.TOGGLES.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(tvFactory.getTogglesSectionView());
        }

        if (InfoResolver.isInfoPanelEnabled(mContext)) {
            InfoViewFactory ivFactory = new InfoViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.INFO.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(ivFactory.getInfoView());
        }

        if (NotificationsResolver.isNotificationsEnabled(mContext)) {
            final ImageView fakeNotificationsButton = (ImageView) dragView
                    .findViewById(R.id.notifications_button_fake);
            PressImageView notificationsButton = (PressImageView) dragView
                    .findViewById(R.id.notifications_button);
            fakeNotificationsButton.setVisibility(View.VISIBLE);
            notificationsButton.setVisibility(View.VISIBLE);
            fakeNotificationsButton.setImageResource(R.drawable.ic_notification_switch);
            fakeNotificationsButton.setColorFilter(ColorsResolver.getActiveColor(mContext));
            final float SCALE = 1.5f;
            fakeNotificationsButton.setScaleX(SCALE);
            fakeNotificationsButton.setScaleY(SCALE);
            notificationsButton.setOnPressedStateChangeListener(new OnPressedStateChangeListener() {
                private final int BG_COLOR = ColorsResolver.getPressedColor(mContext);

                @Override
                public void onPressedStateChange(ImageView v, boolean pressed) {
                    if (pressed) {
                        fakeNotificationsButton.setBackgroundColor(BG_COLOR);
                    } else {
                        fakeNotificationsButton.setBackgroundColor(0x00000000);
                    }
                }
            });

            NotificationViewFactory nvFactory = new NotificationViewFactory(mContext);
            ViewGroup notificationsView = nvFactory.getNotificationsView();
            notificationsView.setAlpha(0.0f);
            notificationsView.setVisibility(View.INVISIBLE);
            FrameLayout notificationsContainer = (FrameLayout) dragView
                    .findViewById(R.id.notifications_section);
            notificationsContainer.addView(notificationsView);
            notificationsButton
                    .setOnClickListener(new NotificationButtonClickListener(viewToHide, notificationsView));
        }

    } else {

        ViewPager pager = (ViewPager) view.findViewById(R.id.landscape_pager);
        viewToHide = pager;
        List<View> views = new ArrayList<View>();

        if (NotificationsResolver.isNotificationsEnabled(mContext)) {
            NotificationViewFactory nvFactory = new NotificationViewFactory(mContext);
            ViewGroup notificationsView = nvFactory.getNotificationsView();
            views.add(notificationsView);
        }

        List<String> panelsOrder = PanelsOrderResolver.getPanelsOrder(mContext);
        for (String t : panelsOrder) {
            PanelType type = PanelType.valueOf(t);
            View v = null;
            FrameLayout container = (FrameLayout) LayoutInflater.from(mContext)
                    .inflate(R.layout.panel_section_land, null, false);
            switch (type) {
            case INFO:
                //     
                if (InfoResolver.isInfoPanelEnabled(mContext)) {
                    InfoViewFactory ivFactory = new InfoViewFactory(mContext);
                    FrameLayout fourthSection = (FrameLayout) view.findViewById(R.id.fourth_section);
                    fourthSection.addView(ivFactory.getInfoView());
                }
                break;
            case MUSIC:
                if (MusicResolver.isMusicPanelEnabled(mContext)) {
                    MusicViewFactory mvFactory = new MusicViewFactory(mContext);
                    v = mvFactory.getMusicView();
                }
                break;
            case SHORTCUTS:
                if (ShortcutsResolver.isShortcutsEnabled(mContext)) {
                    ShortcutsViewFactory svFactory = new ShortcutsViewFactory(mContext);
                    v = svFactory.getShortcutsSectionView();
                }
                break;
            case TOGGLES:
                if (TogglesResolver.isTogglesEnabled(mContext)) {
                    TogglesViewFactory tvFactory = new TogglesViewFactory(mContext);
                    v = tvFactory.getTogglesSectionView();
                }
                break;
            }

            if (v != null) {
                views.add(v);
                container.addView(v);
            }
        }

        LandscapePanelsAdapter adapter = new LandscapePanelsAdapter(views);
        pager.setAdapter(adapter);
        pager.setOverScrollMode(View.OVER_SCROLL_NEVER);
        pager.setOffscreenPageLimit(VIEW_PAGER_OFFSCREEN_PAGES_COUNT);
        pager.setPageMargin(mContext.getResources().getDimensionPixelSize(R.dimen.pager_margin));
    }

    return view;
}