ドキュメント新規保存のロジックを実装 WIP

This commit is contained in:
ろむねこ 2024-01-17 11:05:25 +09:00
parent 119771a7f9
commit dea5f240f0
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -26,9 +26,12 @@ import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.data.Document; import one.nem.lacerta.data.Document;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
@AndroidEntryPoint @AndroidEntryPoint
public class ScannerManagerActivity extends AppCompatActivity { public class ScannerManagerActivity extends AppCompatActivity {
@ -41,6 +44,11 @@ public class ScannerManagerActivity extends AppCompatActivity {
@Inject @Inject
Document document; Document document;
@Inject
DocumentProcessorFactory documentProcessorFactory;
@Inject
LacertaVcsFactory lacertaVcsFactory;
// Variables // Variables
private ArrayList<Bitmap> croppedImages = new ArrayList<>(); private ArrayList<Bitmap> croppedImages = new ArrayList<>();
@ -145,7 +153,18 @@ public class ScannerManagerActivity extends AppCompatActivity {
private void saveNewDocument() { private void saveNewDocument() {
logger.debug(TAG, "saveNewDocument"); logger.debug(TAG, "saveNewDocument");
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
document.createDocument(documentMeta); DocumentDetail documentDetail = document.createDocument(documentMeta);
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
this.croppedImages.toArray(bitmaps);
try {
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
finish();
} catch (Exception e) {
logger.error(TAG, "Error: " + e.getMessage());
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
}
} }
private void insertToExistDocument() { private void insertToExistDocument() {