翰林优商.apk(点击下载) / a.java


package com.mbridge.msdk.interstitial.c;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.c.d;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.tools.w;
import com.mbridge.msdk.interstitial.view.MBInterstitialActivity;
import com.mbridge.msdk.out.InterstitialListener;
import com.mbridge.msdk.out.MBridgeIds;
import java.util.HashMap;
import java.util.Map;

/* compiled from: InterstitialController */
public final class a {
    public static String a;
    public static Map<String, Integer> c = new HashMap();
    public static Map<String, Integer> d = new HashMap();
    public static Map<String, c> e = new HashMap();
    public boolean b = false;
    private String f = "InterstitialController";
    private Context g;
    private String h;
    private String i;
    private String j;
    private MBridgeIds k;
    private Handler l;
    private d m;
    private InterstitialListener n;
    private String o = "";
    private String p = "";
    private boolean q = false;

    public static void a(String str, int i2) {
        try {
            if (c != null && !TextUtils.isEmpty(str)) {
                c.put(str, Integer.valueOf(i2));
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public static int a(String str) {
        Map<String, Integer> map;
        Integer num;
        try {
            if (TextUtils.isEmpty(str) || (map = c) == null || !map.containsKey(str) || (num = c.get(str)) == null) {
                return 0;
            }
            return num.intValue();
        } catch (Exception e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public final void a(InterstitialListener interstitialListener) {
        this.n = interstitialListener;
    }

    public a() {
        try {
            this.l = new Handler(Looper.getMainLooper()) {
                /* class com.mbridge.msdk.interstitial.c.a.AnonymousClass1 */

                public final void handleMessage(Message message) {
                    if (message != null) {
                        int i = message.what;
                        if (i != 1) {
                            String str = "can't show because unknow error";
                            String str2 = "";
                            if (i != 2) {
                                if (i == 3) {
                                    a.this.b = true;
                                    if (a.this.n != null) {
                                        a.this.n.onInterstitialShowSuccess(a.this.k);
                                        w.b(a.this.f, "handler 数据show成功");
                                    }
                                } else if (i != 4) {
                                    if (i != 6) {
                                        if (i == 7) {
                                            a.this.b = false;
                                            if (a.this.n != null) {
                                                a.this.n.onInterstitialClosed(a.this.k);
                                            }
                                        }
                                    } else if (a.this.n != null) {
                                        a.this.n.onInterstitialAdClick(a.this.k);
                                    }
                                } else if (a.this.n != null) {
                                    if (message.obj != null && (message.obj instanceof String)) {
                                        str2 = (String) message.obj;
                                    }
                                    if (!TextUtils.isEmpty(str2)) {
                                        str = str2;
                                    }
                                    a.this.n.onInterstitialShowFail(a.this.k, str);
                                    String str3 = a.this.f;
                                    w.b(str3, "handler 数据show失败:" + str);
                                }
                            } else if (a.this.n != null) {
                                if (message.obj != null && (message.obj instanceof String)) {
                                    str2 = (String) message.obj;
                                }
                                if (!TextUtils.isEmpty(str2)) {
                                    str = str2;
                                }
                                a.this.n.onInterstitialLoadFail(a.this.k, str);
                                String str4 = a.this.f;
                                w.b(str4, "handler 数据load失败:" + str);
                            }
                        } else if (a.this.n != null) {
                            a.this.n.onInterstitialLoadSuccess(a.this.k);
                            w.b(a.this.f, "handler 数据load成功");
                        }
                    }
                }
            };
        } catch (Exception e2) {
            try {
                e2.printStackTrace();
            } catch (Exception e3) {
                e3.printStackTrace();
            }
        }
    }

    public final boolean a(Context context, Map<String, Object> map) {
        try {
            this.q = false;
            if (map == null) {
                w.c(this.f, "init error params==null");
                return false;
            } else if (context == null) {
                w.c(this.f, "init context ==null");
                return false;
            } else {
                if (map.containsKey(MBridgeConstans.PROPERTIES_UNIT_ID)) {
                    if (map.get(MBridgeConstans.PROPERTIES_UNIT_ID) instanceof String) {
                        if (map.containsKey(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY) && (map.get(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY) instanceof String)) {
                            this.h = (String) map.get(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY);
                        }
                        this.i = (String) map.get(MBridgeConstans.PROPERTIES_UNIT_ID);
                        this.g = context;
                        if (map.containsKey(MBridgeConstans.PLACEMENT_ID) && map.get(MBridgeConstans.PLACEMENT_ID) != null) {
                            this.j = (String) map.get(MBridgeConstans.PLACEMENT_ID);
                        }
                        this.k = new MBridgeIds(this.j, this.i);
                        this.q = true;
                        return this.q;
                    }
                }
                w.c(this.f, "init error,make sure you have unitid");
                return false;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            this.q = false;
        }
    }

    public final void a() {
        try {
            if (this.g == null) {
                b("context is null");
                w.b(this.f, "load context is null");
            } else if (TextUtils.isEmpty(this.i)) {
                b("unitid is null");
                w.b(this.f, "load unitid is null");
            } else if (!this.q) {
                b("init error");
                w.b(this.f, "load init error");
            } else {
                d();
                try {
                    d dVar = this.m;
                    if (dVar != null) {
                        int q2 = dVar.q();
                        int v = this.m.v();
                        if (q2 <= 0) {
                            q2 = 1;
                        }
                        if (v <= 0) {
                            v = 1;
                        }
                        int i2 = v * q2;
                        if (d != null && !TextUtils.isEmpty(this.i)) {
                            d.put(this.i, Integer.valueOf(i2));
                        }
                        String str = this.f;
                        w.b(str, "maxOffset:" + i2 + " apiCacheNum:" + q2 + " mUnitId:" + this.i);
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
                a(false);
            }
        } catch (Exception e3) {
            e3.printStackTrace();
            b("can't show because unknow error");
        }
    }

    public final String b() {
        if (this.b) {
            return this.p;
        }
        return this.o;
    }

    public final void c() {
        try {
            if (this.g == null) {
                c("context is null");
                w.b(this.f, "show context is null");
            } else if (TextUtils.isEmpty(this.i)) {
                c("unitid is null");
                w.b(this.f, "show unitid is null");
            } else if (!this.q) {
                c("init error");
                w.b(this.f, "show init error");
            } else {
                d();
                b(true);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            c("can't show because unknow error");
        }
    }

    private void d() {
        try {
            w.b(this.f, "initUnitSetting");
            e();
            d e2 = com.mbridge.msdk.c.b.a().e(com.mbridge.msdk.foundation.controller.a.f().k(), this.i);
            this.m = e2;
            if (e2 == null) {
                this.m = d.f(this.i);
                w.b(this.f, "获取默认的unitsetting");
            }
        } catch (Exception e3) {
            e3.printStackTrace();
        }
    }

    private void a(boolean z) {
        try {
            com.mbridge.msdk.interstitial.a.a aVar = new com.mbridge.msdk.interstitial.a.a(this.g, this.i, this.j, this.h, z);
            b bVar = new b(aVar);
            aVar.a(new C0213a(aVar, bVar));
            Handler handler = this.l;
            if (handler != null) {
                handler.postDelayed(bVar, 30000);
            }
            aVar.b();
        } catch (Exception e2) {
            e2.printStackTrace();
            if (!z) {
                b("can't show because unknow error");
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(boolean z) {
        try {
            String str = this.f;
            w.b(str, "showInterstitial isShowCall:" + z);
            CampaignEx a2 = new com.mbridge.msdk.interstitial.a.a(this.g, this.i, this.j, this.h, true).a();
            if (a2 != null) {
                a(a2);
            } else if (z) {
                w.d(this.f, "showInterstitial 发现cmapaign为空 去load一遍=========");
                a(true);
            } else {
                c("no ads available can show");
                w.b(this.f, "showInterstitial 发现cmapaign为空");
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            if (this.n != null) {
                c("can't show because unknow error");
            }
        }
    }

    private void a(CampaignEx campaignEx) {
        c cVar = new c();
        if (e != null && !TextUtils.isEmpty(this.i)) {
            e.put(this.i, cVar);
        }
        Intent intent = new Intent(this.g, MBInterstitialActivity.class);
        intent.addFlags(67108864);
        intent.addFlags(268435456);
        if (!TextUtils.isEmpty(this.i)) {
            intent.putExtra("unitId", this.i);
        }
        if (campaignEx != null) {
            this.p = campaignEx.getRequestId();
            intent.putExtra(MBInterstitialActivity.INTENT_CAMAPIGN, campaignEx);
        }
        Context context = this.g;
        if (context != null) {
            context.startActivity(intent);
        }
    }

    /* compiled from: InterstitialController */
    public class b implements Runnable {
        private com.mbridge.msdk.interstitial.a.a b;

        public b(com.mbridge.msdk.interstitial.a.a aVar) {
            this.b = aVar;
        }

        public final void run() {
            try {
                w.d(a.this.f, "CommonCancelTimeTask");
                com.mbridge.msdk.interstitial.a.a aVar = this.b;
                if (aVar != null) {
                    if (aVar.d()) {
                        a.this.c((a) "load timeout");
                    } else if (a.this.n != null) {
                        a.this.b((a) "load timeout");
                    }
                    this.b.a((C0213a) null);
                    this.b = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /* renamed from: com.mbridge.msdk.interstitial.c.a$a  reason: collision with other inner class name */
    /* compiled from: InterstitialController */
    public class C0213a {
        private com.mbridge.msdk.interstitial.a.a b;
        private b c;

        public C0213a(com.mbridge.msdk.interstitial.a.a aVar, b bVar) {
            this.b = aVar;
            this.c = bVar;
        }

        public final void a(boolean z, String str) {
            try {
                a.this.o = str;
                if (this.c != null) {
                    if (a.this.l != null) {
                        a.this.l.removeCallbacks(this.c);
                    }
                    if (z) {
                        a.this.b((a) false);
                    } else if (a.this.n != null) {
                        a.e(a.this);
                    }
                    w.d(a.this.f, "onInterstitialLoadSuccess remove task ");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public final void b(boolean z, String str) {
            try {
                com.mbridge.msdk.interstitial.a.a aVar = this.b;
                if (aVar != null) {
                    aVar.a((C0213a) null);
                    this.b = null;
                }
                if (this.c != null) {
                    w.d(a.this.f, "LoadIntersInnerListener onIntersLoadFail remove task");
                    if (a.this.l != null) {
                        a.this.l.removeCallbacks(this.c);
                    }
                    if (z) {
                        if (a.this.n != null) {
                            a.this.c((a) str);
                        }
                    } else if (a.this.n != null) {
                        a.this.b((a) str);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /* compiled from: InterstitialController */
    public class c {
        public c() {
        }

        public final void a(String str) {
            try {
                a.this.c((a) str);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public final void a() {
            try {
                a.f(a.this);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public final void b() {
            try {
                if (a.this.l != null) {
                    a.this.l.sendEmptyMessage(7);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public final void c() {
            try {
                if (a.this.l != null) {
                    a.this.l.sendEmptyMessage(6);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(String str) {
        try {
            if (this.l != null) {
                Message obtain = Message.obtain();
                obtain.obj = str;
                obtain.what = 2;
                this.l.sendMessage(obtain);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void c(String str) {
        try {
            if (this.l != null) {
                Message obtain = Message.obtain();
                obtain.obj = str;
                obtain.what = 4;
                this.l.sendMessage(obtain);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    private void e() {
        try {
            new com.mbridge.msdk.c.c().a(this.g, (String) null, (String) null, this.i);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    static /* synthetic */ void e(a aVar) {
        Handler handler = aVar.l;
        if (handler != null) {
            handler.sendEmptyMessage(1);
        }
    }

    static /* synthetic */ void f(a aVar) {
        Handler handler = aVar.l;
        if (handler != null) {
            handler.sendEmptyMessage(3);
        }
    }
}