Singleモード追加

This commit is contained in:
r-ca 2024-01-29 04:17:01 +09:00
parent b0a0682561
commit 719769c045
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -57,8 +57,7 @@ public class ScannerManagerActivity extends AppCompatActivity {
// Variables // Variables
private ArrayList<Bitmap> croppedImages = new ArrayList<>(); private ArrayList<Bitmap> croppedImages = new ArrayList<>();
private int maxPage = 0; private boolean single = false;
private boolean withOutLimit = false;
View view; View view;
@ -86,9 +85,37 @@ public class ScannerManagerActivity extends AppCompatActivity {
}, },
null, null,
null, null,
withOutLimit ? null : maxPage null
); );
DocumentScanner documentScannerSingle = new DocumentScanner( // TODO-rca: ひどすぎるのでなんとかする
this,
(croppedImageResults) -> {
logger.debug(TAG, "croppedImage size: " + croppedImageResults.size());
ArrayList<Bitmap> croppedImages = new ArrayList<>();
for (String result : croppedImageResults) {
croppedImages.add(BitmapFactory.decodeFile(result));
}
processResult(croppedImages);
return null;
},
(errorMessage) -> {
// an error happened
logger.error(TAG, "Error: " + errorMessage);
logger.e_code("543a230e-cb9a-47a2-8131-3beecfe1c458");
return null;
},
() -> {
// user canceled document scan
logger.debug(TAG, "User canceled document scan");
return null;
},
null,
null,
1
);
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -112,17 +139,21 @@ public class ScannerManagerActivity extends AppCompatActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true); Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
this.single = bundle.getBoolean("single", false);
}
if (this.single) {
documentScanner = documentScannerSingle;
}
documentScanner.startScan(); documentScanner.startScan();
// Init // Init
this.view = findViewById(R.id.main); // TODO-rca:なんとかする this.view = findViewById(R.id.main); // TODO-rca:なんとかする
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
this.maxPage = bundle.getInt("maxPage", 0);
this.withOutLimit = bundle.getBoolean("withOutLimit", false);
}
} }
@Override @Override