package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; import com.google.zxing.DecodeHintType; import com.google.zxing.NotFoundException; import com.google.zxing.ReaderException; import com.google.zxing.Result; import com.google.zxing.common.BitArray; import java.util.ArrayList; import java.util.Collection; import java.util.Map; /* loaded from: classes.dex */ public final class MultiFormatUPCEANReader extends OneDReader { private final UPCEANReader[] a; public MultiFormatUPCEANReader(Map map) { Collection collection = map == null ? null : (Collection) map.get(DecodeHintType.POSSIBLE_FORMATS); ArrayList arrayList = new ArrayList(); if (collection != null) { if (collection.contains(BarcodeFormat.EAN_13)) { arrayList.add(new EAN13Reader()); } else if (collection.contains(BarcodeFormat.UPC_A)) { arrayList.add(new UPCAReader()); } if (collection.contains(BarcodeFormat.EAN_8)) { arrayList.add(new EAN8Reader()); } if (collection.contains(BarcodeFormat.UPC_E)) { arrayList.add(new UPCEReader()); } } if (arrayList.isEmpty()) { arrayList.add(new EAN13Reader()); arrayList.add(new EAN8Reader()); arrayList.add(new UPCEReader()); } this.a = (UPCEANReader[]) arrayList.toArray(new UPCEANReader[arrayList.size()]); } @Override // com.google.zxing.oned.OneDReader public Result a(int i, BitArray bitArray, Map map) throws NotFoundException { boolean z; int[] a = UPCEANReader.a(bitArray); for (UPCEANReader uPCEANReader : this.a) { try { Result a2 = uPCEANReader.a(i, bitArray, a, map); boolean z2 = a2.a() == BarcodeFormat.EAN_13 && a2.e().charAt(0) == '0'; Collection collection = map == null ? null : (Collection) map.get(DecodeHintType.POSSIBLE_FORMATS); if (collection != null && !collection.contains(BarcodeFormat.UPC_A)) { z = false; if (z2 || !z) { return a2; } Result result = new Result(a2.e().substring(1), a2.b(), a2.d(), BarcodeFormat.UPC_A); result.a(a2.c()); return result; } z = true; if (z2) { } return a2; } catch (ReaderException unused) { } } throw NotFoundException.getNotFoundInstance(); } @Override // com.google.zxing.oned.OneDReader, com.google.zxing.Reader public void reset() { for (UPCEANReader uPCEANReader : this.a) { uPCEANReader.reset(); } } }