android.view.View#removeOnAttachStateChangeListener ( )源码实例Demo

下面列出了android.view.View#removeOnAttachStateChangeListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: PopupWindow.java
/** @hide */
protected void detachFromAnchor() {
    final View anchor = getAnchor();
    if (anchor != null) {
        final ViewTreeObserver vto = anchor.getViewTreeObserver();
        vto.removeOnScrollChangedListener(mOnScrollChangedListener);
        anchor.removeOnAttachStateChangeListener(mOnAnchorDetachedListener);
    }

    final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
    if (anchorRoot != null) {
        anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener);
        anchorRoot.removeOnLayoutChangeListener(mOnLayoutChangeListener);
    }

    mAnchor = null;
    mAnchorRoot = null;
    mIsAnchorRootAttached = false;
}
 
源代码2 项目: QuickLyric   文件: IMMLeaks.java
private void clearInputMethodManagerLeak() {
    try {
        Object lock = mHField.get(inputMethodManager);
        // This is highly dependent on the InputMethodManager implementation.
        synchronized (lock) {
            View servedView = (View) mServedViewField.get(inputMethodManager);
            if (servedView != null) {

                boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;

                if (servedViewAttached) {
                    // The view held by the IMM was replaced without a global focus change. Let's make
                    // sure we get notified when that view detaches.

                    // Avoid double registration.
                    servedView.removeOnAttachStateChangeListener(this);
                    servedView.addOnAttachStateChangeListener(this);
                } else {
                    // servedView is not attached. InputMethodManager is being stupid!
                    Activity activity = extractActivity(servedView.getContext());
                    if (activity == null || activity.getWindow() == null) {
                        // Unlikely case. Let's finish the input anyways.
                        finishInputLockedMethod.invoke(inputMethodManager);
                    } else {
                        View decorView = activity.getWindow().peekDecorView();
                        boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
                        if (!windowAttached) {
                            finishInputLockedMethod.invoke(inputMethodManager);
                        } else {
                            decorView.requestFocusFromTouch();
                        }
                    }
                }
            }
        }
    } catch (Exception unexpected) {
        Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
    }
}
 
源代码3 项目: Upchain-wallet   文件: TKeybord.java
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
    try {
        Object lock = mHField.get(inputMethodManager);
        // This is highly dependent on the InputMethodManager implementation.
        synchronized (lock) {
            View servedView = (View) mServedViewField.get(inputMethodManager);
            if (servedView != null) {

                boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;

                if (servedViewAttached) {
                    // The view held by the IMM was replaced without a global focus change. Let's make
                    // sure we get notified when that view detaches.

                    // Avoid double registration.
                    servedView.removeOnAttachStateChangeListener(this);
                    servedView.addOnAttachStateChangeListener(this);
                } else {
                    // servedView is not attached. InputMethodManager is being stupid!
                    Activity activity = extractActivity(servedView.getContext());
                    if (activity == null || activity.getWindow() == null) {
                        // Unlikely case. Let's finish the input anyways.
                        finishInputLockedMethod.invoke(inputMethodManager);
                    } else {
                        View decorView = activity.getWindow().peekDecorView();
                        boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
                        if (!windowAttached) {
                            finishInputLockedMethod.invoke(inputMethodManager);
                        } else {
                            decorView.requestFocusFromTouch();
                        }
                    }
                }
            }
        }
    } catch (IllegalAccessException | InvocationTargetException unexpected) {
        Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: AutofillPopupWindow.java
@Override
protected void detachFromAnchor() {
    final View anchor = getAnchor();
    if (anchor != null) {
        anchor.removeOnAttachStateChangeListener(mOnAttachStateChangeListener);
    }
    super.detachFromAnchor();
}
 
@Override
public void onViewDetachedFromWindow(View v) {
    Context context = v.getContext();
    if (context != null) {
        context.getSystemService(AccessibilityManager.class)
                .removeAccessibilityRequestPreparer(AccessibilityRequestPreparer.this);
    }
    v.removeOnAttachStateChangeListener(this);
}
 
源代码6 项目: fresco   文件: VitoViewImpl2.java
@Override
public void show(
    final ImageSource imageSource,
    final ImageOptions imageOptions,
    final @Nullable Object callerContext,
    final @Nullable ImageListener imageListener,
    final View target) {
  VitoImageRequest imageRequest =
      mVitoImagePipeline.createImageRequest(target.getResources(), imageSource, imageOptions);

  final FrescoDrawable2 frescoDrawable = ensureDrawableSet(target);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // If the view is already attached, we should tell this to controller.
    if (target.isAttachedToWindow()) {
      onAttach(frescoDrawable, imageRequest);
    } else {
      // The fetch will be submitted later when / if the View is attached.
      frescoDrawable.setImageRequest(imageRequest);
      frescoDrawable.setCallerContext(callerContext);
      frescoDrawable.setImageListener(imageListener);
    }
  } else {
    // Before Kitkat we don't have a good way to know.
    // Normally we expect the view to be already attached, thus we always call `onAttach`.
    onAttach(frescoDrawable, imageRequest);
  }

  // `addOnAttachStateChangeListener` is not idempotent
  target.removeOnAttachStateChangeListener(sOnAttachStateChangeListenerCallback);
  target.addOnAttachStateChangeListener(sOnAttachStateChangeListenerCallback);
}
 
源代码7 项目: QuickLyric   文件: IMMLeaks.java
@Override public void onGlobalFocusChanged(View oldFocus, View newFocus) {
    if (newFocus == null) {
        return;
    }
    if (oldFocus != null) {
        oldFocus.removeOnAttachStateChangeListener(this);
    }
    Looper.myQueue().removeIdleHandler(this);
    newFocus.addOnAttachStateChangeListener(this);
}
 
源代码8 项目: timecat   文件: IMMLeaks.java
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
    if (newFocus == null) {
        return;
    }
    if (oldFocus != null) {
        oldFocus.removeOnAttachStateChangeListener(this);
    }
    Looper.myQueue().removeIdleHandler(this);
    newFocus.addOnAttachStateChangeListener(this);
}
 
源代码9 项目: ProjectX   文件: FloatingActionModeHelper.java
private void finish(boolean immediate) {
    mView.removeView(immediate);
    mCallback.onDestroyActionMode(mMode);
    mFinished = true;
    mTarget.removeOnAttachStateChangeListener(this);
    final View root = mTarget.getRootView();
    root.removeOnLayoutChangeListener(this);
    root.removeOnAttachStateChangeListener(this);
    mTarget = null;
}
 
源代码10 项目: timecat   文件: IMMLeaks.java
@TargetApi(Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
    try {
        Object lock = mHField.get(inputMethodManager);
        // This is highly dependent on the InputMethodManager implementation.
        synchronized (lock) {
            View servedView = (View) mServedViewField.get(inputMethodManager);
            if (servedView != null) {

                boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;

                if (servedViewAttached) {
                    // The view held by the IMM was replaced without a global focus change. Let's make
                    // sure we get notified when that view detaches.

                    // Avoid double registration.
                    servedView.removeOnAttachStateChangeListener(this);
                    servedView.addOnAttachStateChangeListener(this);
                } else {
                    // servedView is not attached. InputMethodManager is being stupid!
                    Activity activity = extractActivity(servedView.getContext());
                    if (activity == null || activity.getWindow() == null) {
                        // Unlikely case. Let's finish the input anyways.
                        finishInputLockedMethod.invoke(inputMethodManager);
                    } else {
                        View decorView = activity.getWindow().peekDecorView();
                        boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
                        if (!windowAttached) {
                            finishInputLockedMethod.invoke(inputMethodManager);
                        } else {
                            decorView.requestFocusFromTouch();
                        }
                    }
                }
            }
        }
    } catch (IllegalAccessException | InvocationTargetException unexpected) {
        Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
    }
}
 
源代码11 项目: DebugOverlay-Android   文件: OverlayViewManager.java
@Override
public void onViewDetachedFromWindow(View v) {
    if (DebugOverlay.DEBUG) {
        Log.i(TAG, "onViewDetachedFromWindow");
    }
    windowManager.removeViewImmediate(_rootView);
    v.removeOnAttachStateChangeListener(this);
}
 
源代码12 项目: diycode   文件: IMMLeaks.java
@Override public void onGlobalFocusChanged(View oldFocus, View newFocus) {
  if (newFocus == null) {
    return;
  }
  if (oldFocus != null) {
    oldFocus.removeOnAttachStateChangeListener(this);
  }
  Looper.myQueue().removeIdleHandler(this);
  newFocus.addOnAttachStateChangeListener(this);
}
 
源代码13 项目: diycode   文件: IMMLeaks.java
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
  try {
    Object lock = mHField.get(inputMethodManager);
    // This is highly dependent on the InputMethodManager implementation.
    synchronized (lock) {
      View servedView = (View) mServedViewField.get(inputMethodManager);
      if (servedView != null) {

        boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;

        if (servedViewAttached) {
          // The view held by the IMM was replaced without a global focus change. Let's make
          // sure we get notified when that view detaches.

          // Avoid double registration.
          servedView.removeOnAttachStateChangeListener(this);
          servedView.addOnAttachStateChangeListener(this);
        } else {
          // servedView is not attached. InputMethodManager is being stupid!
          Activity activity = extractActivity(servedView.getContext());
          if (activity == null || activity.getWindow() == null) {
            // Unlikely case. Let's finish the input anyways.
            finishInputLockedMethod.invoke(inputMethodManager);
          } else {
            View decorView = activity.getWindow().peekDecorView();
            boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
            if (!windowAttached) {
              finishInputLockedMethod.invoke(inputMethodManager);
            } else {
              decorView.requestFocusFromTouch();
            }
          }
        }
      }
    }
  } catch (IllegalAccessException | InvocationTargetException unexpected) {
    Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
  }
}
 
源代码14 项目: mvp-helpers   文件: IMMLeaks.java
@Override public void onGlobalFocusChanged(View oldFocus, View newFocus) {
    if (newFocus == null) {
        return;
    }
    if (oldFocus != null) {
        oldFocus.removeOnAttachStateChangeListener(this);
    }
    Looper.myQueue().removeIdleHandler(this);
    newFocus.addOnAttachStateChangeListener(this);
}
 
源代码15 项目: HHComicViewer   文件: IMMLeaks.java
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
    if (newFocus == null) {
        return;
    }
    if (oldFocus != null) {
        oldFocus.removeOnAttachStateChangeListener(this);
    }
    Looper.myQueue().removeIdleHandler(this);
    newFocus.addOnAttachStateChangeListener(this);
}
 
源代码16 项目: Upchain-wallet   文件: TKeybord.java
@Override
public void onViewDetachedFromWindow(View v) {
    v.removeOnAttachStateChangeListener(this);
    Looper.myQueue().removeIdleHandler(this);
    Looper.myQueue().addIdleHandler(this);
}
 
源代码17 项目: rxjava-RxLife   文件: ViewScope.java
@Override
public void onScopeEnd() {
    final View view = this.view;
    if (view == null) return;
    view.removeOnAttachStateChangeListener(this);
}
 
源代码18 项目: diycode   文件: IMMLeaks.java
@Override public void onViewDetachedFromWindow(View v) {
  v.removeOnAttachStateChangeListener(this);
  Looper.myQueue().removeIdleHandler(this);
  Looper.myQueue().addIdleHandler(this);
}
 
源代码19 项目: mvp-helpers   文件: IMMLeaks.java
@Override public void onViewDetachedFromWindow(View v) {
    v.removeOnAttachStateChangeListener(this);
    Looper.myQueue().removeIdleHandler(this);
    Looper.myQueue().addIdleHandler(this);
}
 
源代码20 项目: QuickLyric   文件: IMMLeaks.java
@Override public void onViewDetachedFromWindow(View v) {
    v.removeOnAttachStateChangeListener(this);
    Looper.myQueue().removeIdleHandler(this);
    Looper.myQueue().addIdleHandler(this);
}
 
 方法所在类
 同类方法