From f7b8006fa44f4b8683f99c99f690385d3ccb600a Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 8 Jan 2024 14:42:29 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=83=AD=E3=82=B8=E3=83=83?= =?UTF-8?q?=E3=82=AF=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../processor/impl/DocumentProcessorImpl.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 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 8b48e65c..8d21ad54 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 @@ -8,6 +8,7 @@ import java.util.UUID; import dagger.assisted.Assisted; import dagger.assisted.AssistedInject; +import one.nem.lacerta.model.document.internal.XmlMetaPageModel; import one.nem.lacerta.processor.DocumentProcessor; import one.nem.lacerta.model.document.DocumentDetail; @@ -96,18 +97,19 @@ public class DocumentProcessorImpl implements DocumentProcessor{ @Override public void addNewPageToLast(Bitmap bitmap) { logger.debug("addNewPageToLast", "called"); - String fileName = String.format(UUID.randomUUID().toString() + ".png"); // TODO-rca: 対応表をもたせる - logger.debug("addNewPageToLast", "fileName: " + fileName); - FileManager fileManager = fileManagerFactory.create(this.documentRootPath); - if(fileManager.getList().contains(this.documentRootPath.resolve(DEFAULT_SAVE_DIR))) { - logger.debug("addNewPageToLast", "raw dir found"); - fileManager.changeDir(DEFAULT_SAVE_DIR); - } else { - logger.debug("addNewPageToLast", "raw dir not found"); - fileManager.createDir(DEFAULT_SAVE_DIR); - fileManager.changeDir(DEFAULT_SAVE_DIR); - } - fileManager.saveBitmapAtCurrent(bitmap, fileName); + String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする + + // FileManager + this.fileManager.autoCreateDir(DEFAULT_SAVE_DIR); + + // Save file + this.fileManager.saveBitmapAtCurrent(bitmap, filename); + + // Update meta + XmlMetaPageModel page = new XmlMetaPageModel(); + page.setIndex(xmlMetaModel.getPages().size()); + page.setFilename(filename); + xmlMetaModel.addPage(page); } @Override