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

Feature/scrollbars #30

Merged
merged 10 commits into from
Jun 14, 2018
Merged

Feature/scrollbars #30

merged 10 commits into from
Jun 14, 2018

Conversation

markusressel
Copy link
Collaborator

@markusressel markusressel commented Jun 7, 2018

  • implemented scrollbars for both ZoomLayout and ZoomImageView

There is some reordering going on in the xml file, hope you don't mind.

This is a PR for #29

@natario1
Copy link
Owner

natario1 commented Jun 7, 2018

Man thanks! I will take a look as soon as I can, nice work

@markusressel
Copy link
Collaborator Author

Travis is missing the local.properties file which is ignored by git.
Is this "ok"?

@natario1
Copy link
Owner

natario1 commented Jun 7, 2018

Yeah you can ignore that, I will fix it later

Copy link
Owner

@natario1 natario1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments, looking forward to merge this

protected int computeHorizontalScrollExtent() {
Rect localRect = new Rect();
getLocalVisibleRect(localRect);
return localRect.width();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why using this rather than getWidth() and getHeight? It should return the same thing almost always. Also in vertical extent & in ZoomLayout callbacks.

If there is a reason, could you cache this rect in a tempRect field? So we don't create a lot of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think it should also work with getWidth() and getHeight().
I don't have that much experience with custom views so the "localVisibleRect" method looked like a good fit, but I guess it can be slow.

}

onDrawScrollBars(canvas);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this and use setWillNotDraw(false) in the constructor.

@@ -89,12 +90,50 @@ public boolean onTouchEvent(MotionEvent ev) {
public void onUpdate(ZoomEngine helper, Matrix matrix) {
mMatrix.set(matrix);
setImageMatrix(mMatrix);

if (!awakenScrollBars()) {
invalidate();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this call? We should not need to invalidate. setImageMatrix will do it.
Same for ZoomLayout.

Copy link
Collaborator Author

@markusressel markusressel Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation for awakenScrollBars() states:

When the animation is started, this method returns true, 
and false otherwise. If the animation is started, this method 
calls {@link #invalidate()}; in that case 
the caller should not call {@link invalidate()}.

So I added this condition. I guess if setImageMatrix already does it this check is useless.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it's better to simply call awakenScrollBars() and ignore the result.
Also, you need to merge the other PR changes to merge this one. Thanks!

@markusressel
Copy link
Collaborator Author

I removed the if condition, merged master and added xml attributes for demo ZoomImageView.

@natario1
Copy link
Owner

Thanks @markusressel ! I will release a new version today with your changes.

@natario1 natario1 merged commit 5516fbb into natario1:master Jun 14, 2018
@markusressel markusressel deleted the feature/scrollbars branch June 15, 2018 21:29
markusressel added a commit that referenced this pull request Dec 26, 2018
* added xml attributes for both horizontal and vertical scrollbars
added implementations for scrollXXX methods (wip)

* scrollbars do work for symmetric but don't work yet for asymmetric content

* fixed scrollbars for asymmetric content

* added scrollbar xml tag to imageview
removed unnecessary tags

* moved companion methods closer together
removed todo

* fixed scrollbars getting rendered behind content

* review fixes

* review fix

* merge fix
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.

2 participants