mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
throws追加, 実装WIP
This commit is contained in:
parent
f3ac07e633
commit
1af344a6d3
|
@ -5,8 +5,8 @@ import android.graphics.Bitmap;
|
||||||
public interface DocumentProcessor {
|
public interface DocumentProcessor {
|
||||||
|
|
||||||
// ページ操作
|
// ページ操作
|
||||||
void addNewPageToLast(Bitmap bitmap);
|
void addNewPageToLast(Bitmap bitmap) throws Exception;
|
||||||
void addNewPagesToLast(Bitmap[] bitmaps);
|
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
|
||||||
void addNewPageAfterIndex(Bitmap bitmap, int index);
|
void addNewPageAfterIndex(Bitmap bitmap, int index);
|
||||||
void addNewPageBeforeIndex(Bitmap bitmap, int index);
|
void addNewPageBeforeIndex(Bitmap bitmap, int index);
|
||||||
void removePageAtIndex(int index);
|
void removePageAtIndex(int index);
|
||||||
|
|
|
@ -62,7 +62,8 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
||||||
if (fileManager.isExist("meta.xml")) {
|
if (fileManager.isExist("meta.xml")) {
|
||||||
logger.debug("init", "meta.xml found");
|
logger.debug("init", "meta.xml found");
|
||||||
try {
|
try {
|
||||||
xmlMetaModel = xmlMetaParser.deserialize(this.fileManager.loadDocument("meta.xml"));
|
this.xmlMetaModel = xmlMetaParser.deserialize(this.fileManager.loadXml("meta.xml"));
|
||||||
|
logger.debug("init", "meta.xml parsed");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.debug("init", "meta.xml parse failed");
|
logger.debug("init", "meta.xml parse failed");
|
||||||
logger.trace("init", e.getMessage());
|
logger.trace("init", e.getMessage());
|
||||||
|
@ -78,7 +79,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
||||||
xmlMetaModel.setPages(new ArrayList<>());
|
xmlMetaModel.setPages(new ArrayList<>());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.fileManager.saveDocument(xmlMetaParser.serialize(xmlMetaModel), "meta.xml");
|
this.fileManager.createFile("meta.xml").saveXml(xmlMetaParser.serialize(xmlMetaModel));
|
||||||
logger.debug("init", "meta.xml saved");
|
logger.debug("init", "meta.xml saved");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("init", "meta.xml save failed");
|
logger.error("init", "meta.xml save failed");
|
||||||
|
@ -90,33 +91,15 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNewPageToLast(Bitmap bitmap) {
|
public void addNewPageToLast(Bitmap bitmap) throws Exception{
|
||||||
logger.debug("addNewPageToLast", "called");
|
logger.debug("addNewPageToLast", "called");
|
||||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||||
|
|
||||||
// FileManager
|
this.fileManager.resolve(DEFAULT_SAVE_DIR).createDirectory();
|
||||||
if (this.fileManager.getCurrentDir().equals(this.documentRootPath.resolve(DEFAULT_SAVE_DIR))) { // TODO-rca: 効率化
|
|
||||||
logger.debug("addNewPageToLast", "currentDir is documentRootPath");
|
|
||||||
} else {
|
|
||||||
logger.debug("addNewPageToLast", "currentDir is not documentRootPath");
|
|
||||||
this.fileManager.backRootDir();
|
|
||||||
this.fileManager.autoCreateDir(DEFAULT_SAVE_DIR);
|
|
||||||
this.fileManager.changeDir(DEFAULT_SAVE_DIR);
|
|
||||||
}
|
|
||||||
logger.debug("addNewPageToLast", "DirInit finished");
|
|
||||||
|
|
||||||
// Save file
|
|
||||||
this.fileManager.saveBitmapAtCurrent(bitmap, filename);
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
XmlMetaPageModel page = new XmlMetaPageModel();
|
|
||||||
page.setIndex(xmlMetaModel.getPages().size() + 1);
|
|
||||||
page.setFilename(filename);
|
|
||||||
xmlMetaModel.addPage(page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNewPagesToLast(Bitmap[] bitmaps) {
|
public void addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
|
||||||
logger.debug("addNewPagesToLast", "called");
|
logger.debug("addNewPagesToLast", "called");
|
||||||
|
|
||||||
for (Bitmap bitmap : bitmaps) {
|
for (Bitmap bitmap : bitmaps) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user