Remove image from previous album, if set.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Apr 2011 04:53:37 +0000 (06:53 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Apr 2011 04:53:37 +0000 (06:53 +0200)
src/main/java/net/pterodactylus/sone/data/Album.java

index e3b33de..20862a4 100644 (file)
@@ -160,6 +160,9 @@ public class Album implements Fingerprintable {
         */
        public void addImage(Image image) {
                Validation.begin().isNotNull("Image", image).check().isNotNull("Image Owner", image.getSone()).check().isEqual("Image Owner", image.getSone(), sone).check();
+               if (image.getAlbum() != null) {
+                       image.getAlbum().removeImage(image);
+               }
                image.setAlbum(this);
                if (!images.contains(image)) {
                        images.add(image);