This repository has been archived by the owner on Apr 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In MainWindow are now all the startAll, abortAll etc. buttons placed
vertically instead of horizontally and a abortAllAndClear button has been added. Changed so the code for opening the user's web browser is executed on a background thread instead of the UI thread. Modified the code for getting localized categories, creating new playlists and downloading all existing playlists to perform some of their work on a background thread.
- Loading branch information
Showing
9 changed files
with
198 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/io/github/stekeblad/videouploader/utils/background/OpenInBrowser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.github.stekeblad.videouploader.utils.background; | ||
|
||
import javafx.concurrent.Task; | ||
|
||
import java.awt.*; | ||
import java.net.URI; | ||
|
||
/** | ||
* Attempts to open a web page in the user's default browser by first creating a new thread and opening it from there. | ||
* Calling Desktop.getDesktop().browse(...) on the UI thread does not work on all systems, on some it just fails silently. | ||
*/ | ||
public class OpenInBrowser { | ||
|
||
/** | ||
* Opens uri in the user's default browser or throws a Exception while trying | ||
* | ||
* @param uri the address to the web page that should be opened | ||
* @param ueh A UncaughtExceptionHandler to call if an Exception is thrown, can be null | ||
*/ | ||
public OpenInBrowser(URI uri, Thread.UncaughtExceptionHandler ueh) { | ||
Task<Void> task = new Task<Void>() { | ||
@Override | ||
protected Void call() throws Exception { | ||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { | ||
Desktop.getDesktop().browse(uri); | ||
return null; | ||
} else { | ||
throw new UnsupportedOperationException("Desktop not supported"); | ||
} | ||
} | ||
}; | ||
Thread thread = new Thread(task); | ||
thread.setUncaughtExceptionHandler(ueh); | ||
thread.start(); | ||
} | ||
} |
Oops, something went wrong.