Skip to content

Commit

Permalink
Add null checks to onAnimationUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Viven committed Jun 7, 2017
1 parent dc5246b commit 4321062
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions library/src/main/java/com/viven/imagezoom/ImageZoomHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,23 @@ public void run() {
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedFraction = valueAnimator.getAnimatedFraction();
if (animatedFraction < 1) {
zoomableView.setScaleX(((scaleXEnd - scaleXStart) * animatedFraction) +
scaleXStart);
zoomableView.setScaleY(((scaleYEnd - scaleYStart) * animatedFraction) +
scaleYStart);

updateZoomableViewMargins(
((leftMarginEnd - leftMarginStart) * animatedFraction) +
leftMarginStart,
((topMarginEnd - topMarginStart) * animatedFraction) +
topMarginStart);

darkView.setAlpha(((alphaEnd - alphaStart) * animatedFraction) +
alphaStart);
if (zoomableView != null) {
zoomableView.setScaleX(((scaleXEnd - scaleXStart) *
animatedFraction) + scaleXStart);
zoomableView.setScaleY(((scaleYEnd - scaleYStart) *
animatedFraction) + scaleYStart);

updateZoomableViewMargins(
((leftMarginEnd - leftMarginStart) *
animatedFraction) + leftMarginStart,
((topMarginEnd - topMarginStart) *
animatedFraction) + topMarginStart);
}

if (darkView != null) {
darkView.setAlpha(((alphaEnd - alphaStart) * animatedFraction) +
alphaStart);
}
} else {
dismissDialogAndViews();
}
Expand Down

0 comments on commit 4321062

Please sign in to comment.