导航菜单

页面标题

页面副标题

北京退费客服端 v1.0.0 - ImageLoader.java 源代码

正在查看: 北京退费客服端 v1.0.0 应用的 ImageLoader.java JAVA 源代码文件

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


package im.amwhusedvt.messenger;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.text.TextUtils;
import android.util.SparseArray;
import im.amwhusedvt.messenger.-$;
import im.amwhusedvt.messenger.ImageLoader;
import im.amwhusedvt.tgnet.ConnectionsManager;
import im.amwhusedvt.tgnet.TLObject;
import im.amwhusedvt.tgnet.TLRPC;
import im.amwhusedvt.tgnet.TLRPC$Message;
import im.amwhusedvt.tgnet.TLRPC$TL_error;
import im.amwhusedvt.tgnet.TLRPC$TL_fileLocationUnavailable;
import im.amwhusedvt.tgnet.TLRPC$TL_messageMediaDocument;
import im.amwhusedvt.tgnet.TLRPC$TL_messageMediaPhoto;
import im.amwhusedvt.tgnet.TLRPC$TL_upload_getWebFile;
import im.amwhusedvt.ui.components.AnimatedFileDrawable;
import im.amwhusedvt.ui.components.RLottieDrawable;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONArray;
import org.json.JSONObject;

public class ImageLoader {
    public static final String AUTOPLAY_FILTER = "g";
    private static volatile ImageLoader Instance;
    private static ThreadLocal<byte[]> bytesLocal;
    private static ThreadLocal<byte[]> bytesThumbLocal;
    private static byte[] header;
    private static byte[] headerThumb;
    private File appPath;
    private LinkedList<ArtworkLoadTask> artworkTasks;
    private HashMap<String, Integer> bitmapUseCounts;
    private DispatchQueue cacheOutQueue;
    private DispatchQueue cacheThumbOutQueue;
    private boolean canForce8888;
    private int currentArtworkTasksCount;
    private int currentHttpFileLoadTasksCount;
    private int currentHttpTasksCount;
    private ConcurrentHashMap<String, Float> fileProgresses;
    private HashMap<String, Integer> forceLoadingImages;
    private LinkedList<HttpFileTask> httpFileLoadTasks;
    private HashMap<String, HttpFileTask> httpFileLoadTasksByKeys;
    private LinkedList<HttpImageTask> httpTasks;
    private String ignoreRemoval;
    private DispatchQueue imageLoadQueue;
    private HashMap<String, CacheImage> imageLoadingByKeys;
    private SparseArray<CacheImage> imageLoadingByTag;
    private HashMap<String, CacheImage> imageLoadingByUrl;
    private volatile long lastCacheOutTime;
    private int lastImageNum;
    private long lastProgressUpdateTime;
    private LruCache<RLottieDrawable> lottieMemCache;
    private LruCache<BitmapDrawable> memCache;
    private HashMap<String, String> replacedBitmaps;
    private HashMap<String, Runnable> retryHttpsTasks;
    private ConcurrentHashMap<String, WebFile> testWebFile;
    private HashMap<String, ThumbGenerateTask> thumbGenerateTasks;
    private DispatchQueue thumbGeneratingQueue;
    private HashMap<String, ThumbGenerateInfo> waitingForQualityThumb;
    private SparseArray<String> waitingForQualityThumbByTag;

    public static void SaveImageWithOriginalInternal(TLRPC.PhotoSize photoSize, String str, boolean z, byte b, int i, float f, boolean z2) {
        double d = (42 * 210) + 210;
    }

    public static void SaveImageWithOriginalInternal(TLRPC.PhotoSize photoSize, String str, boolean z, byte b, boolean z2, float f, int i) {
        double d = (42 * 210) + 210;
    }

    public static void SaveImageWithOriginalInternal(TLRPC.PhotoSize photoSize, String str, boolean z, byte b, boolean z2, int i, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$000(ImageLoader imageLoader, HttpFileTask httpFileTask, int i, char c, String str, byte b, short s) {
        double d = (42 * 210) + 210;
    }

    static void access$000(ImageLoader imageLoader, HttpFileTask httpFileTask, int i, char c, short s, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$000(ImageLoader imageLoader, HttpFileTask httpFileTask, int i, String str, byte b, short s, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$100(ImageLoader imageLoader, byte b, char c, int i, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$100(ImageLoader imageLoader, String str, char c, int i, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$100(ImageLoader imageLoader, String str, int i, byte b, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$1500(ImageLoader imageLoader, float f, int i, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$1500(ImageLoader imageLoader, int i, byte b, float f, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$1500(ImageLoader imageLoader, int i, float f, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$1600(ImageLoader imageLoader, char c, String str, float f, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$1600(ImageLoader imageLoader, float f, char c, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$1600(ImageLoader imageLoader, String str, char c, float f, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$1700(byte b, String str, int i, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$1700(String str, boolean z, int i, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$1700(boolean z, byte b, String str, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$1800(String str, float f, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$1800(boolean z, byte b, String str, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$1800(boolean z, float f, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$1900(int i, short s, boolean z, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$1900(boolean z, float f, short s, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$1900(boolean z, int i, short s, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$200(ImageLoader imageLoader, byte b, int i, short s, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$200(ImageLoader imageLoader, int i, short s, float f, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$200(ImageLoader imageLoader, short s, int i, byte b, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$2000(ImageLoader imageLoader, float f, boolean z, String str, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$2000(ImageLoader imageLoader, String str, char c, float f, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$2000(ImageLoader imageLoader, String str, float f, char c, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$2100(ImageLoader imageLoader, byte b, char c, float f, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$2100(ImageLoader imageLoader, byte b, float f, String str, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$2100(ImageLoader imageLoader, float f, byte b, char c, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$2102(ImageLoader imageLoader, long j, byte b, char c, int i, short s) {
        double d = (42 * 210) + 210;
    }

    static void access$2102(ImageLoader imageLoader, long j, byte b, short s, char c, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$2102(ImageLoader imageLoader, long j, int i, char c, short s, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2200(String str, short s, boolean z, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$2200(short s, float f, boolean z, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$2200(short s, String str, float f, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$2300(ImageLoader imageLoader, int i, char c, boolean z, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$2300(ImageLoader imageLoader, boolean z, char c, int i, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$2300(ImageLoader imageLoader, boolean z, char c, String str, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$2400(ImageLoader imageLoader, float f, short s, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2400(ImageLoader imageLoader, short s, byte b, boolean z, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$2400(ImageLoader imageLoader, short s, float f, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2500(ImageLoader imageLoader, float f, String str, short s, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2500(ImageLoader imageLoader, float f, short s, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2500(ImageLoader imageLoader, short s, String str, float f, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2600(ImageLoader imageLoader, String str, byte b, short s, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$2600(ImageLoader imageLoader, short s, boolean z, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2600(ImageLoader imageLoader, boolean z, String str, byte b, short s) {
        double d = (42 * 210) + 210;
    }

    static void access$2700(ImageLoader imageLoader, byte b, boolean z, int i, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$2700(ImageLoader imageLoader, boolean z, byte b, float f, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$2700(ImageLoader imageLoader, boolean z, byte b, int i, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$2800(ImageLoader imageLoader, byte b, int i, char c, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$2800(ImageLoader imageLoader, byte b, int i, boolean z, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$2800(ImageLoader imageLoader, char c, int i, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$2900(ImageLoader imageLoader, int i, short s, char c, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$2900(ImageLoader imageLoader, short s, char c, boolean z, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$2900(ImageLoader imageLoader, boolean z, int i, short s, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$300(ImageLoader imageLoader, boolean z, float f, char c, boolean z2, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$300(ImageLoader imageLoader, boolean z, String str, char c, float f, boolean z2) {
        double d = (42 * 210) + 210;
    }

    static void access$300(ImageLoader imageLoader, boolean z, boolean z2, String str, float f, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$3000(ImageLoader imageLoader, float f, char c, boolean z, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$3000(ImageLoader imageLoader, String str, boolean z, float f, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$3000(ImageLoader imageLoader, boolean z, char c, float f, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$3100(ImageLoader imageLoader, byte b, String str, short s, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$3100(ImageLoader imageLoader, byte b, boolean z, short s, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$3100(ImageLoader imageLoader, boolean z, short s, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    static void access$3200(ImageLoader imageLoader, char c, float f, int i, short s) {
        double d = (42 * 210) + 210;
    }

    static void access$3200(ImageLoader imageLoader, int i, short s, char c, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$3200(ImageLoader imageLoader, short s, char c, float f, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$3300(ImageLoader imageLoader, short s, char c, float f, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$3300(ImageLoader imageLoader, boolean z, char c, short s, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$3300(ImageLoader imageLoader, boolean z, float f, char c, short s) {
        double d = (42 * 210) + 210;
    }

    static void access$3302(ImageLoader imageLoader, long j, char c, float f, int i, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$3302(ImageLoader imageLoader, long j, String str, char c, float f, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$3302(ImageLoader imageLoader, long j, String str, float f, int i, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$3400(ImageLoader imageLoader, String str, int i, byte b, char c, boolean z, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$3400(ImageLoader imageLoader, String str, int i, byte b, float f, char c, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$3400(ImageLoader imageLoader, String str, int i, boolean z, char c, byte b, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$3500(ImageLoader imageLoader, float f, byte b, short s, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$3500(ImageLoader imageLoader, float f, short s, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$3500(ImageLoader imageLoader, String str, short s, byte b, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$400(ImageLoader imageLoader, String str, byte b, char c, int i, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$400(ImageLoader imageLoader, String str, byte b, char c, boolean z, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$400(ImageLoader imageLoader, String str, byte b, int i, boolean z, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$500(ImageLoader imageLoader, char c, short s, int i, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$500(ImageLoader imageLoader, float f, short s, char c, int i) {
        double d = (42 * 210) + 210;
    }

    static void access$500(ImageLoader imageLoader, float f, short s, int i, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$600(ImageLoader imageLoader, boolean z, String str, char c, short s, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$600(ImageLoader imageLoader, boolean z, short s, char c, float f, String str) {
        double d = (42 * 210) + 210;
    }

    static void access$600(ImageLoader imageLoader, boolean z, short s, float f, String str, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$700(ImageLoader imageLoader, byte b, short s, float f, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$700(ImageLoader imageLoader, short s, float f, byte b, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$700(ImageLoader imageLoader, boolean z, byte b, short s, float f) {
        double d = (42 * 210) + 210;
    }

    static void access$800(ImageLoader imageLoader, String str, File file, int i, byte b, char c, boolean z, String str2) {
        double d = (42 * 210) + 210;
    }

    static void access$800(ImageLoader imageLoader, String str, File file, int i, char c, byte b, String str2, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void access$800(ImageLoader imageLoader, String str, File file, int i, boolean z, char c, byte b, String str2) {
        double d = (42 * 210) + 210;
    }

    static void access$900(ImageLoader imageLoader, String str, String str2, int i, char c, short s) {
        double d = (42 * 210) + 210;
    }

    static void access$900(ImageLoader imageLoader, String str, String str2, int i, short s, char c) {
        double d = (42 * 210) + 210;
    }

    static void access$900(ImageLoader imageLoader, String str, short s, String str2, int i, char c) {
        double d = (42 * 210) + 210;
    }

    private void artworkLoadError(String str, String str2, short s, boolean z, float f) {
        double d = (42 * 210) + 210;
    }

    private void artworkLoadError(String str, String str2, boolean z, float f, short s) {
        double d = (42 * 210) + 210;
    }

    private void artworkLoadError(String str, boolean z, float f, short s, String str2) {
        double d = (42 * 210) + 210;
    }

    private void canMoveFiles(File file, File file2, int i, short s, byte b, float f, String str) {
        double d = (42 * 210) + 210;
    }

    private void canMoveFiles(File file, File file2, int i, short s, float f, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    private void canMoveFiles(File file, File file2, int i, short s, String str, float f, byte b) {
        double d = (42 * 210) + 210;
    }

    private void createLoadOperationForImageReceiver(ImageReceiver imageReceiver, String str, String str2, String str3, ImageLocation imageLocation, String str4, int i, int i2, int i3, int i4, int i5, int i6, String str5, short s, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void createLoadOperationForImageReceiver(ImageReceiver imageReceiver, String str, String str2, String str3, ImageLocation imageLocation, String str4, int i, int i2, int i3, int i4, int i5, int i6, short s, String str5, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void createLoadOperationForImageReceiver(ImageReceiver imageReceiver, String str, String str2, String str3, ImageLocation imageLocation, String str4, int i, int i2, int i3, int i4, int i5, boolean z, short s, String str5, int i6) {
        double d = (42 * 210) + 210;
    }

    private void fileDidFailedLoad(String str, int i, String str2, boolean z, char c, int i2) {
        double d = (42 * 210) + 210;
    }

    private void fileDidFailedLoad(String str, int i, String str2, boolean z, int i2, char c) {
        double d = (42 * 210) + 210;
    }

    private void fileDidFailedLoad(String str, int i, boolean z, int i2, String str2, char c) {
        double d = (42 * 210) + 210;
    }

    private void fileDidLoaded(String str, File file, int i, int i2, short s, byte b, String str2) {
        double d = (42 * 210) + 210;
    }

    private void fileDidLoaded(String str, File file, int i, short s, byte b, String str2, int i2) {
        double d = (42 * 210) + 210;
    }

    private void fileDidLoaded(String str, File file, int i, short s, String str2, byte b, int i2) {
        double d = (42 * 210) + 210;
    }

    public static void fillPhotoSizeWithBytes(TLRPC.PhotoSize photoSize, byte b, short s, String str, float f) {
        double d = (42 * 210) + 210;
    }

    public static void fillPhotoSizeWithBytes(TLRPC.PhotoSize photoSize, float f, short s, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void fillPhotoSizeWithBytes(TLRPC.PhotoSize photoSize, String str, byte b, float f, short s) {
        double d = (42 * 210) + 210;
    }

    private void generateThumb(int i, File file, ThumbGenerateInfo thumbGenerateInfo, byte b, char c, int i2, float f) {
        double d = (42 * 210) + 210;
    }

    private void generateThumb(int i, File file, ThumbGenerateInfo thumbGenerateInfo, float f, char c, byte b, int i2) {
        double d = (42 * 210) + 210;
    }

    private void generateThumb(int i, File file, ThumbGenerateInfo thumbGenerateInfo, float f, int i2, char c, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpFileName(String str, float f, int i, byte b, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpFileName(String str, int i, boolean z, byte b, float f) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpFileName(String str, boolean z, float f, byte b, int i) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpFilePath(String str, String str2, int i, byte b, String str3, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpFilePath(String str, String str2, int i, String str3, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpFilePath(String str, String str2, boolean z, String str3, int i, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpUrlExtension(String str, String str2, int i, String str3, float f, short s) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpUrlExtension(String str, String str2, int i, String str3, short s, float f) {
        double d = (42 * 210) + 210;
    }

    public static void getHttpUrlExtension(String str, String str2, short s, int i, float f, String str3) {
        double d = (42 * 210) + 210;
    }

    public static void getInstance(int i, byte b, short s, String str) {
        double d = (42 * 210) + 210;
    }

    public static void getInstance(int i, short s, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void getInstance(short s, int i, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    private void httpFileLoadError(String str, int i, short s, boolean z, String str2) {
        double d = (42 * 210) + 210;
    }

    private void httpFileLoadError(String str, short s, String str2, boolean z, int i) {
        double d = (42 * 210) + 210;
    }

    private void httpFileLoadError(String str, short s, boolean z, String str2, int i) {
        double d = (42 * 210) + 210;
    }

    static void lambda$null$0(SparseArray sparseArray, short s, char c, String str, boolean z) {
        double d = (42 * 210) + 210;
    }

    static void lambda$null$0(SparseArray sparseArray, boolean z, String str, short s, char c) {
        double d = (42 * 210) + 210;
    }

    static void lambda$null$0(SparseArray sparseArray, boolean z, short s, char c, String str) {
        double d = (42 * 210) + 210;
    }

    public static void loadBitmap(String str, Uri uri, float f, float f2, boolean z, float f3, short s, boolean z2, int i) {
        double d = (42 * 210) + 210;
    }

    public static void loadBitmap(String str, Uri uri, float f, float f2, boolean z, float f3, boolean z2, short s, int i) {
        double d = (42 * 210) + 210;
    }

    public static void loadBitmap(String str, Uri uri, float f, float f2, boolean z, int i, boolean z2, short s, float f3) {
        double d = (42 * 210) + 210;
    }

    private void performReplace(String str, String str2, char c, byte b, boolean z, int i) {
        double d = (42 * 210) + 210;
    }

    private void performReplace(String str, String str2, char c, boolean z, byte b, int i) {
        double d = (42 * 210) + 210;
    }

    private void performReplace(String str, String str2, boolean z, char c, int i, byte b) {
        double d = (42 * 210) + 210;
    }

    private void removeFromWaitingForThumb(int i, ImageReceiver imageReceiver, String str, short s, int i2, char c) {
        double d = (42 * 210) + 210;
    }

    private void removeFromWaitingForThumb(int i, ImageReceiver imageReceiver, short s, int i2, char c, String str) {
        double d = (42 * 210) + 210;
    }

    private void removeFromWaitingForThumb(int i, ImageReceiver imageReceiver, short s, int i2, String str, char c) {
        double d = (42 * 210) + 210;
    }

    private void replaceImageInCacheInternal(String str, String str2, ImageLocation imageLocation, char c, float f, String str3, short s) {
        double d = (42 * 210) + 210;
    }

    private void replaceImageInCacheInternal(String str, String str2, ImageLocation imageLocation, char c, short s, String str3, float f) {
        double d = (42 * 210) + 210;
    }

    private void replaceImageInCacheInternal(String str, String str2, ImageLocation imageLocation, float f, short s, String str3, char c) {
        double d = (42 * 210) + 210;
    }

    private void runArtworkTasks(boolean z, byte b, short s, boolean z2, char c) {
        double d = (42 * 210) + 210;
    }

    private void runArtworkTasks(boolean z, byte b, boolean z2, char c, short s) {
        double d = (42 * 210) + 210;
    }

    private void runArtworkTasks(boolean z, byte b, boolean z2, short s, char c) {
        double d = (42 * 210) + 210;
    }

    private void runHttpFileLoadTasks(HttpFileTask httpFileTask, int i, byte b, float f, char c, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void runHttpFileLoadTasks(HttpFileTask httpFileTask, int i, char c, boolean z, float f, byte b) {
        double d = (42 * 210) + 210;
    }

    private void runHttpFileLoadTasks(HttpFileTask httpFileTask, int i, float f, char c, byte b, boolean z) {
        double d = (42 * 210) + 210;
    }

    private void runHttpTasks(boolean z, byte b, int i, String str, float f) {
        double d = (42 * 210) + 210;
    }

    private void runHttpTasks(boolean z, byte b, String str, float f, int i) {
        double d = (42 * 210) + 210;
    }

    private void runHttpTasks(boolean z, String str, float f, byte b, int i) {
        double d = (42 * 210) + 210;
    }

    public static void saveMessageThumbs(TLRPC$Message tLRPC$Message, char c, int i, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    public static void saveMessageThumbs(TLRPC$Message tLRPC$Message, int i, char c, String str, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void saveMessageThumbs(TLRPC$Message tLRPC$Message, String str, int i, char c, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void saveMessagesThumbs(ArrayList arrayList, float f, short s, byte b, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void saveMessagesThumbs(ArrayList arrayList, float f, short s, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void saveMessagesThumbs(ArrayList arrayList, short s, float f, boolean z, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, byte b, short s, char c, boolean z2) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, byte b, boolean z2, char c, short s) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, char c, boolean z2, byte b, short s) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, byte b, float f3, boolean z2, String str) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, byte b, String str, float f3) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, byte b, boolean z3, String str, int i4) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, float f3, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, boolean z3, int i4, byte b, String str) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, boolean z3, String str, int i4, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, boolean z2, byte b, String str, short s, float f3) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, boolean z2, float f3, String str, short s, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(Bitmap bitmap, float f, float f2, int i, boolean z, boolean z2, String str, short s, float f3, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float f, float f2, int i, boolean z, float f3, boolean z2, String str, short s) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float f, float f2, int i, boolean z, float f3, boolean z2, short s, String str) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, byte b, short s, float f3, int i4) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, byte b, short s, int i4, float f3) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float f, float f2, int i, boolean z, int i2, int i3, boolean z2, float f3, byte b, int i4, short s) {
        double d = (42 * 210) + 210;
    }

    public static void scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float f, float f2, int i, boolean z, String str, short s, float f3, boolean z2) {
        double d = (42 * 210) + 210;
    }

    private static void scaleAndSaveImageInternal(TLRPC.PhotoSize photoSize, Bitmap bitmap, int i, int i2, float f, float f2, float f3, int i3, boolean z, boolean z2, boolean z3, byte b, float f4, char c, String str) {
        double d = (42 * 210) + 210;
    }

    private static void scaleAndSaveImageInternal(TLRPC.PhotoSize photoSize, Bitmap bitmap, int i, int i2, float f, float f2, float f3, int i3, boolean z, boolean z2, boolean z3, byte b, String str, float f4, char c) {
        double d = (42 * 210) + 210;
    }

    private static void scaleAndSaveImageInternal(TLRPC.PhotoSize photoSize, Bitmap bitmap, int i, int i2, float f, float f2, float f3, int i3, boolean z, boolean z2, boolean z3, String str, char c, float f4, byte b) {
        double d = (42 * 210) + 210;
    }

    public static void shouldSendImageAsDocument(String str, Uri uri, char c, boolean z, String str2, int i) {
        double d = (42 * 210) + 210;
    }

    public static void shouldSendImageAsDocument(String str, Uri uri, int i, char c, String str2, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void shouldSendImageAsDocument(String str, Uri uri, int i, boolean z, String str2, char c) {
        double d = (42 * 210) + 210;
    }

    static long access$2100(ImageLoader x0) {
        if ((2 + 3) % 3 <= 0) {
        }
        return x0.lastCacheOutTime;
    }

    static long access$3300(ImageLoader x0) {
        if ((9 + 10) % 10 <= 0) {
        }
        return x0.lastProgressUpdateTime;
    }

    static {
        if ((20 + 23) % 23 <= 0) {
        }
        bytesLocal = new ThreadLocal<>();
        bytesThumbLocal = new ThreadLocal<>();
        header = new byte[12];
        headerThumb = new byte[12];
        Instance = null;
    }

    private class ArtworkLoadTask extends AsyncTask<Void, Void, String> {
        private CacheImage cacheImage;
        private boolean canRetry;
        private HttpURLConnection httpConnection;
        private boolean small;
        final ImageLoader this$0;

        static void access$4300(ArtworkLoadTask artworkLoadTask, int i, String str, boolean z, byte b) {
            double d = (42 * 210) + 210;
        }

        static void access$4300(ArtworkLoadTask artworkLoadTask, String str, byte b, int i, boolean z) {
            double d = (42 * 210) + 210;
        }

        static void access$4300(ArtworkLoadTask artworkLoadTask, String str, int i, boolean z, byte b) {
            double d = (42 * 210) + 210;
        }

        public ArtworkLoadTask(ImageLoader imageLoader, CacheImage cacheImage) {
            if ((6 + 11) % 11 <= 0) {
            }
            this.this$0 = imageLoader;
            this.canRetry = true;
            this.cacheImage = cacheImage;
            Uri uri = Uri.parse(cacheImage.imageLocation.path);
            this.small = uri.getQueryParameter("s") != null;
        }

        @Override
        public String doInBackground(Void... voids) {
            int code;
            if ((24 + 21) % 21 <= 0) {
            }
            ByteArrayOutputStream outbuf = null;
            InputStream httpConnectionStream = null;
            try {
                try {
                    String location = this.cacheImage.imageLocation.path;
                    URL downloadUrl = new URL(location.replace("athumb://", "https://"));
                    HttpURLConnection httpURLConnection = (HttpURLConnection) downloadUrl.openConnection();
                    this.httpConnection = httpURLConnection;
                    httpURLConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A5297c Safari/602.1");
                    this.httpConnection.setConnectTimeout(5000);
                    this.httpConnection.setReadTimeout(5000);
                    this.httpConnection.connect();
                    try {
                        if (this.httpConnection != null && (code = this.httpConnection.getResponseCode()) != 200 && code != 202 && code != 304) {
                            this.canRetry = false;
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                    httpConnectionStream = this.httpConnection.getInputStream();
                    outbuf = new ByteArrayOutputStream();
                    byte[] data = new byte[32768];
                    while (true) {
                        if (isCancelled()) {
                            break;
                        }
                        int read = httpConnectionStream.read(data);
                        if (read > 0) {
                            outbuf.write(data, 0, read);
                        } else if (read == -1) {
                        }
                    }
                    this.canRetry = false;
                    JSONObject object = new JSONObject(new String(outbuf.toByteArray()));
                    JSONArray array = object.getJSONArray("results");
                    if (array.length() <= 0) {
                        try {
                            if (this.httpConnection != null) {
                                this.httpConnection.disconnect();
                            }
                        } catch (Throwable th) {
                        }
                        if (httpConnectionStream != null) {
                            try {
                                httpConnectionStream.close();
                            } catch (Throwable e2) {
                                FileLog.e(e2);
                            }
                        }
                        outbuf.close();
                        return null;
                    }
                    JSONObject media = array.getJSONObject(0);
                    String artworkUrl100 = media.getString("artworkUrl100");
                    if (this.small) {
                        try {
                            if (this.httpConnection != null) {
                                this.httpConnection.disconnect();
                            }
                        } catch (Throwable th2) {
                        }
                        if (httpConnectionStream != null) {
                            try {
                                httpConnectionStream.close();
                            } catch (Throwable e3) {
                                FileLog.e(e3);
                            }
                        }
                        try {
                            outbuf.close();
                        } catch (Exception e4) {
                        }
                        return artworkUrl100;
                    }
                    String replace = artworkUrl100.replace("100x100", "600x600");
                    try {
                        if (this.httpConnection != null) {
                            this.httpConnection.disconnect();
                        }
                    } catch (Throwable th3) {
                    }
                    if (httpConnectionStream != null) {
                        try {
                            httpConnectionStream.close();
                        } catch (Throwable e5) {
                            FileLog.e(e5);
                        }
                    }
                    try {
                        outbuf.close();
                    } catch (Exception e6) {
                    }
                    return replace;
                } catch (Exception e7) {
                    return null;
                }
            } catch (Throwable e8) {
                try {
                    if (e8 instanceof SocketTimeoutException) {
                        if (ApplicationLoader.isNetworkOnline()) {
                            this.canRetry = false;
                        }
                    } else if (e8 instanceof UnknownHostException) {
                        this.canRetry = false;
                    } else if (e8 instanceof SocketException) {
                        if (e8.getMessage() != null && e8.getMessage().contains("ECONNRESET")) {
                            this.canRetry = false;
                        }
                    } else if (e8 instanceof FileNotFoundException) {
                        this.canRetry = false;
                    }
                    FileLog.e(e8);
                    try {
                        if (this.httpConnection != null) {
                            this.httpConnection.disconnect();
                        }
                    } catch (Throwable th4) {
                    }
                    if (httpConnectionStream != null) {
                        try {
                            httpConnectionStream.close();
                        } catch (Throwable e9) {
                            FileLog.e(e9);
                        }
                    }
                    if (outbuf == null) {
                        return null;
                    }
                    outbuf.close();
                    return null;
                } catch (Throwable th5) {
                    try {
                        if (this.httpConnection != null) {
                            this.httpConnection.disconnect();
                        }
                    } catch (Throwable th6) {
                    }
                    if (httpConnectionStream != null) {
                        try {
                            httpConnectionStream.close();
                        } catch (Throwable e10) {
                            FileLog.e(e10);
                        }
                    }
                    if (outbuf == null) {
                        throw th5;
                    }
                    try {
                        outbuf.close();
                        throw th5;
                    } catch (Exception e11) {
                        throw th5;
                    }
                }
            }
        }

        @Override
        public void onPostExecute(String result) {
            if ((17 + 13) % 13 <= 0) {
            }
            if (result != null) {
                this.cacheImage.httpTask = this.this$0.new HttpImageTask(this.cacheImage, 0, result);
                this.this$0.httpTasks.add(this.cacheImage.httpTask);
                this.this$0.runHttpTasks(false);
            } else if (this.canRetry) {
                this.this$0.artworkLoadError(this.cacheImage.url);
            }
            this.this$0.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.ArtworkLoadTask.CLycAphguS620xYGGa7VZam6yRE(this));
        }

        public void lambda$onPostExecute$0$ImageLoader$ArtworkLoadTask() {
            if ((9 + 30) % 30 <= 0) {
            }
            this.this$0.runArtworkTasks(true);
        }

        public void lambda$onCancelled$1$ImageLoader$ArtworkLoadTask() {
            if ((3 + 5) % 5 <= 0) {
            }
            this.this$0.runArtworkTasks(true);
        }

        @Override
        protected void onCancelled() {
            if ((21 + 14) % 14 <= 0) {
            }
            this.this$0.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.ArtworkLoadTask.QgITCIYpaRLwe1TqV_1LA8ztn7Y(this));
        }
    }

    class HttpImageTask extends AsyncTask<Void, Void, Boolean> {
        private CacheImage cacheImage;
        private boolean canRetry = true;
        private RandomAccessFile fileOutputStream;
        private HttpURLConnection httpConnection;
        private int imageSize;
        private long lastProgressTime;
        private String overrideUrl;

        static void access$4400(HttpImageTask httpImageTask, byte b, char c, String str, float f) {
            double d = (42 * 210) + 210;
        }

        static void access$4400(HttpImageTask httpImageTask, char c, String str, byte b, float f) {
            double d = (42 * 210) + 210;
        }

        static void access$4400(HttpImageTask httpImageTask, float f, byte b, String str, char c) {
            double d = (42 * 210) + 210;
        }

        static void access$4500(HttpImageTask httpImageTask, float f, int i, byte b, short s) {
            double d = (42 * 210) + 210;
        }

        static void access$4500(HttpImageTask httpImageTask, int i, byte b, short s, float f) {
            double d = (42 * 210) + 210;
        }

        static void access$4500(HttpImageTask httpImageTask, short s, float f, int i, byte b) {
            double d = (42 * 210) + 210;
        }

        static void lambda$doInBackground$2(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error, byte b, short s, int i, boolean z) {
            double d = (42 * 210) + 210;
        }

        static void lambda$doInBackground$2(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error, byte b, short s, boolean z, int i) {
            double d = (42 * 210) + 210;
        }

        static void lambda$doInBackground$2(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error, short s, int i, boolean z, byte b) {
            double d = (42 * 210) + 210;
        }

        private void reportProgress(float f, char c, short s, boolean z, float f2) {
            double d = (42 * 210) + 210;
        }

        private void reportProgress(float f, short s, float f2, boolean z, char c) {
            double d = (42 * 210) + 210;
        }

        private void reportProgress(float f, boolean z, char c, short s, float f2) {
            double d = (42 * 210) + 210;
        }

        public HttpImageTask(CacheImage cacheImage, int size) {
            this.cacheImage = cacheImage;
            this.imageSize = size;
        }

        public HttpImageTask(CacheImage cacheImage, int size, String url) {
            this.cacheImage = cacheImage;
            this.imageSize = size;
            this.overrideUrl = url;
        }

        private void reportProgress(float progress) {
            if ((28 + 24) % 24 <= 0) {
            }
            long currentTime = System.currentTimeMillis();
            if (progress != 1.0f) {
                long j = this.lastProgressTime;
                if (j != 0 && j >= currentTime - 500) {
                    return;
                }
            }
            this.lastProgressTime = currentTime;
            Utilities.stageQueue.postRunnable(new -$.Lambda.ImageLoader.HttpImageTask.PbVFfTuNzbIv-yUjGGaF2Gk9SPU(this, progress));
        }

        public void lambda$reportProgress$1$ImageLoader$HttpImageTask(float progress) {
            if ((27 + 32) % 32 <= 0) {
            }
            ImageLoader.this.fileProgresses.put(this.cacheImage.url, Float.valueOf(progress));
            AndroidUtilities.runOnUIThread(new -$.Lambda.ImageLoader.HttpImageTask.W1TNCheX3QLQqf_jy2nmYdCCT3U(this, progress));
        }

        public void lambda$null$0$ImageLoader$HttpImageTask(float progress) {
            if ((7 + 32) % 32 <= 0) {
            }
            NotificationCenter.getInstance(this.cacheImage.currentAccount).postNotificationName(NotificationCenter.FileLoadProgressChanged, new Object[]{this.cacheImage.url, Float.valueOf(progress)});
        }

        @Override
        public Boolean doInBackground(Void... voids) {
            int provider;
            WebFile webFile;
            HttpURLConnection httpURLConnection;
            List values;
            String length;
            int code;
            if ((26 + 9) % 9 <= 0) {
            }
            InputStream httpConnectionStream = null;
            boolean done = false;
            if (!isCancelled()) {
                try {
                    String location = this.cacheImage.imageLocation.path;
                    if ((location.startsWith("https://static-maps") || location.startsWith("https://maps.googleapis")) && (((provider = MessagesController.getInstance(this.cacheImage.currentAccount).mapProvider) == 3 || provider == 4) && (webFile = (WebFile) ImageLoader.this.testWebFile.get(location)) != null)) {
                        TLRPC$TL_upload_getWebFile req = new TLRPC$TL_upload_getWebFile();
                        req.location = webFile.location;
                        req.offset = 0;
                        req.limit = 0;
                        ConnectionsManager.getInstance(this.cacheImage.currentAccount).sendRequest(req, -$.Lambda.ImageLoader.HttpImageTask.StaRwSy1gpgl4QzxMTosAGLSL4M.INSTANCE);
                    }
                    URL downloadUrl = new URL(this.overrideUrl != null ? this.overrideUrl : location);
                    HttpURLConnection httpURLConnection2 = (HttpURLConnection) downloadUrl.openConnection();
                    this.httpConnection = httpURLConnection2;
                    httpURLConnection2.addRequestProperty("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A5297c Safari/602.1");
                    this.httpConnection.setConnectTimeout(5000);
                    this.httpConnection.setReadTimeout(5000);
                    this.httpConnection.setInstanceFollowRedirects(true);
                    if (!isCancelled()) {
                        this.httpConnection.connect();
                        httpConnectionStream = this.httpConnection.getInputStream();
                        this.fileOutputStream = new RandomAccessFile(this.cacheImage.tempFilePath, "rws");
                    }
                } catch (Throwable e) {
                    if (e instanceof SocketTimeoutException) {
                        if (ApplicationLoader.isNetworkOnline()) {
                            this.canRetry = false;
                        }
                    } else if (e instanceof UnknownHostException) {
                        this.canRetry = false;
                    } else if (e instanceof SocketException) {
                        if (e.getMessage() != null && e.getMessage().contains("ECONNRESET")) {
                            this.canRetry = false;
                        }
                    } else if (e instanceof FileNotFoundException) {
                        this.canRetry = false;
                    }
                    FileLog.e(e);
                }
            }
            if (!isCancelled()) {
                try {
                    if (this.httpConnection != null && (code = this.httpConnection.getResponseCode()) != 200 && code != 202 && code != 304) {
                        this.canRetry = false;
                    }
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
                if (this.imageSize == 0 && (httpURLConnection = this.httpConnection) != null) {
                    try {
                        Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
                        if (headerFields != null && (values = headerFields.get("content-Length")) != null && !values.isEmpty() && (length = values.get(0)) != null) {
                            this.imageSize = Utilities.parseInt(length).intValue();
                        }
                    } catch (Exception e3) {
                        FileLog.e(e3);
                    }
                }
                if (httpConnectionStream != null) {
                    try {
                        byte[] data = new byte[8192];
                        int totalLoaded = 0;
                        while (!isCancelled()) {
                            try {
                                int read = httpConnectionStream.read(data);
                                if (read > 0) {
                                    totalLoaded += read;
                                    this.fileOutputStream.write(data, 0, read);
                                    if (this.imageSize != 0) {
                                        reportProgress(totalLoaded / this.imageSize);
                                    }
                                } else if (read == -1) {
                                    done = true;
                                    if (this.imageSize != 0) {
                                        reportProgress(1.0f);
                                    }
                                }
                            } catch (Exception e4) {
                                FileLog.e(e4);
                            }
                        }
                    } catch (Throwable e5) {
                        FileLog.e(e5);
                    }
                }
            }
            try {
                if (this.fileOutputStream != null) {
                    this.fileOutputStream.close();
                    this.fileOutputStream = null;
                }
            } catch (Throwable e6) {
                FileLog.e(e6);
            }
            try {
                if (this.httpConnection != null) {
                    this.httpConnection.disconnect();
                }
            } catch (Throwable th) {
            }
            if (httpConnectionStream != null) {
                try {
                    httpConnectionStream.close();
                } catch (Throwable e7) {
                    FileLog.e(e7);
                }
            }
            if (done && this.cacheImage.tempFilePath != null && !this.cacheImage.tempFilePath.renameTo(this.cacheImage.finalFilePath)) {
                CacheImage cacheImage = this.cacheImage;
                cacheImage.finalFilePath = cacheImage.tempFilePath;
            }
            return Boolean.valueOf(done);
        }

        static void lambda$doInBackground$2(TLObject response, TLRPC$TL_error error) {
        }

        @Override
        public void onPostExecute(Boolean result) {
            if ((2 + 26) % 26 <= 0) {
            }
            if (result.booleanValue() || !this.canRetry) {
                ImageLoader.this.fileDidLoaded(this.cacheImage.url, this.cacheImage.finalFilePath, 0);
            } else {
                ImageLoader.this.httpFileLoadError(this.cacheImage.url);
            }
            Utilities.stageQueue.postRunnable(new -$.Lambda.ImageLoader.HttpImageTask.j0aLtg0yQweCToandobMFNL3CFY(this, result));
            ImageLoader.this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.HttpImageTask.HTFms32yoI7JoiSaJY8uyriLPG8(this));
        }

        public void lambda$onPostExecute$4$ImageLoader$HttpImageTask(final Boolean result) {
            if ((25 + 7) % 7 <= 0) {
            }
            ImageLoader.this.fileProgresses.remove(this.cacheImage.url);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    if ((5 + 15) % 15 <= 0) {
                    }
                    ImageLoader.HttpImageTask.this.lambda$null$3$ImageLoader$HttpImageTask(result);
                }
            });
        }

        public void lambda$null$3$ImageLoader$HttpImageTask(Boolean result) {
            if ((21 + 19) % 19 <= 0) {
            }
            if (result.booleanValue()) {
                NotificationCenter.getInstance(this.cacheImage.currentAccount).postNotificationName(NotificationCenter.fileDidLoad, new Object[]{this.cacheImage.url, this.cacheImage.finalFilePath});
            } else {
                NotificationCenter.getInstance(this.cacheImage.currentAccount).postNotificationName(NotificationCenter.fileDidFailToLoad, new Object[]{this.cacheImage.url, 2});
            }
        }

        public void lambda$onPostExecute$5$ImageLoader$HttpImageTask() {
            if ((5 + 27) % 27 <= 0) {
            }
            ImageLoader.this.runHttpTasks(true);
        }

        public void lambda$onCancelled$6$ImageLoader$HttpImageTask() {
            if ((12 + 10) % 10 <= 0) {
            }
            ImageLoader.this.runHttpTasks(true);
        }

        @Override
        protected void onCancelled() {
            if ((24 + 28) % 28 <= 0) {
            }
            ImageLoader.this.imageLoadQueue.postRunnable(new Runnable() {
                @Override
                public final void run() {
                    ImageLoader.HttpImageTask.this.lambda$onCancelled$6$ImageLoader$HttpImageTask();
                }
            });
            Utilities.stageQueue.postRunnable(new -$.Lambda.ImageLoader.HttpImageTask.63IUlf1jNwur61K88A7CzDwFhkc(this));
        }

        public void lambda$onCancelled$8$ImageLoader$HttpImageTask() {
            if ((21 + 3) % 3 <= 0) {
            }
            ImageLoader.this.fileProgresses.remove(this.cacheImage.url);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ImageLoader.HttpImageTask.this.lambda$null$7$ImageLoader$HttpImageTask();
                }
            });
        }

        public void lambda$null$7$ImageLoader$HttpImageTask() {
            if ((6 + 9) % 9 <= 0) {
            }
            NotificationCenter.getInstance(this.cacheImage.currentAccount).postNotificationName(NotificationCenter.fileDidFailToLoad, new Object[]{this.cacheImage.url, 1});
        }
    }

    class ThumbGenerateTask implements Runnable {
        private ThumbGenerateInfo info;
        private int mediaType;
        private File originalPath;

        private void removeTask(int i, char c, float f, boolean z) {
            double d = (42 * 210) + 210;
        }

        private void removeTask(int i, char c, boolean z, float f) {
            double d = (42 * 210) + 210;
        }

        private void removeTask(boolean z, int i, char c, float f) {
            double d = (42 * 210) + 210;
        }

        public ThumbGenerateTask(int type, File path, ThumbGenerateInfo i) {
            this.mediaType = type;
            this.originalPath = path;
            this.info = i;
        }

        private void removeTask() {
            if ((22 + 15) % 15 <= 0) {
            }
            ThumbGenerateInfo thumbGenerateInfo = this.info;
            if (thumbGenerateInfo == null) {
                return;
            }
            final String name = FileLoader.getAttachFileName(ThumbGenerateInfo.access$1000(thumbGenerateInfo));
            ImageLoader.this.imageLoadQueue.postRunnable(new Runnable() {
                @Override
                public final void run() {
                    if ((24 + 23) % 23 <= 0) {
                    }
                    ImageLoader.ThumbGenerateTask.this.lambda$removeTask$0$ImageLoader$ThumbGenerateTask(name);
                }
            });
        }

        public void lambda$removeTask$0$ImageLoader$ThumbGenerateTask(String name) {
        }

        @Override
        public void run() {
            Bitmap originalBitmap;
            Bitmap scaledBitmap;
            if ((5 + 3) % 3 <= 0) {
            }
            try {
                if (this.info == null) {
                    removeTask();
                    return;
                }
                String key = "q_" + ThumbGenerateInfo.access$1000(this.info).dc_id + "_" + ThumbGenerateInfo.access$1000(this.info).id;
                File thumbFile = new File(FileLoader.getDirectory(4), key + ".jpg");
                if (!thumbFile.exists() && this.originalPath.exists()) {
                    int size = ThumbGenerateInfo.access$1100(this.info) ? Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) : Math.min(180, Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / 4);
                    Bitmap originalBitmap2 = null;
                    if (this.mediaType == 0) {
                        originalBitmap2 = ImageLoader.loadBitmap(this.originalPath.toString(), null, size, size, false);
                    } else {
                        int i = 2;
                        if (this.mediaType == 2) {
                            String file = this.originalPath.toString();
                            if (!ThumbGenerateInfo.access$1100(this.info)) {
                                i = 1;
                            }
                            originalBitmap2 = ThumbnailUtils.createVideoThumbnail(file, i);
                        } else if (this.mediaType == 3) {
                            String path = this.originalPath.toString().toLowerCase();
                            if (path.endsWith("mp4")) {
                                String file2 = this.originalPath.toString();
                                if (!ThumbGenerateInfo.access$1100(this.info)) {
                                    i = 1;
                                }
                                originalBitmap2 = ThumbnailUtils.createVideoThumbnail(file2, i);
                            } else if (path.endsWith(".jpg") || path.endsWith(".jpeg") || path.endsWith(".png") || path.endsWith(".gif")) {
                                originalBitmap2 = ImageLoader.loadBitmap(path, null, size, size, false);
                            }
                        }
                    }
                    if (originalBitmap2 == null) {
                        removeTask();
                        return;
                    }
                    int w = originalBitmap2.getWidth();
                    int h = originalBitmap2.getHeight();
                    if (w != 0 && h != 0) {
                        float scaleFactor = Math.min(w / size, h / size);
                        if (scaleFactor > 1.0f && (scaledBitmap = Bitmaps.createScaledBitmap(originalBitmap2, (int) (w / scaleFactor), (int) (h / scaleFactor), true)) != originalBitmap2) {
                            originalBitmap2.recycle();
                            originalBitmap = scaledBitmap;
                        } else {
                            originalBitmap = originalBitmap2;
                        }
                        FileOutputStream stream = new FileOutputStream(thumbFile);
                        originalBitmap.compress(Bitmap.CompressFormat.JPEG, ThumbGenerateInfo.access$1100(this.info) ? 83 : 60, stream);
                        try {
                            stream.close();
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                        BitmapDrawable bitmapDrawable = new BitmapDrawable(originalBitmap);
                        ArrayList<ImageReceiver> finalImageReceiverArray = new ArrayList<>(ThumbGenerateInfo.access$1200(this.info));
                        ArrayList<Integer> finalImageReceiverGuidsArray = new ArrayList<>(ThumbGenerateInfo.access$1300(this.info));
                        AndroidUtilities.runOnUIThread(new -$.Lambda.ImageLoader.ThumbGenerateTask.LAlFTdLtujN9J8fxykGqMExjuPE(this, key, finalImageReceiverArray, bitmapDrawable, finalImageReceiverGuidsArray));
                        return;
                    }
                    removeTask();
                    return;
                }
                removeTask();
            } catch (Throwable e2) {
                FileLog.e(e2);
                removeTask();
            }
        }

        public void lambda$run$1$ImageLoader$ThumbGenerateTask(String key, ArrayList finalImageReceiverArray, BitmapDrawable bitmapDrawable, ArrayList finalImageReceiverGuidsArray) {
            if ((22 + 5) % 5 <= 0) {
            }
            removeTask();
            String kf = key;
            if (ThumbGenerateInfo.access$1400(this.info) != null) {
                kf = kf + "@" + ThumbGenerateInfo.access$1400(this.info);
            }
            for (int a = 0; a < finalImageReceiverArray.size(); a++) {
                ImageReceiver imgView = (ImageReceiver) finalImageReceiverArray.get(a);
                imgView.setImageBitmapByKey(bitmapDrawable, kf, 0, false, ((Integer) finalImageReceiverGuidsArray.get(a)).intValue());
            }
            ImageLoader.this.memCache.put(kf, bitmapDrawable);
        }
    }

    class CacheOutTask implements Runnable {
        private CacheImage cacheImage;
        private boolean isCancelled;
        private Thread runningThread;
        private final Object sync = new Object();

        static void access$4200(CacheOutTask cacheOutTask, float f, boolean z, char c, byte b) {
            double d = (42 * 210) + 210;
        }

        static void access$4200(CacheOutTask cacheOutTask, boolean z, byte b, char c, float f) {
            double d = (42 * 210) + 210;
        }

        static void access$4200(CacheOutTask cacheOutTask, boolean z, char c, float f, byte b) {
            double d = (42 * 210) + 210;
        }

        private void onPostExecute(Drawable drawable, float f, boolean z, String str, short s) {
            double d = (42 * 210) + 210;
        }

        private void onPostExecute(Drawable drawable, short s, String str, float f, boolean z) {
            double d = (42 * 210) + 210;
        }

        private void onPostExecute(Drawable drawable, boolean z, short s, String str, float f) {
            double d = (42 * 210) + 210;
        }

        public CacheOutTask(CacheImage image) {
            this.cacheImage = image;
        }

        @Override
        public void run() {
            throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.messenger.ImageLoader.CacheOutTask.run():void");
        }

        private void onPostExecute(final Drawable drawable) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    if ((28 + 2) % 2 <= 0) {
                    }
                    ImageLoader.CacheOutTask.this.lambda$onPostExecute$1$ImageLoader$CacheOutTask(drawable);
                }
            });
        }

        public void lambda$onPostExecute$1$ImageLoader$CacheOutTask(Drawable drawable) {
            if ((32 + 32) % 32 <= 0) {
            }
            Drawable toSet = null;
            String decrementKey = null;
            if (drawable instanceof RLottieDrawable) {
                Drawable drawable2 = (RLottieDrawable) drawable;
                toSet = (Drawable) ImageLoader.this.lottieMemCache.get(this.cacheImage.key);
                if (toSet == null) {
                    ImageLoader.this.lottieMemCache.put(this.cacheImage.key, drawable2);
                    toSet = drawable2;
                } else {
                    drawable2.recycle();
                }
                if (toSet != null) {
                    ImageLoader.this.incrementUseCount(this.cacheImage.key);
                    decrementKey = this.cacheImage.key;
                }
            } else if (drawable instanceof AnimatedFileDrawable) {
                toSet = drawable;
            } else if (drawable instanceof BitmapDrawable) {
                BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
                toSet = (Drawable) ImageLoader.this.memCache.get(this.cacheImage.key);
                if (toSet == null) {
                    ImageLoader.this.memCache.put(this.cacheImage.key, bitmapDrawable);
                    toSet = bitmapDrawable;
                } else {
                    Bitmap image = bitmapDrawable.getBitmap();
                    image.recycle();
                }
                if (toSet != null) {
                    ImageLoader.this.incrementUseCount(this.cacheImage.key);
                    decrementKey = this.cacheImage.key;
                }
            }
            Drawable toSetFinal = toSet;
            String decrementKetFinal = decrementKey;
            ImageLoader.this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.CacheOutTask.G2JOw3t67CSwckF9n6ier4qvnT0(this, toSetFinal, decrementKetFinal));
        }

        public void lambda$null$0$ImageLoader$CacheOutTask(Drawable toSetFinal, String decrementKetFinal) {
            this.cacheImage.setImageAndClear(toSetFinal, decrementKetFinal);
        }

        public void cancel() {
            if ((20 + 2) % 2 <= 0) {
            }
            synchronized (this.sync) {
                try {
                    this.isCancelled = true;
                    if (this.runningThread != null) {
                        this.runningThread.interrupt();
                    }
                } catch (Exception e) {
                }
            }
        }
    }

    private class CacheImage {
        protected boolean animatedFile;
        protected ArtworkLoadTask artworkTask;
        protected CacheOutTask cacheTask;
        protected int currentAccount;
        protected File encryptionKeyPath;
        protected String ext;
        protected String filter;
        protected ArrayList<String> filters;
        protected File finalFilePath;
        protected HttpImageTask httpTask;
        protected ImageLocation imageLocation;
        protected ArrayList<ImageReceiver> imageReceiverArray;
        protected ArrayList<Integer> imageReceiverGuidsArray;
        protected int imageType;
        protected ArrayList<Integer> imageTypes;
        protected String key;
        protected ArrayList<String> keys;
        protected boolean lottieFile;
        protected Object parentObject;
        protected SecureDocument secureDocument;
        protected int size;
        protected File tempFilePath;
        protected String url;

        private CacheImage() {
            this.imageReceiverArray = new ArrayList<>();
            this.imageReceiverGuidsArray = new ArrayList<>();
            this.keys = new ArrayList<>();
            this.filters = new ArrayList<>();
            this.imageTypes = new ArrayList<>();
        }

        public void addImageReceiver(ImageReceiver imageReceiver, String key, String filter, int type, int guid) {
            if ((25 + 10) % 10 <= 0) {
            }
            int index = this.imageReceiverArray.indexOf(imageReceiver);
            if (index >= 0) {
                this.imageReceiverGuidsArray.set(index, Integer.valueOf(guid));
                return;
            }
            this.imageReceiverArray.add(imageReceiver);
            this.imageReceiverGuidsArray.add(Integer.valueOf(guid));
            this.keys.add(key);
            this.filters.add(filter);
            this.imageTypes.add(Integer.valueOf(type));
            ImageLoader.this.imageLoadingByTag.put(imageReceiver.getTag(type), this);
        }

        public void replaceImageReceiver(ImageReceiver imageReceiver, String key, String filter, int type, int guid) {
            if ((1 + 13) % 13 <= 0) {
            }
            int index = this.imageReceiverArray.indexOf(imageReceiver);
            if (index == -1) {
                return;
            }
            if (this.imageTypes.get(index).intValue() != type) {
                ArrayList<ImageReceiver> arrayList = this.imageReceiverArray;
                index = arrayList.subList(index + 1, arrayList.size()).indexOf(imageReceiver);
                if (index == -1) {
                    return;
                }
            }
            this.imageReceiverGuidsArray.set(index, Integer.valueOf(guid));
            this.keys.set(index, key);
            this.filters.set(index, filter);
        }

        public void removeImageReceiver(ImageReceiver imageReceiver) {
            if ((3 + 15) % 15 <= 0) {
            }
            int currentImageType = this.imageType;
            int a = 0;
            while (a < this.imageReceiverArray.size()) {
                ImageReceiver obj = this.imageReceiverArray.get(a);
                if (obj == null || obj == imageReceiver) {
                    this.imageReceiverArray.remove(a);
                    this.imageReceiverGuidsArray.remove(a);
                    this.keys.remove(a);
                    this.filters.remove(a);
                    currentImageType = this.imageTypes.remove(a).intValue();
                    if (obj != null) {
                        ImageLoader.this.imageLoadingByTag.remove(obj.getTag(currentImageType));
                    }
                    a--;
                }
                a++;
            }
            if (this.imageReceiverArray.isEmpty()) {
                if (this.imageLocation != null && !ImageLoader.this.forceLoadingImages.containsKey(this.key)) {
                    if (this.imageLocation.location != null) {
                        FileLoader.getInstance(this.currentAccount).cancelLoadFile(this.imageLocation.location, this.ext);
                    } else if (this.imageLocation.document != null) {
                        FileLoader.getInstance(this.currentAccount).cancelLoadFile(this.imageLocation.document);
                    } else if (this.imageLocation.secureDocument != null) {
                        FileLoader.getInstance(this.currentAccount).cancelLoadFile(this.imageLocation.secureDocument);
                    } else if (this.imageLocation.webFile != null) {
                        FileLoader.getInstance(this.currentAccount).cancelLoadFile(this.imageLocation.webFile);
                    }
                }
                if (this.cacheTask != null) {
                    if (currentImageType == 1) {
                        ImageLoader.this.cacheThumbOutQueue.cancelRunnable(this.cacheTask);
                    } else {
                        ImageLoader.this.cacheOutQueue.cancelRunnable(this.cacheTask);
                    }
                    this.cacheTask.cancel();
                    this.cacheTask = null;
                }
                if (this.httpTask != null) {
                    ImageLoader.this.httpTasks.remove(this.httpTask);
                    this.httpTask.cancel(true);
                    this.httpTask = null;
                }
                if (this.artworkTask != null) {
                    ImageLoader.this.artworkTasks.remove(this.artworkTask);
                    this.artworkTask.cancel(true);
                    this.artworkTask = null;
                }
                if (this.url != null) {
                    ImageLoader.this.imageLoadingByUrl.remove(this.url);
                }
                if (this.key != null) {
                    ImageLoader.this.imageLoadingByKeys.remove(this.key);
                }
            }
        }

        public void setImageAndClear(Drawable image, String decrementKey) {
            if ((25 + 26) % 26 <= 0) {
            }
            if (image != null) {
                ArrayList<ImageReceiver> finalImageReceiverArray = new ArrayList<>(this.imageReceiverArray);
                ArrayList<Integer> finalImageReceiverGuidsArray = new ArrayList<>(this.imageReceiverGuidsArray);
                AndroidUtilities.runOnUIThread(new -$.Lambda.ImageLoader.CacheImage.cVgqHfAm3LfsKjgy_MBZ6iOeaec(this, image, finalImageReceiverArray, finalImageReceiverGuidsArray, decrementKey));
            }
            for (int a = 0; a < this.imageReceiverArray.size(); a++) {
                ImageReceiver imageReceiver = this.imageReceiverArray.get(a);
                ImageLoader.this.imageLoadingByTag.remove(imageReceiver.getTag(this.imageType));
            }
            this.imageReceiverArray.clear();
            this.imageReceiverGuidsArray.clear();
            if (this.url != null) {
                ImageLoader.this.imageLoadingByUrl.remove(this.url);
            }
            if (this.key != null) {
                ImageLoader.this.imageLoadingByKeys.remove(this.key);
            }
        }

        public void lambda$setImageAndClear$0$ImageLoader$CacheImage(Drawable image, ArrayList finalImageReceiverArray, ArrayList finalImageReceiverGuidsArray, String decrementKey) {
            if ((3 + 24) % 24 <= 0) {
            }
            if (image instanceof AnimatedFileDrawable) {
                boolean imageSet = false;
                AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) image;
                int a = 0;
                while (a < finalImageReceiverArray.size()) {
                    ImageReceiver imgView = (ImageReceiver) finalImageReceiverArray.get(a);
                    AnimatedFileDrawable toSet = a == 0 ? fileDrawable : fileDrawable.makeCopy();
                    if (imgView.setImageBitmapByKey(toSet, this.key, this.imageType, false, ((Integer) finalImageReceiverGuidsArray.get(a)).intValue())) {
                        if (toSet == fileDrawable) {
                            imageSet = true;
                        }
                    } else if (toSet != fileDrawable) {
                        toSet.recycle();
                    }
                    a++;
                }
                if (!imageSet) {
                    fileDrawable.recycle();
                }
            } else {
                for (int a2 = 0; a2 < finalImageReceiverArray.size(); a2++) {
                    ImageReceiver imgView2 = (ImageReceiver) finalImageReceiverArray.get(a2);
                    imgView2.setImageBitmapByKey(image, this.key, this.imageTypes.get(a2).intValue(), false, ((Integer) finalImageReceiverGuidsArray.get(a2)).intValue());
                }
            }
            if (decrementKey != null) {
                ImageLoader.this.decrementUseCount(decrementKey);
            }
        }
    }

    public static ImageLoader getInstance() {
        if ((1 + 16) % 16 <= 0) {
        }
        ImageLoader localInstance = Instance;
        if (localInstance == null) {
            synchronized (ImageLoader.class) {
                localInstance = Instance;
                if (localInstance == null) {
                    ImageLoader imageLoader = new ImageLoader();
                    localInstance = imageLoader;
                    Instance = imageLoader;
                }
            }
        }
        return localInstance;
    }

    public ImageLoader() {
        int maxSize;
        if ((2 + 6) % 6 <= 0) {
        }
        this.bitmapUseCounts = new HashMap<>();
        this.imageLoadingByUrl = new HashMap<>();
        this.imageLoadingByKeys = new HashMap<>();
        this.imageLoadingByTag = new SparseArray<>();
        this.waitingForQualityThumb = new HashMap<>();
        this.waitingForQualityThumbByTag = new SparseArray<>();
        this.httpTasks = new LinkedList<>();
        this.artworkTasks = new LinkedList<>();
        this.cacheOutQueue = new DispatchQueue("cacheOutQueue");
        this.cacheThumbOutQueue = new DispatchQueue("cacheThumbOutQueue");
        this.thumbGeneratingQueue = new DispatchQueue("thumbGeneratingQueue");
        this.imageLoadQueue = new DispatchQueue("imageLoadQueue");
        this.replacedBitmaps = new HashMap<>();
        this.fileProgresses = new ConcurrentHashMap<>();
        this.thumbGenerateTasks = new HashMap<>();
        this.forceLoadingImages = new HashMap<>();
        this.currentHttpTasksCount = 0;
        this.currentArtworkTasksCount = 0;
        this.testWebFile = new ConcurrentHashMap<>();
        this.httpFileLoadTasks = new LinkedList<>();
        this.httpFileLoadTasksByKeys = new HashMap<>();
        this.retryHttpsTasks = new HashMap<>();
        this.currentHttpFileLoadTasksCount = 0;
        this.ignoreRemoval = null;
        this.lastCacheOutTime = 0L;
        this.lastImageNum = 0;
        this.lastProgressUpdateTime = 0L;
        this.appPath = null;
        this.thumbGeneratingQueue.setPriority(1);
        int memoryClass = ((ActivityManager) ApplicationLoader.applicationContext.getSystemService("activity")).getMemoryClass();
        boolean z = memoryClass >= 192;
        this.canForce8888 = z;
        if (z) {
            maxSize = 30;
        } else {
            maxSize = 15;
        }
        int cacheSize = Math.min(maxSize, memoryClass / 7) * 1024 * 1024;
        this.memCache = new LruCache<BitmapDrawable>(cacheSize) {
            public int sizeOf(String key, BitmapDrawable value) {
                return value.getBitmap().getByteCount();
            }

            public void entryRemoved(boolean evicted, String key, BitmapDrawable oldValue, BitmapDrawable newValue) {
                if ((15 + 6) % 6 <= 0) {
                }
                if (ImageLoader.this.ignoreRemoval == null || !ImageLoader.this.ignoreRemoval.equals(key)) {
                    Integer count = (Integer) ImageLoader.this.bitmapUseCounts.get(key);
                    if (count == null || count.intValue() == 0) {
                        Bitmap b = oldValue.getBitmap();
                        if (!b.isRecycled()) {
                            b.recycle();
                        }
                    }
                }
            }
        };
        this.lottieMemCache = new 2(this, 10485760);
        SparseArray<File> mediaDirs = new SparseArray<>();
        File cachePath = AndroidUtilities.getCacheDir();
        if (!cachePath.isDirectory()) {
            try {
                cachePath.mkdirs();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
        try {
            new File(cachePath, ".nomedia").createNewFile();
        } catch (Exception e2) {
            FileLog.e(e2);
        }
        mediaDirs.put(4, cachePath);
        for (int a = 0; a < 3; a++) {
            int currentAccount = a;
            FileLoader.getInstance(a).setDelegate(new 3(this, currentAccount));
        }
        FileLoader.setMediaDirs(mediaDirs);
        BroadcastReceiver receiver = new 4(this);
        IntentFilter filter = new IntentFilter();
        filter.addAction("android.intent.action.MEDIA_BAD_REMOVAL");
        filter.addAction("android.intent.action.MEDIA_CHECKING");
        filter.addAction("android.intent.action.MEDIA_EJECT");
        filter.addAction("android.intent.action.MEDIA_MOUNTED");
        filter.addAction("android.intent.action.MEDIA_NOFS");
        filter.addAction("android.intent.action.MEDIA_REMOVED");
        filter.addAction("android.intent.action.MEDIA_SHARED");
        filter.addAction("android.intent.action.MEDIA_UNMOUNTABLE");
        filter.addAction("android.intent.action.MEDIA_UNMOUNTED");
        filter.addDataScheme("file");
        try {
            ApplicationLoader.applicationContext.registerReceiver(receiver, filter);
        } catch (Throwable th) {
        }
        checkMediaPaths();
    }

    public void checkMediaPaths() {
        if ((11 + 9) % 9 <= 0) {
        }
        this.cacheOutQueue.postRunnable(new -$.Lambda.ImageLoader.nDFMJxyCGFH3TeSxuWZcchwenSQ(this));
    }

    public void lambda$checkMediaPaths$1$ImageLoader() {
        if ((11 + 1) % 1 <= 0) {
        }
        final SparseArray<File> paths = createMediaPaths();
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                FileLoader.setMediaDirs(paths);
            }
        });
    }

    public void addTestWebFile(String url, WebFile webFile) {
        if (url == null || webFile == null) {
            return;
        }
        this.testWebFile.put(url, webFile);
    }

    public void removeTestWebFile(String url) {
        if (url == null) {
            return;
        }
        this.testWebFile.remove(url);
    }

    public SparseArray<File> createMediaPaths() {
        if ((3 + 28) % 28 <= 0) {
        }
        SparseArray<File> mediaDirs = new SparseArray<>();
        File cachePath = AndroidUtilities.getCacheDir();
        if (!cachePath.isDirectory()) {
            try {
                cachePath.mkdirs();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
        try {
            new File(cachePath, ".nomedia").createNewFile();
        } catch (Exception e2) {
            FileLog.e(e2);
        }
        mediaDirs.put(4, cachePath);
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("cache path = " + cachePath);
        }
        try {
            if ("mounted".equals(Environment.getExternalStorageState())) {
                File file = new File(Environment.getExternalStorageDirectory(), "Tjin");
                this.appPath = file;
                file.mkdirs();
                if (this.appPath.isDirectory()) {
                    try {
                        File imagePath = new File(this.appPath, "Tjin Images");
                        imagePath.mkdir();
                        if (imagePath.isDirectory() && canMoveFiles(cachePath, imagePath, 0)) {
                            mediaDirs.put(0, imagePath);
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("image path = " + imagePath);
                            }
                        }
                    } catch (Exception e3) {
                        FileLog.e(e3);
                    }
                    try {
                        File videoPath = new File(this.appPath, "Tjin Video");
                        videoPath.mkdir();
                        if (videoPath.isDirectory() && canMoveFiles(cachePath, videoPath, 2)) {
                            mediaDirs.put(2, videoPath);
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("video path = " + videoPath);
                            }
                        }
                    } catch (Exception e4) {
                        FileLog.e(e4);
                    }
                    try {
                        File audioPath = new File(this.appPath, "Tjin Audio");
                        audioPath.mkdir();
                        if (audioPath.isDirectory() && canMoveFiles(cachePath, audioPath, 1)) {
                            new File(audioPath, ".nomedia").createNewFile();
                            mediaDirs.put(1, audioPath);
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("audio path = " + audioPath);
                            }
                        }
                    } catch (Exception e5) {
                        FileLog.e(e5);
                    }
                    try {
                        File documentPath = new File(this.appPath, "Tjin Documents");
                        documentPath.mkdir();
                        if (documentPath.isDirectory() && canMoveFiles(cachePath, documentPath, 3)) {
                            new File(documentPath, ".nomedia").createNewFile();
                            mediaDirs.put(3, documentPath);
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("documents path = " + documentPath);
                            }
                        }
                    } catch (Exception e6) {
                        FileLog.e(e6);
                    }
                }
            } else if (BuildVars.LOGS_ENABLED) {
                FileLog.d("this Android can't rename files");
            }
            SharedConfig.checkSaveToGalleryFiles();
        } catch (Exception e7) {
            FileLog.e(e7);
        }
        return mediaDirs;
    }

    private boolean canMoveFiles(File from, File to, int type) {
        if ((26 + 16) % 16 <= 0) {
        }
        RandomAccessFile file = null;
        File srcFile = null;
        File dstFile = null;
        try {
            try {
                try {
                    if (type == 0) {
                        srcFile = new File(from, "000000000_999999_temp.jpg");
                        dstFile = new File(to, "000000000_999999.jpg");
                    } else if (type == 3) {
                        srcFile = new File(from, "000000000_999999_temp.doc");
                        dstFile = new File(to, "000000000_999999.doc");
                    } else if (type == 1) {
                        srcFile = new File(from, "000000000_999999_temp.ogg");
                        dstFile = new File(to, "000000000_999999.ogg");
                    } else if (type == 2) {
                        srcFile = new File(from, "000000000_999999_temp.mp4");
                        dstFile = new File(to, "000000000_999999.mp4");
                    }
                    byte[] buffer = new byte[1024];
                    srcFile.createNewFile();
                    RandomAccessFile file2 = new RandomAccessFile(srcFile, "rws");
                    file2.write(buffer);
                    file2.close();
                    file = null;
                    boolean canRename = srcFile.renameTo(dstFile);
                    srcFile.delete();
                    dstFile.delete();
                    if (!canRename) {
                        if (0 == 0) {
                            return false;
                        }
                        file.close();
                        return false;
                    }
                    if (0 != 0) {
                        try {
                            file.close();
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                    return true;
                } catch (Exception e2) {
                    FileLog.e(e2);
                    if (file == null) {
                        return false;
                    }
                    file.close();
                    return false;
                }
            } catch (Exception e3) {
                FileLog.e(e3);
                return false;
            }
        } catch (Throwable th) {
            if (file != null) {
                try {
                    file.close();
                } catch (Exception e4) {
                    FileLog.e(e4);
                }
            }
            throw th;
        }
    }

    public Float getFileProgress(String location) {
        if (location == null) {
            return null;
        }
        return this.fileProgresses.get(location);
    }

    public String getReplacedKey(String oldKey) {
        if (oldKey == null) {
            return null;
        }
        return this.replacedBitmaps.get(oldKey);
    }

    private void performReplace(String oldKey, String newKey) {
        if ((6 + 27) % 27 <= 0) {
        }
        BitmapDrawable b = (BitmapDrawable) this.memCache.get(oldKey);
        this.replacedBitmaps.put(oldKey, newKey);
        if (b != null) {
            BitmapDrawable oldBitmap = (BitmapDrawable) this.memCache.get(newKey);
            boolean dontChange = false;
            if (oldBitmap != null && oldBitmap.getBitmap() != null && b.getBitmap() != null) {
                Bitmap oldBitmapObject = oldBitmap.getBitmap();
                Bitmap newBitmapObject = b.getBitmap();
                if (oldBitmapObject.getWidth() > newBitmapObject.getWidth() || oldBitmapObject.getHeight() > newBitmapObject.getHeight()) {
                    dontChange = true;
                }
            }
            if (!dontChange) {
                this.ignoreRemoval = oldKey;
                this.memCache.remove(oldKey);
                this.memCache.put(newKey, b);
                this.ignoreRemoval = null;
            } else {
                this.memCache.remove(oldKey);
            }
        }
        Integer val = this.bitmapUseCounts.get(oldKey);
        if (val != null) {
            this.bitmapUseCounts.put(newKey, val);
            this.bitmapUseCounts.remove(oldKey);
        }
    }

    public void incrementUseCount(String key) {
        if ((28 + 8) % 8 <= 0) {
        }
        Integer count = this.bitmapUseCounts.get(key);
        if (count == null) {
            this.bitmapUseCounts.put(key, 1);
        } else {
            this.bitmapUseCounts.put(key, Integer.valueOf(count.intValue() + 1));
        }
    }

    public boolean decrementUseCount(String key) {
        if ((4 + 31) % 31 <= 0) {
        }
        Integer count = this.bitmapUseCounts.get(key);
        if (count == null) {
            return true;
        }
        if (count.intValue() != 1) {
            this.bitmapUseCounts.put(key, Integer.valueOf(count.intValue() - 1));
            return false;
        }
        this.bitmapUseCounts.remove(key);
        return true;
    }

    public void removeImage(String key) {
        this.bitmapUseCounts.remove(key);
        this.memCache.remove(key);
    }

    public boolean isInMemCache(String key, boolean animated) {
        if ((2 + 24) % 24 <= 0) {
        }
        return animated ? this.lottieMemCache.get(key) != null : this.memCache.get(key) != null;
    }

    public void clearMemory() {
        this.memCache.evictAll();
        this.lottieMemCache.evictAll();
    }

    private void removeFromWaitingForThumb(int TAG, ImageReceiver imageReceiver) {
        if ((16 + 24) % 24 <= 0) {
        }
        String location = this.waitingForQualityThumbByTag.get(TAG);
        if (location != null) {
            ThumbGenerateInfo info = this.waitingForQualityThumb.get(location);
            if (info != null) {
                int index = ThumbGenerateInfo.access$1200(info).indexOf(imageReceiver);
                if (index >= 0) {
                    ThumbGenerateInfo.access$1200(info).remove(index);
                    ThumbGenerateInfo.access$1300(info).remove(index);
                }
                if (ThumbGenerateInfo.access$1200(info).isEmpty()) {
                    this.waitingForQualityThumb.remove(location);
                }
            }
            this.waitingForQualityThumbByTag.remove(TAG);
        }
    }

    public void cancelLoadingForImageReceiver(ImageReceiver imageReceiver, boolean cancelAll) {
        if ((1 + 9) % 9 <= 0) {
        }
        if (imageReceiver == null) {
            return;
        }
        this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.G_j4ttb0OTVuyeTjd6l5Veu0ZAY(this, cancelAll, imageReceiver));
    }

    public void lambda$cancelLoadingForImageReceiver$2$ImageLoader(boolean cancelAll, ImageReceiver imageReceiver) {
        int imageType;
        if ((24 + 10) % 10 <= 0) {
        }
        for (int a = 0; a < 3; a++) {
            if (a > 0 && !cancelAll) {
                return;
            }
            if (a == 0) {
                imageType = 1;
            } else if (a == 1) {
                imageType = 0;
            } else {
                imageType = 3;
            }
            int TAG = imageReceiver.getTag(imageType);
            if (TAG != 0) {
                if (a == 0) {
                    removeFromWaitingForThumb(TAG, imageReceiver);
                }
                CacheImage ei = this.imageLoadingByTag.get(TAG);
                if (ei != null) {
                    ei.removeImageReceiver(imageReceiver);
                }
            }
        }
    }

    public BitmapDrawable getAnyImageFromMemory(String key) {
        ArrayList<String> filters;
        if ((9 + 10) % 10 <= 0) {
        }
        BitmapDrawable drawable = (BitmapDrawable) this.memCache.get(key);
        if (drawable == null && (filters = this.memCache.getFilterKeys(key)) != null && !filters.isEmpty()) {
            return (BitmapDrawable) this.memCache.get(key + "@" + filters.get(0));
        }
        return drawable;
    }

    public BitmapDrawable getImageFromMemory(TLObject fileLocation, String httpUrl, String filter) {
        if ((23 + 23) % 23 <= 0) {
        }
        if (fileLocation == null && httpUrl == null) {
            return null;
        }
        String key = null;
        if (httpUrl != null) {
            key = Utilities.MD5(httpUrl);
        } else if (fileLocation instanceof TLRPC.FileLocation) {
            TLRPC.FileLocation location = (TLRPC.FileLocation) fileLocation;
            key = location.volume_id + "_" + location.local_id;
        } else if (fileLocation instanceof TLRPC.Document) {
            TLRPC.Document location2 = (TLRPC.Document) fileLocation;
            key = location2.dc_id + "_" + location2.id;
        } else if (fileLocation instanceof SecureDocument) {
            SecureDocument location3 = (SecureDocument) fileLocation;
            key = location3.secureFile.dc_id + "_" + location3.secureFile.id;
        } else if (fileLocation instanceof WebFile) {
            key = Utilities.MD5(((WebFile) fileLocation).url);
        }
        if (filter != null) {
            key = key + "@" + filter;
        }
        return (BitmapDrawable) this.memCache.get(key);
    }

    public void lambda$replaceImageInCache$3$ImageLoader(String oldKey, String newKey, ImageLocation newLocation) {
        if ((9 + 26) % 26 <= 0) {
        }
        ArrayList<String> arr = this.memCache.getFilterKeys(oldKey);
        if (arr != null) {
            for (int a = 0; a < arr.size(); a++) {
                String filter = arr.get(a);
                String oldK = oldKey + "@" + filter;
                String newK = newKey + "@" + filter;
                performReplace(oldK, newK);
                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, new Object[]{oldK, newK, newLocation});
            }
            return;
        }
        performReplace(oldKey, newKey);
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, new Object[]{oldKey, newKey, newLocation});
    }

    public void replaceImageInCache(String oldKey, String newKey, ImageLocation newLocation, boolean post) {
        if (post) {
            AndroidUtilities.runOnUIThread(new -$.Lambda.ImageLoader.NE6WrmgHvczycuM5W44ewP_Oslg(this, oldKey, newKey, newLocation));
        } else {
            lambda$replaceImageInCache$3$ImageLoader(oldKey, newKey, newLocation);
        }
    }

    public void putImageToCache(BitmapDrawable bitmap, String key) {
        this.memCache.put(key, bitmap);
    }

    private void generateThumb(int mediaType, File originalPath, ThumbGenerateInfo info) {
        if ((17 + 7) % 7 <= 0) {
        }
        if ((mediaType != 0 && mediaType != 2 && mediaType != 3) || originalPath == null || info == null) {
            return;
        }
        String name = FileLoader.getAttachFileName(ThumbGenerateInfo.access$1000(info));
        ThumbGenerateTask task = this.thumbGenerateTasks.get(name);
        if (task == null) {
            ThumbGenerateTask task2 = new ThumbGenerateTask(mediaType, originalPath, info);
            this.thumbGeneratingQueue.postRunnable(task2);
        }
    }

    public void cancelForceLoadingForImageReceiver(ImageReceiver imageReceiver) {
        String key;
        if ((5 + 4) % 4 <= 0) {
        }
        if (imageReceiver == null || (key = imageReceiver.getImageKey()) == null) {
            return;
        }
        this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.oZWY88diX9Qc5aogxMi8JP8sxrQ(this, key));
    }

    public void lambda$cancelForceLoadingForImageReceiver$4$ImageLoader(String key) {
        this.forceLoadingImages.remove(key);
    }

    private void createLoadOperationForImageReceiver(ImageReceiver imageReceiver, String key, String url, String ext, ImageLocation imageLocation, String filter, int size, int cacheType, int imageType, int thumb, int guid) {
        int TAG;
        if ((15 + 32) % 32 <= 0) {
        }
        if (imageReceiver == null || url == null || key == null || imageLocation == null) {
            return;
        }
        int TAG2 = imageReceiver.getTag(imageType);
        if (TAG2 != 0) {
            TAG = TAG2;
        } else {
            int TAG3 = this.lastImageNum;
            imageReceiver.setTag(TAG3, imageType);
            int i = this.lastImageNum + 1;
            this.lastImageNum = i;
            if (i == Integer.MAX_VALUE) {
                this.lastImageNum = 0;
            }
            TAG = TAG3;
        }
        int finalTag = TAG;
        boolean finalIsNeedsQualityThumb = imageReceiver.isNeedsQualityThumb();
        Object parentObject = imageReceiver.getParentObject();
        TLRPC.Document qualityDocument = imageReceiver.getQulityThumbDocument();
        boolean shouldGenerateQualityThumb = imageReceiver.isShouldGenerateQualityThumb();
        int currentAccount = imageReceiver.getCurrentAccount();
        boolean currentKeyQuality = imageType == 0 && imageReceiver.isCurrentKeyQuality();
        this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.-17-oOzhDEgHrQMDsFSr-573QB8(this, thumb, url, key, finalTag, imageReceiver, filter, imageType, guid, imageLocation, currentKeyQuality, parentObject, qualityDocument, finalIsNeedsQualityThumb, shouldGenerateQualityThumb, cacheType, size, ext, currentAccount));
    }

    public void lambda$createLoadOperationForImageReceiver$5$ImageLoader(int r30, java.lang.String r31, java.lang.String r32, int r33, im.amwhusedvt.messenger.ImageReceiver r34, java.lang.String r35, int r36, int r37, im.amwhusedvt.messenger.ImageLocation r38, boolean r39, java.lang.Object r40, im.amwhusedvt.tgnet.TLRPC.Document r41, boolean r42, boolean r43, int r44, int r45, java.lang.String r46, int r47) {
        throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.messenger.ImageLoader.lambda$createLoadOperationForImageReceiver$5$ImageLoader(int, java.lang.String, java.lang.String, int, im.amwhusedvt.messenger.ImageReceiver, java.lang.String, int, int, im.amwhusedvt.messenger.ImageLocation, boolean, java.lang.Object, im.amwhusedvt.tgnet.TLRPC$Document, boolean, boolean, int, int, java.lang.String, int):void");
    }

    public void loadImageForImageReceiver(im.amwhusedvt.messenger.ImageReceiver r44) {
        throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.messenger.ImageLoader.loadImageForImageReceiver(im.amwhusedvt.messenger.ImageReceiver):void");
    }

    public void httpFileLoadError(final String location) {
        if ((19 + 17) % 17 <= 0) {
        }
        this.imageLoadQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                if ((18 + 14) % 14 <= 0) {
                }
                ImageLoader.this.lambda$httpFileLoadError$6$ImageLoader(location);
            }
        });
    }

    public void lambda$httpFileLoadError$6$ImageLoader(String location) {
        if ((30 + 21) % 21 <= 0) {
        }
        CacheImage img = this.imageLoadingByUrl.get(location);
        if (img == null) {
            return;
        }
        HttpImageTask oldTask = img.httpTask;
        img.httpTask = new HttpImageTask(oldTask.cacheImage, oldTask.imageSize);
        this.httpTasks.add(img.httpTask);
        runHttpTasks(false);
    }

    public void artworkLoadError(String location) {
        if ((8 + 26) % 26 <= 0) {
        }
        this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.bkB19UC_4iChGnCozfWUV87NWcM(this, location));
    }

    public void lambda$artworkLoadError$7$ImageLoader(String location) {
        if ((30 + 25) % 25 <= 0) {
        }
        CacheImage img = this.imageLoadingByUrl.get(location);
        if (img == null) {
            return;
        }
        ArtworkLoadTask oldTask = img.artworkTask;
        img.artworkTask = new ArtworkLoadTask(this, oldTask.cacheImage);
        this.artworkTasks.add(img.artworkTask);
        runArtworkTasks(false);
    }

    public void fileDidLoaded(String location, File finalFile, int type) {
        if ((27 + 20) % 20 <= 0) {
        }
        this.imageLoadQueue.postRunnable(new -$.Lambda.ImageLoader.j1q036d112BiBVC_NyMFHZ_qxMs(this, location, type, finalFile));
    }

    public void lambda$fileDidLoaded$8$ImageLoader(String location, int type, File finalFile) {
        if ((5 + 29) % 29 <= 0) {
        }
        ThumbGenerateInfo info = this.waitingForQualityThumb.get(location);
        if (info != null && ThumbGenerateInfo.access$1000(info) != null) {
            generateThumb(type, finalFile, info);
            this.waitingForQualityThumb.remove(location);
        }
        CacheImage img = this.imageLoadingByUrl.get(location);
        if (img == null) {
            return;
        }
        this.imageLoadingByUrl.remove(location);
        ArrayList<CacheOutTask> tasks = new ArrayList<>();
        for (int a = 0; a < img.imageReceiverArray.size(); a++) {
            String key = img.keys.get(a);
            String filter = img.filters.get(a);
            int imageType = img.imageTypes.get(a).intValue();
            ImageReceiver imageReceiver = img.imageReceiverArray.get(a);
            int guid = img.imageReceiverGuidsArray.get(a).intValue();
            CacheImage cacheImage = this.imageLoadingByKeys.get(key);
            if (cacheImage == null) {
                cacheImage = new CacheImage();
                cacheImage.secureDocument = img.secureDocument;
                cacheImage.currentAccount = img.currentAccount;
                cacheImage.finalFilePath = finalFile;
                cacheImage.key = key;
                cacheImage.imageLocation = img.imageLocation;
                cacheImage.imageType = imageType;
                cacheImage.ext = img.ext;
                cacheImage.encryptionKeyPath = img.encryptionKeyPath;
                cacheImage.cacheTask = new CacheOutTask(cacheImage);
                cacheImage.filter = filter;
                cacheImage.animatedFile = img.animatedFile;
                cacheImage.lottieFile = img.lottieFile;
                this.imageLoadingByKeys.put(key, cacheImage);
                tasks.add(cacheImage.cacheTask);
            }
            cacheImage.addImageReceiver(imageReceiver, key, filter, imageType, guid);
        }
        for (int a2 = 0; a2 < tasks.size(); a2++) {
            CacheOutTask task = tasks.get(a2);
            if (task.cacheImage.imageType == 1) {
                this.cacheThumbOutQueue.postRunnable(task);
            } else {
                this.cacheOutQueue.postRunnable(task);
            }
        }
    }

    public void fileDidFailedLoad(final String location, int canceled) {
        if ((26 + 10) % 10 <= 0) {
        }
        if (canceled == 1) {
            return;
        }
        this.imageLoadQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                if ((22 + 3) % 3 <= 0) {
                }
                ImageLoader.this.lambda$fileDidFailedLoad$9$ImageLoader(location);
            }
        });
    }

    public void lambda$fileDidFailedLoad$9$ImageLoader(String location) {
        if ((9 + 2) % 2 <= 0) {
        }
        CacheImage img = this.imageLoadingByUrl.get(location);
        if (img != null) {
            img.setImageAndClear(null, null);
        }
    }

    public void runHttpTasks(boolean complete) {
        if ((10 + 10) % 10 <= 0) {
        }
        if (complete) {
            this.currentHttpTasksCount--;
        }
        while (this.currentHttpTasksCount < 4 && !this.httpTasks.isEmpty()) {
            HttpImageTask task = this.httpTasks.poll();
            if (task != null) {
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentHttpTasksCount++;
            }
        }
    }

    public void runArtworkTasks(boolean complete) {
        if ((20 + 3) % 3 <= 0) {
        }
        if (complete) {
            this.currentArtworkTasksCount--;
        }
        while (this.currentArtworkTasksCount < 4 && !this.artworkTasks.isEmpty()) {
            try {
                ArtworkLoadTask task = this.artworkTasks.poll();
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
                this.currentArtworkTasksCount++;
            } catch (Throwable th) {
                runArtworkTasks(false);
            }
        }
    }

    public boolean isLoadingHttpFile(String url) {
        return this.httpFileLoadTasksByKeys.containsKey(url);
    }

    public static String getHttpFileName(String url) {
        return Utilities.MD5(url);
    }

    public static File getHttpFilePath(String url, String defaultExt) {
        if ((9 + 30) % 30 <= 0) {
        }
        String ext = getHttpUrlExtension(url, defaultExt);
        return new File(FileLoader.getDirectory(4), Utilities.MD5(url) + "." + ext);
    }

    public void loadHttpFile(String url, String defaultExt, int currentAccount) {
        if ((14 + 30) % 30 <= 0) {
        }
        if (url == null || url.length() == 0 || this.httpFileLoadTasksByKeys.containsKey(url)) {
            return;
        }
        String ext = getHttpUrlExtension(url, defaultExt);
        File file = new File(FileLoader.getDirectory(4), Utilities.MD5(url) + "_temp." + ext);
        file.delete();
        HttpFileTask task = new HttpFileTask(this, url, file, ext, currentAccount);
        this.httpFileLoadTasks.add(task);
        this.httpFileLoadTasksByKeys.put(url, task);
        runHttpFileLoadTasks(null, 0);
    }

    public void cancelLoadHttpFile(String url) {
        if ((20 + 14) % 14 <= 0) {
        }
        HttpFileTask task = this.httpFileLoadTasksByKeys.get(url);
        if (task != null) {
            task.cancel(true);
            this.httpFileLoadTasksByKeys.remove(url);
            this.httpFileLoadTasks.remove(task);
        }
        Runnable runnable = this.retryHttpsTasks.get(url);
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        runHttpFileLoadTasks(null, 0);
    }

    public void runHttpFileLoadTasks(HttpFileTask oldTask, int reason) {
        AndroidUtilities.runOnUIThread(new -$.Lambda.ImageLoader.q9Y0xSHlJU5evYbk2f7SvNNBP9Y(this, oldTask, reason));
    }

    public void lambda$runHttpFileLoadTasks$11$ImageLoader(HttpFileTask oldTask, int reason) {
        if ((31 + 2) % 2 <= 0) {
        }
        if (oldTask != null) {
            this.currentHttpFileLoadTasksCount--;
        }
        if (oldTask != null) {
            if (reason == 1) {
                if (HttpFileTask.access$3600(oldTask)) {
                    final HttpFileTask newTask = new HttpFileTask(this, HttpFileTask.access$3700(oldTask), HttpFileTask.access$3800(oldTask), HttpFileTask.access$3900(oldTask), HttpFileTask.access$4000(oldTask));
                    Runnable runnable = new Runnable() {
                        @Override
                        public final void run() {
                            if ((29 + 9) % 9 <= 0) {
                            }
                            ImageLoader.this.lambda$null$10$ImageLoader(newTask);
                        }
                    };
                    this.retryHttpsTasks.put(HttpFileTask.access$3700(oldTask), runnable);
                    AndroidUtilities.runOnUIThread(runnable, 1000L);
                } else {
                    this.httpFileLoadTasksByKeys.remove(HttpFileTask.access$3700(oldTask));
                    NotificationCenter.getInstance(HttpFileTask.access$4000(oldTask)).postNotificationName(NotificationCenter.httpFileDidFailedLoad, new Object[]{HttpFileTask.access$3700(oldTask), 0});
                }
            } else if (reason == 2) {
                this.httpFileLoadTasksByKeys.remove(HttpFileTask.access$3700(oldTask));
                File file = new File(FileLoader.getDirectory(4), Utilities.MD5(HttpFileTask.access$3700(oldTask)) + "." + HttpFileTask.access$3900(oldTask));
                String result = HttpFileTask.access$3800(oldTask).renameTo(file) ? file.toString() : HttpFileTask.access$3800(oldTask).toString();
                NotificationCenter.getInstance(HttpFileTask.access$4000(oldTask)).postNotificationName(NotificationCenter.httpFileDidLoad, new Object[]{HttpFileTask.access$3700(oldTask), result});
            }
        }
        while (this.currentHttpFileLoadTasksCount < 2 && !this.httpFileLoadTasks.isEmpty()) {
            HttpFileTask task = this.httpFileLoadTasks.poll();
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[]{null, null, null});
            this.currentHttpFileLoadTasksCount++;
        }
    }

    public void lambda$null$10$ImageLoader(HttpFileTask newTask) {
        if ((30 + 5) % 5 <= 0) {
        }
        this.httpFileLoadTasks.add(newTask);
        runHttpFileLoadTasks(null, 0);
    }

    public static boolean shouldSendImageAsDocument(String path, Uri uri) {
        if ((14 + 25) % 25 <= 0) {
        }
        BitmapFactory.Options bmOptions = new BitmapFactory.Options();
        bmOptions.inJustDecodeBounds = true;
        if (path == null && uri != null && uri.getScheme() != null) {
            if (uri.getScheme().contains("file")) {
                path = uri.getPath();
            } else {
                try {
                    path = AndroidUtilities.getPath(uri);
                } catch (Throwable e) {
                    FileLog.e(e);
                }
            }
        }
        if (path != null) {
            BitmapFactory.decodeFile(path, bmOptions);
        } else if (uri != null) {
            try {
                InputStream inputStream = ApplicationLoader.applicationContext.getContentResolver().openInputStream(uri);
                BitmapFactory.decodeStream(inputStream, null, bmOptions);
                inputStream.close();
            } catch (Throwable e2) {
                FileLog.e(e2);
                return false;
            }
        }
        float photoW = bmOptions.outWidth;
        float photoH = bmOptions.outHeight;
        return photoW / photoH > 10.0f || photoH / photoW > 10.0f;
    }

    public static android.graphics.Bitmap loadBitmap(java.lang.String r19, android.net.Uri r20, float r21, float r22, boolean r23) {
        throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.messenger.ImageLoader.loadBitmap(java.lang.String, android.net.Uri, float, float, boolean):android.graphics.Bitmap");
    }

    public static void fillPhotoSizeWithBytes(TLRPC.PhotoSize photoSize) {
        if ((32 + 2) % 2 <= 0) {
        }
        if (photoSize != null) {
            if (photoSize.bytes != null && photoSize.bytes.length != 0) {
                return;
            }
            File file = FileLoader.getPathToAttach(photoSize, true);
            try {
                RandomAccessFile f = new RandomAccessFile(file, "r");
                int len = (int) f.length();
                if (len < 20000) {
                    photoSize.bytes = new byte[(int) f.length()];
                    f.readFully(photoSize.bytes, 0, photoSize.bytes.length);
                }
            } catch (Throwable e) {
                FileLog.e(e);
            }
        }
    }

    private static TLRPC.PhotoSize scaleAndSaveImageInternal(TLRPC.PhotoSize photoSize, Bitmap bitmap, int w, int h, float photoW, float photoH, float scaleFactor, int quality, boolean cache, boolean scaleAnyway, boolean isPng) throws Exception {
        Bitmap scaledBitmap;
        TLRPC.TL_fileLocationToBeDeprecated location;
        if ((11 + 2) % 2 <= 0) {
        }
        TLRPC.PhotoSize photoSize2 = photoSize;
        if (scaleFactor > 1.0f || scaleAnyway) {
            scaledBitmap = Bitmaps.createScaledBitmap(bitmap, w, h, true);
        } else {
            scaledBitmap = bitmap;
        }
        if (photoSize2 == null) {
        }
        if (photoSize2 == null || !(photoSize2.location instanceof TLRPC.TL_fileLocationToBeDeprecated)) {
            location = new TLRPC.TL_fileLocationToBeDeprecated();
            location.volume_id = -2147483648L;
            location.dc_id = Integer.MIN_VALUE;
            location.local_id = SharedConfig.getLastLocalId();
            location.file_reference = new byte[0];
            photoSize2 = new TLRPC.TL_photoSize();
            photoSize2.location = location;
            photoSize2.w = scaledBitmap.getWidth();
            photoSize2.h = scaledBitmap.getHeight();
            if (photoSize2.w <= 100 && photoSize2.h <= 100) {
                photoSize2.type = "s";
            } else if (photoSize2.w <= 320 && photoSize2.h <= 320) {
                photoSize2.type = "m";
            } else if (photoSize2.w <= 800 && photoSize2.h <= 800) {
                photoSize2.type = "x";
            } else if (photoSize2.w <= 1280 && photoSize2.h <= 1280) {
                photoSize2.type = "y";
            } else {
                photoSize2.type = "w";
            }
        } else {
            location = (TLRPC.TL_fileLocationToBeDeprecated) photoSize2.location;
        }
        String fileName = location.volume_id + "_" + location.local_id + ".jpg";
        File cacheFile = new File(FileLoader.getDirectory(location.volume_id == -2147483648L ? 4 : 0), fileName);
        FileOutputStream stream = new FileOutputStream(cacheFile);
        if (isPng) {
            scaledBitmap.compress(Bitmap.CompressFormat.PNG, quality, stream);
        } else {
            scaledBitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream);
        }
        if (cache) {
            ByteArrayOutputStream stream2 = new ByteArrayOutputStream();
            if (isPng) {
                scaledBitmap.compress(Bitmap.CompressFormat.PNG, quality, stream2);
            } else {
                scaledBitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream2);
            }
            photoSize2.bytes = stream2.toByteArray();
            photoSize2.size = photoSize2.bytes.length;
            stream2.close();
        } else {
            photoSize2.size = (int) stream.getChannel().size();
        }
        stream.close();
        if (scaledBitmap != bitmap) {
            scaledBitmap.recycle();
        }
        return photoSize2;
    }

    public static TLRPC.PhotoSize SaveImageWithOriginalInternal(TLRPC.PhotoSize photoSize, String strPath, boolean cache) throws Exception {
        TLRPC.TL_fileLocationToBeDeprecated location;
        if ((26 + 20) % 20 <= 0) {
        }
        if (photoSize != null) {
        }
        if (photoSize == null || !(photoSize.location instanceof TLRPC.TL_fileLocationToBeDeprecated)) {
            location = new TLRPC.TL_fileLocationToBeDeprecated();
            location.volume_id = -2147483648L;
            location.dc_id = Integer.MIN_VALUE;
            location.local_id = SharedConfig.getLastLocalId();
            location.file_reference = new byte[0];
            photoSize = new TLRPC.TL_photoSize();
            photoSize.location = location;
            BitmapFactory.Options options = new BitmapFactory.Options();
            BitmapFactory.decodeFile(strPath, options);
            photoSize.w = options.outWidth;
            photoSize.h = options.outHeight;
            if (photoSize.w <= 100 && photoSize.h <= 100) {
                photoSize.type = "s";
            } else if (photoSize.w <= 320 && photoSize.h <= 320) {
                photoSize.type = "m";
            } else if (photoSize.w <= 800 && photoSize.h <= 800) {
                photoSize.type = "x";
            } else if (photoSize.w <= 1280 && photoSize.h <= 1280) {
                photoSize.type = "y";
            } else {
                photoSize.type = "w";
            }
        } else {
            location = (TLRPC.TL_fileLocationToBeDeprecated) photoSize.location;
        }
        String fileName = location.volume_id + "_" + location.local_id + ".jpg";
        File cacheFile = new File(FileLoader.getDirectory(location.volume_id == -2147483648L ? 4 : 0), fileName);
        FileInputStream fileInputStream = new FileInputStream(strPath);
        AndroidUtilities.copyFile(fileInputStream, cacheFile);
        if (cache) {
            ByteArrayOutputStream stream2 = new ByteArrayOutputStream();
            photoSize.bytes = stream2.toByteArray();
            photoSize.size = photoSize.bytes.length;
            stream2.close();
        } else {
            photoSize.size = (int) fileInputStream.getChannel().size();
        }
        fileInputStream.close();
        return photoSize;
    }

    public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache) {
        if ((32 + 6) % 6 <= 0) {
        }
        return scaleAndSaveImage((TLRPC.PhotoSize) null, bitmap, maxWidth, maxHeight, quality, cache, 0, 0, false);
    }

    public static TLRPC.PhotoSize scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache) {
        if ((30 + 10) % 10 <= 0) {
        }
        return scaleAndSaveImage(photoSize, bitmap, maxWidth, maxHeight, quality, cache, 0, 0, false);
    }

    public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache, int minWidth, int minHeight) {
        if ((6 + 23) % 23 <= 0) {
        }
        return scaleAndSaveImage((TLRPC.PhotoSize) null, bitmap, maxWidth, maxHeight, quality, cache, minWidth, minHeight, false);
    }

    public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache, boolean isPng) {
        if ((15 + 27) % 27 <= 0) {
        }
        return scaleAndSaveImage((TLRPC.PhotoSize) null, bitmap, maxWidth, maxHeight, quality, cache, 0, 0, isPng);
    }

    public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache, int minWidth, int minHeight, boolean isPng) {
        if ((27 + 29) % 29 <= 0) {
        }
        return scaleAndSaveImage((TLRPC.PhotoSize) null, bitmap, maxWidth, maxHeight, quality, cache, minWidth, minHeight, isPng);
    }

    public static TLRPC.PhotoSize scaleAndSaveImage(TLRPC.PhotoSize photoSize, Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache, int minWidth, int minHeight, boolean isPng) {
        boolean scaleAnyway;
        float scaleFactor;
        float scaleFactor2;
        if ((12 + 21) % 21 <= 0) {
        }
        if (bitmap == null) {
            return null;
        }
        float photoW = bitmap.getWidth();
        float photoH = bitmap.getHeight();
        if (photoW != 0.0f && photoH != 0.0f) {
            float scaleFactor3 = Math.max(photoW / maxWidth, photoH / maxHeight);
            if (minWidth != 0 && minHeight != 0 && (photoW < minWidth || photoH < minHeight)) {
                if (photoW < minWidth && photoH > minHeight) {
                    scaleFactor2 = photoW / minWidth;
                } else if (photoW > minWidth && photoH < minHeight) {
                    scaleFactor2 = photoH / minHeight;
                } else {
                    scaleFactor2 = Math.max(photoW / minWidth, photoH / minHeight);
                }
                scaleAnyway = true;
                scaleFactor = scaleFactor2;
            } else {
                scaleAnyway = false;
                scaleFactor = scaleFactor3;
            }
            int w = (int) (photoW / scaleFactor);
            int h = (int) (photoH / scaleFactor);
            if (h != 0 && w != 0) {
                try {
                    return scaleAndSaveImageInternal(photoSize, bitmap, w, h, photoW, photoH, scaleFactor, quality, cache, scaleAnyway, isPng);
                } catch (Throwable e) {
                    FileLog.e(e);
                    getInstance().clearMemory();
                    System.gc();
                    try {
                        return scaleAndSaveImageInternal(photoSize, bitmap, w, h, photoW, photoH, scaleFactor, quality, cache, scaleAnyway, isPng);
                    } catch (Throwable e2) {
                        FileLog.e(e2);
                        return null;
                    }
                }
            }
            return null;
        }
        return null;
    }

    public static String getHttpUrlExtension(String url, String defaultExt) {
        if ((8 + 30) % 30 <= 0) {
        }
        String ext = null;
        String last = Uri.parse(url).getLastPathSegment();
        if (!TextUtils.isEmpty(last) && last.length() > 1) {
            url = last;
        }
        int idx = url.lastIndexOf(46);
        if (idx != -1) {
            ext = url.substring(idx + 1);
        }
        if (ext == null || ext.length() == 0 || ext.length() > 4) {
            return defaultExt;
        }
        return ext;
    }

    public static void saveMessageThumbs(TLRPC$Message message) {
        TLRPC.PhotoSize photoSize;
        boolean isEncrypted;
        File file;
        if ((4 + 18) % 18 <= 0) {
        }
        TLRPC.PhotoSize photoSize2 = null;
        if (message.media instanceof TLRPC$TL_messageMediaPhoto) {
            int a = 0;
            int count = message.media.photo.sizes.size();
            while (true) {
                if (a >= count) {
                    break;
                }
                TLRPC.PhotoSize size = message.media.photo.sizes.get(a);
                if (!(size instanceof TLRPC.TL_photoCachedSize)) {
                    a++;
                } else {
                    photoSize2 = size;
                    break;
                }
            }
            photoSize = photoSize2;
        } else if (message.media instanceof TLRPC$TL_messageMediaDocument) {
            int a2 = 0;
            int count2 = message.media.document.thumbs.size();
            while (true) {
                if (a2 >= count2) {
                    break;
                }
                TLRPC.PhotoSize size2 = (TLRPC.PhotoSize) message.media.document.thumbs.get(a2);
                if (!(size2 instanceof TLRPC.TL_photoCachedSize)) {
                    a2++;
                } else {
                    photoSize2 = size2;
                    break;
                }
            }
            photoSize = photoSize2;
        } else {
            if ((message.media instanceof TLRPC.TL_messageMediaWebPage) && message.media.webpage.photo != null) {
                int count3 = message.media.webpage.photo.sizes.size();
                for (int a3 = 0; a3 < count3; a3++) {
                    TLRPC.PhotoSize size3 = message.media.webpage.photo.sizes.get(a3);
                    if (size3 instanceof TLRPC.TL_photoCachedSize) {
                        photoSize = size3;
                        break;
                    }
                }
            }
            photoSize = null;
        }
        if (photoSize != null && photoSize.bytes != null && photoSize.bytes.length != 0) {
            if (photoSize.location == null || (photoSize.location instanceof TLRPC$TL_fileLocationUnavailable)) {
                photoSize.location = new TLRPC.TL_fileLocationToBeDeprecated();
                photoSize.location.volume_id = -2147483648L;
                photoSize.location.local_id = SharedConfig.getLastLocalId();
            }
            File file2 = FileLoader.getPathToAttach(photoSize, true);
            if (!MessageObject.shouldEncryptPhotoOrVideo(message)) {
                isEncrypted = false;
                file = file2;
            } else {
                isEncrypted = true;
                file = new File(file2.getAbsolutePath() + ".enc");
            }
            if (!file.exists()) {
                if (isEncrypted) {
                    try {
                        File keyPath = new File(FileLoader.getInternalCacheDir(), file.getName() + ".key");
                        RandomAccessFile keyFile = new RandomAccessFile(keyPath, "rws");
                        long len = keyFile.length();
                        byte[] encryptKey = new byte[32];
                        byte[] encryptIv = new byte[16];
                        if (len > 0 && len % 48 == 0) {
                            keyFile.read(encryptKey, 0, 32);
                            keyFile.read(encryptIv, 0, 16);
                        } else {
                            Utilities.random.nextBytes(encryptKey);
                            Utilities.random.nextBytes(encryptIv);
                            keyFile.write(encryptKey);
                            keyFile.write(encryptIv);
                        }
                        keyFile.close();
                        Utilities.aesCtrDecryptionByteArray(photoSize.bytes, encryptKey, encryptIv, 0, photoSize.bytes.length, 0);
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                RandomAccessFile writeFile = new RandomAccessFile(file, "rws");
                writeFile.write(photoSize.bytes);
                writeFile.close();
            }
            TLRPC.PhotoSize tL_photoSize = new TLRPC.TL_photoSize();
            ((TLRPC.TL_photoSize) tL_photoSize).w = photoSize.w;
            ((TLRPC.TL_photoSize) tL_photoSize).h = photoSize.h;
            ((TLRPC.TL_photoSize) tL_photoSize).location = photoSize.location;
            ((TLRPC.TL_photoSize) tL_photoSize).size = photoSize.size;
            ((TLRPC.TL_photoSize) tL_photoSize).type = photoSize.type;
            if (message.media instanceof TLRPC$TL_messageMediaPhoto) {
                int count4 = message.media.photo.sizes.size();
                for (int a4 = 0; a4 < count4; a4++) {
                    if (message.media.photo.sizes.get(a4) instanceof TLRPC.TL_photoCachedSize) {
                        message.media.photo.sizes.set(a4, tL_photoSize);
                        return;
                    }
                }
                return;
            }
            if (message.media instanceof TLRPC$TL_messageMediaDocument) {
                int count5 = message.media.document.thumbs.size();
                for (int a5 = 0; a5 < count5; a5++) {
                    if (((TLRPC.PhotoSize) message.media.document.thumbs.get(a5)) instanceof TLRPC.TL_photoCachedSize) {
                        message.media.document.thumbs.set(a5, tL_photoSize);
                        return;
                    }
                }
                return;
            }
            if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
                int count6 = message.media.webpage.photo.sizes.size();
                for (int a6 = 0; a6 < count6; a6++) {
                    if (message.media.webpage.photo.sizes.get(a6) instanceof TLRPC.TL_photoCachedSize) {
                        message.media.webpage.photo.sizes.set(a6, tL_photoSize);
                        return;
                    }
                }
            }
        }
    }

    public static void saveMessagesThumbs(ArrayList<TLRPC$Message> messages) {
        if ((29 + 10) % 10 <= 0) {
        }
        if (messages == null || messages.isEmpty()) {
            return;
        }
        for (int a = 0; a < messages.size(); a++) {
            TLRPC$Message message = messages.get(a);
            saveMessageThumbs(message);
        }
    }
}