fix legwork suggestions parser

This commit is contained in:
R4SAS 2018-11-19 16:26:38 +03:00
parent 3cd9e0d4d2
commit a880891cf2

View File

@ -35,11 +35,11 @@ public final class LegworkSuggestionsModel extends BaseSuggestionsModel {
@Override @Override
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception { protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception {
String content = FileUtils.readStringFromStream(inputStream, ENCODING); String content = FileUtils.readStringFromStream(inputStream, ENCODING);
JSONArray jsonArray = new JSONArray(content); JSONArray respArray = new JSONArray(content);
JSONArray jsonArray = respArray.getJSONArray(1);
int counter = 0; int counter = 0;
for (int n = 0, size = jsonArray.length(); n < size; n++) { for (int n = 0, size = jsonArray.length(); n < size; n++) {
JSONObject object = jsonArray.getJSONObject(n); String suggestion = jsonArray.getString(n);
String suggestion = object.getString("phrase");
results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"', results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"',
suggestion, R.drawable.ic_search)); suggestion, R.drawable.ic_search));
counter++; counter++;