package com.ss.android.ugc.aweme.influencer.ecommercelive.bridgemethods;

import X.0CB;
import X.0CH;
import X.3i8;
import X.6Is;
import X.C0865KKi;
import X.C1022KQj;
import X.C3362LIj;
import X.FIu;
import X.M12;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.fe.base.BaseCommonJavaMethod;
import com.ss.android.ugc.aweme.out.AVExternalServiceImpl;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class OpenSchemaSingleTaskMethodCrossPlatform extends BaseCommonJavaMethod implements 6Is {
    public static final C3362LIj LIZ = new C3362LIj((byte) 0);

    static {
        Covode.recordClassIndex(88289);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public OpenSchemaSingleTaskMethodCrossPlatform(C0865KKi kKi) {
        super(kKi);
    }

    public final void handle(JSONObject jSONObject, FIu fIu) {
        M12.LIZ((Object) jSONObject, (Object) fIu);
        String optString = jSONObject.optString("schema");
        String optString2 = jSONObject.optString("page");
        int optInt = jSONObject.optInt("is_back");
        boolean z = false;
        if (n.LIZ(optString2, "AWEVideoNewPublishViewController")) {
            Class videoPublishActivityClass = AVExternalServiceImpl.LIZ().classnameService().getVideoPublishActivityClass();
            Activity[] activityStack = ActivityStack.getActivityStack();
            n.LIZIZ(activityStack, "");
            int length = activityStack.length;
            int i = 0;
            while (i < length) {
                if (n.LIZ(activityStack[i].getClass().getName(), videoPublishActivityClass.getName())) {
                    Intent intent = new Intent(getActContext(), videoPublishActivityClass);
                    intent.addFlags(67108864);
                    intent.addFlags(268435456);
                    Context actContext = getActContext();
                    3i8.LIZ(intent, actContext);
                    actContext.startActivity(intent);
                } else {
                    i++;
                }
            }
            fIu.LIZ(0, "No video publish activity in stack");
            return;
        }
        SmartRoute buildRoute = SmartRouter.buildRoute(getActContext(), "//bullet/single_task?intercept_page=show_window");
        Intent buildIntent = buildRoute.buildIntent();
        if (optInt == 1) {
            z = true;
        }
        buildIntent.putExtra("is_clear_top", z);
        buildRoute.withParam(buildIntent);
        n.LIZIZ(optString, "");
        buildRoute.withParam(C1022KQj.LIZ(optString));
        buildRoute.addFlags(67108864);
        buildRoute.addFlags(268435456);
        buildRoute.open();
        fIu.LIZ(new JSONObject());
    }
}
