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
5c4291d7
Commit
5c4291d7
authored
3 years ago
by
Steve Elliott
Committed by
Android (Google) Code Review
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Fix stale View tracking in ShadeViewDiffer" into tm-dev
parents
017ebacd
0b079161
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
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt
+21
-30
21 additions, 30 deletions
...atusbar/notification/collection/render/ShadeViewDiffer.kt
with
21 additions
and
30 deletions
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt
+
21
−
30
View file @
5c4291d7
...
...
@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.notification.collection.render
import
android.annotation.MainThread
import
android.view.View
import
com.android.systemui.util.kotlin.transform
import
com.android.systemui.util.traceSection
/**
...
...
@@ -41,7 +40,6 @@ class ShadeViewDiffer(
)
{
private
val
rootNode
=
ShadeNode
(
rootController
)
private
val
nodes
=
mutableMapOf
(
rootController
to
rootNode
)
private
val
views
=
mutableMapOf
<
View
,
ShadeNode
>()
/**
* Adds and removes views from the root (and its children) until their structure matches the
...
...
@@ -66,26 +64,25 @@ class ShadeViewDiffer(
*
* For debugging purposes.
*/
fun
getViewLabel
(
view
:
View
):
String
=
views
[
view
]
?.
label
?:
view
.
toString
()
private
fun
detachChildren
(
parentNode
:
ShadeNode
,
specMap
:
Map
<
NodeController
,
NodeSpec
>
)
{
val
parentSpec
=
specMap
[
parentNode
.
controller
]
for
(
i
in
parentNode
.
getChildCount
()
-
1
downTo
0
)
{
val
childView
=
parentNode
.
getChildAt
(
i
)
views
[
childView
]
?.
let
{
childNode
->
val
childSpec
=
specMap
[
childNode
.
controller
]
maybeDetachChild
(
parentNode
,
parentSpec
,
childNode
,
childSpec
)
if
(
childNode
.
controller
.
getChildCount
()
>
0
)
{
detachChildren
(
childNode
,
specMap
)
fun
getViewLabel
(
view
:
View
):
String
=
nodes
.
values
.
firstOrNull
{
node
->
node
.
view
===
view
}
?.
label
?:
view
.
toString
()
private
fun
detachChildren
(
parentNode
:
ShadeNode
,
specMap
:
Map
<
NodeController
,
NodeSpec
>)
{
val
views
=
nodes
.
values
.
asSequence
().
map
{
node
->
node
.
view
to
node
}.
toMap
()
fun
detachRecursively
(
parentNode
:
ShadeNode
,
specMap
:
Map
<
NodeController
,
NodeSpec
>)
{
val
parentSpec
=
specMap
[
parentNode
.
controller
]
for
(
i
in
parentNode
.
getChildCount
()
-
1
downTo
0
)
{
val
childView
=
parentNode
.
getChildAt
(
i
)
views
[
childView
]
?.
let
{
childNode
->
val
childSpec
=
specMap
[
childNode
.
controller
]
maybeDetachChild
(
parentNode
,
parentSpec
,
childNode
,
childSpec
)
if
(
childNode
.
controller
.
getChildCount
()
>
0
)
{
detachRecursively
(
childNode
,
specMap
)
}
}
}
}
detachRecursively
(
parentNode
,
specMap
)
}
private
fun
maybeDetachChild
(
...
...
@@ -94,14 +91,13 @@ class ShadeViewDiffer(
childNode
:
ShadeNode
,
childSpec
:
NodeSpec
?
)
{
val
newParentNode
=
transform
(
childSpec
?.
parent
)
{
getNode
(
it
)
}
val
newParentNode
=
childSpec
?.
parent
?.
let
{
getNode
(
it
)
}
if
(
newParentNode
!=
parentNode
)
{
val
childCompletelyRemoved
=
newParentNode
==
null
if
(
childCompletelyRemoved
)
{
nodes
.
remove
(
childNode
.
controller
)
views
.
remove
(
childNode
.
controller
.
view
)
}
logger
.
logDetachingChild
(
...
...
@@ -115,10 +111,7 @@ class ShadeViewDiffer(
}
}
private
fun
attachChildren
(
parentNode
:
ShadeNode
,
specMap
:
Map
<
NodeController
,
NodeSpec
>
)
{
private
fun
attachChildren
(
parentNode
:
ShadeNode
,
specMap
:
Map
<
NodeController
,
NodeSpec
>)
{
val
parentSpec
=
checkNotNull
(
specMap
[
parentNode
.
controller
])
for
((
index
,
childSpec
)
in
parentSpec
.
children
.
withIndex
())
{
...
...
@@ -160,7 +153,6 @@ class ShadeViewDiffer(
if
(
node
==
null
)
{
node
=
ShadeNode
(
spec
.
controller
)
nodes
[
node
.
controller
]
=
node
views
[
node
.
view
]
=
node
}
return
node
}
...
...
@@ -194,10 +186,9 @@ class ShadeViewDiffer(
private
class
DuplicateNodeException
(
message
:
String
)
:
RuntimeException
(
message
)
private
class
ShadeNode
(
val
controller
:
NodeController
)
{
val
view
=
controller
.
view
private
class
ShadeNode
(
val
controller
:
NodeController
)
{
val
view
:
View
get
()
=
controller
.
view
var
parent
:
ShadeNode
?
=
null
...
...
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