new String[] { Browser.BookmarkColumns.URL, Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.FAVICON }, "bookmark = 1", null, null);
- if ((c != null) && c.moveToFirst()) {
- int urlIndex = c.getColumnIndex(Browser.BookmarkColumns.URL);
- int titleIndex = c.getColumnIndex(Browser.BookmarkColumns.TITLE);
- int faviconIndex = c.getColumnIndex(Browser.BookmarkColumns.FAVICON);
- do {
- String url = c.getString(urlIndex);
- String host = Uri.parse(url).getHost();
- if (hosts.containsKey(host)) {
- String title = c.getString(titleIndex);
- Bitmap bmp = null;
- byte[] data = c.getBlob(faviconIndex);
- if (data != null) {
- bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
- }
- Set matchingSites = (Set) hosts.get(host);
- Iterator<Site> sitesIter = matchingSites.iterator();
- while (sitesIter.hasNext()) {
- Site site = sitesIter.next();
- // We should only set the title if the bookmark is for the root
- // (i.e. www.google.com), as website settings act on the origin
- // as a whole rather than a single page under that origin. If the
- // user has bookmarked a page under the root but *not* the root,
- // then we risk displaying the title of that page which may or
- // may not have any relevance to the origin.
- if (url.equals(site.getOrigin()) ||
- (new String(site.getOrigin()+"/")).equals(url)) {
- site.setTitle(title);
+ if (c != null) {
- if(c.moveToFirst()) {
++ if (c.moveToFirst()) {
+ int urlIndex = c.getColumnIndex(Browser.BookmarkColumns.URL);
+ int titleIndex = c.getColumnIndex(Browser.BookmarkColumns.TITLE);
+ int faviconIndex = c.getColumnIndex(Browser.BookmarkColumns.FAVICON);
+ do {
+ String url = c.getString(urlIndex);
+ String host = Uri.parse(url).getHost();
+ if (hosts.containsKey(host)) {
+ String title = c.getString(titleIndex);
+ Bitmap bmp = null;
+ byte[] data = c.getBlob(faviconIndex);
+ if (data != null) {
+ bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
}
- if (bmp != null) {
- site.setIcon(bmp);
- Set matchingSites = (Set)hosts.get(host);
++ Set matchingSites = (Set) hosts.get(host);
+ Iterator<Site> sitesIter = matchingSites.iterator();
+ while (sitesIter.hasNext()) {
+ Site site = sitesIter.next();
- site.setTitle(title);
++ // We should only set the title if the bookmark is for the root
++ // (i.e. www.google.com), as website settings act on the origin
++ // as a whole rather than a single page under that origin. If the
++ // user has bookmarked a page under the root but *not* the root,
++ // then we risk displaying the title of that page which may or
++ // may not have any relevance to the origin.
++ if (url.equals(site.getOrigin()) ||
++ (new String(site.getOrigin()+"/")).equals(url)) {
++ site.setTitle(title);
++ }
+ if (bmp != null) {
+ site.setIcon(bmp);
+ }
}
}
- }
- } while (c.moveToNext());
+ } while (c.moveToNext());
+ }
+ c.close();
}
-
- c.close();
}