use of com.connectsdk.core.AppInfo in project butter-android by butterproject.
the class WebOSTVService method getRunningApp.
private ServiceCommand<AppInfoListener> getRunningApp(boolean isSubscription, final AppInfoListener listener) {
ServiceCommand<AppInfoListener> request;
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
final JSONObject jsonObj = (JSONObject) response;
AppInfo app = new AppInfo() {
{
setId(jsonObj.optString("appId"));
setName(jsonObj.optString("appName"));
setRawData(jsonObj);
}
};
Util.postSuccess(listener, app);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
if (isSubscription)
request = new URLServiceSubscription<AppInfoListener>(this, FOREGROUND_APP, null, true, responseListener);
else
request = new ServiceCommand<AppInfoListener>(this, FOREGROUND_APP, null, true, responseListener);
request.send();
return request;
}
use of com.connectsdk.core.AppInfo in project butter-android by butterproject.
the class WebOSTVService method launchApp.
@Override
public void launchApp(String appId, AppLaunchListener listener) {
AppInfo appInfo = new AppInfo();
appInfo.setId(appId);
launchAppWithInfo(appInfo, listener);
}
use of com.connectsdk.core.AppInfo 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();
}
use of com.connectsdk.core.AppInfo in project butter-android by butterproject.
the class RokuService method launchAppStore.
@Override
public void launchAppStore(final String appId, AppLaunchListener listener) {
AppInfo appInfo = new AppInfo("11");
appInfo.setName("Channel Store");
JSONObject params = null;
try {
params = new JSONObject() {
{
put("contentId", appId);
}
};
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
launchAppWithInfo(appInfo, params, listener);
}
use of com.connectsdk.core.AppInfo in project butter-android by butterproject.
the class DIALService method launchYouTube.
@Override
public void launchYouTube(String contentId, float startTime, AppLaunchListener listener) {
String params = null;
AppInfo appInfo = new AppInfo("YouTube");
appInfo.setName(appInfo.getId());
if (contentId != null && contentId.length() > 0) {
if (startTime < 0.0) {
if (listener != null) {
listener.onError(new ServiceCommandError(0, "Start time may not be negative", null));
}
return;
}
String pairingCode = java.util.UUID.randomUUID().toString();
params = String.format(Locale.US, "pairingCode=%s&v=%s&t=%.1f", pairingCode, contentId, startTime);
}
launchAppWithInfo(appInfo, params, listener);
}
Aggregations