New Layout for FileDetailsFragment (needs to be redone with
authorLennart Rosam <lennart@familie-rosam.de>
Fri, 18 May 2012 12:05:21 +0000 (14:05 +0200)
committerLennart Rosam <lennart@familie-rosam.de>
Fri, 18 May 2012 12:05:21 +0000 (14:05 +0200)
RelativeLayout for better performance), Fix AppCrashes on rotation
change

res/layout-large-land/files.xml
res/layout/file_activity_details.xml
res/layout/file_details_fragment.xml
src/eu/alefzero/owncloud/ui/activity/FileDetailActivity.java
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java
src/eu/alefzero/owncloud/ui/fragment/FileListFragment.java

index aadb269..32d86b0 100644 (file)
@@ -19,6 +19,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
     android:layout_width="fill_parent"\r
     android:layout_height="fill_parent"\r
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
     android:layout_width="fill_parent"\r
     android:layout_height="fill_parent"\r
+    android:background="@color/owncloud_white"\r
     android:orientation="horizontal" >\r
 \r
     <LinearLayout\r
     android:orientation="horizontal" >\r
 \r
     <LinearLayout\r
         android:layout_height="fill_parent"\r
         android:layout_weight="2" >\r
 \r
         android:layout_height="fill_parent"\r
         android:layout_weight="2" >\r
 \r
-        <fragment\r
-            android:id="@+id/fileDetail"\r
-            android:layout_width="fill_parent"\r
-            android:layout_height="fill_parent"\r
-            class="eu.alefzero.owncloud.ui.fragment.FileDetailFragment" >\r
-\r
-            <!-- Preview: layout=@layout/file_details_empty -->\r
-        </fragment>\r
+        <!-- Preview: layout=@layout/file_details_empty -->\r
     </LinearLayout>\r
 \r
 </LinearLayout>
\ No newline at end of file
     </LinearLayout>\r
 \r
 </LinearLayout>
\ No newline at end of file
index 664d756..f37270b 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>\r
 <?xml version="1.0" encoding="utf-8"?>\r
-<!-- \r
+<!--\r
   ownCloud Android client application\r
 \r
   Copyright (C) 2012  Bartek Przybylski\r
   ownCloud Android client application\r
 \r
   Copyright (C) 2012  Bartek Przybylski\r
   GNU General Public License for more details.\r
 \r
   You should have received a copy of the GNU General Public License\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
+  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:layout_width="fill_parent"\r
     android:layout_height="fill_parent"\r
     android:orientation="vertical" >\r
 \r
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
     android:layout_width="fill_parent"\r
     android:layout_height="fill_parent"\r
     android:orientation="vertical" >\r
 \r
-<fragment\r
-    android:id="@+id/fileDetail"\r
-    android:layout_width="fill_parent"\r
-    android:layout_height="fill_parent"\r
-    class="eu.alefzero.owncloud.ui.fragment.FileDetailFragment" />\r
+    <LinearLayout\r
+        android:id="@+id/fragment"\r
+            android:layout_width="fill_parent"\r
+            android:layout_height="fill_parent" >\r
+            <!-- Preview: layout=@layout/file_details_fragment -->\r
+    </LinearLayout>\r
 \r
 </LinearLayout>
\ No newline at end of file
 \r
 </LinearLayout>
\ No newline at end of file
index 99c09bc..16e7404 100644 (file)
         android:layout_height="fill_parent" >
 
         <LinearLayout
         android:layout_height="fill_parent" >
 
         <LinearLayout
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical" >
 
             android:layout_height="wrap_content"
             android:orientation="vertical" >
 
-            <ImageView
-                android:id="@+id/fdIcon"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:layout_marginLeft="16dp"
-                android:src="@drawable/file" />
-
-            <TextView
-                android:id="@+id/fdFilename"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignBottom="@+id/fdIcon"
-                android:layout_centerHorizontal="true"
-                android:text="file.name"
-                android:textAppearance="?android:attr/textAppearanceLarge" />
-
             <LinearLayout
             <LinearLayout
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content" >
-
-                <TextView
-                    android:id="@+id/fdType"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_above="@+id/fdCreatedLabel"
-                    android:layout_alignLeft="@+id/fdFilename"
-                    android:text="JPG Image"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
-
-                <TextView
-                    android:id="@+id/fdSize"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_above="@+id/fdSizeLabel"
-                    android:layout_alignLeft="@+id/fdFilename"
-                    android:text="389 KB"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal" >
 
 
-                <TextView
-                    android:id="@+id/fdCreated"
+                <ImageView
+                    android:id="@+id/fdIcon"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_above="@+id/fdModifiedLabel"
-                    android:layout_alignLeft="@+id/fdFilename"
-                    android:text="2012/05/18 12:23 PM"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
+                    android:layout_marginLeft="16dp"
+                    android:layout_marginTop="4dp"
+                    android:src="@drawable/file" />
 
                 <TextView
 
                 <TextView
