Money Lover v8.14.0.6版本的 MD5 值为:48b9d922212c7ccfd438cdcc183ff396
以下内容为反编译后的 j1.java 源代码,内容仅作参考
package com.zoostudio.moneylover.utils;
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.zoostudio.moneylover.help.utils.HelpsConstant;
import java.io.IOException;
import org.apache.poi.ss.formula.functions.Complex;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class j1 extends wj.l0<Void> {
private final SharedPreferences f14924g;
public j1(Context context) {
super(context);
this.f14924g = context.getSharedPreferences(FirebaseAnalytics.Param.CURRENCY, 0);
}
private void i(SQLiteDatabase sQLiteDatabase) {
sQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS \"currencies\" (\"cur_id\" INTEGER PRIMARY KEY NOT NULL , \"cur_code\" VARCHAR(5), \"cur_name\" VARCHAR(30), \"cur_symbol\" VARCHAR(30), \"cur_display_type\" INTEGER)");
}
private void k(SQLiteDatabase sQLiteDatabase) {
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS currencies");
}
private long l() {
return this.f14924g.getLong("last_update", 0L);
}
private void m(SQLiteDatabase sQLiteDatabase, JSONObject jSONObject) throws JSONException {
ContentValues p10 = p(jSONObject);
try {
sQLiteDatabase.insertOrThrow("currencies", null, p10);
} catch (Exception unused) {
sQLiteDatabase.update("currencies", p10, "cur_id = ?", new String[]{p10.getAsString("cur_id")});
}
}
private JSONObject n(String str) throws JSONException {
return new JSONObject(rt.g.c(d(), str));
}
private JSONObject o() throws IOException, JSONException {
return new JSONObject(rt.g.b("https://static.moneylover.me/data/currency.json"));
}
private ContentValues p(JSONObject jSONObject) throws JSONException {
ContentValues contentValues = new ContentValues();
contentValues.put("cur_code", jSONObject.getString(HelpsConstant.MESSAGE.PARAMS_CONTENT));
contentValues.put("cur_name", jSONObject.getString("n"));
contentValues.put("cur_symbol", jSONObject.getString("s"));
contentValues.put("cur_display_type", jSONObject.getString(com.zoostudio.moneylover.adapter.item.u.CONTENT_KEY_TITLE));
contentValues.put("cur_id", Integer.valueOf(jSONObject.getInt(Complex.DEFAULT_SUFFIX)));
return contentValues;
}
private void q(SQLiteDatabase sQLiteDatabase, JSONArray jSONArray, long j10) throws JSONException {
int length = jSONArray.length();
for (int i10 = 0; i10 < length; i10++) {
m(sQLiteDatabase, jSONArray.getJSONObject(i10));
}
s(j10);
}
private void s(long j10) {
SharedPreferences.Editor edit = this.f14924g.edit();
edit.putLong("last_update", j10);
edit.apply();
}
@Override
public Void b(SQLiteDatabase sQLiteDatabase) {
long l10 = l();
try {
if (l10 == 0) {
r(sQLiteDatabase);
} else if ((System.currentTimeMillis() / 1000) - 604800 > l10) {
JSONObject o10 = o();
q(sQLiteDatabase, o10.getJSONArray("data"), o10.getLong(com.zoostudio.moneylover.adapter.item.u.CONTENT_KEY_TITLE));
}
return null;
} catch (IOException | JSONException e10) {
e10.printStackTrace();
return null;
}
}
public void r(SQLiteDatabase sQLiteDatabase) throws JSONException {
k(sQLiteDatabase);
i(sQLiteDatabase);
JSONObject n10 = n("currency.json");
q(sQLiteDatabase, n10.getJSONArray("data"), n10.getLong(com.zoostudio.moneylover.adapter.item.u.CONTENT_KEY_TITLE));
JSONObject n11 = n("crypto_currency.json");
q(sQLiteDatabase, n11.getJSONArray("data"), n11.getLong(com.zoostudio.moneylover.adapter.item.u.CONTENT_KEY_TITLE));
}
}