mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 02:01:27 +00:00
clean up
This commit is contained in:
@@ -3,13 +3,12 @@ package org.cryptomator.ui.controls;
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* A progress indicator in the shape of {@link FontAwesome5Icon#SPINNER}. The single spinner segements are defined in the css in the `progress-indicator` class.
|
||||
*
|
||||
* <p>
|
||||
* See also https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#progressindicator
|
||||
*/
|
||||
public class FontAwesomeSpinner extends ProgressIndicator {
|
||||
@@ -18,12 +17,11 @@ public class FontAwesomeSpinner extends ProgressIndicator {
|
||||
|
||||
public FontAwesomeSpinner() {
|
||||
this.animation = new Animator(this);
|
||||
|
||||
EasyBind.subscribe(this.visibleProperty(), this::startStopAnimation);
|
||||
}
|
||||
|
||||
private void startStopAnimation(boolean flag){
|
||||
if(flag){
|
||||
private void startStopAnimation(boolean flag) {
|
||||
if (flag) {
|
||||
animation.start();
|
||||
} else {
|
||||
animation.stop();
|
||||
@@ -32,29 +30,30 @@ public class FontAwesomeSpinner extends ProgressIndicator {
|
||||
|
||||
private static class Animator extends AnimationTimer {
|
||||
|
||||
private static final long STATIC_TIMEFRAME = Duration.ofMillis(1000).toNanos();
|
||||
private static final long STATIC_TIMEFRAME = Duration.ofMillis(100).toNanos();
|
||||
//defined in css!
|
||||
private static int SEGMENT_COUNT = 8;
|
||||
private static final int ROTATION_ANGLE = 360/SEGMENT_COUNT;
|
||||
private static final int ROTATION_ANGLE = 360 / SEGMENT_COUNT;
|
||||
|
||||
private final Node toRotate;
|
||||
private final ProgressIndicator toRotate;
|
||||
|
||||
private long lastChange = 0;
|
||||
private int rotation_count = 0;
|
||||
|
||||
Animator(Node toRotate){
|
||||
Animator(ProgressIndicator toRotate) {
|
||||
this.toRotate = toRotate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
if(now - lastChange > STATIC_TIMEFRAME) {
|
||||
if (now - lastChange > STATIC_TIMEFRAME) {
|
||||
lastChange = now;
|
||||
|
||||
toRotate.setRotate(ROTATION_ANGLE * rotation_count);
|
||||
|
||||
rotation_count++;
|
||||
if( rotation_count == SEGMENT_COUNT) {
|
||||
rotation_count =0;
|
||||
if (rotation_count == SEGMENT_COUNT) {
|
||||
rotation_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Region?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.ProgressIndicator?>
|
||||
<?import org.cryptomator.ui.controls.FontAwesomeSpinner?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
|
||||
Reference in New Issue
Block a user