Search in sources :

Example 1 with WindowParams

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

the class WindowRegisterAppActivity method joinRoom.

private void joinRoom(String uuid, String token) {
    logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
    WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
    configuration.setUserCursor(true);
    configuration.setUseMultiViews(true);
    mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
    mWhiteSdk.setCommonCallbacks(new CommonCallback() {

        @Override
        public void onLogger(JSONObject object) {
            logAction(object.toString());
        }
    });
    // 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
    RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
    roomParams.setWritable(true);
    HashMap<String, String> styleMap = new HashMap<>();
    styleMap.put("bottom", "12px");
    styleMap.put("left", "60px");
    styleMap.put("position", "fixed");
    WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
    roomParams.setWindowParams(windowParams);
    registerMonaco();
    registerEmbedPage();
    mWhiteSdk.joinRoom(roomParams, new AbstractRoomCallbacks() {

        @Override
        public void onPhaseChanged(RoomPhase phase) {
            logRoomInfo("onPhaseChanged: " + phase.name());
            showToast(phase.name());
        }

        @Override
        public void onRoomStateChanged(RoomState roomState) {
            if (roomState.getWindowBoxState() != null) {
                logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
            }
        }
    }, new Promise<Room>() {

        @Override
        public void then(Room room) {
            mRoom = room;
        }

        @Override
        public void catchEx(SDKError sdkError) {
        }
    });
}
Also used : CommonCallback(com.herewhite.sdk.CommonCallback) HashMap(java.util.HashMap) WhiteSdkConfiguration(com.herewhite.sdk.WhiteSdkConfiguration) AbstractRoomCallbacks(com.herewhite.sdk.AbstractRoomCallbacks) SDKError(com.herewhite.sdk.domain.SDKError) RoomParams(com.herewhite.sdk.RoomParams) JSONObject(org.json.JSONObject) WindowParams(com.herewhite.sdk.domain.WindowParams) RoomPhase(com.herewhite.sdk.domain.RoomPhase) WhiteSdk(com.herewhite.sdk.WhiteSdk) Room(com.herewhite.sdk.Room) RoomState(com.herewhite.sdk.domain.RoomState)

Example 2 with WindowParams

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

the class WindowRestoreActivity method joinRoom.

private void joinRoom(String uuid, String token) {
    logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
    WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(DemoAPI.get().getAppId(), true);
    configuration.setUserCursor(true);
    configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
    configuration.setUseMultiViews(true);
    mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
    mWhiteSdk.setCommonCallbacks(new CommonCallback() {

        @Override
        public void onLogger(JSONObject object) {
            logAction(object.toString());
        }
    });
    RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
    HashMap<String, String> styleMap = new HashMap<>();
    styleMap.put("backgroundColor", "red");
    styleMap.put("bottom", "12px");
    styleMap.put("left", "60px");
    styleMap.put("position", "fixed");
    WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
    roomParams.setWindowParams(windowParams);
    mWhiteSdk.joinRoom(roomParams, new RoomListener() {

        @Override
        public void onPhaseChanged(RoomPhase phase) {
            logRoomInfo("onPhaseChanged: " + phase.name());
            showToast(phase.name());
        }

        @Override
        public void onDisconnectWithError(Exception e) {
        }

        @Override
        public void onKickedWithReason(String s) {
        }

        @Override
        public void onRoomStateChanged(RoomState roomState) {
            if (roomState.getWindowBoxState() != null) {
                logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
            }
        }

        @Override
        public void onCanUndoStepsUpdate(long l) {
        }

        @Override
        public void onCanRedoStepsUpdate(long l) {
        }

        @Override
        public void onCatchErrorWhenAppendFrame(long l, Exception e) {
        }
    }, new Promise<Room>() {

        @Override
        public void then(Room room) {
            mRoom = room;
        }

        @Override
        public void catchEx(SDKError sdkError) {
        }
    });
}
Also used : CommonCallback(com.herewhite.sdk.CommonCallback) HashMap(java.util.HashMap) WhiteSdkConfiguration(com.herewhite.sdk.WhiteSdkConfiguration) SDKError(com.herewhite.sdk.domain.SDKError) RoomParams(com.herewhite.sdk.RoomParams) RoomListener(com.herewhite.sdk.RoomListener) JSONObject(org.json.JSONObject) WindowParams(com.herewhite.sdk.domain.WindowParams) RoomPhase(com.herewhite.sdk.domain.RoomPhase) WhiteSdk(com.herewhite.sdk.WhiteSdk) Room(com.herewhite.sdk.Room) RoomState(com.herewhite.sdk.domain.RoomState)

