PhotoView 缓存Matrix变形到下一张

来源:互联网 发布:c语言数组赋初值 编辑:程序博客网 时间:2024/04/26 07:52

Matrix 可以记录 移位,缩放,旋转等操作

PhotoView 是一款扩展自Android ImageView ,支持通过单点/多点触摸来进行图片缩放的智能控件。
特性:

支持单点/多点触摸,即时缩放图片;
支持平滑滚动;
在滑动父控件下能够运行良好;(例如:ViewPager)
当用户的触点改变是可以触发通知

github 地址 https://github.com/chrisbanes/PhotoView


由于项目需求,需要缓存Matrix变形到下一张图片,只能修改library 代码

Demo里面的PhotoViewAttacher 里面对移位,缩放,旋转都做了操作

但是每次替换图片的时候,都会多次更新重置设置


public void update() {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (mZoomEnabled) {
            // Make sure we using MATRIX Scale Type
            setImageViewScaleTypeMatrix(imageView);

            // Update the base matrix using the current drawable
            updateBaseMatrix(imageView.getDrawable());
        } else {
            // Reset the Matrix...
            resetMatrix();
        }
    }
}


为了减少代码修改,仅仅修改了update方法 

isResetMatrix为 boolean值,初始化为true,下一张变成false

    public void update() {
        ImageView imageView = getImageView();

        if (null != imageView &&  isResetMatrix) {

            setImageViewScaleTypeMatrix(imageView);
            updateBaseMatrix(imageView.getDrawable());
        }
    }

暂时解决了问题,先记录一下

0 0