package com.tencent.mm.plugin.websearch.widget.view;

import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.i;
import android.support.v4.app.k;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.websearch.api.WidgetData;
import com.tencent.mm.plugin.websearch.api.g;
import com.tencent.mm.plugin.websearch.api.y;
import com.tencent.mm.plugin.websearch.widget.view.ServiceWidgetView.MyFragment;
import com.tencent.mm.plugin.websearch.widget.view.b.a;
import com.tencent.mm.plugin.websearch.widget.view.b.b;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.ui.MMActivity;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ServiceWidgetView$a extends k {
    List<WidgetData> kFl = Collections.emptyList();
    private List<MyFragment> rdA = new ArrayList();
    final /* synthetic */ ServiceWidgetView udI;

    public ServiceWidgetView$a(ServiceWidgetView serviceWidgetView, i iVar) {
        this.udI = serviceWidgetView;
        super(iVar);
        AppMethodBeat.i(91491);
        AppMethodBeat.o(91491);
    }

    public final b Iu(int i) {
        AppMethodBeat.i(91492);
        if (i < 0 || i >= this.rdA.size()) {
            AppMethodBeat.o(91492);
            return null;
        }
        b bVar = ((MyFragment) this.rdA.get(i)).udJ;
        AppMethodBeat.o(91492);
        return bVar;
    }

    public final int getItemPosition(Object obj) {
        AppMethodBeat.i(91493);
        b bVar = ((MyFragment) obj).udJ;
        if (bVar != null) {
            int indexOf = this.kFl.indexOf(bVar.udY);
            if (indexOf >= 0) {
                AppMethodBeat.o(91493);
                return indexOf;
            }
            AppMethodBeat.o(91493);
            return -2;
        }
        AppMethodBeat.o(91493);
        return -2;
    }

    public final Fragment getItem(final int i) {
        MyFragment myFragment;
        AppMethodBeat.i(91494);
        if (i >= this.rdA.size()) {
            myFragment = new MyFragment();
            Bundle bundle = new Bundle();
            bundle.putParcelable("data", (Parcelable) this.kFl.get(i));
            myFragment.setArguments(bundle);
            this.rdA.add(myFragment);
        } else {
            myFragment = (MyFragment) this.rdA.get(i);
        }
        b bVar = myFragment.udJ;
        MMActivity mMActivity = this.udI.hwd;
        ServiceWidgetView serviceWidgetView = this.udI;
        b bVar2 = this.udI.udH;
        AnonymousClass1 anonymousClass1 = new a() {
            public final int cVV() {
                AppMethodBeat.i(91489);
                if (ServiceWidgetView$a.this.kFl == null) {
                    AppMethodBeat.o(91489);
                    return 0;
                }
                int size = ServiceWidgetView$a.this.kFl.size();
                AppMethodBeat.o(91489);
                return size;
            }

            public final List<y> cVW() {
                return ServiceWidgetView$a.this.udI.udG;
            }

            public final boolean cVX() {
                return i > 0;
            }

            public final boolean hasNext() {
                AppMethodBeat.i(91490);
                if (i < ServiceWidgetView$a.this.kFl.size() - 1) {
                    AppMethodBeat.o(91490);
                    return true;
                }
                AppMethodBeat.o(91490);
                return false;
            }
        };
        g gVar = this.udI.mJG;
        WidgetData widgetData = (WidgetData) this.kFl.get(i);
        bVar.hwd = mMActivity;
        bVar.mJs = serviceWidgetView;
        bVar.udH = bVar2;
        bVar.udX = anonymousClass1;
        bVar.mJG = gVar;
        bVar.udY = widgetData;
        if (i == this.udI.rap.getCurrentItem()) {
            MyFragment.a(myFragment).setSelected(true);
        } else {
            MyFragment.a(myFragment).setSelected(false);
        }
        ab.i("ServiceWidgetView", "getItem %s, fragment %s", new Object[]{Integer.valueOf(i), myFragment.toString()});
        AppMethodBeat.o(91494);
        return myFragment;
    }

    public final int getCount() {
        AppMethodBeat.i(91495);
        if (this.kFl == null) {
            AppMethodBeat.o(91495);
            return 0;
        }
        int size = this.kFl.size();
        AppMethodBeat.o(91495);
        return size;
    }
}
