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


package e.g.a.a0.c.f.x.b;

import android.app.Application;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.View;
import com.android.volley.toolbox.ImageRequest;
import com.apkpure.aegon.R;
import com.apkpure.aegon.application.AegonApplication;
import com.apkpure.aegon.application.RealApplicationLike;
import com.tencent.beacon.base.net.adapter.AbstractNetAdapter;
import com.tencent.qqdownloader.notification.QDNotification;
import com.tencent.qqdownloader.notification.QDNotificationManager;
import com.tencent.trpcprotocol.projecta.common.card.nano.Card;
import com.tencent.trpcprotocol.projecta.dynamic_popup_svr.dynamic_popup_svr.nano.PopUpCfg;
import com.tencent.trpcprotocol.projecta.dynamic_popup_svr.dynamic_popup_svr.nano.PopupStyle;
import e.g.a.a0.c.f.x.a.b;
import e.g.a.h0.b.h;
import e.g.a.i0.a1;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import o.m;
import o.p.d;
import o.s.c.j;
import o.y.l;
import p.a.k;
import s.e.c;

public class g {
    public static final s.e.a b = new c("PopUps|PopUpViewLogicAdapter");

    /* renamed from: a  reason: collision with root package name */
    public b f4862a;

    public static final class a implements e.w.d.b.e.b {
        @Override // e.w.d.b.e.b
        public void error(String str, String str2) {
            s.e.a aVar = g.b;
            StringBuilder sb = new StringBuilder();
            sb.append((Object) str);
            sb.append(',');
            sb.append((Object) str2);
            i.i.g.c.d0(((c) aVar).f16991a, sb.toString());
        }

        @Override // e.w.d.b.e.b
        public void info(String str, String str2) {
            s.e.a aVar = g.b;
            StringBuilder sb = new StringBuilder();
            sb.append((Object) str);
            sb.append(',');
            sb.append((Object) str2);
            i.i.g.c.d0(((c) aVar).f16991a, sb.toString());
        }
    }

    public void a(b bVar, View view, QDNotification qDNotification) {
        j.e(bVar, "layoutAdapter");
    }

    public e.g.a.a0.c.f.x.a.a b(e.g.a.m.f.a aVar, Card card, PopUpCfg popUpCfg, String str) {
        Set<String> keySet;
        j.e(aVar, "event");
        j.e(card, "card");
        j.e(popUpCfg, "popUpCfg");
        j.e(str, "sourceType");
        int i2 = AegonApplication.f1165e;
        Context context = RealApplicationLike.getContext();
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        Map<String, String> map = card.params;
        if (!(map == null || (keySet = map.keySet()) == null)) {
            for (T t2 : keySet) {
                j.d(t2, "it");
                linkedHashMap.put(t2, card.params.get(t2));
            }
        }
        String str2 = "2";
        if (j.a(str, str2)) {
            str2 = "1";
        } else if (!j.a(str, "3")) {
            str2 = "";
        }
        linkedHashMap.put("pop_id", Integer.valueOf(popUpCfg.id));
        linkedHashMap.put("pop_type", Integer.valueOf(popUpCfg.type));
        linkedHashMap.put("monitor_type", aVar.f6732a);
        String str3 = card.params.get("content");
        if (str3 == null) {
            str3 = card.params.get("subtitle");
        }
        linkedHashMap.put("pop_content", str3);
        linkedHashMap.put("pop_first_type", str2);
        linkedHashMap.put("link_url", popUpCfg.jumpLink);
        String string = context.getString(R.string.arg_RES_2131820587);
        int b2 = a1.b(context);
        int a2 = a1.a(context);
        PopupStyle popupStyle = popUpCfg.style;
        return new e.g.a.a0.c.f.x.a.a("https://projecta-common-1258344701.file.myqcloud.com/logo.png", string, Integer.valueOf(popupStyle == null ? 1 : popupStyle.gravityType), Integer.valueOf(b2), Integer.valueOf(a2), linkedHashMap);
    }

    public QDNotification c(Context context, e.g.a.m.f.a aVar, PopUpCfg popUpCfg, Card card) {
        Number number;
        j.e(context, "context");
        j.e(aVar, "event");
        j.e(popUpCfg, "popUpCfg");
        j.e(card, "card");
        PendingIntent activity = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), f(aVar, popUpCfg, card, "3"), 134217728);
        Map map = card.params;
        if (map == null) {
            map = new HashMap();
        }
        if (popUpCfg.type != 5) {
            PopupStyle popupStyle = popUpCfg.style;
            if ((popupStyle == null ? null : Integer.valueOf(popupStyle.autoDismissTime)) != null) {
                PopupStyle popupStyle2 = popUpCfg.style;
                Integer valueOf = popupStyle2 == null ? null : Integer.valueOf(popupStyle2.autoDismissTime);
                j.c(valueOf);
                if (valueOf.intValue() > 0) {
                    PopupStyle popupStyle3 = popUpCfg.style;
                    number = popupStyle3 == null ? null : Integer.valueOf(popupStyle3.autoDismissTime);
                    j.c(number);
                    QDNotification build = new QDNotification.Builder().setSmallIcon(R.mipmap.arg_RES_2131623938).setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher, null)).setContentTitle(d((String) map.get("mainTitle"))).setSubText(d((String) map.get("subTitle"))).setContentText(d((String) map.get("content"))).setAutoCancel(number.longValue() * ((long) ImageRequest.DEFAULT_IMAGE_TIMEOUT_MS)).setSwipeCancel(true).setContentIntent(activity).setStartIntentAutomatically(false).build();
                    j.d(build, "Builder()\n              …\n                .build()");
                    return build;
                }
            }
        }
        number = 5L;
        QDNotification build2 = new QDNotification.Builder().setSmallIcon(R.mipmap.arg_RES_2131623938).setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher, null)).setContentTitle(d((String) map.get("mainTitle"))).setSubText(d((String) map.get("subTitle"))).setContentText(d((String) map.get("content"))).setAutoCancel(number.longValue() * ((long) ImageRequest.DEFAULT_IMAGE_TIMEOUT_MS)).setSwipeCancel(true).setContentIntent(activity).setStartIntentAutomatically(false).build();
        j.d(build2, "Builder()\n              …\n                .build()");
        return build2;
    }

    public final String d(String str) {
        if (str == null || str.length() == 0) {
            return "";
        }
        String replaceAll = Pattern.compile("<[^>]+>", 2).matcher(Pattern.compile("<style[^>]*?>[\\s\\S]*?<\\/style>", 2).matcher(Pattern.compile("<script[^>]*?>[\\s\\S]*?<\\/script>", 2).matcher(str).replaceAll("")).replaceAll("")).replaceAll("");
        j.d(replaceAll, "htmlStr");
        return replaceAll;
    }

    public int e(int i2) {
        return AbstractNetAdapter.READ_TIMEOUT + i2;
    }

    public Intent f(e.g.a.m.f.a aVar, PopUpCfg popUpCfg, Card card, String str) {
        StringBuilder sb;
        j.e(aVar, "event");
        j.e(popUpCfg, "popUpCfg");
        j.e(card, "card");
        j.e(str, "sourceType");
        Map map = card.params;
        if (map == null) {
            map = new HashMap();
        }
        String str2 = (String) map.get("jumpLink");
        if (str2 == null) {
            str2 = popUpCfg.jumpLink;
        }
        StringBuilder d0 = e.d.a.a.a.d0(e.d.a.a.a.P(e.d.a.a.a.d0(e.d.a.a.a.N(e.d.a.a.a.f0("source_type=", str, "&source_push_id="), popUpCfg.id, '&'), "storage_total_size="), e.g.a.a0.c.c.d, '&'), "storage_available_size=");
        d0.append(e.g.a.a0.c.c.f4833e);
        d0.append('&');
        String k2 = j.k(d0.toString(), "is_from_push=true&");
        Map<String, String> map2 = card.params;
        String str3 = null;
        String str4 = map2 == null ? null : map2.get("recommendId");
        if (!(str4 == null || str4.length() == 0)) {
            StringBuilder d02 = e.d.a.a.a.d0(k2, "recommend_id=");
            Map<String, String> map3 = card.params;
            if (map3 != null) {
                str3 = map3.get("recommendId");
            }
            k2 = e.d.a.a.a.R(d02, str3, '&');
        }
        j.d(str2, "jumpLink");
        if (l.b(str2, "?", false, 2)) {
            sb = new StringBuilder();
            sb.append((Object) str2);
            sb.append('&');
        } else {
            sb = new StringBuilder();
            sb.append((Object) str2);
            sb.append('?');
        }
        sb.append(k2);
        Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(sb.toString()));
        intent.putExtra("source_position", 0);
        intent.putExtra("source_small_position", 0);
        intent.putExtra("source_type", 2);
        return intent;
    }

    public int g() {
        return R.layout.notification_message_pop;
    }

    public Object h(e.g.a.m.f.a aVar, boolean z, PopUpCfg popUpCfg, d<? super Boolean> dVar) {
        k kVar = new k(k.g.c.O(dVar), 1);
        kVar.v();
        kVar.A(Boolean.TRUE, kVar.d, h.b);
        Object u = kVar.u();
        if (u == o.p.i.a.COROUTINE_SUSPENDED) {
            j.e(dVar, "frame");
        }
        return u;
    }

    public void i(e.g.a.m.f.a aVar, o.s.b.l<Object, m> lVar) {
        j.e(aVar, "event");
        j.e(lVar, "callback");
        ((e.g.a.a0.c.f.m) lVar).invoke(new LinkedHashMap());
    }

    public void j(e.g.a.m.f.a aVar, PopUpCfg popUpCfg, Card card) {
        Object obj;
        Object obj2;
        Object obj3;
        Object obj4;
        Object obj5;
        String str;
        String str2;
        j.e(aVar, "event");
        j.e(popUpCfg, "popUpCfg");
        j.e(card, "card");
        int i2 = AegonApplication.f1165e;
        Application application = RealApplicationLike.getApplication();
        e.g.a.a0.c.f.x.a.a b2 = b(aVar, card, popUpCfg, "3");
        HashMap hashMap = new HashMap();
        Map<String, Object> map = b2.f4851f;
        Object obj6 = null;
        if (map == null) {
            obj = null;
        } else {
            obj = map.get("pop_id");
        }
        hashMap.put("pop_id", obj);
        Map<String, Object> map2 = b2.f4851f;
        if (map2 == null) {
            obj2 = null;
        } else {
            obj2 = map2.get("pop_type");
        }
        hashMap.put("pop_type", obj2);
        Map<String, Object> map3 = b2.f4851f;
        if (map3 == null) {
            obj3 = null;
        } else {
            obj3 = map3.get("monitor_type");
        }
        hashMap.put("monitor_type", obj3);
        Map<String, Object> map4 = b2.f4851f;
        if (map4 == null) {
            obj4 = null;
        } else {
            obj4 = map4.get("pop_content");
        }
        hashMap.put("pop_content", obj4);
        Map<String, Object> map5 = b2.f4851f;
        if (map5 == null) {
            obj5 = null;
        } else {
            obj5 = map5.get("pop_first_type");
        }
        hashMap.put("pop_first_type", obj5);
        Map<String, Object> map6 = b2.f4851f;
        if (map6 != null) {
            obj6 = map6.get("link_url");
        }
        hashMap.put("link_url", obj6);
        Map<String, String> map7 = card.params;
        String str3 = "";
        if (map7 == null || (str = map7.get("recommendId")) == null) {
            str = str3;
        }
        hashMap.put("recommend_id", str);
        long j2 = e.g.a.a0.c.c.d;
        if (j2 <= 0) {
            str2 = str3;
        } else {
            str2 = String.valueOf(j2);
        }
        hashMap.put("storage_total_size", str2);
        long j3 = e.g.a.a0.c.c.f4833e;
        if (j3 > 0) {
            str3 = String.valueOf(j3);
        }
        hashMap.put("storage_available_size", str3);
        View view = new View(application);
        h.s(view, "pop", hashMap, false);
        h.o("imp", view, hashMap);
        j.d(application, "application");
        QDNotification c = c(application, aVar, popUpCfg, card);
        QDNotificationManager gDefault = QDNotificationManager.gDefault();
        gDefault.setUseSystemNotification(true);
        gDefault.setUseFloatNotification(false);
        try {
            gDefault.notify(e(popUpCfg.type), c);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
}