pixivj-jfx

Supporting library for Pixivj using JavaFX.

Лицензия

Лицензия

Группа

Группа

com.github.hanshsieh
Идентификатор

Идентификатор

pixivjjfx
Последняя версия

Последняя версия

0.1.4-beta
Дата

Дата

Тип

Тип

jar
Описание

Описание

pixivj-jfx
Supporting library for Pixivj using JavaFX.
Ссылка на сайт

Ссылка на сайт

https://github.com/hanshsieh/pixivj-jfx
Система контроля версий

Система контроля версий

http://github.com/hanshsieh/pixivj-jfx

Скачать pixivjjfx

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.hanshsieh/pixivjjfx/ -->
<dependency>
    <groupId>com.github.hanshsieh</groupId>
    <artifactId>pixivjjfx</artifactId>
    <version>0.1.4-beta</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.hanshsieh/pixivjjfx/
implementation 'com.github.hanshsieh:pixivjjfx:0.1.4-beta'
// https://jarcasting.com/artifacts/com.github.hanshsieh/pixivjjfx/
implementation ("com.github.hanshsieh:pixivjjfx:0.1.4-beta")
'com.github.hanshsieh:pixivjjfx:jar:0.1.4-beta'
<dependency org="com.github.hanshsieh" name="pixivjjfx" rev="0.1.4-beta">
  <artifact name="pixivjjfx" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.hanshsieh', module='pixivjjfx', version='0.1.4-beta')
)
libraryDependencies += "com.github.hanshsieh" % "pixivjjfx" % "0.1.4-beta"
[com.github.hanshsieh/pixivjjfx "0.1.4-beta"]

Зависимости

compile (7)

Идентификатор библиотеки Тип Версия
org.openjfx : javafx-controls jar 15.0.1
org.openjfx : javafx-web jar 15.0.1
com.github.hanshsieh : pixivj jar 1.1.1-beta-SNAPSHOT
org.checkerframework : checker-qual jar 3.10.0
org.slf4j : slf4j-api jar 1.7.30
com.widen : urlbuilder jar 2.1.1
org.apache.commons : commons-lang3 jar 3.11

Модули Проекта

Данный проект не имеет модулей.

Pixivj-jfx

Supporting library for Pixivj using JavaFX.
Java CI
Maven Central

Usage

Dependency

Because of a dependency it uses, please add the following settings to your pom.xml (For Maven).

<project>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>bintray</name>
      <url>https://jcenter.bintray.com</url>
    </repository>
  </repositories>
</project>

Then, add this library to the dependencies of your project.
Check out here for the available versions.

Getting access-token using web view login

Here, we show an example for getting an access token by showing a web view with JavaFX.

import com.github.hanshsieh.pixivj.oauth.PixivOAuthClient;
import com.github.hanshsieh.pixivj.token.ThreadedTokenRefresher;
import com.github.hanshsieh.pixivj.token.TokenRefresher;
import com.github.hanshsieh.pixivjjfx.stage.PixivLoginStage;
import java.io.Closeable;
import javafx.application.Application;
import javafx.stage.Stage;
public class Test extends Application {
  @Override
  public void start(Stage primaryStage) {
    // Simulate a worker thread
    new Thread(() -> {
      PixivOAuthClient authClient = null;
      TokenRefresher tokenRefresher = null;
      PixivLoginStage loginStage;
      try {
        authClient = new PixivOAuthClient.Builder().build();
        tokenRefresher = new ThreadedTokenRefresher.Builder()
            .setAuthClient(authClient)
            .build();
        loginStage = new PixivLoginStage.Builder().buildInFxThread();
        WebViewTokenProvider tokenProvider = new WebViewTokenProvider.Builder()
            .setAuthClient(authClient)
            .setTokenRefresher(tokenRefresher)
            .setLoginStage(loginStage)
            .build();
        String accessToken = tokenProvider.getAccessToken();
        System.out.printf("Access token: %s", accessToken);
      } catch (Exception ex) {
        ex.printStackTrace();
      } finally {
        closeQuietly(authClient);
        closeQuietly(tokenRefresher);
      }
    }).start();
  }

  private static void closeQuietly(Closeable closeable) {
    if (closeable == null) {
      return;
    }
    try {
      closeable.close();
    } catch (Exception ex) {
      // Do nothing
    }
  }

  public static void main(String[] args) {
    launch();
  }
}

Notice that when using JavaFX, you need to define an Application instance. The Application instance defines the entrypoint of a JavaFX application.
In the example, we use a separate thread to instantiate the PixivOAuthClient instance to simulate the case that you want to use the client in a worker thread (instead of JavaFX application thread).
It uses PixivLoginStage.Builder#buildInFxThread() to instantiate the PixivLoginStage. It's because PixivLoginStage is a JavaFX stage, and a JavaFX stage can only be instantiated and accessed in a JavaFX application thread. PixivLoginStage.Builder#buildInFxThread() helps you create the stage in the JavaFX application thread, and passed the object reference to the calling thread.

Contribution

Style

Please follow the Google coding style.
You may apply the IntelliJ style file here.

Release

Follow the guide at here to setup your PGP key and settings.xml.
Update the version in pom.xml appropriately.
Then, run

mvn -Duser.name="$(git config --get user.name)" clean deploy -P release

Версии библиотеки

Версия
0.1.4-beta
0.1.2-beta
0.1.1-beta