package com.tencent.mm.plugin.appbrand.dynamic.d.b.a;

import android.text.TextUtils;
import com.tencent.mm.modelappbrand.u;
import com.tencent.mm.plugin.appbrand.canvas.action.arg.a.d;
import com.tencent.mm.plugin.appbrand.canvas.widget.DrawCanvasArg;
import com.tencent.mm.plugin.appbrand.dynamic.d.b.b;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.ytcommon.BuildConfig;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.json.JSONObject;

public abstract class a implements e<DrawCanvasArg> {
    protected DrawCanvasArg hnN;
    protected String hnO;
    protected BlockingQueue<b> hnP = new LinkedBlockingQueue(100);
    protected BlockingQueue<Runnable> hnQ = new LinkedBlockingQueue(100);
    protected volatile long hnR;
    protected volatile long hnS;
    protected int hnT;
    protected int hnU;
    protected boolean hnV;
    protected Thread workerThread = new Thread(new 1(this), "DrawCanvasMgr-worker");

    public final /* bridge */ /* synthetic */ void bs(Object obj) {
        String str;
        this.hnN = (DrawCanvasArg) obj;
        if (this.hnN != null) {
            str = this.hnN.hdV;
        } else {
            str = null;
        }
        this.hnO = str;
    }

    public a() {
        this.workerThread.start();
    }

    public final void a(b bVar) {
        try {
            this.hnP.put(bVar);
            this.hnS = bVar.hnC;
            this.hnU++;
        } catch (InterruptedException e) {
            ab.printErrStackTrace("BaseDrawCanvasWithObj", e, BuildConfig.FLAVOR, new Object[0]);
        }
    }

    public final boolean Ai(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        if (this.hnO == null || this.hnO.hashCode() != str.hashCode()) {
            return true;
        }
        return false;
    }

    /* renamed from: c */
    public DrawCanvasArg d(JSONObject jSONObject, String str) {
        DrawCanvasArg drawCanvasArg = (DrawCanvasArg) d.ayk().hdz.aA();
        if (drawCanvasArg == null) {
            drawCanvasArg = new DrawCanvasArg();
        }
        drawCanvasArg.hdU = jSONObject.optBoolean("reserve");
        drawCanvasArg.hdV = str;
        drawCanvasArg.hdW = jSONObject.optLong("__invoke_jsapi_timestamp");
        return drawCanvasArg;
    }

    public final void reset() {
        this.hnO = null;
        u.i("BaseDrawCanvasWithObj", "drop frame %d times, allFrame %d ", new Object[]{Integer.valueOf(this.hnT), Integer.valueOf(this.hnU)});
        this.hnU = 0;
        this.hnT = 0;
        this.hnR = 0;
        this.workerThread.interrupt();
        Runnable runnable = (Runnable) this.hnQ.poll();
        while (runnable != null) {
            if (runnable != null) {
                runnable.run();
            }
            runnable = (Runnable) this.hnQ.poll();
        }
        this.hnQ.clear();
        this.hnP.clear();
        if (this.hnN != null) {
            this.hnN.reset();
            this.hnN = null;
        }
    }

    public final void F(Runnable runnable) {
        try {
            this.hnQ.put(runnable);
        } catch (InterruptedException e) {
            ab.printErrStackTrace("BaseDrawCanvasWithObj", e, BuildConfig.FLAVOR, new Object[0]);
        }
    }

    public final void azU() {
        this.hnV = true;
    }
}
