From 3adccdf045df4f57e1c5ee0e01af228b2adfb506 Mon Sep 17 00:00:00 2001
From: tobias <thinkdifferent055@gmail.com>
Date: Fri, 27 Nov 2020 21:50:43 +0100
Subject: [PATCH] Allow dropping multiple files in PadContentFactory
 implementation of ContentDragOption

---
 .../src/main/java/de/tobias/playpad/pad/Pad.java         | 7 +++++++
 .../de/tobias/playpad/pad/content/PadContentFactory.java | 9 ++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java
index a8f1b910..640152d2 100644
--- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java
+++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java
@@ -372,6 +372,7 @@ public class Pad {
 	}
 
 	public void removePath(MediaPath path) {
+		getContent().unloadMedia(path);
 		mediaPaths.remove(path);
 	}
 
@@ -382,6 +383,12 @@ public class Pad {
 		}
 	}
 
+	public void clearPaths() {
+		while (!mediaPaths.isEmpty()) {
+			removePath(mediaPaths.get(0));
+		}
+	}
+
 	/**
 	 * Get the status of the pad.
 	 *
diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java
index 71c86385..611654dc 100644
--- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java
+++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java
@@ -61,6 +61,13 @@ public abstract class PadContentFactory extends Component implements ContentDrag
 			currentPad.getController().getView().showBusyView(true);
 		}
 
-		currentPad.setPath(files.get(0).toPath());
+		if (currentPad.getContent() instanceof Playlistable) {
+			currentPad.clearPaths();
+			for (File file : files) {
+				currentPad.addPath(file.toPath());
+			}
+		} else {
+			currentPad.setPath(files.get(0).toPath());
+		}
 	}
 }
-- 
GitLab