package com.tencent.mm.plugin.qqmail.b;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.qqmail.b.v.a;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;

class p$1 extends a {
    final /* synthetic */ p pup;

    p$1(p pVar) {
        this.pup = pVar;
    }

    public final void onSuccess(String str, Map<String, String> map) {
        AppMethodBeat.i(67962);
        p pVar = this.pup;
        int i = bo.getInt((String) map.get(".Response.result.Count"), 0);
        if (i > 0) {
            int i2 = pVar.puk.ptp.size() == 0 ? 1 : 0;
            int i3 = 0;
            while (i3 < i) {
                String str2 = ".Response.result.List.item" + (i3 > 0 ? String.valueOf(i3) : BuildConfig.FLAVOR) + ".";
                String str3 = (String) map.get(str2 + "Del");
                String str4 = (String) map.get(str2 + "Freq");
                String str5 = (String) map.get(str2 + "Name");
                str2 = (String) map.get(str2 + "Addr");
                if (str2 != null && str2.length() != 0) {
                    if (str5 == null || str5.length() == 0) {
                        str5 = str2;
                    }
                    int hashCode = str2.hashCode();
                    if (str3.equals("0")) {
                        LinkedList linkedList = pVar.puk.ptp;
                        int i4 = 0;
                        while (i2 == 0 && i4 < linkedList.size() && ((o) linkedList.get(i4)).puf != hashCode) {
                            i4++;
                        }
                        if (i4 >= linkedList.size() || i2 != 0) {
                            o oVar = new o();
                            oVar.puf = hashCode;
                            oVar.name = str5;
                            oVar.nJq = str2;
                            oVar.pug = bo.getInt(str4, 0);
                            pVar.puk.a(oVar);
                        }
                    } else {
                        Iterator it = pVar.puk.ptp.iterator();
                        int i5 = 0;
                        while (it.hasNext()) {
                            if (((o) it.next()).puf == hashCode) {
                                pVar.puk.Bo(i5);
                                break;
                            }
                            i5++;
                        }
                    }
                }
                i3++;
            }
            pVar.puk.Vc((String) map.get(".Response.result.SyncInfo"));
            pVar.save();
        }
        if (((String) map.get(".Response.result.ContinueFlag")).equals("1")) {
            new ak().postDelayed(new 1(this), 0);
            AppMethodBeat.o(67962);
            return;
        }
        this.pup.pui = bo.anU();
        for (p.a onComplete : this.pup.callbacks) {
            onComplete.onComplete();
        }
        AppMethodBeat.o(67962);
    }

    public final void onError(int i, String str) {
        AppMethodBeat.i(67963);
        for (p.a onComplete : this.pup.callbacks) {
            onComplete.onComplete();
        }
        AppMethodBeat.o(67963);
    }

    public final void onComplete() {
        this.pup.status = this.pup.puo;
    }
}
