369 lines
12 KiB
Java
369 lines
12 KiB
Java
package com.ubt.jimu.pack.view;
|
|
|
|
import android.app.AlertDialog;
|
|
import android.content.Intent;
|
|
import android.graphics.Bitmap;
|
|
import android.hardware.Sensor;
|
|
import android.hardware.SensorEvent;
|
|
import android.hardware.SensorEventListener;
|
|
import android.hardware.SensorManager;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.util.Log;
|
|
import android.view.SurfaceHolder;
|
|
import android.view.SurfaceView;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
import com.google.zxing.Result;
|
|
import com.google.zxing.client.android.AmbientLightManager;
|
|
import com.google.zxing.client.android.BeepManager;
|
|
import com.google.zxing.client.android.CaptureActivityHandler;
|
|
import com.google.zxing.client.android.DecodeFormatManager;
|
|
import com.google.zxing.client.android.FinishListener;
|
|
import com.google.zxing.client.android.ICaptureView;
|
|
import com.google.zxing.client.android.InactivityTimer;
|
|
import com.google.zxing.client.android.ViewfinderView;
|
|
import com.google.zxing.client.android.camera.CameraManager;
|
|
import com.google.zxing.client.android.result.ResultHandler;
|
|
import com.google.zxing.client.android.result.ResultHandlerFactory;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.Package;
|
|
import com.ubt.jimu.pack.presenter.BarCodeScanPresenter;
|
|
import com.ubtech.view.widget.ToastView;
|
|
import java.io.IOException;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class BarCodeScanActivity extends BaseActivity implements ICaptureView, IBarCodeScanView, SurfaceHolder.Callback, SensorEventListener {
|
|
private ViewfinderView a;
|
|
private CameraManager b;
|
|
private boolean c;
|
|
private InactivityTimer d;
|
|
private BeepManager e;
|
|
private AmbientLightManager f;
|
|
private TextView g;
|
|
private CaptureActivityHandler h;
|
|
private SurfaceHolder i;
|
|
private BarCodeScanPresenter j;
|
|
private SensorManager k;
|
|
private Sensor l;
|
|
private int m;
|
|
|
|
private void D0() {
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
builder.setTitle(getString(R.string.scan_name));
|
|
builder.setMessage(getString(R.string.msg_camera_framework_bug));
|
|
builder.setPositiveButton(R.string.button_ok, new FinishListener(this));
|
|
builder.setOnCancelListener(new FinishListener(this));
|
|
builder.show();
|
|
}
|
|
|
|
private void E0() {
|
|
this.b = new CameraManager(getApplication());
|
|
ViewfinderView viewfinderView = this.a;
|
|
if (viewfinderView != null) {
|
|
viewfinderView.setCameraManager(this.b);
|
|
}
|
|
AmbientLightManager ambientLightManager = this.f;
|
|
if (ambientLightManager != null) {
|
|
ambientLightManager.a(this.b);
|
|
}
|
|
}
|
|
|
|
private void F0() {
|
|
this.c = false;
|
|
this.d = new InactivityTimer(this);
|
|
this.e = new BeepManager(this);
|
|
this.f = new AmbientLightManager(this);
|
|
}
|
|
|
|
private void G0() {
|
|
this.j = new BarCodeScanPresenter(this);
|
|
}
|
|
|
|
private void H0() {
|
|
this.k = (SensorManager) getSystemService("sensor");
|
|
this.l = this.k.getDefaultSensor(3);
|
|
}
|
|
|
|
private void I0() {
|
|
this.i = ((SurfaceView) findViewById(R.id.preview_view)).getHolder();
|
|
if (this.c) {
|
|
a(this.i);
|
|
} else {
|
|
this.i.addCallback(this);
|
|
}
|
|
}
|
|
|
|
private void J0() {
|
|
this.a = (ViewfinderView) findViewById(R.id.viewfinder_view);
|
|
this.g = (TextView) findViewById(R.id.status_view);
|
|
((Button) findViewById(R.id.btn_back)).setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.pack.view.BarCodeScanActivity.1
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
BarCodeScanActivity.this.K0();
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void K0() {
|
|
finish();
|
|
}
|
|
|
|
private void L0() {
|
|
this.g.setText(getResources().getString(R.string.scan_default_status));
|
|
this.g.setVisibility(0);
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:14:0x0028 */
|
|
/* JADX WARN: Removed duplicated region for block: B:18:0x0034 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
private void l(int r4) {
|
|
/*
|
|
r3 = this;
|
|
com.google.zxing.client.android.camera.CameraManager r0 = r3.b
|
|
boolean r0 = r0.f()
|
|
if (r0 == 0) goto L4a
|
|
r0 = 0
|
|
if (r4 == 0) goto L14
|
|
r1 = 1
|
|
if (r4 == r1) goto L1c
|
|
r1 = 2
|
|
if (r4 == r1) goto L19
|
|
r1 = 3
|
|
if (r4 == r1) goto L16
|
|
L14:
|
|
r4 = 0
|
|
goto L1e
|
|
L16:
|
|
r4 = 270(0x10e, float:3.78E-43)
|
|
goto L1e
|
|
L19:
|
|
r4 = 180(0xb4, float:2.52E-43)
|
|
goto L1e
|
|
L1c:
|
|
r4 = 90
|
|
L1e:
|
|
com.google.zxing.client.android.camera.CameraManager r1 = r3.b
|
|
com.google.zxing.client.android.camera.open.CameraFacing r1 = r1.b()
|
|
com.google.zxing.client.android.camera.open.CameraFacing r2 = com.google.zxing.client.android.camera.open.CameraFacing.BACK
|
|
if (r1 != r2) goto L34
|
|
com.google.zxing.client.android.camera.CameraManager r0 = r3.b
|
|
int r0 = r0.e()
|
|
int r0 = r0 - r4
|
|
int r0 = r0 + 360
|
|
int r0 = r0 % 360
|
|
goto L45
|
|
L34:
|
|
com.google.zxing.client.android.camera.open.CameraFacing r2 = com.google.zxing.client.android.camera.open.CameraFacing.FRONT
|
|
if (r1 != r2) goto L45
|
|
com.google.zxing.client.android.camera.CameraManager r0 = r3.b
|
|
int r0 = r0.e()
|
|
int r0 = r0 + r4
|
|
int r0 = r0 % 360
|
|
int r4 = 360 - r0
|
|
int r0 = r4 % 360
|
|
L45:
|
|
com.google.zxing.client.android.camera.CameraManager r4 = r3.b
|
|
r4.b(r0)
|
|
L4a:
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.pack.view.BarCodeScanActivity.l(int):void");
|
|
}
|
|
|
|
private void o(String str) {
|
|
this.g.setText(str);
|
|
}
|
|
|
|
private void p(String str) {
|
|
ToastView.a(this, str, ToastView.Type.NORMAL).a();
|
|
}
|
|
|
|
@Override // com.google.zxing.client.android.ICaptureView
|
|
public ViewfinderView J() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // com.google.zxing.client.android.ICaptureView
|
|
public CameraManager b0() {
|
|
return this.b;
|
|
}
|
|
|
|
@Override // com.google.zxing.client.android.ICaptureView
|
|
public Handler getHandler() {
|
|
return this.h;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.pack.view.IBarCodeScanView
|
|
public void k0() {
|
|
p(getResources().getString(R.string.scan_match_failed));
|
|
a(3000L);
|
|
}
|
|
|
|
@Override // android.hardware.SensorEventListener
|
|
public void onAccuracyChanged(Sensor sensor, int i) {
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
|
protected void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
setContentView(R.layout.barcode_scan);
|
|
J0();
|
|
G0();
|
|
E0();
|
|
F0();
|
|
H0();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onDestroy() {
|
|
InactivityTimer inactivityTimer = this.d;
|
|
if (inactivityTimer != null) {
|
|
inactivityTimer.d();
|
|
}
|
|
BarCodeScanPresenter barCodeScanPresenter = this.j;
|
|
if (barCodeScanPresenter != null) {
|
|
barCodeScanPresenter.a();
|
|
this.j = null;
|
|
}
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onPause() {
|
|
SurfaceHolder surfaceHolder;
|
|
CaptureActivityHandler captureActivityHandler = this.h;
|
|
if (captureActivityHandler != null) {
|
|
captureActivityHandler.a();
|
|
this.h = null;
|
|
}
|
|
this.d.b();
|
|
this.f.a();
|
|
this.e.close();
|
|
CameraManager cameraManager = this.b;
|
|
if (cameraManager != null) {
|
|
cameraManager.a();
|
|
}
|
|
if (!this.c && (surfaceHolder = this.i) != null) {
|
|
surfaceHolder.removeCallback(this);
|
|
}
|
|
this.k.unregisterListener(this);
|
|
super.onPause();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onResume() {
|
|
super.onResume();
|
|
this.e.b();
|
|
this.d.c();
|
|
I0();
|
|
this.k.registerListener(this, this.l, 3);
|
|
this.m = getWindowManager().getDefaultDisplay().getRotation();
|
|
}
|
|
|
|
@Override // android.hardware.SensorEventListener
|
|
public void onSensorChanged(SensorEvent sensorEvent) {
|
|
int rotation = getWindowManager().getDefaultDisplay().getRotation();
|
|
if (this.m != rotation) {
|
|
l(rotation);
|
|
this.m = rotation;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.SurfaceHolder.Callback
|
|
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
|
|
}
|
|
|
|
@Override // android.view.SurfaceHolder.Callback
|
|
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
|
if (surfaceHolder == null) {
|
|
Log.e("BarCodeScanActivity", "*** WARNING *** surfaceCreated() gave us a null surface!");
|
|
}
|
|
if (this.c) {
|
|
return;
|
|
}
|
|
this.c = true;
|
|
a(surfaceHolder);
|
|
}
|
|
|
|
@Override // android.view.SurfaceHolder.Callback
|
|
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
|
this.c = false;
|
|
}
|
|
|
|
@Override // com.google.zxing.client.android.ICaptureView
|
|
public void w() {
|
|
this.a.a();
|
|
}
|
|
|
|
@Override // com.google.zxing.client.android.ICaptureView
|
|
public void a(Result result, Bitmap bitmap, float f) {
|
|
this.d.a();
|
|
ResultHandler a = ResultHandlerFactory.a(this, this, result);
|
|
if (bitmap != null) {
|
|
this.e.a();
|
|
}
|
|
a(result, a);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.pack.view.IBarCodeScanView
|
|
public void o() {
|
|
p(getResources().getString(R.string.loading_error));
|
|
a(5000L);
|
|
}
|
|
|
|
private void a(Result result, ResultHandler resultHandler) {
|
|
o(getResources().getString(R.string.scan_wait));
|
|
this.j.a(getApplicationContext(), result.a(), resultHandler.e().toString());
|
|
}
|
|
|
|
@Override // com.google.zxing.client.android.ICaptureView
|
|
public void a(long j) {
|
|
CaptureActivityHandler captureActivityHandler = this.h;
|
|
if (captureActivityHandler != null) {
|
|
captureActivityHandler.sendEmptyMessageDelayed(R.id.restart_preview, j);
|
|
}
|
|
L0();
|
|
}
|
|
|
|
private void a(SurfaceHolder surfaceHolder) {
|
|
if (surfaceHolder != null) {
|
|
if (this.b.f()) {
|
|
Log.w("BarCodeScanActivity", "initCamera() while already open -- late SurfaceView callback?");
|
|
return;
|
|
}
|
|
try {
|
|
this.b.a(surfaceHolder);
|
|
if (this.h == null) {
|
|
this.h = new CaptureActivityHandler(this, this, DecodeFormatManager.b, null, null, this.b);
|
|
return;
|
|
}
|
|
return;
|
|
} catch (IOException e) {
|
|
Log.w("BarCodeScanActivity", e);
|
|
D0();
|
|
return;
|
|
} catch (RuntimeException e2) {
|
|
Log.w("BarCodeScanActivity", "Unexpected error initializing camera", e2);
|
|
D0();
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException("No SurfaceHolder provided");
|
|
}
|
|
|
|
@Override // com.ubt.jimu.pack.view.IBarCodeScanView
|
|
public void a(Package r3) {
|
|
Intent intent = new Intent();
|
|
intent.putExtra("scan_result_package", r3);
|
|
setResult(-1, intent);
|
|
finish();
|
|
}
|
|
}
|