#3980 Hitting "My Rank" button from a list position below your rank on leaderboard takes you to the person ranked below you (#3990)

* Refactored scrollToUserRank to account for users scrolling from below their rank

* Refactored my change to use a similar method

* Added comments to change

* Removed leftover cruft

* Reverted package updates

* Added tests for the LeaderBoard UI
This commit is contained in:
Rebecca Rothschild 2020-10-28 07:21:58 -07:00 committed by GitHub
parent 39221f5365
commit ee3e52d0c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 100 additions and 1 deletions

View file

@ -173,10 +173,18 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
/**
* Performs Auto Scroll to the User's Rank
* We use userRank+1 to load one extra user and prevent overlapping of my rank button
* If you are viewing the leaderboard below userRank, it scrolls to the user rank at the top
*/
private void scrollToUserRank() {
if (Objects.requireNonNull(leaderboardListRecyclerView.getAdapter()).getItemCount() > userRank + 1) {
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
int currPosition = ((LinearLayoutManager) leaderboardListRecyclerView.getLayoutManager())
.findFirstCompletelyVisibleItemPosition();
// if you are below your rank, scroll to userRank
if (currPosition > userRank) {
leaderboardListRecyclerView.smoothScrollToPosition(userRank);
} else {
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
}
} else {
if (viewModel != null) {
viewModel.refresh(duration, category, userRank + 1, 0);