mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
#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:
parent
39221f5365
commit
ee3e52d0c6
2 changed files with 100 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue