@Override
  protected void onDetachedFromWindow() {
    if (mLayoutManager != null) mLayoutManager.destroy();
    flushInvalidation();
    mInvalidator.set(null);
    super.onDetachedFromWindow();

    // Removes the accessibility node provider from this view.
    if (mNodeProvider != null) {
      mAccessibilityView.setAccessibilityDelegate(null);
      mNodeProvider = null;
      removeView(mAccessibilityView);
      mAccessibilityView = null;
    }
  }
 @Override
 protected void onAttachedToWindow() {
   mInvalidator.set(this);
   super.onAttachedToWindow();
 }