package net.pterodactylus.sone.data.impl;
+import static com.google.common.collect.FluentIterable.from;
+
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Sone;
return album;
}
+ @Override
+ public void moveUp() throws IllegalStateException {
+ int oldIndex = album.imageIds.indexOf(getId());
+ album.imageIds.remove(getId());
+ album.imageIds.add(Math.max(0, oldIndex - 1), getId());
+ }
+
+ @Override
+ public void moveDown() throws IllegalStateException {
+ int oldIndex = album.imageIds.indexOf(getId());
+ album.imageIds.remove(getId());
+ album.imageIds.add(Math.min(album.imageIds.size(), oldIndex + 1), getId());
+ }
+
+ @Override
+ public void remove() throws IllegalStateException {
+ synchronized (album) {
+ album.images.remove(getId());
+ album.imageIds.remove(getId());
+ if (getId().equals(album.albumImage)) {
+ album.albumImage = from(album.images.values()).transform(GET_ID).first().orNull();
+ }
+ }
+ }
+
}