Browse Source

Fix crash in navigation in FileList

masensio 10 years ago
parent
commit
b3147346eb

+ 10 - 7
src/com/owncloud/android/ui/adapter/FileListListAdapter.java

@@ -30,6 +30,7 @@ import android.accounts.Account;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.graphics.Bitmap;
+import android.os.Build;
 import android.preference.PreferenceManager;
 import android.text.format.DateUtils;
 import android.view.LayoutInflater;
@@ -196,15 +197,17 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
 
                     if (!file.isFolder()) {
                         AbsListView parentList = (AbsListView)parent;
-                        if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {
-                            checkBoxV.setVisibility(View.GONE);
-                        } else {
-                            if (parentList.isItemChecked(position)) {
-                                checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
+                        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+                            if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {
+                                checkBoxV.setVisibility(View.GONE);
                             } else {
-                                checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
+                                if (parentList.isItemChecked(position)) {
+                                    checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
+                                } else {
+                                    checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
+                                }
+                                checkBoxV.setVisibility(View.VISIBLE);
                             }
-                            checkBoxV.setVisibility(View.VISIBLE);
                         }
 
                     } else { //Folder

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

@@ -22,7 +22,9 @@ package com.owncloud.android.ui.fragment;
 
 import java.util.ArrayList;
 
+import android.annotation.TargetApi;
 import android.content.Context;
+import android.os.Build;
 import android.os.Bundle;
 import android.support.v4.widget.SwipeRefreshLayout;
 import android.view.LayoutInflater;
@@ -33,6 +35,7 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.GridView;
 import android.widget.ListAdapter;
+import android.widget.ListView;
 import android.widget.TextView;
 
 import com.actionbarsherlock.app.SherlockFragment;
@@ -80,10 +83,14 @@ implements OnItemClickListener, OnEnforceableRefreshListener {
 
     private ListAdapter mAdapter;
 
-
     protected void setListAdapter(ListAdapter listAdapter) {
         mAdapter = listAdapter;
-        mCurrentListView.setAdapter(listAdapter);
+        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+            mCurrentListView.setAdapter(listAdapter);
+        } else {
+            ((ListView)mCurrentListView).setAdapter(listAdapter);
+        }
+
         mCurrentListView.invalidate();
     }
 
@@ -348,10 +355,11 @@ implements OnItemClickListener, OnEnforceableRefreshListener {
         }
     }
 
-
     protected void setChoiceMode(int choiceMode) {
-        mListView.setChoiceMode(choiceMode);
-        mGridView.setChoiceMode(choiceMode);
+        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+            mListView.setChoiceMode(choiceMode);
+            mGridView.setChoiceMode(choiceMode);
+        }
     }
 
     protected void registerForContextMenu() {