diff --git a/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java b/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java index 20ab99fb6..40ea80a93 100644 --- a/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java +++ b/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java @@ -117,47 +117,34 @@ public class BarcodeSelectorActivity extends CatimaAppCompatActivity private void setButtonListener(final View button, final String cardId) { - button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Log.d(TAG, "Selected no barcode"); - Intent result = new Intent(); - result.putExtra(BARCODE_FORMAT, ""); - result.putExtra(BARCODE_CONTENTS, cardId); - BarcodeSelectorActivity.this.setResult(RESULT_OK, result); - finish(); - } + button.setOnClickListener(view -> { + Log.d(TAG, "Selected no barcode"); + Intent result = new Intent(); + result.putExtra(BARCODE_FORMAT, ""); + result.putExtra(BARCODE_CONTENTS, cardId); + BarcodeSelectorActivity.this.setResult(RESULT_OK, result); + finish(); }); } private void createBarcodeOption(final ImageView image, final String formatType, final String cardId, final TextView text) { final CatimaBarcode format = CatimaBarcode.fromName(formatType); - if(format == null) - { - Log.w(TAG, "Unsupported barcode format: " + formatType); - return; - } image.setImageBitmap(null); - image.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - Log.d(TAG, "Selected barcode type " + formatType); + image.setOnClickListener(v -> { + Log.d(TAG, "Selected barcode type " + formatType); - if (!((boolean) image.getTag())) { - Toast.makeText(BarcodeSelectorActivity.this, getString(R.string.wrongValueForBarcodeType), Toast.LENGTH_LONG).show(); - return; - } - - Intent result = new Intent(); - result.putExtra(BARCODE_FORMAT, formatType); - result.putExtra(BARCODE_CONTENTS, cardId); - BarcodeSelectorActivity.this.setResult(RESULT_OK, result); - finish(); + if (!((boolean) image.getTag())) { + Toast.makeText(BarcodeSelectorActivity.this, getString(R.string.wrongValueForBarcodeType), Toast.LENGTH_LONG).show(); + return; } + + Intent result = new Intent(); + result.putExtra(BARCODE_FORMAT, formatType); + result.putExtra(BARCODE_CONTENTS, cardId); + BarcodeSelectorActivity.this.setResult(RESULT_OK, result); + finish(); }); if(image.getHeight() == 0) diff --git a/app/src/main/java/protect/card_locker/CatimaBarcode.java b/app/src/main/java/protect/card_locker/CatimaBarcode.java index ccb633bd2..91301353d 100644 --- a/app/src/main/java/protect/card_locker/CatimaBarcode.java +++ b/app/src/main/java/protect/card_locker/CatimaBarcode.java @@ -3,10 +3,11 @@ package protect.card_locker; import com.google.zxing.BarcodeFormat; import java.util.Arrays; +import java.util.Collections; import java.util.List; public class CatimaBarcode { - public static final List barcodeFormats = Arrays.asList( + public static final List barcodeFormats = Collections.unmodifiableList(Arrays.asList( BarcodeFormat.AZTEC, BarcodeFormat.CODE_39, BarcodeFormat.CODE_128, @@ -19,9 +20,9 @@ public class CatimaBarcode { BarcodeFormat.QR_CODE, BarcodeFormat.UPC_A, BarcodeFormat.UPC_E - ); + )); - public static final List barcodePrettyNames = Arrays.asList( + public static final List barcodePrettyNames = Collections.unmodifiableList(Arrays.asList( "Aztec", "Code 39", "Code 128", @@ -34,7 +35,7 @@ public class CatimaBarcode { "QR Code", "UPC A", "UPC E" - ); + )); private final BarcodeFormat mBarcodeFormat;