package com.tencent.mm.plugin.emoji.ui;

import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.emoji.a.a;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.emoji.model.j;
import com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.c;
import com.tencent.mm.storage.emotion.EmojiInfo;
import java.util.ArrayList;

class EmojiCustomUI$b extends BaseAdapter {
    private int ezx;
    private ArrayList<EmojiInfo> kWs;
    final /* synthetic */ EmojiCustomUI kZL;
    private Animation kZV;

    public final /* synthetic */ Object getItem(int i) {
        AppMethodBeat.i(53330);
        EmojiInfo uf = uf(i);
        AppMethodBeat.o(53330);
        return uf;
    }

    public EmojiCustomUI$b(EmojiCustomUI emojiCustomUI, int i) {
        this.kZL = emojiCustomUI;
        AppMethodBeat.i(53322);
        this.ezx = i;
        this.kZV = AnimationUtils.loadAnimation(emojiCustomUI, 2131034242);
        this.kZV.setInterpolator(new LinearInterpolator());
        AppMethodBeat.o(53322);
    }

    public final int getCount() {
        AppMethodBeat.i(53323);
        int realCount = getRealCount() + blx();
        AppMethodBeat.o(53323);
        return realCount;
    }

    private int blx() {
        AppMethodBeat.i(53324);
        if (getRealCount() <= 0 || (getRealCount() + 1) % 5 != 0) {
            AppMethodBeat.o(53324);
            return 2;
        }
        AppMethodBeat.o(53324);
        return 1;
    }

    public final int getRealCount() {
        AppMethodBeat.i(53325);
        if (this.kWs == null) {
            AppMethodBeat.o(53325);
            return 0;
        }
        int size = this.kWs.size();
        AppMethodBeat.o(53325);
        return size;
    }

    public final EmojiInfo uf(int i) {
        AppMethodBeat.i(53326);
        if (i >= getRealCount()) {
            AppMethodBeat.o(53326);
            return null;
        } else if (this.kWs == null) {
            AppMethodBeat.o(53326);
            return null;
        } else {
            EmojiInfo emojiInfo = (EmojiInfo) this.kWs.get(i);
            AppMethodBeat.o(53326);
            return emojiInfo;
        }
    }

    public final long getItemId(int i) {
        return (long) i;
    }

    public final android.view.View getView(int r8, android.view.View r9, android.view.ViewGroup r10) {
        /*
        r7 = this;
        r6 = 53327; // 0xd04f float:7.4727E-41 double:2.6347E-319;
        r5 = 8;
        r4 = 0;
        r3 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r6);
        if (r9 == 0) goto L_0x0012;
    L_0x000c:
        r0 = r9.getTag();
        if (r0 != 0) goto L_0x007b;
    L_0x0012:
        r0 = r7.kZL;
        r0 = r0.mController;
        r0 = r0.ylL;
        r0 = android.view.LayoutInflater.from(r0);
        r1 = 2130969333; // 0x7f0402f5 float:1.7547345E38 double:1.05283874E-314;
        r9 = r0.inflate(r1, r3);
        r9.setVisibility(r4);
        r0 = new com.tencent.mm.plugin.emoji.ui.EmojiCustomUI$d;
        r0.<init>(r9);
        r9.setTag(r0);
        r1 = r0;
    L_0x002f:
        r0 = r7.kZL;
        r0 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.m(r0);
        r2 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.c.kZZ;
        if (r0 == r2) goto L_0x0043;
    L_0x0039:
        r0 = r7.kZL;
        r0 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.m(r0);
        r2 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.c.kZX;
        if (r0 != r2) goto L_0x0086;
    L_0x0043:
        r0 = r7.blx();
    L_0x0047:
        r2 = r7.getCount();
        r2 = r2 - r0;
        if (r8 >= r2) goto L_0x00a0;
    L_0x004e:
        r0 = r8 % 5;
        if (r0 != 0) goto L_0x0097;
    L_0x0052:
        r0 = r1.iym;
        r2 = 2130838565; // 0x7f020425 float:1.7282116E38 double:1.052774132E-314;
        r0.setBackgroundResource(r2);
    L_0x005a:
        r0 = r1.image;
        r0.clearAnimation();
        r0 = r1.image;
        r2 = android.widget.ImageView.ScaleType.FIT_CENTER;
        r0.setScaleType(r2);
        r0 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.11.kZQ;
        r2 = r7.kZL;
        r2 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.m(r2);
        r2 = r2.ordinal();
        r0 = r0[r2];
        switch(r0) {
            case 1: goto L_0x00b7;
            case 2: goto L_0x0187;
            case 3: goto L_0x013c;
            case 4: goto L_0x01e7;
            default: goto L_0x0077;
        };
    L_0x0077:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r6);
        return r9;
    L_0x007b:
        r9.setVisibility(r4);
        r0 = r9.getTag();
        r0 = (com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.d) r0;
        r1 = r0;
        goto L_0x002f;
    L_0x0086:
        r0 = 1;
        r2 = r7.ezx;
        if (r0 != r2) goto L_0x0090;
    L_0x008b:
        r0 = r7.blx();
        goto L_0x0047;
    L_0x0090:
        r0 = r7.blx();
        r0 = r0 + -1;
        goto L_0x0047;
    L_0x0097:
        r0 = r1.iym;
        r2 = 2130838570; // 0x7f02042a float:1.7282126E38 double:1.0527741343E-314;
        r0.setBackgroundResource(r2);
        goto L_0x005a;
    L_0x00a0:
        r2 = r7.getCount();
        r0 = r2 - r0;
        if (r8 != r0) goto L_0x00b1;
    L_0x00a8:
        r0 = r1.iym;
        r2 = 2130838569; // 0x7f020429 float:1.7282124E38 double:1.052774134E-314;
        r0.setBackgroundResource(r2);
        goto L_0x005a;
    L_0x00b1:
        r0 = r1.iym;
        r0.setBackgroundColor(r4);
        goto L_0x005a;
    L_0x00b7:
        r0 = r7.getCount();
        r2 = r7.blx();
        r0 = r0 - r2;
        r0 = r0 + 1;
        if (r8 != r0) goto L_0x00d6;
    L_0x00c4:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
    L_0x00d0:
        r0 = r1.lab;
        r0.setVisibility(r5);
        goto L_0x0077;
    L_0x00d6:
        if (r8 != 0) goto L_0x0107;
    L_0x00d8:
        r0 = r7.ezx;
        if (r0 != 0) goto L_0x00f3;
    L_0x00dc:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r2 = android.widget.ImageView.ScaleType.CENTER_INSIDE;
        r0.setScaleType(r2);
        r0 = r1.image;
        r2 = 2131231221; // 0x7f0801f5 float:1.8078517E38 double:1.0529681296E-314;
        r0.setImageResource(r2);
        goto L_0x00d0;
    L_0x00f3:
        r0 = r7.getRealCount();
        if (r8 == r0) goto L_0x00d0;
    L_0x00f9:
        r0 = r7.kWs;
        r0 = r0.get(r8);
        r0 = (com.tencent.mm.storage.emotion.EmojiInfo) r0;
        r2 = r1.image;
        a(r2, r0);
        goto L_0x00d0;
    L_0x0107:
        r0 = r7.ezx;
        if (r0 != 0) goto L_0x011b;
    L_0x010b:
        r0 = r7.kWs;
        r2 = r8 + -1;
        r0 = r0.get(r2);
        r0 = (com.tencent.mm.storage.emotion.EmojiInfo) r0;
        r2 = r1.image;
        a(r2, r0);
        goto L_0x00d0;
    L_0x011b:
        r0 = r7.getRealCount();
        if (r8 == r0) goto L_0x012f;
    L_0x0121:
        r0 = r7.kWs;
        r0 = r0.get(r8);
        r0 = (com.tencent.mm.storage.emotion.EmojiInfo) r0;
        r2 = r1.image;
        a(r2, r0);
        goto L_0x00d0;
    L_0x012f:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
        goto L_0x00d0;
    L_0x013c:
        r0 = r7.getCount();
        r2 = r7.blx();
        r0 = r0 - r2;
        r0 = r0 + 1;
        if (r8 != r0) goto L_0x015c;
    L_0x0149:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
    L_0x0155:
        r0 = r1.lab;
        r0.setVisibility(r5);
        goto L_0x0077;
    L_0x015c:
        r0 = r7.getRealCount();
        if (r8 != r0) goto L_0x0179;
    L_0x0162:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r2 = 2130839884; // 0x7f02094c float:1.7284791E38 double:1.0527747835E-314;
        r0.setImageResource(r2);
        r0 = r1.image;
        r2 = r7.kZV;
        r0.startAnimation(r2);
        goto L_0x0155;
    L_0x0179:
        r0 = r7.kWs;
        r0 = r0.get(r8);
        r0 = (com.tencent.mm.storage.emotion.EmojiInfo) r0;
        r2 = r1.image;
        a(r2, r0);
        goto L_0x0155;
    L_0x0187:
        r0 = r7.getCount();
        r2 = r7.blx();
        r0 = r0 - r2;
        r0 = r0 + 1;
        if (r8 != r0) goto L_0x01a7;
    L_0x0194:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
    L_0x01a0:
        r0 = r1.lab;
        r0.setVisibility(r5);
        goto L_0x0077;
    L_0x01a7:
        r0 = r7.getRealCount();
        if (r8 != r0) goto L_0x01ba;
    L_0x01ad:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
        goto L_0x01a0;
    L_0x01ba:
        r0 = r7.kWs;
        r0 = r0.get(r8);
        r0 = (com.tencent.mm.storage.emotion.EmojiInfo) r0;
        r2 = r1.image;
        a(r2, r0);
        r2 = r0.field_catalog;
        r3 = com.tencent.mm.storage.emotion.EmojiGroupInfo.yad;
        if (r2 == r3) goto L_0x01a0;
    L_0x01cd:
        r2 = r1.lab;
        r2.setVisibility(r4);
        r1 = r1.lab;
        r2 = r7.kZL;
        r2 = com.tencent.mm.plugin.emoji.ui.EmojiCustomUI.n(r2);
        r0 = r0.Aq();
        r0 = r2.contains(r0);
        r1.setChecked(r0);
        goto L_0x0077;
    L_0x01e7:
        r0 = r7.getCount();
        r2 = r7.blx();
        r0 = r0 - r2;
        r0 = r0 + 1;
        if (r8 != r0) goto L_0x0201;
    L_0x01f4:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
        goto L_0x01a0;
    L_0x0201:
        r0 = r7.getRealCount();
        if (r8 != r0) goto L_0x0214;
    L_0x0207:
        r0 = com.tencent.mm.emoji.loader.a.exs;
        r0 = r1.image;
        com.tencent.mm.emoji.loader.a.cf(r0);
        r0 = r1.image;
        r0.setImageBitmap(r3);
        goto L_0x01a0;
    L_0x0214:
        r0 = r7.kWs;
        r0 = r0.get(r8);
        r0 = (com.tencent.mm.storage.emotion.EmojiInfo) r0;
        r2 = r1.image;
        a(r2, r0);
        goto L_0x01a0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.emoji.ui.EmojiCustomUI$b.getView(int, android.view.View, android.view.ViewGroup):android.view.View");
    }

    public final boolean bly() {
        AppMethodBeat.i(53328);
        if (!g.RP().isSDCardAvailable()) {
            this.kWs = new ArrayList();
        } else if (this.ezx == 0) {
            this.kWs = (ArrayList) j.getEmojiStorageMgr().xYn.ps(false);
        } else {
            this.kWs = a.OB().bZ(false);
        }
        if (EmojiCustomUI.m(this.kZL) == c.kZX) {
            int size = EmojiCustomUI.n(this.kZL) == null ? 0 : EmojiCustomUI.n(this.kZL).size();
            this.kZL.setMMTitle(this.kZL.getString(2131299080, new Object[]{Integer.valueOf(size)}));
        } else if (this.ezx == 0) {
            this.kZL.setMMTitle(this.kZL.getString(2131299044, new Object[]{Integer.valueOf(this.kWs.size())}));
        } else {
            this.kZL.setMMTitle(this.kZL.getString(2131299027, new Object[]{Integer.valueOf(this.kWs.size())}));
        }
        AppMethodBeat.o(53328);
        return true;
    }

    private static void a(ImageView imageView, EmojiInfo emojiInfo) {
        AppMethodBeat.i(53329);
        com.tencent.mm.emoji.loader.a aVar = com.tencent.mm.emoji.loader.a.exs;
        com.tencent.mm.emoji.loader.a.a(emojiInfo, imageView);
        AppMethodBeat.o(53329);
    }
}
