package com.bytedance.sdk.openadsdk.component.vc;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
/* loaded from: classes2.dex */
public class Sg implements Handler.Callback {
    private boolean DSW;
    private final com.bytedance.sdk.openadsdk.component.qsH.YFl Sg;
    private YFl tN;
    private Handler YFl = new Handler(Looper.myLooper(), this);
    private int AlY = 0;
    private int wN = 5;
    private int vc = 0;

    public void Sg(int i) {
        this.vc = i;
    }

    public int YFl() {
        return this.vc;
    }

    public void YFl(float f) {
        int i = (int) f;
        this.wN = i;
        if (i <= 0) {
            this.wN = 5;
        }
    }

    public void YFl(YFl yFl) {
        this.tN = yFl;
    }

    public Sg(com.bytedance.sdk.openadsdk.component.qsH.YFl yFl) {
        this.Sg = yFl;
    }

    public void YFl(int i) {
        this.AlY = i;
        int i2 = this.wN - i;
        this.Sg.YFl(i2);
        if (i <= 0) {
            YFl yFl = this.tN;
            if (yFl != null && !this.DSW) {
                yFl.Sg();
                this.DSW = true;
            }
            i = 0;
        }
        boolean z = i2 >= this.vc;
        YFl yFl2 = this.tN;
        if (yFl2 != null) {
            yFl2.YFl(i, i2, z);
        }
    }

    public void Sg() {
        Handler handler = this.YFl;
        if (handler != null) {
            handler.sendMessage(handler.obtainMessage(100, this.wN, 0));
        }
    }

    public void tN() {
        if (this.YFl != null) {
            Message obtain = Message.obtain();
            obtain.what = 100;
            obtain.arg1 = this.AlY;
            this.YFl.sendMessage(obtain);
        }
    }

    public void AlY() {
        Handler handler = this.YFl;
        if (handler != null) {
            handler.removeMessages(100);
        }
    }

    public void wN() {
        this.YFl.removeCallbacksAndMessages(null);
        this.YFl = null;
    }

    @Override // android.os.Handler.Callback
    public boolean handleMessage(Message message) {
        if (message.what == 100 && this.YFl != null) {
            int i = message.arg1;
            YFl(i);
            if (i > 0) {
                Message obtain = Message.obtain();
                obtain.what = 100;
                obtain.arg1 = i - 1;
                this.YFl.sendMessageDelayed(obtain, 1000L);
            }
        }
        return true;
    }
}