-                    android:id="@+id/fdModified"
+                    android:id="@+id/fdFilename"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_alignBaseline="@+id/fdModifiedLabel"
-                    android:layout_alignBottom="@+id/fdModifiedLabel"
-                    android:layout_alignLeft="@+id/fdCreated"
-                    android:text="2012/05/19 02:56 PM"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
+                    android:layout_marginLeft="4dp"
+                    android:text="file.name"
+                    android:textAppearance="?android:attr/textAppearanceLarge" />
+            </LinearLayout>
 
 
-                <ImageView
-                    android:id="@+id/fdPreview"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_below="@+id/fdModified"
-                    android:layout_centerHorizontal="true"
-                    android:layout_marginTop="16dp"
-                    android:src="@drawable/owncloud_logo" />
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:orientation="horizontal" >
 
                 <LinearLayout
 
                 <LinearLayout
-                    android:layout_width="wrap_content"
+                    android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_alignParentLeft="true"
-                    android:layout_alignParentTop="true" >
+                    android:layout_weight="1"
+                    android:orientation="vertical"
+                    android:paddingLeft="16dp" >
 
                     <TextView
                         android:id="@+id/fdTypeLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
 
                     <TextView
                         android:id="@+id/fdTypeLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignLeft="@+id/fdIcon"
-                        android:layout_below="@+id/fdIcon"
                         android:layout_marginTop="24dp"
                         android:text="@string/filedetails_type"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                         android:layout_marginTop="24dp"
                         android:text="@string/filedetails_type"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                         android:id="@+id/fdSizeLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:id="@+id/fdSizeLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignLeft="@+id/fdIcon"
-                        android:layout_below="@+id/fdTypeLabel"
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_size"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_size"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                         android:id="@+id/fdCreatedLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:id="@+id/fdCreatedLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignLeft="@+id/fdIcon"
-                        android:layout_below="@+id/fdSizeLabel"
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_created"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_created"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                         android:id="@+id/fdModifiedLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:id="@+id/fdModifiedLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignLeft="@+id/fdIcon"
-                        android:layout_below="@+id/fdCreatedLabel"
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_modified"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                 </LinearLayout>
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_modified"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                 </LinearLayout>
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="2"
+                    android:orientation="vertical"
+                    android:paddingLeft="4dp" >
+
+                    <TextView
+                        android:id="@+id/fdType"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="24dp"
+                        android:text="JPG Image"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                    <TextView
+                        android:id="@+id/fdSize"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="12dp"
+                        android:text="389 KB"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                    <TextView
+                        android:id="@+id/fdCreated"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="12dp"
+                        android:text="2012/05/18 12:23 PM"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                    <TextView
+                        android:id="@+id/fdModified"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="12dp"
+                        android:text="2012/05/19 02:56 PM"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+                </LinearLayout>
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical" >
+
+                <ImageView
+                    android:id="@+id/fdPreview"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="16dp"
+                    android:layout_gravity="center_horizontal"
+                    android:src="@drawable/owncloud_logo" />
+
+                <Button
+                    android:id="@+id/fdDownloadBtn"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="12dp"
+                    android:layout_gravity="center_horizontal"
+                    android:text="@string/filedetails_download" />
             </LinearLayout>
         </LinearLayout>
     </ScrollView>
 
             </LinearLayout>
         </LinearLayout>
     </ScrollView>
 
-    <Button
-        android:id="@+id/fdDownloadBtn"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_below="@+id/fdScrollView"
-        android:layout_centerHorizontal="true"
-        android:text="@string/filedetails_download" />
-
 </LinearLayout>
\ No newline at end of file
 </LinearLayout>
\ No newline at end of file
index 80898cf..cb899f6 100644 (file)
@@ -43,11 +43,19 @@ public class FileDetailActivity extends SherlockFragmentActivity {
         getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
         setContentView(R.layout.file_activity_details);\r
 \r
         getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
         setContentView(R.layout.file_activity_details);\r
 \r
-        mFileDetail = new FileDetailFragment(getIntent());\r
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
-        ft.add(R.id.fileDetail, mFileDetail);\r
+        mFileDetail = new FileDetailFragment();\r
+        ft.add(R.id.fragment, mFileDetail, "FileDetails");\r
         ft.commit();\r
 \r
     }\r
 \r
         ft.commit();\r
 \r
     }\r
 \r
+    @Override\r
+    protected void onResume() {\r
+        super.onResume();\r
+        mFileDetail.updateFileDetails(getIntent());\r
+    }\r
+    \r
+    \r
+\r
 }\r
 }\r
index e4b33f1..e887876 100644 (file)
@@ -17,7 +17,6 @@
  */\r
 package eu.alefzero.owncloud.ui.fragment;\r
 \r
  */\r
 package eu.alefzero.owncloud.ui.fragment;\r
 \r
-import android.app.FragmentTransaction;\r
 import android.content.BroadcastReceiver;\r
 import android.content.Context;\r
 import android.content.Intent;\r
 import android.content.BroadcastReceiver;\r
 import android.content.Context;\r
 import android.content.Intent;\r
@@ -52,35 +51,33 @@ public class FileDetailFragment extends SherlockFragment implements
 \r
     public static final String FILE = "FILE";\r
 \r
 \r
     public static final String FILE = "FILE";\r
 \r
-    private Intent mIntent;\r
-    //private View mView;\r
     private DownloadFinishReceiver mDownloadFinishReceiver;\r
     private DownloadFinishReceiver mDownloadFinishReceiver;\r
-    private OCFile mFile;\r
-\r
+    private Intent mIntent;\r
     private int mLayout;\r
     private int mLayout;\r
-    private boolean mEmptyLayout;\r
+    private View mView;\r
+    private OCFile mFile;\r
 \r
     /**\r
 \r
     /**\r
-     * Default constructor. When inflated by android -> display empty layout\r
+     * Default constructor - contains real layout\r
      */\r
      */\r
-    public FileDetailFragment() {\r
-        mLayout = R.layout.file_details_empty;\r
-        mEmptyLayout = true;\r
+    public FileDetailFragment(){\r
+        mLayout = R.layout.file_details_fragment;\r
     }\r
     }\r
-\r
+    \r
     /**\r
     /**\r
-     * Custom construtor. Use with a {@link FragmentTransaction}. The intent has\r
-     * to contain {@link FileDetailFragment#FILE} with an OCFile and also\r
-     * {@link FileDownloader#EXTRA_ACCOUNT} with the account.\r
+     * Creates a dummy layout. For use if the user never has\r
+     * tapped on a file before\r
      * \r
      * \r
-     * @param intent Intent with an account and a file in it for rendering\r
+     * @param useEmptyView If true, use empty layout\r
      */\r
      */\r
-    public FileDetailFragment(Intent intent) {\r
-        mLayout = R.layout.file_details_fragment;\r
-        mIntent = intent;\r
-        mEmptyLayout = false;\r
+    public FileDetailFragment(boolean useEmptyView){\r
+        if(useEmptyView){\r
+            mLayout = R.layout.file_details_empty;\r
+        } else {\r
+            mLayout = R.layout.file_details_fragment;\r
+        }\r
     }\r
     }\r
-\r
+    \r
     @Override\r
     public void onResume() {\r
         super.onResume();\r
     @Override\r
     public void onResume() {\r
         super.onResume();\r
@@ -138,31 +135,7 @@ public class FileDetailFragment extends SherlockFragment implements
             downloadButton.setOnClickListener(this);\r
         }\r
     }\r
             downloadButton.setOnClickListener(this);\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
-        return view;\r
-    }\r
-\r
-    @Override\r
-    public void onStart() {\r
-        super.onStart();\r
-        \r
-        // Fill in required information about file displaying\r
-        if(mIntent == null){\r
-            mIntent = getActivity().getIntent();\r
-        }\r
-        \r
-        // Fill in the details if the layout is not empty\r
-        if(!mEmptyLayout){\r
-            updateFileDetails();\r
-        }\r
-        \r
-    }\r
-\r
+    \r
     private void setFilename(String filename) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdFilename);\r
         if (tv != null)\r
     private void setFilename(String filename) {\r
         TextView tv = (TextView) getView().findViewById(R.id.fdFilename);\r
         if (tv != null)\r
@@ -181,20 +154,25 @@ public class FileDetailFragment extends SherlockFragment implements
             tv.setText(DisplayUtils.bitsToHumanReadable(filesize));\r
     }\r
 \r
             tv.setText(DisplayUtils.bitsToHumanReadable(filesize));\r
     }\r
 \r
-    /**\r
-     * Use this to check if the correct layout is loaded. When android\r
-     * instanciates this class using the default constructor, the layout will be\r
-     * empty.\r
-     * \r
-     * Once a user touches a file for the first time, you must instanciate a new\r
-     * Fragment with the new FileDetailFragment(true) to inflate the actual\r
-     * details\r
-     * \r
-     * @return If the layout is empty, this method will return true, otherwise\r
-     *         false\r
-     */\r
-    public boolean isEmptyLayout() {\r
-        return mEmptyLayout;\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
+            mIntent = getActivity().getIntent();\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
     }\r
 \r
     @Override\r
index 659d337..0aeea16 100644 (file)
@@ -52,6 +52,8 @@ public class FileListFragment extends FragmentListView {
     private Stack<String> mDirNames;\r
     private Vector<OCFile> mFiles;\r
     private DataStorageManager mStorageManager;\r
     private Stack<String> mDirNames;\r
     private Vector<OCFile> mFiles;\r
     private DataStorageManager mStorageManager;\r
+    private FileDetailFragment mFileDetailsDetailFragment;\r
+    private boolean mIsLargeDevice = false;\r
 \r
     public FileListFragment() {\r
         mDirNames = new Stack<String>();\r
 \r
     public FileListFragment() {\r
         mDirNames = new Stack<String>();\r
@@ -62,14 +64,29 @@ 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
-        getListView().setDivider(\r
-                getResources().getDrawable(R.drawable.uploader_list_separator));\r
+        getListView().setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));\r
         getListView().setDividerHeight(1);\r
 \r
         populateFileList();\r
     }\r
 \r
     @Override\r
         getListView().setDividerHeight(1);\r
 \r
         populateFileList();\r
     }\r
 \r
     @Override\r
+    public void onStart() {\r
+        // Inflate the original fragment for better performance\r
+        mFileDetailsDetailFragment = new FileDetailFragment();\r
+        \r
+        // Create a placeholder upon launch\r
+        View fragmentContainer = getActivity().findViewById(R.id.file_details_container);\r
+        if (fragmentContainer != null) {\r
+            mIsLargeDevice = true;\r
+            FragmentTransaction transaction = getFragmentManager().beginTransaction();\r
+            transaction.replace(R.id.file_details_container, new FileDetailFragment(true));\r
+            transaction.commit();\r
+        }\r
+        super.onStart();\r
+    }\r
+\r
+    @Override\r
     public void onItemClick(AdapterView<?> l, View v, int position, long id) {\r
         if (mFiles.size() <= position) {\r
             throw new IndexOutOfBoundsException("Incorrect item selected");\r
     public void onItemClick(AdapterView<?> l, View v, int position, long id) {\r
         if (mFiles.size() <= position) {\r
             throw new IndexOutOfBoundsException("Incorrect item selected");\r
@@ -85,68 +102,50 @@ public class FileListFragment extends FragmentListView {
 \r
             populateFileList();\r
             resetFileFragment();\r
 \r
             populateFileList();\r
             resetFileFragment();\r
-            \r
+\r
             return;\r
         }\r
 \r
             return;\r
         }\r
 \r
-        Intent showDetailsIntent = new Intent(getActivity(),\r
-                FileDetailActivity.class);\r
+        Intent showDetailsIntent = new Intent(getActivity(), FileDetailActivity.class);\r
         showDetailsIntent.putExtra(FileDetailFragment.FILE, file);\r
         showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
 \r
         showDetailsIntent.putExtra(FileDetailFragment.FILE, file);\r
         showDetailsIntent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);\r
 \r
-        // Try to find by tag first\r
-        FileDetailFragment fd = (FileDetailFragment) getFragmentManager()\r
-                .findFragmentByTag("FileDetails");\r
-\r
-        // Could be the first time the user has touched a file. find by id\r
-        if (fd == null) {\r
-            fd = (FileDetailFragment) getFragmentManager().findFragmentById(\r
-                    R.id.fileDetail);\r
-        }\r
-\r
-        // Tablets will have this fragment, phones not. Could still be null\r
-        if (fd != null) {\r
-\r
-            if (fd.isEmptyLayout()) {\r
-                // True, if this is the first time a user taps on a file\r
-                FragmentTransaction transaction = getFragmentManager()\r
-                        .beginTransaction();\r
-                fd = new FileDetailFragment(showDetailsIntent);\r
-                transaction.replace(R.id.fileDetail, fd, "FileDetails");\r
+        // If we are on a large device -> update fragment\r
+        if (mIsLargeDevice) {\r
+            FileDetailFragment fileDetails = (FileDetailFragment) getFragmentManager().findFragmentByTag("FileDetails");\r
+            if (fileDetails == null) {\r
+                FragmentTransaction transaction = getFragmentManager().beginTransaction();\r
+                transaction.replace(R.id.file_details_container, mFileDetailsDetailFragment, "FileDetails");\r
                 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);\r
                 transaction.commit();\r
             } else {\r
                 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);\r
                 transaction.commit();\r
             } else {\r
-                fd.updateFileDetails(showDetailsIntent);\r
+                fileDetails.updateFileDetails(showDetailsIntent);\r
             }\r
             }\r
-\r
         } else {\r
             startActivity(showDetailsIntent);\r
         }\r
     }\r
 \r
     /**\r
         } else {\r
             startActivity(showDetailsIntent);\r
         }\r
     }\r
 \r
     /**\r
-     * Resets the FileDetailsFragment on Tablets\r
-     * so that it always displays "Tab on a file to display it's details" \r
+     * Resets the FileDetailsFragment on Tablets so that it always displays\r
+     * "Tab on a file to display it's details"\r
      */\r
     private void resetFileFragment() {\r
         FileDetailFragment fileDetails = (FileDetailFragment) getFragmentManager().findFragmentByTag("FileDetails");\r
      */\r
     private void resetFileFragment() {\r
         FileDetailFragment fileDetails = (FileDetailFragment) getFragmentManager().findFragmentByTag("FileDetails");\r
-        if(fileDetails != null){\r
+        if (fileDetails != null) {\r
             FragmentTransaction transaction = getFragmentManager().beginTransaction();\r
             transaction.remove(fileDetails);\r
             FragmentTransaction transaction = getFragmentManager().beginTransaction();\r
             transaction.remove(fileDetails);\r
-            transaction.add(R.id.file_details_container, new FileDetailFragment());\r
+            transaction.add(R.id.file_details_container, new FileDetailFragment(true));\r
             transaction.commit();\r
         }\r
     }\r
 \r
     @Override\r
             transaction.commit();\r
         }\r
     }\r
 \r
     @Override\r
