Search in sources :

Example 1 with ConverterV5

use of com.herewhite.sdk.converter.ConverterV5 in project whiteboard-android by netless-io.

the class RoomActivity method dynamicConvert.

public void dynamicConvert(MenuItem item) {
    Converter c = new Converter(this.token);
    c.startConvertTask("https://white-cn-edge-doc-convert.oss-cn-hangzhou.aliyuncs.com/-1/1.pptx", Converter.ConvertType.Dynamic, new ConverterCallbacks() {

        @Override
        public void onFailure(ConvertException e) {
            logAction(e.getMessage());
        }

        @Override
        public void onFinish(ConvertedFiles ppt, ConversionInfo convertInfo) {
            mRoom.putScenes("/dynamic", ppt.getScenes(), 0);
            mRoom.setScenePath("/dynamic/1");
            logAction(convertInfo.toString());
        }

        @Override
        public void onProgress(Double progress, ConversionInfo convertInfo) {
            logAction(String.valueOf(progress));
        }
    });
    // ConvertV5
    ConverterV5.Builder builder = new ConverterV5.Builder();
    ConverterV5 converter = builder.setResource("https://white-cn-edge-doc-convert.oss-cn-hangzhou.aliyuncs.com/-1/1.pptx").setType(ConvertType.Dynamic).setPreview(true).setSdkToken(demoAPI.getSdkToken()).setTaskUuid(null).setTaskToken(null).setCallback(new ConverterCallbacks() {

        @Override
        public void onProgress(Double progress, ConversionInfo convertInfo) {
        }

        @Override
        public void onFinish(ConvertedFiles ppt, ConversionInfo convertInfo) {
        }

        @Override
        public void onFailure(ConvertException e) {
        }
    }).build();
    converter.startConvertTask();
}
Also used : ConvertException(com.herewhite.sdk.domain.ConvertException) MapBuilder(com.herewhite.demo.utils.MapBuilder) Converter(com.herewhite.sdk.Converter) ConverterCallbacks(com.herewhite.sdk.ConverterCallbacks) ConvertedFiles(com.herewhite.sdk.domain.ConvertedFiles) ConversionInfo(com.herewhite.sdk.domain.ConversionInfo) ConverterV5(com.herewhite.sdk.converter.ConverterV5)

Example 2 with ConverterV5

use of com.herewhite.sdk.converter.ConverterV5 in project whiteboard-android by netless-io.

the class PptOldActivity method insertPpt.

public void insertPpt(String dir) {
    CloudFile cloudStorageFile = gson.fromJson(FLAT_CLOUD_FILE_JSON, CloudFile.class);
    ConverterV5 converterV5 = new ConverterV5.Builder().setResource(cloudStorageFile.fileURL).setType(ConvertType.Dynamic).setTaskUuid(cloudStorageFile.taskUUID).setTaskToken(cloudStorageFile.taskToken).setCallback(new ConverterCallbacks() {

        @Override
        public void onProgress(Double progress, ConversionInfo convertInfo) {
        }

        @Override
        public void onFinish(ConvertedFiles ppt, ConversionInfo convertInfo) {
            mRoom.putScenes(dir, ppt.getScenes(), 0);
            mRoom.setScenePath(dir + "/1");
        }

        @Override
        public void onFailure(ConvertException e) {
        }
    }).build();
    converterV5.startConvertTask();
}
Also used : ConvertException(com.herewhite.sdk.domain.ConvertException) MapBuilder(com.herewhite.demo.utils.MapBuilder) ConverterCallbacks(com.herewhite.sdk.ConverterCallbacks) ConvertedFiles(com.herewhite.sdk.domain.ConvertedFiles) ConverterV5(com.herewhite.sdk.converter.ConverterV5) ConversionInfo(com.herewhite.sdk.domain.ConversionInfo)

Example 3 with ConverterV5

use of com.herewhite.sdk.converter.ConverterV5 in project whiteboard-android by netless-io.

