List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
From source file:com.android.lru.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override/*from w w w.j a v a2s.c om*/ public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; ImageCache.ImageCacheParams cacheParams = new ImageCache.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, longest); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }
From source file:com.example.android.abhishek.flikr.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override/* ww w . j a v a 2 s.c o m*/ public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; ImageCache.ImageCacheParams cacheParams = new ImageCache.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, longest); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), SplashScreenActivity.imageUrls.size()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }
From source file:ntq.lbs.imagelazyloading.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override//from w ww . ja v a2s. com public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; ImageCache.ImageCacheParams cacheParams = new ImageCache.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, longest); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }
From source file:sample.hawk.com.mybasicappcomponents.data_structure.cache.DisplayingBitmaps.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override// w ww .j a va2s. co m public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; ImageCache.ImageCacheParams cacheParams = new ImageCache.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, longest); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin(64); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }
From source file:com.vector.wemarried.android.utils.bitmapfun.ui.ImageDetailActivity.java
@TargetApi(11) @Override/*from w w w . jav a 2s.c o m*/ public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageIDs.length); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); if (actionBar != null) { // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }
From source file:uz.sag.sagbuyurtmalari.sagbuyurtmalari.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override// ww w .j a va 2s .co m public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; ImageCache.ImageCacheParams cacheParams = new ImageCache.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, longest); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); //@TODO mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }
From source file:org.birthdayadapter.ui.BaseActivity.java
/** * Called when the activity is first created. */// w ww . j a v a2s.c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActivity = this; requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // Load Activity for Android < 4.0 Intent oldActivity = new Intent(mActivity, BaseActivityV8.class); oldActivity.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(oldActivity); finish(); } else { // Load new design with tabs mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_main)), BaseFragment.class, null); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_preferences)), PreferencesFragment.class, null); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_accounts)), AccountListFragment.class, null); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_help)), HelpFragment.class, null); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_about)), AboutFragment.class, null); // default is disabled: mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE); mySharedPreferenceChangeListener = new MySharedPreferenceChangeListener(mActivity, mBackgroundStatusHandler); /* * Show workaround dialog for Android bug http://code.google.com/p/android/issues/detail?id=34880 * Bug exists on Android 4.1 (SDK 16) and on some phones like Galaxy S4 */ if (BuildConfig.GOOGLE_PLAY_VERSION && PreferencesHelper.getShowWorkaroundDialog(mActivity) && !isPackageInstalled("org.birthdayadapter.jb.workaround")) { if ((Build.VERSION.SDK_INT == 16) || Build.DEVICE.toUpperCase().startsWith("GT-I9000") || Build.DEVICE.toUpperCase().startsWith("GT-I9500")) { InstallWorkaroundDialogFragment dialog = InstallWorkaroundDialogFragment.newInstance(); dialog.show(getFragmentManager(), "workaroundDialog"); } } } }
From source file:com.shafiq.mytwittle.view.ProfileActivity.java
boolean configureActionBarView() { if (mScreenName != null) { ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); int layout = R.layout.profile_title_thin; /*//from www . j av a 2 s . c om * // TODO: This is messy, and likely won't work for large screen * devices. Need to come up with a better solution int layout; if * (getResources().getConfiguration().orientation == * Configuration.ORIENTATION_LANDSCAPE) { layout= * R.layout.profile_title_thin; } else { layout = * R.layout.profile_title; } */ View profileTitleView = inflator.inflate(layout, null); ((TextView) profileTitleView.findViewById(R.id.screenname)).setText("@" + mScreenName); TextView fullNameTextView = (TextView) profileTitleView.findViewById(R.id.fullname); if (fullNameTextView != null && mUser != null) { fullNameTextView.setText(mUser.getName()); } ImageView verifiedImage = (ImageView) profileTitleView.findViewById(R.id.verifiedImage); verifiedImage.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(profileTitleView); } return true; }
From source file:fr.cph.chicago.fragment.drawer.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * /* w w w. j ava 2 s . c om*/ * @param fragmentId * The android:id of this fragment in its activity's layout. * @param drawerLayout * The DrawerLayout containing this fragment's UI. */ public final void setUp(final int fragmentId, final DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } if (mPendingRunnable != null) { Handler mHandler = new Handler(); mHandler.post(mPendingRunnable); mPendingRunnable = null; } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } if (!mUserLearnedDrawer) { // The user manually opened the drawer; store this flag to prevent auto-showing // the navigation drawer automatically in the future. mUserLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:ginger.connexus.activity.ImageDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode();/* www . ja v a 2 s . co m*/ } super.onCreate(savedInstanceState); setContentView(R.layout.pager_image_detail); // Fetch screen height and width, to use as our max size when loading // images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our // images. As the image scaling ensures the image is larger than this, // we should be left with a resolution that is appropriate for both // portrait and landscape. For best image quality we shouldn't divide by // 2, but this will use more memory and require a larger memory cache. final int longest = (height > width ? height : width) / 2; ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR); // Set memory cache to 25% of app memory cacheParams.setMemCacheSizePercent(0.25f); // The ImageFetcher takes care of loading images into our ImageView // children asynchronously mImageFetcher = new ImageFetcher(this, longest); mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter final List<String> imageUrls = Arrays.asList(getIntent().getStringArrayExtra(EXTRA_IMAGE_URLS)); mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), imageUrls); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Enable some additional newer visibility and ActionBar features to // create a more immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }