浏览代码

Replaced toolbar loading by SwipeRefresh in Files list

Signed-off-by: Kilian Périsset <kilian.perisset@infomaniak.com>
Kilian Périsset 5 年之前
父节点
当前提交
f971c0b3e6

+ 5 - 9
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -329,9 +329,6 @@ public class FileDisplayActivity extends FileActivity
             syncAndUpdateFolder(true);
         }
 
-        showProgressBar(mSyncInProgress);
-        // always AFTER setContentView(...) in onCreate(); to work around bug in its implementation
-
         upgradeNotificationForInstantUpload();
         checkOutdatedServer();
     }
@@ -1199,6 +1196,8 @@ public class FileDisplayActivity extends FileActivity
     protected void onResume() {
         Log_OC.v(TAG, "onResume() start");
         super.onResume();
+        // Instead of onPostCreate, starting the loading in onResume for children fragments
+        getListOfFilesFragment().setLoading(mSyncInProgress);
         syncAndUpdateFolder(false);
 
         OCFile startFile = null;
@@ -1389,8 +1388,7 @@ public class FileDisplayActivity extends FileActivity
                         DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
 
                         Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
-                        showProgressBar(mSyncInProgress);
-
+                        getListOfFilesFragment().setLoading(mSyncInProgress);
                         setBackgroundText();
                     }
                 }
@@ -1507,9 +1505,7 @@ public class FileDisplayActivity extends FileActivity
                         // TODO what about other kind of previews?
                     }
                 }
-
-                showProgressBar(false);
-
+                getListOfFilesFragment().setLoading(false);
             } finally {
                 if (intent != null) {
                     removeStickyBroadcast(intent);
@@ -2222,7 +2218,7 @@ public class FileDisplayActivity extends FileActivity
                                         null
                                 );
 
-                                showProgressBar(true);
+                                getListOfFilesFragment().setLoading(true);
 
                                 setBackgroundText();
 

+ 4 - 5
src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -178,6 +178,10 @@ public class ExtendedListFragment extends Fragment implements
         return mFabMain;
     }
 
+    public void setLoading(Boolean enabled) {
+        mRefreshListLayout.setRefreshing(enabled);
+    }
+
     public void switchToGridView() {
         if (!isGridEnabled()) {
             getRecyclerView().setLayoutManager(new GridLayoutManager(getContext(), getColumnsCount()));
@@ -549,9 +553,6 @@ public class ExtendedListFragment extends Fragment implements
                 fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isDrawerIndicatorAvailable());
             }
         }
-
-        mRefreshListLayout.setRefreshing(false);
-
         if (mOnRefreshListener != null) {
             mOnRefreshListener.onRefresh();
         }
@@ -794,8 +795,6 @@ public class ExtendedListFragment extends Fragment implements
 
     @Override
     public void onRefresh(boolean ignoreETag) {
-        mRefreshListLayout.setRefreshing(false);
-
         if (mOnRefreshListener != null) {
             mOnRefreshListener.onRefresh();
         }

+ 1 - 2
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -28,7 +28,6 @@ import android.accounts.Account;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
-import android.graphics.drawable.Drawable;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
@@ -1626,7 +1625,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
                                 @Override
                                 public void run() {
                                     if (fileDisplayActivity != null) {
-                                        fileDisplayActivity.showProgressBar(false);
+                                        setLoading(false);
                                     }
                                 }
                             });