File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
app/src/main/java/fr/free/nrw/commons/contributions Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,10 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
199199 }else if (layoutManager instanceof GridLayoutManager ){
200200 lastVisibleItemPosition =((GridLayoutManager )layoutManager ).findLastCompletelyVisibleItemPosition ();
201201 }
202- outState .putString (VISIBLE_ITEM_ID ,findIdOfItemWithPosition (lastVisibleItemPosition ));
202+ String idOfItemWithPosition = findIdOfItemWithPosition (lastVisibleItemPosition );
203+ if (null != idOfItemWithPosition ) {
204+ outState .putString (VISIBLE_ITEM_ID , idOfItemWithPosition );
205+ }
203206 }
204207
205208 @ Override
@@ -216,8 +219,13 @@ public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
216219 * @param position
217220 * @return
218221 */
222+ @ Nullable
219223 private String findIdOfItemWithPosition (int position ) {
220- return callback .getContributionForPosition (position ).getContentUri ().getLastPathSegment ();
224+ Contribution contributionForPosition = callback .getContributionForPosition (position );
225+ if (null != contributionForPosition ) {
226+ return contributionForPosition .getContentUri ().getLastPathSegment ();
227+ }
228+ return null ;
221229 }
222230
223231}
You can’t perform that action at this time.
0 commit comments