Merge branch 'develop2' into imageGrid2
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / LocalFileListFragment.java
index c9408b1..02a1bfe 100644 (file)
@@ -76,7 +76,7 @@ public class LocalFileListFragment extends ExtendedListFragment {
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         Log_OC.i(TAG, "onCreateView() start");
         View v = super.onCreateView(inflater, container, savedInstanceState);
-        getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
+        getGridView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
         disableSwipe(); // Disable pull refresh
         setMessageForEmptyList(getString(R.string.local_file_list_empty));
         Log_OC.i(TAG, "onCreateView() end");
@@ -98,6 +98,20 @@ 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
+                    getGridView().setItemChecked(i, true);                       
+                    // notify the change to the container Activity
+                    mContainerActivity.onFileClick(file);
+                }
+            }
+        }
+    }
     
     /**
      * Checks the file clicked over. Browses inside if it is a directory. Notifies the container activity in any case.
@@ -118,7 +132,7 @@ public class LocalFileListFragment extends ExtendedListFragment {
             } else {    /// Click on a file
                 ImageView checkBoxV = (ImageView) v.findViewById(R.id.custom_checkbox);
                 if (checkBoxV != null) {
-                    if (getListView().isItemChecked(position)) {
+                    if (getGridView().isItemChecked(position)) {
                         checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
                     } else {
                         checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
@@ -195,10 +209,10 @@ public class LocalFileListFragment extends ExtendedListFragment {
             directory = directory.getParentFile();
         }
 
-        mList.clearChoices();   // by now, only files in the same directory will be kept as selected
+        imageView.clearChoices();   // by now, only files in the same directory will be kept as selected
         mAdapter.swapDirectory(directory);
         if (mDirectory == null || !mDirectory.equals(directory)) {
-            mList.setSelectionFromTop(0, 0);
+            imageView.setSelection(0);
         }
         mDirectory = directory;
     }