use of com.connectsdk.service.capability.listeners.ResponseListener in project butter-android by butterproject.
the class NetcastTVService method launchAppStore.
@Override
public void launchAppStore(final String appId, final AppLaunchListener listener) {
if (!serviceDescription.getModelNumber().equals("4.0")) {
// TODO: this will not work in Korea, use Korean name instead
launchApp("LG Smart World", listener);
return;
}
String targetPath = getUDAPRequestURL(ROAP_PATH_APP_STORE);
Map<String, String> params = new HashMap<String, String>();
params.put("name", "SearchCMDPlaySDPContent");
params.put("content_type", "4");
params.put("conts_exec_type", "");
params.put("conts_plex_type_flag", "");
params.put("conts_search_id", "");
params.put("conts_age", "12");
params.put("exec_id", "");
params.put("item_id", HttpMessage.encode(appId));
params.put("app_type", "S");
String httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, params);
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(appId);
// TODO: this will not work in Korea, use Korean name instead
launchSession.setAppName("LG Smart World");
launchSession.setService(NetcastTVService.this);
launchSession.setSessionType(LaunchSessionType.App);
Util.postSuccess(listener, launchSession);
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, targetPath, httpMessage, responseListener);
command.send();
}
use of com.connectsdk.service.capability.listeners.ResponseListener in project butter-android by butterproject.
the class NetcastTVService method sendPairingKey.
@Override
public void sendPairingKey(final String pairingKey) {
state = State.PAIRING;
if (!(serviceConfig instanceof NetcastTVServiceConfig)) {
serviceConfig = new NetcastTVServiceConfig(serviceConfig.getServiceUUID());
}
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
state = State.PAIRED;
((NetcastTVServiceConfig) serviceConfig).setPairingKey(pairingKey);
hConnectSuccess();
}
@Override
public void onError(ServiceCommandError error) {
state = State.INITIAL;
if (listener != null)
listener.onConnectionFailure(NetcastTVService.this, error);
}
};
String requestURL = getUDAPRequestURL(UDAP_PATH_PAIRING);
Map<String, String> params = new HashMap<String, String>();
params.put("name", "hello");
params.put("value", pairingKey);
params.put("port", String.valueOf(serviceDescription.getPort()));
String httpMessage = getUDAPMessageBody(UDAP_API_PAIRING, params);
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL, httpMessage, responseListener);
command.send();
}
use of com.connectsdk.service.capability.listeners.ResponseListener 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.capability.listeners.ResponseListener 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.capability.listeners.ResponseListener 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;
}
Aggregations