mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
parent
b2823514ed
commit
1ccb3578e8
1 changed files with 17 additions and 14 deletions
|
|
@ -16,6 +16,7 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.MergeAdapter;
|
import androidx.recyclerview.widget.MergeAdapter;
|
||||||
|
|
@ -154,7 +155,9 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scrollButton.setOnClickListener(view -> scrollToUserRank());
|
|
||||||
|
scrollButton.setOnClickListener(view -> scrollToUserRank());
|
||||||
|
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
@ -176,22 +179,22 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
* If you are viewing the leaderboard below userRank, it scrolls to the user rank at the top
|
* If you are viewing the leaderboard below userRank, it scrolls to the user rank at the top
|
||||||
*/
|
*/
|
||||||
private void scrollToUserRank() {
|
private void scrollToUserRank() {
|
||||||
if (Objects.requireNonNull(leaderboardListRecyclerView.getAdapter()).getItemCount() > userRank + 1) {
|
|
||||||
int currPosition = ((LinearLayoutManager) leaderboardListRecyclerView.getLayoutManager())
|
if(userRank==0){
|
||||||
.findFirstCompletelyVisibleItemPosition();
|
Toast.makeText(getContext(),R.string.no_achievements_yet,Toast.LENGTH_SHORT).show();
|
||||||
// if you are below your rank, scroll to userRank
|
}else {
|
||||||
if (currPosition > userRank) {
|
if (Objects.requireNonNull(leaderboardListRecyclerView.getAdapter()).getItemCount()
|
||||||
leaderboardListRecyclerView.smoothScrollToPosition(userRank);
|
> userRank + 1) {
|
||||||
} else {
|
|
||||||
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
|
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
|
||||||
}
|
} else {
|
||||||
} else {
|
if (viewModel != null) {
|
||||||
if (viewModel != null) {
|
viewModel.refresh(duration, category, userRank + 1, 0);
|
||||||
viewModel.refresh(duration, category, userRank + 1, 0);
|
setLeaderboard(duration, category, userRank + 1, 0);
|
||||||
setLeaderboard(duration, category, userRank + 1, 0);
|
scrollToRank = true;
|
||||||
scrollToRank = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue