Compare commits
No commits in common. "f49f2dae43c660b473730ef148f78b439141635d" and "9a5a469ad06fd5b7575525a5a78f2a9ab1cdfd9b" have entirely different histories.
f49f2dae43
...
9a5a469ad0
|
@ -268,8 +268,7 @@ public class CamrecApplication extends Application {
|
|||
tabPane.getTabs().add(new RecentlyWatchedTab(recorder, sites));
|
||||
}
|
||||
tabPane.getTabs().add(new SettingsTab(sites, recorder));
|
||||
//tabPane.getTabs().add(new NewsTab(config));
|
||||
tabPane.getTabs().add(new NewsTab(config, getHostServices()));
|
||||
tabPane.getTabs().add(new NewsTab(config));
|
||||
tabPane.getTabs().add(new DonateTabFx());
|
||||
tabPane.getTabs().add(new HelpTab());
|
||||
tabPane.getTabs().add(new LoggingTab());
|
||||
|
|
|
@ -6,9 +6,9 @@ import ctbrec.GlobalThreadPool;
|
|||
import ctbrec.Version;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.io.json.ObjectMapperFactory;
|
||||
import ctbrec.ui.CamrecApplication;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
import ctbrec.ui.tabs.TabSelectionListener;
|
||||
import javafx.application.HostServices;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
|
@ -18,9 +18,7 @@ import javafx.scene.control.ScrollPane;
|
|||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.layout.VBox;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -34,14 +32,11 @@ import static ctbrec.io.HttpConstants.USER_AGENT;
|
|||
public class NewsTab extends Tab implements TabSelectionListener {
|
||||
private static final String URL = "https://git.ctbrec.com/api/v1/repos/j62/ctbrec/releases";
|
||||
private final Config config;
|
||||
private final HostServices hostServices;
|
||||
private final VBox layout = new VBox();
|
||||
private final ObjectMapper mapper = ObjectMapperFactory.getMapper();
|
||||
private final OkHttpClient httpClient = new OkHttpClient();
|
||||
|
||||
public NewsTab(Config config, HostServices hostServices) {
|
||||
public NewsTab(Config config) {
|
||||
this.config = config;
|
||||
this.hostServices = hostServices;
|
||||
setText("Releases");
|
||||
layout.setMaxWidth(800);
|
||||
layout.setAlignment(Pos.CENTER);
|
||||
|
@ -59,7 +54,7 @@ public class NewsTab extends Tab implements TabSelectionListener {
|
|||
.url(URL)
|
||||
.header(USER_AGENT, "ctbrec " + Version.getVersion())
|
||||
.build();
|
||||
try (Response response = httpClient.newCall(request).execute()) {
|
||||
try (var response = CamrecApplication.httpClient.execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
var body = Objects.requireNonNull(response.body(), HTTP_RESPONSE_BODY_IS_NULL).string();
|
||||
log.debug(body);
|
||||
|
@ -112,7 +107,7 @@ public class NewsTab extends Tab implements TabSelectionListener {
|
|||
int downloads = asset.optInt("download_count", 0);
|
||||
|
||||
Hyperlink assetLink = new Hyperlink(assetName + " (" + size / 1024 / 1024 + " MB, " + downloads + " downloads)");
|
||||
assetLink.setOnAction(event -> hostServices.showDocument(downloadUrl));
|
||||
assetLink.setOnAction(event -> CamrecApplication.getHostServicesInstance().showDocument(downloadUrl));
|
||||
|
||||
releasePane.getChildren().add(assetLink);
|
||||
}
|
||||
|
@ -128,4 +123,4 @@ public class NewsTab extends Tab implements TabSelectionListener {
|
|||
public void deselected() {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue