Search in sources :

Example 6 with Scene

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

the class Room method getScenes.

/**
 * 获取房间当前场景组下的场景列表。
 *
 * @note
 * - 该方法为异步调用。
 * - 调用以下方法修改或新增场景后,可以调用 {@link #getScenes(Promise<Scene[]> promise) getScenes},立即获取最新的场景列表。
 *   - {@link #setScenePath(String path) setScenePath}[1/2]
 *   - {@link #setScenePath(String path, Promise<Boolean> promise) setScenePath}[2/2]
 *   - {@link #putScenes(String, Scene[], int) putScenes}
 *
 * @param promise `Promise<Scene[]>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getScenes` 的调用结果:
 *                - 如果方法调用成功,则返回场景列表,详见 {@link com.herewhite.sdk.domain.Scene Scene}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getScenes(final Promise<Scene[]> promise) {
    bridge.callHandler("room.getScenes", new Object[] {}, new OnReturnValue<Object>() {

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

Example 7 with Scene

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

the class PptResourceCacheActivity method insertNewScene.

public void insertNewScene(MenuItem item) {
    logAction();
    mRoom.putScenes(SCENE_DIR, new Scene[] { new Scene("page1") }, 0);
    mRoom.setScenePath(SCENE_DIR + "/page1");
}
Also used : Scene(com.herewhite.sdk.domain.Scene)

Example 8 with Scene

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

the class RoomActivity method insertPPT.

public void insertPPT(MenuItem item) {
    logAction();
    mRoom.putScenes(SCENE_DIR, new Scene[] { new Scene("page2", new PptPage("https://white-pan.oss-cn-shanghai.aliyuncs.com/101/image/alin-rusu-1239275-unsplash_opt.jpg", 600d, 600d)) }, 0);
    mRoom.setScenePath(SCENE_DIR + "/page2");
}
Also used : PptPage(com.herewhite.sdk.domain.PptPage) Scene(com.herewhite.sdk.domain.Scene)

Example 9 with Scene

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

the class RoomActivityTest method moveScene.

@Test
public void moveScene() {
    onIdle();
    SceneStateRecover recover = new SceneStateRecover(mActivity.mRoom.getSceneState());
    CountDownLatch latch = new CountDownLatch(2);
    onIdle((Callable<Void>) () -> {
        mActivity.mRoom.putScenes(PUT_TEST_DIR, new Scene[] { new Scene(PUT_TEST_PAGE) }, 0);
        mActivity.mRoom.setScenePath(PUT_TEST_PATH, new SimpleLatchDownPromise<>(latch));
        mActivity.mRoom.moveScene(PUT_TEST_PATH, PUT_TEST_PATH_TARGET);
        mActivity.mRoom.getSceneState(new SimpleLatchDownPromise<>(latch));
        return null;
    });
    try {
        latch.await();
    } catch (InterruptedException e) {
        fail();
    }
    onIdle((Callable<Void>) () -> {
        assertEquals(PUT_TEST_PATH_TARGET, mActivity.mRoom.getSceneState().getScenePath());
        mActivity.mRoom.removeScenes(PUT_TEST_DIR);
        return null;
    });
    recover.restore();
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Scene(com.herewhite.sdk.domain.Scene) Test(org.junit.Test)

Example 10 with Scene

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

the class Converter method getPpt.

private ConvertedFiles getPpt(ConversionInfo info, ConvertType type) {
    int fileLength = info.getConvertedFileList().length;
    String[] sliderURLs = new String[fileLength];
    Scene[] scenes = new Scene[fileLength];
    ConvertedFiles files = new ConvertedFiles();
    files.setTaskId(taskId);
    files.setType(convertType(type));
    for (int i = 0; i < fileLength; i++) {
        PptPage pptPage = info.getConvertedFileList()[i];
        pptPage.setSrc(info.getPrefix() + pptPage.getSrc());
        sliderURLs[i] = pptPage.getSrc();
        scenes[i] = new Scene(String.valueOf(i + 1), pptPage);
    }
    files.setSlideURLs(sliderURLs);
    files.setScenes(scenes);
    return files;
}
Also used : ConvertedFiles(com.herewhite.sdk.domain.ConvertedFiles) PptPage(com.herewhite.sdk.domain.PptPage) Scene(com.herewhite.sdk.domain.Scene)

Aggregations

Scene (com.herewhite.sdk.domain.Scene)11 PptPage (com.herewhite.sdk.domain.PptPage)4 SDKError (com.herewhite.sdk.domain.SDKError)3 Test (org.junit.Test)3 View (android.view.View)2 ConvertedFiles (com.herewhite.sdk.domain.ConvertedFiles)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Espresso.onView (androidx.test.espresso.Espresso.onView)1 UiController (androidx.test.espresso.UiController)1 CountingIdlingResource (androidx.test.espresso.idling.CountingIdlingResource)1 JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 LocalFileWebViewClient (com.herewhite.demo.LocalFileWebViewClient)1 SimpleViewAction (com.herewhite.demo.utils.SimpleViewAction)1 WhiteboardView (com.herewhite.sdk.WhiteboardView)1 SceneState (com.herewhite.sdk.domain.SceneState)1 WindowAppParam (com.herewhite.sdk.domain.WindowAppParam)1 WindowPrefersColorScheme (com.herewhite.sdk.domain.WindowPrefersColorScheme)1 File (java.io.File)1 IOException (java.io.IOException)1