View recycling - fix API access and disable when not possible#45484
Closed
tdn120 wants to merge 1 commit into
Closed
View recycling - fix API access and disable when not possible#45484tdn120 wants to merge 1 commit into
tdn120 wants to merge 1 commit into
Conversation
Summary: Prior to Android SDK 28, there was no way to tell if a View's pivotX or pivotY were set. Unfortunately this breaks view recycling due to the default behavior of: - `getPivotX()` and `getPivotY()` [initialize as 0](https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r81/libs/hwui/RenderProperties.h#643) - As long as they haven't been set, [they actually default to width/2 and height/2](https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r81/libs/hwui/RenderProperties.cpp#195). Thus even if we were to check for `getPixotX() == 0`, we wouldn't know if it was specifically set to 0 (making the pivot actually 0), or still just the default value. We'd then need to reset the pivot any time the width or height changed. [`View.resetPivot()`](https://developer.android.com/reference/android/view/View#resetPivot%28%29) was presumably added to fix this in API 28. This diff adds nullability to `prepareToRecycleView()` so we can act accordingly - returning null if the view can't be recycled. Also added a version check for [`setAnimationMatrix()`](https://developer.android.com/reference/android/view/View#setAnimationMatrix%28android.graphics.Matrix%29), which is only available in 29+. Changelog: [Internal] Differential Revision: D59827328
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D59827328 |
Contributor
|
This pull request has been merged in b107248. |
Collaborator
|
This pull request was successfully merged by Thomas Nardone in b107248 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Prior to Android SDK 28, there was no way to tell if a View's pivotX or pivotY were set. Unfortunately this breaks view recycling due to the default behavior of:
getPivotX()andgetPivotY()initialize as 0Thus even if we were to check for
getPixotX() == 0, we wouldn't know if it was specifically set to 0 (making the pivot actually 0), or still just the default value. We'd then need to reset the pivot any time the width or height changed.View.resetPivot()was presumably added to fix this in API 28.This diff adds nullability to
prepareToRecycleView()so we can act accordingly - returning null if the view can't be recycled.Also added a version check for
setAnimationMatrix(), which is only available in 29+.Changelog: [Internal]
Differential Revision: D59827328