List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:de.tlabs.ssr.g1.client.SourcesView.java
public void transformToFitScene() { float xScalingFactor = 0.0f; float yScalingFactor = 0.0f; float xDiff;/* w w w. j a v a 2 s . com*/ float yDiff; float[][] sceneBounds; float minBounds[]; float maxBounds[]; // if size of this view not yet initialized, wait until it is initialized if (!viewSizeInitialized) { transformToFitSceneFlag = true; return; } // get scene bounds in screen coordinates recalculateViewportTransformation(); // just to be sure we are using the latest values sceneBounds = getSceneBounds(viewportTransformation); minBounds = sceneBounds[0]; maxBounds = sceneBounds[1]; // get max x and y distances in pixels xDiff = maxBounds[0] - minBounds[0]; yDiff = maxBounds[1] - minBounds[1]; // recalculate scaling if (xDiff > 0 || yDiff > 0) { // calculate best scaling in x and y direction if (xDiff > 0) { xScalingFactor = ((float) getWidth() - FIT_SCENE_PIXEL_BORDER_2) / xDiff; } else { xScalingFactor = Float.POSITIVE_INFINITY; } if (yDiff > 0) { yScalingFactor = ((float) getHeight() - FIT_SCENE_PIXEL_BORDER_2) / yDiff; } else { yScalingFactor = Float.POSITIVE_INFINITY; } // set best scaling float scalingFactor = Math.min(xScalingFactor, yScalingFactor); zoomView(scalingFactor); recalculateViewportTransformation(newViewportTransformation, currentCenterRotation, currentScaling * scalingFactor, currentTranslation); } else { newViewportTransformation.set(viewportTransformation); } // get scene bounds using new scaling sceneBounds = getSceneBounds(newViewportTransformation); minBounds = sceneBounds[0]; maxBounds = sceneBounds[1]; // get max x and y distances in pixels xDiff = maxBounds[0] - minBounds[0]; yDiff = maxBounds[1] - minBounds[1]; // calculate translation to center the scene float transX = -minBounds[0] + (getWidth() - xDiff) / 2; float transY = -minBounds[1] + (getHeight() - yDiff) / 2; if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) { translateView(transX, transY); } else if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { translateView(transY, -transX); } }
From source file:com.cypress.cysmart.RDKEmulatorView.RemoteControlEmulatorFragment.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mParentView = inflater.inflate(R.layout.rgb_view_landscape, null); ViewGroup rootViewG = (ViewGroup) getView(); // Remove all the existing views from the root view. try {// ww w . j av a 2 s . c o m assert rootViewG != null; rootViewG.removeAllViews(); rootViewG.addView(mParentView); } catch (Exception e) { e.printStackTrace(); } } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mParentView = inflater.inflate(R.layout.rgb_view_portrait, null); ViewGroup rootViewG = (ViewGroup) getView(); // Remove all the existing views from the root view. try { assert rootViewG != null; rootViewG.removeAllViews(); rootViewG.addView(mParentView); } catch (Exception e) { e.printStackTrace(); } } }
From source file:de.tlabs.ssr.g1.client.SourcesView.java
public void setOrientation(int newOrientation) { if (currentOrientation == newOrientation) return;/*from w w w. j a v a2s .c om*/ if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) { // portrait -> landscape centerRotationInterpolator.setStartEndValues(0.0f, -90.0f); } else if (newOrientation == Configuration.ORIENTATION_PORTRAIT) { // landscape -> portrait centerRotationInterpolator.setStartEndValues(-90.0f, 0.0f); } else { // unsupported orientation, this should never happen return; } // save current orientation currentOrientation = newOrientation; setOrientationFlag(true); // start interpolating centerRotationInterpolator.startInterpolating(); }
From source file:com.atlas.mars.weatherradar.MainActivity.java
private boolean isLandscapeMode() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { return false; } else {//from www .j av a 2 s.c om return true; } }
From source file:com.ttxgps.zoom.GestureImageView.java
/** * Returns true if the image dimensions are aligned with the orientation of * the device.//from w w w. j a v a2 s.co m * * @return */ public boolean isOrientationAligned() { if (deviceOrientation == Configuration.ORIENTATION_LANDSCAPE) { return isLandscape(); } else if (deviceOrientation == Configuration.ORIENTATION_PORTRAIT) { return isPortrait(); } return true; }
From source file:info.tellmetime.TellmetimeActivity.java
/** * Handles changing highlight color via #mSeekBarHighlight. * * @param value indicates exact offset in gradient (SeekBar's max value is equal to #mRainbow width). *//* w w w . j a v a 2s .co m*/ @Override public void onProgressChanged(SeekBar seekBar, int value, boolean fromUser) { switch (seekBar.getId()) { case R.id.highlightValue: mHighlightColor = mRainbow.getPixel(value, 0); if (((RadioButton) findViewById(R.id.radio_backlight_highlight)).isChecked()) { float[] highlightHSV = new float[3]; Color.colorToHSV(mHighlightColor, highlightHSV); mBacklightColor = Color.HSVToColor(33, highlightHSV); } if (fromUser) mHighlightPosition = (float) value / seekBar.getMax(); mClockAlgorithm.tickTock(); break; case R.id.minutesSize: mMinutesSize = value; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout minutesIndicators = (FrameLayout) findViewById(R.id.minutes_indicators); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) minutesIndicators .getLayoutParams(); params.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); minutesIndicators.setLayoutParams(params); } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); } break; } mHider.delayedHide(4000); }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
private void stopScan() { if (mScanning) { runOnUiThread(new Runnable() { @Override/* www . j av a2 s .co m*/ public void run() { if (mScanType == ScanType.CLASSIC_SCAN) { mBluetoothAdapter.cancelDiscovery(); } else { Toast.makeText(HciDebuggerActivity.this, getResources().getString(R.string.toast_scan_stop), Toast.LENGTH_SHORT).show(); mBluetoothAdapter.stopLeScan(scanCallback); } mScanning = false; MenuItem item; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { item = nvDrawer.getMenu().findItem(R.id.scan_btn_nv); } else { item = toolbar.getMenu().findItem(R.id.scan_btn); } if (item != null) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { item.setIcon(R.drawable.ic_looks); } else { item.setIcon(R.drawable.ic_action_scanning); } item.setTitle(getResources().getString(R.string.menu_item_title_start_scan)); } //Toast.makeText(HciDebuggerActivity.this, getResources().getString(R.string.toast_scan_stop), Toast.LENGTH_SHORT).show(); } }); } else { Log.v(TAG, "not scanning"); } }
From source file:hu.fnf.devel.atlas.Atlas.java
private void setViewCategoryProperties(int page) { /*//from w ww . j a va 2 s. c o m * List LABEL */ TextView header = (TextView) findViewById(R.id.header_text_view); TextView newe = (TextView) findViewById(R.id.new_etwas_text); EditText newc = (EditText) findViewById(R.id.new_etwas); ContentResolver cr = getContentResolver(); Uri.Builder builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); Cursor list = null; String[] projection = null; switch (page) { case AtlasData.PINCOME: newe.setText(getResources().getString(R.string.category) + ":"); newc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); builder.appendPath(AtlasData.TABLE_DATA); builder.appendPath("guess"); list = cr.query(builder.build(), AtlasData.DATA_COLUMNS, null, null, null); header.setText(getResources().getString(R.string.guess) + "(" + String.valueOf(list.getCount()) + ")"); list.close(); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_DATA); projection = AtlasData.DATA_COLUMNS; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("onCreate", "only toptask"); builder.appendPath("topguess"); } else { Log.d("onCreate", "all tasks"); builder.appendPath("guess"); } break; case AtlasData.PSUMMARY: newe.setText(getResources().getString(R.string.amount) + ":"); newc.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); builder.appendPath(AtlasData.TABLE_TRANSACTIONS); builder.appendPath("tasks"); list = cr.query(builder.build(), AtlasData.TRANSACTIONS_COLUMNS, null, null, null); header.setText(getResources().getString(R.string.tasks) + "(" + String.valueOf(list.getCount()) + ")"); list.close(); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_TRANSACTIONS); projection = AtlasData.TRANSACTIONS_COLUMNS; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("onCreate", "only toptask"); builder.appendPath("toptask"); } else { Log.d("onCreate", "all tasks"); builder.appendPath("tasks"); } break; case AtlasData.POUTCOME: newe.setText(getResources().getString(R.string.category) + ":"); newc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); builder.appendPath(AtlasData.TABLE_DATA); builder.appendPath("data"); list = cr.query(builder.build(), AtlasData.DATA_COLUMNS, null, null, null); header.setText(getResources().getString(R.string.data) + "(" + String.valueOf(list.getCount()) + ")"); list.close(); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_DATA); projection = AtlasData.DATA_COLUMNS; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("onCreate", "only toptask"); builder.appendPath("topdata"); } else { Log.d("onCreate", "all tasks"); builder.appendPath("data"); } break; default: Log.e("onPageSelected", "page?!: " + page); break; } header.setOnClickListener(onHeaderClickListener); Cursor tasks_result = cr.query(builder.build(), projection, null, null, null); DatabaseQueryAdapter ta = new DatabaseQueryAdapter(this, tasks_result, 0, builder.build().getPathSegments().get(0)); Log.d("onCreate", "result count: " + tasks_result.getColumnCount()); ListView lv = (ListView) findViewById(R.id.tasklist); lv.setAdapter(ta); }
From source file:net.gaast.giggity.ScheduleViewActivity.java
private void updateOrientation(int orientation) { if (orientation == Configuration.ORIENTATION_PORTRAIT) bigScreen.setOrientation(LinearLayout.VERTICAL); else/* w w w.j ava 2s. c om*/ bigScreen.setOrientation(LinearLayout.HORIZONTAL); }
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Calculate y slide to center value//w w w . j ava2 s .c o m * Portrait: 75% of timer clock view above center * Landscape: 60% of timer clock view above center */ public float calcCenterYValue() { if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { return (getScreenHeight() / 2) - (timerClockView.getHeight() * 0.75f); } else { return (getScreenHeight() / 2) - (timerClockView.getHeight() * 0.60f); } }