-
Notifications
You must be signed in to change notification settings - Fork 141
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
Add page finishing function when over scrolled to SessionDetailActivity #359
Add page finishing function when over scrolled to SessionDetailActivity #359
Conversation
Cool 🆒 |
Interesting implementation 👀 |
|
||
|
||
@BindingMethods({ | ||
@BindingMethod(type = OverScrollLayout.class, attribute = "onOverScroll", method = "setOverScrollListener") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆒
Sorry to be late review 🙇 |
Thank you for your review!! 😄 |
@Override | ||
public void onStopNestedScroll(View target) { | ||
super.onStopNestedScroll(target); | ||
if (Math.abs(getY()) > overScrollThreshold && overScrollListener != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overScrollListener != null
should be checked first.
Could you please swap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. I'd like to make another PR to fix it.
|
||
private int overScrollThreshold; | ||
|
||
private PointF originalLocation = new PointF(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rect
is better, I think. Then, Rect#getHeight can be used instead of originalHeight.
}) | ||
public class OverScrollLayout extends CoordinatorLayout { | ||
|
||
private static final float OVER_SCROLL_THRESHOLD = 0.20f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is a scale or ratio to calculate threshold?
Can you add any suitable suffix?
@@ -157,6 +157,10 @@ public void onClickFab(@SuppressWarnings("unused") View view) { | |||
} | |||
} | |||
|
|||
public void onOverScroll() { | |||
callback.onOverScroll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check null or not.
} | ||
|
||
private boolean isAppBarExpanded(@NonNull AppBarLayout appBarLayout) { | ||
return appBarLayout.getHeight() == appBarLayout.getBottom(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really work?
View#getHeight() is calculated by View#getBottom() - View#getTop().
Can isAppBarExpanded and View#getTop() == zero be used equally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
View#getHeight() is calculated by View#getBottom() - View#getTop()
I didn't know this, it may be able to replaced with View#getTop() == zero.
Thanks!
Oops, I didn't notice this PR was merged 😇 |
I'd like to make another PR to fix your comment! 👍 |
@jmatsu Thanks for great review 😄 |
Issue
Overview (Required)
Links
Screenshot