Use Handler to post action schedule finished callback.

Calling it directly might skip other callbacks. For example:
ActionSchedule.Builder().waitForTimelineChanged(...).build().
is currently immediately calling through to
callback.onActionScheduleFinished when the timeline changes.
Depending on the position of the action schedule listener in the
listener set, it may skip other listeners also
listening to timeline changes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177442975
This commit is contained in:
tonihei 2017-11-30 05:53:45 -08:00 committed by Oliver Woodman
parent 7b08899818
commit e28adb00ff

View File

@ -41,6 +41,7 @@ import com.google.android.exoplayer2.testutil.Action.WaitForPositionDiscontinuit
import com.google.android.exoplayer2.testutil.Action.WaitForSeekProcessed;
import com.google.android.exoplayer2.testutil.Action.WaitForTimelineChanged;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Clock;
/**
@ -487,11 +488,28 @@ public final class ActionSchedule {
}
@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player,
MappingTrackSelector trackSelector,
Surface surface,
Handler handler,
ActionNode nextAction) {
Assertions.checkArgument(nextAction == null);
if (callback != null) {
handler.post(
new Runnable() {
@Override
public void run() {
callback.onActionScheduleFinished();
}
});
}
}
@Override
protected void doActionImpl(
SimpleExoPlayer player, MappingTrackSelector trackSelector, Surface surface) {
// Not triggered.
}
}