酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319

以下内容为反编译后的 ViperOtherFragment.java 源代码,内容仅作参考


package com.kugou.android.app.eq.fragment.viper;

import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import c.t;
import com.google.gson.Gson;
import com.kugou.android.app.KGApplication;
import com.kugou.android.app.NavigationUtils;
import com.kugou.android.app.eq.a.f;
import com.kugou.android.app.eq.c.o;
import com.kugou.android.app.eq.comment.EqCommentsListFragment;
import com.kugou.android.app.eq.entity.ViperItem;
import com.kugou.android.app.eq.entity.j;
import com.kugou.android.app.eq.entity.k;
import com.kugou.android.app.eq.event.m;
import com.kugou.android.app.eq.fragment.EQEffectIntroFragment;
import com.kugou.android.app.eq.widget.c;
import com.kugou.android.app.process.EnvManager;
import com.kugou.android.app.v;
import com.kugou.android.common.delegate.DelegateFragment;
import com.kugou.android.common.delegate.s;
import com.kugou.android.lite.R;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.base.AbsFrameworkFragment;
import com.kugou.common.utils.ag;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.utils.bv;
import com.kugou.common.widget.listview.PullToRefreshListView;
import com.kugou.common.widget.listview.extra.PullToRefreshBase;
import com.kugou.framework.service.util.BackgroundServiceUtil;
import com.qq.e.comm.constants.TangramHippyConstants;
import com.tencent.open.SocialConstants;
import de.greenrobot.event.EventBus;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

@com.kugou.common.base.e.c(a = 528178838)
public class ViperOtherFragment extends DelegateFragment implements View.OnClickListener {

    private static final String f6832a = com.kugou.common.constant.c.dV + ".cache_new";

    private static final String f6833b = com.kugou.common.constant.c.dV + ".cache_hot";

    private static boolean f6834d = false;
    public static int h = -1;
    private com.kugou.android.app.eq.widget.c<ViperItem> A;
    private TextView B;
    private View C;
    private View D;
    private boolean E;
    private boolean F;

    private View f6835c;

    private View f6836e;
    private TextView f;
    private int g;
    private int i;
    private View j;
    private View k;
    private View l;
    private com.kugou.android.app.eq.a.f m;
    private List<k.a.C0122a> n;
    private View o;
    private PullToRefreshListView r;
    private ListView s;
    private int t;
    private int u;
    private int v = 1;
    private int w = 1;
    private int x = -1;
    private List<ViperItem> y = new ArrayList();
    private List<ViperItem> z = new ArrayList();
    private View.OnClickListener G = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            BackgroundServiceUtil.trace(new com.kugou.framework.statistics.easytrace.task.d(ViperOtherFragment.this.getActivity(), com.kugou.framework.statistics.easytrace.a.Bl));
            ViperOtherFragment.this.h(1);
        }
    };
    private View.OnClickListener H = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            BackgroundServiceUtil.trace(new com.kugou.framework.statistics.easytrace.task.d(ViperOtherFragment.this.getActivity(), com.kugou.framework.statistics.easytrace.a.Bk));
            ViperOtherFragment.this.h(0);
        }
    };
    private f.a q = new f.a() {
        @Override
        public void a(View view, int i) {
            k.a.C0122a c0122a = (k.a.C0122a) ViperOtherFragment.this.n.get(i);
            if (c0122a.f6362b == ViperOtherFragment.h) {
                return;
            }
            BackgroundServiceUtil.trace(new com.kugou.framework.statistics.easytrace.task.d(KGCommonApplication.getContext(), com.kugou.framework.statistics.easytrace.a.ajY).setSvar1(c0122a.f6361a));
            ViperOtherFragment.this.m.a(c0122a.f6362b);
            ViperOtherFragment.this.m.notifyDataSetChanged();
            ViperOtherFragment.this.i(c0122a.f6362b);
        }
    };
    private c.d I = new c.d() {
        @Override
        public void a(View view, int i, boolean z) {
            ViperItem viperItem = (ViperItem) ViperOtherFragment.this.A.getItem(i);
            if (viperItem == null) {
                return;
            }
            ViperOtherFragment.this.a(viperItem, z);
        }

        @Override
        public void a(View view, int i) {
            ViperItem viperItem = (ViperItem) ViperOtherFragment.this.A.getItem(i);
            if (viperItem == null) {
                return;
            }
            if (!viperItem.x()) {
                ViperOtherFragment viperOtherFragment = ViperOtherFragment.this;
                viperOtherFragment.a_(viperOtherFragment.getString(R.string.mt));
                return;
            }
            if (viperItem.cp_() == 0) {
                if (com.kugou.android.netmusic.musicstore.c.a(ViperOtherFragment.this.aN_())) {
                    viperItem.g_(1);
                    EventBus.getDefault().post(new m(0, false, viperItem));
                    ViperOtherFragment.this.a(viperItem);
                    return;
                }
                return;
            }
            if (viperItem.cp_() == 2) {
                ViperOtherFragment.this.b(viperItem);
            } else if (viperItem.cp_() == 3) {
                viperItem.g_(2);
                com.kugou.android.app.eq.c.a(new com.kugou.android.app.eq.b(false, 0, -3));
                EventBus.getDefault().post(new m(0, false, viperItem));
            }
        }

        @Override
        public void b(View view, int i) {
            ViperItem viperItem = (ViperItem) ViperOtherFragment.this.A.getItem(i);
            if (viperItem == null) {
                return;
            }
            long intValue = Integer.valueOf(viperItem.c()).intValue();
            if (com.kugou.common.environment.a.Y() == intValue) {
                v.a(ViperOtherFragment.this, "蝰蛇音效");
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putLong("guest_user_id", intValue);
            bundle.putString("guest_nick_name", viperItem.r());
            bundle.putInt(SocialConstants.PARAM_SOURCE, 0);
            bundle.putString("guest_pic", viperItem.s());
            bundle.putString("user_info_source_page", "蝰蛇音效");
            NavigationUtils.a((AbsFrameworkFragment) ViperOtherFragment.this, bundle);
        }
    };

    public static int d(int i) {
        if (i == 1) {
            return 3;
        }
        if (i == 0) {
        }
        return 4;
    }

    @Override
    public boolean hasMenu() {
        return false;
    }

    @Override
    public boolean hasNavigationBar() {
        return false;
    }

    @Override
    public boolean hasPlayingBar() {
        return false;
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.n = b();
        EventBus.getDefault().register(getActivity().getClassLoader(), ViperOtherFragment.class.getName(), this);
    }

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.ami, viewGroup, false);
        inflate.findViewById(R.id.jq).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                BackgroundServiceUtil.trace(new com.kugou.framework.statistics.easytrace.task.d(ViperOtherFragment.this.getActivity(), com.kugou.framework.statistics.easytrace.a.Bj));
                Bundle bundle2 = new Bundle();
                bundle2.putString("key_url", "http://ksyx.kugou.com/mobile.html");
                bundle2.putString("key_title", "我要上传");
                ViperOtherFragment.this.startFragment(EQEffectIntroFragment.class, bundle2);
            }
        });
        this.f6835c = inflate.findViewById(R.id.fij);
        this.f = (TextView) this.f6835c.findViewById(R.id.cf9);
        this.j = this.f6835c.findViewById(R.id.cf_);
        this.j.setOnClickListener(this.G);
        this.k = this.f6835c.findViewById(R.id.cfa);
        this.k.setOnClickListener(this.H);
        View findViewById = inflate.findViewById(R.id.zy);
        this.l = findViewById.findViewById(R.id.b3f);
        this.l.setClickable(false);
        this.o = findViewById.findViewById(R.id.bpx);
        this.r = (PullToRefreshListView) inflate.findViewById(R.id.b1y);
        this.r.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
        this.r.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
                if (ViperOtherFragment.this.a()) {
                    return;
                }
                ViperOtherFragment.this.a(true);
                ViperOtherFragment.this.n();
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
                if (ViperOtherFragment.this.a()) {
                    return;
                }
                ViperOtherFragment.this.a(true);
                ViperOtherFragment.this.n();
            }
        });
        this.s = (ListView) this.r.getRefreshableView();
        ((TextView) this.o.findViewById(R.id.bpv)).setTextColor(-1);
        this.o.findViewById(R.id.it).setOnClickListener(this);
        this.s.setOnScrollListener(new com.kugou.android.netmusic.discovery.ui.a() {
            @Override
            public void a(int i) {
            }

            @Override
            public void onScroll(AbsListView absListView, int i, int i2, int i3) {
                int headerViewsCount;
                super.onScroll(absListView, i, i2, i3);
                if (!ViperOtherFragment.this.a() && i > ViperOtherFragment.this.f() && (headerViewsCount = ViperOtherFragment.this.s.getHeaderViewsCount() + ViperOtherFragment.this.s.getFooterViewsCount()) != i3 && i2 + i > (i3 - headerViewsCount) - 2) {
                    ViperOtherFragment.this.a(true);
                    ViperOtherFragment.this.n();
                }
                ViperOtherFragment.this.b(i);
                if (i < 1 || ViperOtherFragment.this.f6835c.getVisibility() != 8) {
                    if (i == 0 && ViperOtherFragment.this.f6835c.getVisibility() == 0) {
                        ViperOtherFragment.this.f6835c.setVisibility(8);
                        return;
                    }
                    return;
                }
                ViperOtherFragment.this.f6835c.setVisibility(0);
            }
        });
        this.f6836e = layoutInflater.inflate(R.layout.b9b, (ViewGroup) this.s, false);
        this.B = (TextView) this.f6836e.findViewById(R.id.cf9);
        this.C = this.f6836e.findViewById(R.id.cf_);
        this.C.setOnClickListener(this.G);
        this.D = this.f6836e.findViewById(R.id.cfa);
        this.D.setOnClickListener(this.H);
        View inflate2 = layoutInflater.inflate(R.layout.b9i, (ViewGroup) this.s, false);
        RecyclerView recyclerView = (RecyclerView) inflate2.findViewById(R.id.gso);
        this.m = new com.kugou.android.app.eq.a.f(aN_(), this.n, h);
        this.m.a(this.q);
        recyclerView.setAdapter(this.m);
        recyclerView.setLayoutManager(new GridLayoutManager(aN_(), 4));
        final int a2 = br.a((Context) aN_(), 10.0f);
        recyclerView.addItemDecoration(new RecyclerView.g() {
            @Override
            public void a(Rect rect, View view, RecyclerView recyclerView2, RecyclerView.r rVar) {
                rect.set(0, 0, 0, 0);
                int childAdapterPosition = recyclerView2.getChildAdapterPosition(view);
                if (childAdapterPosition / 4 != 0) {
                    rect.top = a2;
                }
                if (childAdapterPosition % 4 != 3) {
                    rect.right = a2;
                }
            }
        });
        int c2 = c();
        this.s.addHeaderView(inflate2);
        this.s.addHeaderView(this.f6836e);
        inflate2.setLayoutParams(new AbsListView.LayoutParams(-1, c2, 0));
        this.A = new com.kugou.android.app.eq.widget.c<>(this, this.I);
        this.s.setAdapter((ListAdapter) this.A);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) findViewById.getLayoutParams();
        layoutParams.topMargin = c2 + br.a((Context) aN_(), 45.0f);
        layoutParams.addRule(3, R.id.cz2);
        findViewById.setLayoutParams(layoutParams);
        return inflate;
    }

    public boolean a() {
        if (this.g == 1) {
            return this.E;
        }
        return this.F;
    }

    public void a(boolean z) {
        a(z, this.g);
    }

    public void a(boolean z, int i) {
        if (i == 1) {
            this.E = z;
        } else {
            this.F = z;
        }
    }

    public void b(int i) {
        if (this.g == 1) {
            this.t = i;
        } else {
            this.u = i;
        }
    }

    public int f() {
        if (this.g == 1) {
            return this.t;
        }
        return this.u;
    }

    public int g() {
        if (this.g == 1) {
            return this.v;
        }
        return this.w;
    }

    public void a(int i, int i2) {
        if (i2 == 1) {
            this.v = i;
        } else {
            this.w = i;
        }
    }

    public int h() {
        return this.x;
    }

    public void c(int i) {
        if (this.x != i) {
            this.x = i;
            a(i);
        }
    }

    public int f(int i) {
        if (i == 1) {
            return this.y.size();
        }
        return this.z.size();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle bundle) {
        super.onActivityCreated(bundle);
        enableTitleDelegate();
        initDelegates();
        getTitleDelegate().f(false);
        getTitleDelegate().b(aN_().getResources().getColor(R.color.e8));
        getTitleDelegate().a("音效市场");
        getTitleDelegate().a(new s.o() {
            @Override
            public void b_(View view) {
                if (ViperOtherFragment.this.s != null) {
                    ViperOtherFragment.this.s.setSelection(0);
                }
            }
        });
        this.i = getArguments().getInt(TangramHippyConstants.COUNT);
        this.g = com.kugou.common.q.c.b().aP();
        if (this.g > 1) {
            this.g = 0;
        }
        if (TextUtils.isEmpty(d())) {
            h = -1;
        }
        if (h == -1) {
            c(this.i);
        } else {
            c(0);
        }
        a(j(), k());
        a(l(), m());
        a(true);
        n();
        e();
    }

    private List<ViperItem> g(int i) {
        if (i == 1) {
            return this.y;
        }
        return this.z;
    }

    private List<k.a.C0122a> b() {
        String bm = com.kugou.common.q.c.b().bm();
        ArrayList arrayList = new ArrayList();
        arrayList.add(new k.a.C0122a(-1, "全部"));
        arrayList.addAll(((k.a) new Gson().fromJson(bm, k.a.class)).a());
        return arrayList;
    }

    private int c() {
        int size = this.n.size();
        int i = (size / 4) + (size % 4 != 0 ? 1 : 0);
        int a2 = br.a((Context) aN_(), 18.0f);
        int a3 = br.a((Context) aN_(), 7.0f);
        return (a2 * 2) + (br.a((Context) aN_(), 35.0f) * i) + (i > 1 ? (i - 1) * a3 : 0) + br.a((Context) aN_(), 0.5f);
    }

    private String d() {
        for (k.a.C0122a c0122a : this.n) {
            if (c0122a.f6362b == h) {
                return c0122a.f6361a;
            }
        }
        return "";
    }

    private void e() {
        if (f6834d) {
            return;
        }
        f6834d = true;
        ((o) new t.a().b("viper").a(com.kugou.common.config.c.a().a(com.kugou.android.app.a.a.xO)).a(c.b.a.a.a()).a().b().a(o.class)).a(com.kugou.common.network.v.a().a("plat", br.E(KGApplication.getContext())).a("version", String.valueOf(br.F(KGApplication.getContext()))).b()).a(new c.d<k>() {
            @Override
            public void a(c.b<k> bVar, Throwable th) {
            }

            @Override
            public void a(c.b<k> bVar, c.s<k> sVar) {
                int size;
                k d2 = sVar.d();
                if (d2 == null || d2.a() != 1 || d2.b() == null || d2.b().a() == null || (size = d2.b().a().size()) <= 0) {
                    return;
                }
                Gson gson = new Gson();
                if (size > 19) {
                    d2.b().a(d2.b().a().subList(0, 19));
                }
                com.kugou.common.q.c.b().J(gson.toJson(d2.b()));
            }
        });
    }

    private void a(View view, View view2) {
        if (!view.isSelected()) {
            view.setSelected(true);
        }
        if (view2.isSelected()) {
            view2.setSelected(false);
        }
    }

    private View j() {
        if (this.g == 1) {
            return this.C;
        }
        return this.D;
    }

    private View k() {
        if (this.g == 1) {
            return this.D;
        }
        return this.C;
    }

    private View l() {
        if (this.g == 1) {
            return this.j;
        }
        return this.k;
    }

    private View m() {
        if (this.g == 1) {
            return this.k;
        }
        return this.j;
    }

    public void h(int i) {
        boolean a2 = a();
        this.g = i;
        a(j(), k());
        a(l(), m());
        List<ViperItem> g = g(this.g);
        this.A.a(g);
        this.A.notifyDataSetChanged();
        if (g.size() == 0) {
            if (a()) {
                return;
            }
            if (a2) {
                this.r.onRefreshComplete();
            }
            if (this.r.getMode() == PullToRefreshBase.Mode.DISABLED) {
                this.r.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
            }
            a(true);
            n();
            return;
        }
        if (a()) {
            o();
            if (a2) {
                this.l.setVisibility(8);
            }
        } else if (a2) {
            q();
        }
        int h2 = h();
        if (h2 > 0 && g.size() < h2 && this.r.getMode() == PullToRefreshBase.Mode.DISABLED) {
            this.r.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
        }
        int f = f();
        if (f >= 1 && this.f6835c.getVisibility() == 8) {
            this.f6835c.setVisibility(0);
        }
        this.s.setSelection(f);
    }

    public void i(int i) {
        this.E = false;
        this.F = false;
        if (this.r.isRefreshing()) {
            this.r.onRefreshComplete();
        }
        h = i;
        if (h == -1) {
            c(this.i);
        } else {
            c(0);
        }
        this.y.clear();
        this.z.clear();
        this.w = 1;
        this.v = 1;
        this.u = 0;
        this.t = 0;
        if (this.r.getMode() == PullToRefreshBase.Mode.DISABLED) {
            this.r.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
        }
        this.A.a(g(this.g));
        this.A.notifyDataSetChanged();
        a(true);
        n();
    }

    public void a(int i) {
        String format = String.format(getResources().getString(R.string.bl3), Integer.valueOf(i));
        this.f.setText(format);
        this.B.setText(format);
    }

    public void n() {
        boolean z = false;
        if (this.r.getMode() == PullToRefreshBase.Mode.DISABLED) {
            a(false);
            return;
        }
        final boolean z2 = g(this.g).size() <= 0 && h == -1;
        if (!br.Q(aN_())) {
            bv.b(aN_(), R.string.av3);
            if (!z2) {
                p();
                a(false);
                return;
            }
            z = z2;
        } else if (!EnvManager.isOnline()) {
            p();
            br.T(aN_());
            a(false);
            return;
        }
        o();
        final int i = h;
        final int i2 = this.g;
        final int g = g();
        rx.e.a(Boolean.valueOf(z)).b(Schedulers.io()).d(new rx.b.e<Boolean, com.kugou.android.app.eq.entity.b>() {
            @Override
            public com.kugou.android.app.eq.entity.b call(Boolean bool) {
                List<ViperItem> j;
                com.kugou.android.app.eq.entity.b a2;
                int d2 = ViperOtherFragment.d(i2);
                if (!bool.booleanValue() && (a2 = new com.kugou.android.app.eq.c.b().a(d2, g, 20, new int[]{2, 3}, 0, 0L, i)) != null && a2.b() != null && a2.a() > 0 && a2.b().size() > 0) {
                    if (g == 1 && i == -1) {
                        ViperOtherFragment.this.c(a2.b(), d2);
                    }
                    return a2;
                }
                com.kugou.android.app.eq.entity.b bVar = new com.kugou.android.app.eq.entity.b();
                if ((bool.booleanValue() || z2) && (j = ViperOtherFragment.this.j(d2)) != null) {
                    bVar.a(j);
                    bVar.a(ViperOtherFragment.this.h());
                    return bVar;
                }
                bVar.a(-1);
                bVar.a((List<ViperItem>) null);
                return bVar;
            }
        }).a(AndroidSchedulers.mainThread()).b(new rx.b.b<com.kugou.android.app.eq.entity.b>() {
            @Override
            public void call(com.kugou.android.app.eq.entity.b bVar) {
                int f;
                if (i != ViperOtherFragment.h) {
                    return;
                }
                ViperOtherFragment.this.a(false, i2);
                if (i2 == ViperOtherFragment.this.g) {
                    ViperOtherFragment.this.q();
                }
                if (bVar.a() >= 0 && bVar.b() != null && bVar.b().size() > 0) {
                    com.kugou.common.q.c.b().c(bVar.a());
                    ViperOtherFragment.this.a(g + 1, i2);
                    ViperOtherFragment.this.c(bVar.a());
                    ViperOtherFragment.this.a(bVar.b(), i2);
                    if (i2 != ViperOtherFragment.this.g || (f = ViperOtherFragment.this.f(i2)) <= 0 || bVar.a() <= 0 || f < bVar.a()) {
                        return;
                    }
                    ViperOtherFragment.this.r.setMode(PullToRefreshBase.Mode.DISABLED);
                    return;
                }
                if ((bVar.a() <= 0 || (bVar.b() != null && bVar.b().size() > 0)) && (bVar.a() != 0 || bVar.b() == null || bVar.b().size() <= 0)) {
                    if (bVar.a() != -1) {
                        return;
                    }
                    if (bVar.b() != null && bVar.b().size() > 0) {
                        return;
                    }
                }
                ViperOtherFragment.this.a_("获取列表失败");
                if (i != -1 && ViperOtherFragment.this.g() == 1) {
                    ViperOtherFragment.this.c(0);
                }
                if (i2 == ViperOtherFragment.this.g) {
                    ViperOtherFragment.this.p();
                }
            }
        });
    }

    public void a(List<ViperItem> list, int i) {
        com.kugou.android.app.eq.d.e.a(list);
        b(list, i);
        if (i == this.g) {
            this.A.a(g(i));
            this.A.notifyDataSetChanged();
        }
    }

    private void b(List<ViperItem> list, int i) {
        long Y = com.kugou.common.environment.a.Y();
        List<ViperItem> g = g(i);
        if (Y > 0) {
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            for (ViperItem viperItem : list) {
                if (String.valueOf(Y).equals(viperItem.c())) {
                    arrayList.add(viperItem);
                } else {
                    arrayList2.add(viperItem);
                }
            }
            if (arrayList.size() > 0) {
                g.addAll(0, arrayList);
            }
            if (arrayList2.size() > 0) {
                g.addAll(arrayList2);
                return;
            }
            return;
        }
        g.addAll(list);
    }

    public List<ViperItem> j(int i) {
        String str;
        JSONArray jSONArray;
        int length;
        if (i == 3) {
            str = f6833b;
        } else {
            str = i == 4 ? f6832a : null;
        }
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        try {
            String K = ag.K(str);
            if (TextUtils.isEmpty(K) || (length = (jSONArray = new JSONArray(K)).length()) == 0) {
                return null;
            }
            ArrayList arrayList = new ArrayList();
            for (int i2 = 0; i2 < length; i2++) {
                ViperItem a2 = ViperItem.a(jSONArray.getJSONObject(i2));
                if (a2 != null) {
                    arrayList.add(a2);
                }
            }
            return arrayList;
        } catch (UnsupportedEncodingException e2) {
            as.e(e2);
            return null;
        } catch (JSONException e3) {
            as.e(e3);
            return null;
        }
    }

    public void c(List<ViperItem> list, int i) {
        String str;
        if (i == 3) {
            str = f6833b;
        } else {
            str = i == 4 ? f6832a : null;
        }
        if (TextUtils.isEmpty(str)) {
            return;
        }
        JSONArray jSONArray = new JSONArray();
        Iterator<ViperItem> it = list.iterator();
        while (it.hasNext()) {
            jSONArray.put(it.next().B());
        }
        ag.h(str, jSONArray.toString());
    }

    private void o() {
        if (g(this.g).size() == 0) {
            this.l.setVisibility(0);
            this.o.setVisibility(8);
        } else {
            this.r.setRefreshing();
        }
    }

    public void p() {
        if (g(this.g).size() == 0) {
            this.o.setVisibility(0);
            this.l.setVisibility(8);
            this.r.setMode(PullToRefreshBase.Mode.DISABLED);
            return;
        }
        this.r.onRefreshComplete();
    }

    public void q() {
        this.o.setVisibility(8);
        this.l.setVisibility(8);
        this.r.onRefreshComplete();
    }

    public void a(final ViperItem viperItem) {
        rx.e.a(viperItem).b(Schedulers.io()).d(new rx.b.e<ViperItem, Integer>() {
            @Override
            public Integer call(ViperItem viperItem2) {
                return Integer.valueOf(com.kugou.android.app.eq.b.d.a().a(viperItem2));
            }
        }).a(AndroidSchedulers.mainThread()).b(new rx.b.b<Integer>() {
            @Override
            public void call(Integer num) {
                if (num.intValue() != 1) {
                    ViperOtherFragment.this.a(viperItem, num.intValue());
                } else {
                    viperItem.g_(2);
                    ViperOtherFragment.this.b(viperItem);
                }
            }
        });
    }

    public void a(ViperItem viperItem, int i) {
        a_(com.kugou.android.app.eq.b.d.a(i));
        viperItem.g_(0);
        EventBus.getDefault().post(new m(0, false, viperItem));
    }

    public void b(ViperItem viperItem) {
        viperItem.g_(3);
        viperItem.j();
        com.kugou.android.app.eq.c.a(new com.kugou.android.app.eq.b(true, 0, -3));
        EventBus.getDefault().post(new m(0, true, viperItem));
        BackgroundServiceUtil.trace(new com.kugou.framework.statistics.easytrace.task.k(getActivity(), com.kugou.framework.statistics.easytrace.a.Ba, viperItem.aU_() + "使用", String.valueOf(viperItem.e()), ""));
    }

    public void onEvent(m mVar) {
        if (mVar.f6463d || mVar.f) {
            return;
        }
        boolean z = false;
        if (mVar.f6460a == 0) {
            if (((j) mVar.f6462c).F_() == 3) {
                ViperItem viperItem = (ViperItem) mVar.f6462c;
                z = a(viperItem, g(this.g));
                a(viperItem, g((this.g + 1) % 2));
            } else if (mVar.f6461b) {
                boolean a2 = a(g(this.g));
                a(g((this.g + 1) % 2));
                z = a2;
            }
        } else if (mVar.f6460a != 1 && mVar.f6461b) {
            z = a(g(this.g));
            a(g((this.g + 1) % 2));
        }
        if (z) {
            this.A.notifyDataSetChanged();
        }
    }

    public void onEventMainThread(com.kugou.android.app.eq.comment.b.b bVar) {
        try {
            int intValue = Integer.valueOf(bVar.a()).intValue();
            long b2 = bVar.b();
            boolean a2 = a(intValue, b2, g(this.g));
            a(intValue, b2, g((this.g + 1) % 2));
            if (a2) {
                this.A.notifyDataSetChanged();
            }
        } catch (NumberFormatException unused) {
        }
    }

    public boolean a(int i, long j, List<ViperItem> list) {
        for (ViperItem viperItem : list) {
            if (viperItem.e() == i) {
                viperItem.c(j);
                return true;
            }
        }
        return false;
    }

    private boolean a(ViperItem viperItem, List<ViperItem> list) {
        boolean z = false;
        for (ViperItem viperItem2 : list) {
            if (viperItem.cp_() == 3 && viperItem2.i_() != viperItem.i_() && viperItem2.cp_() == 3) {
                viperItem2.g_(2);
            } else if (viperItem2.i_() == viperItem.i_()) {
                viperItem2.g_(viperItem.cp_());
            }
            z = true;
        }
        return z;
    }

    private boolean a(List<ViperItem> list) {
        for (ViperItem viperItem : list) {
            if (viperItem.cp_() == 3) {
                viperItem.g_(2);
                return true;
            }
        }
        return false;
    }

    public void a(ViperItem viperItem, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putParcelable("key_viper_info", viperItem.p());
        bundle.putString("request_children_id", String.valueOf(viperItem.e()));
        bundle.putString("request_children_name", viperItem.aU_());
        bundle.putString("cmt_code_generator", "137f95631b6c93ca635718c0aaa86845");
        bundle.putBoolean("key_viper_scroll_comment", z);
        bundle.putString("key_viper_from", "蝰蛇音效/音效市场");
        startFragment(EqCommentsListFragment.class, bundle);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() != R.id.it) {
            return;
        }
        this.r.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
        a(true);
        n();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        com.kugou.common.q.c.b().z(this.g);
        EventBus.getDefault().unregister(this);
    }
}