the class ConvertV5Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_convert_v5);
    display = findViewById(R.id.textDisplay);
    start = findViewById(R.id.startButton);
    start.setOnClickListener(v -> new Thread(() -> {
        int testCount = 10;
        String[] resources = new String[] { "https://white-cn-edge-doc-convert.oss-cn-hangzhou.aliyuncs.com/-1/1.pptx", "https://beings.oss-cn-hangzhou.aliyuncs.com/test/cb839dc0a17811ebb08929f76725f043.pptx" };
        TestCallback[] callbacks = new TestCallback[testCount];
        CountDownLatch latch = new CountDownLatch(testCount);
        for (int i = 0; i < testCount; i++) {
            callbacks[i] = new TestCallback(latch);
            ConverterV5.Builder builder = new ConverterV5.Builder();
            ConverterV5 converter = builder.setResource(resources[i % resources.length]).setType(randomInt(1) == 1 ? ConvertType.Static : ConvertType.Dynamic).setPreview(randomInt(1) == 1).setOutputFormat(randomInt(1) == 1 ? ImageFormat.PNG : ImageFormat.JPEG).setTimeout(60_000L).setPoolInterval(2000).setSdkToken(DemoAPI.get().getSdkToken()).setCallback(callbacks[i]).build();
            converter.startConvertTask();
        }
        try {
            latch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
            return;
        }
        boolean allSuccess = true;
        for (TestCallback callback : callbacks) {
            allSuccess &= (callback.countFailure + callback.countFinish == 1);
        }
        showTestResult(allSuccess);
    }).start());
}
Also used : ConverterV5(com.herewhite.sdk.converter.ConverterV5) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 4 with ConverterV5

use of com.herewhite.sdk.converter.ConverterV5 in project whiteboard-android by netless-io.

the class RoomActivity method staticConvert.

public void staticConvert(MenuItem item) {
    Converter c = new Converter(this.token);
    c.startConvertTask("https://white-cn-edge-doc-convert.oss-cn-hangzhou.aliyuncs.com/LightWaves.pdf", Converter.ConvertType.Static, new ConverterCallbacks() {

        @Override
        public void onFailure(ConvertException e) {
            logAction(e.getMessage());
        }

        @Override
        public void onFinish(ConvertedFiles ppt, ConversionInfo convertInfo) {
            mRoom.putScenes("/static", ppt.getScenes(), 0);
            mRoom.setScenePath("/static/1");
            logAction(convertInfo.toString());
        }

        @Override
        public void onProgress(Double progress, ConversionInfo convertInfo) {
            logAction(String.valueOf(progress));
        }
    });
    // ConvertV5
    ConverterV5.Builder builder = new ConverterV5.Builder();
    ConverterV5 converter = builder.setResource("https://white-cn-edge-doc-convert.oss-cn-hangzhou.aliyuncs.com/LightWaves.pdf").setType(ConvertType.Static).setScale(1.5).setOutputFormat(ImageFormat.JPEG).setSdkToken(demoAPI.getSdkToken()).setTaskUuid(null).setTaskToken(null).setCallback(new ConverterCallbacks() {

        @Override
        public void onProgress(Double progress, ConversionInfo convertInfo) {
        }

        @Override
        public void onFinish(ConvertedFiles ppt, ConversionInfo convertInfo) {
        }

        @Override
        public void onFailure(ConvertException e) {
        }
    }).build();
    converter.startConvertTask();
}
Also used : ConvertException(com.herewhite.sdk.domain.ConvertException) MapBuilder(com.herewhite.demo.utils.MapBuilder) Converter(com.herewhite.sdk.Converter) ConverterCallbacks(com.herewhite.sdk.ConverterCallbacks) ConvertedFiles(com.herewhite.sdk.domain.ConvertedFiles) ConversionInfo(com.herewhite.sdk.domain.ConversionInfo) ConverterV5(com.herewhite.sdk.converter.ConverterV5)

Aggregations

ConverterV5 (com.herewhite.sdk.converter.ConverterV5)4 MapBuilder (com.herewhite.demo.utils.MapBuilder)3 ConverterCallbacks (com.herewhite.sdk.ConverterCallbacks)3 ConversionInfo (com.herewhite.sdk.domain.ConversionInfo)3 ConvertException (com.herewhite.sdk.domain.ConvertException)3 ConvertedFiles (com.herewhite.sdk.domain.ConvertedFiles)3 Converter (com.herewhite.sdk.Converter)2 CountDownLatch (java.util.concurrent.CountDownLatch)1