summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-01-19 17:18:19 -0800
committerJohn Reck <jreck@google.com>2011-01-19 17:18:19 -0800
commit85e3d6f2f852d43488f29124bbd9599161ac380a (patch)
tree8e9358ca978148740658132afe4728ba544171b4 /src
parent54260f25d34969a7337cd9138f1d5be607b0424b (diff)
downloadpackages_apps_Browser-85e3d6f2f852d43488f29124bbd9599161ac380a.zip
packages_apps_Browser-85e3d6f2f852d43488f29124bbd9599161ac380a.tar.gz
packages_apps_Browser-85e3d6f2f852d43488f29124bbd9599161ac380a.tar.bz2
Added checks to guard against illegal state
Bug: 3368524 Added checks to prevent the combo view from trying to remove a fragment it never added. Change-Id: If5da138a547718bbb49cda25288d54616282f94a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/CombinedBookmarkHistoryView.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/com/android/browser/CombinedBookmarkHistoryView.java b/src/com/android/browser/CombinedBookmarkHistoryView.java
index 8b58d2e..6c03746 100644
--- a/src/com/android/browser/CombinedBookmarkHistoryView.java
+++ b/src/com/android/browser/CombinedBookmarkHistoryView.java
@@ -57,6 +57,7 @@ public class CombinedBookmarkHistoryView extends LinearLayout
final static String STARTING_FRAGMENT = "fragment";
+ final static int INVALID_ID = 0;
final static int FRAGMENT_ID_BOOKMARKS = 1;
final static int FRAGMENT_ID_HISTORY = 2;
@@ -66,7 +67,7 @@ public class CombinedBookmarkHistoryView extends LinearLayout
private Bundle mExtras;
- int mCurrentFragment;
+ int mCurrentFragment = INVALID_ID;
ActionBar.Tab mTabBookmarks;
ActionBar.Tab mTabHistory;
@@ -179,7 +180,7 @@ public class CombinedBookmarkHistoryView extends LinearLayout
// This is done because history uses orientation-specific padding
FragmentManager fm = mActivity.getFragmentManager();
mHistory = BrowserHistoryPage.newInstance(mUiController, mHistory.getArguments());
- fm.openTransaction().replace(R.id.fragment, mHistory).commit();
+ fm.beginTransaction().replace(R.id.fragment, mHistory).commit();
}
}
@@ -241,14 +242,17 @@ public class CombinedBookmarkHistoryView extends LinearLayout
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- FragmentManager fm = mActivity.getFragmentManager();
- FragmentTransaction transaction = fm.beginTransaction();
- if (mCurrentFragment == FRAGMENT_ID_BOOKMARKS) {
- transaction.remove(mBookmarks);
- } else if (mCurrentFragment == FRAGMENT_ID_HISTORY) {
- transaction.remove(mHistory);
+ if (mCurrentFragment != INVALID_ID) {
+ FragmentManager fm = mActivity.getFragmentManager();
+ FragmentTransaction transaction = fm.beginTransaction();
+ if (mCurrentFragment == FRAGMENT_ID_BOOKMARKS) {
+ transaction.remove(mBookmarks);
+ } else if (mCurrentFragment == FRAGMENT_ID_HISTORY) {
+ transaction.remove(mHistory);
+ }
+ transaction.commit();
+ mCurrentFragment = INVALID_ID;
}
- transaction.commit();
mUiController.unregisterOptionsMenuHandler(this);
}