use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method setMute.
@Override
public void setMute(boolean isMute, ResponseListener<Object> listener) {
String uri = "ssap://audio/setMute";
JSONObject payload = new JSONObject();
try {
payload.put("mute", isMute);
} catch (JSONException e) {
e.printStackTrace();
}
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, true, listener);
request.send();
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method getCurrentChannel.
private ServiceCommand<ResponseListener<Object>> getCurrentChannel(boolean isSubscription, final ChannelListener listener) {
ServiceCommand<ResponseListener<Object>> request;
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
JSONObject jsonObj = (JSONObject) response;
ChannelInfo channel = parseRawChannelData(jsonObj);
Util.postSuccess(listener, channel);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
if (isSubscription) {
request = new URLServiceSubscription<ResponseListener<Object>>(this, CHANNEL, null, true, responseListener);
} else
request = new ServiceCommand<ResponseListener<Object>>(this, CHANNEL, null, true, responseListener);
request.send();
return request;
}
use of com.connectsdk.service.command.ServiceCommand 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.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method getVolumeStatus.
private ServiceCommand<ResponseListener<Object>> getVolumeStatus(boolean isSubscription, final VolumeStatusListener listener) {
ServiceCommand<ResponseListener<Object>> request;
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
try {
JSONObject jsonObj = (JSONObject) response;
boolean isMute = (Boolean) jsonObj.get("mute");
int iVolume = jsonObj.getInt("volume");
float fVolume = (float) (iVolume / 100.0);
Util.postSuccess(listener, new VolumeStatus(isMute, fVolume));
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
if (isSubscription)
request = new URLServiceSubscription<ResponseListener<Object>>(this, VOLUME_STATUS, null, true, responseListener);
else
request = new ServiceCommand<ResponseListener<Object>>(this, VOLUME_STATUS, null, true, responseListener);
request.send();
return request;
}
use of com.connectsdk.service.command.ServiceCommand 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