Money Lover v8.14.0.6版本的 MD5 值为:48b9d922212c7ccfd438cdcc183ff396

以下内容为反编译后的 k1.java 源代码,内容仅作参考


package com.zoostudio.moneylover.utils;

import android.content.Context;
import android.content.SharedPreferences;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Calendar;
import org.json.JSONException;
import org.json.JSONObject;
import wj.m;

public class k1 {

    public static String f14927c = "timestamp";

    private final Context f14928a;

    private b f14929b;

    public class a implements m.a {

        final c f14930a;

        a(c cVar) {
            this.f14930a = cVar;
        }

        @Override
        public void a(Exception exc) {
            c cVar = this.f14930a;
            if (cVar == null) {
                return;
            }
            cVar.a();
        }

        @Override
        public void onSuccess(String str) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                long timeInMillis = Calendar.getInstance().getTimeInMillis();
                SharedPreferences.Editor edit = k1.this.f14928a.getSharedPreferences("pref_exchange", 0).edit();
                edit.putLong(k1.f14927c, timeInMillis);
                edit.apply();
                jSONObject.put(k1.f14927c, timeInMillis);
                k1.this.i(jSONObject.toString());
                c cVar = this.f14930a;
                if (cVar == null) {
                    s.d(k1.this.f14928a).j(timeInMillis);
                } else {
                    cVar.b(timeInMillis);
                }
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
        }
    }

    public interface b {
        void a();
    }

    public interface c {
        void a();

        void b(long j10);
    }

    public k1(Context context, b bVar) {
        this.f14928a = context;
        this.f14929b = bVar;
    }

    private boolean c() {
        return new File(this.f14928a.getFilesDir() + "/exchanger", "exchanger.json").exists();
    }

    private void d() {
        b bVar = this.f14929b;
        if (bVar != null) {
            bVar.a();
        }
    }

    public static File e(Context context) {
        File file = new File(context.getFilesDir() + "/exchanger");
        if (!file.exists()) {
            file.mkdirs();
        }
        File file2 = new File(context.getFilesDir() + "/exchanger", "exchanger.json");
        if (file2.exists()) {
            return file2;
        }
        try {
            if (!file2.createNewFile()) {
                return null;
            }
            return file2;
        } catch (IOException e10) {
            e10.printStackTrace();
            return null;
        }
    }

    private void h(c cVar) {
        wj.m mVar = new wj.m();
        mVar.d(new a(cVar));
        mVar.execute("https://static.moneylover.me/data/exchanger.json");
    }

    public void i(String str) {
        File e10 = e(this.f14928a);
        try {
            if (e10.exists()) {
                e10.delete();
            }
            if (e10.createNewFile()) {
                FileOutputStream fileOutputStream = new FileOutputStream(e10);
                fileOutputStream.write(str.getBytes());
                fileOutputStream.close();
            }
        } catch (IOException e11) {
            e11.printStackTrace();
            d();
        }
    }

    public String f() throws IOException {
        File e10;
        if (!c() || (e10 = e(this.f14928a)) == null) {
            return null;
        }
        StringBuilder sb2 = new StringBuilder();
        BufferedReader bufferedReader = new BufferedReader(new FileReader(e10));
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                break;
            }
            sb2.append(readLine);
        }
        bufferedReader.close();
        String sb3 = sb2.toString();
        if (sb3.isEmpty()) {
            return null;
        }
        return sb3;
    }

    public void g(c cVar) {
        h(cVar);
    }
}