导航菜单

页面标题

页面副标题

Hyouka private v5.8.9 - EsyLoader.java 源代码

正在查看: Hyouka private v5.8.9 应用的 EsyLoader.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.beint.project.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.widget.ImageView;
import com.beint.project.MainApplication;
import com.beint.project.core.model.contact.Contact;
import com.beint.project.core.services.impl.PathManager;
import com.beint.project.core.services.impl.StorageService;
import com.beint.project.core.services.impl.ZangiConfigurationService;
import com.beint.project.core.utils.CacheManager;
import com.beint.project.core.utils.Log;
import h9.a;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

public final class EsyLoader {
    private static final long DISK_CACHE_SIZE = 20971520;
    public static final EsyLoader INSTANCE;
    private static final int IO_BUFFER_SIZE = 8192;
    private static final String TAG;
    private static final fb.f TILE_SIZE$delegate;
    private static final ThreadPoolExecutor executorService;
    private static final Bitmap.CompressFormat mCompressFormat;
    private static final int mCompressQuality = 100;
    private static final Object mDiskCacheLock;
    private static h9.a mDiskLruCache = null;
    private static final int mapKeySymbolLimit = 40;
    private static Pattern patternsForNumbers = null;
    private static final String regex = "[^0-9a-z-]*";
    private static final String regexWOAlphabet = "[^0-9]*";

    public static final class BitmapWorkerTask extends AsyncTask<Object, Void, fb.k<? extends Bitmap, ? extends ImageView>> {
        private final android.graphics.Bitmap getContactAvatar(android.content.Context r19, java.lang.String r20, java.lang.String r21, boolean r22) {
            throw new UnsupportedOperationException("Method not decompiled: com.beint.project.utils.EsyLoader.BitmapWorkerTask.getContactAvatar(android.content.Context, java.lang.String, java.lang.String, boolean):android.graphics.Bitmap");
        }

        private final Bitmap openPhotoFromNativeContactManager(long j, int i) {
            Contact contactByIdentifire = StorageService.INSTANCE.getContactByIdentifire(String.valueOf(j));
            if (contactByIdentifire != null) {
                return contactByIdentifire.getAvatar(i);
            }
            return null;
        }

        @Override
        public void onPostExecute(fb.k<? extends Bitmap, ? extends ImageView> kVar) {
            onPostExecute2((fb.k<Bitmap, ? extends ImageView>) kVar);
        }

        @Override
        public fb.k<? extends Bitmap, ? extends ImageView> doInBackground2(Object... objArr) {
            qb.l lVar;
            boolean z;
            Bitmap bitmap;
            Bitmap bitmapFromDiskCache;
            kotlin.jvm.internal.k.f(objArr, "params");
            Object obj = objArr[0];
            kotlin.jvm.internal.k.d(obj, "null cannot be cast to non-null type android.content.Context");
            Context context = (Context) obj;
            Object obj2 = objArr[1];
            kotlin.jvm.internal.k.d(obj2, "null cannot be cast to non-null type android.widget.ImageView");
            ImageView imageView = (ImageView) obj2;
            Object obj3 = objArr[2];
            kotlin.jvm.internal.k.d(obj3, "null cannot be cast to non-null type kotlin.String");
            String str = (String) obj3;
            String str2 = (String) objArr[3];
            Object obj4 = objArr[4];
            kotlin.jvm.internal.k.d(obj4, "null cannot be cast to non-null type kotlin.Boolean");
            boolean booleanValue = ((Boolean) obj4).booleanValue();
            Object obj5 = objArr[5];
            kotlin.jvm.internal.k.d(obj5, "null cannot be cast to non-null type kotlin.Int");
            int intValue = ((Integer) obj5).intValue();
            qb.l lVar2 = null;
            try {
                lVar = (qb.l) kotlin.jvm.internal.y.e(objArr[6], 1);
            } catch (Exception e) {
                Log.d(EsyLoader.TAG, "exception = " + e.getMessage());
                lVar = null;
            }
            try {
                lVar2 = (qb.l) kotlin.jvm.internal.y.e(objArr[7], 1);
            } catch (Exception e7) {
                Log.d(EsyLoader.TAG, "exception = " + e7.getMessage());
            }
            if (str.length() < 40) {
                EsyLoader esyLoader = EsyLoader.INSTANCE;
                if (esyLoader.containsKeyInDiskCache(str) && (bitmapFromDiskCache = esyLoader.getBitmapFromDiskCache(str)) != null) {
                    esyLoader.addBitmapToMemoryCache(str, bitmapFromDiskCache);
                    if (lVar2 != null) {
                    }
                    Log.d("TAG", "getBitmapFromDiskCache");
                    return new fb.k<>(bitmapFromDiskCache, imageView);
                }
            }
            Bitmap contactAvatar = getContactAvatar(context, str, str2, booleanValue);
            if (contactAvatar == null) {
                InputStream openRawResource = context.getResources().openRawResource(intValue);
                kotlin.jvm.internal.k.e(openRawResource, "context.resources.openRawResource(defaultImage)");
                contactAvatar = BitmapFactory.decodeStream(openRawResource);
                z = false;
            } else {
                z = true;
            }
            if (contactAvatar != null) {
                if (lVar != null && (bitmap = (Bitmap) lVar.invoke(contactAvatar)) != null) {
                    contactAvatar = bitmap;
                }
                if (z && str.length() < 40) {
                    EsyLoader esyLoader2 = EsyLoader.INSTANCE;
                    Object obj6 = objArr[2];
                    kotlin.jvm.internal.k.d(obj6, "null cannot be cast to non-null type kotlin.String");
                    esyLoader2.addBitmapToCache((String) obj6, contactAvatar);
                }
            }
            if (lVar2 != null) {
            }
            return new fb.k<>(contactAvatar, imageView);
        }

        protected void onPostExecute2(fb.k<Bitmap, ? extends ImageView> kVar) {
            kotlin.jvm.internal.k.f(kVar, "result");
            super.onPostExecute((BitmapWorkerTask) kVar);
            if (kVar.c() != null) {
                EsyLoader.INSTANCE.setBitmapToView((ImageView) kVar.d(), (Bitmap) kVar.c(), null);
                ((ImageView) kVar.d()).setImageBitmap((Bitmap) kVar.c());
            }
        }
    }

    static {
        EsyLoader esyLoader = new EsyLoader();
        INSTANCE = esyLoader;
        mDiskCacheLock = new Object();
        mCompressFormat = Bitmap.CompressFormat.PNG;
        TAG = "EsyLoader";
        patternsForNumbers = Pattern.compile(regexWOAlphabet);
        TILE_SIZE$delegate = fb.g.a(EsyLoader$TILE_SIZE$2.INSTANCE);
        executorService = new ThreadPoolExecutor(10, Math.max(10, (Runtime.getRuntime().availableProcessors() * 2) - 1), 500L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
            @Override
            public final Thread newThread(Runnable runnable) {
                Thread _init_$lambda$0;
                _init_$lambda$0 = EsyLoader._init_$lambda$0(runnable);
                return _init_$lambda$0;
            }
        });
        File diskCacheDir = esyLoader.getDiskCacheDir();
        h9.a w = h9.a.w(diskCacheDir, 1, 1, DISK_CACHE_SIZE);
        kotlin.jvm.internal.k.e(w, "open(cacheDir, 1, 1, DISK_CACHE_SIZE)");
        mDiskLruCache = w;
        if (esyLoader.isClearAvatarFromDisk()) {
            esyLoader.setClearAvatarFromDisk(false);
            esyLoader.cleareDiskCache();
            h9.a w6 = h9.a.w(diskCacheDir, 1, 1, DISK_CACHE_SIZE);
            kotlin.jvm.internal.k.e(w6, "open(cacheDir, 1, 1, DISK_CACHE_SIZE)");
            mDiskLruCache = w6;
        }
    }

    private EsyLoader() {
    }

    public static final Thread _init_$lambda$0(Runnable runnable) {
        Thread thread = new Thread(runnable);
        thread.setPriority(5);
        return thread;
    }

    public final void addBitmapToCache(String str, Bitmap bitmap) {
        if (getBitmapFromMemCache(new zb.e(regex).b(str, "")) == null) {
            try {
                CacheManager.INSTANCE.addBitmapToMemoryCache(new zb.e(regex).b(str, ""), bitmap);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        synchronized (mDiskCacheLock) {
            EsyLoader esyLoader = INSTANCE;
            if (!esyLoader.containsKeyInDiskCache(new zb.e(regex).b(str, ""))) {
                esyLoader.putToDiskCache(new zb.e(regex).b(str, ""), bitmap);
            }
            fb.r rVar = fb.r.a;
        }
    }

    public final void addBitmapToMemoryCache(String str, Bitmap bitmap) {
        if (getBitmapFromMemCache(str) == null) {
            try {
                CacheManager.INSTANCE.addBitmapToMemoryCache(str, bitmap);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public final boolean containsKeyInDiskCache(String str) {
        try {
            a.e t = mDiskLruCache.t(str);
            r0 = t != null;
            if (t != null) {
                t.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return r0;
    }

    private final Bitmap getBitmapFromCache(String str) {
        Bitmap bitmapFromMemCache = getBitmapFromMemCache(new zb.e(regex).b(str, ""));
        if (bitmapFromMemCache != null) {
            Log.d("TAG", "getBitmapFromMemCache");
            return bitmapFromMemCache;
        }
        if (!containsKeyInDiskCache(new zb.e(regex).b(str, ""))) {
            return null;
        }
        Bitmap bitmapFromDiskCache = getBitmapFromDiskCache(new zb.e(regex).b(str, ""));
        if (bitmapFromDiskCache != null) {
            addBitmapToMemoryCache(new zb.e(regex).b(str, ""), bitmapFromDiskCache);
        }
        Log.d("TAG", "getBitmapFromDiskCache");
        return bitmapFromDiskCache;
    }

    public final android.graphics.Bitmap getBitmapFromDiskCache(java.lang.String r7) {
        throw new UnsupportedOperationException("Method not decompiled: com.beint.project.utils.EsyLoader.getBitmapFromDiskCache(java.lang.String):android.graphics.Bitmap");
    }

    private final File getDiskCacheDir() {
        MainApplication.Companion companion = MainApplication.Companion;
        if (companion.getMainContext().getCacheDir() == null) {
            return new File(PathManager.INSTANCE.getCACHE_DIR());
        }
        File cacheDir = companion.getMainContext().getCacheDir();
        kotlin.jvm.internal.k.e(cacheDir, "{\n            MainApplic…text().cacheDir\n        }");
        return cacheDir;
    }

    public final int getTILE_SIZE() {
        return ((Number) TILE_SIZE$delegate.getValue()).intValue();
    }

    private final boolean isClearAvatarFromDisk() {
        return ZangiConfigurationService.INSTANCE.getBoolean("is_to_cleare_esy_loader_4.7.2.2", true);
    }

    private final void putToDiskCache(String str, Bitmap bitmap) {
        a.c cVar = null;
        try {
            cVar = mDiskLruCache.r(new zb.e(regex).b(str, ""));
            if (cVar == null) {
                return;
            }
            if (writeBitmapToFile(bitmap, cVar)) {
                mDiskLruCache.flush();
                cVar.e();
            } else {
                cVar.a();
            }
        } catch (Exception unused) {
            if (cVar != null) {
                try {
                    cVar.a();
                } catch (Exception unused2) {
                }
            }
        }
    }

    public final void setBitmapToView(ImageView imageView, Bitmap bitmap, Integer num) {
        if (bitmap != null) {
            if (imageView != null ? kotlin.jvm.internal.k.b(imageView.getTag(), Integer.valueOf(bitmap.hashCode())) : false) {
                return;
            }
            if (imageView != null) {
                imageView.setTag(Integer.valueOf(bitmap.hashCode()));
            }
            if (imageView != null) {
                imageView.setImageBitmap(bitmap);
                return;
            }
            return;
        }
        if (num != null) {
            if (imageView != null ? kotlin.jvm.internal.k.b(imageView.getTag(), Integer.valueOf(num.hashCode())) : false) {
                return;
            }
            if (imageView != null) {
                imageView.setTag(Integer.valueOf(num.hashCode()));
            }
            if (imageView != null) {
                imageView.setImageResource(num.intValue());
            }
        }
    }

    private final void setClearAvatarFromDisk(boolean z) {
        ZangiConfigurationService.INSTANCE.putBoolean("is_to_cleare_esy_loader_4.7.2.2", z, true);
    }

    private final boolean writeBitmapToFile(Bitmap bitmap, a.c cVar) throws IOException, FileNotFoundException {
        BufferedOutputStream bufferedOutputStream = null;
        try {
            BufferedOutputStream bufferedOutputStream2 = new BufferedOutputStream(cVar.f(0), IO_BUFFER_SIZE);
            try {
                boolean compress = bitmap.compress(mCompressFormat, 100, bufferedOutputStream2);
                bufferedOutputStream2.close();
                return compress;
            } catch (Throwable th) {
                th = th;
                bufferedOutputStream = bufferedOutputStream2;
                if (bufferedOutputStream != null) {
                    bufferedOutputStream.close();
                }
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final void cleareDiskCache() {
        mDiskLruCache.p();
    }

    public final Bitmap getBitmapFromMemCache(String str) {
        kotlin.jvm.internal.k.f(str, "key");
        try {
            return CacheManager.INSTANCE.getBitmapFromMemCache(new zb.e(regex).b(str, ""));
        } catch (Exception unused) {
            return null;
        }
    }

    public final Pattern getPatternsForNumbers() {
        return patternsForNumbers;
    }

    public final void loadAvatar(Context context, ImageView imageView, String str, String str2, boolean z, int i, qb.l<? super Bitmap, Void> lVar) {
        loadAvatar(context, imageView, str, str2, z, i, EsyLoader$loadAvatar$1.INSTANCE, lVar);
    }

    public final void removeFromCache(String str) {
        kotlin.jvm.internal.k.f(str, "key");
        try {
            CacheManager.INSTANCE.removeFromCache(new zb.e(regex).b(str, ""));
            mDiskLruCache.I(new zb.e(regex).b(str, ""));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void setPatternsForNumbers(Pattern pattern) {
        patternsForNumbers = pattern;
    }

    public final void loadAvatar(Context context, ImageView imageView, String str, String str2, boolean z, int i, qb.l<? super Bitmap, Bitmap> lVar, qb.l<? super Bitmap, Void> lVar2) {
        if (imageView != null) {
            if (str != null) {
                try {
                    if (!(str.length() == 0)) {
                        String b = new zb.e(regex).b(str, "");
                        if (!(b.length() > 0)) {
                            if (lVar2 != null) {
                            }
                            setBitmapToView(imageView, null, Integer.valueOf(i));
                            return;
                        }
                        Bitmap bitmapFromMemCache = b.length() < 40 ? getBitmapFromMemCache(b) : null;
                        if (bitmapFromMemCache == null) {
                            imageView.setImageResource(i);
                            new BitmapWorkerTask().executeOnExecutor(executorService, context, imageView, b, str2, Boolean.valueOf(z), Integer.valueOf(i), lVar, lVar2);
                            return;
                        } else {
                            setBitmapToView(imageView, bitmapFromMemCache, Integer.valueOf(i));
                            if (lVar2 != null) {
                                return;
                            }
                            return;
                        }
                    }
                } catch (Exception unused) {
                    if (lVar2 != null) {
                    }
                    setBitmapToView(imageView, null, Integer.valueOf(i));
                    return;
                }
            }
            if (lVar2 != null) {
            }
            setBitmapToView(imageView, null, Integer.valueOf(i));
        }
    }
}