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.moods_final.moods.entertainment.VideoListDemoActivity.java

/**
 * Sets up the layout programatically for the three different states. Portrait, landscape or
 * fullscreen+landscape. This has to be done programmatically because we handle the orientation
 * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources
 * do not get reloaded./*from  ww w  .ja  v a  2  s.  com*/
 */
private void layout() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
    listFragment.setLabelVisibility(isPortrait);
    closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);

    if (isFullscreen) {
        videoBox.setTranslationY(0); // Reset any translation that was applied in portrait.
        setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT);
    } else if (isPortrait) {
        setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT);
        setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM);
    } else {
        videoBox.setTranslationY(0); // Reset any translation that was applied in portrait.
        int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp);
        setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT);
        int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP);
        setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT);
        setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    }
}

From source file:com.experiment.chickenjohn.materialdemo.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    int currentOrientation = this.getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
        portLoading();/*from  w  ww . ja  va2s  .  c o  m*/
        Message uiRefreshMessage = Message.obtain();
        uiRefreshMessage.what = 0;
        uiRefreshHandler.sendMessage(uiRefreshMessage);
    } else if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        landLoading();
    }
    drawSurfaceView.resetSurfaceViewX();
}

From source file:com.kafilicious.popularmovies.ui.activity.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details_main);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.myToolbar);
    setSupportActionBar(toolbar);//w  w w . j  a  v a 2  s . com

    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    final Intent intent = this.getIntent();

    titleTextView = (TextView) findViewById(R.id.title_details);
    releaseDateTextView = (TextView) findViewById(R.id.year_details);
    ratingTextView = (TextView) findViewById(R.id.rating_score_detail);
    voteCountTextView = (TextView) findViewById(R.id.num_of_votes_detail);
    voteAverageTextView = (TextView) findViewById(R.id.vote_average_details);
    videoErrorTV = (TextView) findViewById(R.id.video_error_tv);
    reviewErrorTV = (TextView) findViewById(R.id.review_error_tv);
    ratingBar = (RatingBar) findViewById(R.id.rating_bar_detail);
    backDropImageView = (ImageView) findViewById(R.id.iv_backdrop);
    favoriteButton = (Button) findViewById(R.id.favorite);

    int orientation = this.getResources().getConfiguration().orientation;

    scrollView = (NestedScrollView) findViewById(R.id.nested_scrollView);
    if (scrollView != null) {
        scrollView.setFillViewport(true);
    }

    tabLayout = (TabLayout) findViewById(R.id.movie_details_tabLayout);
    viewPager = (ViewPager) findViewById(R.id.movie_details_container);

    dbHelper = new MovieDbHelper(this);

    sectionPagerAdapter = new SectionPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(sectionPagerAdapter);

    tabLayout.setupWithViewPager(viewPager);

    if (movieIsStored()) {
        favoriteButton.setText(R.string.button_text_marked);
    } else {
        favoriteButton.setText(R.string.button_text);
    }
    if (intent != null && intent.hasExtra(MOVIE_TITLE)) {

        movieTitle = intent.getStringExtra(MOVIE_TITLE);
        id = Integer.parseInt(intent.getStringExtra(MOVIE_ID));
        final String movieRelease = intent.getStringExtra(MOVIE_RELEASE);
        final String movieVoteCount = intent.getStringExtra(MOVIE_VOTE_COUNT);
        movieOverview = intent.getStringExtra(MOVIE_OVERVIEW);
        final String movieVoteAverage = intent.getStringExtra(MOVIE_VOTE_AVERAGE);
        final String moviePoster = intent.getStringExtra(MOVIE_POSTER);
        final String movieBackdrop = intent.getStringExtra(MOVIE_BACK_DROP);

        getSupportActionBar().setTitle(intent.getStringExtra(MOVIE_TITLE) + " ("
                + intent.getStringExtra(MOVIE_RELEASE).substring(0, 4) + ")");

        selectionArgs = new String[] { String.valueOf(id) };

        titleTextView.setText(movieTitle);
        releaseDateTextView.setText(movieRelease.substring(0, 4));
        voteAverageTextView.setText(movieVoteAverage + "/10");
        voteCountTextView.setText(movieVoteCount);
        String url2 = NetworkUtils.buildMovieUrl(movieBackdrop, 1).toString();
        Picasso.with(this).load(url2).into(backDropImageView);

        double voteAverage = Double.parseDouble(movieVoteAverage);
        voteAverage = (voteAverage / 10) * 5;
        String rating = String.format("%.1f", voteAverage);
        voteAverage = Double.parseDouble(rating);
        ratingTextView.setText(rating);
        ratingBar.setRating((float) voteAverage);
        ratingBar.setStepSize((float) 0.1);

        text = intent.getStringExtra(MOVIE_TITLE) + "(" + intent.getStringExtra(MOVIE_RELEASE).substring(0, 4)
                + ")";

        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            favoriteButton.setVisibility(View.GONE);
            fab = (FloatingActionButton) findViewById(R.id.fab);
            collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
            layoutDetail = (LinearLayout) findViewById(R.id.layout_detail_card);
            layoutDetail.setVisibility(View.GONE);
            posterDetailCard = (ImageView) findViewById(R.id.poster_detail_card);
            titleDetailCard = (TextView) findViewById(R.id.movie_title);
            releaseDetailCard = (TextView) findViewById(R.id.movie_release_date);
            ratingDetailCard = (TextView) findViewById(R.id.rating);
            ratingScoreDetailCard = (TextView) findViewById(R.id.rating_score_details);
            voteCountDetailCard = (TextView) findViewById(R.id.num_of_votes_details);
            ratingBarPortrait = (RatingBar) findViewById(R.id.rating_bar_details);
            myAppBarLayout = (AppBarLayout) findViewById(R.id.myAppbar);

            if (movieIsStored()) {
                fab.setImageResource(R.drawable.ic_star_black_24dp);
            } else {
                fab.setImageResource(R.drawable.ic_star_border_black_24dp);
            }

            myAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
                @Override
                public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
                    if (i == -collapsingToolbarLayout.getHeight() + toolbar.getHeight()) {
                        collapsingToolbarLayout
                                .setCollapsedTitleTextColor(getResources().getColor(android.R.color.white));
                        layoutDetail.setVisibility(View.VISIBLE);
                    } else {
                        layoutDetail.setVisibility(View.GONE);
                        collapsingToolbarLayout
                                .setExpandedTitleColor(getResources().getColor(R.color.transparent));
                    }
                }
            });

            titleDetailCard.setText(movieTitle);
            releaseDetailCard.setText(movieRelease);
            ratingDetailCard.setText(movieVoteAverage + "/10");
            voteCountDetailCard.setText(movieVoteCount);
            ratingScoreDetailCard.setText(rating);
            ratingBarPortrait.setRating((float) voteAverage);
            ratingBarPortrait.setStepSize((float) 0.1);
            ratingBarPortrait.setNumStars(5);
            String url = NetworkUtils.buildMovieUrl(moviePoster, 0).toString();
            Picasso.with(this).load(url).into(posterDetailCard);
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (movieIsStored()) {
                        fab.setImageResource(R.drawable.ic_star_border_black_24dp);
                        int deletedMovie = getContentResolver().delete(MovieContract.MovieEntry.CONTENT_URI,
                                selection, selectionArgs);
                        Log.i("Movie deleted", String.valueOf(deletedMovie));
                        Toast.makeText(DetailActivity.this, movieTitle + " has being removed from My Favorites",
                                Toast.LENGTH_LONG).show();
                    } else {
                        fab.setImageResource(R.drawable.ic_star_black_24dp);
                        ContentValues values = new ContentValues();
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_TITLE, movieTitle);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_ID, String.valueOf(id));
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_OVERVIEW, movieOverview);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_COUNT, movieVoteCount);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_AVERAGE, movieVoteAverage);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_BACKDROP_PATH, movieBackdrop);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_POSTR_PATH, moviePoster);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_RELEASE_DATE, movieRelease);
                        Uri updatedMovie = getContentResolver().insert(MovieContract.MovieEntry.CONTENT_URI,
                                values);
                        Log.i("Movie Added ", String.valueOf(updatedMovie) + " | Title: " + movieTitle);
                        Toast.makeText(DetailActivity.this, movieTitle + " has being added to My Favorites",
                                Toast.LENGTH_LONG).show();
                    }

                }
            });

        } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            favoriteButton.setVisibility(View.VISIBLE);
            favoriteButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (movieIsStored()) {
                        favoriteButton.setText(R.string.button_text);
                        int deletedMovie = getContentResolver().delete(MovieContract.MovieEntry.CONTENT_URI,
                                selection, selectionArgs);
                        Log.i("Movie deleted", String.valueOf(deletedMovie));
                        Toast.makeText(DetailActivity.this, movieTitle + " has being removed from My Favorites",
                                Toast.LENGTH_LONG).show();
                    } else {
                        favoriteButton.setText(R.string.button_text_marked);
                        ContentValues values = new ContentValues();
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_TITLE, movieTitle);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_ID, String.valueOf(id));
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_OVERVIEW, movieOverview);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_COUNT, movieVoteCount);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_VOTE_AVERAGE, movieVoteAverage);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_BACKDROP_PATH, movieBackdrop);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_POSTR_PATH, moviePoster);
                        values.put(MovieContract.MovieEntry.COLUMN_MOVIE_RELEASE_DATE, movieRelease);
                        Uri updatedMovie = getContentResolver().insert(MovieContract.MovieEntry.CONTENT_URI,
                                values);
                        Log.i("Movie Added", String.valueOf(updatedMovie) + " | Title: " + movieTitle);
                        Toast.makeText(DetailActivity.this, movieTitle + " has being added to My Favorites",
                                Toast.LENGTH_LONG).show();
                    }

                }
            });
        }

        Log.i("Results", "ID set successful");

    }
}

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onCreate(savedInstanceState);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    final int layout;
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, is_large_screen);
    mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, is_large_screen);
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        layout = mDualPaneInLandscape || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();/*ww w . j  av  a  2  s .  c om*/
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        layout = mDualPaneInPortrait || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();
        break;
    default:
        layout = getNormalLayoutRes();
        break;
    }
    setContentView(layout);
    if (mSlidingPane != null) {
        mSlidingPane.setRightPaneBackground(getPaneBackground());
    }
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
    if (savedInstanceState != null) {
        final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT);
        final View main_view = findViewById(R.id.main);
        final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded();
        if (main_view != null) {
            final int visibility = left_pane_used ? View.GONE : View.VISIBLE;
            main_view.setVisibility(visibility);
        }
    }
}

