Search in sources :

Example 1 with ProgramList

use of com.connectsdk.core.ProgramList in project butter-android by butterproject.

the class WebOSTVService method getProgramList.

private ServiceCommand<ResponseListener<Object>> getProgramList(boolean isSubscription, final ProgramListListener listener) {
    ServiceCommand<ResponseListener<Object>> request;
    ResponseListener<Object> responseListener = new ResponseListener<Object>() {

        @Override
        public void onSuccess(Object response) {
            try {
                JSONObject jsonObj = (JSONObject) response;
                JSONObject jsonChannel = (JSONObject) jsonObj.get("channel");
                ChannelInfo channel = parseRawChannelData(jsonChannel);
                JSONArray programList = (JSONArray) jsonObj.get("programList");
                Util.postSuccess(listener, new ProgramList(channel, programList));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }
    };
    if (isSubscription)
        request = new URLServiceSubscription<ResponseListener<Object>>(this, PROGRAM, null, true, responseListener);
    else
        request = new ServiceCommand<ResponseListener<Object>>(this, PROGRAM, null, true, responseListener);
    request.send();
    return request;
}
Also used : ProgramList(com.connectsdk.core.ProgramList) JSONObject(org.json.JSONObject) URLServiceSubscription(com.connectsdk.service.command.URLServiceSubscription) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) ChannelInfo(com.connectsdk.core.ChannelInfo) ServiceCommandError(com.connectsdk.service.command.ServiceCommandError) ResponseListener(com.connectsdk.service.capability.listeners.ResponseListener) ServiceCommand(com.connectsdk.service.command.ServiceCommand)

Aggregations

ChannelInfo (com.connectsdk.core.ChannelInfo)1 ProgramList (com.connectsdk.core.ProgramList)1 ResponseListener (com.connectsdk.service.capability.listeners.ResponseListener)1 ServiceCommand (com.connectsdk.service.command.ServiceCommand)1 ServiceCommandError (com.connectsdk.service.command.ServiceCommandError)1 URLServiceSubscription (com.connectsdk.service.command.URLServiceSubscription)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1