Bug 729463 - Favicons should not be based on whats shown in views. r=margaret

This commit is contained in:
Wes Johnston 2013-05-09 17:44:45 -07:00
parent 42846fe36d
commit ef16e70a9d
4 changed files with 19 additions and 12 deletions

View File

@ -523,7 +523,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
throw new IllegalStateException("Couldn't move cursor to position " + position);
updateTitle(viewHolder.titleView, cursor);
updateUrl(viewHolder.urlView, cursor);
updateUrl(viewHolder, cursor);
updateBookmarkIcon(viewHolder.bookmarkIconView, cursor);
displayFavicon(viewHolder);
}
@ -911,13 +911,18 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
}
private void displayFavicon(AwesomeEntryViewHolder viewHolder) {
final String url = viewHolder.urlView.getText().toString();
final String url = viewHolder.url;
Bitmap bitmap = Favicons.getInstance().getFaviconFromMemCache(url);
updateFavicon(viewHolder.faviconView, bitmap, url);
}
private void updateFavicons() {
ListView listView = getListView();
AwesomeBarCursorAdapter adapter = getCursorAdapter();
Cursor cursor = adapter.getCursor();
if (cursor == null)
return;
for (int i = 0; i < listView.getChildCount(); i++) {
final View view = listView.getChildAt(i);
final Object tag = view.getTag();

View File

@ -61,6 +61,7 @@ abstract public class AwesomeBarTab {
protected class AwesomeEntryViewHolder {
public TextView titleView;
public String url;
public TextView urlView;
public FaviconView faviconView;
public ImageView bookmarkIconView;
@ -166,20 +167,21 @@ abstract public class AwesomeBarTab {
}
}
protected void updateUrl(TextView urlView, Cursor cursor) {
protected void updateUrl(AwesomeEntryViewHolder holder, Cursor cursor) {
int urlIndex = cursor.getColumnIndexOrThrow(URLColumns.URL);
String url = cursor.getString(urlIndex);
updateUrl(urlView, url);
updateUrl(holder, url);
}
protected void updateUrl(TextView urlView, String url) {
protected void updateUrl(AwesomeEntryViewHolder holder, String url) {
Integer tabId = getOpenTabs().get(url);
holder.url = url;
if (tabId != null) {
urlView.setText(R.string.awesomebar_switch_to_tab);
urlView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_awesomebar_tab, 0, 0, 0);
holder.urlView.setText(R.string.awesomebar_switch_to_tab);
holder.urlView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_awesomebar_tab, 0, 0, 0);
} else {
urlView.setText(url);
urlView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
holder.urlView.setText(url);
holder.urlView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
}

View File

@ -339,7 +339,7 @@ public class BookmarksTab extends AwesomeBarTab {
if (viewType == VIEW_TYPE_ITEM) {
updateTitle(viewHolder.titleView, cursor);
updateUrl(viewHolder.urlView, cursor);
updateUrl(viewHolder, cursor);
byte[] b = cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
Bitmap favicon = null;

View File

@ -186,7 +186,7 @@ public class HistoryTab extends AwesomeBarTab {
String url = (String) historyItem.get(URLColumns.URL);
updateTitle(viewHolder.titleView, title, url);
updateUrl(viewHolder.urlView, url);
updateUrl(viewHolder, url);
byte[] b = (byte[]) historyItem.get(URLColumns.FAVICON);
Bitmap favicon = null;