package com.tencent.mm.plugin.topstory.ui.video;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.topstory.a.g;
import com.tencent.mm.plugin.topstory.ui.video.n.2;
import com.tencent.mm.protocal.protobuf.bqg;
import com.tencent.mm.protocal.protobuf.chw;
import com.tencent.mm.protocal.protobuf.chy;
import com.tencent.mm.protocal.protobuf.clz;
import com.tencent.mm.protocal.protobuf.cnu;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

class n$2$1 implements Runnable {
    final /* synthetic */ bqg sFk;
    final /* synthetic */ 2 sFl;

    n$2$1(2 2, bqg bqg) {
        this.sFl = 2;
        this.sFk = bqg;
    }

    public final void run() {
        AppMethodBeat.i(1758);
        ArrayList<chw> arrayList = new ArrayList();
        Iterator it = this.sFk.wSz.vHk.iterator();
        while (it.hasNext()) {
            cnu cnu = (cnu) it.next();
            chw chw = new chw();
            if (!bo.isNullOrNil(cnu.xkY.wbI)) {
                chw.xgS = cnu.xkY.wbI;
                chy dM;
                if (cnu.xla == null || cnu.xla.xkW != 1) {
                    if (!bo.isNullOrNil(cnu.xlb)) {
                        String str = BuildConfig.FLAVOR;
                        chw.xhb.clear();
                        n.b(chw, cnu.xlb, str);
                        dM = g.dM(chw.xhb);
                        if (dM != null) {
                            chw.videoUrl = dM.url;
                            chw.xhg = dM.xhg;
                        }
                    }
                } else if (!(cnu.xla.xkX == null || bo.ek(cnu.xla.xkX.wHo))) {
                    chw.xhb.clear();
                    Iterator it2 = cnu.xla.xkX.wHo.iterator();
                    while (it2.hasNext()) {
                        clz clz = (clz) it2.next();
                        chy chy = new chy();
                        chy.url = clz.xjH.dlY();
                        chy.xhg = 0;
                        chw.xhb.add(chy);
                        chw.xha = clz.xjJ;
                    }
                    dM = g.dM(chw.xhb);
                    if (dM != null) {
                        chw.videoUrl = dM.url;
                        chw.xhg = dM.xhg;
                    }
                }
                arrayList.add(chw);
            }
        }
        synchronized (this.sFl.sFe) {
            try {
                List cGQ = this.sFl.sFe.cGQ();
                if (bo.ek(cGQ)) {
                } else {
                    for (int i = 0; i < cGQ.size(); i++) {
                        chw chw2 = (chw) cGQ.get(i);
                        for (chw chw3 : arrayList) {
                            if (chw2.xgS.equals(chw3.xgS)) {
                                chw2.xhb = chw3.xhb;
                                chw2.xha = chw3.xha;
                                chw2.videoUrl = chw3.videoUrl;
                                ab.d("MicroMsg.TopStory.TopStoryVideoDataMgr", "item title:%s, after url:%s", new Object[]{chw2.title, chw2.videoUrl});
                            }
                        }
                    }
                    AppMethodBeat.o(1758);
                }
            } finally {
                AppMethodBeat.o(1758);
            }
        }
    }
}
