use of com.connectsdk.service.sessions.WebAppSession.WebAppPinStatusListener in project butter-android by butterproject.
the class WebOSTVService method isWebAppPinned.
private ServiceCommand<WebAppPinStatusListener> isWebAppPinned(boolean isSubscription, String webAppId, final WebAppPinStatusListener listener) {
if (webAppId == null || webAppId.length() == 0) {
if (listener != null) {
listener.onError(new ServiceCommandError(-1, "You must provide a valid web app id", null));
}
return null;
}
String uri = "ssap://webapp/isWebAppPinned";
JSONObject payload = new JSONObject();
try {
payload.put("webAppId", webAppId);
} catch (JSONException e) {
e.printStackTrace();
}
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(final Object response) {
JSONObject obj = (JSONObject) response;
boolean status = obj.optBoolean("pinned");
if (listener != null) {
listener.onSuccess(status);
}
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<WebAppPinStatusListener> request;
if (isSubscription)
request = new URLServiceSubscription<WebAppPinStatusListener>(this, uri, payload, true, responseListener);
else
request = new ServiceCommand<WebAppPinStatusListener>(this, uri, payload, true, responseListener);
request.send();
return request;
}
Aggregations