| | |
| | | package com.hdl.sdk.common.event;
|
| | |
|
| | | import androidx.annotation.NonNull;
|
| | | import androidx.collection.ArrayMap;
|
| | |
|
| | | import android.util.ArrayMap;
|
| | |
|
| | | import com.hdl.sdk.common.utils.LogUtils;
|
| | | import com.hdl.sdk.common.utils.ThreadToolUtils;
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Objects;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | | import java.util.concurrent.ExecutorService;
|
| | |
|
| | |
|
| | |
| | |
|
| | | private static final List<EventListener> ALL_TOPICS_EVENT = new ArrayList<>();//所有主题消息
|
| | |
|
| | | private static final ArrayMap<Object, List<EventListener>> EVENT = new ArrayMap<>();
|
| | | private static final ConcurrentHashMap<Object, List<EventListener>> EVENT = new ConcurrentHashMap<>();
|
| | |
|
| | | private static final ArrayMap<EventListener, Integer> TYPE = new ArrayMap<>();
|
| | | private static final ConcurrentHashMap<EventListener, Integer> TYPE = new ConcurrentHashMap<>();
|
| | |
|
| | | private static final int MAIN_TYPE = 0;
|
| | | private static final int IO_TYPE = 1;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public synchronized void post(Object tag, @NonNull Object o) {
|
| | | public synchronized void post(Object tag, Object o) {
|
| | | if (tag == null) {
|
| | | LogUtils.i("post tag为空");
|
| | | return;
|
| | |
| | | listener.onMessage(o);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogUtils.e("post异常1:" + e.getMessage());
|
| | | // LogUtils.e("post异常1:" + e.getMessage());
|
| | | }
|
| | | }
|
| | | });
|
| | |
| | |
|
| | | /**
|
| | | * 注册所有主题消息的监听
|
| | | *
|
| | | * @param listener
|
| | | */
|
| | | public synchronized void registerAllTopicsListener(EventListener listener) {
|
| | |
| | |
|
| | | /**
|
| | | * 取消所有主题消息的监听
|
| | | *
|
| | | * @param listener
|
| | | */
|
| | | public synchronized void removeAllTopicsListener(EventListener listener) {
|