diff --git a/library/src/main/java/com/viven/imagezoom/ImageZoomHelper.java b/library/src/main/java/com/viven/imagezoom/ImageZoomHelper.java index 1e467cd..08d0e6d 100644 --- a/library/src/main/java/com/viven/imagezoom/ImageZoomHelper.java +++ b/library/src/main/java/com/viven/imagezoom/ImageZoomHelper.java @@ -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(); }