package com.flurry.android;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/0.dex */
public final class bd {
    private static String a = "FlurryAgent";
    private static String b = "FlurryBannerTag";
    private static Runnable e;
    private Map<Context, List<t>> c = new HashMap();
    private Context d;

    /* JADX INFO: Access modifiers changed from: package-private */
    public bd(Context context) {
        this.d = context;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void a() {
        List<t> list = this.c.get(this.d);
        if (list != null) {
            for (t tVar : list) {
                if (tVar.e().a()) {
                    tVar.a(0L);
                }
                if (tVar.a() > 0 && !tVar.b()) {
                    a(tVar);
                }
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void b() {
        List<t> list = this.c.get(this.d);
        if (list != null) {
            for (t tVar : list) {
                if (tVar.a() > 0 && !tVar.b()) {
                    a(tVar);
                }
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void a(t tVar) {
        e = new am(this, tVar);
        if (!tVar.b()) {
            tVar.postDelayed(e, tVar.a());
            tVar.a(true);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void b(t tVar) {
        tVar.a(false);
        if (tVar.getContext().equals(this.d) && this.c.get(this.d).contains(tVar)) {
            String str = "Rotating banner for adSpace: " + tVar.d();
            o e2 = tVar.e();
            if (e2 != null && e2.a()) {
                tVar.a(1L);
            }
            if (tVar.a() > 0) {
                a(tVar);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized ar a(t tVar, long j) {
        return tVar.a(j);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* JADX WARN: Code restructure failed: missing block: B:10:0x0021, code lost:
        r0 = "BannerHolder removed for adSpace: " + r5.d();
        r1.remove();
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public final synchronized void a(android.content.Context r4, com.flurry.android.t r5) {
        /*
            r3 = this;
            monitor-enter(r3)
            java.util.Map<android.content.Context, java.util.List<com.flurry.android.t>> r0 = r3.c     // Catch: java.lang.Throwable -> L3c
            java.lang.Object r0 = r0.get(r4)     // Catch: java.lang.Throwable -> L3c
            java.util.List r0 = (java.util.List) r0     // Catch: java.lang.Throwable -> L3c
            if (r0 == 0) goto L3a
            java.util.Iterator r1 = r0.iterator()     // Catch: java.lang.Throwable -> L3c
        Lf:
            boolean r0 = r1.hasNext()     // Catch: java.lang.Throwable -> L3c
            if (r0 == 0) goto L3a
            java.lang.Object r0 = r1.next()     // Catch: java.lang.Throwable -> L3c
            com.flurry.android.t r0 = (com.flurry.android.t) r0     // Catch: java.lang.Throwable -> L3c
            boolean r0 = r0.equals(r5)     // Catch: java.lang.Throwable -> L3c
            if (r0 == 0) goto Lf
            java.lang.StringBuilder r0 = new java.lang.StringBuilder     // Catch: java.lang.Throwable -> L3c
            r0.<init>()     // Catch: java.lang.Throwable -> L3c
            java.lang.String r2 = "BannerHolder removed for adSpace: "
            java.lang.StringBuilder r0 = r0.append(r2)     // Catch: java.lang.Throwable -> L3c
            java.lang.String r2 = r5.d()     // Catch: java.lang.Throwable -> L3c
            java.lang.StringBuilder r0 = r0.append(r2)     // Catch: java.lang.Throwable -> L3c
            r0.toString()     // Catch: java.lang.Throwable -> L3c
            r1.remove()     // Catch: java.lang.Throwable -> L3c
        L3a:
            monitor-exit(r3)
            return
        L3c:
            r0 = move-exception
            monitor-exit(r3)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.flurry.android.bd.a(android.content.Context, com.flurry.android.t):void");
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized List<t> a(Context context, ViewGroup viewGroup, String str) {
        ArrayList arrayList;
        List<t> list = this.c.get(context);
        arrayList = new ArrayList();
        if (list != null) {
            for (t tVar : list) {
                if (tVar.c().equals(viewGroup) && !tVar.d().equals(str)) {
                    arrayList.add(tVar);
                }
                if (!tVar.c().equals(viewGroup) && tVar.d().equals(str)) {
                    arrayList.add(tVar);
                }
            }
        }
        return arrayList;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void b(Context context, t tVar) {
        if (tVar != null) {
            List<t> list = this.c.get(context);
            if (list == null) {
                list = new ArrayList<>();
            }
            list.add(tVar);
            this.c.put(context, list);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized t a(be beVar, Context context, ViewGroup viewGroup, String str, FlurryAdSize flurryAdSize) {
        t tVar;
        tVar = new t(beVar, context, str, viewGroup, flurryAdSize);
        tVar.setTag(b);
        return tVar;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized t a(ViewGroup viewGroup) {
        return (t) viewGroup.findViewWithTag(b);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized t a(Context context, String str) {
        t tVar;
        List<t> list = this.c.get(context);
        if (list != null) {
            Iterator<t> it = list.iterator();
            while (true) {
                if (!it.hasNext()) {
                    tVar = null;
                    break;
                }
                tVar = it.next();
                if (tVar.d().equals(str)) {
                    break;
                }
            }
        } else {
            tVar = null;
        }
        return tVar;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized t a(Context context, View view, String str) {
        t tVar;
        List<t> list = this.c.get(context);
        if (list != null) {
            Iterator<t> it = list.iterator();
            while (true) {
                if (!it.hasNext()) {
                    tVar = null;
                    break;
                }
                tVar = it.next();
                if (view.equals(tVar.c()) && str.equals(tVar.d())) {
                    break;
                }
            }
        } else {
            tVar = null;
        }
        return tVar;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void a(Context context) {
        this.d = context;
    }
}
