From 7bc8839a2cdd5490bc9c802c752d40723eabdc03 Mon Sep 17 00:00:00 2001 From: VlC Date: Thu, 16 Feb 2023 16:48:16 +0100 Subject: [PATCH] Downgrade to P3 for export --- Channel.pde | 3 +-- Player.pde | 3 +-- Playlister.pde | 31 +++++++++++++++++++++---------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Channel.pde b/Channel.pde index 5db6508..3d687b6 100644 --- a/Channel.pde +++ b/Channel.pde @@ -49,8 +49,7 @@ public class ChannelOsc { void create_display(int x, int y, int id) { ChannelDisplay d; - if (demo_ui) d = new ChannelDisplayDemo(x, y, id, this); - else d = new ChannelDisplay(x, y, id, this); + d = new ChannelDisplay(x, y, id, this); this.disp = d; this.id = id; } diff --git a/Player.pde b/Player.pde index 8811f18..f6f9850 100644 --- a/Player.pde +++ b/Player.pde @@ -77,8 +77,7 @@ class Player { void create_display(int x, int y) { PlayerDisplay d; - if (demo_ui) d = new PlayerDisplayDemo(x, y, this); - else d = new PlayerDisplay(x, y, this); + d = new PlayerDisplay(x, y, this); this.disp = d; } diff --git a/Playlister.pde b/Playlister.pde index 01b7134..964f354 100644 --- a/Playlister.pde +++ b/Playlister.pde @@ -1,7 +1,11 @@ import java.util.stream.Stream; -import java.nio.file.*; import java.util.Comparator; import java.util.Collections; +import java.util.stream.Collectors; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.Path; +import java.nio.file.InvalidPathException; public class PlaylistModule extends PApplet { @@ -30,7 +34,7 @@ public class PlaylistModule extends PApplet { this.parentFrame = f; this.parentPApplet = parent; - items = new ArrayList<>(); + items = new ArrayList(); } @@ -348,13 +352,19 @@ public class PlaylistModule extends PApplet { ArrayList add_folder_to_list(boolean recursive, File folder) { - ArrayList aux = new ArrayList<>(); + ArrayList aux = new ArrayList(); - try (Stream stream = recursive ? Files.walk(folder.toPath(), 2) : Files.list(folder.toPath())) { - stream.filter(Files::isRegularFile).forEach( (k) -> { + try { + Stream stream = recursive ? Files.walk(folder.toPath(), 2) : Files.list(folder.toPath()); + for (Object path : stream.collect(Collectors.toList())) { + PlaylistItem i = new PlaylistItem((Path) path); + if (i.file != null && is_valid_midi(i.file)) aux.add(i); + }; + /*stream.filter(Files::isRegularFile).forEach( (k) -> { PlaylistItem i = new PlaylistItem(k); if (i.file != null && is_valid_midi(i.file)) aux.add(i); - }); + });*/ + stream.close(); } catch (IOException ioe) { println("ioe on recursive folder"); @@ -446,7 +456,7 @@ public class PlaylistModule extends PApplet { String load_m3u(File in) { if (in == null) return ""; - ArrayList aux = new ArrayList<>(); + ArrayList aux = new ArrayList(); try { BufferedReader reader = new BufferedReader(new FileReader(in.getAbsolutePath())); @@ -454,7 +464,8 @@ public class PlaylistModule extends PApplet { while (l != null) { try { Paths.get(l); } - catch (InvalidPathException | NullPointerException pex) { break; } + catch (InvalidPathException ipe) { break; } + catch (NullPointerException npe) { break; } File f = new File(l); if (f.exists() && is_valid_midi(f)) { @@ -537,7 +548,7 @@ class PlaylistItem implements Comparator { PlaylistItem(File f) { - if (f == null) return; + if (f == null || !f.isFile()) return; file = f; //filename = check_and_shrink_string(f.getName().replaceFirst("[.][^.]+$", ""), 18); @@ -547,7 +558,7 @@ class PlaylistItem implements Comparator { PlaylistItem(Path p) { - if (p == null) return; + if (p == null || !p.toFile().isFile()) return; file = p.toFile(); //filename = check_and_shrink_string(p.getFileName().toString().replaceFirst("[.][^.]+$", ""), 18);