diff options
author | Paul Westbrook <pwestbro@google.com> | 2012-08-29 01:13:28 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-08-29 01:13:28 -0700 |
commit | 9cb4051d02351dfb400f31e5193f55d5c8d22b10 (patch) | |
tree | eef6ae7931926d5caa68b88998666ae5cd9978e0 /photoviewer | |
parent | 364c5e3cc2890aa03ec156e2ba02e8ece7c979a8 (diff) | |
parent | 4689c6f834a99fe8b57f2391bc14d13a3c6645cb (diff) | |
download | android_frameworks_ex-9cb4051d02351dfb400f31e5193f55d5c8d22b10.tar.gz android_frameworks_ex-9cb4051d02351dfb400f31e5193f55d5c8d22b10.tar.bz2 android_frameworks_ex-9cb4051d02351dfb400f31e5193f55d5c8d22b10.zip |
am 4689c6f8: am 162052cc: am 114cef99: Fix crash in email with attachments
* commit '4689c6f834a99fe8b57f2391bc14d13a3c6645cb':
Fix crash in email with attachments
Diffstat (limited to 'photoviewer')
-rw-r--r-- | photoviewer/src/com/android/ex/photo/PhotoViewActivity.java | 66 | ||||
-rw-r--r-- | photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java | 13 |
2 files changed, 38 insertions, 41 deletions
diff --git a/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java b/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java index c15bc1a..b060f28 100644 --- a/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java +++ b/photoviewer/src/com/android/ex/photo/PhotoViewActivity.java @@ -134,7 +134,7 @@ public class PhotoViewActivity extends Activity implements private boolean mRestartLoader; /** Whether or not this activity is paused */ private boolean mIsPaused = true; - private Handler mActionBarHideHandler; + private final Handler mHandler = new Handler(); // TODO Find a better way to do this. We basically want the activity to display the // "loading..." progress until the fragment takes over and shows it's own "loading..." // progress [located in photo_header_view.xml]. We could potentially have all status displayed @@ -198,7 +198,6 @@ public class PhotoViewActivity extends Activity implements R.integer.action_bar_delay_time_in_millis); actionBar.addOnMenuVisibilityListener(this); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); - mActionBarHideHandler = new Handler(); } @Override @@ -308,39 +307,29 @@ public class PhotoViewActivity extends Activity implements } else { mAlbumCount = data.getCount(); - // Cannot do this directly; need to be out of the loader - // TODO(pwestbro): Fix this as this could cause a problem as the cursor may be - // closed before the runnable runs. - new Handler().post(new Runnable() { - @Override - public void run() { - // If the cursor is closed, we can leave, as another runnable will have - // been posted (this means our Cursor is already out-of-date) - if (data.isClosed()) return; - - // We're paused; don't do anything now, we'll get re-invoked - // when the activity becomes active again - if (mIsPaused) { - mRestartLoader = true; - return; - } - mIsEmpty = false; - - // set the selected photo - int itemIndex = mPhotoIndex; - - // Use an index of 0 if the index wasn't specified or couldn't be found - if (itemIndex < 0) { - itemIndex = 0; - } - - mAdapter.swapCursor(data); - notifyCursorListeners(data); - - mViewPager.setCurrentItem(itemIndex, false); - setViewActivated(); - } - }); + // We're paused; don't do anything now, we'll get re-invoked + // when the activity becomes active again + // TODO(pwestbro): This shouldn't be necessary, as the loader manager should + // restart the loader + if (mIsPaused) { + mRestartLoader = true; + return; + } + mIsEmpty = false; + + // set the selected photo + int itemIndex = mPhotoIndex; + + // Use an index of 0 if the index wasn't specified or couldn't be found + if (itemIndex < 0) { + itemIndex = 0; + } + + mAdapter.swapCursor(data); + notifyCursorListeners(data); + + mViewPager.setCurrentItem(itemIndex, false); + setViewActivated(); } } } @@ -355,6 +344,9 @@ public class PhotoViewActivity extends Activity implements @Override public void onLoaderReset(Loader<Cursor> loader) { + // If the loader is reset, remove the reference in the adapter to this cursor + // TODO(pwestbro): reenable this when b/7075236 is fixed + // mAdapter.swapCursor(null); } @Override @@ -433,12 +425,12 @@ public class PhotoViewActivity extends Activity implements } private void postActionBarHideRunnableWithDelay() { - mActionBarHideHandler.postDelayed(mActionBarHideRunnable, + mHandler.postDelayed(mActionBarHideRunnable, mActionBarHideDelayTime); } private void cancelActionBarHideRunnable() { - mActionBarHideHandler.removeCallbacks(mActionBarHideRunnable); + mHandler.removeCallbacks(mActionBarHideRunnable); } private void setLightsOutMode(boolean enabled) { diff --git a/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java b/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java index 3cc387f..bf75ecb 100644 --- a/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java +++ b/photoviewer/src/com/android/ex/photo/adapters/PhotoPagerAdapter.java @@ -55,10 +55,15 @@ public class PhotoPagerAdapter extends BaseCursorPagerAdapter { @Override public Cursor swapCursor(Cursor newCursor) { - mContentUriIndex = - newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.CONTENT_URI); - mThumbnailUriIndex = - newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.THUMBNAIL_URI); + if (newCursor != null) { + mContentUriIndex = + newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.CONTENT_URI); + mThumbnailUriIndex = + newCursor.getColumnIndex(PhotoContract.PhotoViewColumns.THUMBNAIL_URI); + } else { + mContentUriIndex = -1; + mThumbnailUriIndex = -1; + } return super.swapCursor(newCursor); } |