package com.ss.android.ugc.effectmanager.common.task;

import X.2Pr;
import X.Ls2;
import X.M12;
import android.os.Handler;
import com.bytedance.covode.number.Covode;

public abstract class NewNormalTask<T> implements NewITask<T> {
    public IEffectPlatformBaseListener<T> baseListener;
    public final Handler handler;
    public boolean isCanceled;
    public String taskId;

    static {
        Covode.recordClassIndex(125301);
    }

    public abstract void execute();

    public abstract void onCancel();

    public final IEffectPlatformBaseListener<T> getBaseListener() {
        return this.baseListener;
    }

    public final Handler getHandler() {
        return this.handler;
    }

    public String getId() {
        return this.taskId;
    }

    public final boolean isCanceled() {
        return this.isCanceled;
    }

    public void cancel() {
        this.isCanceled = true;
        runInHandler(new NewNormalTask$cancel$1(this));
    }

    public final void setBaseListener(IEffectPlatformBaseListener<T> iEffectPlatformBaseListener) {
        this.baseListener = iEffectPlatformBaseListener;
    }

    public final void setCanceled(boolean z) {
        this.isCanceled = z;
    }

    public void execute(IEffectPlatformBaseListener<T> iEffectPlatformBaseListener) {
        if (!this.isCanceled) {
            this.baseListener = iEffectPlatformBaseListener;
            execute();
        }
    }

    public final void runInHandler(Ls2<2Pr> ls2) {
        M12.LIZ(ls2);
        Handler handler2 = this.handler;
        if (handler2 != null) {
            handler2.post(new NewNormalTask$sam$java_lang_Runnable$0(ls2));
        } else {
            ls2.invoke();
        }
    }

    public NewNormalTask(Handler handler2, String str) {
        M12.LIZ(str);
        this.handler = handler2;
        this.taskId = str;
    }
}
