diff options
author | Brian Attwell <brianattwell@google.com> | 2014-10-27 15:05:09 -0700 |
---|---|---|
committer | Brian Attwell <brianattwell@google.com> | 2014-10-27 15:16:48 -0700 |
commit | 841c333c527c087894c093ec0ad51d331e457625 (patch) | |
tree | d773ee53be9d3d51f952d1b5c43657bd68a88e4d /src/com/android/contacts/widget | |
parent | 1f9f48d413810c01b4daaebfe398a1bb875ea10a (diff) | |
download | Contacts-841c333c527c087894c093ec0ad51d331e457625.tar.gz |
Avoid Resources$NotFoundException
I'm guessing that this bug was being caused by doOnPreDraw()
callbacks occuring after rotation (the monkey links 404, so it
is hard to do more than conjecture)? To fix this: define the
resource for both landscape and profile. To make this more
testable: load quickcontact_landscape_photo_ratio during
contruction instead of inside an asynchronous callback.
Additional cleanup: don't use two different ways to determine
whether we are in landscape mode. This wasn't causing a bug
that we know of.
Bug: 18102632
Change-Id: I1f27d873ca71be28de7a1e59aa628c4696cb4c89
Diffstat (limited to 'src/com/android/contacts/widget')
-rw-r--r-- | src/com/android/contacts/widget/MultiShrinkScroller.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java index dcc3b6117..72dc99659 100644 --- a/src/com/android/contacts/widget/MultiShrinkScroller.java +++ b/src/com/android/contacts/widget/MultiShrinkScroller.java @@ -142,6 +142,7 @@ public class MultiShrinkScroller extends FrameLayout { private final int mMaximumTitleMargin; private final float mToolbarElevation; private final boolean mIsTwoPanel; + private final float mLandscapePhotoRatio; private final int mActionBarSize; // Objects used to perform color filtering on the header. These are stored as fields for @@ -251,6 +252,11 @@ public class MultiShrinkScroller extends FrameLayout { mMaximumTitleMargin = (int) getResources().getDimension( R.dimen.quickcontact_title_initial_margin); + final TypedValue photoRatio = new TypedValue(); + getResources().getValue(R.dimen.quickcontact_landscape_photo_ratio, photoRatio, + /* resolveRefs = */ true); + mLandscapePhotoRatio = photoRatio.getFloat(); + final TypedArray attributeArray = context.obtainStyledAttributes( new int[]{android.R.attr.actionBarSize}); mActionBarSize = attributeArray.getDimensionPixelSize(0, 0); @@ -317,9 +323,7 @@ public class MultiShrinkScroller extends FrameLayout { mIntermediateHeaderHeight = (int) (mMaximumHeaderHeight * INTERMEDIATE_HEADER_HEIGHT_RATIO); } - final boolean isLandscape = getResources().getConfiguration().orientation - == Configuration.ORIENTATION_LANDSCAPE; - mMaximumPortraitHeaderHeight = isLandscape ? getHeight() + mMaximumPortraitHeaderHeight = mIsTwoPanel ? getHeight() : mPhotoViewContainer.getWidth(); setHeaderHeight(getMaximumScrollableHeaderHeight()); mMaximumHeaderTextSize = mLargeTextView.getHeight(); @@ -329,13 +333,10 @@ public class MultiShrinkScroller extends FrameLayout { mIntermediateHeaderHeight = mMaximumHeaderHeight; // Permanently set photo width and height. - final TypedValue photoRatio = new TypedValue(); - getResources().getValue(R.vals.quickcontact_photo_ratio, photoRatio, - /* resolveRefs = */ true); final ViewGroup.LayoutParams photoLayoutParams = mPhotoViewContainer.getLayoutParams(); photoLayoutParams.height = mMaximumHeaderHeight; - photoLayoutParams.width = (int) (mMaximumHeaderHeight * photoRatio.getFloat()); + photoLayoutParams.width = (int) (mMaximumHeaderHeight * mLandscapePhotoRatio); mPhotoViewContainer.setLayoutParams(photoLayoutParams); // Permanently set title width and margin. |