Commit 24b4cb84 by olly Committed by Oliver Woodman

Fix attr inheritance in SimpleExoPlayerView

When creating PlaybackControlView inside SimpleExoPlayerView,
we want certain attributes to be passed through. This lets you
set control attributes on the SimpleExoPlayerView directly. We
don't want all attributes to be propagated though; only our own
custom ones.

Not sure if there's a cleaner way to do this. Pragmatically this
solution seems ... ok :)?

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167619801
parent a5302be6
...@@ -339,15 +339,19 @@ public class PlaybackControlView extends FrameLayout { ...@@ -339,15 +339,19 @@ public class PlaybackControlView extends FrameLayout {
} }
public PlaybackControlView(Context context, AttributeSet attrs, int defStyleAttr) { public PlaybackControlView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); this(context, attrs, defStyleAttr, attrs);
}
public PlaybackControlView(Context context, AttributeSet attrs, int defStyleAttr,
AttributeSet playbackAttrs) {
super(context, attrs, defStyleAttr);
int controllerLayoutId = R.layout.exo_playback_control_view; int controllerLayoutId = R.layout.exo_playback_control_view;
rewindMs = DEFAULT_REWIND_MS; rewindMs = DEFAULT_REWIND_MS;
fastForwardMs = DEFAULT_FAST_FORWARD_MS; fastForwardMs = DEFAULT_FAST_FORWARD_MS;
showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS; showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS;
repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES; repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES;
if (attrs != null) { if (playbackAttrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, TypedArray a = context.getTheme().obtainStyledAttributes(playbackAttrs,
R.styleable.PlaybackControlView, 0, 0); R.styleable.PlaybackControlView, 0, 0);
try { try {
rewindMs = a.getInt(R.styleable.PlaybackControlView_rewind_increment, rewindMs); rewindMs = a.getInt(R.styleable.PlaybackControlView_rewind_increment, rewindMs);
......
...@@ -239,7 +239,7 @@ public final class SimpleExoPlayerView extends FrameLayout { ...@@ -239,7 +239,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
controller = null; controller = null;
componentListener = null; componentListener = null;
overlayFrameLayout = null; overlayFrameLayout = null;
ImageView logo = new ImageView(context, attrs); ImageView logo = new ImageView(context);
if (Util.SDK_INT >= 23) { if (Util.SDK_INT >= 23) {
configureEditModeLogoV23(getResources(), logo); configureEditModeLogoV23(getResources(), logo);
} else { } else {
...@@ -329,9 +329,9 @@ public final class SimpleExoPlayerView extends FrameLayout { ...@@ -329,9 +329,9 @@ public final class SimpleExoPlayerView extends FrameLayout {
if (customController != null) { if (customController != null) {
this.controller = customController; this.controller = customController;
} else if (controllerPlaceholder != null) { } else if (controllerPlaceholder != null) {
// Note: rewindMs and fastForwardMs are passed via attrs, so we don't need to make explicit // Propagate attrs as playbackAttrs so that PlaybackControlView's custom attributes are
// calls to set them. // transferred, but standard FrameLayout attributes (e.g. background) are not.
this.controller = new PlaybackControlView(context, attrs); this.controller = new PlaybackControlView(context, null, 0, attrs);
controller.setLayoutParams(controllerPlaceholder.getLayoutParams()); controller.setLayoutParams(controllerPlaceholder.getLayoutParams());
ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent()); ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent());
int controllerIndex = parent.indexOfChild(controllerPlaceholder); int controllerIndex = parent.indexOfChild(controllerPlaceholder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment