From 6907ffb2852d56556c5a4186d6d7cfb00d8d7553 Mon Sep 17 00:00:00 2001 From: olly Date: Sun, 23 Jul 2017 09:55:50 +0100 Subject: [PATCH] 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 --- .../android/exoplayer2/castdemo/MainActivity.java | 6 +++--- .../google/android/exoplayer2/demo/PlayerActivity.java | 8 ++++---- .../android/exoplayer2/demo/SampleChooserActivity.java | 2 +- .../android/exoplayer2/ui/PlaybackControlView.java | 8 ++++---- .../android/exoplayer2/ui/SimpleExoPlayerView.java | 10 +++++----- .../android/exoplayer2/testutil/HostActivity.java | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java b/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java index e1367858aa..e1c7519a05 100644 --- a/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java +++ b/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java @@ -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()); } diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 6d733c9f97..b2750a93bb 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -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(); } diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java index 382c783598..c0edb1d1b8 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java @@ -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 diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java index 105dbc2495..91308848f9 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java @@ -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); } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java index bdbdf34331..0a531375c1 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java @@ -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; diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java index 54087c4461..299cb10815 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java @@ -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); }