diff options
author | Jay Shrauner <shrauner@google.com> | 2014-03-04 05:19:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-04 05:19:50 +0000 |
commit | 550241c85227b8d0228d0e99d979646759983393 (patch) | |
tree | 62d1ee70392a5e0af19602b1bd0a6ceca8dd8806 | |
parent | 19a0255d3a8e274c5ffbb4a8dc29920bf9a2e6be (diff) | |
parent | de047f43f7b113f256e573fe586b86a18ebd6d80 (diff) | |
download | android_packages_apps_Contacts-550241c85227b8d0228d0e99d979646759983393.tar.gz android_packages_apps_Contacts-550241c85227b8d0228d0e99d979646759983393.tar.bz2 android_packages_apps_Contacts-550241c85227b8d0228d0e99d979646759983393.zip |
Merge "Fix crash in getPhotoPickSize" into klp-dev
-rw-r--r-- | src/com/android/contacts/activities/AttachPhotoActivity.java | 5 | ||||
-rw-r--r-- | src/com/android/contacts/detail/PhotoSelectionHandler.java | 23 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/com/android/contacts/activities/AttachPhotoActivity.java b/src/com/android/contacts/activities/AttachPhotoActivity.java index 6a55c302e..f70bc7efa 100644 --- a/src/com/android/contacts/activities/AttachPhotoActivity.java +++ b/src/com/android/contacts/activities/AttachPhotoActivity.java @@ -101,8 +101,9 @@ public class AttachPhotoActivity extends ContactsActivity { new String[]{DisplayPhoto.DISPLAY_MAX_DIM}, null, null, null); if (c != null) { try { - c.moveToFirst(); - mPhotoDim = c.getInt(0); + if (c.moveToFirst()) { + mPhotoDim = c.getInt(0); + } } finally { c.close(); } diff --git a/src/com/android/contacts/detail/PhotoSelectionHandler.java b/src/com/android/contacts/detail/PhotoSelectionHandler.java index 52a292b88..d2363de08 100644 --- a/src/com/android/contacts/detail/PhotoSelectionHandler.java +++ b/src/com/android/contacts/detail/PhotoSelectionHandler.java @@ -59,6 +59,11 @@ public abstract class PhotoSelectionHandler implements OnClickListener { private static final int REQUEST_CODE_PHOTO_PICKED_WITH_DATA = 1002; private static final int REQUEST_CROP_PHOTO = 1003; + // Height and width (in pixels) to request for the photo - queried from the provider. + private static int mPhotoDim; + // Default photo dimension to use if unable to query the provider. + private static final int mDefaultPhotoDim = 720; + protected final Context mContext; private final View mPhotoView; private final int mPhotoMode; @@ -263,15 +268,23 @@ public abstract class PhotoSelectionHandler implements OnClickListener { } private int getPhotoPickSize() { + if (mPhotoDim != 0) { + return mPhotoDim; + } + // Note that this URI is safe to call on the UI thread. Cursor c = mContext.getContentResolver().query(DisplayPhoto.CONTENT_MAX_DIMENSIONS_URI, new String[]{DisplayPhoto.DISPLAY_MAX_DIM}, null, null, null); - try { - c.moveToFirst(); - return c.getInt(0); - } finally { - c.close(); + if (c != null) { + try { + if (c.moveToFirst()) { + mPhotoDim = c.getInt(0); + } + } finally { + c.close(); + } } + return mPhotoDim != 0 ? mPhotoDim : mDefaultPhotoDim; } /** |