本文整理汇总了Java中com.connectsdk.service.sessions.WebOSWebAppSession类的典型用法代码示例。如果您正苦于以下问题:Java WebOSWebAppSession类的具体用法?Java WebOSWebAppSession怎么用?Java WebOSWebAppSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebOSWebAppSession类属于com.connectsdk.service.sessions包,在下文中一共展示了WebOSWebAppSession类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: closeWebApp
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
@Override
public void closeWebApp(LaunchSession launchSession, final ResponseListener<Object> listener) {
if (launchSession == null || launchSession.getAppId() == null || launchSession.getAppId().length() == 0) {
Util.postError(listener, new ServiceCommandError(0, "Must provide a valid launch session", null));
return;
}
final WebOSWebAppSession webAppSession = mWebAppSessions.get(launchSession.getAppId());
if (webAppSession != null) {
webAppSession.disconnectFromWebApp();
}
String uri = "ssap://webapp/closeWebApp";
JSONObject payload = new JSONObject();
try {
if (launchSession.getAppId() != null) payload.put("webAppId", launchSession.getAppId());
if (launchSession.getSessionId() != null) payload.put("sessionId", launchSession.getSessionId());
} catch (JSONException e) {
e.printStackTrace();
}
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, true, listener);
request.send();
}
示例2: connectToApp
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
public void connectToApp(String appId, final WebAppSession.LaunchListener listener) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(appId);
launchSession.setSessionType(LaunchSessionType.App);
launchSession.setService(this);
final WebOSWebAppSession webAppSession = webAppSessionForLaunchSession(launchSession);
connectToWebApp(webAppSession, false, new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
@Override
public void onSuccess(Object object) {
Util.postSuccess(listener, webAppSession);
}
});
}
示例3: joinWebApp
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
@Override
public void joinWebApp(final LaunchSession webAppLaunchSession, final WebAppSession.LaunchListener listener) {
final WebOSWebAppSession webAppSession = this.webAppSessionForLaunchSession(webAppLaunchSession);
webAppSession.join(new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
@Override
public void onSuccess(Object object) {
Util.postSuccess(listener, webAppSession);
}
});
}
示例4: testPlayMediaDeprecatedWithAllParametersOnTheLatestWebOS
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
@Test
public void testPlayMediaDeprecatedWithAllParametersOnTheLatestWebOS() {
MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
WebOSWebAppSession webAppSession = Mockito.mock(WebOSWebAppSession.class);
service.mWebAppSessions.put("MediaPlayer", webAppSession);
MediaInfo mediaInfo = new MediaInfo.Builder("url", "mimetype")
.setTitle("title")
.setDescription("description")
.setIcon("icon")
.build();
boolean shouldLoop = true;
service.playMedia(mediaInfo.getUrl(), mediaInfo.getMimeType(), mediaInfo.getTitle(),
mediaInfo.getDescription(), mediaInfo.getImages().get(0).getUrl(), shouldLoop,
listener);
verifyPlayMediaOnTheLatestWebOS(mediaInfo, shouldLoop, listener, webAppSession);
}
示例5: verifyPlayMediaOnTheLatestWebOS
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
private void verifyPlayMediaOnTheLatestWebOS(MediaInfo mediaInfo, boolean shouldLoop, MediaPlayer.LaunchListener listener, WebOSWebAppSession webAppSession) {
// should try to join to the web app
ArgumentCaptor<ResponseListener> argListener = ArgumentCaptor.forClass(ResponseListener
.class);
Mockito.verify(webAppSession).join(argListener.capture());
// run join success
ResponseListener webAppListener = argListener.getValue();
webAppListener.onSuccess(null);
Robolectric.runUiThreadTasksIncludingDelayedTasks();
// should delegate playing media to the WebAppSession
ArgumentCaptor<MediaInfo> argMediaInfo = ArgumentCaptor.forClass(MediaInfo.class);
ArgumentCaptor<Boolean> argShouldLoop = ArgumentCaptor.forClass(Boolean.class);
Mockito.verify(webAppSession).playMedia(argMediaInfo.capture(), argShouldLoop.capture(),
Mockito.same(listener));
MediaInfo capturedMediaInfo = argMediaInfo.getValue();
Assert.assertEquals(mediaInfo.getDescription(), capturedMediaInfo.getDescription());
Assert.assertEquals(mediaInfo.getMimeType(), capturedMediaInfo.getMimeType());
Assert.assertEquals(mediaInfo.getTitle(), capturedMediaInfo.getTitle());
Assert.assertEquals(mediaInfo.getUrl(), capturedMediaInfo.getUrl());
Assert.assertEquals(mediaInfo.getImages(), capturedMediaInfo.getImages());
Assert.assertEquals(mediaInfo.getSubtitleInfo(), capturedMediaInfo.getSubtitleInfo());
Assert.assertEquals(shouldLoop, argShouldLoop.getValue().booleanValue());
}
示例6: WebOSTVService
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
public WebOSTVService(ServiceDescription serviceDescription, ServiceConfig serviceConfig) {
super(serviceDescription, serviceConfig);
setServiceDescription(serviceDescription);
pairingType = PairingType.FIRST_SCREEN;
mAppToAppIdMappings = new ConcurrentHashMap<String, String>();
mWebAppSessions = new ConcurrentHashMap<String, WebOSWebAppSession>();
}
示例7: disconnect
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
@Override
public void disconnect() {
Log.d(Util.T, "attempting to disconnect to " + serviceDescription.getIpAddress());
Util.runOnUI(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onDisconnect(WebOSTVService.this, null);
}
});
if (socket != null) {
socket.setListener(null);
socket.disconnect();
socket = null;
}
if (mAppToAppIdMappings != null)
mAppToAppIdMappings.clear();
if (mWebAppSessions != null) {
Enumeration<WebOSWebAppSession> iterator = mWebAppSessions.elements();
while (iterator.hasMoreElements()) {
WebOSWebAppSession session = iterator.nextElement();
session.disconnectFromWebApp();
}
mWebAppSessions.clear();
}
}
示例8: launchWebApp
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
@Override
public void launchWebApp(final String webAppId, final JSONObject params, boolean relaunchIfRunning, final WebAppSession.LaunchListener listener) {
if (webAppId == null) {
Util.postError(listener, new ServiceCommandError(0, "Must pass a web App id", null));
return;
}
if (relaunchIfRunning) {
launchWebApp(webAppId, params, listener);
} else {
getLauncher().getRunningApp(new AppInfoListener() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
@Override
public void onSuccess(AppInfo appInfo) {
// TODO: this will only work on pinned apps, currently
if (appInfo.getId().indexOf(webAppId) != -1) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(webAppId);
launchSession.setSessionType(LaunchSessionType.WebApp);
launchSession.setService(WebOSTVService.this);
launchSession.setRawData(appInfo.getRawData());
WebOSWebAppSession webAppSession = webAppSessionForLaunchSession(launchSession);
Util.postSuccess(listener, webAppSession);
} else {
launchWebApp(webAppId, params, listener);
}
}
});
}
}
示例9: testPlayMediaDeprecatedWithRequiredParametersOnTheLatestWebOS
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
@Test
public void testPlayMediaDeprecatedWithRequiredParametersOnTheLatestWebOS() {
MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
WebOSWebAppSession webAppSession = Mockito.mock(WebOSWebAppSession.class);
service.mWebAppSessions.put("MediaPlayer", webAppSession);
MediaInfo mediaInfo = new MediaInfo.Builder("url", "mimetype").build();
boolean shouldLoop = true;
service.playMedia(mediaInfo.getUrl(), mediaInfo.getMimeType(), null, null, null,
shouldLoop, listener);
verifyPlayMediaOnTheLatestWebOS(mediaInfo, shouldLoop, listener, webAppSession);
}
示例10: callAndVerifyPlayMediaOnTheLatestWebOS
import com.connectsdk.service.sessions.WebOSWebAppSession; //导入依赖的package包/类
private void callAndVerifyPlayMediaOnTheLatestWebOS(final MediaInfo mediaInfo, boolean shouldLoop) {
MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
WebOSWebAppSession webAppSession = Mockito.mock(WebOSWebAppSession.class);
service.mWebAppSessions.put("MediaPlayer", webAppSession);
service.playMedia(mediaInfo, shouldLoop, listener);
verifyPlayMediaOnTheLatestWebOS(mediaInfo, shouldLoop, listener, webAppSession);
}