Remove unnecessary view casts

findViewById is now defined using generics, which allows
the types to be inferred.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166355555
This commit is contained in:
olly 2017-07-23 09:55:50 +01:00 committed by Oliver Woodman
parent 6e03dcdfa1
commit 6907ffb285
6 changed files with 18 additions and 18 deletions

View file

@ -49,12 +49,12 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.main_activity);
simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
simpleExoPlayerView = findViewById(R.id.player_view);
simpleExoPlayerView.requestFocus();
castControlView = (PlaybackControlView) findViewById(R.id.cast_control_view);
castControlView = findViewById(R.id.cast_control_view);
ListView sampleList = (ListView) findViewById(R.id.sample_list);
ListView sampleList = findViewById(R.id.sample_list);
sampleList.setAdapter(new SampleListAdapter());
sampleList.setOnItemClickListener(new SampleClickListener());
}

View file

@ -148,12 +148,12 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
setContentView(R.layout.player_activity);
View rootView = findViewById(R.id.root);
rootView.setOnClickListener(this);
debugRootView = (LinearLayout) findViewById(R.id.controls_root);
debugTextView = (TextView) findViewById(R.id.debug_text_view);
retryButton = (Button) findViewById(R.id.retry_button);
debugRootView = findViewById(R.id.controls_root);
debugTextView = findViewById(R.id.debug_text_view);
retryButton = findViewById(R.id.retry_button);
retryButton.setOnClickListener(this);
simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
simpleExoPlayerView = findViewById(R.id.player_view);
simpleExoPlayerView.setControllerVisibilityListener(this);
simpleExoPlayerView.requestFocus();
}

View file

@ -90,7 +90,7 @@ public class SampleChooserActivity extends Activity {
Toast.makeText(getApplicationContext(), R.string.sample_list_load_error, Toast.LENGTH_LONG)
.show();
}
ExpandableListView sampleList = (ExpandableListView) findViewById(R.id.sample_list);
ExpandableListView sampleList = findViewById(R.id.sample_list);
sampleList.setAdapter(new SampleAdapter(this, groups));
sampleList.setOnChildClickListener(new OnChildClickListener() {
@Override

View file

@ -374,9 +374,9 @@ public class PlaybackControlView extends FrameLayout {
LayoutInflater.from(context).inflate(controllerLayoutId, this);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
durationView = (TextView) findViewById(R.id.exo_duration);
positionView = (TextView) findViewById(R.id.exo_position);
timeBar = (TimeBar) findViewById(R.id.exo_progress);
durationView = findViewById(R.id.exo_duration);
positionView = findViewById(R.id.exo_position);
timeBar = findViewById(R.id.exo_progress);
if (timeBar != null) {
timeBar.setListener(componentListener);
}
@ -404,7 +404,7 @@ public class PlaybackControlView extends FrameLayout {
if (fastForwardButton != null) {
fastForwardButton.setOnClickListener(componentListener);
}
repeatToggleButton = (ImageView) findViewById(R.id.exo_repeat_toggle);
repeatToggleButton = findViewById(R.id.exo_repeat_toggle);
if (repeatToggleButton != null) {
repeatToggleButton.setOnClickListener(componentListener);
}

View file

@ -286,7 +286,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
// Content frame.
contentFrame = (AspectRatioFrameLayout) findViewById(R.id.exo_content_frame);
contentFrame = findViewById(R.id.exo_content_frame);
if (contentFrame != null) {
setResizeModeRaw(contentFrame, resizeMode);
}
@ -307,24 +307,24 @@ public final class SimpleExoPlayerView extends FrameLayout {
}
// Overlay frame layout.
overlayFrameLayout = (FrameLayout) findViewById(R.id.exo_overlay);
overlayFrameLayout = findViewById(R.id.exo_overlay);
// Artwork view.
artworkView = (ImageView) findViewById(R.id.exo_artwork);
artworkView = findViewById(R.id.exo_artwork);
this.useArtwork = useArtwork && artworkView != null;
if (defaultArtworkId != 0) {
defaultArtwork = BitmapFactory.decodeResource(context.getResources(), defaultArtworkId);
}
// Subtitle view.
subtitleView = (SubtitleView) findViewById(R.id.exo_subtitles);
subtitleView = findViewById(R.id.exo_subtitles);
if (subtitleView != null) {
subtitleView.setUserDefaultStyle();
subtitleView.setUserDefaultTextSize();
}
// Playback control view.
PlaybackControlView customController = (PlaybackControlView) findViewById(R.id.exo_controller);
PlaybackControlView customController = findViewById(R.id.exo_controller);
View controllerPlaceholder = findViewById(R.id.exo_controller_placeholder);
if (customController != null) {
this.controller = customController;

View file

@ -159,7 +159,7 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(getResources().getIdentifier("host_activity", "layout", getPackageName()));
surfaceView = (SurfaceView) findViewById(
surfaceView = findViewById(
getResources().getIdentifier("surface_view", "id", getPackageName()));
surfaceView.getHolder().addCallback(this);
}