mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixes #3845 (Contributions list starts at the last uploaded pic, not the currently uploading one) (#3962)
* Fixes #3845 * Fixes #3845 *Scroll to the top when a new upload item is added in a contribution list
This commit is contained in:
parent
4571b76b82
commit
f6963c8d47
1 changed files with 10 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
|
@ -134,6 +135,15 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
contributionsListPresenter.setup();
|
||||
contributionsListPresenter.contributionList.observe(this.getViewLifecycleOwner(), adapter::submitList);
|
||||
rvContributionsList.setAdapter(adapter);
|
||||
adapter.registerAdapterDataObserver(new AdapterDataObserver() {
|
||||
@Override
|
||||
public void onItemRangeInserted(int positionStart, int itemCount) {
|
||||
super.onItemRangeInserted(positionStart, itemCount);
|
||||
if (itemCount > 0 && positionStart == 0) {
|
||||
rvContributionsList.scrollToPosition(0);//Newly upload items are always added to the top
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int getSpanCount(final int orientation) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue