Java Code Examples for android.view.View#OnAttachStateChangeListener

The following examples show how to use android.view.View#OnAttachStateChangeListener . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
    this.recyclerView = recyclerView;
    recyclerViewAttachStateChangeListener = new View.OnAttachStateChangeListener() {
        public void onViewAttachedToWindow(View v) {

        public void onViewDetachedFromWindow(View v) {
    for (LocalAdapter<?> localAdapter : localAdapters) {
Example 2
Source Project: coordinators   File:    License: Apache License 2.0 6 votes vote down vote up
 * Attempts to bind a view to a {@link Coordinator}.
 * Immediately calls provider to obtain a Coordinator for the view. If a non-null Coordinator is
 * returned, that Coordinator is permanently bound to the View.
public static void bind(@NonNull View view, @NonNull CoordinatorProvider provider) {
  final Coordinator coordinator = provider.provideCoordinator(view);
  if (coordinator == null) {

  View.OnAttachStateChangeListener binding = new Binding(coordinator, view);
  // Sometimes we missed the first attach because the child's already been added.
  // Sometimes we didn't. The binding keeps track to avoid double attachment of the Coordinator,
  // and to guard against attachment to two different views simultaneously.
  if (isAttachedToWindow(view)) {
Example 3
public View.OnAttachStateChangeListener getOnAttachStateChangeListener() {
    return mOnAttachStateChangeListener;
Example 4
public void setOnAttachStateChangeListener(View.OnAttachStateChangeListener listener) {
    this.mOnAttachStateChangeListener = listener;
Example 5
Source Project: RxLifecycle   File:    License: Apache License 2.0 2 votes vote down vote up
 * Manually retrieve the view's attach state change listeners of an event. Robolectric
 * doesn't currently support manually firing these, and it would seem the events are not called
 * in normal Robolectric usage either.
 * @param view View with listeners to notify
static CopyOnWriteArrayList<View.OnAttachStateChangeListener> getAttachStateChangeListeners(View view) {
    Object listenerInfo = ReflectionHelpers.callInstanceMethod(view, "getListenerInfo");
    return ReflectionHelpers.getField(listenerInfo, "mOnAttachStateChangeListeners");