use of com.connectsdk.service.roku.RokuApplicationListParser in project butter-android by butterproject.
the class RokuService method getAppList.
@Override
public void getAppList(final AppListListener listener) {
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
String msg = (String) response;
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
InputStream stream;
try {
stream = new ByteArrayInputStream(msg.getBytes("UTF-8"));
SAXParser saxParser = saxParserFactory.newSAXParser();
RokuApplicationListParser parser = new RokuApplicationListParser();
saxParser.parse(stream, parser);
List<AppInfo> appList = parser.getApplicationList();
Util.postSuccess(listener, appList);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
String action = "query";
String param = "apps";
String uri = requestURL(action, param);
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, null, responseListener);
request.setHttpMethod(ServiceCommand.TYPE_GET);
request.send();
}
Aggregations