Commit f2055396 by olly Committed by Ian Baker

Use lambdas where possible

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