List of usage examples for android.app ActionBar show
public abstract void show();
From source file:com.af.synapse.MainActivity.java
@SuppressWarnings("ConstantConditions") private void continueCreate() { View v = LayoutInflater.from(this).inflate(R.layout.activity_main, null); mViewPager = (ViewPager) v.findViewById(R.id.mainPager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPagerPageChangeListener()); mDrawerList = (ListView) v.findViewById(R.id.left_drawer); String[] section_titles = new String[Utils.configSections.size()]; for (int i = 0; i < Utils.configSections.size(); i++) section_titles[i] = Utils.localise(((JSONObject) Utils.configSections.get(i)).get("name")); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_item, section_titles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerList.setItemChecked(0, true); mDrawerLayout = (DrawerLayout) v.findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);//from www.ja v a 2 s.c om mDrawerLayout.setDrawerListener(mDrawerToggle); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); mDrawerToggle.syncState(); ActionValueUpdater.refreshButtons(true); for (TabSectionFragment f : fragments) f.onElementsMainStart(); setContentView(v); actionBar.show(); Utils.appStarted = true; setPaddingDimensions(); L.i("Interface creation finished in " + (System.nanoTime() - startTime) + "ns"); if (Utils.appStarted) this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); if (!BootService.getBootFlag() && !BootService.getBootFlagPending()) { new AlertDialog.Builder(this).setTitle(R.string.popup_failed_boot_title) .setMessage(R.string.popup_failed_boot_message).setCancelable(true) .setPositiveButton(R.string.popup_failed_boot_ack, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } }
From source file:com.simplelife.seeds.android.utils.gridview.gridviewui.ImageDetailActivity.java
@TargetApi(11) @Override// w w w .ja v a 2 s .co m public void onCreate(Bundle savedInstanceState) { /* if (BuildConfig.DEBUG) { Utils.enableStrictMode(); }*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_seeds_gridview_detailpager); // 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, SeedsDefinitions.SEEDS_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, "DETAILTAG"); mImageFetcher.setImageFadeIn(false); // Set up ViewPager and backing adapter //mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length); mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.getSeedsEntity().getPicLinks().size()); 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 if (null != actionBar) { 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.kegbot.app.HomeActivity.java
@Override protected void onStart() { super.onStart(); mCore = KegbotCore.getInstance(this); mConfig = mCore.getConfiguration();/*from w ww. j av a2 s .c o m*/ maybeShowTapWarnings(); //for dummy pour status final Pair<String, String> qty = Units.localizeWithoutScaling(mCore.getConfiguration(), 0.0); mPourVolumeBadge.setBadgeValue(qty.first); mPourVolumeBadge.setBadgeCaption("Current " + Units.capitalizeUnits(qty.second) + " Poured"); mImageView0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final ActionBar actionBar = getActionBar(); if (actionBar.isShowing()) { actionBar.hide(); mConfig.setShowActionBar(false); } else { actionBar.show(); mConfig.setShowActionBar(true); } } }); //for start button final Context thisContext = this; mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mConfig.useAccounts()) { final Intent intent = KegtabCommon.getAuthDrinkerActivityIntent(thisContext); startActivityForResult(intent, REQUEST_AUTHENTICATE); } else { mCore.getFlowManager().activateUserAmbiguousTap(""); } } }); mNewDrinkerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = KegtabCommon.getCreateDrinkerActivityIntent(thisContext); startActivityForResult(intent, REQUEST_CREATE_DRINKER); } }); mTapStatusPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { //for progress bar if (mTaps.size() > 0) { final KegTap tap = mTaps.get(position); if (tap.hasCurrentKeg()) { final Models.Keg keg = tap.getCurrentKeg(); double remainml = keg.getRemainingVolumeMl(); double totalml = keg.getFullVolumeMl(); double percent = (remainml) / (totalml) * 100; final ProgressBar mTapProgress = (ProgressBar) findViewById(R.id.tapProgress); mTapProgress.setMax((int) totalml); mTapProgress.setProgress((int) remainml); final TextView mTapPercentage = (TextView) findViewById(R.id.tapPercentage); mTapPercentage.setText(String.format("%.2f", percent) + "%"); } } //for backgrounds switch (position) { case 0: mImageView0.setImageResource(R.drawable.e1); mImageView1.setBackgroundResource(R.drawable.e2); break; case 1: mImageView0.setImageResource(R.drawable.a1); mImageView1.setBackgroundResource(R.drawable.a2); break; case 2: mImageView0.setImageResource(R.drawable.b1); mImageView1.setBackgroundResource(R.drawable.b2); break; case 3: mImageView0.setImageResource(R.drawable.c1); mImageView1.setBackgroundResource(R.drawable.c2); break; case 4: mImageView0.setImageResource(R.drawable.d1); mImageView1.setBackgroundResource(R.drawable.d2); break; default: mImageView0.setImageResource(R.drawable.e1); mImageView1.setBackgroundResource(R.drawable.e2); break; } } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.dhl.android.bitmapfun.ui.ImageDetailActivity.java
@Override 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; final int longest = height > width ? height : width; // The ImageWorker takes care of loading images into our ImageView children asynchronously mImageWorker = new ImageFetcher(this, longest); mImageWorker.setAdapter(Images.imageWorkerUrlsAdapter); mImageWorker.setImageCache(ImageCache.findOrCreateCache(this, IMAGE_CACHE_DIR)); mImageWorker.setImageFadeIn(false);//from w w w . j a v a 2 s .com // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mImageWorker.getAdapter().getSize()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); // 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.hasActionBar()) { final ActionBar actionBar = getActionBar(); // Enable "up" navigation on ActionBar icon and hide title text actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); // 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(); } } }); } // 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:co.touchlab.thumbcache.ui.ImageDetailActivity.java
@SuppressLint("NewApi") @Override/*from www . j av a2 s. com*/ 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; final int longest = height > width ? height : width; // The ImageWorker takes care of loading images into our ImageView children asynchronously mImageWorker = new ImageFetcher(this, longest); mImageWorker.setAdapter(Images.imageWorkerUrlsAdapter); mImageWorker.setImageCache(ImageCache.findOrCreateCache(this, IMAGE_CACHE_DIR)); mImageWorker.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mImageWorker.getAdapter().getSize()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); // 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.hasActionBar()) { final ActionBar actionBar = getActionBar(); // Enable "up" navigation on ActionBar icon and hide title text actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); // 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(); } } }); } // 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.mbpro.tweebook.facebook.images.FacebookImageDetailActivity.java
@SuppressLint("NewApi") @Override/*from w w w.j a va 2s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.facebook_album_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; final int longest = height > width ? height : width; // The ImageWorker takes care of loading images into our ImageView children asynchronously mImageWorker = new ImageFetcher(this, longest); mImageWorker.setAdapter(FaceBookAlbumImages.imageWorkerUrlsAdapter); mImageWorker.setImageCache(ImageCache.findOrCreateCache(this, IMAGE_CACHE_DIR)); mImageWorker.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mImageWorker.getAdapter().getSize()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); // 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.hasActionBar()) { final ActionBar actionBar = getActionBar(); // Enable "up" navigation on ActionBar icon and hide title text actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); // 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(); } } }); } // 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.manning.androidhacks.hack040.ImageDetailActivity.java
@SuppressLint("NewApi") @Override/*from w ww.j a v a2 s. com*/ 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; final int longest = height > width ? height : width; // The ImageWorker takes care of loading images into our ImageView children // asynchronously mImageWorker = new ImageFetcher(this, longest); mImageWorker.setAdapter(Images.imageWorkerUrlsAdapter); mImageWorker.setImageCache(ImageCache.findOrCreateCache(this, IMAGE_CACHE_DIR)); mImageWorker.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mImageWorker.getAdapter().getSize()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); // 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.hasActionBar()) { final ActionBar actionBar = getActionBar(); // Enable "up" navigation on ActionBar icon and hide title text actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); // 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(); } } }); } // 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.opensource.bitmapfun.ui.ImageDetailActivity.java
@Override 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); // The ImageWorker takes care of loading images into our ImageView children asynchronously mImageWorker = new ImageFetcher(this, displaymetrics.widthPixels, displaymetrics.heightPixels); File cachePath = null;//from w w w. j av a2s . c o m if (Utils.hasExternalStorage()) { File appRoot = new File(Environment.getExternalStorageDirectory(), "BitmapFun"); cachePath = new File(appRoot, ".cache"); } // mImageWorker = new ImageResizer(this, displaymetrics.widthPixels, displaymetrics.heightPixels); mImageWorker.setAdapter(Images.imageWorkerUrlsAdapter); mImageWorker.setImageCache(ImageCache.findOrCreateCache(this, cachePath, IMAGE_CACHE_DIR)); mImageWorker.setImageFadeIn(false); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mImageWorker.getAdapter().getSize()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); // 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.hasActionBar()) { final ActionBar actionBar = getActionBar(); // Enable "up" navigation on ActionBar icon and hide title text actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); // 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(); } } }); } // 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.kegbot.app.PourInProgressActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate()"); mCore = KegbotCore.getInstance(this); mFlowManager = mCore.getFlowManager(); mConfig = mCore.getConfiguration();/*from w w w . j a v a2 s. c o m*/ mImageDownloader = mCore.getImageDownloader(); overridePendingTransition(R.anim.image_fade_in, R.anim.image_fade_in); final ActionBar actionBar = getActionBar(); // if (actionBar != null) { // actionBar.hide(); // } if (mConfig.getShowActionBar()) { actionBar.show(); } else { actionBar.hide(); } setContentView(R.layout.pour_in_progress_activity); mTapPager = (ViewPager) findViewById(R.id.tapPager); mPouringTapAdapter = new PouringTapAdapter(getFragmentManager()); mTapPager.setAdapter(mPouringTapAdapter); mTapPager.setOnPageChangeListener(mPageChangeListener); mControlsFlipper = (ViewFlipper) findViewById(R.id.pour_controls_flipper); mClaimPourButton = (Button) findViewById(R.id.claimPourButton); mDrinkerName = (TextView) findViewById(R.id.pourDrinkerName); mDoneButton = (Button) findViewById(R.id.pourEndButton); mDrinkerImage = (ImageView) findViewById(R.id.pourDrinkerImage); mShoutText = (TextView) findViewById(R.id.shoutText); mAddButton = (Button) findViewById(R.id.pourAddButton); mSubtractButton = (Button) findViewById(R.id.pourSubtractButton); //for backgrounds mImageView0 = (ImageView) findViewById(R.id.imageView0); mImageView1 = (LinearLayout) findViewById(R.id.imageView1); mClaimPourButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Flow flow = getCurrentlyFocusedFlow(); if (flow == null || flow.isAuthenticated() || flow.isFinished()) { return; } Log.d(TAG, "Attempting to claim flow id=" + flow.getFlowId()); final Intent intent = KegtabCommon.getAuthDrinkerActivityIntent(PourInProgressActivity.this); intent.putExtra(EXTRA_FLOW_ID, flow.getFlowId()); startActivityForResult(intent, REQUEST_AUTH_DRINKER); overridePendingTransition(R.anim.image_fade_in, R.anim.image_fade_in); } }); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final FlowManager flowManager = mCore.getFlowManager(); final Flow flow = getCurrentlyFocusedFlow(); if (flow == null) { return; } Log.d(TAG, "Done button pressed, ending flow " + flow.getFlowId()); overridePendingTransition(R.anim.image_fade_in, R.anim.image_fade_in); flowManager.endFlow(flow); // If we're finishing a non-dormant flow, and other dormant flows // exist, assume those were started optimistically and finish them // now. if (flow.getVolumeMl() > 0) { final AppConfiguration config = mCore.getConfiguration(); final long minVolume = config.getMinimumVolumeMl(); for (final Flow suspectFlow : flowManager.getAllActiveFlows()) { if (suspectFlow.getVolumeMl() < minVolume) { Log.d(TAG, "Also ending dormant flow: " + suspectFlow.getFlowId()); flowManager.endFlow(suspectFlow); } } } } }); mAddButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final FlowManager flowManager = mCore.getFlowManager(); final Flow flow = getCurrentlyFocusedFlow(); if (flow == null) { return; } flow.addTicks(135); refreshFlows(); } }); mSubtractButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final FlowManager flowManager = mCore.getFlowManager(); final Flow flow = getCurrentlyFocusedFlow(); if (flow == null) { return; } flow.addTicks(-135); refreshFlows(); } }); mShoutText = (EditText) findViewById(R.id.shoutText); mShoutText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { final Flow flow = getCurrentlyFocusedFlow(); if (flow == null) { Log.w(TAG, "Flow went away, dropping shout."); return; } flow.setShout(s.toString()); flow.pokeActivity(); } }); mShowCamera = true; mCameraFragment = (CameraFragment) getFragmentManager().findFragmentById(R.id.camera); mAddButton.setVisibility(View.GONE); mSubtractButton.setVisibility(View.GONE); if (!mConfig.getUseCamera() || !mConfig.getTakePhotosDuringPour()) { mShowCamera = false; getFragmentManager().beginTransaction().hide(mCameraFragment).commit(); mAddButton.setVisibility(View.VISIBLE); mSubtractButton.setVisibility(View.VISIBLE); } refreshFlows(); }
From source file:com.opensource.bitmaploader.test.ui.ImageDetailActivity.java
@Override 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); // The ImageWorker takes care of loading images into our ImageView children asynchronously // mPicWorker = new ImageFetcher(this, displaymetrics.widthPixels, displaymetrics.heightPixels); mPicWorker = new ImageFetcher(this, getResources().getDisplayMetrics().widthPixels); File cachePath = null;/*from w w w . j a v a 2 s.c o m*/ if (Utils.hasExternalStorage()) { File appRoot = new File(Environment.getExternalStorageDirectory(), "BitmapLoader"); cachePath = new File(appRoot, ".cache"); } ImageCache.ImageCacheParams picCacheParams = new ImageCache.ImageCacheParams(cachePath, IMAGE_CACHE_DIR); picCacheParams.memCacheSize = 1024 * 1024 * Utils.getMemoryClass(this) / 3; picCacheParams.diskCacheEnabled = true; mPicWorker.setAdapter(Images.imageWorkerUrlsAdapter); mPicWorker.setImageCache(new ImageCache(this, picCacheParams)); mPicWorker.setImageFadeIn(false); mPicWorker.setLoadingImage(R.drawable.empty_photo); ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(cachePath, THUMB_CACHE_DIR); // ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(cachePath, IMAGE_CACHE_DIR); cacheParams.memCacheSize = 1024 * 1024 * Utils.getMemoryClass(this) / 3; cacheParams.diskCacheEnabled = false; mThumbWorker = new ImageFetcher(this, 150); mThumbWorker.setAdapter(Images.imageWorkerUrlsAdapter); mThumbWorker.setLoadingImage(R.drawable.empty_photo); mThumbWorker.setImageCache(new ImageCache(this, cacheParams)); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mPicWorker.getAdapter().getSize()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); // 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.hasActionBar()) { final ActionBar actionBar = getActionBar(); if (null != actionBar) { // Enable "up" navigation on ActionBar icon and hide title text actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Start low profile mode and hide ActionBar mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); // 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(); } } }); } } // 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); } }