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:org.anothermonitor.ActivityPreferences.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_preferences); mPrefs = getSharedPreferences(getString(R.string.app_name) + "Prefs", MODE_PRIVATE); res = getResources();/*ww w . ja v a 2 s .c om*/ navigationBarHeight = res .getDimensionPixelSize(res.getIdentifier("navigation_bar_height", "dimen", "android")); mLTabs = (LinearLayout) findViewById(R.id.LTabs); if (Build.VERSION.SDK_INT >= 19) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); sSW = res.getConfiguration().smallestScreenWidthDp; int statusBarHeight = res .getDimensionPixelSize(res.getIdentifier("status_bar_height", "dimen", "android")); if (!ViewConfiguration.get(this).hasPermanentMenuKey() && (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || sSW > 560)) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); FrameLayout nb = (FrameLayout) findViewById(R.id.LNavigationBar); nb.setVisibility(View.VISIBLE); ((FrameLayout.LayoutParams) nb.getLayoutParams()).height = navigationBarHeight; } int paddingTop = mLTabs.getPaddingTop(); int paddingBottom = mLTabs.getPaddingBottom(); int paddingLeft = mLTabs.getPaddingLeft(); int paddingRight = mLTabs.getPaddingRight(); mLTabs.setPadding(paddingLeft, paddingTop + statusBarHeight, paddingRight, paddingBottom); } findViewById(R.id.TVTabMain).setActivated(true); findViewById(R.id.TVTabMain).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mVP.setCurrentItem(0); } }); findViewById(R.id.TVTabShowRecord).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mVP.setCurrentItem(1); } }); mVP = (ViewPager) findViewById(R.id.VP); mVP.setAdapter(new MyPreferencesAdapter()); // mVP.setOffscreenPageLimit(2); mVP.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { int currentItem = 0; if (position == 1) currentItem = 2; mLTabs.getChildAt(currentItem).setActivated(true); mLTabs.getChildAt(previousSelected).setActivated(false); previousSelected = currentItem; } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int arg0) { } }); mVP.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mVP.getViewTreeObserver().removeGlobalOnLayoutListener(this); if (currentItem != -1) mVP.setCurrentItem(currentItem, false); } }); if (savedInstanceState != null && !savedInstanceState.isEmpty()) { mB = savedInstanceState; currentItem = savedInstanceState.getInt(C.currentItem); currentItem = savedInstanceState.getInt(C.currentItem); currentItem = savedInstanceState.getInt(C.currentItem); currentItem = savedInstanceState.getInt(C.currentItem); } }
From source file:org.saydroid.tether.usb.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (((Engine) Engine.getInstance()).getConfigurationService().getBoolean(SgsConfigurationEntry.GENERAL_DSO, SgsConfigurationEntry.DEFAULT_GENERAL_DSO)) { setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT); }//from w w w .j a v a 2s . c o m requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); mHandler = new Handler(); setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); if (!Engine.getInstance().isStarted()) { startActivityForResult(new Intent(this, ScreenSplash.class), MainActivity.RC_SPLASH); return; } Bundle bundle = savedInstanceState; if (bundle == null) { Intent intent = getIntent(); bundle = intent == null ? null : intent.getExtras(); } if (bundle != null && bundle.getInt("action", MainActivity.ACTION_NONE) != MainActivity.ACTION_NONE) { handleAction(bundle); } else if (mScreenService != null) { mScreenService.show(ScreenHome.class); } }
From source file:com.example.propertylist.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_project_sales_list); ImageView mImageView = new ImageView(this); DisplayMetrics metrics;//from w ww . ja va 2s . c o m int mScreenWidth; int mScreenHeight; api_key = getResources().getString(R.string.key); metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mScreenWidth = metrics.widthPixels; mScreenHeight = metrics.heightPixels; if (mScreenWidth >= minScreenwidth) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (mScreenWidth >= minLandScreenwidth) { largeScreen = true; } } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { if (mScreenHeight > minLandScreenwidth) { largeScreen = true; } } } else { largeScreen = false; } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.daft_logo_image, options); mImageView.setImageBitmap( // ensure image size is 100 x 100. decodeSampledBitmapFromResource(getResources(), R.id.daft_logo_image, 100, 100)); handler = new Handler() { @Override public void handleMessage(Message msg) { hideProgressDialog(); startListActivity(); } }; }
From source file:by.onliner.news.fragments.tabs.TabBase.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View myFragmentView = inflater.inflate(R.layout.fragment_news_preview, container, false); // Views/*from ww w . j av a 2s.c o m*/ btnLoadContent = (Button) myFragmentView.findViewById(R.id.bt_loadContent); btnLoadContent.setOnClickListener(this); mLinerRepeatGroup = (ViewGroup) myFragmentView.findViewById(R.id.l_group_repeat); mProgressBarStatus = (ProgressBar) myFragmentView.findViewById(R.id.pb_news_list_loading); mProgressBarStatus.setVisibility(View.VISIBLE); mSwipeRefreshLayout = (SwipeRefreshLayout) myFragmentView.findViewById(R.id.swipe_news_preview); mSwipeRefreshLayout.setOnRefreshListener(this); mRecyclerView = (RecyclerView) myFragmentView.findViewById(R.id.lv_news_list); mRecyclerView.setHasFixedSize(true); LinearLayoutManager horizontalLayoutManager; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) horizontalLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); else horizontalLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); mRecyclerView.setLayoutManager(horizontalLayoutManager); mNewsListAdapter = new NewsListAdapter(getContext(), mProjectId, mRecyclerView); mNewsListAdapter.setOnLoadMoreListener(new OnLoadMoreListener() { @Override public void onLoadMore() { mNewsListAdapter.getResource().add(null); mNewsListAdapter.notifyItemInserted(mNewsListAdapter.getResource().size() - 1); loadingNews(true, false); } }); mRecyclerView.setAdapter(mNewsListAdapter); mRecyclerView.setVisibility(View.INVISIBLE); loadingNews(false, false); return myFragmentView; }
From source file:com.example.julia.popularmovies.MovieGridFragment.java
private int getGridColsNumber() { int gridColsNumber = getResources().getInteger(R.integer.grid_number_cols); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { gridColsNumber = getResources().getInteger(R.integer.grid_number_cols_portrait); }//from w w w.j a va 2 s.c om return gridColsNumber; }
From source file:de.hackerspacebremen.StartActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//ww w .j a v a 2s . c om this.state = null; this.changeShown = false; this.mapShown = false; this.newsShown = false; if (this.getIntent() != null && this.getIntent().getAction() != null && this.getIntent().getAction().equals("android.intent.action.VIEW")) { if (this.getIntent().getBooleanExtra("widget", false)) { this.manageFragment(FragmentState.ONLY_STATUS, null); } else { this.manageFragment(FragmentState.CHANGE_SHOWN, null); } } else { if (savedInstanceState != null && savedInstanceState.getString("state") != null) { this.state = FragmentState.parseToState(savedInstanceState.getString("state")); if ((getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && state == FragmentState.CHANGE_SHOWN && savedInstanceState.getString("change_json") != null) || (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && state == FragmentState.CHANGE_SHOWN)) { this.manageFragment(state, savedInstanceState); } // this.manageFragment(FragmentState.parseToState(savedInstanceState.getString("state")),savedInstanceState); } else { this.manageFragment(FragmentState.ONLY_STATUS, savedInstanceState); } } }
From source file:com.nike.plusgps.nikeplusgallery.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dbHelper = new DBHelper(this); // Creates the database dbHelper.deleteAllResponse(); // Clears the JSON response cache dbHelper.deleteAllMedia(); // Clears the JSON images cache // Get memory class of this device, exceeding this amount will throw an // OutOfMemory exception. final int memClass = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); // Use 1/8th of the available memory for this memory cache. final int cacheSize = 1024 * 1024 * memClass / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override//from w ww. jav a 2 s . c o m protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in bytes rather than number of items. return bitmap.getByteCount(); } }; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setContentView(R.layout.activity_main_port); GridView view = (GridView) findViewById(R.id.gridView); flickrFeedList = new ArrayList<FlickrFeed>(); new JSONParser() .execute("http://api.flickr.com/services/feeds/photos_public.gne?tags=nike&format=json"); adapter = new FlickrFeedAdapter(getApplicationContext(), R.layout.single_elem_port, flickrFeedList, dbHelper, mMemoryCache); view.setAdapter(adapter); } else { 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); 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:tech.salroid.filmy.fragment.SearchFragment.java
@Nullable @Override/*from w w w . j a v a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_search, container, false); ButterKnife.bind(this, view); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean nightMode = sp.getBoolean("dark", false); if (nightMode) fragmentRelativeLayout.setBackgroundColor(getActivity().getResources().getColor(R.color.black)); else fragmentRelativeLayout.setBackgroundColor(getActivity().getResources().getColor(R.color.grey)); 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 { 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); } } return view; }
From source file:com.andrew.apollo.ui.fragments.ThemeFragment.java
/** * {@inheritDoc}//from w ww . j av a2 s. co m */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // The View for the fragment's UI final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.grid_base, null); // Initialize the grid mGridView = (GridView) rootView.findViewById(R.id.grid_base); // Release any reference to the recycled Views mGridView.setRecyclerListener(new RecycleHolder()); // Set the new theme mGridView.setOnItemClickListener(this); // Listen for ContextMenus to be created mGridView.setOnCreateContextMenuListener(this); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { // Limit the columns to one in portrait mode mGridView.setNumColumns(1); } else { // And two for landscape mGridView.setNumColumns(2); } return rootView; }
From source file:com.manning.androidhacks.hack014.MainActivity.java
private void setVideoViewPosition() { switch (getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_LANDSCAPE: { mPortraitContent.setVisibility(View.GONE); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); params.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(params); break;/*from www.ja v a2s . c om*/ } case Configuration.ORIENTATION_SQUARE: case Configuration.ORIENTATION_UNDEFINED: case Configuration.ORIENTATION_PORTRAIT: default: { mPortraitContent.setVisibility(View.VISIBLE); int[] locationArray = new int[2]; mPortraitPosition.getLocationOnScreen(locationArray); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mPortraitPosition.getWidth(), mPortraitPosition.getHeight()); params.leftMargin = locationArray[0]; params.topMargin = locationArray[1]; mVideoView.setLayoutParams(params); break; } } }