Merge branch 'fix_protocol_send_mail' into fix_logs_change_orientation
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / LogHistoryActivity.java
index ce2d0ce..793b3d9 100644 (file)
@@ -53,12 +53,15 @@ public class LogHistoryActivity extends SherlockFragmentActivity  {
 
     private static final String MAIL_ATTACHMENT_TYPE = "text/plain";
 
+    private static final String KEY_LOG_TEXT = "LOG_TEXT";
+
     private static final String TAG = LogHistoryActivity.class.getSimpleName();
 
     private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
 
     private String mLogPath = FileStorageUtils.getLogPath();
     private File logDIR = null;
+    private String mLogText;
 
 
     @Override
@@ -72,6 +75,7 @@ public class LogHistoryActivity extends SherlockFragmentActivity  {
         actionBar.setDisplayHomeAsUpEnabled(true);
         Button deleteHistoryButton = (Button) findViewById(R.id.deleteLogHistoryButton);
         Button sendHistoryButton = (Button) findViewById(R.id.sendLogHistoryButton);
+        TextView logTV = (TextView) findViewById(R.id.logTV);
 
         deleteHistoryButton.setOnClickListener(new OnClickListener() {
             
@@ -91,20 +95,22 @@ public class LogHistoryActivity extends SherlockFragmentActivity  {
             }
         });
 
-        if (mLogPath != null) {
-            logDIR = new File(mLogPath);
-        }
-
-        if (logDIR != null && logDIR.isDirectory()) {
-            // Show a dialog while log data is being loaded
-            showLoadingDialog();
-
-            TextView logTV = (TextView) findViewById(R.id.logTV);
+        if (savedInstanceState == null) {
+            if (mLogPath != null) {
+                logDIR = new File(mLogPath);
+            }
 
-            // Start a new thread that will load all the log data
-            LoadingLogTask task = new LoadingLogTask(logTV);
-            task.execute();
+            if (logDIR != null && logDIR.isDirectory()) {
+                // Show a dialog while log data is being loaded
+                showLoadingDialog();
 
+                // Start a new thread that will load all the log data
+                LoadingLogTask task = new LoadingLogTask(logTV);
+                task.execute();
+            }
+        } else {
+            mLogText = savedInstanceState.getString(KEY_LOG_TEXT);
+            logTV.setText(mLogText);
         }
     }
 
@@ -189,7 +195,8 @@ public class LogHistoryActivity extends SherlockFragmentActivity  {
             if (textViewReference != null && result != null) {
                 final TextView logTV = textViewReference.get();
                 if (logTV != null) {
-                    logTV.setText(result);
+                    mLogText = result;
+                    logTV.setText(mLogText);
                     dismissLoadingDialog();
                 }
             }
@@ -264,4 +271,12 @@ public class LogHistoryActivity extends SherlockFragmentActivity  {
             loading.dismiss();
         }
     }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+
+        /// global state
+        outState.putString(KEY_LOG_TEXT, mLogText);
+    }
 }
\ No newline at end of file