2021-08-03 07:33:18 +00:00
|
|
|
package me.dm7.barcodescanner.zxing;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Rect;
|
|
|
|
import android.hardware.Camera;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Looper;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.Log;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.i.a.f.e.o.f;
|
|
|
|
import b.i.e.c;
|
|
|
|
import b.i.e.e;
|
|
|
|
import b.i.e.g;
|
|
|
|
import b.i.e.h;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.google.zxing.NotFoundException;
|
|
|
|
import com.google.zxing.ReaderException;
|
|
|
|
import com.google.zxing.Result;
|
2021-11-02 06:38:17 +00:00
|
|
|
import e0.a.a.a.d;
|
2021-08-03 07:33:18 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.EnumMap;
|
|
|
|
import java.util.List;
|
2021-11-02 06:38:17 +00:00
|
|
|
public class ZXingScannerView extends e0.a.a.a.a {
|
2021-12-17 21:59:34 +00:00
|
|
|
public static final List<b.i.e.a> D;
|
2021-12-02 18:53:44 +00:00
|
|
|
public g E;
|
2021-12-17 21:59:34 +00:00
|
|
|
public List<b.i.e.a> F;
|
2021-12-02 18:53:44 +00:00
|
|
|
public b G;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
public class a implements Runnable {
|
2021-12-02 18:53:44 +00:00
|
|
|
public final /* synthetic */ Result j;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
public a(Result result) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.j = result;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.lang.Runnable
|
|
|
|
public void run() {
|
|
|
|
ZXingScannerView zXingScannerView = ZXingScannerView.this;
|
2021-12-02 18:53:44 +00:00
|
|
|
b bVar = zXingScannerView.G;
|
|
|
|
zXingScannerView.G = null;
|
|
|
|
d dVar = zXingScannerView.k;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (dVar != null) {
|
|
|
|
dVar.e();
|
|
|
|
}
|
|
|
|
if (bVar != null) {
|
2021-12-02 18:53:44 +00:00
|
|
|
bVar.handleResult(this.j);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public interface b {
|
|
|
|
void handleResult(Result result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
ArrayList arrayList = new ArrayList();
|
2021-12-02 18:53:44 +00:00
|
|
|
D = arrayList;
|
2021-12-17 21:59:34 +00:00
|
|
|
arrayList.add(b.i.e.a.AZTEC);
|
|
|
|
arrayList.add(b.i.e.a.CODABAR);
|
|
|
|
arrayList.add(b.i.e.a.CODE_39);
|
|
|
|
arrayList.add(b.i.e.a.CODE_93);
|
|
|
|
arrayList.add(b.i.e.a.CODE_128);
|
|
|
|
arrayList.add(b.i.e.a.DATA_MATRIX);
|
|
|
|
arrayList.add(b.i.e.a.EAN_8);
|
|
|
|
arrayList.add(b.i.e.a.EAN_13);
|
|
|
|
arrayList.add(b.i.e.a.ITF);
|
|
|
|
arrayList.add(b.i.e.a.MAXICODE);
|
|
|
|
arrayList.add(b.i.e.a.PDF_417);
|
|
|
|
arrayList.add(b.i.e.a.QR_CODE);
|
|
|
|
arrayList.add(b.i.e.a.RSS_14);
|
|
|
|
arrayList.add(b.i.e.a.RSS_EXPANDED);
|
|
|
|
arrayList.add(b.i.e.a.UPC_A);
|
|
|
|
arrayList.add(b.i.e.a.UPC_E);
|
|
|
|
arrayList.add(b.i.e.a.UPC_EAN_EXTENSION);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ZXingScannerView(Context context, AttributeSet attributeSet) {
|
|
|
|
super(context, attributeSet);
|
|
|
|
c();
|
|
|
|
}
|
|
|
|
|
|
|
|
public h b(byte[] bArr, int i, int i2) {
|
|
|
|
Rect rect;
|
|
|
|
synchronized (this) {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (this.m == null) {
|
|
|
|
Rect framingRect = ((e0.a.a.a.g) this.l).getFramingRect();
|
|
|
|
int width = this.l.getWidth();
|
|
|
|
int height = this.l.getHeight();
|
2021-08-03 07:33:18 +00:00
|
|
|
if (!(framingRect == null || width == 0)) {
|
|
|
|
if (height != 0) {
|
|
|
|
Rect rect2 = new Rect(framingRect);
|
|
|
|
if (i < width) {
|
|
|
|
rect2.left = (rect2.left * i) / width;
|
|
|
|
rect2.right = (rect2.right * i) / width;
|
|
|
|
}
|
|
|
|
if (i2 < height) {
|
|
|
|
rect2.top = (rect2.top * i2) / height;
|
|
|
|
rect2.bottom = (rect2.bottom * i2) / height;
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
this.m = rect2;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rect = null;
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
rect = this.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
if (rect == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return new h(bArr, i, i2, rect.left, rect.top, rect.width(), rect.height(), false);
|
|
|
|
} catch (Exception unused) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void c() {
|
2021-12-17 21:59:34 +00:00
|
|
|
EnumMap enumMap = new EnumMap(b.i.e.d.class);
|
|
|
|
enumMap.put((EnumMap) b.i.e.d.POSSIBLE_FORMATS, (b.i.e.d) getFormats());
|
2021-08-03 07:33:18 +00:00
|
|
|
g gVar = new g();
|
2021-12-02 18:53:44 +00:00
|
|
|
this.E = gVar;
|
2021-08-03 07:33:18 +00:00
|
|
|
gVar.c(enumMap);
|
|
|
|
}
|
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
public Collection<b.i.e.a> getFormats() {
|
|
|
|
List<b.i.e.a> list = this.F;
|
2021-12-02 18:53:44 +00:00
|
|
|
return list == null ? D : list;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: finally extract failed */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:28:0x0079 A[Catch:{ RuntimeException -> 0x00ee }] */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:55:0x00d6 */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:56:0x00e8 */
|
|
|
|
@Override // android.hardware.Camera.PreviewCallback
|
|
|
|
public void onPreviewFrame(byte[] bArr, Camera camera) {
|
|
|
|
byte[] bArr2;
|
|
|
|
h b2;
|
|
|
|
Result result;
|
|
|
|
Result result2;
|
2021-12-02 18:53:44 +00:00
|
|
|
if (this.G != null) {
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
|
|
|
Camera.Size previewSize = camera.getParameters().getPreviewSize();
|
|
|
|
int i = previewSize.width;
|
|
|
|
int i2 = previewSize.height;
|
2021-12-02 18:53:44 +00:00
|
|
|
if (f.o0(getContext()) == 1) {
|
2021-08-03 07:33:18 +00:00
|
|
|
int rotationCount = getRotationCount();
|
|
|
|
if (rotationCount != 1) {
|
|
|
|
if (rotationCount != 3) {
|
|
|
|
i = i2;
|
|
|
|
i2 = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Camera.Size previewSize2 = camera.getParameters().getPreviewSize();
|
|
|
|
int i3 = previewSize2.width;
|
|
|
|
int i4 = previewSize2.height;
|
|
|
|
int rotationCount2 = getRotationCount();
|
|
|
|
if (rotationCount2 != 1) {
|
|
|
|
if (rotationCount2 != 3) {
|
|
|
|
i = i2;
|
|
|
|
i2 = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int i5 = i4;
|
|
|
|
int i6 = 0;
|
|
|
|
bArr2 = bArr;
|
|
|
|
while (i6 < rotationCount2) {
|
|
|
|
byte[] bArr3 = new byte[bArr2.length];
|
|
|
|
for (int i7 = 0; i7 < i5; i7++) {
|
|
|
|
for (int i8 = 0; i8 < i3; i8++) {
|
|
|
|
bArr3[(((i8 * i5) + i5) - i7) - 1] = bArr2[(i7 * i3) + i8];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i6++;
|
|
|
|
bArr2 = bArr3;
|
|
|
|
i5 = i3;
|
|
|
|
i3 = i5;
|
|
|
|
}
|
|
|
|
b2 = b(bArr2, i2, i);
|
|
|
|
result = null;
|
|
|
|
if (b2 != null) {
|
2021-12-17 21:59:34 +00:00
|
|
|
c cVar = new c(new b.i.e.n.h(b2));
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
2021-12-02 18:53:44 +00:00
|
|
|
g gVar = this.E;
|
2021-12-17 21:59:34 +00:00
|
|
|
if (gVar.f1809b == null) {
|
2021-08-03 07:33:18 +00:00
|
|
|
gVar.c(null);
|
|
|
|
}
|
|
|
|
result2 = gVar.b(cVar);
|
2021-12-02 18:53:44 +00:00
|
|
|
this.E.reset();
|
2021-08-03 07:33:18 +00:00
|
|
|
} catch (ReaderException | ArrayIndexOutOfBoundsException | NullPointerException unused) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.E.reset();
|
2021-08-03 07:33:18 +00:00
|
|
|
result2 = null;
|
|
|
|
} catch (Throwable th) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.E.reset();
|
2021-08-03 07:33:18 +00:00
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
if (result2 == null) {
|
2021-12-17 21:59:34 +00:00
|
|
|
c cVar2 = new c(new b.i.e.n.h(new e(b2)));
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
2021-12-02 18:53:44 +00:00
|
|
|
g gVar2 = this.E;
|
2021-12-17 21:59:34 +00:00
|
|
|
if (gVar2.f1809b == null) {
|
2021-08-03 07:33:18 +00:00
|
|
|
gVar2.c(null);
|
|
|
|
}
|
|
|
|
result = gVar2.b(cVar2);
|
|
|
|
} catch (NotFoundException unused2) {
|
|
|
|
} finally {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.E.reset();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
result = result2;
|
|
|
|
}
|
|
|
|
if (result == null) {
|
|
|
|
new Handler(Looper.getMainLooper()).post(new a(result));
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
camera.setOneShotPreviewCallback(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bArr2 = bArr;
|
|
|
|
i = i2;
|
|
|
|
i2 = i;
|
|
|
|
b2 = b(bArr2, i2, i);
|
|
|
|
result = null;
|
|
|
|
if (b2 != null) {
|
|
|
|
}
|
|
|
|
if (result == null) {
|
|
|
|
}
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
Log.e("ZXingScannerView", e.toString(), e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
public void setFormats(List<b.i.e.a> list) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.F = list;
|
2021-08-03 07:33:18 +00:00
|
|
|
c();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setResultHandler(b bVar) {
|
2021-12-02 18:53:44 +00:00
|
|
|
this.G = bVar;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|