- GridLayout
authortobiasKaminsky <tobias@kaminsky.me>
Mon, 15 Sep 2014 17:12:12 +0000 (19:12 +0200)
committertobiasKaminsky <tobias@kaminsky.me>
Mon, 15 Sep 2014 17:12:12 +0000 (19:12 +0200)
res/layout/grid_image.xml [new file with mode: 0644]
res/layout/grid_item.xml [new file with mode: 0644]
res/layout/image_item.xml [deleted file]
res/layout/list_fragment.xml
src/com/owncloud/android/ui/ExtendedListView.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/ui/fragment/ExtendedListFragment.java
src/com/owncloud/android/ui/fragment/LocalFileListFragment.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

diff --git a/res/layout/grid_image.xml b/res/layout/grid_image.xml
new file mode 100644 (file)
index 0000000..a9fe863
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  ownCloud Android client application\r
+\r
+  Copyright (C) 2012  Bartek Przybylski\r
+  Copyright (C) 2012-2013 ownCloud Inc.\r
+\r
+  This program is free software: you can redistribute it and/or modify\r
+  it under the terms of the GNU General Public License version 2,\r
+  as published by the Free Software Foundation.\r
+\r
+  This program is distributed in the hope that it will be useful,\r
+  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+  GNU General Public License for more details.\r
+\r
+  You should have received a copy of the GNU General Public License\r
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+  \r
+-->\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:id="@+id/ListItemLayout"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="160dp"\r
+    android:background="@drawable/list_selector"\r
+    android:orientation="horizontal" >\r
+\r
+    <ImageView\r
+        android:id="@+id/imageView1"\r
+        android:layout_width="150dp"\r
+        android:layout_height="150dp"\r
+        android:layout_marginBottom="5dp"\r
+        android:layout_marginLeft="9dp"\r
+        android:layout_marginTop="5dp"\r
+        android:src="@drawable/ic_menu_archive" />\r
+\r
+    <ImageView\r
+        android:id="@+id/imageView2"\r
+        android:layout_width="40dp"\r
+        android:layout_height="22dp"\r
+        android:layout_marginLeft="22dp"\r
+        android:src="@drawable/local_file_indicator" />\r
+\r
+    <FrameLayout\r
+        android:id="@+id/imageItemFrame"\r
+        android:layout_width="56dp"\r
+        android:layout_height="56dp"\r
+        android:focusable="false"\r
+        android:focusableInTouchMode="false" >\r
+\r
+        <ImageView\r
+            android:id="@+id/sharedIcon"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginBottom="4dp"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:src="@drawable/sharedlink" />\r
+\r
+        <ImageView\r
+            android:id="@+id/sharedWithMeIcon"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:layout_marginTop="4dp"\r
+            android:src="@drawable/shared_with_me" />\r
+\r
+        <ImageView\r
+            android:id="@+id/custom_checkbox"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:src="@android:drawable/checkbox_off_background" />\r
+\r
+        <TextView\r
+            android:id="@+id/Filename"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:ellipsize="middle"\r
+            android:singleLine="true"\r
+            android:text="TextView"\r
+            android:textColor="#303030"\r
+            android:textSize="16dip" />\r
+\r
+        <ImageView\r
+            android:id="@+id/imageView3"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_gravity="bottom|right"\r
+            android:layout_marginBottom="10dp"\r
+            android:layout_marginRight="2dp"\r
+            android:src="@drawable/ic_favorite" />\r
+\r
+        <TextView\r
+            android:id="@+id/last_mod"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_weight=".5"\r
+            android:text="TextView"\r
+            android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+            android:textSize="12dip" />\r
+\r
+        <TextView\r
+            android:id="@+id/file_size"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_weight=".5"\r
+            android:gravity="right"\r
+            android:text="TextView"\r
+            android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+            android:textSize="12dip" />\r
+    </FrameLayout>\r
+\r
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/grid_item.xml b/res/layout/grid_item.xml
new file mode 100644 (file)
index 0000000..5c35c62
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  ownCloud Android client application\r
+\r
+  Copyright (C) 2012  Bartek Przybylski\r
+  Copyright (C) 2012-2013 ownCloud Inc.\r
+\r
+  This program is free software: you can redistribute it and/or modify\r
+  it under the terms of the GNU General Public License version 2,\r
+  as published by the Free Software Foundation.\r
+\r
+  This program is distributed in the hope that it will be useful,\r
+  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+  GNU General Public License for more details.\r
+\r
+  You should have received a copy of the GNU General Public License\r
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+  \r
+-->\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:id="@+id/ListItemLayout"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="160dp"\r
+    android:background="@drawable/list_selector"\r
+    android:orientation="vertical" >\r
+\r
+    <ImageView\r
+        android:id="@+id/imageView1"\r
+        android:layout_width="90dp"\r
+        android:layout_height="93dp"\r
+        android:layout_marginBottom="5dp"\r
+        android:layout_marginLeft="9dp"\r
+        android:layout_marginTop="5dp"\r
+        android:src="@drawable/ic_menu_archive" />\r
+\r
+    <TextView\r
+        android:id="@+id/Filename"\r
+        android:layout_width="95dp"\r
+        android:layout_height="wrap_content"\r
+        android:layout_marginLeft="4dp"\r
+        android:layout_marginRight="4dp"\r
+        android:ellipsize="middle"\r
+        android:singleLine="true"\r
+        android:text="TextView"\r
+        android:textColor="#303030"\r
+        android:textSize="16dip" />\r
+\r
+    <ImageView\r
+        android:id="@+id/imageView2"\r
+        android:layout_width="40dp"\r
+        android:layout_height="22dp"\r
+        android:layout_marginLeft="22dp"\r
+        android:src="@drawable/local_file_indicator" />\r
+\r
+    <TextView\r
+        android:id="@+id/file_size"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content"\r
+        android:layout_weight=".5"\r
+        android:gravity="right"\r
+        android:text="TextView"\r
+        android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+        android:textSize="12dip" />\r
+\r
+    <FrameLayout\r
+        android:id="@+id/imageItemFrame"\r
+        android:layout_width="56dp"\r
+        android:layout_height="56dp"\r
+        android:focusable="false"\r
+        android:focusableInTouchMode="false" >\r
+\r
+        <ImageView\r
+            android:id="@+id/sharedIcon"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginBottom="4dp"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:src="@drawable/sharedlink" />\r
+\r
+        <ImageView\r
+            android:id="@+id/sharedWithMeIcon"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:layout_marginTop="4dp"\r
+            android:src="@drawable/shared_with_me" />\r
+\r
+        <ImageView\r
+            android:id="@+id/custom_checkbox"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_marginLeft="4dp"\r
+            android:layout_marginRight="4dp"\r
+            android:src="@android:drawable/checkbox_off_background" />\r
+\r
+        <ImageView\r
+            android:id="@+id/imageView3"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_gravity="bottom|right"\r
+            android:layout_marginBottom="10dp"\r
+            android:layout_marginRight="2dp"\r
+            android:src="@drawable/ic_favorite" />\r
+\r
+        <TextView\r
+            android:id="@+id/last_mod"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_weight=".5"\r
+            android:text="TextView"\r
+            android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+            android:textSize="12dip" />\r
+    </FrameLayout>\r
+\r
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/image_item.xml b/res/layout/image_item.xml
deleted file mode 100644 (file)
index bd9f8d7..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-  ownCloud Android client application\r
-\r
-  Copyright (C) 2012  Bartek Przybylski\r
-  Copyright (C) 2012-2013 ownCloud Inc.\r
-\r
-  This program is free software: you can redistribute it and/or modify\r
-  it under the terms of the GNU General Public License version 2,\r
-  as published by the Free Software Foundation.\r
-\r
-  This program is distributed in the hope that it will be useful,\r
-  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-  GNU General Public License for more details.\r
-\r
-  You should have received a copy of the GNU General Public License\r
-  along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-  \r
--->\r
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
-    android:id="@+id/ListItemLayout"\r
-    android:layout_width="fill_parent"\r
-    android:layout_height="160dp"\r
-    android:background="@drawable/list_selector"\r
-    android:orientation="horizontal" >\r
-\r
-    <ImageView\r
-        android:id="@+id/imageView1"\r
-        android:layout_width="150dp"\r
-        android:layout_height="150dp"\r
-        android:layout_marginBottom="5dp"\r
-        android:layout_marginLeft="9dp"\r
-        android:layout_marginTop="5dp"\r
-        android:src="@drawable/ic_menu_archive" />\r
-\r
-    <FrameLayout\r
-        android:id="@+id/imageItemFrame"\r
-        android:layout_width="56dp"\r
-        android:layout_height="56dp"\r
-        android:focusable="false"\r
-        android:focusableInTouchMode="false" >\r
-\r
-        <ImageView\r
-            android:id="@+id/sharedIcon"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_marginBottom="4dp"\r
-            android:layout_marginLeft="4dp"\r
-            android:layout_marginRight="4dp"\r
-            android:src="@drawable/sharedlink" />\r
-\r
-        <ImageView\r
-            android:id="@+id/sharedWithMeIcon"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_marginLeft="4dp"\r
-            android:layout_marginRight="4dp"\r
-            android:layout_marginTop="4dp"\r
-            android:src="@drawable/shared_with_me" />\r
-\r
-        <ImageView\r
-            android:id="@+id/custom_checkbox"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_marginLeft="4dp"\r
-            android:layout_marginRight="4dp"\r
-            android:src="@android:drawable/checkbox_off_background" />\r
-\r
-        <ImageView\r
-            android:id="@+id/imageView2"\r
-            android:layout_width="32dp"\r
-            android:layout_height="32dp"\r
-            android:layout_gravity="center_vertical"\r
-            android:layout_marginLeft="22dp"\r
-            android:src="@drawable/local_file_indicator" />\r
-\r
-        <TextView\r
-            android:id="@+id/Filename"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_marginLeft="4dp"\r
-            android:layout_marginRight="4dp"\r
-            android:ellipsize="middle"\r
-            android:singleLine="true"\r
-            android:text="TextView"\r
-            android:textColor="#303030"\r
-            android:textSize="16dip" />\r
-\r
-        <ImageView\r
-            android:id="@+id/imageView3"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_gravity="bottom|right"\r
-            android:layout_marginBottom="10dp"\r
-            android:layout_marginRight="2dp"\r
-            android:src="@drawable/ic_favorite" />\r
-\r
-        <TextView\r
-            android:id="@+id/last_mod"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight=".5"\r
-            android:text="TextView"\r
-            android:textColor="@color/list_item_lastmod_and_filesize_text"\r
-            android:textSize="12dip" />\r
-\r
-        <TextView\r
-            android:id="@+id/file_size"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight=".5"\r
-            android:gravity="right"\r
-            android:text="TextView"\r
-            android:textColor="@color/list_item_lastmod_and_filesize_text"\r
-            android:textSize="12dip" />\r
-    </FrameLayout>\r
-\r
-</LinearLayout>
\ No newline at end of file
index 24dbb49..1f51f41 100644 (file)
@@ -19,7 +19,7 @@
 -->
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="0dp"
+    android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_weight="1" >
 
         <com.owncloud.android.ui.ExtendedListView
             android:id="@+id/list_root"
             android:layout_width="match_parent"
-            android:layout_height="match_parent" />
+            android:layout_height="match_parent"
+            android:columnWidth="160dp"
+            android:gravity="center"
+            android:horizontalSpacing="10dp"
+            android:numColumns="auto_fit"
+            android:stretchMode="columnWidth"
+            android:verticalSpacing="10dp"
+            android:visibility="visible" />
     </android.support.v4.widget.SwipeRefreshLayout>
 
     <android.support.v4.widget.SwipeRefreshLayout
         android:layout_height="match_parent"
         android:visibility="gone" >
 
-        <GridView
-            android:id="@+id/grid_list_view"
-            android:layout_width="fill_parent"
+        <TextView
+            android:id="@+id/empty_list_view"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:numColumns="1"
+            android:layout_gravity="center"
+            android:gravity="center_vertical|center_horizontal"
+            android:text="@string/empty"
             android:visibility="visible" />
-
     </android.support.v4.widget.SwipeRefreshLayout>
 
 </FrameLayout>
\ No newline at end of file
index 9fe885b..9b347be 100644 (file)
@@ -21,6 +21,7 @@ package com.owncloud.android.ui;
 import android.content.Context;
 import android.graphics.Canvas;
 import android.util.AttributeSet;
+import android.widget.GridView;
 import android.widget.ListView;
 
 /**
@@ -30,7 +31,7 @@ import android.widget.ListView;
  *  
  * @author David A. Velasco
  */
-public class ExtendedListView extends ListView {
+public class ExtendedListView extends GridView {
 
     private int mPositionToSetAndCenter;
 
@@ -55,7 +56,8 @@ public class ExtendedListView extends ListView {
     protected void onDraw (Canvas canvas) {
         super.onDraw(canvas);
         if (mPositionToSetAndCenter > 0) {
-            this.setSelectionFromTop(mPositionToSetAndCenter, getHeight() / 2);
+            this.setSelection(mPositionToSetAndCenter);
+            //this.setSelectionFromTop(mPositionToSetAndCenter, getHeight() / 2);
             mPositionToSetAndCenter = 0;
         }
     }
index c6fc19e..202854f 100644 (file)
@@ -130,22 +130,31 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
         }\r
         \r
         View view = convertView;\r
+        OCFile file = null;\r
         LayoutInflater inflator = (LayoutInflater) mContext\r
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
+        \r
+        if (mFiles != null && mFiles.size() > position) {\r
+            file = mFiles.get(position);\r
+        }\r
+        \r
         if (fileView){\r
             view = inflator.inflate(R.layout.list_item, null);\r
         } else {\r
-            view = inflator.inflate(R.layout.image_item, null);\r
+            if (file.isImage()){\r
+                view = inflator.inflate(R.layout.grid_image, null);\r
+            } else {\r
+                view = inflator.inflate(R.layout.grid_item, null);\r
+            }\r
+            \r
             View frame = view.findViewById(R.id.imageItemFrame);\r
             frame.setVisibility(View.GONE);\r
         }\r
-//    }\r
         view.invalidate();\r
     \r
-        if (mFiles != null && mFiles.size() > position) {\r
-            OCFile file = mFiles.get(position);\r
+       if (file != null){\r
             TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
-            if (!fileView){fileName.setVisibility(View.GONE);}\r
+            // if (!fileView){fileName.setVisibility(View.GONE);}\r
             String name = file.getFileName();\r
 \r
             fileName.setText(name);\r
@@ -189,7 +198,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
                 }\r
                 \r
                 GridView parentList = (GridView)parent;\r
-                if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { \r
+                if (parentList.getChoiceMode() == GridView.CHOICE_MODE_NONE) { \r
                     checkBoxV.setVisibility(View.GONE);\r
                 } else {\r
                     if (parentList.isItemChecked(position)) {\r
index bbf33e5..547a3c0 100644 (file)
@@ -52,7 +52,7 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
     private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
     private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
 
-    protected ExtendedListView mList;
+    // protected ExtendedListView mList;
     
     private SwipeRefreshLayout mRefreshLayout;
     private SwipeRefreshLayout mRefreshEmptyLayout;
@@ -66,29 +66,24 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
 
     private SwipeRefreshLayout.OnRefreshListener mOnRefreshListener = null;
     
-    private GridView imageView;
-    private View fileView;
-    
-    
+    protected GridView imageView;
+       
     public void setListAdapter(ListAdapter listAdapter) {
         imageView.setAdapter(listAdapter);
         imageView.invalidate();
     }
 
-    public ListView getListView() {
-        return mList;
+    public GridView getGridView() {
+        return imageView;
     }
     
     protected void switchImageView(){
-        // TODO berechnen, wieviele Spalten
-        imageView.setNumColumns(3);
-        mList.invalidate();
+       imageView.setNumColumns(GridView.AUTO_FIT);
        imageView.invalidate();
     }
     
     protected void switchFileView(){
-        imageView.setNumColumns(1);
-        mList.invalidate();
+       imageView.setNumColumns(1);
        imageView.invalidate();
     }
     
@@ -99,15 +94,16 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
         
         View v = inflater.inflate(R.layout.list_fragment, null);
         
-        imageView = (GridView) v.findViewById(R.id.grid_list_view);
-        imageView.setOnItemClickListener(this);
+//        imageView = (GridView) v.findViewById(R.id.grid_list_view);
+//        imageView.setOnItemClickListener(this);
         
        // mEmptyListMessage = (TextView) v.findViewById(R.id.empty_list_view);
-        mList = (ExtendedListView)(v.findViewById(R.id.list_root));
-        // mList.setOnItemClickListener(this);
+        imageView = (ExtendedListView)(v.findViewById(R.id.list_root));
+        imageView.setOnItemClickListener(this);
 
-        mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
-        mList.setDividerHeight(1);
+        //mList.set
+        //mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
+        //mList.setDividerHeight(1);
 
         if (savedInstanceState != null) {
             int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION);
@@ -121,7 +117,7 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
         onCreateSwipeToRefresh(mRefreshLayout);
         onCreateSwipeToRefresh(mRefreshEmptyLayout);
         
-        mList.setEmptyView(mRefreshEmptyLayout);
+//        mList.setEmptyView(mRefreshEmptyLayout);
 
         return v;
     }
@@ -172,8 +168,8 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
      * @return      The position in the list of the visible item in the center of the screen.
      */
     protected int getReferencePosition() {
-        if (mList != null) {
-            return (mList.getFirstVisiblePosition() + mList.getLastVisiblePosition()) / 2;
+        if (imageView != null) {
+            return (imageView.getFirstVisiblePosition() + imageView.getLastVisiblePosition()) / 2;
         } else {
             return 0;
         }
@@ -186,8 +182,8 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
      * @param   position    Reference position previously returned by {@link LocalFileListFragment#getReferencePosition()}
      */
     protected void setReferencePosition(int position) {
-        if (mList != null) {
-            mList.setAndCenterSelection(position);
+        if (imageView != null) {
+            imageView.setSelection(position);
         }
     }
 
@@ -205,20 +201,20 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
             
             int top = mTops.remove(mTops.size() - 1);
             
-            mList.setSelectionFromTop(firstPosition, top);
+            imageView.setSelection(firstPosition);
             
             // Move the scroll if the selection is not visible
             int indexPosition = mHeightCell*index;
-            int height = mList.getHeight();
+            int height = imageView.getHeight();
             
             if (indexPosition > height) {
                 if (android.os.Build.VERSION.SDK_INT >= 11)
                 {
-                    mList.smoothScrollToPosition(index); 
+                    imageView.smoothScrollToPosition(index); 
                 }
                 else if (android.os.Build.VERSION.SDK_INT >= 8)
                 {
-                    mList.setSelectionFromTop(index, 0);
+                    imageView.setSelection(index);
                 }
                 
             }
@@ -232,10 +228,10 @@ implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
         
         mIndexes.add(index);
         
-        int firstPosition = mList.getFirstVisiblePosition();
+        int firstPosition = imageView.getFirstVisiblePosition();
         mFirstPositions.add(firstPosition);
         
-        View view = mList.getChildAt(0);
+        View view = imageView.getChildAt(0);
         int top = (view == null) ? 0 : view.getTop() ;
 
         mTops.add(top);
index c6d562c..c695733 100644 (file)
@@ -75,7 +75,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");
@@ -117,7 +117,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);
@@ -194,10 +194,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;
     }
@@ -210,12 +210,12 @@ public class LocalFileListFragment extends ExtendedListFragment {
      */
     public String[] getCheckedFilePaths() {
         String [] result = null;
-        SparseBooleanArray positions = mList.getCheckedItemPositions();
+        SparseBooleanArray positions = imageView.getCheckedItemPositions();
         if (positions.size() > 0) {
             Log_OC.d(TAG, "Returning " + positions.size() + " selected files");
             result = new String[positions.size()];
             for (int i=0; i<positions.size(); i++) {
-                result[i] = ((File) mList.getItemAtPosition(positions.keyAt(i))).getAbsolutePath();
+                result[i] = ((File) imageView.getItemAtPosition(positions.keyAt(i))).getAbsolutePath();
             }
         }
         return result;
index 209c60a..3e126b9 100644 (file)
@@ -126,8 +126,8 @@ public class OCFileListFragment extends ExtendedListFragment {
         );
         setListAdapter(mAdapter);
         
-        registerForContextMenu(getListView());
-        getListView().setOnCreateContextMenuListener(this);
+        registerForContextMenu(getGridView());
+        getGridView().setOnCreateContextMenuListener(this);
   }
     
     /**
@@ -381,7 +381,7 @@ public class OCFileListFragment extends ExtendedListFragment {
 
             mAdapter.swapDirectory(directory, storageManager);
             if (mFile == null || !mFile.equals(directory)) {
-                mList.setSelectionFromTop(0, 0);
+                imageView.setSelection(0);
             }
             mFile = directory;