Search in sources :

Example 31 with SDKError

use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.

the class CameraMoveImageActivity method joinRoom.

private void joinRoom() {
    WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
    whiteSdk = new WhiteSdk(whiteboardView, this, configuration);
    RoomParams roomParams = new RoomParams(demoAPI.getRoomUUID(), demoAPI.getRoomToken(), DemoAPI.DEFAULT_UID);
    whiteSdk.joinRoom(roomParams, new EmptyRoomListener(), new Promise<Room>() {

        @Override
        public void then(Room room) {
            CameraMoveImageActivity.this.room = room;
            loadImageInfo(TEST_IMAGE_URL);
        }

        @Override
        public void catchEx(SDKError t) {
            showToast(t.getMessage());
        }
    });
}
Also used : WhiteSdkConfiguration(com.herewhite.sdk.WhiteSdkConfiguration) SDKError(com.herewhite.sdk.domain.SDKError) RoomParams(com.herewhite.sdk.RoomParams) WhiteSdk(com.herewhite.sdk.WhiteSdk) Room(com.herewhite.sdk.Room) EmptyRoomListener(com.herewhite.demo.utils.EmptyRoomListener)

Example 32 with SDKError

use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.

the class RoomActivityTest method setScenePath_should_start_with_slash_CDL.

@Test
public void setScenePath_should_start_with_slash_CDL() {
    onIdle();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    onView(isRoot()).perform(new SimpleViewAction() {

        @Override
        public void perform(UiController uiController, View view) {
            errorMessage = null;
            mActivity.mRoom.setScenePath("invalid/path", new Promise<Boolean>() {

                @Override
                public void then(Boolean aBoolean) {
                    countDownLatch.countDown();
                }

                @Override
                public void catchEx(SDKError t) {
                    errorMessage = t.getMessage();
                    countDownLatch.countDown();
                }
            });
        }
    });
    try {
        countDownLatch.await();
        assertEquals("path \"invalid/path\" should start with \"/\"", errorMessage);
    } catch (InterruptedException e) {
        fail();
    }
}
Also used : Promise(com.herewhite.sdk.domain.Promise) SimpleViewAction(com.herewhite.demo.utils.SimpleViewAction) SDKError(com.herewhite.sdk.domain.SDKError) UiController(androidx.test.espresso.UiController) CountDownLatch(java.util.concurrent.CountDownLatch) View(android.view.View) Espresso.onView(androidx.test.espresso.Espresso.onView) Test(org.junit.Test)

Example 33 with SDKError

use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.

the class SdkJsInterfaceImpl method setupFail.

@JavascriptInterface
public void setupFail(Object args) {
    JSONObject jsonObject = convertToJsonOrNull(args);
    if (commonCallback != null && jsonObject != null) {
        SDKError sdkError = SDKError.parseError(jsonObject);
        commonCallback.sdkSetupFail(sdkError);
    }
}
Also used : JSONObject(org.json.JSONObject) SDKError(com.herewhite.sdk.domain.SDKError) JavascriptInterface(android.webkit.JavascriptInterface)

Example 34 with SDKError

use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.

the class PlayerTest method getPlayerState.

@Test
public void getPlayerState() {
    PlayerState playerPhase = mPlayer.getPlayerState();
    assertNull(playerPhase);
    mPlayer.getPlayerState(new Promise<PlayerState>() {

        @Override
        public void then(PlayerState playerState) {
        }

        @Override
        public void catchEx(SDKError t) {
        }
    });
    verify(mockJsBridgeInterface).callHandler(eq("player.state.playerState"), any(), any());
}
Also used : PlayerState(com.herewhite.sdk.domain.PlayerState) SDKError(com.herewhite.sdk.domain.SDKError) Test(org.junit.Test)

Example 35 with SDKError

use of com.herewhite.sdk.domain.SDKError in project whiteboard-android by netless-io.

the class Room method getRoomMembers.

/**
 * 获取房间的用户列表。
 *
 * @note
 * - 该方法为异步调用。
 * - 房间的用户列表仅包含互动模式(具有读写权限)的用户,不包含订阅模式(只读权限)的用户。
 *
 * @param promise `Promise<RoomMember[]>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getRoomMembers` 的调用结果:
 *                - 如果方法调用成功,则返回用户列表,详见 {@link com.herewhite.sdk.domain.RoomMember RoomMember}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getRoomMembers(final Promise<RoomMember[]> promise) {
    bridge.callHandler("room.getRoomMembers", new Object[] {}, new OnReturnValue<Object>() {

        @Override
        public void onValue(Object o) {
            try {
                promise.then(gson.fromJson(String.valueOf(o), RoomMember[].class));
            } catch (AssertionError a) {
                throw a;
            } catch (JsonSyntaxException e) {
                Logger.error("An JsonSyntaxException occurred while parse json from getRoomMembers", e);
                promise.catchEx(new SDKError(e.getMessage()));
            } catch (Throwable e) {
                Logger.error("An exception occurred in getRoomMembers promise then method", e);
                promise.catchEx(new SDKError(e.getMessage()));
            }
        }
    });
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) RoomMember(com.herewhite.sdk.domain.RoomMember) SDKError(com.herewhite.sdk.domain.SDKError) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Aggregations

SDKError (com.herewhite.sdk.domain.SDKError)38 JSONObject (org.json.JSONObject)18 JsonSyntaxException (com.google.gson.JsonSyntaxException)13 WhiteSdk (com.herewhite.sdk.WhiteSdk)12 WhiteSdkConfiguration (com.herewhite.sdk.WhiteSdkConfiguration)12 JsonObject (com.google.gson.JsonObject)10 Room (com.herewhite.sdk.Room)10 RoomParams (com.herewhite.sdk.RoomParams)10 RoomPhase (com.herewhite.sdk.domain.RoomPhase)7 RoomState (com.herewhite.sdk.domain.RoomState)7 AbstractRoomCallbacks (com.herewhite.sdk.AbstractRoomCallbacks)5 CommonCallback (com.herewhite.sdk.CommonCallback)5 Test (org.junit.Test)5 RoomCallbacks (com.herewhite.sdk.RoomCallbacks)4 View (android.view.View)3 ConvertException (com.herewhite.sdk.domain.ConvertException)3 FontFace (com.herewhite.sdk.domain.FontFace)3 Scene (com.herewhite.sdk.domain.Scene)3 SceneState (com.herewhite.sdk.domain.SceneState)3 WindowParams (com.herewhite.sdk.domain.WindowParams)3