Remove dependency on Java streams API.

This commit is contained in:
Ryan Heise 2020-08-13 13:01:02 +10:00
parent 66d6006761
commit b264c36095
2 changed files with 17 additions and 12 deletions

View File

@ -45,7 +45,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
public class AudioPlayer implements MethodCallHandler, Player.EventListener, MetadataOutput { public class AudioPlayer implements MethodCallHandler, Player.EventListener, MetadataOutput {
@ -454,15 +453,12 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
.setTag(id) .setTag(id)
.createMediaSource(Uri.parse((String)map.get("uri"))); .createMediaSource(Uri.parse((String)map.get("uri")));
case "concatenating": case "concatenating":
List<Object> audioSources = (List<Object>)map.get("audioSources"); MediaSource[] mediaSources = getAudioSourcesArray(map.get("audioSources"));
return new ConcatenatingMediaSource( return new ConcatenatingMediaSource(
false, // isAtomic false, // isAtomic
(Boolean)map.get("useLazyPreparation"), (Boolean)map.get("useLazyPreparation"),
new DefaultShuffleOrder(audioSources.size()), new DefaultShuffleOrder(mediaSources.length),
audioSources mediaSources);
.stream()
.map(s -> getAudioSource(s))
.toArray(MediaSource[]::new));
case "clipping": case "clipping":
Long start = getLong(map.get("start")); Long start = getLong(map.get("start"));
Long end = getLong(map.get("end")); Long end = getLong(map.get("end"));
@ -482,11 +478,20 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
} }
} }
private MediaSource[] getAudioSourcesArray(final Object json) {
List<MediaSource> mediaSources = getAudioSources(json);
MediaSource[] mediaSourcesArray = new MediaSource[mediaSources.size()];
mediaSources.toArray(mediaSourcesArray);
return mediaSourcesArray;
}
private List<MediaSource> getAudioSources(final Object json) { private List<MediaSource> getAudioSources(final Object json) {
return ((List<Object>)json) List<Object> audioSources = (List<Object>)json;
.stream() List<MediaSource> mediaSources = new ArrayList<MediaSource>();
.map(s -> getAudioSource(s)) for (int i = 0 ; i < audioSources.size(); i++) {
.collect(Collectors.toList()); mediaSources.add(getAudioSource(audioSources.get(i)));
}
return mediaSources;
} }
private DataSource.Factory buildDataSourceFactory() { private DataSource.Factory buildDataSourceFactory() {

View File

@ -106,7 +106,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.2.2" version: "0.3.2"
matcher: matcher:
dependency: transitive dependency: transitive
description: description: