public class LiveDataBus { private static LiveDataBus liveDataBus = new LiveDataBus(); Map<String, MutableLiveData<Object>> map; public LiveDataBus() { this.map = new HashMap<>(); } public static LiveDataBus getInstance() { return liveDataBus; } public<T> MutableLiveData<T> with(String key, Class<T> clazz) { if (!map.containsKey(key)) { map.put(key, new MutableLiveData<>()); } return (MutableLiveData<T>) map.get(key); } }
2021-02-23
最新推荐文章于 2021-11-02 19:07:36 发布