Initial commit
This commit is contained in:
25
sources/org/greenrobot/eventbus/AsyncPoster.java
Normal file
25
sources/org/greenrobot/eventbus/AsyncPoster.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class AsyncPoster implements Runnable {
|
||||
private final PendingPostQueue a = new PendingPostQueue();
|
||||
private final EventBus b;
|
||||
|
||||
AsyncPoster(EventBus eventBus) {
|
||||
this.b = eventBus;
|
||||
}
|
||||
|
||||
public void a(Subscription subscription, Object obj) {
|
||||
this.a.a(PendingPost.a(subscription, obj));
|
||||
this.b.a().execute(this);
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
PendingPost a = this.a.a();
|
||||
if (a == null) {
|
||||
throw new IllegalStateException("No pending post available");
|
||||
}
|
||||
this.b.a(a);
|
||||
}
|
||||
}
|
48
sources/org/greenrobot/eventbus/BackgroundPoster.java
Normal file
48
sources/org/greenrobot/eventbus/BackgroundPoster.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class BackgroundPoster implements Runnable {
|
||||
private final PendingPostQueue a = new PendingPostQueue();
|
||||
private final EventBus b;
|
||||
private volatile boolean c;
|
||||
|
||||
BackgroundPoster(EventBus eventBus) {
|
||||
this.b = eventBus;
|
||||
}
|
||||
|
||||
public void a(Subscription subscription, Object obj) {
|
||||
PendingPost a = PendingPost.a(subscription, obj);
|
||||
synchronized (this) {
|
||||
this.a.a(a);
|
||||
if (!this.c) {
|
||||
this.c = true;
|
||||
this.b.a().execute(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
PendingPost a = this.a.a(1000);
|
||||
if (a == null) {
|
||||
synchronized (this) {
|
||||
a = this.a.a();
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.b.a(a);
|
||||
} catch (InterruptedException e) {
|
||||
Log.w("Event", Thread.currentThread().getName() + " was interruppted", e);
|
||||
return;
|
||||
} finally {
|
||||
this.c = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
383
sources/org/greenrobot/eventbus/EventBus.java
Normal file
383
sources/org/greenrobot/eventbus/EventBus.java
Normal file
@@ -0,0 +1,383 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.greenrobot.eventbus.meta.SubscriberInfoIndex;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class EventBus {
|
||||
public static String q = "EventBus";
|
||||
static volatile EventBus r;
|
||||
private static final EventBusBuilder s = new EventBusBuilder();
|
||||
private static final Map<Class<?>, List<Class<?>>> t = new HashMap();
|
||||
private final Map<Class<?>, CopyOnWriteArrayList<Subscription>> a;
|
||||
private final Map<Object, List<Class<?>>> b;
|
||||
private final Map<Class<?>, Object> c;
|
||||
private final ThreadLocal<PostingThreadState> d;
|
||||
private final HandlerPoster e;
|
||||
private final BackgroundPoster f;
|
||||
private final AsyncPoster g;
|
||||
private final SubscriberMethodFinder h;
|
||||
private final ExecutorService i;
|
||||
private final boolean j;
|
||||
private final boolean k;
|
||||
private final boolean l;
|
||||
private final boolean m;
|
||||
private final boolean n;
|
||||
private final boolean o;
|
||||
private final int p;
|
||||
|
||||
/* renamed from: org.greenrobot.eventbus.EventBus$2, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass2 {
|
||||
static final /* synthetic */ int[] a = new int[ThreadMode.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[ThreadMode.POSTING.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[ThreadMode.MAIN.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[ThreadMode.BACKGROUND.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[ThreadMode.ASYNC.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final class PostingThreadState {
|
||||
final List<Object> a = new ArrayList();
|
||||
boolean b;
|
||||
boolean c;
|
||||
Subscription d;
|
||||
Object e;
|
||||
boolean f;
|
||||
|
||||
PostingThreadState() {
|
||||
}
|
||||
}
|
||||
|
||||
public EventBus() {
|
||||
this(s);
|
||||
}
|
||||
|
||||
private void a(Object obj, SubscriberMethod subscriberMethod) {
|
||||
Class<?> cls = subscriberMethod.c;
|
||||
Subscription subscription = new Subscription(obj, subscriberMethod);
|
||||
CopyOnWriteArrayList<Subscription> copyOnWriteArrayList = this.a.get(cls);
|
||||
if (copyOnWriteArrayList == null) {
|
||||
copyOnWriteArrayList = new CopyOnWriteArrayList<>();
|
||||
this.a.put(cls, copyOnWriteArrayList);
|
||||
} else if (copyOnWriteArrayList.contains(subscription)) {
|
||||
throw new EventBusException("Subscriber " + obj.getClass() + " already registered to event " + cls);
|
||||
}
|
||||
int size = copyOnWriteArrayList.size();
|
||||
for (int i = 0; i <= size; i++) {
|
||||
if (i == size || subscriberMethod.d > copyOnWriteArrayList.get(i).b.d) {
|
||||
copyOnWriteArrayList.add(i, subscription);
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Class<?>> list = this.b.get(obj);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
this.b.put(obj, list);
|
||||
}
|
||||
list.add(cls);
|
||||
if (subscriberMethod.e) {
|
||||
if (!this.o) {
|
||||
b(subscription, this.c.get(cls));
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<Class<?>, Object> entry : this.c.entrySet()) {
|
||||
if (cls.isAssignableFrom(entry.getKey())) {
|
||||
b(subscription, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static EventBus b() {
|
||||
if (r == null) {
|
||||
synchronized (EventBus.class) {
|
||||
if (r == null) {
|
||||
r = new EventBus();
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public void c(Object obj) {
|
||||
List<SubscriberMethod> a = this.h.a(obj.getClass());
|
||||
synchronized (this) {
|
||||
Iterator<SubscriberMethod> it = a.iterator();
|
||||
while (it.hasNext()) {
|
||||
a(obj, it.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void d(Object obj) {
|
||||
List<Class<?>> list = this.b.get(obj);
|
||||
if (list != null) {
|
||||
Iterator<Class<?>> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
a(obj, it.next());
|
||||
}
|
||||
this.b.remove(obj);
|
||||
} else {
|
||||
Log.w(q, "Subscriber to unregister was not registered before: " + obj.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "EventBus[indexCount=" + this.p + ", eventInheritance=" + this.o + "]";
|
||||
}
|
||||
|
||||
EventBus(EventBusBuilder eventBusBuilder) {
|
||||
this.d = new ThreadLocal<PostingThreadState>(this) { // from class: org.greenrobot.eventbus.EventBus.1
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // java.lang.ThreadLocal
|
||||
public PostingThreadState initialValue() {
|
||||
return new PostingThreadState();
|
||||
}
|
||||
};
|
||||
this.a = new HashMap();
|
||||
this.b = new HashMap();
|
||||
this.c = new ConcurrentHashMap();
|
||||
this.e = new HandlerPoster(this, Looper.getMainLooper(), 10);
|
||||
this.f = new BackgroundPoster(this);
|
||||
this.g = new AsyncPoster(this);
|
||||
List<SubscriberInfoIndex> list = eventBusBuilder.j;
|
||||
this.p = list != null ? list.size() : 0;
|
||||
this.h = new SubscriberMethodFinder(eventBusBuilder.j, eventBusBuilder.h, eventBusBuilder.g);
|
||||
this.k = eventBusBuilder.a;
|
||||
this.l = eventBusBuilder.b;
|
||||
this.m = eventBusBuilder.c;
|
||||
this.n = eventBusBuilder.d;
|
||||
this.j = eventBusBuilder.e;
|
||||
this.o = eventBusBuilder.f;
|
||||
this.i = eventBusBuilder.i;
|
||||
}
|
||||
|
||||
private void b(Subscription subscription, Object obj) {
|
||||
if (obj != null) {
|
||||
a(subscription, obj, Looper.getMainLooper() == Looper.myLooper());
|
||||
}
|
||||
}
|
||||
|
||||
public void b(Object obj) {
|
||||
PostingThreadState postingThreadState = this.d.get();
|
||||
List<Object> list = postingThreadState.a;
|
||||
list.add(obj);
|
||||
if (postingThreadState.b) {
|
||||
return;
|
||||
}
|
||||
postingThreadState.c = Looper.getMainLooper() == Looper.myLooper();
|
||||
postingThreadState.b = true;
|
||||
if (!postingThreadState.f) {
|
||||
while (!list.isEmpty()) {
|
||||
try {
|
||||
a(list.remove(0), postingThreadState);
|
||||
} finally {
|
||||
postingThreadState.b = false;
|
||||
postingThreadState.c = false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new EventBusException("Internal error. Abort state was not reset");
|
||||
}
|
||||
|
||||
public synchronized boolean a(Object obj) {
|
||||
return this.b.containsKey(obj);
|
||||
}
|
||||
|
||||
private void a(Object obj, Class<?> cls) {
|
||||
CopyOnWriteArrayList<Subscription> copyOnWriteArrayList = this.a.get(cls);
|
||||
if (copyOnWriteArrayList != null) {
|
||||
int size = copyOnWriteArrayList.size();
|
||||
int i = 0;
|
||||
while (i < size) {
|
||||
Subscription subscription = copyOnWriteArrayList.get(i);
|
||||
if (subscription.a == obj) {
|
||||
subscription.c = false;
|
||||
copyOnWriteArrayList.remove(i);
|
||||
i--;
|
||||
size--;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Object obj, PostingThreadState postingThreadState) throws Error {
|
||||
boolean a;
|
||||
Class<?> cls = obj.getClass();
|
||||
if (this.o) {
|
||||
List<Class<?>> a2 = a(cls);
|
||||
int size = a2.size();
|
||||
a = false;
|
||||
for (int i = 0; i < size; i++) {
|
||||
a |= a(obj, postingThreadState, a2.get(i));
|
||||
}
|
||||
} else {
|
||||
a = a(obj, postingThreadState, cls);
|
||||
}
|
||||
if (a) {
|
||||
return;
|
||||
}
|
||||
if (this.l) {
|
||||
Log.d(q, "No subscribers registered for event " + cls);
|
||||
}
|
||||
if (!this.n || cls == NoSubscriberEvent.class || cls == SubscriberExceptionEvent.class) {
|
||||
return;
|
||||
}
|
||||
b(new NoSubscriberEvent(this, obj));
|
||||
}
|
||||
|
||||
private boolean a(Object obj, PostingThreadState postingThreadState, Class<?> cls) {
|
||||
CopyOnWriteArrayList<Subscription> copyOnWriteArrayList;
|
||||
synchronized (this) {
|
||||
copyOnWriteArrayList = this.a.get(cls);
|
||||
}
|
||||
if (copyOnWriteArrayList == null || copyOnWriteArrayList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Iterator<Subscription> it = copyOnWriteArrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Subscription next = it.next();
|
||||
postingThreadState.e = obj;
|
||||
postingThreadState.d = next;
|
||||
try {
|
||||
a(next, obj, postingThreadState.c);
|
||||
if (postingThreadState.f) {
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
postingThreadState.e = null;
|
||||
postingThreadState.d = null;
|
||||
postingThreadState.f = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void a(Subscription subscription, Object obj, boolean z) {
|
||||
int i = AnonymousClass2.a[subscription.b.b.ordinal()];
|
||||
if (i == 1) {
|
||||
a(subscription, obj);
|
||||
return;
|
||||
}
|
||||
if (i == 2) {
|
||||
if (z) {
|
||||
a(subscription, obj);
|
||||
return;
|
||||
} else {
|
||||
this.e.a(subscription, obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i == 3) {
|
||||
if (z) {
|
||||
this.f.a(subscription, obj);
|
||||
return;
|
||||
} else {
|
||||
a(subscription, obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i == 4) {
|
||||
this.g.a(subscription, obj);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("Unknown thread mode: " + subscription.b.b);
|
||||
}
|
||||
|
||||
private static List<Class<?>> a(Class<?> cls) {
|
||||
List<Class<?>> list;
|
||||
synchronized (t) {
|
||||
list = t.get(cls);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
for (Class<?> cls2 = cls; cls2 != null; cls2 = cls2.getSuperclass()) {
|
||||
list.add(cls2);
|
||||
a(list, cls2.getInterfaces());
|
||||
}
|
||||
t.put(cls, list);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static void a(List<Class<?>> list, Class<?>[] clsArr) {
|
||||
for (Class<?> cls : clsArr) {
|
||||
if (!list.contains(cls)) {
|
||||
list.add(cls);
|
||||
a(list, cls.getInterfaces());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void a(PendingPost pendingPost) {
|
||||
Object obj = pendingPost.a;
|
||||
Subscription subscription = pendingPost.b;
|
||||
PendingPost.a(pendingPost);
|
||||
if (subscription.c) {
|
||||
a(subscription, obj);
|
||||
}
|
||||
}
|
||||
|
||||
void a(Subscription subscription, Object obj) {
|
||||
try {
|
||||
subscription.b.a.invoke(subscription.a, obj);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalStateException("Unexpected exception", e);
|
||||
} catch (InvocationTargetException e2) {
|
||||
a(subscription, obj, e2.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Subscription subscription, Object obj, Throwable th) {
|
||||
if (obj instanceof SubscriberExceptionEvent) {
|
||||
if (this.k) {
|
||||
Log.e(q, "SubscriberExceptionEvent subscriber " + subscription.a.getClass() + " threw an exception", th);
|
||||
SubscriberExceptionEvent subscriberExceptionEvent = (SubscriberExceptionEvent) obj;
|
||||
Log.e(q, "Initial event " + subscriberExceptionEvent.b + " caused exception in " + subscriberExceptionEvent.c, subscriberExceptionEvent.a);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!this.j) {
|
||||
if (this.k) {
|
||||
Log.e(q, "Could not dispatch event: " + obj.getClass() + " to subscribing class " + subscription.a.getClass(), th);
|
||||
}
|
||||
if (this.m) {
|
||||
b(new SubscriberExceptionEvent(this, th, obj, subscription.a));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new EventBusException("Invoking subscriber failed", th);
|
||||
}
|
||||
|
||||
ExecutorService a() {
|
||||
return this.i;
|
||||
}
|
||||
}
|
24
sources/org/greenrobot/eventbus/EventBusBuilder.java
Normal file
24
sources/org/greenrobot/eventbus/EventBusBuilder.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.greenrobot.eventbus.meta.SubscriberInfoIndex;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class EventBusBuilder {
|
||||
private static final ExecutorService k = Executors.newCachedThreadPool();
|
||||
boolean e;
|
||||
boolean g;
|
||||
boolean h;
|
||||
List<SubscriberInfoIndex> j;
|
||||
boolean a = true;
|
||||
boolean b = true;
|
||||
boolean c = true;
|
||||
boolean d = true;
|
||||
boolean f = true;
|
||||
ExecutorService i = k;
|
||||
|
||||
EventBusBuilder() {
|
||||
}
|
||||
}
|
18
sources/org/greenrobot/eventbus/EventBusException.java
Normal file
18
sources/org/greenrobot/eventbus/EventBusException.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class EventBusException extends RuntimeException {
|
||||
private static final long serialVersionUID = -2912559384646531479L;
|
||||
|
||||
public EventBusException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public EventBusException(Throwable th) {
|
||||
super(th);
|
||||
}
|
||||
|
||||
public EventBusException(String str, Throwable th) {
|
||||
super(str, th);
|
||||
}
|
||||
}
|
60
sources/org/greenrobot/eventbus/HandlerPoster.java
Normal file
60
sources/org/greenrobot/eventbus/HandlerPoster.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class HandlerPoster extends Handler {
|
||||
private final PendingPostQueue a;
|
||||
private final int b;
|
||||
private final EventBus c;
|
||||
private boolean d;
|
||||
|
||||
HandlerPoster(EventBus eventBus, Looper looper, int i) {
|
||||
super(looper);
|
||||
this.c = eventBus;
|
||||
this.b = i;
|
||||
this.a = new PendingPostQueue();
|
||||
}
|
||||
|
||||
void a(Subscription subscription, Object obj) {
|
||||
PendingPost a = PendingPost.a(subscription, obj);
|
||||
synchronized (this) {
|
||||
this.a.a(a);
|
||||
if (!this.d) {
|
||||
this.d = true;
|
||||
if (!sendMessage(obtainMessage())) {
|
||||
throw new EventBusException("Could not send handler message");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
try {
|
||||
long uptimeMillis = SystemClock.uptimeMillis();
|
||||
do {
|
||||
PendingPost a = this.a.a();
|
||||
if (a == null) {
|
||||
synchronized (this) {
|
||||
a = this.a.a();
|
||||
if (a == null) {
|
||||
this.d = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.c.a(a);
|
||||
} while (SystemClock.uptimeMillis() - uptimeMillis < this.b);
|
||||
if (!sendMessage(obtainMessage())) {
|
||||
throw new EventBusException("Could not send handler message");
|
||||
}
|
||||
this.d = true;
|
||||
} finally {
|
||||
this.d = false;
|
||||
}
|
||||
}
|
||||
}
|
7
sources/org/greenrobot/eventbus/NoSubscriberEvent.java
Normal file
7
sources/org/greenrobot/eventbus/NoSubscriberEvent.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class NoSubscriberEvent {
|
||||
public NoSubscriberEvent(EventBus eventBus, Object obj) {
|
||||
}
|
||||
}
|
42
sources/org/greenrobot/eventbus/PendingPost.java
Normal file
42
sources/org/greenrobot/eventbus/PendingPost.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class PendingPost {
|
||||
private static final List<PendingPost> d = new ArrayList();
|
||||
Object a;
|
||||
Subscription b;
|
||||
PendingPost c;
|
||||
|
||||
private PendingPost(Object obj, Subscription subscription) {
|
||||
this.a = obj;
|
||||
this.b = subscription;
|
||||
}
|
||||
|
||||
static PendingPost a(Subscription subscription, Object obj) {
|
||||
synchronized (d) {
|
||||
int size = d.size();
|
||||
if (size <= 0) {
|
||||
return new PendingPost(obj, subscription);
|
||||
}
|
||||
PendingPost remove = d.remove(size - 1);
|
||||
remove.a = obj;
|
||||
remove.b = subscription;
|
||||
remove.c = null;
|
||||
return remove;
|
||||
}
|
||||
}
|
||||
|
||||
static void a(PendingPost pendingPost) {
|
||||
pendingPost.a = null;
|
||||
pendingPost.b = null;
|
||||
pendingPost.c = null;
|
||||
synchronized (d) {
|
||||
if (d.size() < 10000) {
|
||||
d.add(pendingPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
sources/org/greenrobot/eventbus/PendingPostQueue.java
Normal file
50
sources/org/greenrobot/eventbus/PendingPostQueue.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class PendingPostQueue {
|
||||
private PendingPost a;
|
||||
private PendingPost b;
|
||||
|
||||
PendingPostQueue() {
|
||||
}
|
||||
|
||||
synchronized void a(PendingPost pendingPost) {
|
||||
try {
|
||||
if (pendingPost == null) {
|
||||
throw new NullPointerException("null cannot be enqueued");
|
||||
}
|
||||
if (this.b != null) {
|
||||
this.b.c = pendingPost;
|
||||
this.b = pendingPost;
|
||||
} else {
|
||||
if (this.a != null) {
|
||||
throw new IllegalStateException("Head present, but no tail");
|
||||
}
|
||||
this.b = pendingPost;
|
||||
this.a = pendingPost;
|
||||
}
|
||||
notifyAll();
|
||||
} catch (Throwable th) {
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
synchronized PendingPost a() {
|
||||
PendingPost pendingPost;
|
||||
pendingPost = this.a;
|
||||
if (this.a != null) {
|
||||
this.a = this.a.c;
|
||||
if (this.a == null) {
|
||||
this.b = null;
|
||||
}
|
||||
}
|
||||
return pendingPost;
|
||||
}
|
||||
|
||||
synchronized PendingPost a(int i) throws InterruptedException {
|
||||
if (this.a == null) {
|
||||
wait(i);
|
||||
}
|
||||
return a();
|
||||
}
|
||||
}
|
19
sources/org/greenrobot/eventbus/Subscribe.java
Normal file
19
sources/org/greenrobot/eventbus/Subscribe.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/* loaded from: classes2.dex */
|
||||
public @interface Subscribe {
|
||||
int priority() default 0;
|
||||
|
||||
boolean sticky() default false;
|
||||
|
||||
ThreadMode threadMode() default ThreadMode.POSTING;
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class SubscriberExceptionEvent {
|
||||
public final Throwable a;
|
||||
public final Object b;
|
||||
public final Object c;
|
||||
|
||||
public SubscriberExceptionEvent(EventBus eventBus, Throwable th, Object obj, Object obj2) {
|
||||
this.a = th;
|
||||
this.b = obj;
|
||||
this.c = obj2;
|
||||
}
|
||||
}
|
50
sources/org/greenrobot/eventbus/SubscriberMethod.java
Normal file
50
sources/org/greenrobot/eventbus/SubscriberMethod.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SubscriberMethod {
|
||||
final Method a;
|
||||
final ThreadMode b;
|
||||
final Class<?> c;
|
||||
final int d;
|
||||
final boolean e;
|
||||
String f;
|
||||
|
||||
public SubscriberMethod(Method method, Class<?> cls, ThreadMode threadMode, int i, boolean z) {
|
||||
this.a = method;
|
||||
this.b = threadMode;
|
||||
this.c = cls;
|
||||
this.d = i;
|
||||
this.e = z;
|
||||
}
|
||||
|
||||
private synchronized void a() {
|
||||
if (this.f == null) {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
sb.append(this.a.getDeclaringClass().getName());
|
||||
sb.append('#');
|
||||
sb.append(this.a.getName());
|
||||
sb.append('(');
|
||||
sb.append(this.c.getName());
|
||||
this.f = sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof SubscriberMethod)) {
|
||||
return false;
|
||||
}
|
||||
a();
|
||||
SubscriberMethod subscriberMethod = (SubscriberMethod) obj;
|
||||
subscriberMethod.a();
|
||||
return this.f.equals(subscriberMethod.f);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.a.hashCode();
|
||||
}
|
||||
}
|
225
sources/org/greenrobot/eventbus/SubscriberMethodFinder.java
Normal file
225
sources/org/greenrobot/eventbus/SubscriberMethodFinder.java
Normal file
@@ -0,0 +1,225 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.greenrobot.eventbus.meta.SubscriberInfo;
|
||||
import org.greenrobot.eventbus.meta.SubscriberInfoIndex;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class SubscriberMethodFinder {
|
||||
private static final Map<Class<?>, List<SubscriberMethod>> d = new ConcurrentHashMap();
|
||||
private static final FindState[] e = new FindState[4];
|
||||
private List<SubscriberInfoIndex> a;
|
||||
private final boolean b;
|
||||
private final boolean c;
|
||||
|
||||
SubscriberMethodFinder(List<SubscriberInfoIndex> list, boolean z, boolean z2) {
|
||||
this.a = list;
|
||||
this.b = z;
|
||||
this.c = z2;
|
||||
}
|
||||
|
||||
private List<SubscriberMethod> b(Class<?> cls) {
|
||||
FindState a = a();
|
||||
a.a(cls);
|
||||
while (a.e != null) {
|
||||
a.g = c(a);
|
||||
SubscriberInfo subscriberInfo = a.g;
|
||||
if (subscriberInfo != null) {
|
||||
for (SubscriberMethod subscriberMethod : subscriberInfo.a()) {
|
||||
if (a.a(subscriberMethod.a, subscriberMethod.c)) {
|
||||
a.a.add(subscriberMethod);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a(a);
|
||||
}
|
||||
a.a();
|
||||
}
|
||||
return b(a);
|
||||
}
|
||||
|
||||
private SubscriberInfo c(FindState findState) {
|
||||
SubscriberInfo subscriberInfo = findState.g;
|
||||
if (subscriberInfo != null && subscriberInfo.b() != null) {
|
||||
SubscriberInfo b = findState.g.b();
|
||||
if (findState.e == b.c()) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
List<SubscriberInfoIndex> list = this.a;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
Iterator<SubscriberInfoIndex> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
SubscriberInfo a = it.next().a(findState.e);
|
||||
if (a != null) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<SubscriberMethod> a(Class<?> cls) {
|
||||
List<SubscriberMethod> list = d.get(cls);
|
||||
if (list != null) {
|
||||
return list;
|
||||
}
|
||||
List<SubscriberMethod> c = this.c ? c(cls) : b(cls);
|
||||
if (!c.isEmpty()) {
|
||||
d.put(cls, c);
|
||||
return c;
|
||||
}
|
||||
throw new EventBusException("Subscriber " + cls + " and its super classes have no public methods with the @Subscribe annotation");
|
||||
}
|
||||
|
||||
static class FindState {
|
||||
final List<SubscriberMethod> a = new ArrayList();
|
||||
final Map<Class, Object> b = new HashMap();
|
||||
final Map<String, Class> c = new HashMap();
|
||||
final StringBuilder d = new StringBuilder(PeripheralType.SERVO);
|
||||
Class<?> e;
|
||||
boolean f;
|
||||
SubscriberInfo g;
|
||||
|
||||
FindState() {
|
||||
}
|
||||
|
||||
void a(Class<?> cls) {
|
||||
this.e = cls;
|
||||
this.f = false;
|
||||
this.g = null;
|
||||
}
|
||||
|
||||
void b() {
|
||||
this.a.clear();
|
||||
this.b.clear();
|
||||
this.c.clear();
|
||||
this.d.setLength(0);
|
||||
this.e = null;
|
||||
this.f = false;
|
||||
this.g = null;
|
||||
}
|
||||
|
||||
boolean a(Method method, Class<?> cls) {
|
||||
Object put = this.b.put(cls, method);
|
||||
if (put == null) {
|
||||
return true;
|
||||
}
|
||||
if (put instanceof Method) {
|
||||
if (b((Method) put, cls)) {
|
||||
this.b.put(cls, this);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
return b(method, cls);
|
||||
}
|
||||
|
||||
private boolean b(Method method, Class<?> cls) {
|
||||
this.d.setLength(0);
|
||||
this.d.append(method.getName());
|
||||
StringBuilder sb = this.d;
|
||||
sb.append('>');
|
||||
sb.append(cls.getName());
|
||||
String sb2 = this.d.toString();
|
||||
Class<?> declaringClass = method.getDeclaringClass();
|
||||
Class put = this.c.put(sb2, declaringClass);
|
||||
if (put == null || put.isAssignableFrom(declaringClass)) {
|
||||
return true;
|
||||
}
|
||||
this.c.put(sb2, put);
|
||||
return false;
|
||||
}
|
||||
|
||||
void a() {
|
||||
if (this.f) {
|
||||
this.e = null;
|
||||
return;
|
||||
}
|
||||
this.e = this.e.getSuperclass();
|
||||
String name = this.e.getName();
|
||||
if (name.startsWith("java.") || name.startsWith("javax.") || name.startsWith("android.")) {
|
||||
this.e = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<SubscriberMethod> c(Class<?> cls) {
|
||||
FindState a = a();
|
||||
a.a(cls);
|
||||
while (a.e != null) {
|
||||
a(a);
|
||||
a.a();
|
||||
}
|
||||
return b(a);
|
||||
}
|
||||
|
||||
private FindState a() {
|
||||
synchronized (e) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
FindState findState = e[i];
|
||||
if (findState != null) {
|
||||
e[i] = null;
|
||||
return findState;
|
||||
}
|
||||
}
|
||||
return new FindState();
|
||||
}
|
||||
}
|
||||
|
||||
private List<SubscriberMethod> b(FindState findState) {
|
||||
ArrayList arrayList = new ArrayList(findState.a);
|
||||
findState.b();
|
||||
synchronized (e) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= 4) {
|
||||
break;
|
||||
}
|
||||
if (e[i] == null) {
|
||||
e[i] = findState;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private void a(FindState findState) {
|
||||
Method[] methods;
|
||||
try {
|
||||
methods = findState.e.getDeclaredMethods();
|
||||
} catch (Throwable unused) {
|
||||
methods = findState.e.getMethods();
|
||||
findState.f = true;
|
||||
}
|
||||
for (Method method : methods) {
|
||||
int modifiers = method.getModifiers();
|
||||
if ((modifiers & 1) != 0 && (modifiers & 5192) == 0) {
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
if (parameterTypes.length == 1) {
|
||||
Subscribe subscribe = (Subscribe) method.getAnnotation(Subscribe.class);
|
||||
if (subscribe != null) {
|
||||
Class<?> cls = parameterTypes[0];
|
||||
if (findState.a(method, cls)) {
|
||||
findState.a.add(new SubscriberMethod(method, cls, subscribe.threadMode(), subscribe.priority(), subscribe.sticky()));
|
||||
}
|
||||
}
|
||||
} else if (this.b && method.isAnnotationPresent(Subscribe.class)) {
|
||||
throw new EventBusException("@Subscribe method " + (method.getDeclaringClass().getName() + "." + method.getName()) + "must have exactly 1 parameter but has " + parameterTypes.length);
|
||||
}
|
||||
} else if (this.b && method.isAnnotationPresent(Subscribe.class)) {
|
||||
throw new EventBusException((method.getDeclaringClass().getName() + "." + method.getName()) + " is a illegal @Subscribe method: must be public, non-static, and non-abstract");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
sources/org/greenrobot/eventbus/Subscription.java
Normal file
25
sources/org/greenrobot/eventbus/Subscription.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class Subscription {
|
||||
final Object a;
|
||||
final SubscriberMethod b;
|
||||
volatile boolean c = true;
|
||||
|
||||
Subscription(Object obj, SubscriberMethod subscriberMethod) {
|
||||
this.a = obj;
|
||||
this.b = subscriberMethod;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Subscription)) {
|
||||
return false;
|
||||
}
|
||||
Subscription subscription = (Subscription) obj;
|
||||
return this.a == subscription.a && this.b.equals(subscription.b);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.a.hashCode() + this.b.f.hashCode();
|
||||
}
|
||||
}
|
9
sources/org/greenrobot/eventbus/ThreadMode.java
Normal file
9
sources/org/greenrobot/eventbus/ThreadMode.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package org.greenrobot.eventbus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum ThreadMode {
|
||||
POSTING,
|
||||
MAIN,
|
||||
BACKGROUND,
|
||||
ASYNC
|
||||
}
|
12
sources/org/greenrobot/eventbus/meta/SubscriberInfo.java
Normal file
12
sources/org/greenrobot/eventbus/meta/SubscriberInfo.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package org.greenrobot.eventbus.meta;
|
||||
|
||||
import org.greenrobot.eventbus.SubscriberMethod;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SubscriberInfo {
|
||||
SubscriberMethod[] a();
|
||||
|
||||
SubscriberInfo b();
|
||||
|
||||
Class<?> c();
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package org.greenrobot.eventbus.meta;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SubscriberInfoIndex {
|
||||
SubscriberInfo a(Class<?> cls);
|
||||
}
|
10
sources/org/greenrobot/eventbus/util/ErrorDialogConfig.java
Normal file
10
sources/org/greenrobot/eventbus/util/ErrorDialogConfig.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.greenrobot.eventbus.util;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ErrorDialogConfig {
|
||||
EventBus a() {
|
||||
throw null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package org.greenrobot.eventbus.util;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class ErrorDialogFragmentFactory<T> {
|
||||
protected final ErrorDialogConfig a;
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
package org.greenrobot.eventbus.util;
|
||||
|
||||
import android.R;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ErrorDialogFragments {
|
||||
public static int a;
|
||||
public static Class<?> b;
|
||||
|
||||
@TargetApi(11)
|
||||
public static class Honeycomb extends DialogFragment implements DialogInterface.OnClickListener {
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ErrorDialogFragments.a(dialogInterface, i, getActivity(), getArguments());
|
||||
}
|
||||
|
||||
@Override // android.app.DialogFragment
|
||||
public Dialog onCreateDialog(Bundle bundle) {
|
||||
return ErrorDialogFragments.a(getActivity(), getArguments(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dialog a(Context context, Bundle bundle, DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(bundle.getString("de.greenrobot.eventbus.errordialog.title"));
|
||||
builder.setMessage(bundle.getString("de.greenrobot.eventbus.errordialog.message"));
|
||||
int i = a;
|
||||
if (i != 0) {
|
||||
builder.setIcon(i);
|
||||
}
|
||||
builder.setPositiveButton(R.string.ok, onClickListener);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public static void a(DialogInterface dialogInterface, int i, Activity activity, Bundle bundle) {
|
||||
Class<?> cls = b;
|
||||
if (cls == null) {
|
||||
if (!bundle.getBoolean("de.greenrobot.eventbus.errordialog.finish_after_dialog", false) || activity == null) {
|
||||
return;
|
||||
}
|
||||
activity.finish();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
cls.newInstance();
|
||||
ErrorDialogManager.a.a.a();
|
||||
throw null;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Event cannot be constructed", e);
|
||||
}
|
||||
}
|
||||
}
|
28
sources/org/greenrobot/eventbus/util/ErrorDialogManager.java
Normal file
28
sources/org/greenrobot/eventbus/util/ErrorDialogManager.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package org.greenrobot.eventbus.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Fragment;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ErrorDialogManager {
|
||||
public static ErrorDialogFragmentFactory<?> a;
|
||||
|
||||
@TargetApi(11)
|
||||
public static class HoneycombManagerFragment extends Fragment {
|
||||
private EventBus a;
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onPause() {
|
||||
this.a.d(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
ErrorDialogManager.a.a.a();
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user