Search in sources :

Example 1 with JakuResponse

use of com.jaku.core.JakuResponse in project RoMote by wseemann.

the class RequestTask method doInBackground.

@Override
protected RequestTask.Result doInBackground(RokuRequestTypes... requestTypes) {
    Result result = null;
    if (!isCancelled() && requestTypes != null && requestTypes.length > 0) {
        RokuRequestTypes requestType = requestTypes[0];
        try {
            if (requestType.equals(RokuRequestTypes.query_active_app)) {
                JakuResponse response = request.send();
                List<Channel> channels = (List<Channel>) response.getResponseData();
                result = new Result(channels);
            } else if (requestType.equals(RokuRequestTypes.query_device_info)) {
                JakuResponse response = request.send();
                Device device = (Device) response.getResponseData();
                result = new Result(device);
            } else if (requestType.equals(RokuRequestTypes.query_icon)) {
                JakuResponse response = request.send();
                byte[] data = ((ByteArrayOutputStream) response.getResponseData()).toByteArray();
                result = new Result(data);
            } else {
                request.send();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = new Result(e);
        }
    }
    return result;
}
Also used : RokuRequestTypes(wseemann.media.romote.utils.RokuRequestTypes) Device(com.jaku.model.Device) Channel(com.jaku.model.Channel) List(java.util.List) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JakuResponse(com.jaku.core.JakuResponse)

Aggregations

JakuResponse (com.jaku.core.JakuResponse)1 Channel (com.jaku.model.Channel)1 Device (com.jaku.model.Device)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 List (java.util.List)1 RokuRequestTypes (wseemann.media.romote.utils.RokuRequestTypes)1