diff options
author | Adam Copp <adamcopp@google.com> | 2012-09-21 03:58:14 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-21 03:58:16 -0700 |
commit | e02a7d708f11c3fe213d17a886eebe1131cd77f3 (patch) | |
tree | c8429bacb3cb9db79751a87ce8a1b0a68bd21019 /photoviewer | |
parent | a0646d0f8e6f597bc6da6ae1fc15909eb2afdacf (diff) | |
parent | 5b5c48652859e1ba79542f59f94398f18e76ca30 (diff) | |
download | android_frameworks_ex-e02a7d708f11c3fe213d17a886eebe1131cd77f3.tar.gz android_frameworks_ex-e02a7d708f11c3fe213d17a886eebe1131cd77f3.tar.bz2 android_frameworks_ex-e02a7d708f11c3fe213d17a886eebe1131cd77f3.zip |
Merge "Add option to permenantly show ProgressBar"
Diffstat (limited to 'photoviewer')
5 files changed, 32 insertions, 5 deletions
diff --git a/photoviewer/src/com/android/ex/photo/adapters/BaseCursorPagerAdapter.java b/photoviewer/src/com/android/ex/photo/adapters/BaseCursorPagerAdapter.java index f827690..ae2c92e 100644 --- a/photoviewer/src/com/android/ex/photo/adapters/BaseCursorPagerAdapter.java +++ b/photoviewer/src/com/android/ex/photo/adapters/BaseCursorPagerAdapter.java @@ -43,7 +43,7 @@ public abstract class BaseCursorPagerAdapter extends BaseFragmentPagerAdapter { /** Mapping of row ID to cursor position */ private SparseIntArray mItemPosition; /** Mapping of instantiated object to row ID */ - private HashMap<Object, Integer> mObjectRowMap = new HashMap<Object, Integer>(); + private final HashMap<Object, Integer> mObjectRowMap = new HashMap<Object, Integer>(); /** * Constructor that always enables auto-requery. diff --git a/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java b/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java index d22a378..4536432 100644 --- a/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java +++ b/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java @@ -33,7 +33,8 @@ import com.android.ex.photo.provider.PhotoContract; public class PhotoPagerAdapter extends BaseCursorPagerAdapter { private int mContentUriIndex; private int mThumbnailUriIndex; - private float mMaxScale; + private int mLoadingIndex; + private final float mMaxScale; public PhotoPagerAdapter(Context context, FragmentManager fm, Cursor c, float maxScale) { super(context, fm, c); @@ -44,6 +45,16 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { public Fragment getItem(Context context, Cursor cursor, int position) { final String photoUri = cursor.getString(mContentUriIndex); final String thumbnailUri = cursor.getString(mThumbnailUriIndex); + boolean loading; + if(mLoadingIndex != -1) { + loading = Boolean.valueOf(cursor.getString(mLoadingIndex)); + } else { + loading = false; + } + boolean onlyShowSpinner = false; + if(photoUri == null && loading) { + onlyShowSpinner = true; + } // create new PhotoViewFragment final PhotoViewIntentBuilder builder = @@ -53,7 +64,7 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { .setThumbnailUri(thumbnailUri) .setMaxInitialScale(mMaxScale); - return new PhotoViewFragment(builder.build(), position, this); + return new PhotoViewFragment(builder.build(), position, this, onlyShowSpinner); } @Override @@ -63,9 +74,12 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.CONTENT_URI); mThumbnailUriIndex = newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.THUMBNAIL_URI); + mLoadingIndex = + newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.LOADING_INDICATOR); } else { mContentUriIndex = -1; mThumbnailUriIndex = -1; + mLoadingIndex = -1; } return super.swapCursor(newCursor); diff --git a/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java b/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java index 23171dd..a721b26 100644 --- a/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java +++ b/photoviewer/src/com/android/ex/photo/fragments/PhotoViewFragment.java @@ -106,6 +106,9 @@ public class PhotoViewFragment extends Fragment implements /** Whether or not the fragment should make the photo full-screen */ private boolean mFullScreen; + /** Whether or not this fragment will only show the loading spinner */ + private final boolean mOnlyShowSpinner; + /** Whether or not the progress bar is showing valid information about the progress stated */ private boolean mProgressBarNeeded = true; @@ -113,13 +116,16 @@ public class PhotoViewFragment extends Fragment implements public PhotoViewFragment() { mPosition = -1; + mOnlyShowSpinner = false; mProgressBarNeeded = true; } - public PhotoViewFragment(Intent intent, int position, PhotoPagerAdapter adapter) { + public PhotoViewFragment(Intent intent, int position, PhotoPagerAdapter adapter, + boolean onlyShowSpinner) { mIntent = intent; mPosition = position; mAdapter = adapter; + mOnlyShowSpinner = onlyShowSpinner; mProgressBarNeeded = true; } @@ -246,6 +252,9 @@ public class PhotoViewFragment extends Fragment implements @Override public Loader<Bitmap> onCreateLoader(int id, Bundle args) { + if(mOnlyShowSpinner) { + return null; + } switch (id) { case LOADER_ID_PHOTO: return new PhotoBitmapLoader(getActivity(), mResolvedPhotoUri); diff --git a/photoviewer/src/com/android/ex/photo/provider/PhotoContract.java b/photoviewer/src/com/android/ex/photo/provider/PhotoContract.java index 439b68b..8483620 100644 --- a/photoviewer/src/com/android/ex/photo/provider/PhotoContract.java +++ b/photoviewer/src/com/android/ex/photo/provider/PhotoContract.java @@ -48,6 +48,11 @@ public final class PhotoContract { * This string column is the MIME type. */ public static final String CONTENT_TYPE = "contentType"; + /** + * This boolean column indicates that a loading indicator should display permenantly + * if no image urls are provided. + */ + public static final String LOADING_INDICATOR = "loadingIndicator"; } diff --git a/photoviewer/src/com/android/ex/photo/util/ImageUtils.java b/photoviewer/src/com/android/ex/photo/util/ImageUtils.java index 9c1636b..a9790eb 100644 --- a/photoviewer/src/com/android/ex/photo/util/ImageUtils.java +++ b/photoviewer/src/com/android/ex/photo/util/ImageUtils.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import java.net.URLConnection; /** * Image utilities |