Эх сурвалжийг харах

Implement onRefresh method for SwipeRefreshLayout

masensio 11 жил өмнө
parent
commit
84d10342ce

+ 7 - 0
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -927,6 +927,13 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
                         removeStickyBroadcast(intent);
                         Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
                         setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
+                        
+                        if (mSyncInProgress) {
+                            getListOfFilesFragment().showSwipeProgress();
+                            
+                        } else {
+                            getListOfFilesFragment().hideSwipeProgress();
+                        }
                 }
                 
                 if (synchResult != null) {

+ 14 - 0
src/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -147,6 +147,20 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic
     public void disableSwipe() {
         mRefreshLayout.setEnabled(false);
     }
+    
+    /**
+     * It shows the SwipeRefreshLayout progress
+     */
+    public void showSwipeProgress() {
+        mRefreshLayout.setRefreshing(true);
+    }
+ 
+    /**
+     * It shows the SwipeRefreshLayout progress
+     */
+    public void hideSwipeProgress() {
+        mRefreshLayout.setRefreshing(false);
+    }
  
     
 }

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

@@ -35,7 +35,6 @@ import com.owncloud.android.utils.Log_OC;
 
 import android.app.Activity;
 import android.os.Bundle;
-import android.support.v4.widget.SwipeRefreshLayout;
 import android.view.ContextMenu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -434,5 +433,19 @@ public class OCFileListFragment extends ExtendedListFragment {
             mFile = directory;
         }
     }
+
+
+    @Override
+    public void onRefresh() {
+        super.onRefresh();
+        
+        if (mFile != null) {
+            listDirectory(mFile);
+            
+            ((FileDisplayActivity)mContainerActivity).startSyncFolderOperation(mFile);
+        }
+    }
+    
+    
     
 }