androidannotation的OnViewChangedNotifier

浏览:44日期:2022-11-06

问题描述

androidannotation中的OnViewChangedNotifier有什么作用?

问题解答

回答1:

直接看代码 OnViewChangedNotifier

public class OnViewChangedNotifier { private static OnViewChangedNotifier currentNotifier; public static OnViewChangedNotifier replaceNotifier(OnViewChangedNotifier notifier) {OnViewChangedNotifier previousNotifier = currentNotifier;currentNotifier = notifier;return previousNotifier; } public static void registerOnViewChangedListener(OnViewChangedListener listener) {if (currentNotifier != null) { currentNotifier.listeners.add(listener);} } private final Set<OnViewChangedListener> listeners = new LinkedHashSet<>(); public void notifyViewChanged(HasViews hasViews) {for (OnViewChangedListener listener : listeners) { listener.onViewChanged(hasViews);} }}

可以很明显的看到是用来调用 onViewChanged 来通知 OnViewChangedListener 说明一个 View 状态改变了的助手类。

相关文章: