use of com.herewhite.sdk.domain.ConversionInfo 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();
}
use of com.herewhite.sdk.domain.ConversionInfo 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();
}
use of com.herewhite.sdk.domain.ConversionInfo in project whiteboard-android by netless-io.
the class PptResourceCacheActivity 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));
}
});
}
use of com.herewhite.sdk.domain.ConversionInfo in project whiteboard-android by netless-io.
the class PptResourceCacheActivity 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));
}
});
}
use of com.herewhite.sdk.domain.ConversionInfo in project whiteboard-android by netless-io.
the class Converter method checkProgress.
private void checkProgress(String taskId, ConvertType type, final CheckCallback checkCallback) {
String typeUrl = type.equals(ConvertType.Dynamic) ? "dynamic_conversion" : "static_conversion";
Request request = new Request.Builder().url(PPT_ORIGIN + "/services/conversion/tasks/" + taskId + "/progress?roomToken=" + this.roomToken + "&serviceType=" + typeUrl).header("Content-Type", "application/json").header("Accept", "application/json").build();
Call call = client.newCall(request);
final CountDownLatch latch = new CountDownLatch(1);
final Converter that = this;
this.status = ConverterStatus.Checking;
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
checkCallback.onCheckFailure(e);
that.status = ConverterStatus.CheckingFail;
latch.countDown();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
JsonObject json = gson.fromJson(response.body().string(), JsonObject.class);
if (response.code() == 200) {
JsonObject task = json.getAsJsonObject("msg").getAsJsonObject("task");
ConversionInfo info = gson.fromJson(gson.toJson(task), ConversionInfo.class);
checkCallback.onCheckResponse(info);
} else {
ConvertException e = new ConvertException(ConvertErrorCode.ConvertFail, gson.toJson(json));
checkCallback.onCheckFailure(e);
}
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations