160 lines
5.6 KiB
Java
160 lines
5.6 KiB
Java
|
package com.journeyapps.barcodescanner;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.res.Resources;
|
||
|
import android.content.res.TypedArray;
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.graphics.Paint;
|
||
|
import android.graphics.Rect;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.View;
|
||
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||
|
import com.journeyapps.barcodescanner.CameraPreview;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
import o.C17083tlK;
|
||
|
import o.VDF;
|
||
|
import o.qCz;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class ViewfinderView extends View {
|
||
|
private static int[] e = {0, 64, 128, 192, 255, 192, 128, 64};
|
||
|
List<qCz> a;
|
||
|
private Rect b;
|
||
|
private CameraPreview c;
|
||
|
private int d;
|
||
|
private List<qCz> f;
|
||
|
private int g;
|
||
|
private VDF h;
|
||
|
private boolean i;
|
||
|
private Paint j;
|
||
|
private int l;
|
||
|
private int m;
|
||
|
private Bitmap n;
|
||
|
|
||
|
/* renamed from: o, reason: collision with root package name */
|
||
|
private int f6501o;
|
||
|
|
||
|
public ViewfinderView(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
this.j = new Paint(1);
|
||
|
Resources resources = getResources();
|
||
|
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, C17083tlK.ojQ.zxing_finder);
|
||
|
this.g = obtainStyledAttributes.getColor(C17083tlK.ojQ.zxing_finder_zxing_viewfinder_mask, resources.getColor(C17083tlK.IeS.zxing_viewfinder_mask));
|
||
|
this.f6501o = obtainStyledAttributes.getColor(C17083tlK.ojQ.zxing_finder_zxing_result_view, resources.getColor(C17083tlK.IeS.zxing_result_view));
|
||
|
this.d = obtainStyledAttributes.getColor(C17083tlK.ojQ.zxing_finder_zxing_viewfinder_laser, resources.getColor(C17083tlK.IeS.zxing_viewfinder_laser));
|
||
|
this.m = obtainStyledAttributes.getColor(C17083tlK.ojQ.zxing_finder_zxing_possible_result_points, resources.getColor(C17083tlK.IeS.zxing_possible_result_points));
|
||
|
this.i = obtainStyledAttributes.getBoolean(C17083tlK.ojQ.zxing_finder_zxing_viewfinder_laser_visibility, true);
|
||
|
obtainStyledAttributes.recycle();
|
||
|
this.l = 0;
|
||
|
this.a = new ArrayList(20);
|
||
|
this.f = new ArrayList(20);
|
||
|
}
|
||
|
|
||
|
public void setCameraPreview(CameraPreview cameraPreview) {
|
||
|
this.c = cameraPreview;
|
||
|
cameraPreview.h.add(new CameraPreview.Sts(this) { // from class: com.journeyapps.barcodescanner.ViewfinderView.3
|
||
|
private ViewfinderView c;
|
||
|
|
||
|
@Override // com.journeyapps.barcodescanner.CameraPreview.Sts
|
||
|
public final void b() {
|
||
|
}
|
||
|
|
||
|
@Override // com.journeyapps.barcodescanner.CameraPreview.Sts
|
||
|
public final void c() {
|
||
|
}
|
||
|
|
||
|
@Override // com.journeyapps.barcodescanner.CameraPreview.Sts
|
||
|
public final void d() {
|
||
|
}
|
||
|
|
||
|
@Override // com.journeyapps.barcodescanner.CameraPreview.Sts
|
||
|
public final void d(Exception exc) {
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.c = this;
|
||
|
}
|
||
|
|
||
|
@Override // com.journeyapps.barcodescanner.CameraPreview.Sts
|
||
|
public final void e() {
|
||
|
this.c.d();
|
||
|
this.c.invalidate();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onDraw(Canvas canvas) {
|
||
|
VDF vdf;
|
||
|
d();
|
||
|
Rect rect = this.b;
|
||
|
if (rect == null || (vdf = this.h) == null) {
|
||
|
return;
|
||
|
}
|
||
|
int width = getWidth();
|
||
|
int height = getHeight();
|
||
|
this.j.setColor(this.g);
|
||
|
float f = width;
|
||
|
canvas.drawRect(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, f, rect.top, this.j);
|
||
|
canvas.drawRect(BitmapDescriptorFactory.HUE_RED, rect.top, rect.left, rect.bottom + 1, this.j);
|
||
|
canvas.drawRect(rect.right + 1, rect.top, f, rect.bottom + 1, this.j);
|
||
|
canvas.drawRect(BitmapDescriptorFactory.HUE_RED, rect.bottom + 1, f, height, this.j);
|
||
|
if (this.i) {
|
||
|
this.j.setColor(this.d);
|
||
|
Paint paint = this.j;
|
||
|
int[] iArr = e;
|
||
|
paint.setAlpha(iArr[this.l]);
|
||
|
this.l = (this.l + 1) % iArr.length;
|
||
|
int height2 = (rect.height() / 2) + rect.top;
|
||
|
canvas.drawRect(rect.left + 2, height2 - 1, rect.right - 1, height2 + 2, this.j);
|
||
|
}
|
||
|
float width2 = getWidth() / vdf.c;
|
||
|
float height3 = getHeight() / vdf.b;
|
||
|
if (!this.f.isEmpty()) {
|
||
|
this.j.setAlpha(80);
|
||
|
this.j.setColor(this.m);
|
||
|
for (qCz qcz : this.f) {
|
||
|
canvas.drawCircle((int) (qcz.a * width2), (int) (qcz.e * height3), 3.0f, this.j);
|
||
|
}
|
||
|
this.f.clear();
|
||
|
}
|
||
|
if (!this.a.isEmpty()) {
|
||
|
this.j.setAlpha(160);
|
||
|
this.j.setColor(this.m);
|
||
|
for (qCz qcz2 : this.a) {
|
||
|
canvas.drawCircle((int) (qcz2.a * width2), (int) (qcz2.e * height3), 6.0f, this.j);
|
||
|
}
|
||
|
List<qCz> list = this.a;
|
||
|
List<qCz> list2 = this.f;
|
||
|
this.a = list2;
|
||
|
this.f = list;
|
||
|
list2.clear();
|
||
|
}
|
||
|
postInvalidateDelayed(80L, rect.left - 6, rect.top - 6, rect.right + 6, rect.bottom + 6);
|
||
|
}
|
||
|
|
||
|
protected final void d() {
|
||
|
CameraPreview cameraPreview = this.c;
|
||
|
if (cameraPreview == null) {
|
||
|
return;
|
||
|
}
|
||
|
Rect rect = cameraPreview.c;
|
||
|
VDF vdf = this.c.j;
|
||
|
if (rect == null || vdf == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.b = rect;
|
||
|
this.h = vdf;
|
||
|
}
|
||
|
|
||
|
public void setMaskColor(int i) {
|
||
|
this.g = i;
|
||
|
}
|
||
|
|
||
|
public void setLaserVisibility(boolean z) {
|
||
|
this.i = z;
|
||
|
}
|
||
|
}
|