ImageViewZoom
ImageViewZoom copied to clipboard
Feature Request: On Image Matrix Changed Listener
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.
@bfarrelladelphi Thanks