use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method setChannel.
@Override
public void setChannel(ChannelInfo channelInfo, ResponseListener<Object> listener) {
String uri = "ssap://tv/openChannel";
JSONObject payload = new JSONObject();
try {
payload.put("channelNumber", channelInfo.getNumber());
} 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 getMuteStatus.
private ServiceCommand<ResponseListener<Object>> getMuteStatus(boolean isSubscription, final MuteListener 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");
Util.postSuccess(listener, isMute);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
if (isSubscription)
request = new URLServiceSubscription<ResponseListener<Object>>(this, MUTE, null, true, responseListener);
else
request = new ServiceCommand<ResponseListener<Object>>(this, MUTE, null, true, responseListener);
request.send();
return request;
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method connectMouse.
private void connectMouse(final WebOSTVMouseSocketConnection.WebOSTVMouseSocketListener successHandler) {
if (mouseSocket != null)
return;
String uri = "ssap://com.webos.service.networkinput/getPointerInputSocket";
ResponseListener<Object> listener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
try {
JSONObject jsonObj = (JSONObject) response;
String socketPath = (String) jsonObj.get("socketPath");
mouseSocket = new WebOSTVMouseSocketConnection(socketPath, successHandler);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(ServiceCommandError error) {
Log.w(Util.T, "Connect mouse error: " + error.getMessage());
}
};
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, null, true, listener);
request.send();
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method get3DEnabled.
private ServiceCommand<State3DModeListener> get3DEnabled(boolean isSubscription, final State3DModeListener listener) {
String uri = "ssap://com.webos.service.tv.display/get3DStatus";
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
JSONObject jsonObj = (JSONObject) response;
JSONObject status;
try {
status = jsonObj.getJSONObject("status3D");
boolean isEnabled = status.getBoolean("status");
Util.postSuccess(listener, isEnabled);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<State3DModeListener> request;
if (isSubscription)
request = new URLServiceSubscription<State3DModeListener>(this, uri, null, true, responseListener);
else
request = new ServiceCommand<State3DModeListener>(this, uri, null, true, responseListener);
request.send();
return request;
}
use of com.connectsdk.service.command.ServiceCommand in project butter-android by butterproject.
the class WebOSTVService method setChannelById.
public void setChannelById(String channelId, ResponseListener<Object> listener) {
String uri = "ssap://tv/openChannel";
JSONObject payload = new JSONObject();
try {
payload.put("channelId", channelId);
} catch (JSONException e) {
e.printStackTrace();
}
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, true, listener);
request.send();
}
Aggregations