1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-22 21:43:06 +02:00

read clipboard correctly to start auto-download

fixes #86.
This commit is contained in:
soloturn
2022-04-26 02:28:36 +02:00
parent 3a9f5b51f7
commit 7262a79a8d

View File

@@ -1,8 +1,8 @@
package com.rarchives.ripme.ui;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.HashSet;
@@ -30,16 +30,13 @@ class ClipboardUtils {
}
public static String getClipboardString() {
try {
return (String) Toolkit
.getDefaultToolkit()
.getSystemClipboard()
.getData(DataFlavor.getTextPlainUnicodeFlavor());
} catch (IllegalStateException e) {
e.printStackTrace();
logger.error("Caught and recovered from IllegalStateException: " + e.getMessage());
} catch (HeadlessException | IOException | UnsupportedFlavorException e) {
e.printStackTrace();
Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (contents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
return (String) contents.getTransferData(DataFlavor.stringFlavor);
} catch (UnsupportedFlavorException | IOException e) {
logger.debug("ignore this one" + e.getMessage());
}
}
return null;
}
@@ -47,7 +44,7 @@ class ClipboardUtils {
class AutoripThread extends Thread {
volatile boolean isRunning = false;
private Set<String> rippedURLs = new HashSet<>();
private final Set<String> rippedURLs = new HashSet<>();
public void run() {
isRunning = true;