Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature Request: On Image Matrix Changed Listener #89

Open
ghost opened this issue Jul 14, 2016 · 1 comment
Open

Feature Request: On Image Matrix Changed Listener #89

ghost opened this issue Jul 14, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 14, 2016

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.

@HungTDO
Copy link

HungTDO commented Aug 14, 2017

@bfarrelladelphi Thanks

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant