Filelisting using intents and OCFile.getId() instead of string matching
authorLennart Rosam <lennart@familie-rosam.de>
Wed, 23 May 2012 17:59:29 +0000 (19:59 +0200)
committerLennart Rosam <lennart@familie-rosam.de>
Wed, 23 May 2012 17:59:29 +0000 (19:59 +0200)
in db which can be very very slow if there are lots of files

res/values/strings.xml
src/eu/alefzero/owncloud/ui/activity/FileDetailActivity.java
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java
src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java

index afec754..c33e085 100644 (file)
@@ -54,6 +54,7 @@
     <string name="filedetails_created">Created:</string>
     <string name="filedetails_modified">Modified:</string>
     <string name="filedetails_download">Download</string>
     <string name="filedetails_created">Created:</string>
     <string name="filedetails_modified">Modified:</string>
     <string name="filedetails_download">Download</string>
+    <string name="filedetails_open">Open</string>
     <string name="common_yes">Yes</string>
     <string name="common_no">No</string>
     <string name="common_ok">OK</string>
     <string name="common_yes">Yes</string>
     <string name="common_no">No</string>
     <string name="common_ok">OK</string>
index cb899f6..f5664ea 100644 (file)
  */\r
 package eu.alefzero.owncloud.ui.activity;\r
 \r
  */\r
 package eu.alefzero.owncloud.ui.activity;\r
 \r
+import android.content.Intent;\r
 import android.os.Bundle;\r
 import android.support.v4.app.FragmentTransaction;\r
 import android.os.Bundle;\r
 import android.support.v4.app.FragmentTransaction;\r
-import android.view.Window;\r
 \r
 \r
+import com.actionbarsherlock.app.ActionBar;\r
 import com.actionbarsherlock.app.SherlockFragmentActivity;\r
 import com.actionbarsherlock.app.SherlockFragmentActivity;\r
+import com.actionbarsherlock.view.MenuItem;\r
 \r
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.ui.fragment.FileDetailFragment;\r
 \r
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.ui.fragment.FileDetailFragment;\r
@@ -38,11 +40,12 @@ public class FileDetailActivity extends SherlockFragmentActivity {
 \r
     @Override\r
     protected void onCreate(Bundle savedInstanceState) {\r
 \r
     @Override\r
     protected void onCreate(Bundle savedInstanceState) {\r
-        // TODO Auto-generated method stub\r
         super.onCreate(savedInstanceState);\r
         super.onCreate(savedInstanceState);\r
-        getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
         setContentView(R.layout.file_activity_details);\r
 \r
         setContentView(R.layout.file_activity_details);\r
 \r
+        ActionBar actionBar = getSupportActionBar();\r
+        actionBar.setDisplayHomeAsUpEnabled(true);\r
+        \r
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
         mFileDetail = new FileDetailFragment();\r
         ft.add(R.id.fragment, mFileDetail, "FileDetails");\r
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
         mFileDetail = new FileDetailFragment();\r
         ft.add(R.id.fragment, mFileDetail, "FileDetails");\r
@@ -51,6 +54,25 @@ public class FileDetailActivity extends SherlockFragmentActivity {
     }\r
 \r
     @Override\r
     }\r
 \r
     @Override\r
+    public boolean onOptionsItemSelected(MenuItem item) {\r
+        boolean returnValue = false;\r
+        \r
+        switch(item.getItemId()){\r
+        case android.R.id.home:\r
+            Intent intent = new Intent(this, FileDisplayActivity.class);\r
+            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r
+            intent.putExtra(FileDetailFragment.EXTRA_FILE, mFileDetail.getDisplayedFile());\r
+            startActivity(intent);\r
+            finish();\r
+            returnValue = true;\r
+        }\r
+        \r
+        return returnValue;\r
+    }\r
+\r
+\r
+\r
+    @Override\r
     protected void onResume() {\r
         super.onResume();\r
         mFileDetail.updateFileDetails(getIntent());\r
     protected void onResume() {\r
         super.onResume();\r
         mFileDetail.updateFileDetails(getIntent());\r
index bdc146c..832ccae 100644 (file)
@@ -20,8 +20,6 @@ package eu.alefzero.owncloud.ui.activity;
 \r
 import java.io.File;\r
 import java.net.URLDecoder;\r
 \r
 import java.io.File;\r
 import java.net.URLDecoder;\r
-import java.net.URLEncoder;\r
-\r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
 import android.app.AlertDialog;\r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
 import android.app.AlertDialog;\r
@@ -62,7 +60,6 @@ import eu.alefzero.owncloud.datamodel.OCFile;
 import eu.alefzero.owncloud.files.services.FileUploader;\r
 import eu.alefzero.owncloud.syncadapter.FileSyncService;\r
 import eu.alefzero.owncloud.ui.fragment.FileListFragment;\r
 import eu.alefzero.owncloud.files.services.FileUploader;\r
 import eu.alefzero.owncloud.syncadapter.FileSyncService;\r
 import eu.alefzero.owncloud.ui.fragment.FileListFragment;\r
-import eu.alefzero.owncloud.utils.OwnCloudVersion;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
@@ -84,8 +81,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
     \r
     private static final int DIALOG_SETUP_ACCOUNT = 0;\r
     private static final int DIALOG_CREATE_DIR = 1;\r
     \r
     private static final int DIALOG_SETUP_ACCOUNT = 0;\r
     private static final int DIALOG_CREATE_DIR = 1;\r
-\r
-    private static final int REQUEST_ACCOUNT_SETUP = 0;\r
     private static final int ACTION_SELECT_FILE = 1;\r
 \r
     public void pushPath(String path) {\r
     private static final int ACTION_SELECT_FILE = 1;\r
 \r
     public void pushPath(String path) {\r
@@ -175,8 +170,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
 \r
         requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
         setProgressBarIndeterminateVisibility(false);\r
 \r
         requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
         setProgressBarIndeterminateVisibility(false);\r
-        // if (getSupportFragmentManager().findFragmentById(R.id.fileList) ==\r
-        // null)\r
+        \r
         setContentView(R.layout.files);\r
 \r
     }\r
         setContentView(R.layout.files);\r
 \r
     }\r
@@ -282,7 +276,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                 mDirectories.insert(s, 0);\r
             FileListFragment fileListFramgent = (FileListFragment) getSupportFragmentManager()\r
                     .findFragmentById(R.id.fileList);\r
                 mDirectories.insert(s, 0);\r
             FileListFragment fileListFramgent = (FileListFragment) getSupportFragmentManager()\r
                     .findFragmentById(R.id.fileList);\r
-            if (fileListFramgent != null) fileListFramgent.populateFileList();\r
+            if (fileListFramgent != null) fileListFramgent.listDirectory();\r
         }\r
 \r
         mStorageManager = new FileDataStorageManager(\r
         }\r
 \r
         mStorageManager = new FileDataStorageManager(\r
@@ -466,7 +460,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                 FileListFragment fileListFramgent = (FileListFragment) getSupportFragmentManager()\r
                         .findFragmentById(R.id.fileList);\r
                 if (fileListFramgent != null)\r
                 FileListFragment fileListFramgent = (FileListFragment) getSupportFragmentManager()\r
                         .findFragmentById(R.id.fileList);\r
                 if (fileListFramgent != null)\r
-                    fileListFramgent.populateFileList();\r
+                    fileListFramgent.listDirectory();\r
             }\r
         }\r
 \r
             }\r
         }\r
 \r
index f76c2b2..45ec0a9 100644 (file)
@@ -51,7 +51,7 @@ import eu.alefzero.owncloud.datamodel.OCFile;
 public class FileDetailFragment extends SherlockFragment implements\r
         OnClickListener {\r
 \r
 public class FileDetailFragment extends SherlockFragment implements\r
         OnClickListener {\r
 \r
-    public static final String FILE = "FILE";\r
+    public static final String EXTRA_FILE = "FILE";\r
 \r
     private DownloadFinishReceiver mDownloadFinishReceiver;\r
     private Intent mIntent;\r
 \r
     private DownloadFinishReceiver mDownloadFinishReceiver;\r
     private Intent mIntent;\r
@@ -109,6 +109,46 @@ public class FileDetailFragment extends SherlockFragment implements
         mDownloadFinishReceiver = null;\r
     }\r
 \r
         mDownloadFinishReceiver = null;\r
     }\r
 \r
+    @Override\r
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
+            Bundle savedInstanceState) {\r
+        View view = null;\r
+        view = inflater.inflate(mLayout, container, false);\r
+        mView = view;\r
+        if(mLayout == R.layout.file_details_fragment){\r
+            // Phones will launch an activity with this intent\r
+            if(mIntent == null){\r
+                mIntent = getActivity().getIntent();\r
+            }\r
+            updateFileDetails();\r
+        }\r
+        \r
+        return view;\r
+    }\r
+\r
+    @Override\r
+    public View getView() {\r
+        return super.getView() == null ? mView : super.getView();\r
+    }\r
+\r
+    @Override\r
+    public void onClick(View v) {\r
+        Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();\r
+        Intent i = new Intent(getActivity(), FileDownloader.class);\r
+        i.putExtra(FileDownloader.EXTRA_ACCOUNT,\r
+                mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT));\r
+        i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getPath());\r
+        getActivity().startService(i);\r
+    }\r
+\r
+    /**\r
+     * Can be used to get the file that is currently being displayed.\r
+     * @return The file on the screen.\r
+     */\r
+    public OCFile getDisplayedFile(){\r
+        return mFile;\r
+    }\r
+    \r
     /**\r
      * Use this method to signal this Activity that it shall update its view.\r
      * \r
     /**\r
      * Use this method to signal this Activity that it shall update its view.\r
      * \r
@@ -116,7 +156,7 @@ public class FileDetailFragment extends SherlockFragment implements
      *            this file The intent needs to have these extras:\r
      *            <p>\r
      * \r
      *            this file The intent needs to have these extras:\r
      *            <p>\r
      * \r
-     *            {@link FileDetailFragment#FILE}: An {@link OCFile}\r
+     *            {@link FileDetailFragment#EXTRA_FILE}: An {@link OCFile}\r
      *            {@link FileDownloader#EXTRA_ACCOUNT}: The Account that file\r
      *            belongs to (required for downloading)\r
      */\r
      *            {@link FileDownloader#EXTRA_ACCOUNT}: The Account that file\r
      *            belongs to (required for downloading)\r
      */\r
@@ -125,8 +165,11 @@ public class FileDetailFragment extends SherlockFragment implements
         updateFileDetails();\r
     }\r
 \r
         updateFileDetails();\r
     }\r
 \r
+    /**\r
+     * Updates the view with all relevant details about that file.\r
+     */\r
     private void updateFileDetails() {\r
     private void updateFileDetails() {\r
-        mFile = mIntent.getParcelableExtra(FILE);\r
+        mFile = mIntent.getParcelableExtra(EXTRA_FILE);\r
         Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn);\r
 \r
         if (mFile != null) {\r
         Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn);\r
 \r
         if (mFile != null) {\r
@@ -150,7 +193,7 @@ public class FileDetailFragment extends SherlockFragment implements
                 } catch (OutOfMemoryError e) {\r
                     Log.e(TAG, "Out of memory occured for file with size " + mFile.getFileLength());\r
                 }\r
                 } catch (OutOfMemoryError e) {\r
                     Log.e(TAG, "Out of memory occured for file with size " + mFile.getFileLength());\r
                 }\r
-                downloadButton.setText("Open file");\r
+                downloadButton.setText(R.string.filedetails_open);\r
                 downloadButton.setOnClickListener(new OnClickListener() {\r
                     @Override\r
                     public void onClick(View v) {\r
                 downloadButton.setOnClickListener(new OnClickListener() {\r
                     @Override\r
                     public void onClick(View v) {\r
@@ -166,24 +209,40 @@ public class FileDetailFragment extends SherlockFragment implements
         }\r
     }\r
     \r
         }\r
     }\r
     \r
+    /**\r
+     * Updates the filename in view\r
+     * @param filename to set\r
+     */\r
     private void setFilename(String filename) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdFilename);\r
         if (tv != null)\r
             tv.setText(filename);\r
     }\r
 \r
     private void setFilename(String filename) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdFilename);\r
         if (tv != null)\r
             tv.setText(filename);\r
     }\r
 \r
+    /**\r
+     * Updates the MIME type in view\r
+     * @param mimetype to set\r
+     */\r
     private void setFiletype(String mimetype) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdType);\r
         if (tv != null)\r
             tv.setText(mimetype);\r
     }\r
 \r
     private void setFiletype(String mimetype) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdType);\r
         if (tv != null)\r
             tv.setText(mimetype);\r
     }\r
 \r
+    /**\r
+     * Updates the file size in view\r
+     * @param filesize in bytes to set\r
+     */\r
     private void setFilesize(long filesize) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdSize);\r
         if (tv != null)\r
             tv.setText(DisplayUtils.bytesToHumanReadable(filesize));\r
     }\r
     \r
     private void setFilesize(long filesize) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdSize);\r
         if (tv != null)\r
             tv.setText(DisplayUtils.bytesToHumanReadable(filesize));\r
     }\r
     \r
+    /**\r
+     * Updates the time that the file was created in view\r
+     * @param milliseconds Unix time to set\r
+     */\r
     private void setTimeCreated(long milliseconds){\r
         TextView tv = (TextView) getView().findViewById(R.id.fdCreated);\r
         if(tv != null){\r
     private void setTimeCreated(long milliseconds){\r
         TextView tv = (TextView) getView().findViewById(R.id.fdCreated);\r
         if(tv != null){\r
@@ -191,6 +250,10 @@ public class FileDetailFragment extends SherlockFragment implements
         }\r
     }\r
     \r
         }\r
     }\r
     \r
+    /**\r
+     * Updates the time that the file was last modified\r
+     * @param milliseconds Unix time to set\r
+     */\r
     private void setTimeModified(long milliseconds){\r
         TextView tv = (TextView) getView().findViewById(R.id.fdModified);\r
         if(tv != null){\r
     private void setTimeModified(long milliseconds){\r
         TextView tv = (TextView) getView().findViewById(R.id.fdModified);\r
         if(tv != null){\r
@@ -198,40 +261,10 @@ public class FileDetailFragment extends SherlockFragment implements
         }\r
     }\r
 \r
         }\r
     }\r
 \r
-    @Override\r
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
-            Bundle savedInstanceState) {\r
-        View view = null;\r
-        view = inflater.inflate(mLayout, container, false);\r
-        mView = view;\r
-        if(mLayout == R.layout.file_details_fragment){\r
-            // Phones will launch an activity with this intent\r
-            if(mIntent == null){\r
-                mIntent = getActivity().getIntent();\r
-            }\r
-            updateFileDetails();\r
-        }\r
-        \r
-        return view;\r
-    }\r
-    \r
-    \r
-\r
-    @Override\r
-    public View getView() {\r
-        return super.getView() == null ? mView : super.getView();\r
-    }\r
-\r
-    @Override\r
-    public void onClick(View v) {\r
-        Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();\r
-        Intent i = new Intent(getActivity(), FileDownloader.class);\r
-        i.putExtra(FileDownloader.EXTRA_ACCOUNT,\r
-                mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT));\r
-        i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getPath());\r
-        getActivity().startService(i);\r
-    }\r
-\r
+    /**\r
+     * Once the file download has finished -> update view\r
+     * @author Bartek Przybylski\r
+     */\r
     private class DownloadFinishReceiver extends BroadcastReceiver {\r
         @Override\r
         public void onReceive(Context context, Intent intent) {\r
     private class DownloadFinishReceiver extends BroadcastReceiver {\r
         @Override\r
         public void onReceive(Context context, Intent intent) {\r
index 5879298..e326730 100644 (file)
@@ -48,10 +48,12 @@ import eu.alefzero.owncloud.ui.adapter.FileListListAdapter;
  * \r
  */\r
 public class FileListFragment extends FragmentListView {\r
  * \r
  */\r
 public class FileListFragment extends FragmentListView {\r
+    private static final String TAG = "FileListFragment";\r
     private Account mAccount;\r
     private Stack<String> mDirNames;\r
     private Vector<OCFile> mFiles;\r
     private DataStorageManager mStorageManager;\r
     private Account mAccount;\r
     private Stack<String> mDirNames;\r
     private Vector<OCFile> mFiles;\r
     private DataStorageManager mStorageManager;\r
+    private OCFile mFile;\r
     private boolean mIsLargeDevice = false;\r
 \r
     public FileListFragment() {\r
     private boolean mIsLargeDevice = false;\r
 \r
     public FileListFragment() {\r
@@ -63,15 +65,19 @@ public class FileListFragment extends FragmentListView {
         super.onCreate(savedInstanceState);\r
 \r
         mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity());\r
         super.onCreate(savedInstanceState);\r
 \r
         mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity());\r
+        mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
         getListView().setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));\r
         getListView().setDividerHeight(1);\r
 \r
         getListView().setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));\r
         getListView().setDividerHeight(1);\r
 \r
-        populateFileList();\r
+        Intent intent = getActivity().getIntent();\r
+        OCFile directory = intent.getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
+        mFile = directory;\r
+        \r
+        listDirectory(directory);\r
     }\r
 \r
     @Override\r
     public void onStart() {\r
     }\r
 \r
     @Override\r
     public void onStart() {\r
-                \r
         // Create a placeholder upon launch\r
         View fragmentContainer = getActivity().findViewById(R.id.file_details_container);\r
         if (fragmentContainer != null) {\r
         // Create a placeholder upon launch\r
         View fragmentContainer = getActivity().findViewById(R.id.file_details_container);\r
         if (fragmentContainer != null) {\r
@@ -89,22 +95,23 @@ public class FileListFragment extends FragmentListView {
             throw new IndexOutOfBoundsException("Incorrect item selected");\r
         }\r
         OCFile file = mFiles.get(position);\r
             throw new IndexOutOfBoundsException("Incorrect item selected");\r
         }\r
         OCFile file = mFiles.get(position);\r
-\r
+        mFile = file;\r
+        \r
         // Update ActionBarPath\r
         if (file.getMimetype().equals("DIR")) {\r
             String dirname = file.getFileName();\r
 \r
             mDirNames.push(dirname);\r
             ((FileDisplayActivity) getActivity()).pushPath(dirname);\r
         // Update ActionBarPath\r
         if (file.getMimetype().equals("DIR")) {\r
             String dirname = file.getFileName();\r
 \r
             mDirNames.push(dirname);\r
             ((FileDisplayActivity) getActivity()).pushPath(dirname);\r
-\r
-            populateFileList();\r
+            \r
+            listDirectory(file);\r
             resetFileFragment();\r
 \r
             return;\r
         }\r
 \r
         Intent showDetailsIntent = new Intent(getActivity(), FileDetailActivity.class);\r
             resetFileFragment();\r
 \r
             return;\r
         }\r
 \r
         Intent showDetailsIntent = new Intent(getActivity(), FileDetailActivity.class);\r
-        showDetailsIntent.putExtra(FileDetailFragment.FILE, file);\r
+        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);\r
         showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
 \r
         // If we are on a large device -> update fragment\r
         showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
 \r
         // If we are on a large device -> update fragment\r
@@ -151,26 +158,53 @@ public class FileListFragment extends FragmentListView {
      */\r
     public void onNavigateUp() {\r
         mDirNames.pop();\r
      */\r
     public void onNavigateUp() {\r
         mDirNames.pop();\r
-        populateFileList();\r
+        OCFile parentDir = null;\r
+        \r
+        if(mFile != null){\r
+            parentDir = mStorageManager.getFileById(mFile.getParentId());\r
+            mFile = parentDir;\r
+        }\r
+        \r
+        listDirectory(parentDir);\r
         resetFileFragment();\r
     }\r
 \r
     /**\r
         resetFileFragment();\r
     }\r
 \r
     /**\r
-     * Lists the directory\r
+     * Calls {@link FileListFragment#listDirectory(OCFile)} with a null parameter\r
      */\r
      */\r
-    public void populateFileList() {\r
-        String s = "/";\r
-        for (String a : mDirNames)\r
-            s += a + "/";\r
-        Log.e("ASD", s);\r
-\r
-        mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
-        OCFile file = mStorageManager.getFileByPath(s);\r
-        mFiles = mStorageManager.getDirectoryContent(file);\r
+    public void listDirectory(){\r
+        listDirectory(null);\r
+    }\r
+    \r
+    /**\r
+     * Lists the given directory on the view. When the input parameter is null,\r
+     * it will either refresh the last known directory, or list the root\r
+     * if there never was a directory.\r
+     * \r
+     * @param directory File to be listed\r
+     */\r
+    public void listDirectory(OCFile directory) {\r
+                \r
+        // Check input parameters for null\r
+        if(directory == null){\r
+            if(mFile != null){\r
+                directory = mFile;\r
+            } else {\r
+                directory = mStorageManager.getFileByPath("/");\r
+            }\r
+        }\r
+        \r
+        // If that's not a directory -> List its parent\r
+        if(!directory.isDirectory()){\r
+            Log.w(TAG, "You see, that is not a directory -> " + directory.toString());\r
+            directory = mStorageManager.getFileById(directory.getParentId());\r
+        }\r
+        \r
+        mFiles = mStorageManager.getDirectoryContent(directory);\r
         if (mFiles == null || mFiles.size() == 0) {\r
             Toast.makeText(getActivity(), "There are no files here", Toast.LENGTH_LONG).show();\r
         }\r
         if (mFiles == null || mFiles.size() == 0) {\r
             Toast.makeText(getActivity(), "There are no files here", Toast.LENGTH_LONG).show();\r
         }\r
-        setListAdapter(new FileListListAdapter(file, mStorageManager, getActivity()));\r
+        setListAdapter(new FileListListAdapter(directory, mStorageManager, getActivity()));\r
     }\r
 \r
     @Override\r
     }\r
 \r
     @Override\r
@@ -178,48 +212,5 @@ public class FileListFragment extends FragmentListView {
         super.onSaveInstanceState(outState);\r
         outState.putParcelable("ACCOUNT", mAccount);\r
     }\r
         super.onSaveInstanceState(outState);\r
         outState.putParcelable("ACCOUNT", mAccount);\r
     }\r
-    \r
-    // TODO: Delete this testing stuff.\r
-    /*\r
-     * private void addContact(Account account, String name, String username) {\r
-     * Log.i("ASD", "Adding contact: " + name);\r
-     * ArrayList<ContentProviderOperation> operationList = new\r
-     * ArrayList<ContentProviderOperation>();\r
-     * \r
-     * //Create our RawContact ContentProviderOperation.Builder builder =\r
-     * ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);\r
-     * builder.withValue(RawContacts.ACCOUNT_NAME, account.name);\r
-     * builder.withValue(RawContacts.ACCOUNT_TYPE, account.type);\r
-     * builder.withValue(RawContacts.SYNC1, username);\r
-     * operationList.add(builder.build());\r
-     * \r
-     * //Create a Data record of common type 'StructuredName' for our RawContact\r
-     * builder =\r
-     * ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
-     * builder\r
-     * .withValueBackReference(ContactsContract.CommonDataKinds.StructuredName\r
-     * .RAW_CONTACT_ID, 0); builder.withValue(ContactsContract.Data.MIMETYPE,\r
-     * ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);\r
-     * builder\r
-     * .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,\r
-     * name); operationList.add(builder.build());\r
-     * \r
-     * //Create a Data record of custom type\r
-     * "vnd.android.cursor.item/vnd.fm.last.android.profile" to display a link\r
-     * to the Last.fm profile builder =\r
-     * ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);\r
-     * builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0);\r
-     * builder.withValue(ContactsContract.Data.MIMETYPE,\r
-     * "vnd.android.cursor.item/vnd.owncloud.contact.profile");\r
-     * builder.withValue(ContactsContract.Data.DATA1, username);\r
-     * builder.withValue(ContactsContract.Data.DATA2, "Last.fm Profile");\r
-     * builder.withValue(ContactsContract.Data.DATA3, "View profile");\r
-     * operationList.add(builder.build());\r
-     * \r
-     * try {\r
-     * getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY,\r
-     * operationList); } catch (Exception e) { Log.e("ASD",\r
-     * "Something went wrong during creation! " + e); e.printStackTrace(); } }\r
-     */\r
 \r
 }\r
 \r
 }\r