Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
a8177574
Commit
a8177574
authored
1 year ago
by
Treehugger Robot
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Make animation notifications thread safe." into main
parents
1c415972
b8a61212
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/java/android/animation/Animator.java
+6
-9
6 additions, 9 deletions
core/java/android/animation/Animator.java
with
6 additions
and
9 deletions
core/java/android/animation/Animator.java
+
6
−
9
View file @
a8177574
...
...
@@ -26,6 +26,7 @@ import android.os.Build;
import
android.util.LongArray
;
import
java.util.ArrayList
;
import
java.util.concurrent.atomic.AtomicReference
;
/**
* This is the superclass for classes which provide basic support for animations which can be
...
...
@@ -76,7 +77,7 @@ public abstract class Animator implements Cloneable {
* of it in case the list is modified while iterating. The array can be reused to avoid
* allocation on every notification.
*/
private
Object
[]
mCachedList
;
private
AtomicReference
<
Object
[]
>
mCachedList
=
new
AtomicReference
<>()
;
/**
* Tracks whether we've notified listeners of the onAnimationStart() event. This can be
...
...
@@ -452,7 +453,7 @@ public abstract class Animator implements Cloneable {
if
(
mPauseListeners
!=
null
)
{
anim
.
mPauseListeners
=
new
ArrayList
<
AnimatorPauseListener
>(
mPauseListeners
);
}
anim
.
mCachedList
=
null
;
anim
.
mCachedList
.
set
(
null
)
;
anim
.
mStartListenersCalled
=
false
;
return
anim
;
}
catch
(
CloneNotSupportedException
e
)
{
...
...
@@ -654,13 +655,9 @@ public abstract class Animator implements Cloneable {
int
size
=
list
==
null
?
0
:
list
.
size
();
if
(
size
>
0
)
{
// Try to reuse mCacheList to store the items of list.
Object
[]
array
;
if
(
mCachedList
==
null
||
mCachedList
.
length
<
size
)
{
Object
[]
array
=
mCachedList
.
getAndSet
(
null
)
;
if
(
array
==
null
||
array
.
length
<
size
)
{
array
=
new
Object
[
size
];
}
else
{
array
=
mCachedList
;
// Clear it in case there is some reentrancy
mCachedList
=
null
;
}
list
.
toArray
(
array
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
...
...
@@ -670,7 +667,7 @@ public abstract class Animator implements Cloneable {
array
[
i
]
=
null
;
}
// Store it for the next call so we can reuse this array, if needed.
mCachedList
=
array
;
mCachedList
.
compareAndSet
(
null
,
array
)
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment