Skip to content

Commit

Permalink
Made WrapperListView not try to get reflectionfields mSelectorRect an…
Browse files Browse the repository at this point in the history
…d mSelectorPosition out from AbsListView if running in P or later, since access to them has been removed.
  • Loading branch information
mathiasafjochnick committed Dec 7, 2020
1 parent 81b074e commit 7f792cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ public WrapperViewList(Context context) {
// Use reflection to be able to change the size/position of the list
// selector so it does not come under/over the header
try {
Field selectorRectField = AbsListView.class.getDeclaredField("mSelectorRect");
selectorRectField.setAccessible(true);
mSelectorRect = (Rect) selectorRectField.get(this);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
Field selectorRectField = AbsListView.class.getDeclaredField("mSelectorRect");
selectorRectField.setAccessible(true);
mSelectorRect = (Rect) selectorRectField.get(this);
}


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
mSelectorPositionField = AbsListView.class.getDeclaredField("mSelectorPosition");
mSelectorPositionField.setAccessible(true);
}
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
defaultConfig {
applicationId 'se.emilsjolander.stickylistheaders'
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
}

sourceSets {
Expand Down

0 comments on commit 7f792cf

Please sign in to comment.