Skip to content

Commit af86a1e

Browse files
committed
Tidy up button code (#1207)
1 parent 6e2240c commit af86a1e

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

Diff for: src/main/java/org/quantumbadger/redreader/views/video/ExoPlayerWrapperView.java

+18-20
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,11 @@ public ExoPlayerWrapperView(
179179
});
180180

181181
if (PrefsUtility.pref_behaviour_video_frame_step()) {
182-
final AtomicReference<ImageButton> stepBackButton = new AtomicReference<>();
183-
final AtomicReference<ImageButton> stepForwardButton = new AtomicReference<>();
184182
final long frameDuration = (long)(1000f / (mVideoPlayer.getVideoFormat() != null
185183
? mVideoPlayer.getVideoFormat().frameRate
186184
: 30));
187185

188-
stepBackButton.set(createButton(
186+
final ImageButton stepBackButton = createButton(
189187
context,
190188
mControlView,
191189
R.drawable.icon_step_back,
@@ -194,9 +192,9 @@ public ExoPlayerWrapperView(
194192
mVideoPlayer.seekTo(mVideoPlayer.getCurrentPosition() - frameDuration);
195193
updateProgress();
196194
}
197-
));
195+
);
198196

199-
stepForwardButton.set(createButton(
197+
final ImageButton stepForwardButton = createButton(
200198
context,
201199
mControlView,
202200
R.drawable.icon_step_forward,
@@ -205,39 +203,39 @@ public ExoPlayerWrapperView(
205203
mVideoPlayer.seekTo(mVideoPlayer.getCurrentPosition() + frameDuration);
206204
updateProgress();
207205
}
208-
));
206+
);
209207

210208
mVideoPlayer.addListener(new Player.Listener() {
211209
@Override
212210
public void onIsPlayingChanged(final boolean isPlaying) {
213211
if (isPlaying) {
214-
stepBackButton.get().setImageAlpha(0x3F);
215-
stepBackButton.get().setContentDescription(
212+
stepBackButton.setImageAlpha(0x3F);
213+
stepBackButton.setContentDescription(
216214
context.getString(R.string.video_step_back_disabled));
217-
stepBackButton.get().setEnabled(false);
215+
stepBackButton.setEnabled(false);
218216

219-
stepForwardButton.get().setImageAlpha(0x3F);
220-
stepForwardButton.get().setContentDescription(
217+
stepForwardButton.setImageAlpha(0x3F);
218+
stepForwardButton.setContentDescription(
221219
context.getString(R.string.video_step_forward_disabled));
222-
stepForwardButton.get().setEnabled(false);
220+
stepForwardButton.setEnabled(false);
223221

224222
} else {
225-
stepBackButton.get().setImageAlpha(0xFF);
226-
stepBackButton.get().setContentDescription(
223+
stepBackButton.setImageAlpha(0xFF);
224+
stepBackButton.setContentDescription(
227225
context.getString(R.string.video_step_back));
228-
stepBackButton.get().setEnabled(true);
226+
stepBackButton.setEnabled(true);
229227

230-
stepForwardButton.get().setImageAlpha(0xFF);
231-
stepForwardButton.get().setContentDescription(
228+
stepForwardButton.setImageAlpha(0xFF);
229+
stepForwardButton.setContentDescription(
232230
context.getString(R.string.video_step_forward));
233-
stepForwardButton.get().setEnabled(true);
231+
stepForwardButton.setEnabled(true);
234232
}
235233
}
236234
});
237235

238-
addButton(stepBackButton.get(), buttons);
236+
addButton(stepBackButton, buttons);
239237
addButton(mPlayButton, buttons);
240-
addButton(stepForwardButton.get(), buttons);
238+
addButton(stepForwardButton, buttons);
241239

242240
} else {
243241
addButton(mPlayButton, buttons);

0 commit comments

Comments
 (0)