Ejemplo n.º 1
0
  @Override
  public void start(Stage primaryStage) {
    // primaryStage.initStyle(StageStyle.TRANSPARENT);
    accessor = new TwitchAPIAccessor();

    GridPane root = new GridPane();
    root.setHgap(20);
    root.setVgap(20);
    Button exit = new Button("Exit");
    exit.setOnAction(e -> primaryStage.close());
    root.add(exit, 0, 0);

    authStage = new Authentication();
    Button auth = new Button("Authenticate");
    auth.setOnAction(e -> authStage.authenticate(false, this::authSuccess, this::authFailure));
    root.add(auth, 0, 1);

    Button forceAuth = new Button("Force Authenticate");
    forceAuth.setOnAction(e -> authStage.authenticate(true, this::authSuccess, this::authFailure));
    root.add(forceAuth, 0, 2);

    Button isValid = new Button("Is Valid");
    isValid.setOnAction(e -> accessor.isOAuthValid(this::oauthValid, this::oauthInvalid));
    root.add(isValid, 0, 3);

    Button follows = new Button("Get Follows");
    follows.setOnAction(
        e -> accessor.getFollowAccessor().getUserStreamsFollowed(this::follows, this::exception));
    root.add(follows, 0, 4);

    ImageView imageView = new ImageView(image);
    imageView.setEffect(new ColorAdjust(0, -1, 0, 0));

    BorderPane imagePane = new BorderPane(imageView);
    imagePane.setStyle(
        "-fx-border-color: green;\n"
            + "-fx-border-insets: 5;\n"
            + "-fx-border-width:3;\n"
            + "-fx-border-style: dashed;\n");

    root.add(imagePane, 0, 5);

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Ejemplo n.º 2
0
 private void authSuccess(AuthState state) {
   System.out.println("Auth Success: " + state + ": " + authStage.getAuthToken());
   accessor.setOauthToken(authStage.getAuthToken());
 }
Ejemplo n.º 3
0
 private void oauthValid() {
   System.out.println("OAuth is valid");
   accessor.setOauthToken(authStage.getAuthToken());
 }