File tree 1 file changed +10
-0
lines changed
app/src/main/java/fr/free/nrw/commons/contributions
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 22
22
import androidx .fragment .app .FragmentManager ;
23
23
import androidx .recyclerview .widget .GridLayoutManager ;
24
24
import androidx .recyclerview .widget .RecyclerView ;
25
+ import androidx .recyclerview .widget .RecyclerView .AdapterDataObserver ;
25
26
import butterknife .BindView ;
26
27
import butterknife .ButterKnife ;
27
28
import com .google .android .material .floatingactionbutton .FloatingActionButton ;
@@ -134,6 +135,15 @@ private void initRecyclerView() {
134
135
contributionsListPresenter .setup ();
135
136
contributionsListPresenter .contributionList .observe (this .getViewLifecycleOwner (), adapter ::submitList );
136
137
rvContributionsList .setAdapter (adapter );
138
+ adapter .registerAdapterDataObserver (new AdapterDataObserver () {
139
+ @ Override
140
+ public void onItemRangeInserted (int positionStart , int itemCount ) {
141
+ super .onItemRangeInserted (positionStart , itemCount );
142
+ if (itemCount > 0 && positionStart == 0 ) {
143
+ rvContributionsList .scrollToPosition (0 );//Newly upload items are always added to the top
144
+ }
145
+ }
146
+ });
137
147
}
138
148
139
149
private int getSpanCount (final int orientation ) {
You can’t perform that action at this time.
0 commit comments