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:edu.mit.mobile.android.locast.ver2.casts.VideoPlayer.java

private void adjustForOrientation(Configuration newConfig) {
    if (Configuration.ORIENTATION_PORTRAIT == newConfig.orientation) {
        mDescriptionView.setVisibility(View.VISIBLE);
        mTitleView.setVisibility(View.VISIBLE);
        mHandler.removeMessages(HIDE_TITLE);
    } else {/*w w w .  j a v a2 s . c o  m*/
        mDescriptionView.setVisibility(View.INVISIBLE);
        if (mVideoView.isPlaying()) {
            hideTitleNow();
        }
    }
}

From source file:com.waz.zclient.pages.main.profile.ZetaPreferencesActivity.java

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

    if (LayoutSpec.isPhone(this)) {
        ViewUtils.lockScreenOrientation(Configuration.ORIENTATION_PORTRAIT, this);
    }/* w  w w  .jav a  2s. c  om*/

    if (savedInstanceState == null) {
        getSupportFragmentManager()
                .beginTransaction().add(R.id.content,
                        RootPreferences.newInstance(null, getIntent().getExtras()), RootPreferences.TAG)
                .commit();
    }
}

From source file:io.github.msc42.masterthemaze.SearchDeviceActivity.java

private void lockScreenOrientation() {
    int orientation = getResources().getConfiguration().orientation;
    int rotation = getWindowManager().getDefaultDisplay().getRotation();

    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {//from ww w.j  a  va  2 s . c  o  m
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        }
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        }
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

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

/**
 * Set up tabs/*  w  ww .  j  ava 2s  .  co  m*/
 * 
 * @param res   the application's resources
 */
private void setupTabs(Resources res) {
    mTabManager = new TabManager(this, mTabHost, R.id.realtabcontent);

    mTabManager.addTab(mTabHost.newTabSpec(POI).setIndicator("POIs", res.getDrawable(R.drawable.ic_tab_poi)),
            POIFragment.class, null);
    mTabManager.addTab(
            mTabHost.newTabSpec(FEATURE).setIndicator("Features", res.getDrawable(R.drawable.ic_tab_feature)),
            FeatureFragment.class, null);

    // add MapDisplayFragment to tabs only in portrait mode
    if (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        Fragment mapFragment = getSupportFragmentManager().findFragmentByTag(MAP);

        if (mapFragment != null) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.remove(mapFragment);
            ft.commit();
            getSupportFragmentManager().executePendingTransactions();
            mTabManager.addTab(
                    mTabHost.newTabSpec(MAP).setIndicator("Map", res.getDrawable(R.drawable.ic_tab_map)),
                    mapFragment, null);
        } else
            mTabManager.addTab(
                    mTabHost.newTabSpec(MAP).setIndicator("Map", res.getDrawable(R.drawable.ic_tab_map)),
                    MapDisplayFragment.class, null);
    }
}

From source file:com.nike.plusgps.nikeplusgallery.MainActivity.java

/**
 * Handles the screen layouts based on the orientation.
 * The activity is not restarted when the orientation changes.
 *///from  w ww . j a  va 2s.c  o m
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // In Portrait mode the grid view is displayed
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

        setContentView(R.layout.activity_main_port);
        GridView view = (GridView) findViewById(R.id.gridView);
        adapter = new FlickrFeedAdapter(getApplicationContext(), R.layout.single_elem_port, flickrFeedList,
                dbHelper, mMemoryCache);
        view.setAdapter(adapter);

    } else { // In Landscape mode the carousel view is displayed

        setContentView(R.layout.activity_main_land);
        carouselElement = (LinearLayout) findViewById(R.id.carousel);
        // Compute width of a carousel item based on screen width and initial item count
        final DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        final int imageWidth = (int) (displayMetrics.widthPixels / INITIAL_ITEMS_COUNT);

        // Fetches image url from SQLite cache
        ImageView imageItem;
        String imgURL;
        for (int i = 0; i < flickrFeedList.size(); ++i) {
            imageItem = new ImageView(this);
            imgURL = flickrFeedList.get(i).getMedia();
            new DownloadImageTask(imageItem).execute(imgURL);
            imageItem.setLayoutParams(new LinearLayout.LayoutParams(imageWidth, imageWidth));
            carouselElement.addView(imageItem);
        }
    }
}

From source file:com.zephyrteam.costituzione.DetailedActivity.java

public void heuristicSetTytle(Configuration config) {
    if (mIsTablet) {
        setTitle(R.string.app_name);/* w w  w.j  ava2  s  .c o  m*/
    } else {
        int orientation = config.orientation;
        switch (orientation) {
        case Configuration.ORIENTATION_LANDSCAPE:
        case Configuration.ORIENTATION_SQUARE:
            setTitle(R.string.app_name);
            break;
        case Configuration.ORIENTATION_PORTRAIT:
            setTitle(null);
            break;
        default:
            setTitle(R.string.app_name);
            break;
        }
    }
}

From source file:eu.inmite.apps.smsjizdenka.fragment.TicketsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    vList = (ListView) view.findViewById(android.R.id.list);
    vTopHelp = view.findViewById(R.id.top_help);
    vBottomHelp = view.findViewById(R.id.bottom_help);
    vBuy = (Button) view.findViewById(R.id.buy);
    vEmpty = view.findViewById(android.R.id.empty);
    vProgress = view.findViewById(android.R.id.progress);
    vList.setEmptyView(vEmpty);//  w  ww.  j av a  2  s  . c o  m
    showProgress();
    vList.setVisibility(View.GONE);
    if (mShowAnimation) {
        vList.setLayoutAnimation(
                new LayoutAnimationController(AnimationUtils.loadAnimation(c, android.R.anim.slide_in_left)));
    }
    vList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            collapseUncollapseTicket(id, false);
        }
    });
    vBuy.setOnClickListener(new

    View.OnClickListener() {
        @Override
        public void onClick(View v) {

            startActivity(CitiesActivity.class);
        }
    });
    vSwipeDismissList = new SwipeDismissList(vList, callback, SwipeDismissList.UndoMode.COLLAPSED_UNDO);
    vSwipeDismissList.setUndoString(c.getString(R.string.tickets_ticket_deleted));
    vSwipeDismissList.setUndoMultipleString(c.getString(R.string.tickets_tickets_deleted));
    // first launch animations
    int dpi = getResources().getDisplayMetrics().densityDpi;
    if (mShowAnimation && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
            && dpi != DisplayMetrics.DENSITY_LOW && dpi != DisplayMetrics.DENSITY_MEDIUM) {
        AnimationUtil.addAnimationToView(vTopHelp, R.anim.slide_in_top);
        AnimationUtil.addAnimationToView(vBottomHelp, R.anim.slide_in_bottom);
    }
    mShowAnimation = false;
    //SL.get(AnalyticsService.class).trackScreen("my-tickets");
}

From source file:com.landenlabs.all_devtool.ScreenFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    // super.onViewCreated(view, savedInstanceState);
    cacheFragment();/*  w ww .  ja va  2  s .  com*/
    if (GlobalInfo.s_globalInfo.haveActionBarOverlay) {
        RelativeLayout.LayoutParams relParams = (RelativeLayout.LayoutParams) m_screenDevice.getLayoutParams();
        int padTop = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
                ? GlobalInfo.s_globalInfo.actionBarHeight * 2
                : GlobalInfo.s_globalInfo.actionBarHeight;
        relParams.setMargins(0, padTop, 0, 0);
    }
}

From source file:net.mEmoZz.PopMovies.frags.MoviesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_main, container, false);
    setHasOptionsMenu(true);//from w  ww  .ja va 2 s.  c  o  m

    noConn = (ImageView) v.findViewById(R.id.noConn);
    noConnTxt = (TextView) v.findViewById(R.id.noConnTxt);
    gridView = (RecyclerView) v.findViewById(R.id.mainGrid);
    mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.refreshLayout);
    mRefreshLayout.setColorSchemeColors(0xff6b4d9c);
    conf = getResources().getConfiguration();
    int rotation = getResources().getConfiguration().orientation;

    LinearLayoutManager tabPort = manager = new GridLayoutManager(getActivity(), 1);
    LinearLayoutManager tabLand = manager = new GridLayoutManager(getActivity(), 2);
    LinearLayoutManager mobPort = manager = new GridLayoutManager(getActivity(), 2);
    LinearLayoutManager mobLand = manager = new GridLayoutManager(getActivity(), 3);

    if (conf.smallestScreenWidthDp >= 600) {
        switch (rotation) {
        case Configuration.ORIENTATION_PORTRAIT:
            gridView.setLayoutManager(tabPort);
            loadMore(tabPort);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            gridView.setLayoutManager(tabLand);
            loadMore(tabLand);
            break;
        }
    } else {
        switch (rotation) {
        case Configuration.ORIENTATION_PORTRAIT:
            gridView.setLayoutManager(mobPort);
            loadMore(mobPort);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            gridView.setLayoutManager(mobLand);
            loadMore(mobLand);
            break;
        }
    }
    return v;
}

From source file:org.catrobat.paintroid.ui.BottomBar.java

private void startBottomBarAnimation() {
    final HorizontalScrollView horizontalScrollView = (HorizontalScrollView) mMainActivity
            .findViewById(R.id.bottom_bar_scroll_view);
    final ScrollView verticalScrollView = (ScrollView) mMainActivity
            .findViewById(R.id.bottom_bar_landscape_scroll_view);
    final int animationDuration = 1000;
    int orientation = mMainActivity.getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        horizontalScrollView.post(new Runnable() {
            public void run() {
                int scrollToX = (int) (getToolButtonByToolType(mCurrentToolType).getX()
                        - horizontalScrollView.getWidth() / 2.0f
                        + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_button_width) / 2.0f);
                int scrollFromX = PaintroidApplication.isRTL ? horizontalScrollView.getChildAt(0).getLeft()
                        : horizontalScrollView.getChildAt(0).getRight();
                horizontalScrollView.setScrollX(scrollFromX);
                ObjectAnimator.ofInt(horizontalScrollView, "scrollX", scrollToX).setDuration(animationDuration)
                        .start();/*w ww  . ja  va2  s .  c o m*/
            }
        });
    } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        verticalScrollView.post(new Runnable() {
            public void run() {
                int scrollToY = (int) (getToolButtonByToolType(mCurrentToolType).getY()
                        - verticalScrollView.getHeight() / 2.0f
                        + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_landscape_button_height)
                                / 2.0f);
                int scrollFromY = verticalScrollView.getChildAt(0).getBottom();
                verticalScrollView.setScrollY(scrollFromY);
                ObjectAnimator.ofInt(verticalScrollView, "scrollY", scrollToY).setDuration(animationDuration)
                        .start();
            }
        });
    }

    delayedAnimateSelectedTool(animationDuration);
}