Skip to content

Commit

Permalink
Fix attr inheritance in SimpleExoPlayerView
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ojw28 committed Sep 6, 2017
1 parent b22150c commit 26bbee5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,19 @@ public PlaybackControlView(Context context, AttributeSet attrs) {
}

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;
rewindMs = DEFAULT_REWIND_MS;
fastForwardMs = DEFAULT_FAST_FORWARD_MS;
showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS;
repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES;
if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
TypedArray a = context.getTheme().obtainStyledAttributes(playbackAttrs,
R.styleable.PlaybackControlView, 0, 0);
try {
rewindMs = a.getInt(R.styleable.PlaybackControlView_rewind_increment, rewindMs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public SimpleExoPlayerView(Context context, AttributeSet attrs, int defStyleAttr
controller = null;
componentListener = null;
overlayFrameLayout = null;
ImageView logo = new ImageView(context, attrs);
ImageView logo = new ImageView(context);
if (Util.SDK_INT >= 23) {
configureEditModeLogoV23(getResources(), logo);
} else {
Expand Down Expand Up @@ -329,9 +329,9 @@ public SimpleExoPlayerView(Context context, AttributeSet attrs, int defStyleAttr
if (customController != null) {
this.controller = customController;
} else if (controllerPlaceholder != null) {
// Note: rewindMs and fastForwardMs are passed via attrs, so we don't need to make explicit
// calls to set them.
this.controller = new PlaybackControlView(context, attrs);
// Propagate attrs as playbackAttrs so that PlaybackControlView's custom attributes are
// transferred, but standard FrameLayout attributes (e.g. background) are not.
this.controller = new PlaybackControlView(context, null, 0, attrs);
controller.setLayoutParams(controllerPlaceholder.getLayoutParams());
ViewGroup parent = ((ViewGroup) controllerPlaceholder.getParent());
int controllerIndex = parent.indexOfChild(controllerPlaceholder);
Expand Down

0 comments on commit 26bbee5

Please sign in to comment.