Remember state of queue if closed/crashed.

Closes #235
This commit is contained in:
4pr0n 2015-09-17 03:11:50 -07:00
parent 998035d17f
commit 9df47d6466
3 changed files with 25 additions and 2 deletions

View File

@ -154,6 +154,7 @@ public class EightmusesRipper extends AbstractHTMLRipper {
}
private String getFullSizeImage(String imageUrl) throws IOException {
sendUpdate(STATUS.LOADING_RESOURCE, imageUrl);
Document doc = new Http(imageUrl).get();
return doc.select("#image").first().attr("src");
}

View File

@ -30,6 +30,7 @@ import java.net.URI;
import java.net.URL;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import javax.imageio.ImageIO;
@ -398,6 +399,14 @@ public class MainWindow implements Runnable, RipStatusHandler {
queueListScroll = new JScrollPane(queueList,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
for (String item : Utils.getConfigList("queue")) {
queueListModel.addElement(item);
}
if (queueListModel.size() > 0) {
optionQueue.setText("Queue (" + queueListModel.size() + ")");
} else {
optionQueue.setText("Queue");
}
gbc.gridx = 0;
JPanel queueListPanel = new JPanel(new GridBagLayout());
queueListPanel.add(queueListScroll, gbc);
@ -968,9 +977,14 @@ public class MainWindow implements Runnable, RipStatusHandler {
}
}
@SuppressWarnings("unchecked")
private void ripNextAlbum() {
isRipping = true;
if (queueListModel.size() == 0) {
// Save current state of queue to configuration.
Utils.setConfigList("queue", (Enumeration<Object>) queueListModel.elements());
if (queueListModel.isEmpty()) {
// End of queue
isRipping = false;
return;
@ -1057,7 +1071,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
class RipButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent event) {
if (!queueListModel.contains(ripTextfield.getText())) {
if (!queueListModel.contains(ripTextfield.getText()) && !ripTextfield.getText().equals("")) {
queueListModel.add(queueListModel.size(), ripTextfield.getText());
ripTextfield.setText("");
}

View File

@ -119,6 +119,14 @@ public class Utils {
config.clearProperty(key);
config.addProperty(key, list);
}
public static void setConfigList(String key, Enumeration<Object> enumeration) {
config.clearProperty(key);
List<Object> list = new ArrayList<Object>();
while (enumeration.hasMoreElements()) {
list.add(enumeration.nextElement());
}
config.addProperty(key, list);
}
public static void saveConfig() {
try {