1
0
mirror of https://bitbucket.org/HeshamTB/barcodescanner2.git synced 2025-01-11 03:35:31 +01:00

cleanup whitespcae

This commit is contained in:
HeshamTB 2018-05-02 21:17:12 +03:00
parent 4d2de19132
commit 68fee5a553

View File

@ -98,7 +98,6 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
try { try {
//get scan result //get scan result
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
// if not empty // if not empty
if (scanningResult != null) { if (scanningResult != null) {
String result = scanningResult.getContents(); String result = scanningResult.getContents();
@ -113,7 +112,6 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
Toast toast = Toast.makeText(getApplicationContext(), "Key 1 Accepted", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(getApplicationContext(), "Key 1 Accepted", Toast.LENGTH_SHORT);
toast.show(); toast.show();
passed1 = true; passed1 = true;
//take shot of barcode 2 //take shot of barcode 2
IntentIntegrator scanIntegrator = new IntentIntegrator(this); IntentIntegrator scanIntegrator = new IntentIntegrator(this);
scanIntegrator.initiateScan(0); scanIntegrator.initiateScan(0);
@ -126,18 +124,13 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
|| result.equalsIgnoreCase("member3") || result.equalsIgnoreCase("member3")
|| result.equalsIgnoreCase("member4") || result.equalsIgnoreCase("member4")
&& passed1) { && passed1) {
passed1 = false; passed1 = false;
Toast toast = Toast.makeText(getApplicationContext(), "Opening lock", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(getApplicationContext(), "Opening lock", Toast.LENGTH_SHORT);
toast.show(); toast.show();
//flash LED //flash LED
flashLightOn(); flashLightOn();
IntentIntegrator scanIntegrator = new IntentIntegrator(this); IntentIntegrator scanIntegrator = new IntentIntegrator(this);
scanIntegrator.initiateScan(0); scanIntegrator.initiateScan(0);
//Scan again if cont. is checked //Scan again if cont. is checked
//make flash on! //make flash on!
//open door //open door
@ -151,19 +144,15 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
passed1 = false; passed1 = false;
IntentIntegrator scanIntegrator = new IntentIntegrator(this); IntentIntegrator scanIntegrator = new IntentIntegrator(this);
scanIntegrator.initiateScan(0); scanIntegrator.initiateScan(0);
} }
} }
else { else {
Toast toast = Toast.makeText(getApplicationContext(), "Key not accepted", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(getApplicationContext(), "Key not accepted", Toast.LENGTH_SHORT);
toast.show(); toast.show();
passed1 = false; passed1 = false;
IntentIntegrator scanIntegrator = new IntentIntegrator(this); IntentIntegrator scanIntegrator = new IntentIntegrator(this);
scanIntegrator.initiateScan(0); scanIntegrator.initiateScan(0);
} }
} }
else { else {
@ -171,7 +160,6 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
"No scan data received!", Toast.LENGTH_SHORT); "No scan data received!", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
} }
catch (Exception e){ catch (Exception e){
@ -183,17 +171,14 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
private void flashLightOn() { private void flashLightOn() {
try { try {
//Camera settings from https://developer.android.com/reference/android/hardware/Camera.html //Camera settings from https://developer.android.com/reference/android/hardware/Camera.html
android.hardware.Camera.Parameters para; android.hardware.Camera.Parameters para;
android.hardware.Camera cam = android.hardware.Camera.open(0); android.hardware.Camera cam = android.hardware.Camera.open(0);
para = cam.getParameters(); para = cam.getParameters();
para.setFlashMode(para.FLASH_MODE_TORCH); para.setFlashMode(para.FLASH_MODE_TORCH);
cam.setParameters(para); cam.setParameters(para);
//Flash on //Flash on
cam.startPreview(); cam.startPreview();
//Delay //Delay
int dum=0; int dum=0;
for (int i =0;i<999999;i++){ for (int i =0;i<999999;i++){
@ -212,11 +197,7 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
//Flash off //Flash off
cam.stopPreview(); cam.stopPreview();
cam.release(); cam.release();
}
catch (Exception e)
{
} }
catch (Exception e){}
} }
} }