Code cleanup
This commit is contained in:
parent
5c3755dedc
commit
267e3394b5
|
@ -13,6 +13,7 @@ import ctbrec.ui.CamrecApplication;
|
|||
import ctbrec.ui.SiteUiFactory;
|
||||
import ctbrec.ui.StreamSourceSelectionDialog;
|
||||
import ctbrec.ui.action.PlayAction;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
import ctbrec.ui.controls.PausedIndicator;
|
||||
import ctbrec.ui.controls.StreamPreview;
|
||||
import javafx.animation.FadeTransition;
|
||||
|
@ -22,7 +23,6 @@ import javafx.animation.Transition;
|
|||
import javafx.application.Platform;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Insets;
|
||||
|
@ -236,7 +236,7 @@ public class ThumbCell extends StackPane {
|
|||
play.setStyle("-fx-background-color: black;");
|
||||
previewTrigger.getChildren().add(play);
|
||||
|
||||
Circle clip = new Circle(s / 2);
|
||||
Circle clip = new Circle(s / 2.0);
|
||||
clip.setTranslateX(clip.getRadius());
|
||||
clip.setTranslateY(clip.getRadius());
|
||||
previewTrigger.setClip(clip);
|
||||
|
@ -287,8 +287,7 @@ public class ThumbCell extends StackPane {
|
|||
resolution = resolutionCache.get(model);
|
||||
resolutionBackgroundColor = resolutionOnlineColor;
|
||||
final int w = resolution[1];
|
||||
String width = w != Integer.MAX_VALUE ? Integer.toString(w) : "HD";
|
||||
tagText = width;
|
||||
tagText = w != Integer.MAX_VALUE ? Integer.toString(w) : "HD";
|
||||
if (w == 0) {
|
||||
State state = model.getOnlineState(false);
|
||||
tagText = state.name();
|
||||
|
@ -364,7 +363,7 @@ public class ThumbCell extends StackPane {
|
|||
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
|
||||
});
|
||||
} else {
|
||||
img.progressProperty().addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
|
||||
img.progressProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue.doubleValue() == 1.0) {
|
||||
iv.setImage(img);
|
||||
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
|
||||
|
@ -403,13 +402,13 @@ public class ThumbCell extends StackPane {
|
|||
|
||||
private void setRecording(boolean recording) {
|
||||
this.recording = recording;
|
||||
Color c;
|
||||
if (recording) {
|
||||
Color c = mouseHovering ? colorHighlight : colorRecording;
|
||||
nameBackground.setFill(c);
|
||||
c = mouseHovering ? colorHighlight : colorRecording;
|
||||
} else {
|
||||
Color c = mouseHovering ? colorHighlight : colorNormal;
|
||||
nameBackground.setFill(c);
|
||||
c = mouseHovering ? colorHighlight : colorNormal;
|
||||
}
|
||||
nameBackground.setFill(c);
|
||||
|
||||
updateRecordingIndicator();
|
||||
}
|
||||
|
@ -430,7 +429,7 @@ public class ThumbCell extends StackPane {
|
|||
boolean selectSource = Config.getInstance().getSettings().chooseStreamQuality;
|
||||
if (selectSource && start) {
|
||||
Function<Model, Void> onSuccess = modl -> {
|
||||
startStopActionAsync(modl, start);
|
||||
startStopActionAsync(modl, true);
|
||||
return null;
|
||||
};
|
||||
Function<Throwable, Void> onFail = throwable -> {
|
||||
|
@ -484,13 +483,7 @@ public class ThumbCell extends StackPane {
|
|||
}
|
||||
} catch (Exception e1) {
|
||||
LOG.error(COULDNT_START_STOP_RECORDING, e1);
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, getScene());
|
||||
alert.setTitle(ERROR);
|
||||
alert.setHeaderText(COULDNT_START_STOP_RECORDING);
|
||||
alert.setContentText("I/O error while starting/stopping the recording: " + e1.getLocalizedMessage());
|
||||
alert.showAndWait();
|
||||
});
|
||||
Dialogs.showError(getScene(), COULDNT_START_STOP_RECORDING, "I/O error while starting/stopping the recording: ", e1);
|
||||
} finally {
|
||||
setCursor(Cursor.DEFAULT);
|
||||
}
|
||||
|
@ -507,13 +500,7 @@ public class ThumbCell extends StackPane {
|
|||
if (followed) {
|
||||
return true;
|
||||
} else {
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, getScene());
|
||||
alert.setTitle(ERROR);
|
||||
alert.setHeaderText("Couldn't follow model");
|
||||
alert.setContentText("");
|
||||
alert.showAndWait();
|
||||
});
|
||||
Dialogs.showError(getScene(), "Couldn't follow model", "", null);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -523,25 +510,14 @@ public class ThumbCell extends StackPane {
|
|||
Platform.runLater(() -> thumbCellList.remove(ThumbCell.this));
|
||||
return true;
|
||||
} else {
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, getScene());
|
||||
alert.setTitle(ERROR);
|
||||
alert.setHeaderText("Couldn't unfollow model");
|
||||
alert.setContentText("");
|
||||
alert.showAndWait();
|
||||
});
|
||||
Dialogs.showError(getScene(), "Couldn't unfollow model", "", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
LOG.error("Couldn't follow/unfollow model {}", model.getName(), e1);
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, getScene());
|
||||
alert.setTitle(ERROR);
|
||||
alert.setHeaderText("Couldn't follow/unfollow model");
|
||||
alert.setContentText("I/O error while following/unfollowing model " + model.getName() + ": " + e1.getLocalizedMessage());
|
||||
alert.showAndWait();
|
||||
});
|
||||
String msg = "I/O error while following/unfollowing model " + model.getName() + ": ";
|
||||
Dialogs.showError(getScene(), "Couldn't follow/unfollow model", msg, e1);
|
||||
return false;
|
||||
} finally {
|
||||
setCursor(Cursor.DEFAULT);
|
||||
|
@ -616,8 +592,8 @@ public class ThumbCell extends StackPane {
|
|||
public void setThumbWidth(int width) {
|
||||
int height = (int) (width * imgAspectRatio);
|
||||
setSize(width, height);
|
||||
iv.prefHeight(height);
|
||||
iv.prefWidth(width);
|
||||
iv.prefHeight(width);
|
||||
iv.prefWidth(height);
|
||||
}
|
||||
|
||||
private void setSize(int w, int h) {
|
||||
|
@ -638,8 +614,8 @@ public class ThumbCell extends StackPane {
|
|||
topic.prefHeight(getHeight() - 25);
|
||||
topic.maxHeight(getHeight() - 25);
|
||||
int margin = 4;
|
||||
topic.maxWidth(w - margin * 2);
|
||||
topic.setWrappingWidth(w - margin * 2);
|
||||
topic.maxWidth(w - margin * 2.0);
|
||||
topic.setWrappingWidth(w - margin * 2.0);
|
||||
|
||||
streamPreview.resizeTo(w, h);
|
||||
|
||||
|
|
Loading…
Reference in New Issue