mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Try to use custom scan contrat from zxing library. No success.
This commit is contained in:
parent
e11e1c1b4a
commit
4d365c5092
1 changed files with 9 additions and 16 deletions
|
@ -32,7 +32,6 @@ import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.zxing.client.android.Intents;
|
import com.google.zxing.client.android.Intents;
|
||||||
import com.journeyapps.barcodescanner.ScanContract;
|
|
||||||
import com.journeyapps.barcodescanner.ScanOptions;
|
import com.journeyapps.barcodescanner.ScanOptions;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -216,16 +215,10 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
/** Register the launcher and result handler
|
/** Register the launcher and result handler
|
||||||
* ActivityResultLauncher
|
* ActivityResultLauncher
|
||||||
*/
|
*/
|
||||||
private final ActivityResultLauncher<ScanOptions, ScanIntentResult> barcodeLauncher = registerForActivityResult(new CustomScanContract.StartActivityForResult(),
|
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new PilldroidScanContract(),
|
||||||
new ActivityResultCallback<ActivityResult>() {
|
result -> {
|
||||||
@Override
|
|
||||||
public void onActivityResult(ActivityResult result) {
|
|
||||||
if(result.getResultCode() = Activity.RESULT_OK) {
|
|
||||||
Intent data = result.getData();
|
|
||||||
Log.d(TAG, "return data ==" + data);
|
|
||||||
//doSomeOperations();
|
|
||||||
/*result -> {
|
|
||||||
if(result.getContents() == null) {
|
if(result.getContents() == null) {
|
||||||
|
Toast.makeText(DrugListActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
|
||||||
Intent originalIntent = result.getOriginalIntent();
|
Intent originalIntent = result.getOriginalIntent();
|
||||||
if (originalIntent == null) {
|
if (originalIntent == null) {
|
||||||
Log.d(TAG, "Cancelled Scan");
|
Log.d(TAG, "Cancelled Scan");
|
||||||
|
@ -234,17 +227,17 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
} else if (originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) {
|
} else if (originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) {
|
||||||
Log.d(TAG, "Cancelled scan due missing camera permission");
|
Log.d(TAG, "Cancelled scan due missing camera permission");
|
||||||
Toast.makeText(DrugListActivity.this, "Cancelled due missing camera persmission",
|
Toast.makeText(DrugListActivity.this, "Cancelled due missing camera persmission",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
} else if (originalIntent.hasExtra(Intents.Scan.TIMEOUT)) {
|
} else if (originalIntent.hasExtra(Intents.Scan.TIMEOUT)) {
|
||||||
Log.d(TAG, "Cancelled due timeout");
|
Log.d(TAG, "Cancelled due timeout");
|
||||||
Toast.makeText(DrugListActivity.this, "Cancelled due timeout",
|
Toast.makeText(DrugListActivity.this, "Cancelled due timeout",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Scanned");
|
Log.d(TAG, "Scanned result == " + result.toString());
|
||||||
Toast.makeText(DrugListActivity.this, "Scanned: " + result.getContents(),
|
Toast.makeText(DrugListActivity.this, "Scanned", Toast.LENGTH_LONG).show();
|
||||||
Toast.LENGTH_LONG).show();
|
//Intent originalIntent = scanIntentResult.getOriginalIntent();
|
||||||
}*/
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Launch scan
|
// Launch scan
|
||||||
|
@ -255,7 +248,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
options.setCameraId(0); // Use a specific camera of the device
|
options.setCameraId(0); // Use a specific camera of the device
|
||||||
options.setBeepEnabled(true);
|
options.setBeepEnabled(true);
|
||||||
options.setBarcodeImageEnabled(true);
|
options.setBarcodeImageEnabled(true);
|
||||||
options.setTimeout(60);
|
//options.setTimeout(3600);
|
||||||
options.setCaptureActivity(CustomScannerActivity.class);
|
options.setCaptureActivity(CustomScannerActivity.class);
|
||||||
options.addExtra(Intents.Scan.SCAN_TYPE, Intents.Scan.MIXED_SCAN);
|
options.addExtra(Intents.Scan.SCAN_TYPE, Intents.Scan.MIXED_SCAN);
|
||||||
barcodeLauncher.launch(options);
|
barcodeLauncher.launch(options);
|
||||||
|
|
Loading…
Reference in a new issue