-    public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,\r
-            long arg3) {\r
+    public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {\r
         ClipData.Item item = new ClipData.Item("ASD");\r
         ClipData.Item item = new ClipData.Item("ASD");\r
-        ClipDescription cd = new ClipDescription("ASD",\r
-                new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });\r
+        ClipDescription cd = new ClipDescription("ASD", new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });\r
         ClipData dragData = new ClipData(cd, item);\r
         ClipData dragData = new ClipData(cd, item);\r
-        arg1.startDrag(dragData,\r
-                new View.DragShadowBuilder(arg0.getChildAt(arg2)), null, 0);\r
+        arg1.startDrag(dragData, new View.DragShadowBuilder(arg0.getChildAt(arg2)), null, 0);\r
         return true;\r
     }\r
 \r
         return true;\r
     }\r
 \r
@@ -168,16 +167,13 @@ public class FileListFragment extends FragmentListView {
             s += a + "/";\r
         Log.e("ASD", s);\r
 \r
             s += a + "/";\r
         Log.e("ASD", s);\r
 \r
-        mStorageManager = new FileDataStorageManager(mAccount, getActivity()\r
-                .getContentResolver());\r
+        mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
         OCFile file = mStorageManager.getFileByPath(s);\r
         mFiles = mStorageManager.getDirectoryContent(file);\r
         if (mFiles == null || mFiles.size() == 0) {\r
         OCFile file = mStorageManager.getFileByPath(s);\r
         mFiles = mStorageManager.getDirectoryContent(file);\r
         if (mFiles == null || mFiles.size() == 0) {\r
-            Toast.makeText(getActivity(), "There are no files here",\r
-                    Toast.LENGTH_LONG).show();\r
+            Toast.makeText(getActivity(), "There are no files here", Toast.LENGTH_LONG).show();\r
         }\r
         }\r
-        setListAdapter(new FileListListAdapter(file, mStorageManager,\r
-                getActivity()));\r
+        setListAdapter(new FileListListAdapter(file, mStorageManager, getActivity()));\r
     }\r
 \r
     // TODO: Delete this testing stuff.\r
     }\r
 \r
     // TODO: Delete this testing stuff.\r