Commit f2055396 by olly Committed by Ian Baker

Use lambdas where possible

PiperOrigin-RevId: 320960833
parent 29b12e2f
......@@ -1146,17 +1146,16 @@ public class SessionPlayerConnectorTest {
assertPlayerResultSuccess(sessionPlayerConnector.prepare());
InstrumentationRegistry.getInstrumentation()
.runOnMainSync(
() -> {
simpleExoPlayer.addListener(
new Player.EventListener() {
@Override
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
if (playWhenReady) {
simpleExoPlayer.setPlayWhenReady(false);
() ->
simpleExoPlayer.addListener(
new Player.EventListener() {
@Override
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
if (playWhenReady) {
simpleExoPlayer.setPlayWhenReady(false);
}
}
}
});
});
}));
assertPlayerResultSuccess(sessionPlayerConnector.play());
assertThat(
......
......@@ -149,19 +149,19 @@ public final class SessionPlayerConnector extends SessionPlayer {
@Override
public ListenableFuture<PlayerResult> play() {
return playerCommandQueue.addCommand(
PlayerCommandQueue.COMMAND_CODE_PLAYER_PLAY, /* command= */ () -> player.play());
PlayerCommandQueue.COMMAND_CODE_PLAYER_PLAY, /* command= */ player::play);
}
@Override
public ListenableFuture<PlayerResult> pause() {
return playerCommandQueue.addCommand(
PlayerCommandQueue.COMMAND_CODE_PLAYER_PAUSE, /* command= */ () -> player.pause());
PlayerCommandQueue.COMMAND_CODE_PLAYER_PAUSE, /* command= */ player::pause);
}
@Override
public ListenableFuture<PlayerResult> prepare() {
return playerCommandQueue.addCommand(
PlayerCommandQueue.COMMAND_CODE_PLAYER_PREPARE, /* command= */ () -> player.prepare());
PlayerCommandQueue.COMMAND_CODE_PLAYER_PREPARE, /* command= */ player::prepare);
}
@Override
......
......@@ -771,9 +771,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
keepaliveSessions.add(session);
Assertions.checkNotNull(sessionReleasingHandler)
.postAtTime(
() -> {
session.release(/* eventDispatcher= */ null);
},
() -> session.release(/* eventDispatcher= */ null),
session,
/* uptimeMillis= */ SystemClock.uptimeMillis() + sessionKeepaliveMs);
} else if (newReferenceCount == 0) {
......
......@@ -156,9 +156,8 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
mediaDrm.setOnExpirationUpdateListener(
listener == null
? null
: (mediaDrm, sessionId, expirationTimeMs) -> {
listener.onExpirationUpdate(FrameworkMediaDrm.this, sessionId, expirationTimeMs);
},
: (mediaDrm, sessionId, expirationTimeMs) ->
listener.onExpirationUpdate(FrameworkMediaDrm.this, sessionId, expirationTimeMs),
/* handler= */ null);
}
......
......@@ -1913,9 +1913,7 @@ public final class ExoPlayerTest {
.waitForTimelineChanged()
.pause()
.sendMessage(
(messageType, payload) -> {
counter.getAndIncrement();
},
(messageType, payload) -> counter.getAndIncrement(),
/* windowIndex= */ 0,
/* positionMs= */ 2000,
/* deleteAfterDelivery= */ false)
......
......@@ -40,7 +40,6 @@ import com.google.android.exoplayer2.testutil.FakeSampleStream;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
......@@ -78,11 +77,8 @@ public class MediaCodecAudioRendererTest {
when(audioSink.handleBuffer(any(), anyLong(), anyInt())).thenReturn(true);
mediaCodecSelector =
new MediaCodecSelector() {
@Override
public List<MediaCodecInfo> getDecoderInfos(
String mimeType, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder) {
return Collections.singletonList(
(mimeType, requiresSecureDecoder, requiresTunnelingDecoder) ->
Collections.singletonList(
MediaCodecInfo.newInstance(
/* name= */ "name",
/* mimeType= */ mimeType,
......@@ -93,8 +89,6 @@ public class MediaCodecAudioRendererTest {
/* vendor= */ false,
/* forceDisableAdaptive= */ false,
/* forceSecure= */ false));
}
};
mediaCodecAudioRenderer =
new MediaCodecAudioRenderer(
......
......@@ -711,19 +711,13 @@ public class DownloadManagerTest {
private List<Download> postGetCurrentDownloads() {
AtomicReference<List<Download>> currentDownloadsReference = new AtomicReference<>();
runOnMainThread(
() -> {
currentDownloadsReference.set(downloadManager.getCurrentDownloads());
});
runOnMainThread(() -> currentDownloadsReference.set(downloadManager.getCurrentDownloads()));
return currentDownloadsReference.get();
}
private DownloadIndex postGetDownloadIndex() {
AtomicReference<DownloadIndex> downloadIndexReference = new AtomicReference<>();
runOnMainThread(
() -> {
downloadIndexReference.set(downloadManager.getDownloadIndex());
});
runOnMainThread(() -> downloadIndexReference.set(downloadManager.getDownloadIndex()));
return downloadIndexReference.get();
}
......
......@@ -50,7 +50,6 @@ import com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamI
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
......@@ -82,11 +81,8 @@ public class MediaCodecVideoRendererTest {
@Before
public void setUp() throws Exception {
MediaCodecSelector mediaCodecSelector =
new MediaCodecSelector() {
@Override
public List<MediaCodecInfo> getDecoderInfos(
String mimeType, boolean requiresSecureDecoder, boolean requiresTunnelingDecoder) {
return Collections.singletonList(
(mimeType, requiresSecureDecoder, requiresTunnelingDecoder) ->
Collections.singletonList(
MediaCodecInfo.newInstance(
/* name= */ "name",
/* mimeType= */ mimeType,
......@@ -97,8 +93,6 @@ public class MediaCodecVideoRendererTest {
/* vendor= */ false,
/* forceDisableAdaptive= */ false,
/* forceSecure= */ false));
}
};
mediaCodecVideoRenderer =
new MediaCodecVideoRenderer(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment