Bug 766940 - Notify MENU_UPDATED TabEvent when menu items change. r=mbrubeck

Also fixes bug 767959.
This commit is contained in:
Brian Nicholson 2012-07-24 16:12:12 -07:00
parent 0614ceffe9
commit 4bdc1be50a
4 changed files with 19 additions and 32 deletions

View File

@ -62,11 +62,10 @@ abstract public class BrowserApp extends GeckoApp
maybeCancelFaviconLoad(tab);
}
break;
case LOAD_ERROR:
case START:
if (Tabs.getInstance().isSelectedTab(tab)) {
invalidateOptionsMenu();
}
case STOP:
case MENU_UPDATED:
if (Tabs.getInstance().isSelectedTab(tab)) {
invalidateOptionsMenu();
}

View File

@ -169,14 +169,6 @@ abstract public class GeckoApp
updatePopups(tab);
invalidateOptionsMenu();
break;
case LOAD_ERROR:
case START:
case STOP:
// The options menu only applies to the selected tab.
if (Tabs.getInstance().isSelectedTab(tab))
invalidateOptionsMenu();
break;
}
}

View File

@ -101,7 +101,6 @@ public final class Tab {
mContentObserver = new ContentObserver(GeckoAppShell.getHandler()) {
public void onChange(boolean selfChange) {
updateBookmark();
updateReadingListItem();
}
};
BrowserDB.registerBookmarkObserver(mContentResolver, mContentObserver);
@ -248,7 +247,6 @@ public final class Tab {
mUrl = url;
Log.i(LOGTAG, "Updated url: " + url + " for tab with id: " + mId);
updateBookmark();
updateReadingListItem();
updateHistory(mUrl, mTitle);
}
}
@ -379,6 +377,11 @@ public final class Tab {
public void setReaderEnabled(boolean readerEnabled) {
mReaderEnabled = readerEnabled;
GeckoAppShell.getMainHandler().post(new Runnable() {
public void run() {
Tabs.getInstance().notifyListeners(Tab.this, Tabs.TabEvents.MENU_UPDATED);
}
});
}
private void updateBookmark() {
@ -386,29 +389,21 @@ public final class Tab {
if (url == null)
return;
GeckoBackgroundThread.getHandler().post(new Runnable() {
public void run() {
boolean bookmark = BrowserDB.isBookmark(mContentResolver, url);
(new GeckoAsyncTask<Void, Void, Void>() {
@Override
public Void doInBackground(Void... params) {
if (url.equals(getURL())) {
mBookmark = bookmark;
mBookmark = BrowserDB.isBookmark(mContentResolver, url);
mReadingListItem = BrowserDB.isReadingListItem(mContentResolver, url);
}
return null;
}
});
}
private void updateReadingListItem() {
final String url = getURL();
if (url == null)
return;
GeckoBackgroundThread.getHandler().post(new Runnable() {
public void run() {
boolean readingListItem = BrowserDB.isReadingListItem(mContentResolver, url);
if (url.equals(getURL())) {
mReadingListItem = readingListItem;
}
@Override
public void onPostExecute(Void result) {
Tabs.getInstance().notifyListeners(Tab.this, Tabs.TabEvents.MENU_UPDATED);
}
});
}).execute();
}
public void addBookmark() {

View File

@ -350,7 +350,8 @@ public class Tabs implements GeckoEventListener {
UNSELECTED,
ADDED,
RESTORED,
LOCATION_CHANGE
LOCATION_CHANGE,
MENU_UPDATED
}
public void notifyListeners(Tab tab, TabEvents msg) {