Skip to content

Instantly share code, notes, and snippets.

@kingargyle
Last active September 4, 2017 23:04
Show Gist options
  • Save kingargyle/3081152c351fae124b3bf2355a0f5873 to your computer and use it in GitHub Desktop.
Save kingargyle/3081152c351fae124b3bf2355a0f5873 to your computer and use it in GitHub Desktop.
A ShadowSubtitleView for use with Exoplayer Simple View and Robolectric.
// A shadow for the ExoPlayer Subtitle View for use with Robolectric. Allows the view to inflate on any API level
// Add it to the config annotation (shadows = ShadowSubtitleView.class).
import com.google.android.exoplayer2.text.CaptionStyleCompat;
import com.google.android.exoplayer2.ui.SubtitleView;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.shadows.ShadowView;
@Implements(SubtitleView.class)
public class ShadowSubtitleView extends ShadowView {
@RealObject private SubtitleView subtitleView;
boolean setUserDefaultTextSize = false;
@Implementation public void setUserDefaultTextSize() {
setUserDefaultTextSize = true;
}
public boolean isSetUserDefaultTextSizeCalled() {
return setUserDefaultTextSize;
}
@Implementation public void setUserDefaultStyle() {
subtitleView.setStyle(CaptionStyleCompat.DEFAULT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment