/** * Returns the path segment for the underlying adapter. * * @return AdapterPathSegment for the wrapped adapter */ @NonNull public AdapterPathSegment getWrappedAdapterSegment() { return new AdapterPathSegment(mWrappedAdapter, mWrappedAdapterTag); }
/** * Returns the path segment for the header adapter. * * @return AdapterPathSegment for the header adapter */ @NonNull public AdapterPathSegment getHeaderSegment() { return new AdapterPathSegment(mHeaderAdapter, mHeaderAdapterTag); }
/** * Returns the path segment for the footer adapter. * * @return AdapterPathSegment for the footer adapter */ @NonNull public AdapterPathSegment getFooterSegment() { return new AdapterPathSegment(mFooterAdapter, mFooterAdapterTag); }
/** * Appends path segment. * * @param adapter The adapter * @param tag The tag object * @return {@link AdapterPath} instance itself. */ @NonNull public AdapterPath append(@NonNull RecyclerView.Adapter adapter, @Nullable Object tag) { return append(new AdapterPathSegment(adapter, tag)); }
/** * {@inheritDoc} * <p> * This class also invokes {@link WrapperAdapter#wrapPosition(AdapterPathSegment, int)} of the child adapter when * verify option is enabled. * If inconsistency has been detected, <code>IllegalStateException</code> will be thrown. */ @Override public void unwrapPosition(@NonNull UnwrapPositionResult dest, int position) { if (((mFlags & FLAG_VERIFY_UNWRAP_POSITION) != 0) && (getWrappedAdapter() instanceof WrapperAdapter)) { final WrapperAdapter wrapperAdapter = (WrapperAdapter) getWrappedAdapter(); final UnwrapPositionResult tmpResult = new UnwrapPositionResult(); wrapperAdapter.unwrapPosition(tmpResult, position); if (tmpResult.isValid()) { final AdapterPathSegment segment = new AdapterPathSegment(tmpResult.adapter, tmpResult.tag); final int reWrappedPosition = wrapperAdapter.wrapPosition(segment, tmpResult.position); if (position != reWrappedPosition) { final String wrappedClassName = getWrappedAdapter().getClass().getSimpleName(); throw new IllegalStateException( "Found a WrapperAdapter implementation issue while executing unwrapPosition(): " + wrappedClassName + "\n" + "unwrapPosition(" + position + ") returns " + tmpResult.position + ", but " + "wrapPosition(" + tmpResult.position + ") returns " + reWrappedPosition); } } } super.unwrapPosition(dest, position); }
destPath.append(new AdapterPathSegment(originAdapter, null));