APKPure.apk(点击下载) / f.java


package e.g.a.s.k;

import android.content.Context;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.MenuItem;
import android.view.View;
import com.apkpure.aegon.R;
import com.apkpure.aegon.person.login.LoginUser;
import com.apkpure.aegon.post.model.CommentSelectionDigest;
import com.apkpure.proto.nano.AppDetailInfoProtos;
import com.apkpure.proto.nano.CmsResponseProtos;
import com.apkpure.proto.nano.CommentInfoProtos;
import com.apkpure.proto.nano.ReferInfoProtos;
import com.apkpure.proto.nano.ResultResponseProtos;
import com.apkpure.proto.nano.UserInfoProtos;
import e.g.a.e.f.d2;
import e.g.a.i0.n0;
import e.g.a.m0.i;
import e.g.a.v.o;
import e.g.a.z.d;
import e.g.a.z.n.h;
import i.b.g.i.g;
import i.b.h.l0;
import i.o.c.l;

public class f implements l0.a {

    /* renamed from: a  reason: collision with root package name */
    public CommentInfoProtos.CommentInfo f7090a;
    public AppDetailInfoProtos.AppDetailInfo b;
    public SparseArray<ReferInfoProtos.ReferInfo> c = new SparseArray<>();
    public Context d;

    /* renamed from: e  reason: collision with root package name */
    public c f7091e;

    /* renamed from: f  reason: collision with root package name */
    public String f7092f;

    /* renamed from: g  reason: collision with root package name */
    public l f7093g;

    public class a implements o {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ int f7094a;

        public a(int i2) {
            this.f7094a = i2;
        }

        @Override // e.g.a.v.o
        public void a(String str, String str2) {
            f.this.f7091e.a(str, str2, this.f7094a);
        }

        @Override // e.g.a.v.o
        public void b(ResultResponseProtos.ResponseWrapper responseWrapper) {
            f.this.f7091e.b(this.f7094a);
        }
    }

    public class b implements o {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ int f7095a;
        public final /* synthetic */ CommentInfoProtos.CommentInfo b;

        public b(int i2, CommentInfoProtos.CommentInfo commentInfo) {
            this.f7095a = i2;
            this.b = commentInfo;
        }

        @Override // e.g.a.v.o
        public void a(String str, String str2) {
            f.this.f7091e.a(str, str2, this.f7095a);
        }

        @Override // e.g.a.v.o
        public void b(ResultResponseProtos.ResponseWrapper responseWrapper) {
            f.this.f7091e.b(this.f7095a);
            new k(this.f7095a, this.b.aiHeadlineInfo).b();
        }
    }

    public interface c {
        void a(String str, String str2, int i2);

        void b(int i2);
    }

    public f(Context context, CmsResponseProtos.CmsItemList cmsItemList) {
        CommentInfoProtos.CommentInfo commentInfo = cmsItemList.commentInfo;
        this.f7090a = commentInfo;
        this.b = cmsItemList.appInfo;
        this.d = context;
        d(commentInfo);
    }

    public f(Context context, CmsResponseProtos.CmsItemList cmsItemList, e.g.a.i.d0.a aVar) {
        this.d = context;
        CommentInfoProtos.CommentInfo commentInfo = cmsItemList.commentInfo;
        this.f7090a = commentInfo;
        this.b = cmsItemList.appInfo;
        d(commentInfo);
    }

    public f(Context context, CommentInfoProtos.CommentInfo commentInfo, AppDetailInfoProtos.AppDetailInfo appDetailInfo) {
        this.f7090a = commentInfo;
        this.b = appDetailInfo;
        this.d = context;
        d(commentInfo);
    }

    public final void a(CommentInfoProtos.CommentInfo commentInfo, int i2) {
        if (!i.i.d.c.J(this.d)) {
            n0.V(this.d);
        } else if (!TextUtils.isEmpty(String.valueOf(commentInfo.id))) {
            CommentSelectionDigest commentSelectionDigest = new CommentSelectionDigest();
            commentSelectionDigest.a(String.valueOf(commentInfo.id));
            e.g.a.s.l.a.w0(this.d, commentSelectionDigest, e.g.a.s.l.a.O("comment/cancel_collect_comment"), new b(i2, commentInfo));
        }
    }

    public final void b(CommentInfoProtos.CommentInfo commentInfo, int i2) {
        if (!i.i.d.c.J(this.d)) {
            n0.V(this.d);
        } else if (commentInfo != null && !TextUtils.isEmpty(String.valueOf(commentInfo.id))) {
            CommentSelectionDigest commentSelectionDigest = new CommentSelectionDigest();
            commentSelectionDigest.a(String.valueOf(commentInfo.id));
            AppDetailInfoProtos.AppDetailInfo appDetailInfo = this.b;
            commentSelectionDigest.c(appDetailInfo == null ? "" : appDetailInfo.packageName);
            e.g.a.s.l.a.w0(this.d, commentSelectionDigest, e.g.a.s.l.a.O("comment/collect_comment"), new a(i2));
        }
    }

    public l0 c(View view) {
        Context context = view.getContext();
        l0 l0Var = new l0(context, view);
        l0Var.a().inflate(R.menu.arg_RES_2131558410, l0Var.b);
        g gVar = l0Var.b;
        UserInfoProtos.UserInfo userInfo = this.f7090a.author;
        MenuItem findItem = gVar.findItem(R.id.arg_RES_2131296365);
        MenuItem findItem2 = gVar.findItem(R.id.arg_RES_2131296342);
        MenuItem findItem3 = gVar.findItem(R.id.arg_RES_2131296348);
        MenuItem findItem4 = gVar.findItem(R.id.arg_RES_2131296338);
        MenuItem findItem5 = gVar.findItem(R.id.arg_RES_2131296331);
        if (i.i.d.c.J(context)) {
            LoginUser.User t2 = i.i.d.c.t(context);
            findItem.setVisible(!TextUtils.equals(String.valueOf(t2.m()), userInfo.id));
            findItem2.setVisible(TextUtils.equals(String.valueOf(t2.m()), userInfo.id));
            findItem3.setVisible(false);
            findItem4.setVisible(!this.f7090a.isCollect);
            findItem5.setVisible(this.f7090a.isCollect);
            if (this.c.size() > 0) {
                for (int i2 = 0; i2 < this.c.size(); i2++) {
                    int keyAt = this.c.keyAt(i2);
                    ReferInfoProtos.ReferInfo referInfo = this.c.get(keyAt);
                    if (referInfo != null) {
                        gVar.add(0, keyAt, i2, referInfo.isFollow ? context.getString(R.string.arg_RES_2131821884, referInfo.name) : context.getString(R.string.arg_RES_2131821013, referInfo.name));
                    }
                }
            }
        } else {
            findItem.setVisible(true);
            findItem2.setVisible(false);
            findItem3.setVisible(false);
            findItem4.setVisible(false);
            findItem5.setVisible(false);
        }
        return l0Var;
    }

    public final void d(CommentInfoProtos.CommentInfo commentInfo) {
        ReferInfoProtos.ReferInfo[] referInfoArr;
        this.c.clear();
        if (commentInfo != null && (referInfoArr = commentInfo.refersInfo) != null && referInfoArr.length > 0) {
            int i2 = 0;
            while (true) {
                ReferInfoProtos.ReferInfo[] referInfoArr2 = commentInfo.refersInfo;
                if (i2 < referInfoArr2.length) {
                    this.c.put(-1 - i2, referInfoArr2[i2]);
                    i2++;
                } else {
                    return;
                }
            }
        }
    }

    @Override // i.b.h.l0.a
    public boolean onMenuItemClick(MenuItem menuItem) {
        UserInfoProtos.UserInfo userInfo;
        l lVar;
        String str;
        e.g.a.i0.c2.a aVar = e.g.a.i0.c2.a.f6490a;
        if (this.f7090a == null || this.d == null) {
            return false;
        }
        int itemId = menuItem.getItemId();
        ReferInfoProtos.ReferInfo referInfo = this.c.size() > 0 ? this.c.get(itemId) : null;
        if (referInfo != null) {
            int i2 = referInfo.isFollow ? R.id.arg_RES_2131296373 : R.id.arg_RES_2131296349;
            if (TextUtils.equals(referInfo.type, "APP")) {
                String str2 = referInfo.typeId;
                if (!(str2 == null || referInfo.type == null || referInfo.name == null)) {
                    e.g.a.s.l.a.u(!referInfo.isFollow, this.d, str2, new j(this, referInfo, i2));
                }
            } else if (TextUtils.equals(referInfo.type, "USER")) {
                String str3 = referInfo.typeId;
                if (!(str3 == null || referInfo.type == null || referInfo.name == null)) {
                    e.d.a.a.a.g(this.d, e.g.a.s.l.a.s(this.d, str3, !referInfo.isFollow).e(aVar)).a(new h(this, referInfo, i2));
                }
            } else if (!(!TextUtils.equals(referInfo.type, "HASHTAG") || (str = referInfo.typeId) == null || referInfo.type == null || referInfo.name == null)) {
                e.d.a.a.a.g(this.d, e.g.a.s.l.a.t(this.d, str, !referInfo.isFollow).e(aVar)).a(new i(this, referInfo, i2));
            }
            return true;
        }
        String str4 = "";
        switch (itemId) {
            case R.id.arg_RES_2131296331 /*{ENCODED_INT: 2131296331}*/:
                a(this.f7090a, itemId);
                new k(itemId, this.f7090a.aiHeadlineInfo).b();
                return true;
            case R.id.arg_RES_2131296337 /*{ENCODED_INT: 2131296337}*/:
                if (menuItem.isChecked()) {
                    a(this.f7090a, itemId);
                } else {
                    b(this.f7090a, itemId);
                }
                new k(itemId, this.f7090a.aiHeadlineInfo, menuItem.isChecked() ? 23 : 22).b();
                return true;
            case R.id.arg_RES_2131296338 /*{ENCODED_INT: 2131296338}*/:
                b(this.f7090a, itemId);
                if ("HeadLine".equals(this.f7092f)) {
                    Context context = this.d;
                    e.g.a.s.f.f(context, context.getString(R.string.arg_RES_2131821192), this.f7090a.id);
                }
                new k(itemId, this.f7090a.aiHeadlineInfo).b();
                return true;
            case R.id.arg_RES_2131296342 /*{ENCODED_INT: 2131296342}*/:
                CommentInfoProtos.CommentInfo commentInfo = this.f7090a;
                i iVar = new i(this.d);
                iVar.l(R.string.arg_RES_2131820895);
                iVar.d(R.string.arg_RES_2131820896);
                iVar.j(R.string.arg_RES_2131820890, new b(this, commentInfo, itemId)).f(17039360, null).n();
                return true;
            case R.id.arg_RES_2131296365 /*{ENCODED_INT: 2131296365}*/:
                if ("HeadLine".equals(this.f7092f)) {
                    Context context2 = this.d;
                    AppDetailInfoProtos.AppDetailInfo appDetailInfo = this.b;
                    if (appDetailInfo != null) {
                        str4 = appDetailInfo.packageName;
                    }
                    e.f.a.e.c.h0(context2, str4, String.valueOf(this.f7090a.id), null, "HeadLine");
                } else {
                    Context context3 = this.d;
                    AppDetailInfoProtos.AppDetailInfo appDetailInfo2 = this.b;
                    if (appDetailInfo2 != null) {
                        str4 = appDetailInfo2.packageName;
                    }
                    e.f.a.e.c.h0(context3, str4, String.valueOf(this.f7090a.id), null, null);
                }
                new k(itemId, this.f7090a.aiHeadlineInfo).b();
                c cVar = this.f7091e;
                if (cVar != null) {
                    cVar.b(R.id.arg_RES_2131296365);
                }
                return true;
            case R.id.arg_RES_2131296368 /*{ENCODED_INT: 2131296368}*/:
                CommentInfoProtos.CommentInfo commentInfo2 = this.f7090a;
                if (!(commentInfo2 == null || (userInfo = commentInfo2.author) == null || (lVar = this.f7093g) == null)) {
                    if (this.b == null) {
                        String str5 = userInfo.id;
                        long j2 = commentInfo2.id;
                        d2 d2Var = d2.f5385e;
                        h.d(lVar, String.format("%s/u/%s/post/%s", "https://apkpure.com", str5, Long.valueOf(j2)));
                    } else if (!TextUtils.isEmpty(String.valueOf(commentInfo2.id))) {
                        l lVar2 = this.f7093g;
                        String str6 = this.b.packageName;
                        CommentInfoProtos.CommentInfo commentInfo3 = this.f7090a;
                        Object obj = h.f7767a;
                        String valueOf = String.valueOf(commentInfo3.id);
                        d2 d2Var2 = d2.f5385e;
                        if (!TextUtils.isEmpty(str6) && !TextUtils.isEmpty(valueOf)) {
                            str4 = String.format("%s/group/%s/%s?hl=%s", "https://apkpure.com", str6, valueOf, d.c());
                        }
                        h.d(lVar2, str4);
                    }
                }
                new k(itemId, this.f7090a.aiHeadlineInfo).b();
                return true;
            default:
                return false;
        }
    }
}