Skip to content

Commit

Permalink
fix: only long image play the auto scale animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Piasy committed Nov 10, 2016
1 parent a94ad56 commit 586cb4a
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
*/

public class BigImageView extends FrameLayout implements ImageLoader.Callback {
private static final int LONG_IMAGE_SIZE_RATIO = 2;

private final SubsamplingScaleImageView mImageView;

private final ImageLoader mImageLoader;
Expand Down Expand Up @@ -84,21 +86,12 @@ public void onReady() {
}
}

if (!hasZeroValue) {
if ((float) imageHeight / imageWidth > 1.5f) {
// scale at top
mImageView
.animateScaleAndCenter(result, new PointF(imageWidth / 2, 0))
.withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD)
.start();
} else {
// scale at center
mImageView
.animateScaleAndCenter(result,
new PointF(viewWidth / 2, viewHeight / 2))
.withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD)
.start();
}
if (!hasZeroValue && (float) imageHeight / imageWidth > LONG_IMAGE_SIZE_RATIO) {
// scale at top
mImageView
.animateScaleAndCenter(result, new PointF(imageWidth / 2, 0))
.withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD)
.start();
}

// `对结果进行放大裁定,防止计算结果跟双击放大结果过于相近`
Expand Down

0 comments on commit 586cb4a

Please sign in to comment.