mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-24 16:54:08 +00:00
Bug 671131 - (Part 2) Make observer to update history tab when history item is removed. r=bnicholson
This commit is contained in:
parent
9e2144459f
commit
027ab6d4f5
@ -41,6 +41,7 @@ package org.mozilla.gecko;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@ -102,6 +103,7 @@ public class AwesomeBarTabs extends TabHost {
|
||||
private View.OnTouchListener mListTouchListener;
|
||||
private JSONArray mSearchEngines;
|
||||
private ContentResolver mContentResolver;
|
||||
private ContentObserver mContentObserver;
|
||||
|
||||
private BookmarksQueryTask mBookmarksQueryTask;
|
||||
private HistoryQueryTask mHistoryQueryTask;
|
||||
@ -581,6 +583,17 @@ public class AwesomeBarTabs extends TabHost {
|
||||
result.second
|
||||
);
|
||||
|
||||
if (mContentObserver == null) {
|
||||
// Register an observer to update the history tab contents if they change.
|
||||
mContentObserver = new ContentObserver(GeckoAppShell.getHandler()) {
|
||||
public void onChange(boolean selfChange) {
|
||||
mHistoryQueryTask = new HistoryQueryTask();
|
||||
mHistoryQueryTask.execute();
|
||||
}
|
||||
};
|
||||
BrowserDB.registerHistoryObserver(mContentResolver, mContentObserver);
|
||||
}
|
||||
|
||||
final ExpandableListView historyList =
|
||||
(ExpandableListView) findViewById(R.id.history_list);
|
||||
|
||||
@ -738,6 +751,7 @@ public class AwesomeBarTabs extends TabHost {
|
||||
mInflated = false;
|
||||
mSearchEngines = new JSONArray();
|
||||
mContentResolver = context.getContentResolver();
|
||||
mContentObserver = null;
|
||||
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
||||
@ -1001,6 +1015,9 @@ public class AwesomeBarTabs extends TabHost {
|
||||
if (bookmarksCursor != null)
|
||||
bookmarksCursor.close();
|
||||
}
|
||||
|
||||
if (mContentObserver != null)
|
||||
BrowserDB.unregisterContentObserver(mContentResolver, mContentObserver);
|
||||
}
|
||||
|
||||
public void filter(String searchTerm) {
|
||||
|
@ -139,7 +139,7 @@ public final class Tab {
|
||||
|
||||
public void onDestroy() {
|
||||
mDoorHangers = new HashMap<String, DoorHanger>();
|
||||
BrowserDB.unregisterBookmarkObserver(mContentResolver, mContentObserver);
|
||||
BrowserDB.unregisterContentObserver(mContentResolver, mContentObserver);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -313,6 +313,10 @@ public class AndroidBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
registerBookmarkObserverPre11(cr, observer);
|
||||
}
|
||||
|
||||
public void registerHistoryObserver(ContentResolver cr, ContentObserver observer) {
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
public BitmapDrawable getFaviconForUrl(ContentResolver cr, String uri) {
|
||||
Cursor c = cr.query(Browser.BOOKMARKS_URI,
|
||||
new String[] { Browser.BookmarkColumns.FAVICON },
|
||||
|
@ -102,6 +102,8 @@ public class BrowserDB {
|
||||
public byte[] getThumbnailForUrl(ContentResolver cr, String uri);
|
||||
|
||||
public void registerBookmarkObserver(ContentResolver cr, ContentObserver observer);
|
||||
|
||||
public void registerHistoryObserver(ContentResolver cr, ContentObserver observer);
|
||||
}
|
||||
|
||||
static {
|
||||
@ -198,7 +200,11 @@ public class BrowserDB {
|
||||
sDb.registerBookmarkObserver(cr, observer);
|
||||
}
|
||||
|
||||
public static void unregisterBookmarkObserver(ContentResolver cr, ContentObserver observer) {
|
||||
public static void registerHistoryObserver(ContentResolver cr, ContentObserver observer) {
|
||||
sDb.registerHistoryObserver(cr, observer);
|
||||
}
|
||||
|
||||
public static void unregisterContentObserver(ContentResolver cr, ContentObserver observer) {
|
||||
cr.unregisterContentObserver(observer);
|
||||
}
|
||||
}
|
||||
|
@ -508,8 +508,11 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
}
|
||||
|
||||
public void registerBookmarkObserver(ContentResolver cr, ContentObserver observer) {
|
||||
Uri uri = mBookmarksUriWithProfile;
|
||||
cr.registerContentObserver(uri, false, observer);
|
||||
cr.registerContentObserver(mBookmarksUriWithProfile, false, observer);
|
||||
}
|
||||
|
||||
public void registerHistoryObserver(ContentResolver cr, ContentObserver observer) {
|
||||
cr.registerContentObserver(mHistoryUriWithProfile, false, observer);
|
||||
}
|
||||
|
||||
public void updateBookmark(ContentResolver cr, int id, String uri, String title, String keyword) {
|
||||
|
Loading…
Reference in New Issue
Block a user