Example 3 with WindowParams

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

the class WindowTestActivity method joinRoom.

private void joinRoom(String uuid, String token) {
    logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
    WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
    /*显示用户头像*/
    configuration.setUserCursor(true);
    // 动态 ppt 需要的自定义字体,如果没有使用,无需调用
    configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
    // configuration.setEnableSyncedStore(true);
    configuration.setUseMultiViews(true);
    mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
    mWhiteSdk.setCommonCallbacks(new CommonCallback() {

        @Override
        public void onLogger(JSONObject object) {
            logAction(object.toString());
        }
    });
    /* 设置自定义全局状态,在后续回调中 GlobalState 直接进行类型转换即可 */
    WhiteDisplayerState.setCustomGlobalStateClass(GlobalState.class);
    // 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
    RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
    HashMap<String, String> styleMap = new HashMap<>();
    styleMap.put("backgroundColor", "red");
    styleMap.put("top", "12px");
    styleMap.put("left", "60px");
    styleMap.put("position", "fixed");
    // String darkMode = darkModeStyle();
    WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
    // optional
    roomParams.setWindowParams(windowParams);
    mWhiteSdk.joinRoom(roomParams, new RoomListener() {

        @Override
        public void onPhaseChanged(RoomPhase phase) {
            logRoomInfo("onPhaseChanged: " + phase.name());
            showToast(phase.name());
        }

        @Override
        public void onDisconnectWithError(Exception e) {
        }

        @Override
        public void onKickedWithReason(String s) {
        }

        @Override
        public void onRoomStateChanged(RoomState roomState) {
            if (roomState.getWindowBoxState() != null) {
                logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
            }
        }

        @Override
        public void onCanUndoStepsUpdate(long l) {
        }

        @Override
        public void onCanRedoStepsUpdate(long l) {
        }

        @Override
        public void onCatchErrorWhenAppendFrame(long l, Exception e) {
        }

        @Override
        public void onAttributesUpdate(String valueOf) {
            state = gson.fromJson(valueOf, UserSyncedState.class);
            logRoomInfo("onAttributesUpdate:" + state);
            updateDragView();
        }
    }, new Promise<Room>() {

        @Override
        public void then(Room room) {
            mRoom = room;
        }

        @Override
        public void catchEx(SDKError sdkError) {
        }
    });
}
Also used : CommonCallback(com.herewhite.sdk.CommonCallback) HashMap(java.util.HashMap) WhiteSdkConfiguration(com.herewhite.sdk.WhiteSdkConfiguration) SDKError(com.herewhite.sdk.domain.SDKError) RoomParams(com.herewhite.sdk.RoomParams) RoomListener(com.herewhite.sdk.RoomListener) IOException(java.io.IOException) JSONObject(org.json.JSONObject) WindowParams(com.herewhite.sdk.domain.WindowParams) RoomPhase(com.herewhite.sdk.domain.RoomPhase) WhiteSdk(com.herewhite.sdk.WhiteSdk) Room(com.herewhite.sdk.Room) RoomState(com.herewhite.sdk.domain.RoomState)

Aggregations

CommonCallback (com.herewhite.sdk.CommonCallback)3 Room (com.herewhite.sdk.Room)3 RoomParams (com.herewhite.sdk.RoomParams)3 WhiteSdk (com.herewhite.sdk.WhiteSdk)3 WhiteSdkConfiguration (com.herewhite.sdk.WhiteSdkConfiguration)3 RoomPhase (com.herewhite.sdk.domain.RoomPhase)3 RoomState (com.herewhite.sdk.domain.RoomState)3 SDKError (com.herewhite.sdk.domain.SDKError)3 WindowParams (com.herewhite.sdk.domain.WindowParams)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 RoomListener (com.herewhite.sdk.RoomListener)2 AbstractRoomCallbacks (com.herewhite.sdk.AbstractRoomCallbacks)1 IOException (java.io.IOException)1