Merge pull request #669 from grecep/master
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / LocalFileListFragment.java
index c9408b1..62b41a3 100644 (file)
@@ -98,13 +98,33 @@ public class LocalFileListFragment extends ExtendedListFragment {
         Log_OC.i(TAG, "onActivityCreated() stop");
     }
     
+    public void selectAll(){
+        int numberOfFiles = mAdapter.getCount();
+        for(int i = 0; i < numberOfFiles; i++){
+            File file = (File) mAdapter.getItem(i);
+            if (file != null) {                
+                if (!file.isDirectory()) {  
+                    /// Click on a file
+                    getListView().setItemChecked(i, true);                       
+                    // notify the change to the container Activity
+                    mContainerActivity.onFileClick(file);
+                }
+            }
+        }
+    }
+    
+    public void deselectAll(){        
+        mAdapter = new LocalFileListAdapter(mContainerActivity.getInitialDirectory(), getActivity());
+        setListAdapter(mAdapter);
+    }
     
     /**
      * Checks the file clicked over. Browses inside if it is a directory. Notifies the container activity in any case.
      */
     @Override
     public void onItemClick(AdapterView<?> l, View v, int position, long id) {
-        File file = (File) mAdapter.getItem(position); 
+        File file = (File) mAdapter.getItem(position);
+        
         if (file != null) {
             /// Click on a directory
             if (file.isDirectory()) {