mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
非同期化
This commit is contained in:
parent
acc5b166d5
commit
e6a4393b6d
|
@ -1,5 +1,6 @@
|
|||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
@ -22,6 +23,7 @@ import com.websitebeaver.documentscanner.DocumentScanner;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
@ -152,21 +154,31 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
|||
|
||||
private void saveNewDocument() {
|
||||
logger.debug(TAG, "saveNewDocument");
|
||||
// Deprecatedだが、中断機能が存在しないので操作をブロックする目的で(意図的に)使用
|
||||
ProgressDialog dialog = new ProgressDialog(this);
|
||||
dialog.setMessage("保存中..."); // TODO-rca: テキストをリソースに移動
|
||||
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
|
||||
DocumentDetail documentDetail = document.createDocument(documentMeta);
|
||||
document.createDocument(documentMeta).thenAccept((documentDetail1) -> {
|
||||
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
|
||||
this.croppedImages.toArray(bitmaps);
|
||||
addPagesToDocumentDetail(documentDetail1, bitmaps).thenRun(() -> {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
|
||||
Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show();
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printLog(); // Debug
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printRev(); // Debug
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
logger.error(TAG, "Error: " + e.getMessage());
|
||||
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void insertToExistDocument() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user