ImageViewZoom icon indicating copy to clipboard operation
ImageViewZoom copied to clipboard

Feature Request: On Image Matrix Changed Listener

Open ghost opened this issue 7 years ago • 1 comments

I noticed that in ImageViewTouchBase there is a method called onImageMatrixChanged that is called whenever a new matrix is set. Though, this method is empty. Considering it looks like you set the class up to support a listener, why is one not included? It seems simple enough, it could even be taken a step further if the method took two matrices:

public interface OnMatrixChangedListener {
    void onMatrixChanged(Matrix previous, Matrix current);
}

private OnMatrixChangedListener mOnMatrixChangedListener;

public void setImageMatrix(Matrix matrix) {
    Matrix current = new Matrix(this.getImageMatrix);
    boolean needUpdate = false;
    if(matrix == null && !current.isIdentity() || matrix != null && !current.equals(matrix)) {
        needUpdate = true;
    }

    super.setImageMatrix(matrix);
    if(needUpdate) {
        this.onImageMatrixChanged(current, matrix);
    }
}

protected void onMatrixChanged(Matrix previous, Matrix current) {
    if(mOnMatrixChangedListener != null) {
        mOnMatrixChangedListener.onMatrixChanged(previous, current);
    }
}

A version of this is easy enough to do by subclassing and overriding onMatrixChanged() (and/or setImageMatrix()), but I feel it would be worth including in the library.

ghost avatar Jul 14 '16 20:07 ghost

@bfarrelladelphi Thanks

HungTDO avatar Aug 14 '17 15:08 HungTDO