Created
September 11, 2022 10:01
-
-
Save hongbeomi/a058f96a1d2d5fffd2304c1adad03974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NonNull | |
private WrapperAndLocalPosition findWrapperAndLocalPosition( | |
int globalPosition | |
) { | |
WrapperAndLocalPosition result; | |
if (mReusableHolder.mInUse) { | |
result = new WrapperAndLocalPosition(); | |
} else { | |
mReusableHolder.mInUse = true; | |
result = mReusableHolder; | |
} | |
int localPosition = globalPosition; | |
for (NestedAdapterWrapper wrapper : mWrappers) { | |
if (wrapper.getCachedItemCount() > localPosition) { | |
result.mWrapper = wrapper; | |
result.mLocalPosition = localPosition; | |
break; | |
} | |
localPosition -= wrapper.getCachedItemCount(); | |
} | |
if (result.mWrapper == null) { | |
throw new IllegalArgumentException("Cannot find wrapper for " + globalPosition); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment