use of forpdateam.ru.forpda.api.devdb.models.DeviceSearch in project ForPDA by RadiationX.
the class DevDb method search.
public DeviceSearch search(String query) throws Exception {
DeviceSearch searchResult = new DeviceSearch();
try {
query = URLDecoder.decode(query, "windows-1251");
} catch (Exception ignore) {
}
NetworkResponse response = Api.getWebClient().get("http://4pda.ru/devdb/search?s=" + query);
Matcher matcher = SEARCH_PATTERN.matcher(response.getBody());
while (matcher.find()) {
DeviceSearch.DeviceItem item = new DeviceSearch.DeviceItem();
item.setImageSrc(matcher.group(1));
item.setId(matcher.group(2));
item.setTitle(ApiUtils.fromHtml(matcher.group(3)));
searchResult.addDevice(item);
}
searchResult.setAll(searchResult.getDevices().size());
searchResult.setActual(searchResult.getAll());
return searchResult;
}
Aggregations