issue #3996 solved (#3999)

This commit is contained in:
Harsh Maheshwari 2020-12-22 23:52:40 +05:30 committed by GitHub
parent b2823514ed
commit 1ccb3578e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.MergeAdapter;
@ -154,8 +155,10 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
}
});
scrollButton.setOnClickListener(view -> scrollToUserRank());
return rootView;
}
@ -176,15 +179,13 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
* 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) {
int currPosition = ((LinearLayoutManager) leaderboardListRecyclerView.getLayoutManager())
.findFirstCompletelyVisibleItemPosition();
// if you are below your rank, scroll to userRank
if (currPosition > userRank) {
leaderboardListRecyclerView.smoothScrollToPosition(userRank);
if(userRank==0){
Toast.makeText(getContext(),R.string.no_achievements_yet,Toast.LENGTH_SHORT).show();
}else {
if (Objects.requireNonNull(leaderboardListRecyclerView.getAdapter()).getItemCount()
> userRank + 1) {
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
}
} else {
if (viewModel != null) {
viewModel.refresh(duration, category, userRank + 1, 0);
@ -194,6 +195,8 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
}
}
}
/**
* Set the spinners for the leaderboard filters
*/