List of usage examples for android.app ActionBar show
public abstract void show();
From source file:eu.liveGov.gordexola.urbanplanning.activities.MainActivity.java
@SuppressLint("NewApi") @Override/*from w w w .j av a 2 s . com*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { Process process = Runtime.getRuntime().exec("logcat -c"); } catch (IOException e) { Log.e("MainActivity", "I was unable to clear LogCat"); } _savedInstanceState = savedInstanceState; configureLogbackDirectly(); tracker = EasyTracker.getInstance(this); setContentView(R.layout.activity_main); initialiseTabHost(); initialisePager(); ctx = this; //------ Location Service Start -------------------- Functions.startLocationService(ctx); //------------ Measure kb downloaded ---------------- uid = this.getApplicationInfo().uid; mStartRX = TrafficStats.getUidRxBytes(uid); mStartTX = TrafficStats.getUidTxBytes(uid); //------------ Menu hard or soft key ------------------ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { boolean hasMenuKey = ViewConfiguration.get(ctx).hasPermanentMenuKey(); ActionBar actionBar = getActionBar(); if (!hasMenuKey) { actionBar.show(); } else { actionBar.hide(); } } //------------------ Temperature ----------------------------------- mReceiver_Temperature = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0); if (temperature > 450) { String mes = getString(R.string.tempwarn); int fullstopIndex = mes.indexOf("."); mes = mes.replace("XXXXX", Float.toString((((float) temperature) / 10)) + "\u2103"); String mesA = mes.substring(0, fullstopIndex); Toast.makeText(ctx, mesA, Toast.LENGTH_LONG).show(); String mesB = mes.substring(fullstopIndex + 2); Toast.makeText(ctx, mesB, Toast.LENGTH_LONG).show(); } } }; //--------------- Remove Transparency and Enable ------------------------------- intentFilter = new IntentFilter("android.intent.action.MAIN"); // DataCh mReceiverARFinished = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String ARFINISHED = intent.getStringExtra("ARFINISHED"); Integer ARDATAPLUSVal = intent.getIntExtra("DataPlus", 0); if (ARFINISHED != null) { Log.e("AR Finished", "ok 2"); if (pbarGeneral != null) pbarGeneral.setProgress(90); Message msg = new Message(); msg.arg1 = 2; handlerDialog.sendMessage(msg); } else if (ARDATAPLUSVal != 0) { if (pbarGeneral != null) { if (ARDATAPLUSVal > 90) ARDATAPLUSVal = 90; pbarGeneral.setProgress(ARDATAPLUSVal); } else { if (ARDATAPLUSVal < 15) { Message msg = new Message(); msg.arg1 = 1; handlerDialog.sendMessage(msg); } } } } }; registerReceiver(mReceiverARFinished, intentFilter); //----- Handler for Redrawing Markers from update thread ------------ handlerDialog = new Handler() { public void handleMessage(Message msg) { if (msg.arg1 == 1) { if (progressReceiving == null) { progressReceiving = ProgressDialog.show(ctx, "", "", true); progressReceiving.setContentView(R.layout.dialog_transparent_progress); pbarGeneral = (ProgressBar) progressReceiving.findViewById(R.id.allprogress); } } else { if (progressReceiving != null && progressReceiving.isShowing()) progressReceiving.dismiss(); progressReceiving = null; } super.handleMessage(msg); } }; if (Functions.checkInternetConnection(this) && Functions.hasNetLocationProviderEnabled(this) && Functions.hasGPSLocationProviderEnabled(this)) { // Show progress transparency Message msg = new Message(); msg.arg1 = 1; handlerDialog.sendMessage(msg); } }
From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_item_media_chooser); FrameLayout mSelectedImagesContainerFrame = (FrameLayout) findViewById(R.id.selectedPhotosContainerFrame); if (MediaChooserConstants.MAX_MEDIA_LIMIT == 1) { mSelectedImagesContainerFrame.setVisibility(View.GONE); }//ww w. j a v a 2 s .c o m mSelectedImagesContainer = (LinearLayout) findViewById(R.id.selectedPhotosContainer); mSelectedImageEmptyMessage = (TextView) findViewById(R.id.selectedPhotosEmptyText); mViewPager = (ViewPager) findViewById(R.id.pager); if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { mTabTitles.add(getResources().getString(R.string.image)); setCurrentMode(MediaType.IMAGE); } else { mTabTitles.add(getResources().getString(R.string.video)); setCurrentMode(MediaType.VIDEO); } } else { if (MediaChooserConstants.showImage) { mTabTitles.add(getResources().getString(R.string.image)); } if (MediaChooserConstants.showVideo) { mTabTitles.add(getResources().getString(R.string.video)); } } mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.slidingTabs); mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); //mSlidingTabLayout.setSelectedIndicatorColors(getResources().getColor(android.R.color.white)); mSlidingTabLayout.setDistributeEvenly(true); mSlidingTabLayout.setViewPager(mViewPager); final android.app.ActionBar actionBar = getActionBar(); if (actionBar != null) { materialMenu = new MaterialMenuIcon(this, Color.WHITE); materialMenu.setState(IconState.ARROW); if (mTabTitles.size() > 1) { mSlidingTabLayout.setVisibility(View.VISIBLE); } else { mSlidingTabLayout.setVisibility(View.GONE); } mSlidingTabLayout.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { ActionBar ab = HomeFragmentActivity.this.getActionBar(); ab.show(); if (position == 0) { setCurrentMode(MediaType.IMAGE); } else { setCurrentMode(MediaType.VIDEO); } } }); } mViewPager.setCurrentItem(0); //boolean isFromBucket = (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))); if (getIntent().getParcelableArrayListExtra("selectedImages") != null) { mCurrentSelectedImages = getIntent().getParcelableArrayListExtra("selectedImages"); //mImageSelectedCount = mCurrentSelectedImages.size(); if (mCurrentSelectedImages.size() > 0) { onImageSelectedCount(mCurrentSelectedImages.size()); for (MediaModel selImage : mCurrentSelectedImages) { this.onImageSelected(selImage); } } } if (getIntent().getParcelableArrayListExtra("selectedVideos") != null) { mCurrentSelectedVideos = getIntent().getParcelableArrayListExtra("selectedVideos"); //mImageSelectedCount = mCurrentSelectedImages.size(); if (mCurrentSelectedVideos.size() > 0) { onVideoSelectedCount(mCurrentSelectedVideos.size()); for (MediaModel selVideo : mCurrentSelectedVideos) { this.onVideoSelected(selVideo); } } } }
From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home_media_chooser); FrameLayout mSelectedImagesContainerFrame = (FrameLayout) findViewById(R.id.selectedPhotosContainerFrame); if (MediaChooserConstants.MAX_MEDIA_LIMIT == 1) { mSelectedImagesContainerFrame.setVisibility(View.GONE); }/*from w ww. j a va 2 s . c o m*/ mSelectedImagesContainer = (LinearLayout) findViewById(R.id.selectedPhotosContainer); mSelectedImageEmptyMessage = (TextView) findViewById(R.id.selectedPhotosEmptyText); mViewPager = (ViewPager) findViewById(R.id.pager); if (MediaChooserConstants.showImage) { mTabTitles.add(getResources().getString(R.string.image)); } if (MediaChooserConstants.showVideo) { mTabTitles.add(getResources().getString(R.string.video)); } mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.slidingTabs); mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); //mSlidingTabLayout.setSelectedIndicatorColors(getResources().getColor(android.R.color.white)); mSlidingTabLayout.setDistributeEvenly(true); mSlidingTabLayout.setViewPager(mViewPager); final android.app.ActionBar actionBar = getActionBar(); if (actionBar != null) { materialMenu = new MaterialMenuIcon(this, Color.WHITE); materialMenu.setState(IconState.ARROW); materialMenu = new MaterialMenuIcon(this, Color.WHITE); materialMenu.setState(IconState.ARROW); if (mTabTitles.size() > 1) { } else { mSlidingTabLayout.setVisibility(View.GONE); } mSlidingTabLayout.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { ActionBar ab = BucketHomeFragmentActivity.this.getActionBar(); ab.show(); if (position == 0) { setCurrentMode(MediaType.IMAGE); } else { setCurrentMode(MediaType.VIDEO); } } }); } mViewPager.setCurrentItem(0); if (getIntent().getParcelableArrayListExtra("selectedImages") != null) { mSelectedImages = getIntent().getParcelableArrayListExtra("selectedImages"); for (MediaModel selImage : mSelectedImages) { this.onMediaSelected(selImage); } } if (getIntent().getParcelableArrayListExtra("selectedVideos") != null) { mSelectedVideos = getIntent().getParcelableArrayListExtra("selectedVideos"); for (MediaModel selVideo : mSelectedVideos) { this.onMediaSelected(selVideo); } } }
From source file:com.hellosky.recyclingimageloader.ImageDetailActivity.java
@TargetApi(11) @Override//from ww w . j a va 2 s .c o m public void onCreate(Bundle savedInstanceState) { 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; mImageLoader = new ImageLoader(this); mImageLoader.setImageSize(longest); // 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:com.vbehl.connections.ui.ImageDetailActivity.java
@TargetApi(11) @Override/*w ww . j ava 2s .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() { 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.volley.demo.ImageDetailActivity.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override//from w w 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; 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 mImageLoader = new SimpleImageLoader(this, cacheParams);//, R.drawable.empty_photo); //mImageFetcher.setFadeInImage(false); mImageLoader.setMaxImageSize(longest); // 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:com.dl2974.andbitmap.ui.ImageDetailActivity.java
@TargetApi(11) @Override/*from w w w .j a v a2 s.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.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:com.example.kent_zheng.sdk_displayingbitmaps.displayingbitmaps.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override//from w ww . j av 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(), 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()) { //?! NullPointException final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(true); 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.android.lru.ui.ImageDetailActivity.java
@TargetApi(VERSION_CODES.HONEYCOMB) @Override/*from w w w . ja 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(), 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/*from w w w .j a va2 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); } }