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:com.google.android.apps.santatracker.games.SplashActivity.java

@Override
protected void onStart() {
    super.onStart();

    // Orientation
    boolean gameIsLandscape = getIntent().getBooleanExtra(EXTRA_LANDSCAPE, false);
    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int rotation = display.getRotation();

    // Figure out how many degrees to rotate
    // Landscape always wants to be at 90degrees, portrait always wants to be at 0degrees
    float degreesToRotate = 0f;
    if (rotation == Surface.ROTATION_0) {
        degreesToRotate = gameIsLandscape && !isLandscape ? 90.0f : 0.0f;
    } else if (rotation == Surface.ROTATION_90) {
        degreesToRotate = gameIsLandscape && isLandscape ? 0f : -90f;
    } else if (rotation == Surface.ROTATION_180) {
        degreesToRotate = gameIsLandscape && !isLandscape ? -90f : -180f;
    } else if (rotation == Surface.ROTATION_270) {
        degreesToRotate = gameIsLandscape && isLandscape ? -180f : -270f;
    }/*w ww  . j av  a  2s . co  m*/

    // On a TV, should always be 0
    if (isRunningOnTV()) {
        degreesToRotate = 0f;
    }

    // Rotate, if necessary
    if (degreesToRotate != 0) {
        Point size = new Point();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            display.getRealSize(size);
        } else {
            display.getSize(size);
        }
        int w = size.x;
        int h = size.y;

        View mainLayout = findViewById(R.id.splash_layout);
        mainLayout.setRotation(degreesToRotate);
        mainLayout.setTranslationX((w - h) / 2);
        mainLayout.setTranslationY((h - w) / 2);

        ViewGroup.LayoutParams lp = mainLayout.getLayoutParams();
        lp.height = w;
        lp.width = h;

        mainLayout.requestLayout();
    }
}

From source file:com.nineducks.hereader.ui.NewsItemsFragment.java

private void initUI() {
    Log.d("hereader", "Creating UI");
    webViewContainer = (FrameLayout) getActivity().findViewById(R.id.webview_container);
    mDualPane = webViewContainer != null && webViewContainer.getVisibility() == View.VISIBLE;
    actionBar = (ActionBar) getActivity().findViewById(R.id.action_bar);
    actionBar.setHomeIcon(R.drawable.hackful_icon);
    actionBar.addAction(new LoadFrontpageItemsAction(HackfulReaderActivity.getContext(), this));
    actionBar.addAction(new LoadNewItemsAction(HackfulReaderActivity.getContext(), this));
    actionBar.addAction(new LoadAskItemsAction(HackfulReaderActivity.getContext(), this));
    actionBar.addAction(new AboutAction(HackfulReaderActivity.getContext(), this));
    if (mDualPane || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        actionBar.setTitle(R.string.app_name);
    }/*from  w  w w.ja v a  2  s  . c o  m*/
    if (mDualPane) {
        if (webView == null) {
            Log.d("hereader", "WebView is null, creating new instance");
            final ActionBar actionB = actionBar;
            webView = new WebView(getActivity());
            webView.setId(R.id.webview_id);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setSupportZoom(true);
            //webView.getSettings().setBuiltInZoomControls(false);
            webView.setWebChromeClient(new WebChromeClient() {

                @Override
                public void onProgressChanged(WebView view, int newProgress) {
                    if (newProgress == 100) {
                        actionB.setProgressBarVisibility(View.GONE);
                    }
                }

            });
        }
        webViewContainer.addView(webView, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    }
    Log.d("hereader", "UI created");
}

From source file:com.nextgis.maplibui.activity.FormBuilderModifyAttributesActivity.java

@Override
protected void fillControls(LinearLayout layout, Bundle savedState) {
    //TODO: add location control via fragment only defined by user space

    Bundle extras = getIntent().getExtras(); // null != extras
    File form = (File) extras.getSerializable(KEY_FORM_PATH);

    int orientation = getResources().getConfiguration().orientation;
    boolean isLand = orientation == Configuration.ORIENTATION_LANDSCAPE;

    try {/* w w  w  . j  av a2 s. c o m*/
        String formString = FileUtil.readFromFile(form);
        if (TextUtils.indexOf(formString, "tabs") == -1) {
            JSONArray elements = new JSONArray(formString);
            if (elements.length() > 0) {
                fillTabControls(layout, savedState, elements);
            }
        } else {
            JSONObject jsonFormContents = new JSONObject(formString);
            JSONArray tabs = jsonFormContents.getJSONArray(JSON_TABS_KEY);

            for (int i = 0; i < tabs.length(); i++) {
                JSONObject tab = tabs.getJSONObject(i);
                JSONArray elements = null;

                if (isLand && !tab.isNull(JSON_ALBUM_ELEMENTS_KEY)) {
                    elements = tab.getJSONArray(JSON_ALBUM_ELEMENTS_KEY);
                }

                if (null == elements) {
                    if (!isLand && !tab.isNull(JSON_PORTRAIT_ELEMENTS_KEY)) {
                        elements = tab.getJSONArray(JSON_PORTRAIT_ELEMENTS_KEY);
                    }
                }

                if (null == elements) {
                    if (!tab.isNull(JSON_ALBUM_ELEMENTS_KEY)) {
                        elements = tab.getJSONArray(JSON_ALBUM_ELEMENTS_KEY);
                    }

                    if (!tab.isNull(JSON_PORTRAIT_ELEMENTS_KEY)) {
                        elements = tab.getJSONArray(JSON_ALBUM_ELEMENTS_KEY);
                    }
                }

                if (null != elements && elements.length() > 0) {
                    fillTabControls(layout, savedState, elements);
                }
            }
        }

    } catch (JSONException | IOException e) {
        e.printStackTrace();
        Toast.makeText(this, getString(R.string.error_form_create), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.fowlcorp.homebank4android.gui.AccountFragment.java

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

    int key = accountList.get(sectionNumber).getKey();

    List<Operation> operation = model.getOperations(model.getAccounts().get(key));
    ArrayList<Operation> listTemp = new ArrayList<>();

    switch (displayValue) {
    case DISPLAY_ALL:
        listTemp.addAll(operation); //get all the operation to display all
        break;/*w ww. j a v a  2 s .  co m*/
    case DISPLAY_PAID:
        for (Operation op : operation) {
            if (op.isReconciled()) {
                listTemp.add(op);
            }
        }
        break;
    case DISPLAY_UNPAID:
        for (Operation op : operation) {
            if (!op.isReconciled()) {
                listTemp.add(op);
            }
        }
        break;
    case DISPLAY_REMIND:
        for (Operation op : operation) {
            if (op.isRemind()) {
                listTemp.add(op);
            }
        }

    }

    ArrayList<Operation> listOperation = new ArrayList<>();
    for (int i = listTemp.size() - 1; i >= 0; i--) { //revert the sort
        listOperation.add(listTemp.get(i));
    }

    View rootView = inflater.inflate(R.layout.recycle_layout, container, false); //the recycler layout

    RecyclerView mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view);
    LinearLayout overview = (LinearLayout) rootView.findViewById(R.id.fragmentOverview);
    OverviewCard over = new OverviewCard(getActivity(), inflater, overview, model); //create the overview card

    mRecyclerView.setHasFixedSize(false);

    LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mLayoutManager.setOrientation(HORIZONTAL);
    }
    mRecyclerView.setLayoutManager(mLayoutManager);
    AccountRecyclerAdapter mAdapter = new AccountRecyclerAdapter(listOperation, getActivity());
    mRecyclerView.setAdapter(mAdapter);

    return rootView;
}

From source file:com.ttxgps.zoom.GestureImageView.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    if (drawable != null) {
        int orientation = getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            displayHeight = MeasureSpec.getSize(heightMeasureSpec);

            if (getLayoutParams().width == LayoutParams.WRAP_CONTENT) {
                float ratio = (float) getImageWidth() / (float) getImageHeight();
                displayWidth = Math.round((float) displayHeight * ratio);
            } else {
                displayWidth = MeasureSpec.getSize(widthMeasureSpec);
            }/* w  ww .  ja  v a2s . c  o m*/
        } else {
            displayWidth = MeasureSpec.getSize(widthMeasureSpec);
            if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) {
                float ratio = (float) getImageHeight() / (float) getImageWidth();
                displayHeight = Math.round((float) displayWidth * ratio);
            } else {
                displayHeight = MeasureSpec.getSize(heightMeasureSpec);
            }
        }
    } else {
        displayHeight = MeasureSpec.getSize(heightMeasureSpec);
        displayWidth = MeasureSpec.getSize(widthMeasureSpec);
    }

    setMeasuredDimension(displayWidth, displayHeight);
}

