客户需求 双击放大倍数2.5f,延伸放大0.5f
W:\m08735-git\alps\packages\apps\Gallery2\src\com\android\gallery3d\ui\PhotoView.java
双击放大 为2.5f
@Override
public boolean onDoubleTap(float x, float y) {
if (mIgnoreScalingGesture) return true;
if (mIgnoreSwipingGesture) return true;
if (mPictures.get(0).isCamera()) return false;
PositionController controller = mPositionController;
float scale = controller.getImageScale();
// onDoubleTap happened on the second ACTION_DOWN.
// We need to ignore the next UP event.
mIgnoreUpEvent = true;
//chch
// if (scale <= .75f || controller.isAtMinimalScale()) {//chch
if (controller.isAtMinimalScale()) {
/// M: [BUG.MODIFY] A black area show at the right side of picture.@{
/* controller.zoomIn(x, y, Math.max(1.0f, scale * 1.5f)); */
//chch
controller.zoomIn(x, y, scale * 2.5f);//chch
/// @}
} else {
controller.resetToFullView();
}
return true;
}
这个放大只能修改截屏的放大倍率 拍照图片放大比率是原图的倍数 所以 还要修改
W:\m08735-git\alps\packages\apps\Gallery2\src\com\android\gallery3d\ui\PositionController.java
private static final float SCALE_LIMIT = 3f;//4f
private float getMaximalScale(Box b) {
if (mFilmMode) return getMinimalScale(b);
if (mConstrained && !mConstrainedFrame.isEmpty()) return getMinimalScale(b);
return b.mCurrentScale*3.0f;//roco chch
}
双击放大倍数2.5f 最大伸缩倍数为3f 所以双击放大之后 还能延伸放大0.5f
在延伸放大时候 手势停止 会恢复 苹果图库不会 在延伸放大方法 中加入一个判断
private void startExtraScalingIfNeeded() {
//if (!mCancelExtraScalingPending){
if (!mCancelExtraScalingPending&&mIgnoreUpEvent==true) {//roco chch
mHandler.sendEmptyMessageDelayed(
MSG_CANCEL_EXTRA_SCALING, 700);
mPositionController.setExtraScalingRange(true);
mCancelExtraScalingPending = true;
}
}