From source file:org.mariotaku.twidere.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        final int count = fm.getBackStackEntryCount();
        for (int i = 0; i < count; i++) {
            fm.popBackStackImmediate();/*  w ww .  j  a va 2 s  . co m*/
        }
    }
    super.onStart();
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, false);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            false);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:com.fsm.storybook.launcher.WebViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "onCreate");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);

    context = this;
    bkdb = new BookDatabase(getApplicationContext());
    globalApp = (GlobalApplication) this.getApplicationContext();
    util = new ActivityUtil(this);
    currentOrientation = String.valueOf(util.getScreenOrientation());
    gestureListener = new ContentGestureListener(this);
    //gestureListener = new WebViewGestureDetector();

    mWebview = (WebView) findViewById(R.id.webview);
    //mWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    mWebview.setOnClickListener(WebViewActivity.this);
    mWebview.setOnTouchListener(gestureListener);
    //mHiddenWebview = (WebView) findViewById(R.id.webview_hidden);
    //mHiddenWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    mPageInfo = (TextView) findViewById(R.id.page_info);
    mPageSlider = (SeekBar) findViewById(R.id.page_slider);
    mPageSlider.setOnSeekBarChangeListener(this);
    mPageInfo.setVisibility(View.GONE);
    mPageSlider.setVisibility(View.GONE);

    Intent intent = getIntent();//from w  w  w  . j a  va2 s.co m
    Bundle extras = intent.getExtras();

    if (extras == null)
        return;
    //if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) {

    mContainer = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID));
    if (mContainer == null) {
        finish();
        return;
    }
    mPackage = mContainer.getDefaultPackage();

    //?
    int bookCode = extras.getInt(Constants.BOOK_CODE);
    mBookData = bkdb.fetchBook(bookCode);
    setTitle(mBookData.getTitle());

    //??spineitem?spineitem??
    List<SpineItem> spineItems = mPackage.getSpineItems();
    for (SpineItem item : spineItems) {
        String idref = item.getIdRef();
        mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_PORTRAIT), idref, 1);
        mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_LANDSCAPE), idref, 1);
    }
    bkdb.updateBook(mBookData);

    /*
    mBookmarkList = bkdb.fetchBookmarkList(bookCode);
    mHighlightList = bkdb.fetchHighlightList(bookCode);
    */
    mViewerSettings = new ViewerSettings(mBookData.getSpreadCount() == 2, mBookData.getFontSize(), 20);
    try {
        Log.d(TAG, "openPageRequest JSON:" + extras.getString(Constants.OPEN_PAGE_REQUEST_DATA));
        mOpenPageRequestData = OpenPageRequest.fromJSON(extras.getString(Constants.OPEN_PAGE_REQUEST_DATA));
    } catch (JSONException e) {
        Log.e(TAG, "Constants.OPEN_PAGE_REQUEST_DATA must be a valid JSON object: " + e.getMessage(), e);
    }

    //???
    if (mBookData.getTotalPageCount(currentOrientation) <= 0) {
        pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_NONE;
    } else {
        pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_DONE;
    }

    //epub web server
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            mServer = new EpubServer(EpubServer.HTTP_HOST, EpubServer.HTTP_PORT, mPackage, false);
            mServer.startServer();
            return null;
        }
    }.execute();

    //??hidden webview
    /*
    initHiddenWebView();
    mHiddenWebview.loadUrl(HIDDEN_READER_SKELETON);
    mReadiumJSApiForHiddenWebView = new ReadiumJSApi(new ReadiumJSApi.JSLoader() {
     @Override
     public void loadJS(String javascript) {
        mHiddenWebview.loadUrl(javascript);
     }
    });
    */

    //?webview
    initWebView();
    mWebview.loadUrl(READER_SKELETON);
    mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() {
        @Override
        public void loadJS(String javascript) {
            mWebview.loadUrl(javascript);
        }
    });

    //}

}

