Methods Summary |
---|
public void | addOnComputeInternalInsetsListener(android.view.ViewTreeObserver$OnComputeInternalInsetsListener listener)Register a callback to be invoked when the invoked when it is time to
compute the window's internal insets.
checkIsAlive();
if (mOnComputeInternalInsetsListeners == null) {
mOnComputeInternalInsetsListeners =
new CopyOnWriteArray<OnComputeInternalInsetsListener>();
}
mOnComputeInternalInsetsListeners.add(listener);
|
public void | addOnDrawListener(android.view.ViewTreeObserver$OnDrawListener listener)Register a callback to be invoked when the view tree is about to be drawn.
Note: this method cannot be invoked from
{@link android.view.ViewTreeObserver.OnDrawListener#onDraw()}.
checkIsAlive();
if (mOnDrawListeners == null) {
mOnDrawListeners = new ArrayList<OnDrawListener>();
}
mOnDrawListeners.add(listener);
|
public void | addOnEnterAnimationCompleteListener(android.view.ViewTreeObserver$OnEnterAnimationCompleteListener listener)
checkIsAlive();
if (mOnEnterAnimationCompleteListeners == null) {
mOnEnterAnimationCompleteListeners =
new CopyOnWriteArrayList<OnEnterAnimationCompleteListener>();
}
mOnEnterAnimationCompleteListeners.add(listener);
|
public void | addOnGlobalFocusChangeListener(android.view.ViewTreeObserver$OnGlobalFocusChangeListener listener)Register a callback to be invoked when the focus state within the view tree changes.
checkIsAlive();
if (mOnGlobalFocusListeners == null) {
mOnGlobalFocusListeners = new CopyOnWriteArrayList<OnGlobalFocusChangeListener>();
}
mOnGlobalFocusListeners.add(listener);
|
public void | addOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener listener)Register a callback to be invoked when the global layout state or the visibility of views
within the view tree changes
checkIsAlive();
if (mOnGlobalLayoutListeners == null) {
mOnGlobalLayoutListeners = new CopyOnWriteArray<OnGlobalLayoutListener>();
}
mOnGlobalLayoutListeners.add(listener);
|
public void | addOnPreDrawListener(android.view.ViewTreeObserver$OnPreDrawListener listener)Register a callback to be invoked when the view tree is about to be drawn
checkIsAlive();
if (mOnPreDrawListeners == null) {
mOnPreDrawListeners = new CopyOnWriteArray<OnPreDrawListener>();
}
mOnPreDrawListeners.add(listener);
|
public void | addOnScrollChangedListener(android.view.ViewTreeObserver$OnScrollChangedListener listener)Register a callback to be invoked when a view has been scrolled.
checkIsAlive();
if (mOnScrollChangedListeners == null) {
mOnScrollChangedListeners = new CopyOnWriteArray<OnScrollChangedListener>();
}
mOnScrollChangedListeners.add(listener);
|
public void | addOnTouchModeChangeListener(android.view.ViewTreeObserver$OnTouchModeChangeListener listener)Register a callback to be invoked when the invoked when the touch mode changes.
checkIsAlive();
if (mOnTouchModeChangeListeners == null) {
mOnTouchModeChangeListeners = new CopyOnWriteArrayList<OnTouchModeChangeListener>();
}
mOnTouchModeChangeListeners.add(listener);
|
public void | addOnWindowAttachListener(android.view.ViewTreeObserver$OnWindowAttachListener listener)Register a callback to be invoked when the view hierarchy is attached to a window.
checkIsAlive();
if (mOnWindowAttachListeners == null) {
mOnWindowAttachListeners
= new CopyOnWriteArrayList<OnWindowAttachListener>();
}
mOnWindowAttachListeners.add(listener);
|
public void | addOnWindowFocusChangeListener(android.view.ViewTreeObserver$OnWindowFocusChangeListener listener)Register a callback to be invoked when the window focus state within the view tree changes.
checkIsAlive();
if (mOnWindowFocusListeners == null) {
mOnWindowFocusListeners
= new CopyOnWriteArrayList<OnWindowFocusChangeListener>();
}
mOnWindowFocusListeners.add(listener);
|
public void | addOnWindowShownListener(android.view.ViewTreeObserver$OnWindowShownListener listener)Register a callback to be invoked when the view tree window has been shown
checkIsAlive();
if (mOnWindowShownListeners == null) {
mOnWindowShownListeners = new CopyOnWriteArray<OnWindowShownListener>();
}
mOnWindowShownListeners.add(listener);
if (mWindowShown) {
listener.onWindowShown();
}
|
private void | checkIsAlive()
if (!mAlive) {
throw new IllegalStateException("This ViewTreeObserver is not alive, call "
+ "getViewTreeObserver() again");
}
|
final void | dispatchOnComputeInternalInsets(android.view.ViewTreeObserver$InternalInsetsInfo inoutInfo)Calls all listeners to compute the current insets.
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArray<OnComputeInternalInsetsListener> listeners =
mOnComputeInternalInsetsListeners;
if (listeners != null && listeners.size() > 0) {
CopyOnWriteArray.Access<OnComputeInternalInsetsListener> access = listeners.start();
try {
int count = access.size();
for (int i = 0; i < count; i++) {
access.get(i).onComputeInternalInsets(inoutInfo);
}
} finally {
listeners.end();
}
}
|
public final void | dispatchOnDraw()Notifies registered listeners that the drawing pass is about to start.
if (mOnDrawListeners != null) {
final ArrayList<OnDrawListener> listeners = mOnDrawListeners;
int numListeners = listeners.size();
for (int i = 0; i < numListeners; ++i) {
listeners.get(i).onDraw();
}
}
|
public final void | dispatchOnEnterAnimationComplete()
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArrayList<OnEnterAnimationCompleteListener> listeners =
mOnEnterAnimationCompleteListeners;
if (listeners != null && !listeners.isEmpty()) {
for (OnEnterAnimationCompleteListener listener : listeners) {
listener.onEnterAnimationComplete();
}
}
|
final void | dispatchOnGlobalFocusChange(View oldFocus, View newFocus)Notifies registered listeners that focus has changed.
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArrayList<OnGlobalFocusChangeListener> listeners = mOnGlobalFocusListeners;
if (listeners != null && listeners.size() > 0) {
for (OnGlobalFocusChangeListener listener : listeners) {
listener.onGlobalFocusChanged(oldFocus, newFocus);
}
}
|
public final void | dispatchOnGlobalLayout()Notifies registered listeners that a global layout happened. This can be called
manually if you are forcing a layout on a View or a hierarchy of Views that are
not attached to a Window or in the GONE state.
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArray<OnGlobalLayoutListener> listeners = mOnGlobalLayoutListeners;
if (listeners != null && listeners.size() > 0) {
CopyOnWriteArray.Access<OnGlobalLayoutListener> access = listeners.start();
try {
int count = access.size();
for (int i = 0; i < count; i++) {
access.get(i).onGlobalLayout();
}
} finally {
listeners.end();
}
}
|
public final boolean | dispatchOnPreDraw()Notifies registered listeners that the drawing pass is about to start. If a
listener returns true, then the drawing pass is canceled and rescheduled. This can
be called manually if you are forcing the drawing on a View or a hierarchy of Views
that are not attached to a Window or in the GONE state.
boolean cancelDraw = false;
final CopyOnWriteArray<OnPreDrawListener> listeners = mOnPreDrawListeners;
if (listeners != null && listeners.size() > 0) {
CopyOnWriteArray.Access<OnPreDrawListener> access = listeners.start();
try {
int count = access.size();
for (int i = 0; i < count; i++) {
cancelDraw |= !(access.get(i).onPreDraw());
}
} finally {
listeners.end();
}
}
return cancelDraw;
|
final void | dispatchOnScrollChanged()Notifies registered listeners that something has scrolled.
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArray<OnScrollChangedListener> listeners = mOnScrollChangedListeners;
if (listeners != null && listeners.size() > 0) {
CopyOnWriteArray.Access<OnScrollChangedListener> access = listeners.start();
try {
int count = access.size();
for (int i = 0; i < count; i++) {
access.get(i).onScrollChanged();
}
} finally {
listeners.end();
}
}
|
final void | dispatchOnTouchModeChanged(boolean inTouchMode)Notifies registered listeners that the touch mode has changed.
final CopyOnWriteArrayList<OnTouchModeChangeListener> listeners =
mOnTouchModeChangeListeners;
if (listeners != null && listeners.size() > 0) {
for (OnTouchModeChangeListener listener : listeners) {
listener.onTouchModeChanged(inTouchMode);
}
}
|
final void | dispatchOnWindowAttachedChange(boolean attached)Notifies registered listeners that window has been attached/detached.
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArrayList<OnWindowAttachListener> listeners
= mOnWindowAttachListeners;
if (listeners != null && listeners.size() > 0) {
for (OnWindowAttachListener listener : listeners) {
if (attached) listener.onWindowAttached();
else listener.onWindowDetached();
}
}
|
final void | dispatchOnWindowFocusChange(boolean hasFocus)Notifies registered listeners that window focus has changed.
// NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
// perform the dispatching. The iterator is a safe guard against listeners that
// could mutate the list by calling the various add/remove methods. This prevents
// the array from being modified while we iterate it.
final CopyOnWriteArrayList<OnWindowFocusChangeListener> listeners
= mOnWindowFocusListeners;
if (listeners != null && listeners.size() > 0) {
for (OnWindowFocusChangeListener listener : listeners) {
listener.onWindowFocusChanged(hasFocus);
}
}
|
public final void | dispatchOnWindowShown()Notifies registered listeners that the window is now shown
mWindowShown = true;
final CopyOnWriteArray<OnWindowShownListener> listeners = mOnWindowShownListeners;
if (listeners != null && listeners.size() > 0) {
CopyOnWriteArray.Access<OnWindowShownListener> access = listeners.start();
try {
int count = access.size();
for (int i = 0; i < count; i++) {
access.get(i).onWindowShown();
}
} finally {
listeners.end();
}
}
|
final boolean | hasComputeInternalInsetsListeners()Returns whether there are listeners for computing internal insets.
final CopyOnWriteArray<OnComputeInternalInsetsListener> listeners =
mOnComputeInternalInsetsListeners;
return (listeners != null && listeners.size() > 0);
|
final boolean | hasOnPreDrawListeners()Returns whether there are listeners for on pre-draw events.
return mOnPreDrawListeners != null && mOnPreDrawListeners.size() > 0;
|
public boolean | isAlive()Indicates whether this ViewTreeObserver is alive. When an observer is not alive,
any call to a method (except this one) will throw an exception.
If an application keeps a long-lived reference to this ViewTreeObserver, it should
always check for the result of this method before calling any other method.
return mAlive;
|
private void | kill()Marks this ViewTreeObserver as not alive. After invoking this method, invoking
any other method but {@link #isAlive()} and {@link #kill()} will throw an Exception.
mAlive = false;
|
void | merge(android.view.ViewTreeObserver observer)Merges all the listeners registered on the specified observer with the listeners
registered on this object. After this method is invoked, the specified observer
will return false in {@link #isAlive()} and should not be used anymore.
if (observer.mOnWindowAttachListeners != null) {
if (mOnWindowAttachListeners != null) {
mOnWindowAttachListeners.addAll(observer.mOnWindowAttachListeners);
} else {
mOnWindowAttachListeners = observer.mOnWindowAttachListeners;
}
}
if (observer.mOnWindowFocusListeners != null) {
if (mOnWindowFocusListeners != null) {
mOnWindowFocusListeners.addAll(observer.mOnWindowFocusListeners);
} else {
mOnWindowFocusListeners = observer.mOnWindowFocusListeners;
}
}
if (observer.mOnGlobalFocusListeners != null) {
if (mOnGlobalFocusListeners != null) {
mOnGlobalFocusListeners.addAll(observer.mOnGlobalFocusListeners);
} else {
mOnGlobalFocusListeners = observer.mOnGlobalFocusListeners;
}
}
if (observer.mOnGlobalLayoutListeners != null) {
if (mOnGlobalLayoutListeners != null) {
mOnGlobalLayoutListeners.addAll(observer.mOnGlobalLayoutListeners);
} else {
mOnGlobalLayoutListeners = observer.mOnGlobalLayoutListeners;
}
}
if (observer.mOnPreDrawListeners != null) {
if (mOnPreDrawListeners != null) {
mOnPreDrawListeners.addAll(observer.mOnPreDrawListeners);
} else {
mOnPreDrawListeners = observer.mOnPreDrawListeners;
}
}
if (observer.mOnTouchModeChangeListeners != null) {
if (mOnTouchModeChangeListeners != null) {
mOnTouchModeChangeListeners.addAll(observer.mOnTouchModeChangeListeners);
} else {
mOnTouchModeChangeListeners = observer.mOnTouchModeChangeListeners;
}
}
if (observer.mOnComputeInternalInsetsListeners != null) {
if (mOnComputeInternalInsetsListeners != null) {
mOnComputeInternalInsetsListeners.addAll(observer.mOnComputeInternalInsetsListeners);
} else {
mOnComputeInternalInsetsListeners = observer.mOnComputeInternalInsetsListeners;
}
}
if (observer.mOnScrollChangedListeners != null) {
if (mOnScrollChangedListeners != null) {
mOnScrollChangedListeners.addAll(observer.mOnScrollChangedListeners);
} else {
mOnScrollChangedListeners = observer.mOnScrollChangedListeners;
}
}
if (observer.mOnWindowShownListeners != null) {
if (mOnWindowShownListeners != null) {
mOnWindowShownListeners.addAll(observer.mOnWindowShownListeners);
} else {
mOnWindowShownListeners = observer.mOnWindowShownListeners;
}
}
observer.kill();
|
public void | removeGlobalOnLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener victim)Remove a previously installed global layout callback
removeOnGlobalLayoutListener(victim);
|
public void | removeOnComputeInternalInsetsListener(android.view.ViewTreeObserver$OnComputeInternalInsetsListener victim)Remove a previously installed internal insets computation callback
checkIsAlive();
if (mOnComputeInternalInsetsListeners == null) {
return;
}
mOnComputeInternalInsetsListeners.remove(victim);
|
public void | removeOnDrawListener(android.view.ViewTreeObserver$OnDrawListener victim)Remove a previously installed pre-draw callback.
Note: this method cannot be invoked from
{@link android.view.ViewTreeObserver.OnDrawListener#onDraw()}.
checkIsAlive();
if (mOnDrawListeners == null) {
return;
}
mOnDrawListeners.remove(victim);
|
public void | removeOnEnterAnimationCompleteListener(android.view.ViewTreeObserver$OnEnterAnimationCompleteListener listener)
checkIsAlive();
if (mOnEnterAnimationCompleteListeners == null) {
return;
}
mOnEnterAnimationCompleteListeners.remove(listener);
|
public void | removeOnGlobalFocusChangeListener(android.view.ViewTreeObserver$OnGlobalFocusChangeListener victim)Remove a previously installed focus change callback.
checkIsAlive();
if (mOnGlobalFocusListeners == null) {
return;
}
mOnGlobalFocusListeners.remove(victim);
|
public void | removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener victim)Remove a previously installed global layout callback
checkIsAlive();
if (mOnGlobalLayoutListeners == null) {
return;
}
mOnGlobalLayoutListeners.remove(victim);
|
public void | removeOnPreDrawListener(android.view.ViewTreeObserver$OnPreDrawListener victim)Remove a previously installed pre-draw callback
checkIsAlive();
if (mOnPreDrawListeners == null) {
return;
}
mOnPreDrawListeners.remove(victim);
|
public void | removeOnScrollChangedListener(android.view.ViewTreeObserver$OnScrollChangedListener victim)Remove a previously installed scroll-changed callback
checkIsAlive();
if (mOnScrollChangedListeners == null) {
return;
}
mOnScrollChangedListeners.remove(victim);
|
public void | removeOnTouchModeChangeListener(android.view.ViewTreeObserver$OnTouchModeChangeListener victim)Remove a previously installed touch mode change callback
checkIsAlive();
if (mOnTouchModeChangeListeners == null) {
return;
}
mOnTouchModeChangeListeners.remove(victim);
|
public void | removeOnWindowAttachListener(android.view.ViewTreeObserver$OnWindowAttachListener victim)Remove a previously installed window attach callback.
checkIsAlive();
if (mOnWindowAttachListeners == null) {
return;
}
mOnWindowAttachListeners.remove(victim);
|
public void | removeOnWindowFocusChangeListener(android.view.ViewTreeObserver$OnWindowFocusChangeListener victim)Remove a previously installed window focus change callback.
checkIsAlive();
if (mOnWindowFocusListeners == null) {
return;
}
mOnWindowFocusListeners.remove(victim);
|
public void | removeOnWindowShownListener(android.view.ViewTreeObserver$OnWindowShownListener victim)Remove a previously installed window shown callback
checkIsAlive();
if (mOnWindowShownListeners == null) {
return;
}
mOnWindowShownListeners.remove(victim);
|