同程有借 v1.0.0版本的 MD5 值为:e33397cdbab33543d0c134ec96d77fb8

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


package com.bonree.sdk.n;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.bonree.sdk.n.g;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
public class a {
    private static final int f6230a = 0;
    private static final String f6231d = "BR-CacheData-Thread";
    private final ConcurrentLinkedQueue<Object> f6232b;
    private Handler f6233c;

    public static class C0072a {
        private static final a f6234a = new a((byte) 0);
    }

    public class b extends Handler {
        b(a aVar, Looper looper, byte b9) {
            this(looper);
        }

        @Override
        public final void handleMessage(Message message) {
            removeMessages(0);
            a.a(a.this);
            sendEmptyMessageDelayed(0, 10000L);
        }

        private b(Looper looper) {
            super(looper);
            a.this = r1;
        }
    }

    a(byte b9) {
        this();
    }

    public static a a() {
        return C0072a.f6234a;
    }

    private void e() {
        synchronized (this.f6232b) {
            if (!this.f6232b.isEmpty()) {
                ArrayList arrayList = new ArrayList();
                Iterator<Object> it = this.f6232b.iterator();
                while (it.hasNext()) {
                    Object next = it.next();
                    if (next instanceof com.bonree.sdk.o.b) {
                        com.bonree.sdk.o.b bVar = (com.bonree.sdk.o.b) next;
                        if (com.bonree.sdk.c.a.b() - bVar.c() >= 10000) {
                            arrayList.add(next);
                            if (!bVar.p()) {
                                bVar.q();
                                com.bonree.sdk.bl.a.a().c("cachedata:%s", bVar);
                                g.a.f6280a.notifyService(bVar);
                            }
                        }
                    }
                }
                this.f6232b.removeAll(arrayList);
            }
        }
    }

    public final void b() {
        try {
            if (this.f6233c == null) {
                b bVar = new b(this, com.bonree.sdk.b.c.a().a(f6231d), (byte) 0);
                this.f6233c = bVar;
                bVar.sendEmptyMessageDelayed(0, 10000L);
            }
        } catch (Throwable th) {
            com.bonree.sdk.bl.a.a().a("cacheData-handler startWorker error ", th);
        }
    }

    public final void c() {
        try {
            com.bonree.sdk.b.c.a().b(f6231d);
            Handler handler = this.f6233c;
            if (handler != null) {
                handler.removeCallbacksAndMessages(null);
            }
        } catch (Throwable th) {
            try {
                com.bonree.sdk.bl.a.a().a("cacheData-handler stopWorker error ", th);
            } finally {
                this.f6233c = null;
            }
        }
    }

    public final void d() {
        synchronized (this.f6232b) {
            if (!this.f6232b.isEmpty()) {
                this.f6232b.clear();
            }
        }
    }

    private a() {
        this.f6232b = new ConcurrentLinkedQueue<>();
    }

    public final void a(Object obj) {
        synchronized (this.f6232b) {
            if (this.f6232b.size() >= 50) {
                com.bonree.sdk.bl.g.a("cachedata length:" + this.f6232b.size(), new Object[0]);
                com.bonree.sdk.o.b bVar = (com.bonree.sdk.o.b) obj;
                if (bVar.p()) {
                    return;
                }
                bVar.q();
                g.a.f6280a.notifyService(bVar);
            } else {
                this.f6232b.add(obj);
            }
        }
    }

    static void a(a aVar) {
        synchronized (aVar.f6232b) {
            if (!aVar.f6232b.isEmpty()) {
                ArrayList arrayList = new ArrayList();
                Iterator<Object> it = aVar.f6232b.iterator();
                while (it.hasNext()) {
                    Object next = it.next();
                    if (next instanceof com.bonree.sdk.o.b) {
                        com.bonree.sdk.o.b bVar = (com.bonree.sdk.o.b) next;
                        if (com.bonree.sdk.c.a.b() - bVar.c() >= 10000) {
                            arrayList.add(next);
                            if (!bVar.p()) {
                                bVar.q();
                                com.bonree.sdk.bl.a.a().c("cachedata:%s", bVar);
                                g.a.f6280a.notifyService(bVar);
                            }
                        }
                    }
                }
                aVar.f6232b.removeAll(arrayList);
            }
        }
    }
}