author | Lucas Rocha <lucasr@mozilla.com> |
Tue, 15 Jul 2014 20:54:27 +0100 | |
changeset 216236 | bf73e3732df414dd2cdac1875858d053ae351370 |
parent 216235 | 02df6765db56826dc4491f7ac52694621164715d |
child 216237 | 7811f4c944c5092ad38281d2d94824dee2c19568 |
push id | 515 |
push user | raliiev@mozilla.com |
push date | Mon, 06 Oct 2014 12:51:51 +0000 |
treeherder | mozilla-release@267c7a481bef [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | rnewman |
bugs | 1012462 |
milestone | 33.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/db/SuggestedSites.java +++ b/mobile/android/base/db/SuggestedSites.java @@ -20,16 +20,17 @@ import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import org.mozilla.gecko.GeckoSharedPrefs; import org.mozilla.gecko.R; import org.mozilla.gecko.db.BrowserContract; import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.preferences.GeckoPreferences; import org.mozilla.gecko.util.RawResource; @@ -73,30 +74,48 @@ public class SuggestedSites { private static final String JSON_KEY_BG_COLOR = "bgcolor"; private static class Site { public final String url; public final String title; public final String imageUrl; public final String bgColor; + public Site(JSONObject json) throws JSONException { + this.url = json.getString(JSON_KEY_URL); + this.title = json.getString(JSON_KEY_TITLE); + this.imageUrl = json.getString(JSON_KEY_IMAGE_URL); + this.bgColor = json.getString(JSON_KEY_BG_COLOR); + } + public Site(String url, String title, String imageUrl, String bgColor) { this.url = url; this.title = title; this.imageUrl = imageUrl; this.bgColor = bgColor; } @Override public String toString() { return "{ url = " + url + "\n" + "title = " + title + "\n" + "imageUrl = " + imageUrl + "\n" + "bgColor = " + bgColor + " }"; } + + public JSONObject toJSON() throws JSONException { + final JSONObject json = new JSONObject(); + + json.put(JSON_KEY_URL, url); + json.put(JSON_KEY_TITLE, title); + json.put(JSON_KEY_IMAGE_URL, imageUrl); + json.put(JSON_KEY_BG_COLOR, bgColor); + + return json; + } } private final Context context; private Map<String, Site> cachedSites; private Locale cachedLocale; private Set<String> cachedBlacklist; public SuggestedSites(Context appContext) {