Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix maxscale #515

Merged
merged 4 commits into from
Jun 30, 2017
Merged

Fix maxscale #515

merged 4 commits into from
Jun 30, 2017

Conversation

yangshiliang
Copy link
Contributor

@yangshiliang yangshiliang commented Jun 1, 2017

First, revert back to old logic for layout change listener. old logic
It should fix #452 and #493.
Because when we are trying to set an initial scale by setScale, even if we are posting a runnable, onLayoutChange will be triggered after setScale. Inside onLayoutChange, updateBaseMatrix will reset the mSuppMatrix. Then setScale won't work for the initial setScale.

Second, add public methods getSuppMatrix and setSuppMatrix to save and restore scale and visible area, which should fix #509.

Third, sometimes the user can zoom the image larger than the max scale, which happens when we move the two fingers close first and then far away with a fling. We should make the image zoom back to the max scale.

Last, if we force the image to zoom back to max scale, with the above gesture, sometimes it causes the boundary issue. Please see the gif. So we should do checkMatrixBounds for the fling.
demo_photoview

@yangshiliang
Copy link
Contributor Author

yangshiliang commented Jun 1, 2017

I used the following code to save and restore the state.

/// To save:
Matrix matrix = new Matrix();
float[] matrixValues = new float[9];
mPhotoView.getSuppMatrix(matrix);
matrix.getValues(matrixValues);
outState.putFloatArray(mKeySuppMatrixValues, matrixValues);
/// To restore:
float[] values = savedInstanceState.getFloatArray(mKeySuppMatrixValues);
mInitialSuppMatrix = new Matrix();
mInitialSuppMatrix.setValues(values);
mPhotoView.post(new Runnable() {
    @Override
    public void run() {
        mPhotoView.setSuppMatrix(mInitialSuppMatrix);
    }
});

@Jawnnypoo
Copy link
Contributor

Can you rebase this?

@yangshiliang
Copy link
Contributor Author

Done. Please review.

@Jawnnypoo Jawnnypoo merged commit 8b1344a into Baseflow:master Jun 30, 2017
@Jawnnypoo
Copy link
Contributor

Thanks

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

Successfully merging this pull request may close these issues.

Mantain scale and visible area setScale not functioning when animate == false unless after long delay
2 participants