Java Code Examples for android.view.View.removeOnAttachStateChangeListener()

The following are Jave code examples for showing how to use removeOnAttachStateChangeListener() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: windowmanager   File: SDWindowManager.java   Source Code and License Vote up 7 votes
/**
 * 添加view到Window
 *
 * @param view
 * @param params
 */
public void addView(View view, ViewGroup.LayoutParams params)
{
    if (view == null)
    {
        return;
    }
    init(view);
    if (containsView(view))
    {
        return;
    }
    if (params == null)
    {
        params = newLayoutParams();
    }

    getWindowManager().addView(view, params);

    view.removeOnAttachStateChangeListener(mInternalOnAttachStateChangeListener);
    view.addOnAttachStateChangeListener(mInternalOnAttachStateChangeListener);
    mMapView.put(view, 0);
}
 
Example 2
Project: poper   File: FPoper.java   Source Code and License Vote up 7 votes
/**
 * 设置目标view
 *
 * @param target
 */
public FPoper setTarget(View target)
{
    final View old = getTarget();
    if (old != target)
    {
        if (old != null)
        {
            old.removeOnAttachStateChangeListener(mOnAttachStateChangeListenerTarget);
        }

        if (target != null)
        {
            mTarget = new WeakReference<>(target);
            target.removeOnAttachStateChangeListener(mOnAttachStateChangeListenerTarget);
            target.addOnAttachStateChangeListener(mOnAttachStateChangeListenerTarget);
        } else
        {
            mTarget = null;
            removeUpdateListener();
        }
    }
    return this;
}
 
Example 3
Project: Bigbang   File: IMMLeaks.java   Source Code and License Vote up 6 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 4
Project: Bigbang   File: IMMLeaks.java   Source Code and License Vote up 6 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 5
Project: diycode   File: IMMLeaks.java   Source Code and License Vote up 6 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 6
Project: diycode   File: IMMLeaks.java   Source Code and License Vote up 6 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 7
Project: DebugOverlay-Android   File: OverlayViewManager.java   Source Code and License Vote up 5 votes
@Override
public void onViewDetachedFromWindow(View v) {
    if (DebugOverlay.DEBUG) {
        Log.i(TAG, "onViewDetachedFromWindow");
    }
    windowManager.removeViewImmediate(_rootView);
    v.removeOnAttachStateChangeListener(this);
}
 
Example 8
Project: EvolvingNetLib   File: CCBaseLazyRxFragment.java   Source Code and License Vote up 4 votes
@Override
public void onViewDetachedFromWindow(View v) {
    v.removeOnAttachStateChangeListener(this);
    checkVisibility(false);
}
 
Example 9
Project: Bigbang   File: IMMLeaks.java   Source Code and License Vote up 4 votes
@Override
public void onViewDetachedFromWindow(View v) {
    v.removeOnAttachStateChangeListener(this);
    Looper.myQueue().removeIdleHandler(this);
    Looper.myQueue().addIdleHandler(this);
}
 
Example 10
Project: windowmanager   File: SDWindowManager.java   Source Code and License Vote up 4 votes
@Override
public void onViewDetachedFromWindow(View v)
{
    v.removeOnAttachStateChangeListener(this);
    mMapView.remove(v);
}
 
Example 11
Project: diycode   File: IMMLeaks.java   Source Code and License Vote up 4 votes
@Override public void onViewDetachedFromWindow(View v) {
  v.removeOnAttachStateChangeListener(this);
  Looper.myQueue().removeIdleHandler(this);
  Looper.myQueue().addIdleHandler(this);
}