Browse Source

if photo search returns less photos than limit -> hide spinner

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 years ago
parent
commit
0be925f00e

+ 7 - 1
src/main/java/com/owncloud/android/ui/asynctasks/PhotoSearchTask.java

@@ -41,6 +41,7 @@ public class PhotoSearchTask extends AsyncTask<Void, Void, RemoteOperationResult
     private WeakReference<PhotoFragment> photoFragmentWeakReference;
     private WeakReference<PhotoFragment> photoFragmentWeakReference;
     private SearchRemoteOperation searchRemoteOperation;
     private SearchRemoteOperation searchRemoteOperation;
     private FileDataStorageManager storageManager;
     private FileDataStorageManager storageManager;
+    private int limit;
 
 
     public PhotoSearchTask(int columnsCount,
     public PhotoSearchTask(int columnsCount,
                            PhotoFragment photoFragment,
                            PhotoFragment photoFragment,
@@ -76,7 +77,7 @@ public class PhotoSearchTask extends AsyncTask<Void, Void, RemoteOperationResult
         if (isCancelled()) {
         if (isCancelled()) {
             return new RemoteOperationResult(new Exception("Cancelled"));
             return new RemoteOperationResult(new Exception("Cancelled"));
         } else {
         } else {
-            int limit = 15 * columnCount;
+            limit = 15 * columnCount;
 
 
             long timestamp = -1;
             long timestamp = -1;
             if (adapter.getLastTimestamp() > 0) {
             if (adapter.getLastTimestamp() > 0) {
@@ -105,6 +106,11 @@ public class PhotoSearchTask extends AsyncTask<Void, Void, RemoteOperationResult
                 } else {
                 } else {
                     OCFileListAdapter adapter = photoFragment.getAdapter();
                     OCFileListAdapter adapter = photoFragment.getAdapter();
 
 
+                    if (result.getData().size() < limit) {
+                        // stop loading spinner
+                        photoFragment.setSearchDidNotFindNewPhotos(true);
+                    }
+
                     adapter.setData(result.getData(),
                     adapter.setData(result.getData(),
                                     ExtendedListFragment.SearchType.PHOTO_SEARCH,
                                     ExtendedListFragment.SearchType.PHOTO_SEARCH,
                                     storageManager,
                                     storageManager,