11package fr .free .nrw .commons .explore .images ;
22
33
4+ import android .annotation .SuppressLint ;
45import android .content .SharedPreferences ;
56import android .content .res .Configuration ;
67import android .os .Bundle ;
@@ -123,6 +124,7 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
123124 * Checks for internet connection and then initializes the recycler view with 25 images of the searched query
124125 * Clearing imageAdapter every time new keyword is searched so that user can see only new results
125126 */
127+ @ SuppressLint ("CheckResult" )
126128 public void updateImageList (String query ) {
127129 this .query = query ;
128130 if (imagesNotFoundView != null ) {
@@ -146,6 +148,7 @@ public void updateImageList(String query) {
146148 /**
147149 * Adds more results to existing search results
148150 */
151+ @ SuppressLint ("CheckResult" )
149152 public void addImagesToList (String query ) {
150153 this .query = query ;
151154 progressBar .setVisibility (View .VISIBLE );
@@ -163,13 +166,11 @@ public void addImagesToList(String query) {
163166 */
164167 private void handlePaginationSuccess (List <Media > mediaList ) {
165168 progressBar .setVisibility (View .GONE );
166- if (mediaList .size ()!=0 ){
167- if (!queryList .get (queryList .size ()-1 ).getFilename ().equals (mediaList .get (mediaList .size ()-1 ).getFilename ())) {
168- queryList .addAll (mediaList );
169- imagesAdapter .addAll (mediaList );
170- imagesAdapter .notifyDataSetChanged ();
171- ((SearchActivity )getContext ()).viewPagerNotifyDataSetChanged ();
172- }
169+ if (mediaList .size () != 0 || !queryList .get (queryList .size () - 1 ).getFilename ().equals (mediaList .get (mediaList .size () - 1 ).getFilename ())) {
170+ queryList .addAll (mediaList );
171+ imagesAdapter .addAll (mediaList );
172+ imagesAdapter .notifyDataSetChanged ();
173+ ((SearchActivity ) getContext ()).viewPagerNotifyDataSetChanged ();
173174 }
174175 }
175176
0 commit comments