Java Code Examples for android.view.View#removeOnAttachStateChangeListener()
The following examples show how to use
android.view.View#removeOnAttachStateChangeListener() .
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
Source Project: android_9.0.0_r45 File: PopupWindow.java License: Apache License 2.0 | 6 votes |
/** @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; }
Example 2
Source Project: QuickLyric File: IMMLeaks.java License: GNU General Public License v3.0 | 5 votes |
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); } }
Example 3
Source Project: Upchain-wallet File: TKeybord.java License: GNU Affero General Public License v3.0 | 5 votes |
@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); } }
Example 4
Source Project: android_9.0.0_r45 File: AutofillPopupWindow.java License: Apache License 2.0 | 5 votes |
@Override protected void detachFromAnchor() { final View anchor = getAnchor(); if (anchor != null) { anchor.removeOnAttachStateChangeListener(mOnAttachStateChangeListener); } super.detachFromAnchor(); }
Example 5
Source Project: android_9.0.0_r45 File: AccessibilityRequestPreparer.java License: Apache License 2.0 | 5 votes |
@Override public void onViewDetachedFromWindow(View v) { Context context = v.getContext(); if (context != null) { context.getSystemService(AccessibilityManager.class) .removeAccessibilityRequestPreparer(AccessibilityRequestPreparer.this); } v.removeOnAttachStateChangeListener(this); }
Example 6
Source Project: fresco File: VitoViewImpl2.java License: MIT License | 5 votes |
@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); }
Example 7
Source Project: QuickLyric File: IMMLeaks.java License: GNU General Public License v3.0 | 5 votes |
@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); }
Example 8
Source Project: timecat File: IMMLeaks.java License: Apache License 2.0 | 5 votes |
@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); }
Example 9
Source Project: ProjectX File: FloatingActionModeHelper.java License: Apache License 2.0 | 5 votes |
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; }
Example 10
Source Project: timecat File: IMMLeaks.java License: Apache License 2.0 | 5 votes |
@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); } }
Example 11
Source Project: DebugOverlay-Android File: OverlayViewManager.java License: Apache License 2.0 | 5 votes |
@Override public void onViewDetachedFromWindow(View v) { if (DebugOverlay.DEBUG) { Log.i(TAG, "onViewDetachedFromWindow"); } windowManager.removeViewImmediate(_rootView); v.removeOnAttachStateChangeListener(this); }
Example 12
Source Project: diycode File: IMMLeaks.java License: Apache License 2.0 | 5 votes |
@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); }
Example 13
Source Project: diycode File: IMMLeaks.java License: Apache License 2.0 | 5 votes |
@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); } }
Example 14
Source Project: mvp-helpers File: IMMLeaks.java License: MIT License | 5 votes |
@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); }
Example 15
Source Project: HHComicViewer File: IMMLeaks.java License: Apache License 2.0 | 5 votes |
@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); }
Example 16
Source Project: Upchain-wallet File: TKeybord.java License: GNU Affero General Public License v3.0 | 4 votes |
@Override public void onViewDetachedFromWindow(View v) { v.removeOnAttachStateChangeListener(this); Looper.myQueue().removeIdleHandler(this); Looper.myQueue().addIdleHandler(this); }
Example 17
Source Project: rxjava-RxLife File: ViewScope.java License: Apache License 2.0 | 4 votes |
@Override public void onScopeEnd() { final View view = this.view; if (view == null) return; view.removeOnAttachStateChangeListener(this); }
Example 18
Source Project: diycode File: IMMLeaks.java License: Apache License 2.0 | 4 votes |
@Override public void onViewDetachedFromWindow(View v) { v.removeOnAttachStateChangeListener(this); Looper.myQueue().removeIdleHandler(this); Looper.myQueue().addIdleHandler(this); }
Example 19
Source Project: mvp-helpers File: IMMLeaks.java License: MIT License | 4 votes |
@Override public void onViewDetachedFromWindow(View v) { v.removeOnAttachStateChangeListener(this); Looper.myQueue().removeIdleHandler(this); Looper.myQueue().addIdleHandler(this); }
Example 20
Source Project: QuickLyric File: IMMLeaks.java License: GNU General Public License v3.0 | 4 votes |
@Override public void onViewDetachedFromWindow(View v) { v.removeOnAttachStateChangeListener(this); Looper.myQueue().removeIdleHandler(this); Looper.myQueue().addIdleHandler(this); }