1
1
package fr .free .nrw .commons .explore .images ;
2
2
3
3
4
+ import android .annotation .SuppressLint ;
4
5
import android .content .SharedPreferences ;
5
6
import android .content .res .Configuration ;
6
7
import android .os .Bundle ;
@@ -123,6 +124,7 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
123
124
* Checks for internet connection and then initializes the recycler view with 25 images of the searched query
124
125
* Clearing imageAdapter every time new keyword is searched so that user can see only new results
125
126
*/
127
+ @ SuppressLint ("CheckResult" )
126
128
public void updateImageList (String query ) {
127
129
this .query = query ;
128
130
if (imagesNotFoundView != null ) {
@@ -146,6 +148,7 @@ public void updateImageList(String query) {
146
148
/**
147
149
* Adds more results to existing search results
148
150
*/
151
+ @ SuppressLint ("CheckResult" )
149
152
public void addImagesToList (String query ) {
150
153
this .query = query ;
151
154
progressBar .setVisibility (View .VISIBLE );
@@ -163,13 +166,11 @@ public void addImagesToList(String query) {
163
166
*/
164
167
private void handlePaginationSuccess (List <Media > mediaList ) {
165
168
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 ();
173
174
}
174
175
}
175
176
0 commit comments