diff --git a/data/src/main/java/one/nem/lacerta/data/Document.java b/data/src/main/java/one/nem/lacerta/data/Document.java index 70610913..3491fc7d 100644 --- a/data/src/main/java/one/nem/lacerta/data/Document.java +++ b/data/src/main/java/one/nem/lacerta/data/Document.java @@ -6,6 +6,7 @@ import java.util.concurrent.CompletableFuture; import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.model.document.path.DocumentPath; import one.nem.lacerta.model.document.tag.DocumentTag; @@ -25,4 +26,6 @@ public interface Document { CompletableFuture updateDocument(DocumentDetail detail); CompletableFuture getDocument(String documentId); + + CompletableFuture> getDocumentPageListByFileNameList(String documentId, ArrayList fileNameList); } diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java index 7a303ec5..523c7277 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java @@ -173,6 +173,34 @@ public class DocumentImpl implements Document { }); } + @Override + public CompletableFuture> getDocumentPageListByFileNameList(String documentId, ArrayList fileNameList) { + return CompletableFuture.supplyAsync(() -> { + ArrayList pages = new ArrayList<>(); + FileManager fileManager; + try { + fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()).resolve(documentId).resolve("raw"); + } catch (IOException e) { + logger.error(TAG, "FileManager resolve error"); + logger.trace(TAG, e.getMessage()); + logger.e_code("1210ae5b-dd2f-42ef-bc15-40b9a9bbdb16"); + return null; + } + + fileNameList.forEach(fileName -> { + try { + pages.add(new Page(fileName, fileManager.loadBitmap(fileName))); + } catch (IOException e) { + logger.error(TAG, "Bitmap decode error"); + logger.trace(TAG, e.getMessage()); + logger.e_code("6f9ba0dc-ac63-401c-8f50-a2bd9ff5cb91"); + } + }); + + return pages; + }); + } + private CompletableFuture> getPagesByXmlMeta(String documentId) { return CompletableFuture.supplyAsync(() -> { FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());