正常に画像を取得できるように

This commit is contained in:
r-ca 2024-01-21 18:45:51 +09:00
parent 8c71dedd85
commit f0b4cc556e
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
3 changed files with 21 additions and 8 deletions

View File

@ -161,11 +161,12 @@ public class ScannerManagerActivity extends AppCompatActivity {
dialog.setCancelable(false);
dialog.show();
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
document.createDocument(documentMeta).thenAccept((documentDetail1) -> {
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
this.croppedImages.toArray(bitmaps);
addPagesToDocumentDetail(documentDetail1, bitmaps).join();
document.updateDocument(documentDetail1).join();
document.createDocument(documentMeta).thenAccept((documentDetail) -> {
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
croppedImages.toArray(bitmaps);
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
addPagesToDocumentDetail(documentDetail, bitmaps).join();
document.updateDocument(documentDetail).join();
dialog.dismiss();
finish();
});

View File

@ -21,6 +21,7 @@ import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.utils.LacertaLogger;
/**
* A simple {@link Fragment} subclass.
@ -33,6 +34,9 @@ public class ComponentViewerTopFragment extends Fragment {
@Inject
Document document;
@Inject
LacertaLogger logger;
private static final String TAG = "ComponentViewerTopFragment";
private String documentId;
@ -71,9 +75,11 @@ public class ComponentViewerTopFragment extends Fragment {
recyclerView.setAdapter(viewerBodyAdapter);
document.getDocument(documentId).thenAccept(documentDetail -> {
viewerBodyAdapter.setPages(documentDetail.getPages());
ArrayList<Page> pages = documentDetail.getPages();
logger.debug(TAG, "pages.size(): " + pages.size());
viewerBodyAdapter.setPages(pages);
getActivity().runOnUiThread(() -> {
viewerBodyAdapter.notifyItemRangeChanged(0, documentDetail.getPages().size());
viewerBodyAdapter.notifyItemRangeChanged(0, pages.size());
});
});

View File

@ -157,7 +157,13 @@ public class DocumentImpl implements Document {
return CompletableFuture.supplyAsync(() -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
try {
return xmlMetaParser.deserialize(fileManager.resolve(documentId).loadXml("meta.xml")).getPages();
ArrayList<XmlMetaPageModel> xmlMetaPageModels = xmlMetaParser.deserialize(fileManager.resolve(documentId).loadXml("meta.xml")).getPages();
// Debug
logger.debug(TAG, "xmlMetaPageModels: " + xmlMetaPageModels.size());
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
logger.debug(TAG, "\txmlMetaPageModel: " + xmlMetaPageModel.getFilename());
}
return xmlMetaPageModels;
} catch (IOException e) {
logger.error(TAG, "DocumentMeta parse error");
logger.trace(TAG, e.getMessage());