From source file:com.near.chimerarevo.activities.PostContainerActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if ((newConfig.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
            isLandscapeLarge = true;//from  w w  w .  j  a v a2 s. c om
        else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
            isLandscapeLarge = false;
    }
}

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

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

    try {/*from   www.  java2  s. c  o m*/

        // Checks the orientation of the screen
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;

        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

        }
        setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.worshipsongs.activity.CustomYoutubeBoxActivity.java

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer,
        boolean wasRestored) {
    if (Configuration.ORIENTATION_PORTRAIT == getResources().getConfiguration().orientation) {
        this.youTubePlayer = youTubePlayer;
        youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
        youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
        youTubePlayer.setShowFullscreenButton(false);
        youTubePlayer.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() {
            @Override/* w w  w  . j  av  a  2  s  .  c om*/
            public void onFullscreen(boolean b) {
                isFullscreen = b;
            }
        });
        if (mVideoId != null && !wasRestored) {
            youTubePlayer.loadVideo(mVideoId);
        }
        if (wasRestored) {
            youTubePlayer.seekToMillis(millis);
        }
    }
}

From source file:net.xisberto.work_schedule.alarm.AlarmMessageActivity.java

private void setOrientation() {
    if (isLargeScreen()) {
        setRequestedOrientation(Configuration.ORIENTATION_LANDSCAPE);
    } else {/*from ww w . java2 s. co m*/
        setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
    }
}