Back to project page bitmapfun.
The source code is released under:
Apache License
If you think the Android project bitmapfun listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2012 The Android Open Source Project */*w ww . ja v a2 s.c om*/ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.bitmapfun.util; import java.util.List; import android.annotation.TargetApi; import android.app.ActionBar; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.NavUtils; import android.support.v4.view.ViewPager; import android.util.DisplayMetrics; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; import android.widget.Toast; import com.example.android.bitampfun.BuildConfig; import com.example.android.bitampfun.R; import com.example.android.bitmapfun.util.ImageFetcher; import com.example.android.bitmapfun.util.Utils; public class ImageDetailActivity extends FragmentActivity implements OnClickListener { public static final String EXTRA_IMAGE = "extra_image"; public static final String EXTRA_IMAGE_SET="extra_image_set"; public static final String DEFAULT_IMAGE_SET="default_iamge_set"; public static final String URLS="urls"; public static final String DEFAULT="default"; private ImagePagerAdapter mAdapter; private ViewPager mPager; public static ImageSet getDefaultImageSet(){ return ImageSetFactory.getImageSet(DEFAULT_IMAGE_SET); } @TargetApi(11) @Override public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode(); } super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Integer.MAX_VALUE -1); 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); // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getDefaultImageSet().getFirst(); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem + getDefaultImageSet().size() * 800); } } @Override public void onResume() { super.onResume(); } @Override protected void onPause() { super.onPause(); } @Override protected void onDestroy() { super.onDestroy(); } /** * The main adapter that backs the ViewPager. A subclass of FragmentStatePagerAdapter as there * could be a large number of items in the ViewPager and we don't want to retain them all in * memory at once but create/destroy them on the fly. */ private class ImagePagerAdapter extends FragmentStatePagerAdapter { private final int mSize; public ImagePagerAdapter(FragmentManager fm, int size) { super(fm); mSize = size; } @Override public int getCount() { return mSize; } @Override public Fragment getItem(int position) { return ImageDetailFragment.newInstance(position); } } /** * Set on the ImageView in the ViewPager children fragments, to enable/disable low profile mode * when the ImageView is touched. */ @TargetApi(11) @Override public void onClick(View v) { final int vis = mPager.getSystemUiVisibility(); if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } else { mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } } }