package com.tencent.mm.plugin.webview.ui.tools;

import android.os.Bundle;
import android.util.SparseBooleanArray;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import java.util.ArrayList;
import java.util.HashSet;

class n$35 implements Runnable {
    final /* synthetic */ Bundle cgJ;
    final /* synthetic */ int uqC;
    final /* synthetic */ n uuo;

    n$35(n nVar, int i, Bundle bundle) {
        this.uuo = nVar;
        this.uqC = i;
        this.cgJ = bundle;
    }

    public final void run() {
        AppMethodBeat.i(7748);
        if (n.a(this.uuo).get() == null || ((WebViewUI) n.a(this.uuo).get()).isFinishing() || ((WebViewUI) n.a(this.uuo).get()).pzf == null) {
            AppMethodBeat.o(7748);
            return;
        }
        ab.i("MicroMsg.WebViewStubCallbackAIDLStub", "setMenuItemsVisible, actionCode = " + this.uqC);
        HashSet<Object> hashSet = new HashSet();
        if (this.uqC == 3003 || this.uqC == 3004) {
            hashSet.add("menuItem:share:brand");
            hashSet.add("menuItem:share:appMessage");
            hashSet.add("menuItem:share:dataMessage");
            hashSet.add("menuItem:share:timeline");
            hashSet.add("menuItem:favorite");
            hashSet.add("menuItem:profile");
            hashSet.add("menuItem:addContact");
            hashSet.add("menuItem:copyUrl");
            hashSet.add("menuItem:openWithSafari");
            hashSet.add("menuItem:share:email");
            hashSet.add("menuItem:delete");
            hashSet.add("menuItem:editTag");
            hashSet.add("menuItem:readMode");
            hashSet.add("menuItem:originPage");
            hashSet.add("menuItem:share:qq");
            hashSet.add("menuItem:share:weiboApp");
            hashSet.add("menuItem:share:QZone");
            hashSet.add("menuItem:share:Facebook");
            hashSet.add("menuItem:share:enterprise");
            hashSet.add("menuItem:share:wework");
            hashSet.add("menuItem:share:weread");
            hashSet.add("menuItem:addShortcut");
        } else if (this.cgJ == null) {
            ab.w("MicroMsg.WebViewStubCallbackAIDLStub", "setMenuItemsVisible data is null.");
            AppMethodBeat.o(7748);
            return;
        } else {
            ArrayList stringArrayList = this.cgJ.getStringArrayList("menu_item_list");
            if (stringArrayList == null || stringArrayList.size() == 0) {
                ab.w("MicroMsg.WebViewStubCallbackAIDLStub", "setMenuItemsVisible menuItems is null or nil.");
                AppMethodBeat.o(7748);
                return;
            }
            hashSet.addAll(stringArrayList);
            hashSet.remove("menuItem:exposeArticle");
            hashSet.remove("menuItem:setFont");
            hashSet.remove("menuItem:keepTop");
            hashSet.remove("menuItem:cancelKeepTop");
            hashSet.remove("menuItem:profile");
            hashSet.remove("menuItem:addContact");
            hashSet.remove("menuItem:refresh");
        }
        String url = ((WebViewUI) n.a(this.uuo).get()).pzf.getUrl();
        SparseBooleanArray sparseBooleanArray = (SparseBooleanArray) ((WebViewUI) n.a(this.uuo).get()).uwI.utA.get(url);
        switch (this.uqC) {
            case 3001:
            case 3003:
                SparseBooleanArray sparseBooleanArray2;
                if (sparseBooleanArray == null) {
                    sparseBooleanArray2 = new SparseBooleanArray();
                    ((WebViewUI) n.a(this.uuo).get()).uwI.utA.put(url, sparseBooleanArray2);
                } else {
                    sparseBooleanArray2 = sparseBooleanArray;
                }
                for (Object obj : hashSet) {
                    int a = bo.a((Integer) ((WebViewUI) n.a(this.uuo).get()).uwI.utB.get(obj), -1);
                    if (a >= 0) {
                        sparseBooleanArray2.put(a, true);
                    }
                }
                ((WebViewUI) n.a(this.uuo).get()).uwI.Kt();
                AppMethodBeat.o(7748);
                return;
            case 3002:
            case 3004:
                if (sparseBooleanArray != null) {
                    for (Object obj2 : hashSet) {
                        int a2 = bo.a((Integer) ((WebViewUI) n.a(this.uuo).get()).uwI.utB.get(obj2), -1);
                        if (a2 >= 0) {
                            sparseBooleanArray.delete(a2);
                        }
                    }
                    ((WebViewUI) n.a(this.uuo).get()).uwI.Kt();
                    break;
                }
                break;
        }
        AppMethodBeat.o(7748);
    }
}
