code: private boolean updateAnchorFromChildren(RecyclerView.State state, AnchorInfo anchorInfo) {
          if (getChildCount() == 0) {
              return false;
          }
          final View focused = getFocusedChild();
          if (focused != null && anchorInfo.isViewValidAsAnchor(focused, state)) {
              anchorInfo.assignFromViewAndKeepVisibleRect(focused);
              return true;
          }
          /*
          if (mLastStackFromEnd != mStackFromEnd) {
              return false;
          }
          */
          View referenceChild = anchorInfo.mLayoutFromEnd ? findReferenceChildClosestToEnd(state)
                  : findReferenceChildClosestToStart(state);
          if (referenceChild != null) {
              anchorInfo.assignFromView(referenceChild);
              // If all visible views are removed in 1 pass, reference child might be out of bounds.
              // If that is the case, offset it back to 0 so that we use these pre-layout children.
              if (!state.isPreLayout() && supportsPredictiveItemAnimations()) {
                  // validate this child is at least partially visible. if not, offset it to start
                  final boolean notVisible =
                          mOrientationHelper.getDecoratedStart(referenceChild) >= mOrientationHelper
                                  .getEndAfterPadding()
                                  || mOrientationHelper.getDecoratedEnd(referenceChild)
                                  < mOrientationHelper.getStartAfterPadding();
                  if (notVisible) {
                      anchorInfo.mCoordinate = anchorInfo.mLayoutFromEnd
                              ? mOrientationHelper.getEndAfterPadding()
                              : mOrientationHelper.getStartAfterPadding();
                  }
              }
              return true;
          }
          return false;
      }
docs: Finds an anchor child from existing Views. Most of the time, this is the view closest to
  start or end that has a valid position (e.g. not removed).
  <p>
  If a child has focus, it is given priority.