Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Fixed NullPointerException when there is no HeroView on Android. #5

Merged
merged 2 commits into from
Apr 20, 2016

Conversation

nlutsenko
Copy link
Member

Looks like we were always trying to get/set the height of the assetView in the HeroView, even though we never add it as a subview.
This produced a NullPointerException. Tested with any of the example payloads by removing hero portion of the payload.
Also, as a result - we needed to handle the corner radius case in BodyView (which turns out is handled in ActionsView, but not in BodyView).

@@ -116,15 +116,17 @@ private static int getRoundedCorners(@NonNull CardConfiguration cardConfiguratio
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
LayoutParams params = (LayoutParams) assetView.getLayoutParams();
params.height = LayoutParams.WRAP_CONTENT;
// Params can return null if the assetView is not yet attached to the screen.
if (params != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'd prefer a if (params == null) { return } instead of indenting here, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, doesn't matter much, the important part is that we need to explicitly call into super here.

@facebook-github-bot
Copy link

@nlutsenko updated the pull request.

@facebook-github-bot
Copy link

@nlutsenko updated the pull request.

@nlutsenko nlutsenko merged commit db767b1 into master Apr 20, 2016
@nlutsenko nlutsenko deleted the nlutsenko.android.nohero branch April 20, 2016 02:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants