正在查看: Súper Préstamo v1.9.1 应用的 CustomTakePhotoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Súper Préstamo v1.9.1 应用的 CustomTakePhotoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.pf.prestafast.view.activity.apply.takephoto;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.ImageCapture;
import androidx.camera.core.ImageCaptureException;
import androidx.camera.core.Preview;
import androidx.camera.core.UseCase;
import androidx.camera.lifecycle.ProcessCameraProvider;
import androidx.core.content.ContextCompat;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.pf.prestafast.R$color;
import com.pf.prestafast.R$id;
import com.pf.prestafast.R$layout;
import com.pf.prestafast.base.BaseActivity;
import com.pf.prestafast.view.activity.apply.takephoto.CustomTakePhotoActivity;
import defpackage.dx;
import defpackage.e60;
import defpackage.f30;
import defpackage.ff0;
import defpackage.gl;
import defpackage.h30;
import defpackage.i01;
import defpackage.io0;
import defpackage.lb1;
import defpackage.ml;
import defpackage.sa;
import defpackage.t41;
import defpackage.tk;
import defpackage.ua;
import defpackage.yo;
import defpackage.zx;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public final class CustomTakePhotoActivity extends BaseActivity {
public ProcessCameraProvider f;
public Preview h;
public Camera j;
public ImageCapture m;
public File n;
public Map o = new LinkedHashMap();
public static final class a implements ff0 {
public a() {
}
@Override
public void a(List list, boolean z) {
}
@Override
public void b(List list, boolean z) {
if (z) {
CustomTakePhotoActivity.this.T();
}
}
}
public static final class b implements ImageCapture.OnImageSavedCallback {
public static final class a extends i01 implements dx {
public int a;
public final CustomTakePhotoActivity b;
public static final class C0018a extends i01 implements dx {
public int a;
public final CustomTakePhotoActivity b;
public C0018a(CustomTakePhotoActivity customTakePhotoActivity, tk tkVar) {
super(2, tkVar);
this.b = customTakePhotoActivity;
}
@Override
public final tk create(Object obj, tk tkVar) {
return new C0018a(this.b, tkVar);
}
@Override
public final Object invoke(ml mlVar, tk tkVar) {
return ((C0018a) create(mlVar, tkVar)).invokeSuspend(t41.a);
}
@Override
public final Object invokeSuspend(Object obj) {
h30.c();
if (this.a != 0) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
io0.b(obj);
CustomTakePhotoActivity customTakePhotoActivity = this.b;
File file = customTakePhotoActivity.n;
f30.e(file);
customTakePhotoActivity.S(file);
return t41.a;
}
}
public a(CustomTakePhotoActivity customTakePhotoActivity, tk tkVar) {
super(2, tkVar);
this.b = customTakePhotoActivity;
}
@Override
public final tk create(Object obj, tk tkVar) {
return new a(this.b, tkVar);
}
@Override
public final Object invoke(ml mlVar, tk tkVar) {
return ((a) create(mlVar, tkVar)).invokeSuspend(t41.a);
}
@Override
public final Object invokeSuspend(Object obj) {
Object c = h30.c();
int i = this.a;
if (i == 0) {
io0.b(obj);
this.b.A();
gl b = yo.b();
C0018a c0018a = new C0018a(this.b, null);
this.a = 1;
if (sa.e(b, c0018a, this) == c) {
return c;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
io0.b(obj);
}
this.b.r();
CustomTakePhotoActivity customTakePhotoActivity = this.b;
int i2 = R$id.mIvPhotoImg;
((ImageView) customTakePhotoActivity.G(i2)).setVisibility(0);
Glide.with((ImageView) this.b.G(i2)).load(this.b.n).transition(DrawableTransitionOptions.withCrossFade()).into((ImageView) this.b.G(i2));
((ImageView) this.b.G(R$id.mIvConfirm)).setVisibility(0);
((ImageView) this.b.G(R$id.mIvCancel)).setVisibility(0);
return t41.a;
}
}
public b() {
}
public void onError(ImageCaptureException imageCaptureException) {
f30.h(imageCaptureException, "exception");
((ImageView) CustomTakePhotoActivity.this.G(R$id.mIvTakePhoto)).setVisibility(0);
System.out.println(imageCaptureException.getImageCaptureError());
((ImageView) CustomTakePhotoActivity.this.G(R$id.mIvConfirm)).setVisibility(8);
((ImageView) CustomTakePhotoActivity.this.G(R$id.mIvCancel)).setVisibility(8);
}
public void onImageSaved(ImageCapture.OutputFileResults outputFileResults) {
f30.h(outputFileResults, "outputFileResults");
((ImageView) CustomTakePhotoActivity.this.G(R$id.mIvTakePhoto)).setVisibility(0);
if (FileUtils.getLength(CustomTakePhotoActivity.this.n) > 0) {
ua.b(zx.a, yo.c(), null, new a(CustomTakePhotoActivity.this, null), 2, null);
}
}
}
public static final void N(CustomTakePhotoActivity customTakePhotoActivity, View view) {
f30.h(customTakePhotoActivity, "this$0");
customTakePhotoActivity.finish();
}
public static final void O(CustomTakePhotoActivity customTakePhotoActivity, View view) {
f30.h(customTakePhotoActivity, "this$0");
Intent intent = new Intent();
File file = customTakePhotoActivity.n;
intent.putExtra("face_file", file != null ? file.getAbsolutePath() : null);
customTakePhotoActivity.setResult(-1, intent);
customTakePhotoActivity.finish();
}
public static final void P(CustomTakePhotoActivity customTakePhotoActivity, View view) {
f30.h(customTakePhotoActivity, "this$0");
((ImageView) customTakePhotoActivity.G(R$id.mIvConfirm)).setVisibility(8);
((ImageView) customTakePhotoActivity.G(R$id.mIvCancel)).setVisibility(8);
int i = R$id.mIvPhotoImg;
((ImageView) customTakePhotoActivity.G(i)).setImageResource(R$color.white);
((ImageView) customTakePhotoActivity.G(i)).setVisibility(8);
}
public static final void Q(CustomTakePhotoActivity customTakePhotoActivity, View view) {
f30.h(customTakePhotoActivity, "this$0");
customTakePhotoActivity.V();
}
public static final void U(CustomTakePhotoActivity customTakePhotoActivity, e60 e60Var) {
f30.h(customTakePhotoActivity, "this$0");
f30.h(e60Var, "$cameraProviderFuture");
try {
Object obj = e60Var.get();
f30.g(obj, "cameraProviderFuture.get()");
ProcessCameraProvider processCameraProvider = (ProcessCameraProvider) obj;
customTakePhotoActivity.f = processCameraProvider;
if (processCameraProvider == null) {
f30.w("cameraProvider");
processCameraProvider = null;
}
customTakePhotoActivity.K(processCameraProvider);
} catch (Exception e) {
e.printStackTrace();
}
}
public View G(int i) {
Map map = this.o;
View view = (View) map.get(Integer.valueOf(i));
if (view != null) {
return view;
}
View findViewById = findViewById(i);
if (findViewById == null) {
return null;
}
map.put(Integer.valueOf(i), findViewById);
return findViewById;
}
public final void K(ProcessCameraProvider processCameraProvider) {
this.h = new Preview.Builder().build();
this.m = new ImageCapture.Builder().build();
processCameraProvider.unbindAll();
this.j = processCameraProvider.bindToLifecycle(this, CameraSelector.DEFAULT_FRONT_CAMERA, new UseCase[]{this.h, this.m});
Preview preview = this.h;
if (preview != null) {
preview.setSurfaceProvider(G(R$id.previewView).getSurfaceProvider());
}
}
public final int L(String str) {
try {
int attributeInt = new ExifInterface(str).getAttributeInt("Orientation", 1);
LogUtils.dTag("123123123", new Object[]{"orientation=" + attributeInt});
if (attributeInt == 3) {
return 0;
}
if (attributeInt != 6) {
return attributeInt != 8 ? 0 : 90;
}
return -90;
} catch (IOException e) {
e.printStackTrace();
return 0;
}
}
public final void M() {
((ImageView) G(R$id.mIvFinish)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
CustomTakePhotoActivity.N(CustomTakePhotoActivity.this, view);
}
});
((ImageView) G(R$id.mIvConfirm)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
CustomTakePhotoActivity.O(CustomTakePhotoActivity.this, view);
}
});
((ImageView) G(R$id.mIvCancel)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
CustomTakePhotoActivity.P(CustomTakePhotoActivity.this, view);
}
});
((ImageView) G(R$id.mIvTakePhoto)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
CustomTakePhotoActivity.Q(CustomTakePhotoActivity.this, view);
}
});
}
public final void R() {
lb1.m(this).e("android.permission.CAMERA").l().g(new a());
}
public final void S(File file) {
FileOutputStream fileOutputStream;
Bitmap decodeFile = BitmapFactory.decodeFile(file.getAbsolutePath());
f30.g(decodeFile, "decodeFile(file.absolutePath)");
Matrix matrix = new Matrix();
matrix.postScale(-1.0f, 1.0f);
f30.g(file.getAbsolutePath(), "file.absolutePath");
matrix.postRotate(L(r0));
Bitmap createBitmap = Bitmap.createBitmap(decodeFile, 0, 0, decodeFile.getWidth(), decodeFile.getHeight(), matrix, true);
f30.g(createBitmap, "createBitmap(\n … true\n )");
FileOutputStream fileOutputStream2 = null;
try {
try {
try {
fileOutputStream = new FileOutputStream(file);
} catch (Exception e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
try {
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.close();
} catch (Exception e2) {
e = e2;
fileOutputStream2 = fileOutputStream;
e.printStackTrace();
if (fileOutputStream2 != null) {
fileOutputStream2.close();
}
} catch (Throwable th2) {
th = th2;
fileOutputStream2 = fileOutputStream;
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
throw th;
}
} catch (IOException e4) {
e4.printStackTrace();
}
}
public final void T() {
final e60 processCameraProvider = ProcessCameraProvider.getInstance(this);
f30.g(processCameraProvider, "getInstance(this)");
processCameraProvider.addListener(new Runnable() {
@Override
public final void run() {
CustomTakePhotoActivity.U(CustomTakePhotoActivity.this, processCameraProvider);
}
}, ContextCompat.getMainExecutor(this));
}
public final void V() {
((ImageView) G(R$id.mIvTakePhoto)).setVisibility(8);
File file = new File(getCacheDir(), System.currentTimeMillis() + ".jpg");
this.n = file;
FileUtils.createOrExistsFile(file);
File file2 = this.n;
f30.e(file2);
ImageCapture.OutputFileOptions build = new ImageCapture.OutputFileOptions.Builder(file2).build();
f30.g(build, "Builder(file!!).build()");
ImageCapture imageCapture = this.m;
if (imageCapture != null) {
imageCapture.takePicture(build, ContextCompat.getMainExecutor(this), new b());
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R$layout.activity_cutom_take_photo);
R();
M();
}
}