use of acr.browser.lightning.database.HistoryItem in project Lightning-Browser by anthonycr.
the class GoogleSuggestionsModel method parseResults.
@Override
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception {
BufferedInputStream bufferedInput = new BufferedInputStream(inputStream);
XmlPullParser parser = getParser();
parser.setInput(bufferedInput, ENCODING);
int eventType = parser.getEventType();
int counter = 0;
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && "suggestion".equals(parser.getName())) {
String suggestion = parser.getAttributeValue(null, "data");
results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"', suggestion, R.drawable.ic_search));
counter++;
if (counter >= MAX_RESULTS) {
break;
}
}
eventType = parser.next();
}
}
use of acr.browser.lightning.database.HistoryItem in project Lightning-Browser by anthonycr.
the class DuckSuggestionsModel method parseResults.
@Override
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception {
String content = FileUtils.readStringFromStream(inputStream, ENCODING);
JSONArray jsonArray = new JSONArray(content);
int counter = 0;
for (int n = 0, size = jsonArray.length(); n < size; n++) {
JSONObject object = jsonArray.getJSONObject(n);
String suggestion = object.getString("phrase");
results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"', suggestion, R.drawable.ic_search));
counter++;
if (counter >= MAX_RESULTS) {
break;
}
}
}
Aggregations