APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:CoinCalc
版本号:17.5
包名称:com.samruston.flip

MD5 校验值:719081c19dfabad7b000ef11fc4f3317

反编译源代码说明

UpdateManager.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.samruston.flip.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.material.timepicker.GOQC.kBtYkq;
import d4.WACp.QALqxpFtNki;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Iterator;
import k5.lSse.jABisTZYuzKsAS;
import kotlin.Metadata;
import n3.x;
import n7.d0;
import o7.k;
import org.json.JSONException;
import org.json.JSONObject;
import r6.f1;
import r6.v0;
import w6.z;
import y3.l;

@Metadata(d1 = {"\u0000Z\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\bÆ\u0002\u0018\u00002\u00020\u0001:\u0001/B\t\b\u0002¢\u0006\u0004\b-\u0010.J\u0018\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0002J \u0010\u000b\u001a\u00020\b2\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\n\u001a\u00020\bH\u0002J\u0010\u0010\f\u001a\u00020\b2\u0006\u0010\u0003\u001a\u00020\u0002H\u0002J\u001e\u0010\u000f\u001a\u00020\u00062\u0014\u0010\u000e\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\u0004\u0012\u0004\u0012\u00020\u00010\rH\u0002J\u001e\u0010\u0010\u001a\u00020\u00062\u0014\u0010\u000e\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\u0004\u0012\u0004\u0012\u00020\u00010\rH\u0002J\u000e\u0010\u0013\u001a\u00020\u00062\u0006\u0010\u0012\u001a\u00020\u0011J\u000e\u0010\u0014\u001a\u00020\u00062\u0006\u0010\u0012\u001a\u00020\u0011J\u000e\u0010\u0016\u001a\u00020\b2\u0006\u0010\u0015\u001a\u00020\u0004J\u000e\u0010\u0019\u001a\u00020\u00042\u0006\u0010\u0018\u001a\u00020\u0017J\u0018\u0010\u001c\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u001b\u001a\u00020\u001aH\u0007J\u0016\u0010\u001d\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u001b\u001a\u00020\u001aJ\u000e\u0010\u001e\u001a\u00020\u001a2\u0006\u0010\u0003\u001a\u00020\u0002J\u000e\u0010\u001f\u001a\u00020\u001a2\u0006\u0010\u0003\u001a\u00020\u0002J2\u0010 \u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\b2\u0012\u0010\u000e\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\u00010\rJ$\u0010\"\u001a\u00020\u00062\u0006\u0010!\u001a\u00020\u00042\u0014\u0010\u000e\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\u0004\u0012\u0004\u0012\u00020\u00060\rR\u001c\u0010%\u001a\n $*\u0004\u0018\u00010#0#8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b%\u0010&R\u001c\u0010(\u001a\n $*\u0004\u0018\u00010'0'8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b(\u0010)R\u001a\u0010+\u001a\b\u0012\u0004\u0012\u00020\u00110*8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b+\u0010,¨\u00060"}, d2 = {"Lcom/samruston/flip/utils/UpdateManager;", "", "Landroid/content/Context;", "context", "", "json", "Ln3/x;", "hasUpdated", "", "background", "force", "canUpdateRates", "canUpdateConfig", "Lkotlin/Function1;", "callback", "downloadCurrencies", "downloadConfig", "Lcom/samruston/flip/utils/UpdateManager$Subscription;", "subscription", "subscribe", "dispose", "test", "isValidJSON", "Ljava/io/InputStream;", "inputStream", "convertStreamToString", "", "time", "setLastUpdateTime", "setLastUpdatedConfigTime", "getLastUpdateTime", "getLastUpdateConfigTime", "updateCurrencies", "code", "downloadGraph", "Ln7/d0;", "kotlin.jvm.PlatformType", "retrofit", "Ln7/d0;", "Lcom/samruston/flip/utils/CurrencyService;", "service", "Lcom/samruston/flip/utils/CurrencyService;", "Ljava/util/ArrayList;", "subscribers", "Ljava/util/ArrayList;", "<init>", "()V", "Subscription", "app_release"}, k = 1, mv = {1, 8, LinearLayoutManager.HORIZONTAL})
public final class UpdateManager {
    public static final UpdateManager INSTANCE = new UpdateManager();
    private static final d0 retrofit;
    private static final CurrencyService service;
    private static final ArrayList<Subscription> subscribers;

    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H&¨\u0006\u0006"}, d2 = {"Lcom/samruston/flip/utils/UpdateManager$Subscription;", "", "", "data", "Ln3/x;", "onUpdate", "app_release"}, k = 1, mv = {1, 8, LinearLayoutManager.HORIZONTAL})
    public interface Subscription {
        void onUpdate(String str);
    }

    private UpdateManager() {
    }

