package com.ss.android.ugc.aweme.shortvideo.util;

import X.0CB;
import X.0CH;
import X.0CN;
import X.6Is;
import X.C4836O8h;
import X.C4837O8i;
import X.C4883OAc;
import X.Pah;
import X.QCf;
import X.QCi;
import X.QDI;
import X.QEG;
import X.QEL;
import X.QIr;
import com.bytedance.covode.number.Covode;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class VideoCoverCacheImpl implements 6Is, C4836O8h {
    public String LIZ;
    public boolean LIZIZ = true;
    public Map<Integer, C4837O8i> LIZJ = new ConcurrentHashMap();
    public int LIZLLL;
    public int LJ;
    public Executor LJFF;

    static {
        Covode.recordClassIndex(113522);
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public void onDestroy() {
        this.LIZIZ = true;
    }

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    public final void LIZ(int i, C4837O8i o8i) {
        Pah LIZ2 = QEL.LIZIZ().LJ().LIZ(new QDI("file://".concat(String.valueOf(this.LIZ + i)), (QCi) null, QCf.LIZIZ, QIr.LIZ, (QEG) null, (String) null, (Object) null));
        if (LIZ2 != null) {
            o8i.LIZ(LIZ2.LIZIZ());
            Pah.LIZJ(LIZ2);
            return;
        }
        this.LIZJ.put(Integer.valueOf(i), o8i);
    }

    public VideoCoverCacheImpl(0CH r15, String str, int i, int i2, int i3, float f) {
        String str2 = str;
        this.LIZ = str2;
        int i4 = i;
        this.LIZLLL = i4;
        int i5 = i2;
        this.LJ = i5;
        r15.getLifecycle().LIZ(this);
        float f2 = 1000.0f * f;
        if (f2 > 0.0f) {
            int i6 = (int) (((float) i3) / f2);
            int[] iArr = new int[i6];
            for (int i7 = 0; i7 < i6; i7++) {
                iArr[i7] = (int) (((float) i7) * f2);
            }
            ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 4, 30, TimeUnit.SECONDS, new LinkedBlockingQueue(), new ThreadPoolExecutor.DiscardOldestPolicy());
            this.LJFF = threadPoolExecutor;
            threadPoolExecutor.execute(new C4883OAc(this, str2, iArr, i4, i5));
        }
    }
}
