From e3a5dee36cf41f5f329f33f355d55812f9f44eb0 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 9 Jan 2024 17:07:37 +0900 Subject: [PATCH] =?UTF-8?q?addNewPageAfterIndex=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../processor/impl/DocumentProcessorImpl.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 c4669c36..23efa144 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 @@ -118,6 +118,19 @@ public class DocumentProcessorImpl implements DocumentProcessor{ } // TODO-rca: 効率悪いので改善する } + // Internal + // Indexを振り直す + private ArrayList reIndexPages(ArrayList pages) { + logger.debug("reIndexPages", "called"); // TODO-rca: 効率化 + ArrayList newPages = new ArrayList<>(); + for (int i = 0; i < pages.size(); i++) { + XmlMetaPageModel xmlMetaPageModel = pages.get(i); + xmlMetaPageModel.setIndex(i + 1); + newPages.add(xmlMetaPageModel); + } + return newPages; + } + @Override public void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception { logger.debug("addNewPageAfterIndex", "called"); @@ -129,7 +142,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{ xmlMetaPageModel.setFilename(filename); xmlMetaPageModel.setIndex(index + 1); xmlMetaModel.getPages().add(index, xmlMetaPageModel); - + xmlMetaModel.setPages(reIndexPages(xmlMetaModel.getPages())); }