Money Lover v8.14.0.6版本的 MD5 值为:48b9d922212c7ccfd438cdcc183ff396
以下内容为反编译后的 b0.java 源代码,内容仅作参考
package com.zoostudio.moneylover.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import com.google.auth.http.AuthHttpConstants;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.google.firebase.sessions.settings.RemoteSettings;
import com.zoostudio.moneylover.MoneyApplication;
import com.zoostudio.moneylover.db.sync.item.g;
import com.zoostudio.moneylover.exception.MoneyError;
import fr.y;
import ii.c;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Locale;
import org.apache.poi.openxml4j.opc.ContentTypes;
import org.json.JSONException;
import org.json.JSONObject;
public final class b0 {
private static String f14812a = "image-v2-";
private static final String f14813b;
private static final String f14814c;
private static final String f14815d;
public static final class a implements c.a {
a() {
}
@Override
public void b(JSONObject response) {
kotlin.jvm.internal.r.h(response, "response");
}
@Override
public void onFail(MoneyError error) {
kotlin.jvm.internal.r.h(error, "error");
}
}
public static final class b extends c4.c<Bitmap> {
final String f14816a;
final wn.l<Boolean, kn.v> f14817b;
b(String str, wn.l<? super Boolean, kn.v> lVar) {
this.f14816a = str;
this.f14817b = lVar;
}
@Override
public void onResourceReady(Bitmap resource, d4.b<? super Bitmap> bVar) {
kotlin.jvm.internal.r.h(resource, "resource");
try {
b0.m(resource, this.f14816a);
wn.l<Boolean, kn.v> lVar = this.f14817b;
if (lVar != null) {
lVar.invoke(Boolean.TRUE);
}
} catch (IOException e10) {
e10.printStackTrace();
wn.l<Boolean, kn.v> lVar2 = this.f14817b;
if (lVar2 != null) {
lVar2.invoke(Boolean.FALSE);
}
}
}
@Override
public void onLoadCleared(Drawable drawable) {
}
@Override
public void onLoadFailed(Drawable drawable) {
super.onLoadFailed(drawable);
wn.l<Boolean, kn.v> lVar = this.f14817b;
if (lVar != null) {
lVar.invoke(Boolean.FALSE);
}
}
}
public static final class c implements g.e {
final ImageView f14818a;
final File f14819b;
c(ImageView imageView, File file) {
this.f14818a = imageView;
this.f14819b = file;
}
@Override
public void onFail(MoneyError error) {
kotlin.jvm.internal.r.h(error, "error");
FirebaseCrashlytics.getInstance().recordException(error);
}
@Override
public void onSuccess(JSONObject data) {
kotlin.jvm.internal.r.h(data, "data");
try {
String string = data.getJSONObject("data").getString("icon");
com.bumptech.glide.b.u(this.f14818a.getRootView().getContext()).n(string).z0(this.f14818a);
Context context = this.f14818a.getRootView().getContext();
kotlin.jvm.internal.r.g(context, "getContext(...)");
kotlin.jvm.internal.r.e(string);
String absolutePath = this.f14819b.getAbsolutePath();
kotlin.jvm.internal.r.g(absolutePath, "getAbsolutePath(...)");
b0.b(context, string, absolutePath);
} catch (Exception e10) {
qe.b.b(e10);
}
}
}
static {
String str;
String str2;
String str3;
boolean z10 = m7.a.f27647b;
if (z10) {
str = "https://revotestapi.moneylover.com/image";
} else {
str = "https://revoapi.moneylover.com/image";
}
f14813b = str;
if (z10) {
str2 = "https://s3-img-dev.moneylover.me/";
} else {
str2 = "https://s3-img.moneylover.me/";
}
f14814c = str2;
if (z10) {
str3 = "https://bucket-dev.moneylover.com/";
} else {
str3 = "https://bucket.moneylover.com/";
}
f14815d = str3;
}
public static final void a(String str, String str2) throws JSONException {
JSONObject jSONObject = new JSONObject();
jSONObject.put("image", str2);
kotlin.jvm.internal.r.e(str);
com.zoostudio.moneylover.db.sync.item.h hVar = new com.zoostudio.moneylover.db.sync.item.h(3, str, com.zoostudio.moneylover.db.sync.item.h.Companion.makeBody(jSONObject));
String B = zi.f.i().B();
kotlin.jvm.internal.r.g(B, "getToken(...)");
hVar.addHeader(AuthHttpConstants.BEARER, B);
new ii.c().b(hVar, new a());
}
public static final void b(Context context, String url, String path) {
kotlin.jvm.internal.r.h(context, "context");
kotlin.jvm.internal.r.h(url, "url");
kotlin.jvm.internal.r.h(path, "path");
c(context, url, path, null);
}
public static final void c(Context context, String url, String path, wn.l<? super Boolean, kn.v> lVar) {
kotlin.jvm.internal.r.h(context, "context");
kotlin.jvm.internal.r.h(url, "url");
kotlin.jvm.internal.r.h(path, "path");
com.bumptech.glide.b.u(context).c().F0(url).g0(true).w0(new b(path, lVar));
}
public static final void d(Context context, String url, String name) {
kotlin.jvm.internal.r.h(context, "context");
kotlin.jvm.internal.r.h(url, "url");
kotlin.jvm.internal.r.h(name, "name");
b(context, url, MoneyApplication.f11023j.w() + '/' + name + ".png");
}
private static final void e(File file, int i10, ImageView imageView) throws JSONException {
JSONObject jSONObject = new JSONObject();
jSONObject.put("service_id", i10);
com.zoostudio.moneylover.db.sync.item.g.callFunctionInBackground(com.zoostudio.moneylover.db.sync.item.g.GET_SERVICE, jSONObject, new c(imageView, file));
}
public static final String f() {
return f14812a;
}
public static final String g() {
return f14814c;
}
public static final String h() {
return f14815d;
}
public static final String i() {
return f14813b;
}
public static final void j(String url, ImageView imageView) {
kotlin.jvm.internal.r.h(url, "url");
kotlin.jvm.internal.r.h(imageView, "imageView");
com.bumptech.glide.b.u(imageView.getContext()).n(url).z0(imageView);
}
public static final void k(String name, ImageView iconView) throws JSONException, NumberFormatException {
boolean M;
int e02;
String B;
int parseInt;
kotlin.jvm.internal.r.h(name, "name");
kotlin.jvm.internal.r.h(iconView, "iconView");
File file = new File(MoneyApplication.L + name + ".png");
if (file.exists()) {
com.bumptech.glide.b.u(iconView.getContext()).k(file).z0(iconView);
return;
}
M = pq.v.M(name, RemoteSettings.FORWARD_SLASH_STRING, false, 2, null);
if (!M) {
parseInt = Integer.parseInt(name);
} else {
e02 = pq.v.e0(name, RemoteSettings.FORWARD_SLASH_STRING, 0, false, 6, null);
String substring = name.substring(e02, name.length());
kotlin.jvm.internal.r.g(substring, "this as java.lang.String…ing(startIndex, endIndex)");
B = pq.u.B(substring, RemoteSettings.FORWARD_SLASH_STRING, "", false, 4, null);
parseInt = Integer.parseInt(B);
}
e(file, parseInt, iconView);
}
public static final void l(String host, String name, ImageView iconView) {
kotlin.jvm.internal.r.h(host, "host");
kotlin.jvm.internal.r.h(name, "name");
kotlin.jvm.internal.r.h(iconView, "iconView");
File file = new File(MoneyApplication.L + name + ".png");
if (file.exists()) {
com.bumptech.glide.b.u(iconView.getContext()).k(file).z0(iconView);
return;
}
com.bumptech.glide.b.u(iconView.getContext()).n(host).z0(iconView);
Context context = iconView.getContext();
kotlin.jvm.internal.r.g(context, "getContext(...)");
String absolutePath = file.getAbsolutePath();
kotlin.jvm.internal.r.g(absolutePath, "getAbsolutePath(...)");
b(context, host, absolutePath);
}
public static final void m(Bitmap bitmap, String path) throws IOException {
int e02;
boolean M;
kotlin.jvm.internal.r.h(bitmap, "bitmap");
kotlin.jvm.internal.r.h(path, "path");
e02 = pq.v.e0(path, RemoteSettings.FORWARD_SLASH_STRING, 0, false, 6, null);
String substring = path.substring(0, e02);
kotlin.jvm.internal.r.g(substring, "this as java.lang.String…ing(startIndex, endIndex)");
File file = new File(substring);
if (!file.exists()) {
file.mkdirs();
}
File file2 = new File(path);
if (!file2.exists()) {
file2.createNewFile();
}
FileOutputStream fileOutputStream = new FileOutputStream(file2);
Locale a10 = f0.a();
kotlin.jvm.internal.r.g(a10, "getLocale(...)");
String lowerCase = path.toLowerCase(a10);
kotlin.jvm.internal.r.g(lowerCase, "this as java.lang.String).toLowerCase(locale)");
M = pq.v.M(lowerCase, ".png", false, 2, null);
if (M) {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
} else {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
}
fileOutputStream.close();
}
public static final void n(String str, String imageLocalPath, c.a callback) throws IOException, NullPointerException {
kotlin.jvm.internal.r.h(imageLocalPath, "imageLocalPath");
kotlin.jvm.internal.r.h(callback, "callback");
File r10 = p.r(imageLocalPath);
if (r10 == null) {
callback.b(new JSONObject());
return;
}
fr.y d10 = new y.a(null, 1, 0 == true ? 1 : 0).e(fr.y.f17691l).a("image", r10.getName(), fr.c0.INSTANCE.d(r10, fr.x.INSTANCE.b(ContentTypes.IMAGE_PNG))).d();
kotlin.jvm.internal.r.e(str);
com.zoostudio.moneylover.db.sync.item.h hVar = new com.zoostudio.moneylover.db.sync.item.h(1, str, d10);
String B = zi.f.i().B();
kotlin.jvm.internal.r.g(B, "getToken(...)");
hVar.addHeader(AuthHttpConstants.BEARER, B);
new ii.c().b(hVar, callback);
}
}