Search in sources :

Example 1 with AppInfo

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

the class NetcastTVService method getApplications.

private void getApplications(int type, int number, final AppListListener listener) {
    ResponseListener<Object> responseListener = new ResponseListener<Object>() {

        @Override
        public void onSuccess(Object response) {
            String strObj = (String) response;
            JSONArray applicationArray = parseApplicationsXmlToJSON(strObj);
            List<AppInfo> appList = new ArrayList<AppInfo>();
            for (int i = 0; i < applicationArray.length(); i++) {
                try {
                    final JSONObject appJSON = applicationArray.getJSONObject(i);
                    AppInfo appInfo = new AppInfo() {

                        {
                            setId(appJSON.getString("id"));
                            setName(appJSON.getString("title"));
                        }
                    };
                    appList.add(appInfo);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            Util.postSuccess(listener, appList);
        }

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }
    };
    String requestURL = getUDAPRequestURL(UDAP_PATH_DATA, TARGET_APPLIST_GET, String.valueOf(type), "0", String.valueOf(number));
    ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL, null, responseListener);
    command.setHttpMethod(ServiceCommand.TYPE_GET);
    command.send();
}
Also used : JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) ServiceCommandError(com.connectsdk.service.command.ServiceCommandError) ResponseListener(com.connectsdk.service.capability.listeners.ResponseListener) AppInfo(com.connectsdk.core.AppInfo) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) ServiceCommand(com.connectsdk.service.command.ServiceCommand)

Example 2 with AppInfo

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

the class WebOSTVService method launchInputPicker.

@Override
public void launchInputPicker(final AppLaunchListener listener) {
    final AppInfo appInfo = new AppInfo() {

        {
            setId("com.webos.app.inputpicker");
            setName("InputPicker");
        }
    };
    launchAppWithInfo(appInfo, null, new AppLaunchListener() {

        @Override
        public void onSuccess(LaunchSession object) {
            listener.onSuccess(object);
        }

        @Override
        public void onError(ServiceCommandError error) {
            appInfo.setId("com.webos.app.inputmgr");
            launchAppWithInfo(appInfo, null, listener);
        }
    });
}
Also used : LaunchSession(com.connectsdk.service.sessions.LaunchSession) ServiceCommandError(com.connectsdk.service.command.ServiceCommandError) AppInfo(com.connectsdk.core.AppInfo)

Example 3 with AppInfo

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

the class WebOSTVService method launchHulu.

@Override
public void launchHulu(String contentId, Launcher.AppLaunchListener listener) {
    JSONObject params = new JSONObject();
    try {
        params.put("contentId", contentId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    AppInfo appInfo = new AppInfo() {

        {
            setId("hulu");
            setName("Hulu");
        }
    };
    launchAppWithInfo(appInfo, params, listener);
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) AppInfo(com.connectsdk.core.AppInfo)

Example 4 with AppInfo

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

the class WebOSTVService method launchAppStore.

@Override
public void launchAppStore(String appId, AppLaunchListener listener) {
    AppInfo appInfo = new AppInfo("com.webos.app.discovery");
    appInfo.setName("LG Store");
    JSONObject params = new JSONObject();
    if (appId != null && appId.length() > 0) {
        String query = String.format("category/GAME_APPS/%s", appId);
        try {
            params.put("query", query);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    launchAppWithInfo(appInfo, params, listener);
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) AppInfo(com.connectsdk.core.AppInfo)

Example 5 with AppInfo

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

the class WebOSTVService method launchNetflix.

@Override
public void launchNetflix(String contentId, Launcher.AppLaunchListener listener) {
    JSONObject params = new JSONObject();
    String netflixContentId = "m=http%3A%2F%2Fapi.netflix.com%2Fcatalog%2Ftitles%2Fmovies%2F" + contentId + "&source_type=4";
    try {
        params.put("contentId", netflixContentId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    AppInfo appInfo = new AppInfo() {

        {
            setId("netflix");
            setName("Netflix");
        }
    };
    launchAppWithInfo(appInfo, params, listener);
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) AppInfo(com.connectsdk.core.AppInfo)

Aggregations

AppInfo (com.connectsdk.core.AppInfo)17 JSONObject (org.json.JSONObject)12 ServiceCommandError (com.connectsdk.service.command.ServiceCommandError)11 JSONException (org.json.JSONException)9 ResponseListener (com.connectsdk.service.capability.listeners.ResponseListener)6 ServiceCommand (com.connectsdk.service.command.ServiceCommand)6 LaunchSession (com.connectsdk.service.sessions.LaunchSession)2 ArrayList (java.util.ArrayList)2 JSONArray (org.json.JSONArray)2 SuppressLint (android.annotation.SuppressLint)1 URLServiceSubscription (com.connectsdk.service.command.URLServiceSubscription)1 RokuApplicationListParser (com.connectsdk.service.roku.RokuApplicationListParser)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParser (javax.xml.parsers.SAXParser)1