From 81d545b90b26a2dde278a5bf09e93f1007d42c01 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 25 Dec 2023 13:29:02 +0900 Subject: [PATCH] =?UTF-8?q?addNewPage=E5=AE=9F=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../processor/impl/DocumentProcessorImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java index 602f8cf7..36bbdcef 100644 --- a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java +++ b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java @@ -4,6 +4,7 @@ import android.graphics.Bitmap; import java.io.File; import java.nio.file.Path; +import java.util.UUID; import javax.inject.Inject; @@ -13,21 +14,33 @@ import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.source.file.FileManager; +import one.nem.lacerta.source.file.factory.FileManagerFactory; public class DocumentProcessorImpl implements DocumentProcessor{ + // Magic Numbers + private static final String DEFAULT_SAVE_DIR = "raw"; + private DocumentDetail documentDetail; // Injection @Inject - FileManager fileManager; + FileManagerFactory fileManagerFactory; // Internal utils @Override public void addNewPageToLast(Bitmap bitmap) { Path path = documentDetail.getPath().getFullPath(); -// fileManager.saveBitmap(path, bitmap); + String fileName = String.format(UUID.randomUUID().toString() + ".png"); // TODO-rca: 対応表をもたせる + FileManager fileManager = fileManagerFactory.create(path); + if(fileManager.getList().contains(path.resolve(DEFAULT_SAVE_DIR))) { + fileManager.changeDir(DEFAULT_SAVE_DIR); + } else { + fileManager.createDir(DEFAULT_SAVE_DIR); + fileManager.changeDir(DEFAULT_SAVE_DIR); + } + fileManager.saveBitmapAtCurrent(bitmap, fileName); } @Override