mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
スキャン後の操作を行う画面を実装 WIP
This commit is contained in:
parent
78505c62e6
commit
a6aeb5480a
|
@ -2,10 +2,13 @@ package one.nem.lacerta.component.scanner;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.AnimatorRes;
|
||||
|
@ -32,17 +35,19 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
|||
LacertaLogger logger;
|
||||
|
||||
// Variables
|
||||
private ArrayList<Bitmap> resultImages = new ArrayList<>();
|
||||
private ArrayList<Bitmap> croppedImages = new ArrayList<>();
|
||||
|
||||
View view;
|
||||
|
||||
DocumentScanner documentScanner = new DocumentScanner(
|
||||
this,
|
||||
(croppedImageResults) -> {
|
||||
logger.debug(TAG, "croppedImage size: " + croppedImageResults.size());
|
||||
ArrayList<Bitmap> croppedImages = new ArrayList<>();
|
||||
for (String result : croppedImageResults) {
|
||||
this.resultImages.add(BitmapFactory.decodeFile(result));
|
||||
croppedImages.add(BitmapFactory.decodeFile(result));
|
||||
}
|
||||
initResultView();
|
||||
processResult(croppedImages);
|
||||
return null;
|
||||
},
|
||||
(errorMessage) -> {
|
||||
|
@ -78,18 +83,51 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
|
||||
private void initResultView() {
|
||||
if (this.view == null) {
|
||||
logger.debug(TAG, "initResultView: view is null");
|
||||
return;
|
||||
private void processResult(ArrayList<Bitmap> resultImages) {
|
||||
logger.debug(TAG, "processResult");
|
||||
|
||||
if (resultImages.isEmpty()) {
|
||||
logger.debug(TAG, "resultImages(arg) is empty");
|
||||
if (this.croppedImages.isEmpty()) {
|
||||
logger.debug(TAG, "this.resultImages is empty");
|
||||
logger.error(TAG, "error code: 398f4ca7-06f4-43c4-a153-e2ba5bbdb92b"); // TODO-rca: Loggerに組み込む?
|
||||
// TODO-rca: なんかする
|
||||
} else {
|
||||
logger.debug(TAG, "this.resultImages is not empty");
|
||||
updateResultView(this.croppedImages);
|
||||
}
|
||||
} else {
|
||||
logger.debug(TAG, "resultImages(arg) is not empty");
|
||||
updateResultView(resultImages);
|
||||
this.croppedImages = resultImages;
|
||||
}
|
||||
|
||||
// Log pt
|
||||
logger.debug(TAG, "Total images: " + this.resultImages.size());
|
||||
}
|
||||
|
||||
LinearLayout resultContainer = view.findViewById(R.id.result_list_container);
|
||||
private void updateResultView(ArrayList<Bitmap> resultImages) {
|
||||
logger.debug(TAG, "updateResultView");
|
||||
|
||||
// ImageButtonを追加する
|
||||
LinearLayout resultView = findViewById(R.id.result_list_container);
|
||||
resultView.removeAllViews();
|
||||
|
||||
for (Bitmap resultImage : resultImages) {
|
||||
View resultImageView = getLayoutInflater().inflate(R.layout.result_image_container_item, null);
|
||||
ImageView imageView = resultImageView.findViewById(R.id.result_image);
|
||||
imageView.setImageBitmap(resultImage);
|
||||
imageView.setOnClickListener(v -> {
|
||||
// タッチされた画像をプレビューに設定します。
|
||||
// selectedImage.setImageBitmap(resultImage);
|
||||
// すべての画像の選択状態を解除します。
|
||||
for (int i = 0; i < resultView.getChildCount(); i++) {
|
||||
View child = resultView.getChildAt(i).findViewById(R.id.result_image);
|
||||
child.setSelected(false);
|
||||
}
|
||||
// タッチされた画像を選択状態にします。
|
||||
v.setSelected(true);
|
||||
});
|
||||
|
||||
resultView.addView(resultImageView);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/result_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="64dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="@drawable/result_image_container_item_border"
|
||||
android:padding="8dp"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user