当前位置: 首页>>代码示例>>Java>>正文


Java Util类代码示例

本文整理汇总了Java中com.connectsdk.core.Util的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Util类属于com.connectsdk.core包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadMedia

import com.connectsdk.core.Util; //导入依赖的package包/类
private void loadMedia(com.google.android.gms.cast.MediaInfo mediaInformation,
                       final WebAppSession webAppSession, final LaunchListener listener) {
    try {
        mMediaPlayer.load(mApiClient, mediaInformation, true).setResultCallback(new ResultCallback<MediaChannelResult>() {

            @Override
            public void onResult(MediaChannelResult result) {
                Status status = result.getStatus();

                if (status.isSuccess()) {
                    webAppSession.launchSession.setSessionType(LaunchSessionType.Media);
                    mMediaPlayer.setActiveMediaTracks(mApiClient, new long[] { MEDIA_TRACK_ID });
                    Util.postSuccess(listener, new MediaLaunchObject(webAppSession.launchSession, CastService.this));
                }
                else {
                    Util.postError(listener, new ServiceCommandError(status.getStatusCode(), status.getStatusMessage(), status));
                }
            }
        });
    } catch (Exception e) {
        Util.postError(listener, new ServiceCommandError(0, "Unable to load", null));
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:24,代码来源:CastService.java

示例2: reportConnected

import com.connectsdk.core.Util; //导入依赖的package包/类
protected void reportConnected(boolean ready) {
    if (listener == null)
        return;

    // only run callback on main thread if the callback is leaving the SDK
    if (listener instanceof ConnectableDevice)
        listener.onConnectionSuccess(this);
    else {
        Util.runOnUI(new Runnable() {
            @Override
            public void run() {
                if (listener != null)
                    listener.onConnectionSuccess(DeviceService.this);
            }
        });
    }
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:18,代码来源:DeviceService.java

示例3: onConnectionFailed

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void onConnectionFailed(final ConnectionResult result) {
    Log.d(Util.T, "ConnectionFailedListener.onConnectionFailed " + (result != null ? result: ""));

    detachMediaPlayer();
    connected = false;
    mWaitingForReconnect = false;
    mApiClient = null;


    Util.runOnUI(new Runnable() {

        @Override
        public void run() {
            if (listener != null) {
                ServiceCommandError error = new ServiceCommandError(result.getErrorCode(), "Failed to connect to Google Cast device", result);

                listener.onConnectionFailure(CastService.this, error);
            }
        }
    });
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:23,代码来源:CastService.java

示例4: connect

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void connect(final ResponseListener<Object> listener) {
    if (castServiceChannel != null) {
        disconnectFromWebApp();
    }

    castServiceChannel = new CastServiceChannel(launchSession.getAppId(), this);

    try {
        Cast.CastApi.setMessageReceivedCallbacks(service.getApiClient(),
                castServiceChannel.getNamespace(),
                castServiceChannel);

        Util.postSuccess(listener, null);
    } catch (IOException e) {
        castServiceChannel = null;

        Util.postError(listener, new ServiceCommandError(0, "Failed to create channel", null));
    }
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:21,代码来源:CastWebAppSession.java

示例5: launchNetflix

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void launchNetflix(final String contentId, AppLaunchListener listener) {
    JSONObject params = null;

    if (contentId != null && contentId.length() > 0) {
        try {
            params = new JSONObject() {{
                put("v", contentId);
            }};
        } catch (JSONException e) {
            Log.e(Util.T, "Launch Netflix error", e);
        }
    }

    AppInfo appInfo = new AppInfo(APP_NETFLIX);
    appInfo.setName(appInfo.getId());

    launchAppWithInfo(appInfo, params, listener);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:20,代码来源:DIALService.java

示例6: sendKeyCode

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void sendKeyCode(KeyCode keycode, ResponseListener<Object> listener) {
    switch (keycode) {
        case NUM_0:
        case NUM_1:
        case NUM_2:
        case NUM_3:
        case NUM_4:
        case NUM_5:
        case NUM_6:
        case NUM_7:
        case NUM_8:
        case NUM_9:
            sendSpecialKey(String.valueOf(keycode.getCode()), listener);
            break;
        case DASH:
            sendSpecialKey("DASH", listener);
            break;
        case ENTER:
            sendSpecialKey("ENTER", listener);
        default:
            Util.postError(listener, new ServiceCommandError(0, "The keycode is not available", null));
    }
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:25,代码来源:WebOSTVService.java

示例7: launchAppWithInfo

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void launchAppWithInfo(final AppInfo appInfo, Object params, final AppLaunchListener listener) {
    ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL(appInfo.getName()), params, new ResponseListener<Object>() {
        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, new ServiceCommandError(0, "Problem Launching app", null));
        }

        @Override
        public void onSuccess(Object object) {
            LaunchSession launchSession = LaunchSession.launchSessionForAppId(appInfo.getId());
            launchSession.setAppName(appInfo.getName());
            launchSession.setSessionId((String)object);
            launchSession.setService(DIALService.this);
            launchSession.setSessionType(LaunchSessionType.App);

            Util.postSuccess(listener, launchSession);
        }
    });

    command.send();
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:23,代码来源:DIALService.java

示例8: getTotalNumberOfApplications

import com.connectsdk.core.Util; //导入依赖的package包/类
private void getTotalNumberOfApplications(int type, final AppCountListener listener) {
    ResponseListener<Object> responseListener = new ResponseListener<Object>() {

        @Override
        public void onSuccess(Object response) {
            String strObj = (String) response;

            int applicationNumber = parseAppNumberXmlToJSON(strObj);

            Util.postSuccess(listener, applicationNumber);
        }

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }
    };

    String requestURL = getUDAPRequestURL(UDAP_PATH_DATA, TARGET_APPNUM_GET, String.valueOf(type));

    ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL, null, responseListener);
    command.setHttpMethod(ServiceCommand.TYPE_GET);
    command.send();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:25,代码来源:NetcastTVService.java

示例9: getVolume

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void getVolume(final VolumeListener listener) {

    getVolumeStatus(new VolumeStatusListener() {

        @Override
        public void onSuccess(VolumeStatus status) {
            Util.postSuccess(listener, status.volume);
        }

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }
    });

}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:18,代码来源:NetcastTVService.java

示例10: requestStatus

import com.connectsdk.core.Util; //导入依赖的package包/类
public void requestStatus(final ResponseListener<Object> listener) {
    try {
        mMediaPlayer
                .requestStatus(mApiClient)
                .setResultCallback(
                        new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {

                            @Override
                            public void onResult(MediaChannelResult result) {
                                if (result.getStatus().isSuccess()) {
                                    Util.postSuccess(listener, result);
                                }
                                else {
                                    Util.postError(listener, new ServiceCommandError(0, "Failed to request status", result));
                                }
                            }
                        });
    } catch (Exception e) {
        Util.postError(listener, new ServiceCommandError(0, "There is no media currently available", null));
    }
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:22,代码来源:CastService.java

示例11: sendMessage

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void sendMessage(String message, final ResponseListener<Object> listener) {
    if (message == null) {
        Util.postError(listener, new ServiceCommandError(0, "Cannot send null message", null));
        return;
    }

    if (castServiceChannel == null) {
        Util.postError(listener, new ServiceCommandError(0, "Cannot send a message to the web app without first connecting", null));
        return;
    }

    Cast.CastApi.sendMessage(service.getApiClient(), castServiceChannel.getNamespace(), message).setResultCallback(new ResultCallback<Status>() {

        @Override
        public void onResult(Status result) {
            if (result.isSuccess()) {
                Util.postSuccess(listener, null);
            }
            else {
                Util.postError(listener, new ServiceCommandError(result.getStatusCode(), result.toString(), result));
            }
        }
    });
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:26,代码来源:CastWebAppSession.java

示例12: getLaunchPoints

import com.connectsdk.core.Util; //导入依赖的package包/类
public void getLaunchPoints(final LaunchPointsListener listener) {
    String uri = "ssap://com.webos.applicationManager/listLaunchPoints";

    ResponseListener<Object> responseListener = new ResponseListener<Object>() {

        @Override
        public void onSuccess(Object response) {

            try {
                JSONObject jsonObj = (JSONObject) response;
                JSONArray launchPoints = (JSONArray) jsonObj.get("launchPoints");
                Util.postSuccess(listener, launchPoints);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }
    };

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, null, true, responseListener);
    request.send();
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:27,代码来源:WebOSTVService.java

示例13: store

import com.connectsdk.core.Util; //导入依赖的package包/类
private void store() {
    updated = Util.getTime();

    JSONObject deviceStore = new JSONObject();
    try {
        deviceStore.put(KEY_VERSION, version);
        deviceStore.put(KEY_CREATED, created);
        deviceStore.put(KEY_UPDATED, updated);
        JSONArray deviceArray = new JSONArray(storedDevices.values());
        deviceStore.put(KEY_DEVICES, deviceArray);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    if (!waitToWrite)
        writeStoreToDisk(deviceStore);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:18,代码来源:DefaultConnectableDeviceStore.java

示例14: launchHulu

import com.connectsdk.core.Util; //导入依赖的package包/类
@Override
public void launchHulu(final String contentId, final Launcher.AppLaunchListener listener) {
    final String appName = "Hulu";

    getApplication(appName, new AppInfoListener() {

        @Override
        public void onSuccess(AppInfo appInfo) {
            launchApplication(appName, appInfo.getId(), contentId, listener);
        }

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }
    });
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:18,代码来源:NetcastTVService.java

示例15: pickFailed

import com.connectsdk.core.Util; //导入依赖的package包/类
protected void pickFailed(final ConnectableDevice device) {
    Util.runOnUI(new Runnable() {
        @Override
        public void run() {
            if (pendingDevice == device) {
                // Device failed before successfully picking device
                if (listener != null) {
                    listener.onPickDeviceFailed(false);
                }
            }

            cleanupPending();

            Toast.makeText(activity, connectionFailedResId, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:18,代码来源:SimpleDevicePicker.java


注:本文中的com.connectsdk.core.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。