OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046

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


package com.excelliance.kxqp.ui.detail.comment;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.excean.ggspace.main.R;
import com.excelliance.kxqp.bitmap.bean.RankingItem;
import com.excelliance.kxqp.gs.base.BaseLazyFragment;
import com.excelliance.kxqp.gs.i.d;
import com.excelliance.kxqp.gs.ui.gaccount.receive.e;
import com.excelliance.kxqp.gs.ui.question.WebNoVideoActivity;
import com.excelliance.kxqp.gs.util.bx;
import com.excelliance.kxqp.gs.util.s;
import com.excelliance.kxqp.gs.util.x;
import com.excelliance.kxqp.ui.comment.BasicRecyclerAdapter;
import com.excelliance.kxqp.ui.comment.b.a;
import com.excelliance.kxqp.ui.comment.complaint.CommentComplainActivity;
import com.excelliance.kxqp.ui.comment.detail.CommentDetailActivity;
import com.excelliance.kxqp.ui.comment.subscribe.SubmitCommentActivity;
import com.excelliance.kxqp.ui.detail.RankingDetailActivity;
import com.excelliance.kxqp.ui.detail.RankingDetailInfo;
import com.excelliance.kxqp.ui.detail.comment.ViewCommentMine;
import com.excelliance.kxqp.ui.detail.comment.a;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.cookie.ClientCookie;

public class CommentFragment extends BaseLazyFragment<a.InterfaceC0583a> implements com.excelliance.kxqp.gs.i.b, a.b {
    private RankingDetailInfo A;
    private Comment B;

    private RecyclerView f14450a;
    private View m;
    private ImageView n;
    private CommentAdapter o;
    private com.excelliance.kxqp.gs.i.a p;
    private String s;
    private ViewCommentSummary t;
    private ViewCommentMine u;
    private TextView v;
    private com.excelliance.kxqp.ui.comment.b.a w;
    private List<String> x;
    private List<String> y;
    private boolean q = true;
    private int r = 1;
    private boolean z = false;
    private int C = 0;
    private View.OnClickListener D = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (CommentFragment.this.u.getState()) {
                case 0:
                    CommentFragment.this.o();
                    return;
                case 1:
                    CommentFragment.this.q();
                    return;
                case 2:
                    CommentFragment.this.r();
                    return;
                case 3:
                    ((a.InterfaceC0583a) CommentFragment.this.h).a();
                    return;
                default:
                    return;
            }
        }
    };
    private final View.OnClickListener E = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
        }
    };
    private final View.OnClickListener F = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            CommentFragment.this.o();
        }
    };
    private final View.OnClickListener G = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            CommentFragment.this.r();
        }
    };
    private final View.OnClickListener H = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (bx.a().b(CommentFragment.this.d)) {
                ((a.InterfaceC0583a) CommentFragment.this.h).a();
            }
        }
    };
    private ViewCommentMine.a I = new ViewCommentMine.a() {
        @Override
        public void a(View view) {
            CommentFragment.this.n();
        }

        @Override
        public void b(View view) {
            CommentFragment.this.a(view);
        }

        @Override
        public void c(View view) {
            CommentFragment.this.c(CommentFragment.this.B);
        }

        @Override
        public void d(View view) {
            CommentFragment.this.c(CommentFragment.this.B);
        }
    };
    private final d J = new d() {
        @Override
        public void a(View view, Object obj, int i) {
            CommentFragment.this.d(CommentFragment.this.o.l().get(i));
        }
    };
    private final BasicRecyclerAdapter.a K = new BasicRecyclerAdapter.a() {
        @Override
        public void a(int i, View view) {
            if (view.getId() == R.id.tv_like) {
                if (CommentFragment.this.s()) {
                    Comment comment = CommentFragment.this.o.l().get(i);
                    boolean z = !(x.a(comment.isLiked) == 1);
                    int a2 = x.a(comment.likeNum) + (z ? 1 : -1);
                    ((a.InterfaceC0583a) CommentFragment.this.h).a(comment, z);
                    comment.isLiked = z ? "1" : "0";
                    comment.likeNum = String.valueOf(a2);
                    if (a2 > 0) {
                        ((TextView) view).setText(comment.likeNum);
                    } else {
                        ((TextView) view).setText(R.string.comment_item_like);
                    }
                    view.setSelected(z);
                    return;
                }
                CommentFragment.this.r();
                return;
            }
            if (view.getId() == R.id.tv_comment || view.getId() == R.id.tv_view_more || view.getId() == R.id.layout_main_comment) {
                CommentFragment.this.b(CommentFragment.this.o.l().get(i));
            } else if (view.getId() == R.id.tv_more) {
                CommentFragment.this.d(CommentFragment.this.o.l().get(i));
            }
        }
    };

    @Override
    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            this.s = arguments.getString("pkgName");
        }
        this.x = new ArrayList<String>() {
            {
                add(CommentFragment.this.d.getString(R.string.comment_option_edit));
                add(CommentFragment.this.d.getString(R.string.comment_option_share));
                add(CommentFragment.this.d.getString(R.string.comment_option_delete));
            }
        };
        this.y = new ArrayList<String>() {
            {
                add(CommentFragment.this.d.getString(R.string.comment_option_complain));
            }
        };
    }

    @Override
    protected void b() {
        this.f14450a = (RecyclerView) b("recycler_view");
        this.f14450a.setLayoutManager(new LinearLayoutManager(this.d));
        l();
        this.o = new CommentAdapter(this.d, null, this.m);
        this.o.a((com.excelliance.kxqp.gs.i.b) this);
        this.o.a(this.K);
        this.o.b(this.J);
        this.f14450a.setAdapter(this.o);
        this.p = new e(this.d);
        this.p.a(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CommentFragment.this.m();
            }
        });
        this.p.a((ViewGroup) this.f14450a.getParent(), this.f14450a);
        this.n = (ImageView) b("iv_edit");
        this.n.setOnClickListener(this);
    }

    @Override
    protected int d() {
        return R.layout.fragment_detail_comment;
    }

    @Override
    public a.InterfaceC0583a e() {
        return new CommentPresenter(this.d, this.s, this);
    }

    public void a(RankingDetailInfo rankingDetailInfo) {
        if (rankingDetailInfo != null) {
            this.A = rankingDetailInfo;
            f();
        }
    }

    public void b(boolean z) {
        this.z = z;
    }

    private void f() {
        if (this.t != null) {
            this.t.setAppType(this.A.apkType);
            this.t.a(this.A.getXs_score(), this.A.getGp_score());
            this.t.a(this.A.sub1, this.A.sub2, this.A.sub3, this.A.sub4);
        }
    }

    private void l() {
        this.m = LayoutInflater.from(this.d).inflate(R.layout.item_app_comment_header, (ViewGroup) this.f14450a, false);
        this.t = (ViewCommentSummary) this.m.findViewById(R.id.vcr_summary);
        this.u = (ViewCommentMine) this.m.findViewById(R.id.vcm_mine);
        this.v = (TextView) this.m.findViewById(R.id.tv_comment_count);
        this.u.setCallback(this.I);
        this.u.setComment(null);
        this.u.setOnClickListener(this.D);
    }

    private void a(Comment comment) {
        this.B = comment;
        this.u.setComment(comment);
    }

    @Override
    public void onViewCreated(View view, Bundle bundle) {
        super.onViewCreated(view, bundle);
        this.h = e();
        this.r = 1;
        ((a.InterfaceC0583a) this.h).a(this.r, 10);
        if (s()) {
            ((a.InterfaceC0583a) this.h).a();
        }
    }

    @Override
    public void a(Comment comment, boolean z) {
        if (z) {
            a(comment);
        } else {
            this.u.setState(3);
        }
        if (z && comment != null) {
            this.o.a(this.d.getString(R.string.comment_no_more_default));
            if (getActivity() == null || !(getActivity() instanceof RankingDetailActivity)) {
                return;
            }
            ((RankingDetailActivity) getActivity()).a(this.C + 1);
            return;
        }
        this.o.a(this.d.getString(R.string.comment_no_more_version_1));
        if (getActivity() == null || !(getActivity() instanceof RankingDetailActivity)) {
            return;
        }
        ((RankingDetailActivity) getActivity()).a(this.C);
    }

    @Override
    public void a(List<Comment> list, int i, boolean z) {
        if (z) {
            if (this.q) {
                this.p.a();
                this.o.b(list);
                if (s.a(list) || list.size() < 10) {
                    this.o.f();
                }
            } else {
                this.o.a(list);
                if (s.a(list) || list.size() < 10) {
                    this.o.f();
                } else {
                    this.o.g();
                }
            }
            this.v.setVisibility(i > 0 ? 0 : 8);
            this.v.setText("[" + i + "]");
        } else if (this.q) {
            this.p.b(this.d.getString(R.string.recommend_nodata_try));
        } else {
            this.o.h();
        }
        if (getActivity() == null || !(getActivity() instanceof RankingDetailActivity)) {
            return;
        }
        this.C = i;
        ((RankingDetailActivity) getActivity()).a(i + (this.B != null ? 1 : 0));
    }

    @Override
    public void a(boolean z) {
        if (z) {
            Toast.makeText(this.d, R.string.comment_delete_success, 0).show();
            ((a.InterfaceC0583a) this.h).a();
        } else {
            Toast.makeText(this.d, R.string.comment_delete_failed, 0).show();
        }
    }

    @Override
    public void a() {
        if (this.q) {
            this.p.a("加载中...");
        }
    }

    @Override
    public void g() {
        this.q = false;
        this.r++;
        m();
    }

    public void m() {
        ((a.InterfaceC0583a) this.h).a(this.r, 10);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (this.h != 0) {
            ((a.InterfaceC0583a) this.h).c();
        }
    }

    @Override
    public void singleClick(View view) {
        super.singleClick(view);
        if (view.getId() == this.n.getId()) {
            o();
        }
    }

    public class a implements a.InterfaceC0538a {

        private Comment f14467b;

        public a(Comment comment) {
            this.f14467b = comment;
        }

        @Override
        public void a(int i) {
            if (!CommentFragment.this.s()) {
                CommentFragment.this.r();
            } else if (i == 0) {
                CommentComplainActivity.a(CommentFragment.this.d, this.f14467b);
            }
        }
    }

    public void n() {
        if (this.B == null) {
            return;
        }
        if (this.w == null) {
            this.w = new com.excelliance.kxqp.ui.comment.b.a(getActivity());
        }
        this.w.a(this.x, new a.InterfaceC0538a() {
            @Override
            public void a(int i) {
                if (i == 0) {
                    CommentFragment.this.q();
                    return;
                }
                if (i == 1) {
                    int b2 = (int) x.b(CommentFragment.this.B.grade);
                    CommentFragment.this.a(CommentFragment.this.B.content, b2, false);
                } else if (i == 2) {
                    com.excelliance.kxqp.ui.comment.a.a.a(CommentFragment.this.d, new Runnable() {
                        @Override
                        public void run() {
                            ((a.InterfaceC0583a) CommentFragment.this.h).a(CommentFragment.this.B);
                        }
                    });
                }
            }
        });
        this.w.a(getActivity().findViewById(android.R.id.content));
    }

    public void a(View view) {
        if (this.B != null) {
            boolean z = !(x.a(this.B.isLiked) == 1);
            int a2 = x.a(this.B.likeNum) + (z ? 1 : -1);
            ((a.InterfaceC0583a) this.h).a(this.B, z);
            this.B.isLiked = z ? "1" : "0";
            this.B.likeNum = String.valueOf(a2);
            if (a2 > 0) {
                ((TextView) view).setText(this.B.likeNum);
            } else {
                ((TextView) view).setText(this.d.getString(R.string.comment_item_like));
            }
            view.setSelected(z);
        }
    }

    public void o() {
        if (!s()) {
            r();
        } else if (this.z) {
            p();
        } else {
            a(2560, (Bundle) null);
        }
    }

    private void p() {
        if (getActivity() == null || !(getActivity() instanceof RankingDetailActivity)) {
            return;
        }
        RankingDetailActivity rankingDetailActivity = (RankingDetailActivity) getActivity();
        if (this.B == null) {
            SubmitCommentActivity.a(this, 1000, rankingDetailActivity.c());
        } else {
            SubmitCommentActivity.a(this, 1001, rankingDetailActivity.c(), this.B);
        }
    }

    public void b(Comment comment) {
        if (!s()) {
            r();
        } else {
            if (this.z) {
                c(comment);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putParcelable(ClientCookie.COMMENT_ATTR, comment);
            a(3856, bundle);
        }
    }

    public void c(Comment comment) {
        if (comment == null || getActivity() == null || !(getActivity() instanceof RankingDetailActivity) || this.A == null) {
            return;
        }
        RankingDetailActivity rankingDetailActivity = (RankingDetailActivity) getActivity();
        CommentDetailActivity.a(this, 7881, Integer.valueOf(comment.commentId).intValue(), this.A.getPkgname(), rankingDetailActivity.f(), rankingDetailActivity.g());
    }

    private void a(final int i, final Bundle bundle) {
        com.excelliance.kxqp.ui.comment.a.b.a(this.d, null, new Runnable() {
            @Override
            public void run() {
                if (!bx.a().b(CommentFragment.this.d)) {
                    Toast.makeText(CommentFragment.this.d, "请先登录", 0).show();
                    return;
                }
                StringBuilder sb = new StringBuilder("https://h5.ourplay.com.cn/commanswer");
                try {
                    sb.append("?rid=" + URLEncoder.encode(bx.a().a(CommentFragment.this.d), "UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                WebNoVideoActivity.startActivityForResult(CommentFragment.this, i, sb.toString(), bundle);
            }
        });
    }

    public void q() {
        if (this.A != null) {
            SubmitCommentActivity.a(this, 1001, this.A, this.B);
        }
    }

    public void r() {
        com.excelliance.kxqp.gs.router.a.a.f8074a.invokeLoginWithBundle(this, 8312, new Bundle());
    }

    public void d(Comment comment) {
        if (this.w == null) {
            this.w = new com.excelliance.kxqp.ui.comment.b.a(this.c);
        }
        this.w.a(this.y, new a(comment));
        this.w.a(getActivity().findViewById(android.R.id.content));
    }

    public boolean s() {
        return bx.a().b(this.d);
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        int intExtra;
        if (i == 1000 && i2 == -1) {
            a(intent.getStringExtra("content"), intent.getIntExtra(RankingItem.KEY_STAR, 0), true);
            ((a.InterfaceC0583a) this.h).a();
        }
        if (i == 1001 && i2 == -1) {
            ((a.InterfaceC0583a) this.h).a();
        }
        if (i == 2560 && i2 == -1 && TextUtils.equals(intent.getStringExtra("data"), "OK")) {
            this.z = true;
            p();
        }
        if (i == 3856 && i2 == -1 && TextUtils.equals(intent.getStringExtra("data"), "OK")) {
            this.z = true;
            try {
                c((Comment) intent.getBundleExtra("bundle").getParcelable(ClientCookie.COMMENT_ATTR));
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }
        if (i == 7881 && i2 == -1 && (intExtra = intent.getIntExtra("id", 0)) > 0) {
            if (this.B != null && TextUtils.equals(this.B.commentId, String.valueOf(intExtra))) {
                ((a.InterfaceC0583a) this.h).a();
            } else {
                this.q = true;
                this.r = 1;
                ((a.InterfaceC0583a) this.h).a(this.r, 10);
            }
        }
        if (i == 8312 && i2 == -1) {
            ((a.InterfaceC0583a) this.h).a();
            this.q = true;
            this.r = 1;
            ((a.InterfaceC0583a) this.h).a(this.r, 10);
        }
        super.onActivityResult(i, i2, intent);
    }

    public void a(String str, int i, boolean z) {
        if (getActivity() == null || !(getActivity() instanceof RankingDetailActivity)) {
            return;
        }
        RankingDetailInfo c = ((RankingDetailActivity) getActivity()).c();
        com.excelliance.kxqp.ui.comment.subscribe.b.a(this.d, c.getIcon(), c.getName(), String.valueOf(c.getRank_id()), c.getTitlepic(), i, str, z);
    }
}