Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
751809b4
authored
Dec 15, 2020
by
olly
Committed by
Christos Tsilopoulos
Dec 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
StyledPlayerView: Fix control overflow logic
PiperOrigin-RevId: 347657903
parent
7c28df62
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
48 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlViewLayoutManager.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlViewLayoutManager.java
View file @
751809b4
...
@@ -631,65 +631,59 @@ import java.util.List;
...
@@ -631,65 +631,59 @@ import java.util.List;
styledPlayerControlView
.
getWidth
()
styledPlayerControlView
.
getWidth
()
-
styledPlayerControlView
.
getPaddingLeft
()
-
styledPlayerControlView
.
getPaddingLeft
()
-
styledPlayerControlView
.
getPaddingRight
();
-
styledPlayerControlView
.
getPaddingRight
();
int
bottomBarWidth
=
getWidthWithMargins
(
timeView
);
for
(
int
i
=
0
;
i
<
basicControls
.
getChildCount
();
++
i
)
{
bottomBarWidth
+=
basicControls
.
getChildAt
(
i
).
getWidth
();
}
if
(
bottomBarWidth
>
width
)
{
// Reset back to all controls being basic controls and the overflow not being needed. The last
if
(
overflowShowButton
!=
null
&&
overflowShowButton
.
getVisibility
()
!=
View
.
VISIBLE
)
{
// child of extraControls is the overflow hide button, which shouldn't be moved back.
overflowShowButton
.
setVisibility
(
View
.
VISIBLE
);
while
(
extraControls
.
getChildCount
()
>
1
)
{
bottomBarWidth
+=
overflowShowButton
.
getWidth
();
int
controlViewIndex
=
extraControls
.
getChildCount
()
-
2
;
}
View
controlView
=
extraControls
.
getChildAt
(
controlViewIndex
);
// Move control views from basicControls to extraControls
extraControls
.
removeViewAt
(
controlViewIndex
);
ArrayList
<
View
>
movingChildren
=
new
ArrayList
<>();
basicControls
.
addView
(
controlView
,
/* index= */
0
);
int
movingWidth
=
0
;
// The last child is overflow show button, which shouldn't move.
int
endIndex
=
basicControls
.
getChildCount
()
-
1
;
for
(
int
index
=
0
;
index
<
endIndex
;
index
++)
{
View
child
=
basicControls
.
getChildAt
(
index
);
movingWidth
+=
child
.
getWidth
();
movingChildren
.
add
(
child
);
if
(
bottomBarWidth
-
movingWidth
<=
width
)
{
break
;
}
}
if
(
overflowShowButton
!=
null
)
{
overflowShowButton
.
setVisibility
(
View
.
GONE
);
}
}
if
(!
movingChildren
.
isEmpty
())
{
// Calculate how much of the available width is occupied. The last child of basicControls is the
basicControls
.
removeViews
(
0
,
movingChildren
.
size
());
// overflow show button, which we're currently assuming will not be visible.
int
occupiedWidth
=
getWidthWithMargins
(
timeView
);
for
(
View
child
:
movingChildren
)
{
int
endIndex
=
basicControls
.
getChildCount
()
-
1
;
// The last child of extra controls is the overflow hide button. Adding other buttons
for
(
int
i
=
0
;
i
<
endIndex
;
i
++)
{
// before it.
View
controlView
=
basicControls
.
getChildAt
(
i
);
int
index
=
extraControls
.
getChildCount
()
-
1
;
occupiedWidth
+=
getWidthWithMargins
(
controlView
);
extraControls
.
addView
(
child
,
index
);
}
}
}
}
else
{
if
(
occupiedWidth
>
width
)
{
// Move controls from extraControls to basicControls if possible, else do nothing.
// We need to move some controls to extraControls.
ArrayList
<
View
>
movingChildren
=
new
ArrayList
<>();
if
(
overflowShowButton
!=
null
)
{
int
movingWidth
=
0
;
overflowShowButton
.
setVisibility
(
View
.
VISIBLE
);
// The last child of extra controls is the overflow button, which shouldn't move.
occupiedWidth
+=
getWidthWithMargins
(
overflowShowButton
);
int
endIndex
=
extraControls
.
getChildCount
()
-
2
;
}
for
(
int
index
=
endIndex
;
index
>=
0
;
index
--)
{
ArrayList
<
View
>
controlsToMove
=
new
ArrayList
<>();
View
child
=
extraControls
.
getChildAt
(
index
);
// The last child of basicControls is the overflow show button, which shouldn't be moved.
movingWidth
+=
child
.
getWidth
();
for
(
int
i
=
0
;
i
<
endIndex
;
i
++)
{
if
(
bottomBarWidth
+
movingWidth
>
width
)
{
View
control
=
basicControls
.
getChildAt
(
i
);
occupiedWidth
-=
getWidthWithMargins
(
control
);
controlsToMove
.
add
(
control
);
if
(
occupiedWidth
<=
width
)
{
break
;
break
;
}
}
movingChildren
.
add
(
child
);
}
}
if
(!
controlsToMove
.
isEmpty
())
{
if
(!
movingChildren
.
isEmpty
())
{
basicControls
.
removeViews
(
/* start= */
0
,
controlsToMove
.
size
());
extraControls
.
removeViews
(
endIndex
-
movingChildren
.
size
()
+
1
,
movingChildren
.
size
());
for
(
int
i
=
0
;
i
<
controlsToMove
.
size
();
i
++)
{
// The last child of extraControls is the overflow hide button. Add controls before it.
for
(
View
child
:
movingChildren
)
{
int
index
=
extraControls
.
getChildCount
()
-
1
;
basicControls
.
addView
(
child
,
0
);
extraControls
.
addView
(
controlsToMove
.
get
(
i
),
index
);
}
}
}
}
if
(
extraControls
.
getChildCount
()
==
1
&&
overflowShowButton
!=
null
)
{
}
else
{
overflowShowButton
.
setVisibility
(
View
.
GONE
);
// If extraControls are visible, hide them since they're now empty.
if
(
extraControlsScrollView
!=
null
&&
extraControlsScrollView
.
getVisibility
()
==
View
.
VISIBLE
&&
!
overflowHideAnimator
.
isStarted
())
{
overflowShowAnimator
.
cancel
();
overflowHideAnimator
.
start
();
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment