FreeShare Geek v3.1.8290版本的 MD5 值为:492ca3ae4cdfab7e2d18d5e1b4428e75
以下内容为反编译后的 ZBarScannerActivity.java 源代码,内容仅作参考
package com.stkj.presenter.ui.qrcode;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.widget.Toast;
import com.google.zxing.ReaderException;
import com.google.zxing.b;
import com.google.zxing.d;
import com.google.zxing.f;
import com.google.zxing.h;
import com.stkj.presenter.i;
import com.stkj.presenter.router.InterceptActivity;
import com.stkj.ui.core.c;
import com.stkj.ui.core.j;
public class ZBarScannerActivity extends c implements Camera.PreviewCallback, com.stkj.ui.def.c {
private a q;
private Camera r;
private d s;
private Handler t;
private String v;
private boolean f1995u = true;
private Runnable w = new Runnable() {
@Override
public void run() {
if (ZBarScannerActivity.this.r != null && ZBarScannerActivity.this.f1995u) {
ZBarScannerActivity.this.r.autoFocus(ZBarScannerActivity.this.n);
}
}
};
Camera.AutoFocusCallback n = new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean z, Camera camera) {
ZBarScannerActivity.this.t.postDelayed(ZBarScannerActivity.this.w, 1000L);
}
};
public static void a(Activity activity) {
activity.startActivityForResult(new Intent(activity, (Class<?>) ZBarScannerActivity.class), 273);
}
@Override
protected void a(Bundle bundle) {
if (!m()) {
n();
return;
}
this.t = new Handler();
l();
this.q = new a(this, this, this.n);
setContentView(this.q);
}
@Override
public void k() {
super.k();
o();
}
public void l() {
this.s = new d();
}
@Override
public void onResume() {
super.onResume();
try {
this.r = Camera.open();
if (this.r == null) {
a(i.camera_unavailable);
n();
return;
}
try {
this.r.setDisplayOrientation(90);
} catch (Exception e) {
e.printStackTrace();
}
this.q.setCamera(this.r);
this.q.b();
this.f1995u = true;
} catch (Exception e2) {
Log.e("camera", e2.toString());
a(i.camera_unavailable);
n();
}
}
private void a(int i) {
Toast.makeText(this, i, 0).show();
}
@Override
public void onPause() {
super.onPause();
if (this.r != null) {
this.q.setCamera(null);
this.r.cancelAutoFocus();
this.r.setOneShotPreviewCallback(null);
this.r.stopPreview();
this.r.release();
this.q.a();
this.f1995u = false;
this.r = null;
}
}
public boolean m() {
return getPackageManager().hasSystemFeature("android.hardware.camera");
}
public void n() {
Intent intent = new Intent();
intent.putExtra("ERROR_INFO", "Camera unavailable");
setResult(0, intent);
finish();
}
private f a(Camera camera, byte[] bArr, int i, int i2) {
try {
return new f(bArr, i, i2, 0, 0, i, i2, false);
} catch (Exception e) {
return null;
}
}
@Override
public void onPreviewFrame(byte[] bArr, Camera camera) {
h hVar;
Camera.Size previewSize = camera.getParameters().getPreviewSize();
f a2 = a(camera, bArr, previewSize.width, previewSize.height);
if (a2 != null) {
try {
hVar = this.s.a(new b(new com.google.zxing.common.i(a2)));
this.s.a();
} catch (ReaderException e) {
this.s.a();
hVar = null;
} catch (ArrayIndexOutOfBoundsException e2) {
this.s.a();
hVar = null;
} catch (NullPointerException e3) {
this.s.a();
hVar = null;
} catch (Throwable th) {
this.s.a();
throw th;
}
} else {
hVar = null;
}
if (hVar == null) {
this.r.setOneShotPreviewCallback(this);
return;
}
this.r.cancelAutoFocus();
this.r.setOneShotPreviewCallback(null);
this.r.stopPreview();
this.f1995u = false;
a(hVar.a());
}
private void a(String str) {
if (!InterceptActivity.a(this, str) && !str.startsWith("backups://")) {
if (str.startsWith("http://192.168")) {
Toast.makeText(this, i.scan_fail_need_wifi, 0).show();
} else {
Toast.makeText(this, i.scan_fail_not_support, 0).show();
}
finish();
return;
}
if (InterceptActivity.a(this, str)) {
InterceptActivity.a(this, Uri.parse(str));
} else if (str.startsWith("backups://")) {
if (!com.stkj.ui.b.a.a(this)) {
Toast.makeText(this, i.check_network, 0).show();
finish();
return;
} else {
this.v = str;
j.a(1201, this, new String[]{"android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"}, this);
return;
}
}
finish();
}
private String b(String str) {
if (str.startsWith("dianchuan://")) {
str.lastIndexOf("/");
return str.substring("dianchuan://".length());
}
if (str.startsWith("backups://")) {
return str.substring("backups://".length(), str.length());
}
return null;
}
@Override
public void a(com.stkj.ui.def.b bVar) {
}
@Override
public void g_() {
}
@Override
public void c(int i) {
switch (i) {
case 1201:
if (this.v != null) {
Toast.makeText(this, i.copying, 1).show();
com.stkj.processor.impl.l.a.a().b(b(this.v));
com.stkj.processor.impl.l.a.a().a(false);
new com.stkj.processor.impl.a.b().a(this, new com.stkj.processor.def.a.f() {
@Override
public void a(boolean z, int i2) {
int i3 = i.copy_contact_failed;
switch (i2) {
case 0:
i3 = i.check_network;
break;
case 1:
i3 = i.check_contact;
break;
case 2:
i3 = i.copy_contact_success;
break;
case 3:
i3 = i.success_backup;
break;
case 4:
i3 = i.no_contact_on_cloud;
break;
}
Toast.makeText(ZBarScannerActivity.this, i3, 0).show();
}
});
break;
}
break;
}
finish();
}
@Override
public void a(int i, String[] strArr) {
j.a((Context) this);
finish();
}
@Override
public void d_(int i) {
}
@Override
public void e(int i) {
}
@Override
public void a(Context context) {
}
@Override
public void b(Context context) {
}
@Override
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
j.a(this, this, i, strArr, iArr);
}
}