use of com.herewhite.sdk.domain.SceneState in project whiteboard-android by netless-io.
the class ScenesActivity method onClick.
// sample of scenes apis
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.putScenes:
// create slides on scenes
// it should run only once
mRoom.putScenes(SCENE_DIR, scenes, 0);
mRoom.setScenePath(SCENE_DIR);
break;
case R.id.setScenePath:
mRoom.setScenePath(SCENE_DIR + "/" + scenes[1].getName());
break;
case R.id.setSceneIndex:
// switch scene by index
mRoom.setSceneIndex(2, new Promise<Boolean>() {
@Override
public void then(Boolean aBoolean) {
}
@Override
public void catchEx(SDKError t) {
}
});
break;
case R.id.getRoomState:
// sync SceneState
SceneState sceneState = mRoom.getSceneState();
logRoomInfo("current sceneState " + sceneState.toString());
// get sceneState by async
mRoom.getSceneState(new Promise<SceneState>() {
@Override
public void then(SceneState sceneState) {
logRoomInfo("current sceneState " + sceneState.toString());
}
@Override
public void catchEx(SDKError t) {
}
});
break;
}
}
use of com.herewhite.sdk.domain.SceneState in project whiteboard-android by netless-io.
the class RoomActivityTest method setScenePath.
@Test
public void setScenePath() {
onIdle();
CountingIdlingResource idlingResource = new CountingIdlingResource("getScenePath");
idlingResource.increment();
mActivity.mRoom.getSceneState(new Promise<SceneState>() {
@Override
public void then(SceneState sceneState) {
currentSceneState = sceneState;
idlingResource.decrement();
}
@Override
public void catchEx(SDKError t) {
idlingResource.decrement();
}
});
IdlingRegistry.getInstance().register(idlingResource);
SetScenePathResult result = new SetScenePathResult();
result.register();
onView(isRoot()).perform(new SimpleViewAction() {
@Override
public void perform(UiController uiController, View view) {
IdlingRegistry.getInstance().unregister(idlingResource);
if (currentSceneState == null) {
fail();
}
result.start();
mActivity.mRoom.setScenePath(getNextScenePath(currentSceneState), result);
}
private String getNextScenePath(SceneState currentSceneState) {
String dir = currentSceneState.getScenePath().substring(0, currentSceneState.getScenePath().lastIndexOf('/'));
int index = currentSceneState.getIndex();
Scene[] scenes = currentSceneState.getScenes();
Scene tScene = scenes[(index + 1) % scenes.length];
return dir + '/' + tScene.getName();
}
});
// wait for idling
onIdle();
onView(isRoot()).perform(new SimpleViewAction() {
@Override
public void perform(UiController uiController, View view) {
assertEquals(true, result.success);
result.unregister();
}
});
}
use of com.herewhite.sdk.domain.SceneState in project whiteboard-android by netless-io.
the class ScenesActivity method joinRoom.
// region room
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
roomParams.setDisableNewPencil(false);
roomParams.setWritable(true);
mWhiteSdk.joinRoom(roomParams, new RoomCallbacks() {
@Override
public void onCanUndoStepsUpdate(long canUndoSteps) {
}
@Override
public void onCanRedoStepsUpdate(long canRedoSteps) {
}
@Override
public void onCatchErrorWhenAppendFrame(long userId, Exception error) {
}
@Override
public void onPhaseChanged(RoomPhase phase) {
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
logRoomInfo("onDisconnectWithError: " + e.getMessage());
}
@Override
public void onKickedWithReason(String reason) {
logRoomInfo("onKickedWithReason: " + reason);
}
@Override
public void onRoomStateChanged(RoomState modifyState) {
logRoomInfo("onRoomStateChanged: " + modifyState);
if (modifyState.getSceneState() != null) {
// callback when sceneState changed
SceneState sceneState = modifyState.getSceneState();
logRoomInfo("sceneState changed " + sceneState.toString());
}
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
mRoom = room;
}
@Override
public void catchEx(SDKError t) {
showToast(t.getMessage());
}
});
}
Aggregations