-
Notifications
You must be signed in to change notification settings - Fork 140
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
If today matches the opening date, scroll to that day. #430
base: master
Are you sure you want to change the base?
Conversation
@Override | ||
public void onGlobalLayout() { | ||
binding.recyclerView.getLayoutManager().scrollToPosition(position); | ||
binding.recyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this); |
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.
Is there a better way? 🤔
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, I don't know why OnGlobalLayoutListener
is needed 🙇
Is it enough just to call binding.recyclerView.getLayoutManager().scrollToPosition(position);
?
b7ba24b
to
7887630
Compare
.indexed() | ||
.filter(pair -> todayString.equals(pair.getSecond())) | ||
.findFirst() | ||
.orElse(new IntPair<>(0, "")) |
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.
If there is no match, position 0 is returned.
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.
Is it better to use Stream
? In this case, just for loop seems easy. What do you think?
for (int i = 0; i<= adjustedSessionViewModels.size(); i++) {
SessionViewModel viewModel = adjustedSessionViewModels.get(i);
if (todayString.equals(viewModel.getFormattedDate()) {
return i;
}
return 0;
}
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.
agreeee~
👀 |
Issue
None
Overview (Required)
If today matches the opening date, scroll to that day.
Links
Screenshot