    private final void downloadConfig(l<? super String, ? extends Object> lVar) {
        r6.f.b(f1.f12599e, v0.c(), null, new UpdateManager$downloadConfig$1(lVar, null), 2, null);
    }

    private final void downloadCurrencies(l<? super String, ? extends Object> lVar) {
        r6.f.b(f1.f12599e, v0.c(), null, new UpdateManager$downloadCurrencies$1(lVar, null), 2, null);
    }

    static {
        d0 d8 = new d0.b().f(new z.a().a(x6.a.f14065a).b()).b("https://converter.wuzly.com/").a(k.f()).d();
        retrofit = d8;
        service = (CurrencyService) d8.b(CurrencyService.class);
        subscribers = new ArrayList<>();
    }

    public final String convertStreamToString(InputStream inputStream) {
        BufferedReader bufferedReader;
        z3.k.f(inputStream, "inputStream");
        Reader inputStreamReader = new InputStreamReader(inputStream, q6.d.UTF_8);
        if (inputStreamReader instanceof BufferedReader) {
            bufferedReader = (BufferedReader) inputStreamReader;
        } else {
            bufferedReader = new BufferedReader(inputStreamReader, 8192);
        }
        try {
            String c8 = w3.b.c(bufferedReader);
            w3.a.a(bufferedReader, null);
            return c8;
        } finally {
        }
    }

    public final void dispose(Subscription subscription) {
        z3.k.f(subscription, jABisTZYuzKsAS.CsrHpiWwEP);
        subscribers.remove(subscription);
    }

    public final void downloadGraph(String str, l<? super String, x> lVar) {
        z3.k.f(str, "code");
        z3.k.f(lVar, "callback");
        r6.f.b(f1.f12599e, v0.c(), null, new UpdateManager$downloadGraph$1(lVar, str, null), 2, null);
    }

    public final long getLastUpdateConfigTime(Context context) {
        z3.k.f(context, "context");
        return PreferenceManager.getDefaultSharedPreferences(context).getLong("updateConfigTime", 0L);
    }

    public final long getLastUpdateTime(Context context) {
        z3.k.f(context, "context");
        return PreferenceManager.getDefaultSharedPreferences(context).getLong("updateTime", 0L);
    }

    public final boolean isValidJSON(String test) {
        z3.k.f(test, "test");
        try {
            new JSONObject(test);
            return true;
        } catch (JSONException unused) {
            return false;
        }
    }

    @SuppressLint({"ApplySharedPref"})
    public final void setLastUpdateTime(Context context, long j8) {
        z3.k.f(context, "context");
        PreferenceManager.getDefaultSharedPreferences(context).edit().putLong("updateTime", j8).commit();
    }

    public final void setLastUpdatedConfigTime(Context context, long j8) {
        z3.k.f(context, QALqxpFtNki.dlZyPtcZCFnLHLI);
        PreferenceManager.getDefaultSharedPreferences(context).edit().putLong("updateConfigTime", j8).commit();
    }

    public final void subscribe(Subscription subscription) {
        z3.k.f(subscription, kBtYkq.YaoCpMJKwRH);
        subscribers.add(subscription);
    }

    public final void updateCurrencies(Context context, boolean z7, boolean z8, l<? super Boolean, ? extends Object> lVar) {
        z3.k.f(context, "context");
        z3.k.f(lVar, "callback");
        if (canUpdateRates(context, z8, z7)) {
            downloadCurrencies(new UpdateManager$updateCurrencies$1(context, lVar));
        } else {
            lVar.invoke(Boolean.FALSE);
        }
        if (canUpdateConfig(context) && !z8) {
            downloadConfig(new UpdateManager$updateCurrencies$2(context));
        }
    }

    private final boolean canUpdateConfig(Context context) {
        if (System.currentTimeMillis() - getLastUpdateConfigTime(context) >= 172800000) {
            return true;
        }
        return false;
    }

    private final boolean canUpdateRates(Context context, boolean background, boolean force) {
        int i8;
        long currentTimeMillis = System.currentTimeMillis();
        boolean hasPurchased = ProMode.INSTANCE.hasPurchased(context);
        if (force) {
            i8 = 120000;
        } else if (background) {
            if (hasPurchased) {
                i8 = 1800000;
            } else {
                i8 = 43200000;
            }
        } else if (hasPurchased) {
            i8 = 900000;
        } else {
            i8 = 3600000;
        }
        if (currentTimeMillis - getLastUpdateTime(context) >= i8) {
            return true;
        }
        return false;
    }

    public final void hasUpdated(Context context, String str) {
        setLastUpdateTime(context, System.currentTimeMillis());
        Iterator<T> it = subscribers.iterator();
        while (it.hasNext()) {
            ((Subscription) it.next()).onUpdate(str);
        }
    }
}