From: tobiasKaminsky Date: Sun, 19 Oct 2014 17:33:31 +0000 (+0200) Subject: - fix bug X-Git-Tag: oc-android-1.7.0_signed~126^2~3 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/697719ce0ed3c15065566b18a5bb1034e2b3a343?ds=inline;hp=--cc - fix bug --- 697719ce0ed3c15065566b18a5bb1034e2b3a343 diff --git a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java index 40c03a46..81c43a33 100644 --- a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java @@ -18,11 +18,7 @@ package com.owncloud.android.ui.fragment; import java.io.File; - -import com.owncloud.android.Log_OC; -import com.owncloud.android.R; -import com.owncloud.android.ui.adapter.LocalFileListAdapter; - +import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; @@ -35,6 +31,9 @@ import android.widget.AdapterView; import android.widget.ImageView; import android.widget.ListView; +import com.owncloud.android.Log_OC; +import com.owncloud.android.R; +import com.owncloud.android.ui.adapter.LocalFileListAdapter; /** * A Fragment that lists all files and folders in a given LOCAL path. @@ -44,17 +43,19 @@ import android.widget.ListView; */ public class LocalFileListFragment extends ExtendedListFragment { private static final String TAG = "LocalFileListFragment"; - - /** Reference to the Activity which this fragment is attached to. For callbacks */ + + /** + * Reference to the Activity which this fragment is attached to. For + * callbacks + */ private LocalFileListFragment.ContainerActivity mContainerActivity; - + /** Directory to show */ private File mDirectory = null; - + /** Adapter to connect the data from the directory with the View object */ private LocalFileListAdapter mAdapter = null; - /** * {@inheritDoc} */ @@ -64,11 +65,11 @@ public class LocalFileListFragment extends ExtendedListFragment { try { mContainerActivity = (ContainerActivity) activity; } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + " must implement " + LocalFileListFragment.ContainerActivity.class.getSimpleName()); + throw new ClassCastException(activity.toString() + " must implement " + + LocalFileListFragment.ContainerActivity.class.getSimpleName()); } } - - + /** * {@inheritDoc} */ @@ -79,8 +80,7 @@ public class LocalFileListFragment extends ExtendedListFragment { getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); Log_OC.i(TAG, "onCreateView() end"); return v; - } - + } /** * {@inheritDoc} @@ -88,30 +88,30 @@ public class LocalFileListFragment extends ExtendedListFragment { @Override public void onActivityCreated(Bundle savedInstanceState) { Log_OC.i(TAG, "onActivityCreated() start"); - + super.onCreate(savedInstanceState); mAdapter = new LocalFileListAdapter(mContainerActivity.getInitialDirectory(), getActivity()); setListAdapter(mAdapter); - + Log_OC.i(TAG, "onActivityCreated() stop"); } - - + /** - * Checks the file clicked over. Browses inside if it is a directory. Notifies the container activity in any case. + * 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 + // / Click on a directory if (file.isDirectory()) { // just local updates listDirectory(file); // notify the click to container Activity mContainerActivity.onDirectoryClick(file); - - } else { /// Click on a file + + } else { // / Click on a file ImageView checkBoxV = (ImageView) v.findViewById(R.id.custom_checkbox); if (checkBoxV != null) { if (getListView().isItemChecked(position)) { @@ -123,129 +123,138 @@ public class LocalFileListFragment extends ExtendedListFragment { // notify the change to the container Activity mContainerActivity.onFileClick(file); } - + } else { Log_OC.w(TAG, "Null object in ListAdapter!!"); } } - /** * Call this, when the user presses the up button */ public void onNavigateUp() { File parentDir = null; - if(mDirectory != null) { - parentDir = mDirectory.getParentFile(); // can be null + if (mDirectory != null) { + parentDir = mDirectory.getParentFile(); // can be null } listDirectory(parentDir); } - /** - * Use this to query the {@link File} object for the directory - * that is currently being displayed by this fragment + * Use this to query the {@link File} object for the directory that is + * currently being displayed by this fragment * - * @return File The currently displayed directory + * @return File The currently displayed directory */ - public File getCurrentDirectory(){ + public File getCurrentDirectory() { return mDirectory; } - - + /** - * Calls {@link LocalFileListFragment#listDirectory(File)} with a null parameter - * to refresh the current directory. + * Calls {@link LocalFileListFragment#listDirectory(File)} with a null + * parameter to refresh the current directory. */ - public void listDirectory(){ + public void listDirectory() { listDirectory(null); } - - + /** * Lists the given directory on the view. When the input parameter is null, - * it will either refresh the last known directory. list the root - * if there never was a directory. + * it will either refresh the last known directory. list the root if there + * never was a directory. * - * @param directory Directory to be listed + * @param directory Directory to be listed */ public void listDirectory(File directory) { - + // Check input parameters for null - if(directory == null) { - if(mDirectory != null){ + if (directory == null) { + if (mDirectory != null) { directory = mDirectory; } else { - directory = Environment.getExternalStorageDirectory(); // TODO be careful with the state of the storage; could not be available - if (directory == null) return; // no files to show + directory = Environment.getExternalStorageDirectory(); // TODO + // be + // careful + // with + // the + // state + // of the + // storage; + // could + // not be + // available + if (directory == null) + return; // no files to show } } - - + // if that's not a directory -> List its parent - if(!directory.isDirectory()){ + if (!directory.isDirectory()) { Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString()); directory = directory.getParentFile(); } - mList.clearChoices(); // by now, only files in the same directory will be kept as selected + mList.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); } mDirectory = directory; } - /** * Returns the fule paths to the files checked by the user * - * @return File paths to the files checked by the user. + * @return File paths to the files checked by the user. */ public String[] getCheckedFilePaths() { - String [] result = null; + ArrayList result = new ArrayList(); SparseBooleanArray positions = mList.getCheckedItemPositions(); if (positions.size() > 0) { - Log_OC.d(TAG, "Returning " + positions.size() + " selected files"); - result = new String[positions.size()]; - for (int i=0; i