From source file:com.ushahidi.android.app.activities.BaseActivity.java

private MenuDrawer appendMenuDrawer() {
    MenuDrawer menuDrawer = null;/*ww w  .ja  v  a  2 s  .c  o m*/
    if (mXLargeDevice) {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.LEFT, true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        } else {
            menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    } else {
        menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT);
    }
    int shadowSizeInPixels = getResources().getDimensionPixelSize(R.dimen.menu_shadow_width);
    menuDrawer.setDropShadowSize(shadowSizeInPixels);
    menuDrawer.setDropShadowColor(getResources().getColor(R.color.md_shadowColor));
    return menuDrawer;
}

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

/**
 * Update views in the fragment when provider status is busy.
 *
 * @param resId resource ID of the string to show in mMessageView.
 *//*from   w  w  w .  j a v  a  2  s.  c o  m*/
private void updateViewsForBusyStatus(int resId) {
    mMessageView.setText(resId);
    mMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
    mMessageView.setVisibility(View.VISIBLE);
    updateButtonVisibilty(View.GONE);
    mProgress.setVisibility(View.VISIBLE);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mMessageView.getLayoutParams();
        final int marginTop = (int) getResources().getDimension(R.dimen.update_contact_list_top_margin);
        lp.setMargins(0, marginTop, 0, 0);
        mImageView.setVisibility(View.GONE);
    } else {
        mImageView.setVisibility(View.INVISIBLE);
    }
}

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

public void heuristicSetTytle(Configuration config) {
    if (mIsTablet) {
        setTitle(R.string.app_name);/*from   ww  w.j a v  a2  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:com.finchuk.clock2.timers.ui.TimersFragment.java

@Override
protected RecyclerView.LayoutManager getLayoutManager() {
    switch (getOrientation(getResources())) {
    case Configuration.ORIENTATION_LANDSCAPE:
        return new GridLayoutManager(getActivity(), LANDSCAPE_LAYOUT_COLUMNS);
    default:/*w w  w  .j av  a  2 s  . c o m*/
        return super.getLayoutManager();
    }
}

From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java

@SuppressLint("NewApi")
protected void initBaseZoomableImageView(Context context) {
    mPaint = new Paint();
    mPaint.setDither(true);//from  ww w.  j a v a2 s .  co m
    mPaint.setFilterBitmap(true);
    mPaint.setAntiAlias(true);
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        landscape = true;
    } else {
        landscape = false;
    }
    // Setup the refresh runnable
    mRefresh = new Runnable() {
        @Override
        public void run() {
            postInvalidate();
        }
    };
}