乐健体育 v3.9.1版本的 MD5 值为:87ae8a64955cdd0e43f3559ee8984d75
以下内容为反编译后的 a.java 源代码,内容仅作参考
package io.dcloud.feature.pdr;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.text.TextUtils;
import com.taobao.weex.common.Constants;
import com.taobao.weex.el.parse.Operators;
import io.dcloud.base.R;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.constant.DOMException;
import io.dcloud.common.util.Deprecated_JSUtil;
import io.dcloud.common.util.FileUtil;
import io.dcloud.common.util.JSUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.ThreadPool;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Locale;
import org.json.JSONException;
import org.json.JSONObject;
public class a {
public class RunnableC0191a implements Runnable {
public final IWebview a;
public final String[] b;
public RunnableC0191a(IWebview iWebview, String[] strArr) {
this.a = iWebview;
this.b = strArr;
}
@Override
public void run() {
a.a(this.a, this.b);
}
}
public static class b {
public float a;
public float b;
public float c;
public float f5108d;
public float f5109e;
public float f5110f;
public b(String str, String str2, String str3, String str4, float f2, float f3) {
this.f5109e = f2;
this.f5110f = f3;
this.a = a.a(str, f3, 0.0f);
float a = a.a(str2, this.f5109e, 0.0f);
this.b = a;
float f4 = this.f5109e;
this.c = a.a(str3, f4, f4 - a);
float f5 = this.f5110f;
float a2 = a.a(str4, f5, f5 - this.a);
this.f5108d = a2;
float f6 = this.c;
float f7 = this.b;
float f8 = this.f5109e;
if (f6 + f7 > f8) {
this.c = f8 - f7;
}
float f9 = this.a;
float f10 = this.f5110f;
if (a2 + f9 > f10) {
this.f5108d = f10 - f9;
}
}
public boolean a() {
return this.a <= this.f5110f && this.b <= this.f5109e;
}
}
public static synchronized void a(IWebview iWebview, String[] strArr) {
Bitmap a;
Bitmap bitmap;
Bitmap createBitmap;
long a2;
synchronized (a.class) {
String str = strArr[0];
String str2 = strArr[1];
try {
JSONObject jSONObject = new JSONObject(str);
c cVar = new c();
if (cVar.a(jSONObject, iWebview, str2)) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
if (cVar.f5112e < 0) {
cVar.f5112e = 50;
}
if (cVar.f5120m > 1500000) {
options.inSampleSize = 2;
} else {
options.inSampleSize = 1;
}
Logger.d("CompressImage", "文件获取完毕 初始化bitmap 获取文件大小" + cVar.f5120m);
Matrix matrix = null;
try {
try {
a = a(iWebview.getContext(), cVar.a, options);
} catch (IOException unused) {
a = null;
}
} catch (OutOfMemoryError unused2) {
Logger.d("CompressImage", "获取bitmap 内存溢出第一次 bitmap路径" + cVar.a);
options.inSampleSize = options.inSampleSize * 2;
Logger.d("CompressImage", "获取bitmap 内存溢出第一次 第二次获取bitmmap bitmap路径" + cVar.a);
a = a(iWebview.getContext(), cVar.a, options);
}
if (a == null) {
a(iWebview, str2, DOMException.MSG_PARAMETER_ERROR, -1);
return;
}
if (!cVar.f5119l || cVar.f5113f <= 0.0f || cVar.f5114g <= 0.0f) {
bitmap = a;
} else {
Matrix matrix2 = new Matrix();
matrix2.setScale(cVar.f5113f / a.getWidth(), cVar.f5114g / a.getHeight());
bitmap = Bitmap.createBitmap(a, 0, 0, a.getWidth(), a.getHeight(), matrix2, false);
}
Logger.d("CompressImage", "缩放完毕" + cVar.a);
if (cVar.f5115h > 0) {
matrix = new Matrix();
matrix.postRotate(cVar.f5115h);
}
Matrix matrix3 = matrix;
Logger.d("CompressImage", "旋转完毕" + cVar.a);
b bVar = cVar.f5118k;
if (bVar != null) {
float f2 = bVar.a;
float f3 = options.inSampleSize;
createBitmap = Bitmap.createBitmap(bitmap, (int) (bVar.b / f3), (int) (f2 / f3), (int) (bVar.c / f3), (int) (bVar.f5108d / f3), matrix3, false);
if (createBitmap != bitmap) {
bitmap.recycle();
}
} else {
if (matrix3 != null) {
createBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix3, false);
if (createBitmap != bitmap) {
bitmap.recycle();
}
}
Logger.d("CompressImage", "裁剪完毕" + cVar.a);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
a2 = a(cVar.b, bitmap, cVar.f5111d, cVar.f5112e);
if (a2 <= 0) {
a(cVar.a, cVar.b);
Logger.d("CompressImage", "开始保存图片" + cVar.a);
a(iWebview, str2, String.format(Locale.ENGLISH, "{path:'file://%s', w:%d, h:%d, size:%d}", cVar.b, Integer.valueOf(width), Integer.valueOf(height), Long.valueOf(a2)));
} else {
if (!bitmap.isRecycled()) {
bitmap.recycle();
}
a(iWebview, str2, iWebview.getContext().getString(R.string.dcloud_common_zip_image_output_failed), -5);
}
if (!a.isRecycled()) {
a.recycle();
}
}
bitmap = createBitmap;
Logger.d("CompressImage", "裁剪完毕" + cVar.a);
int width2 = bitmap.getWidth();
int height2 = bitmap.getHeight();
a2 = a(cVar.b, bitmap, cVar.f5111d, cVar.f5112e);
if (a2 <= 0) {
}
if (!a.isRecycled()) {
}
}
} catch (JSONException e2) {
e2.printStackTrace();
a(iWebview, str2, DOMException.MSG_PARAMETER_ERROR, -1);
}
}
}
public static void b(IWebview iWebview, String[] strArr) {
ThreadPool.self().addThreadTask(new RunnableC0191a(iWebview, strArr));
}
public static Bitmap.CompressFormat c(String str) {
if (!str.contains(".jpg") && !str.contains(".jpeg")) {
return Bitmap.CompressFormat.PNG;
}
return Bitmap.CompressFormat.JPEG;
}
public static boolean b(String str) {
try {
File file = new File(str);
if (file.exists()) {
if (file.length() >= 5) {
return true;
}
}
} catch (Exception unused) {
}
return false;
}
public static class c {
public String a;
public String b;
public String c;
public boolean f5111d;
public int f5112e;
public float f5113f;
public float f5114g;
public int f5115h;
public int f5116i;
public int f5117j;
public b f5118k;
public boolean f5119l = false;
public long f5120m;
public boolean a(JSONObject jSONObject, IWebview iWebview, String str) {
this.a = jSONObject.optString("src");
this.b = jSONObject.optString("dst");
if (a(iWebview, str)) {
this.f5111d = jSONObject.optBoolean("overwrite", false);
this.c = jSONObject.optString(AbsoluteConst.JSON_KEY_FORMAT);
this.f5112e = jSONObject.optInt(Constants.Name.QUALITY, -1);
a(iWebview.getContext(), jSONObject.optString("width", "auto"), jSONObject.optString("height", "auto"));
this.f5115h = jSONObject.optInt("rotate", -1);
JSONObject optJSONObject = jSONObject.optJSONObject("clip");
if (optJSONObject != null) {
b bVar = new b(optJSONObject.optString("top"), optJSONObject.optString("left"), optJSONObject.optString("width"), optJSONObject.optString("height"), this.f5113f, this.f5114g);
this.f5118k = bVar;
if (bVar.a()) {
return true;
}
a.a(iWebview, str, DOMException.MSG_PARAMETER_ERROR, -1);
return false;
}
return true;
}
return false;
}
public boolean a(IWebview iWebview, String str) {
if (!TextUtils.isEmpty(this.a) && !TextUtils.isEmpty(this.b)) {
String convert2AbsFullPath = iWebview.obtainFrameView().obtainApp().convert2AbsFullPath(iWebview.obtainFullUrl(), this.a);
this.a = convert2AbsFullPath;
if (!a.b(convert2AbsFullPath)) {
a.a(iWebview, str, DOMException.MSG_FILE_NOT_EXIST, -4);
return false;
}
this.b = iWebview.obtainFrameView().obtainApp().convert2AbsFullPath(iWebview.obtainFullUrl(), this.b);
return true;
}
a.a(iWebview, str, DOMException.MSG_PARAMETER_ERROR, -1);
return false;
}
public void a(Context context, String str, String str2) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
a.a(context, this.a, options);
} catch (IOException e2) {
e2.printStackTrace();
}
int i2 = options.outWidth;
this.f5116i = i2;
int i3 = options.outHeight;
this.f5117j = i3;
if (i3 <= 0 || i2 <= 0) {
return;
}
this.f5120m = new File(this.a).length();
if (str.equals("auto") && str2.endsWith("auto")) {
this.f5119l = false;
this.f5113f = this.f5116i;
this.f5114g = this.f5117j;
} else if (str.equals("auto")) {
this.f5119l = true;
float f2 = this.f5117j;
float parseFloat = PdrUtil.parseFloat(str2, f2, f2);
this.f5114g = parseFloat;
this.f5113f = (this.f5116i * parseFloat) / this.f5117j;
} else if (str2.equals("auto")) {
this.f5119l = true;
float f3 = this.f5116i;
float parseFloat2 = PdrUtil.parseFloat(str, f3, f3);
this.f5113f = parseFloat2;
this.f5114g = (this.f5117j * parseFloat2) / this.f5116i;
} else {
this.f5119l = true;
float f4 = this.f5116i;
this.f5113f = PdrUtil.parseFloat(str, f4, f4);
float f5 = this.f5117j;
this.f5114g = PdrUtil.parseFloat(str2, f5, f5);
}
}
}
private static void a(String str, String str2) {
Field[] fields;
Object obj;
String obj2;
String attribute;
try {
ExifInterface exifInterface = new ExifInterface(str);
ExifInterface exifInterface2 = new ExifInterface(str2);
for (Field field : ExifInterface.class.getFields()) {
String name = field.getName();
if (!TextUtils.isEmpty(name) && name.startsWith("TAG") && (obj = field.get(ExifInterface.class)) != null && (attribute = exifInterface.getAttribute((obj2 = obj.toString()))) != null) {
exifInterface2.setAttribute(obj2, attribute);
}
}
exifInterface2.saveAttributes();
} catch (Throwable unused) {
}
}
public static Bitmap a(Context context, String str, BitmapFactory.Options options) throws IOException {
if (!FileUtil.checkPrivatePath(context, str)) {
InputStream fileInputStream = FileUtil.getFileInputStream(context, str);
if (fileInputStream != null) {
Bitmap decodeStream = BitmapFactory.decodeStream(fileInputStream, null, options);
fileInputStream.close();
return decodeStream;
}
return null;
}
return BitmapFactory.decodeFile(str, options);
}
public static void a(IWebview iWebview, String str, String str2, int i2) {
Deprecated_JSUtil.execCallback(iWebview, str, DOMException.toJSON(i2, str2), JSUtil.ERROR, true, false);
}
public static void a(IWebview iWebview, String str, String str2) {
Deprecated_JSUtil.execCallback(iWebview, str, str2, JSUtil.OK, true, false);
}
public static long a(String str, Bitmap bitmap, boolean z, int i2) {
File file = new File(str);
if (file.exists()) {
if (file.length() < 1) {
file.delete();
} else if (!z) {
return -1L;
} else {
file.delete();
}
} else if (a(str)) {
file = new File(str);
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
bitmap.compress(c(str), i2, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
if (!bitmap.isRecycled()) {
bitmap.recycle();
}
return file.length();
} catch (FileNotFoundException e2) {
e2.printStackTrace();
return -1L;
} catch (IOException e3) {
e3.printStackTrace();
return -1L;
}
}
public static boolean a(String str) {
int lastIndexOf;
if (!TextUtils.isEmpty(str) && (lastIndexOf = str.lastIndexOf(Operators.DIV)) != -1 && lastIndexOf != 0) {
try {
File file = new File(str.substring(0, lastIndexOf));
if (file.exists()) {
return true;
}
file.mkdirs();
return true;
} catch (Exception unused) {
}
}
return false;
}
public static float a(String str, float f2, float f3) {
return str.equals("auto") ? f3 : PdrUtil.parseFloat(str, f2, f3);
}
}