diff options
author | Leon Scroggins <scroggo@google.com> | 2010-12-07 15:22:21 -0500 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2010-12-07 17:00:52 -0500 |
commit | 1961ed2f2856ca0993c8c4d15924bbb4e4ef98c0 (patch) | |
tree | 2bceecc682ed5b954fa5fd259536b5bd1f71d45d /src/com/android/browser/Controller.java | |
parent | ffce12cded5227cc94752de75e3f00acdbf9c90f (diff) | |
download | packages_apps_browser-1961ed2f2856ca0993c8c4d15924bbb4e4ef98c0.zip packages_apps_browser-1961ed2f2856ca0993c8c4d15924bbb4e4ef98c0.tar.gz packages_apps_browser-1961ed2f2856ca0993c8c4d15924bbb4e4ef98c0.tar.bz2 |
Update each Tab when the bookmarks database changes.
Bug:3222677
When the bookmarks database changes, we may have added or
removed a bookmark. For each Tab, make sure that it knows
whether or not it is a bookmark, and update the UI
accordingly.
Change-Id: Ie91008973c2841dc7367e38ad5db40bf25b1dddf
Diffstat (limited to 'src/com/android/browser/Controller.java')
-rw-r--r-- | src/com/android/browser/Controller.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index a2caf90..e433e29 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -33,6 +33,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; +import android.database.ContentObserver; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; @@ -191,6 +192,9 @@ public class Controller private boolean mLoadStopped; private Handler mHandler; + // Checks to see when the bookmarks database has changed, and updates the + // Tabs' notion of whether they represent bookmarked sites. + private ContentObserver mBookmarksObserver; private static class ClearThumbnails extends AsyncTask<File, Void, Void> { @Override @@ -221,6 +225,18 @@ public class Controller mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Browser"); startHandler(); + mBookmarksObserver = new ContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange) { + int size = mTabControl.getTabCount(); + for (int i = 0; i < size; i++) { + mTabControl.getTab(i).updateBookmarkedStatus(); + } + } + + }; + browser.getContentResolver().registerContentObserver( + BrowserContract.Bookmarks.CONTENT_URI, true, mBookmarksObserver); mNetworkHandler = new NetworkStateHandler(mActivity, this); // Start watching the default geolocation permissions @@ -668,6 +684,7 @@ public class Controller dismissSubWindow(t); removeTab(t); } + mActivity.getContentResolver().unregisterContentObserver(mBookmarksObserver); // Destroy all the tabs mTabControl.destroy(); WebIconDatabase.getInstance().close(); |