Search in sources :

Example 11 with RequestTask

use of wseemann.media.romote.tasks.RequestTask in project RoMote by wseemann.

the class NotificationService method sendStatusCommand.

private void sendStatusCommand() {
    String url = CommandHelper.getDeviceURL(this);
    QueryActiveAppRequest queryActiveAppRequest = new QueryActiveAppRequest(url);
    JakuRequest request = new JakuRequest(queryActiveAppRequest, new AppsParser());
    new RequestTask(request, new RequestCallback() {

        @Override
        public void requestResult(RokuRequestTypes rokuRequestType, RequestTask.Result result) {
            List<Channel> channels = (List<Channel>) result.mResultValue;
            if (channels.size() > 0) {
                mChannel = channels.get(0);
                getAppIcon(mChannel.getId());
            }
        }

        @Override
        public void onErrorResponse(RequestTask.Result result) {
            Log.d(TAG, "That didn't work!");
        }
    }).execute(RokuRequestTypes.query_active_app);
}
Also used : RequestTask(wseemann.media.romote.tasks.RequestTask) RokuRequestTypes(wseemann.media.romote.utils.RokuRequestTypes) JakuRequest(com.jaku.core.JakuRequest) RequestCallback(wseemann.media.romote.tasks.RequestCallback) AppsParser(com.jaku.parser.AppsParser) Channel(com.jaku.model.Channel) QueryActiveAppRequest(com.jaku.request.QueryActiveAppRequest) List(java.util.List)

Example 12 with RequestTask

use of wseemann.media.romote.tasks.RequestTask in project RoMote by wseemann.

the class NotificationService method getAppIcon.

private void getAppIcon(String appId) {
    String url = CommandHelper.getDeviceURL(this);
    QueryIconRequest queryIconRequest = new QueryIconRequest(url, appId);
    JakuRequest request = new JakuRequest(queryIconRequest, new IconParser());
    new RequestTask(request, new RequestCallback() {

        @Override
        public void requestResult(RokuRequestTypes rokuRequestType, RequestTask.Result result) {
            try {
                byte[] data = (byte[]) result.mResultValue;
                Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
                mDevice = PreferenceUtils.getConnectedDevice(NotificationService.this);
                notification = NotificationUtils.buildNotification(NotificationService.this, mDevice.getModelName(), mChannel.getTitle(), bitmap);
                mNM.notify(NOTIFICATION, notification);
            } catch (Exception ex) {
            }
        }

        @Override
        public void onErrorResponse(RequestTask.Result result) {
            Log.d(TAG, "That didn't work!");
        }
    }).execute(RokuRequestTypes.query_icon);
}
Also used : IconParser(com.jaku.parser.IconParser) RequestTask(wseemann.media.romote.tasks.RequestTask) Bitmap(android.graphics.Bitmap) RokuRequestTypes(wseemann.media.romote.utils.RokuRequestTypes) JakuRequest(com.jaku.core.JakuRequest) RequestCallback(wseemann.media.romote.tasks.RequestCallback) QueryIconRequest(com.jaku.request.QueryIconRequest)

Example 13 with RequestTask

use of wseemann.media.romote.tasks.RequestTask in project RoMote by wseemann.

the class RemoteFragment method onVolumeChanged.

@Override
public void onVolumeChanged(final KeypressKeyValues keypressKeyValue) {
    String url = CommandHelper.getDeviceURL(getActivity());
    KeypressRequest keypressRequest = new KeypressRequest(url, keypressKeyValue.getValue());
    JakuRequest request = new JakuRequest(keypressRequest, null);
    new RequestTask(request, new RequestCallback() {

        @Override
        public void requestResult(RokuRequestTypes rokuRequestType, RequestTask.Result result) {
        }

        @Override
        public void onErrorResponse(RequestTask.Result result) {
        }
    }).execute(RokuRequestTypes.keypress);
}
Also used : RequestTask(wseemann.media.romote.tasks.RequestTask) RokuRequestTypes(wseemann.media.romote.utils.RokuRequestTypes) JakuRequest(com.jaku.core.JakuRequest) RequestCallback(wseemann.media.romote.tasks.RequestCallback) KeypressRequest(com.jaku.request.KeypressRequest)

Example 14 with RequestTask

use of wseemann.media.romote.tasks.RequestTask in project RoMote by wseemann.

the class MainActivity method performSearch.

private void performSearch(String searchText) {
    String url = CommandHelper.getDeviceURL(this);
    SearchRequest searchRequest = new SearchRequest(url, searchText, null, null, null, null, null, null, null, null, null);
    JakuRequest request = new JakuRequest(searchRequest, null);
    new RequestTask(request, new RequestCallback() {

        @Override
        public void requestResult(RokuRequestTypes rokuRequestType, RequestTask.Result result) {
        }

        @Override
        public void onErrorResponse(RequestTask.Result result) {
        }
    }).execute(RokuRequestTypes.search);
}
Also used : SearchRequest(com.jaku.request.SearchRequest) RequestTask(wseemann.media.romote.tasks.RequestTask) RokuRequestTypes(wseemann.media.romote.utils.RokuRequestTypes) JakuRequest(com.jaku.core.JakuRequest) RequestCallback(wseemann.media.romote.tasks.RequestCallback)

Aggregations

JakuRequest (com.jaku.core.JakuRequest)14 RequestCallback (wseemann.media.romote.tasks.RequestCallback)14 RequestTask (wseemann.media.romote.tasks.RequestTask)14 RokuRequestTypes (wseemann.media.romote.utils.RokuRequestTypes)14 KeypressRequest (com.jaku.request.KeypressRequest)6 Device (com.jaku.model.Device)3 DeviceParser (com.jaku.parser.DeviceParser)3 QueryDeviceInfoRequest (com.jaku.request.QueryDeviceInfoRequest)3 SearchRequest (com.jaku.request.SearchRequest)2 Bitmap (android.graphics.Bitmap)1 Channel (com.jaku.model.Channel)1 AppsParser (com.jaku.parser.AppsParser)1 IconParser (com.jaku.parser.IconParser)1 LaunchAppRequest (com.jaku.request.LaunchAppRequest)1 QueryActiveAppRequest (com.jaku.request.QueryActiveAppRequest)1 QueryIconRequest (com.jaku.request.QueryIconRequest)1 List (java.util.List)1 Entry (wseemann.media.romote.model.Entry)1