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:tech.salroid.filmy.fragment.UpComing.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_up_coming, container, false); ButterKnife.bind(this, view); boolean tabletSize = getResources().getBoolean(R.bool.isTablet); if (tabletSize) { if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } else {// w ww . j ava 2 s . c o m StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } } else { if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } else { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } } mainActivityAdapter = new MainActivityAdapter(getActivity(), null); recycler.setAdapter(mainActivityAdapter); mainActivityAdapter.setClickListener(this); return view; }
From source file:tech.salroid.filmy.fragment.Trending.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_trending, container, false); ButterKnife.bind(this, view); boolean tabletSize = getResources().getBoolean(R.bool.isTablet); if (tabletSize) { if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } else {// ww w. j a va2 s . c o m StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } } else { if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } else { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } } mainActivityAdapter = new MainActivityAdapter(getActivity(), null); recycler.setAdapter(mainActivityAdapter); mainActivityAdapter.setClickListener(this); return view; }
From source file:tech.salroid.filmy.fragment.InTheaters.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_in_theaters, container, false); ButterKnife.bind(this, view); boolean tabletSize = getResources().getBoolean(R.bool.isTablet); if (tabletSize) { if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } else {/*from w w w . j ava 2 s . com*/ StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } } else { if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } else { StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.VERTICAL); recycler.setLayoutManager(gridLayoutManager); } } mainActivityAdapter = new MainActivityAdapter(getActivity(), null); recycler.setAdapter(mainActivityAdapter); mainActivityAdapter.setClickListener(this); return view; }
From source file:com.hippo.conductor.dialog.DialogContentView.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); final int widthMode = MeasureSpec.getMode(widthMeasureSpec); final boolean isPortrait = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; final TypedValue tv = isPortrait ? minWidthMinor : minWidthMajor; boolean measure = false; if (widthMode == MeasureSpec.AT_MOST && tv.type != TypedValue.TYPE_NULL) { final int min; final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); if (tv.type == TypedValue.TYPE_DIMENSION) { min = (int) tv.getDimension(metrics); } else if (tv.type == TypedValue.TYPE_FRACTION) { min = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels); } else {/*from w ww.j a v a2s .c o m*/ min = 0; } if (getMeasuredWidth() < min) { widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, MeasureSpec.EXACTLY); measure = true; } } if (measure) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.CustomAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Log.d(LOG_TAG, "onCreateViewHolder: "); View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_movie, parent, false); ImageView posterImageView = (ImageView) view.findViewById(R.id.poster); boolean isTablet = Utility.isTabletPreference(mContext); if (mMinWidth == 0) { if (isTablet && mOrientation == Configuration.ORIENTATION_PORTRAIT) { mMinHeight = mRecyclerView.getHeight(); mMinWidth = (int) (((double) mMinHeight / 278) * 185); } else {//from ww w . j av a 2s. c o m mMinWidth = mRecyclerView.getWidth() / (mOrientation == Configuration.ORIENTATION_LANDSCAPE || isTablet ? 3 : 2); mMinHeight = (int) (((double) mMinWidth / 185) * 278); } } posterImageView.setMinimumWidth(mMinWidth); posterImageView.setMinimumHeight(mMinHeight); return new ViewHolder(view); }
From source file:org.iisgcp.waterwalk.activity.PictureActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); View view = getLayoutInflater().inflate(R.layout.activity_picture, null); setContentView(view);//from w w w . j av a 2 s.c om view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); // check to see if we were called by clicking on a link if (getIntent().getData() != null) { Uri data = getIntent().getData(); int resId = Integer.valueOf(data.getPath().replace("/", "")); TypedArray historicalPhotos = getResources().obtainTypedArray(R.array.historical_photos); mImageId = historicalPhotos.getResourceId(resId, -1); historicalPhotos.recycle(); } // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageId, options); int outWidth = options.outWidth; int outHeight = options.outHeight; int maxWidth; int targetWidth; int targetHeight; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { maxWidth = getResources().getDisplayMetrics().widthPixels; } else { maxWidth = getResources().getDisplayMetrics().heightPixels; } if (outWidth < maxWidth) { targetWidth = maxWidth; int scale = maxWidth / outWidth; targetHeight = outHeight * scale; } else { targetWidth = maxWidth; int scale = outWidth / maxWidth; targetHeight = outHeight * scale; } mImageView = (ImageView) findViewById(R.id.picture); ImageCacheParams cacheParams = new ImageCacheParams(this, IMAGE_CACHE_DIR); cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of app memory // The ImageFetcher takes care of loading images into our ImageView children asynchronously mImageFetcher = new ImageFetcher(this, targetWidth, targetHeight); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); }
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
public void setOrientationPadding(View v) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { v.setPadding(toPixels(55), toPixels(0), toPixels(55), toPixels(0)); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { v.setPadding(toPixels(5), toPixels(0), toPixels(5), toPixels(0)); }//w w w. j ava 2s . c o m }
From source file:com.inovex.zabbixmobile.activities.GraphFullscreenActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { ZaxPreferences prefs = ZaxPreferences.getInstance(getApplicationContext()); if (prefs.isDarkTheme()) setTheme(R.style.AppThemeDark);/* ww w . ja va2 s . c o m*/ else setTheme(R.style.AppTheme); requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) return; bindService(); mItemId = getIntent().getLongExtra("itemid", -1); mGraphId = getIntent().getLongExtra("graphid", -1); if (mItemId == -1 && mGraphId == -1) { finish(); return; } mLayout = new LinearLayout(this); setContentView(mLayout); }
From source file:com.money.manager.ex.reports.IncomeVsExpensesAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView txtYear = (TextView) view.findViewById(R.id.textViewYear); TextView txtMonth = (TextView) view.findViewById(R.id.textViewMonth); TextView txtIncome = (TextView) view.findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) view.findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) view.findViewById(R.id.textViewDifference); // take data// ww w .j a v a 2 s . c o m int year, month; year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR)); month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month)); Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, 1); double income = 0, expenses = 0; expenses = cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)); income = cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income)); // attach data txtYear.setText(Integer.toString(year)); String formatMonth = context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "MMM" : "MMMM"; if (month != IncomeVsExpensesActivity.SUBTOTAL_MONTH) { txtMonth.setText(new SimpleDateFormat(formatMonth).format(calendar.getTime())); } else { txtMonth.setText(null); } CurrencyService currencyService = new CurrencyService(mContext); txtIncome.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income))); txtExpenses.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(Math.abs(expenses)))); txtDifference.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income - Math.abs(expenses)))); UIHelper uiHelper = new UIHelper(context); if (income - Math.abs(expenses) < 0) { txtDifference.setTextColor( context.getResources().getColor(uiHelper.resolveAttribute(R.attr.holo_red_color_theme))); } else { txtDifference.setTextColor( context.getResources().getColor(uiHelper.resolveAttribute(R.attr.holo_green_color_theme))); } //view.setBackgroundColor(core.resolveColorAttribute(cursor.getPosition() % 2 == 1 ? R.attr.row_dark_theme : R.attr.row_light_theme)); // check if subtotal int typefaceStyle = month == IncomeVsExpensesActivity.SUBTOTAL_MONTH ? Typeface.BOLD : Typeface.NORMAL; txtDifference.setTypeface(null, typefaceStyle); txtExpenses.setTypeface(null, typefaceStyle); txtIncome.setTypeface(null, typefaceStyle); txtMonth.setTypeface(null, typefaceStyle); txtYear.setTypeface(null, typefaceStyle); }
From source file:org.jorge.lolin1.ui.activities.ChampionDetailFragmentActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); ImageView x;// w ww. j av a 2s. c om x = ((ImageView) findViewById(R.id.background)); if (x != null) x.setImageResource(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT ? R.drawable.champion_background_portrait : R.drawable.champion_background_landscape); }