• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Services类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.gluonhq.charm.down.Services的典型用法代码示例。如果您正苦于以下问题:Java Services类的具体用法?Java Services怎么用?Java Services使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Services类属于com.gluonhq.charm.down包,在下文中一共展示了Services类的34个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createWebLaunchFAB

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static FloatingActionButton createWebLaunchFAB(Supplier<String> urlSupplier) {
    return createFAB(MaterialDesignIcon.LAUNCH, e -> {
        Services.get(BrowserService.class).ifPresent(b -> {
            try {
                String url = urlSupplier.get();
                if (!url.startsWith("http://") && !url.startsWith("https://")) {
                    url = "http://".concat(url);
                }
                b.launchExternalBrowser(url);
            } catch (IOException | URISyntaxException ex) {
                Toast toast = new Toast(OTNBundle.getString("OTN.VISUALS.CONNECTION_FAILED"));
                toast.show();
            }
        });
    });
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:17,
代码来源:Util.java

示例2: createFloatingActionButtons

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private Layer createFloatingActionButtons() {
    callActionButton = Util.createFAB(MaterialDesignIcon.CALL, e -> {
        Dialog confirmCallDialog = new Dialog(OTNBundle.getString("OTN.VENUE.CALLDIALOG.TITLE"), OTNBundle.getString("OTN.VENUE.CALLDIALOG.CONTENT", getVenue().getName(), getVenue().getPhoneNumber())) {
            {
                rootNode.setPrefWidth(MobileApplication.getInstance().getView().getScene().getWidth() * 0.9);
            }

        };
        Button cancel = new Button(OTNBundle.getString("OTN.VENUE.CALLDIALOG.NO"));
        Button ok = new Button(OTNBundle.getString("OTN.VENUE.CALLDIALOG.YES"));
        cancel.setOnAction(event -> confirmCallDialog.hide());
        ok.setOnAction(event -> {
            Services.get(DialerService.class).ifPresent(d -> d.call(getVenue().getPhoneNumber()));
            confirmCallDialog.hide();
        });
        confirmCallDialog.getButtons().addAll(cancel, ok);
        confirmCallDialog.showAndWait();

    });
    webActionButton = Util.createWebLaunchFAB(() -> getVenue().getUrl());
    webActionButton.getStyleClass().add("secondary");
    webActionButton.attachTo(callActionButton, Side.TOP);
    return callActionButton.getLayer();
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:25,
代码来源:VenuePresenter.java

示例3: initialize

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public void initialize() {
    maxCol = Services.get(DisplayService.class)
                .map(d -> d.isTablet() ? 3 : 2)
                .orElse(2);

    experiences.setOnShowing(event -> {
        AppBar appBar = getApp().getAppBar();
        appBar.setNavIcon(getApp().getNavMenuButton());
        appBar.setTitleText(OTNView.EXPERIENCES.getTitle());
        appBar.getActionItems().add(getApp().getSearchButton());
    });
    experiences.getStyleClass().add("experiences-view");
    
    experiencesGridPane = new GridPane();
    experiencesGridPane.getStyleClass().add("experiences-grid-pane");
    experiencesGridPane.setAlignment(Pos.TOP_CENTER);
    enabledOTNExperiences = service.retrieveEnabledOTNExperiences();
    enabledOTNExperiences.addListener(o -> setExperiences());

    experiences.setCenter(new Placeholder(PLACEHOLDER_MESSAGE, MaterialDesignIcon.ANNOUNCEMENT));
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:22,
代码来源:ExperiencesPresenter.java

示例4: MediaService

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public MediaService() {
    
    MobileApplication.getInstance().addLayerFactory(POPUP_NAME, () -> {
        imageView = new ImageView();
        imageView.setFitHeight(50);
        imageView.setPreserveRatio(true);
        HBox adsBox = new HBox(imageView);
        adsBox.getStyleClass().add("mediaBox");
        return new SidePopupView(adsBox, Side.BOTTOM, false);
    });
    
    Services.get(LifecycleService.class).ifPresent(service -> {
        service.addListener(LifecycleEvent.PAUSE, this::stopExecutor);
        service.addListener(LifecycleEvent.RESUME, this::startExecutor);
    });
    startExecutor();
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:18,
代码来源:MediaService.java

示例5: update

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private void update() {
    if (currentItem != null) {
        tile.textProperty().setAll(currentItem.getTitle(), 
                                   getSecondLine(currentItem.getText()));
        if (settings.isShowDate()) {
            tile.textProperty().add(dateFormat.format(currentItem.getCreationDate()));
        }
        
        if (fontSize != settings.getFontSize()) { 
            fontSize = settings.getFontSize();
            tile.getCenter().setStyle("-fx-font-size: " + 
                    (Services.get(DisplayService.class)
                            .map(d -> d.isTablet() ? 1.4 : 1.0)
                            .orElse(1.0) * fontSize) + "pt;");
        }
    } else {
        tile.textProperty().clear();
    }
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:20,
代码来源:NoteCell.java

示例6: postInit

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
@Override
public void postInit(Scene scene) {
    Swatch.LIGHT_GREEN.assignTo(scene);

    scene.getStylesheets().add(PushNotes.class.getResource("style.css").toExternalForm());
    ((Stage) scene.getWindow()).getIcons().add(new Image(PushNotes.class.getResourceAsStream("/icon.png")));
    
    Services.get(RuntimeArgsService.class).ifPresent(ras -> {
        ras.addListener(RuntimeArgsService.LAUNCH_PUSH_NOTIFICATION_KEY, f -> {
            System.out.println("Received a push notification with contents: " + f);
        });
    });
    
    PushClient pushClient = new PushClient();
    pushClient.enable(FIREBASE_SENDER_ID);
    
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:18,
代码来源:PushNotes.java

示例7: setStackEntry

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public void setStackEntry(StackEntry stackEntry) {
  StackOwner stackOwner = stackEntry.getOwner();
  if (stackOwner != null) {
      ImageView imageView = new ImageView(Util.getImage(stackOwner.getProfile_image()));
      imageView.setPreserveRatio(true);
      listTile.setPrimaryGraphic(imageView);
      listTile.setWrapText(true);
      listTile.textProperty().setAll(stackEntry.getTitle(), 
              stackOwner.getDisplay_name(), 
              "Created: " + Util.FORMATTER.format(LocalDateTime.ofEpochSecond(stackEntry.getCreation_date(), 0, ZoneOffset.UTC)) + 
                  " - Answers: " + stackEntry.getAnswer_count());
      Icon icon = new Icon(MaterialDesignIcon.OPEN_IN_BROWSER);
      icon.setOnMouseClicked(e -> Services.get(BrowserService.class)
              .ifPresent(browser -> {
                  try {
                      browser.launchExternalBrowser(stackEntry.getLink());
                  } catch (IOException | URISyntaxException ex) {}
              }));
      listTile.setSecondaryGraphic(icon);
  }
  search(String.valueOf(stackEntry.getQuestion_id()));
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:23,
代码来源:DetailPresenter.java

示例8: registerViewsAndDrawer

点赞 3

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static void registerViewsAndDrawer(MobileApplication app) {
    for (AppView view : REGISTRY.getViews()) {
        view.registerView(app);
    }

    avatar = new Avatar();
    Services.get(DisplayService.class).ifPresent(d -> {
        if (d.isTablet()) {
            avatar.getStyleClass().add("tablet");
        }
    });
    
    NavigationDrawer.Header header = new NavigationDrawer.Header("Gluon Mobile",
            "The Comments App", avatar);

    drawerManager = new DrawerManager(app, header, REGISTRY.getViews()); 
    drawerManager.installDrawer();
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:19,
代码来源:AppViewManager.java

示例9: showOfflineIndication

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static void showOfflineIndication() {
    STATUS_BAR.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, true);
    
    boolean show = Services.get(SettingsService.class)
            .map(s -> !"checked".equals(s.retrieve(DONT_SHOW_AGAIN_KEY)))
            .orElse(true);
    
    if (show) {
        Dialog dialog = new Dialog();
        VBox vBox = new VBox();
        vBox.getStyleClass().add("offline-dialog-content");
        Label label = new Label(OTNBundle.getString("OTN.OFFLINE.DIALOG.CONTENT"));
        label.setWrapText(true);
        CheckBox checkBox = new CheckBox(OTNBundle.getString("OTN.DIALOG.DONT_SHOW_AGAIN"));
        vBox.getChildren().addAll(label, checkBox);
        dialog.setTitleText(OTNBundle.getString("OTN.OFFLINE.DIALOG.TITLE"));
        dialog.setContent(vBox);
        Button okButton = new Button(OTNBundle.getString("OTN.OFFLINE.DIALOG.OK"));
        okButton.setOnAction(event -> {
            if (checkBox.isSelected()) {
                Services.get(SettingsService.class).ifPresent(s -> s.store(DONT_SHOW_AGAIN_KEY, "checked"));
            }
            dialog.hide();
        });
        dialog.getButtons().add(okButton);
        dialog.showAndWait();
    }
    
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:30,
代码来源:ConnectivityUtils.java

示例10: postInit

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
@Override
public void postInit(Scene scene) {
    String formFactorSuffix = Services.get(DisplayService.class)
            .map(s -> s.isTablet() ? "_tablet" : "")
            .orElse("");

    String stylesheetName = String.format("javaone_%s%s.css",
            Platform.getCurrent().name().toLowerCase(Locale.ROOT),
            formFactorSuffix);
    scene.getStylesheets().add(OTNApplication.class.getResource(stylesheetName).toExternalForm());
    
    if (Platform.isDesktop()) {
        Window window = scene.getWindow();
        ((Stage) window).getIcons().add(new Image(OTNApplication.class.getResourceAsStream("/icon.png")));
        window.setWidth(350);
        window.setHeight(700);
    }
    
    drawerPresenter = Injector.instantiateModelOrService(OTNDrawerPresenter.class);

    scene.getWindow().showingProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                initConnectivityServices();
                scene.getWindow().showingProperty().removeListener(this);
            }
        }
    });
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:31,
代码来源:OTNApplication.java

示例11: initConnectivityServices

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private void initConnectivityServices() {
    Services.get(ConnectivityService.class).ifPresent(connectivityService -> {
        connectivityService.connectedProperty().addListener((observable, oldValue, newValue) -> {
            ConnectivityUtils.showConnectivityIndication(newValue);
        });

        ConnectivityUtils.showConnectivityIndication(connectivityService.isConnected());
    });

}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:11,
代码来源:OTNApplication.java

示例12: initImageStore

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private static Optional<File> initImageStore() {
    try {
        File rootDir = Services.get(StorageService.class)
                .flatMap(StorageService::getPrivateStorage)
                .orElseThrow(() -> new IOException("Private storage file not available"));
        
        File imageDir = new File(rootDir, "otn-images");
        imageDir.mkdir();
        return Optional.of(imageDir);
    } catch (IOException ex) {
        LOG.log(Level.SEVERE, null, ex);
        return Optional.empty();
    }
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:15,
代码来源:ImageCache.java

示例13: getUserUUID

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static String getUserUUID() {
    uuid = Services.get(SettingsService.class)
            .map(s -> s.retrieve("UUID"))
            .orElse(null);
    
    if (uuid == null) {
        uuid = UUID.randomUUID().toString();
        Services.get(SettingsService.class).ifPresent(s -> s.store("UUID", uuid));
    }
    return uuid;
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:12,
代码来源:OTNSettings.java

示例14: getLastVoteCast

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static long getLastVoteCast() {
    if (lastVoteCast == null) {
        String lastVoteCastString = Services.get(SettingsService.class)
                .map(s -> s.retrieve("LAST_VOTE_CAST"))
                .orElse(null);
        if (lastVoteCastString != null) {
            lastVoteCast = Long.parseLong(lastVoteCastString);
        } else {
            lastVoteCast = 0L;
        }
    }

    return lastVoteCast;
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:15,
代码来源:OTNSettings.java

示例15: init

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
@Override
public void init() throws IOException {
	appStoragePath = Services.get(StorageService.class).orElseThrow(() -> new RuntimeException("Local storage not supported on this device!"))
		.getPrivateStorage().orElseThrow(() -> new RuntimeException("No local storage found on this device!"));
	
	setupServices();
    
    addViewFactory(LoginView.NAME, () -> new LoginView(LoginService.getInstance()));
    addViewFactory(TraplineListView.NAME, () -> new TraplineListView(trapDataService));
    addViewFactory(NavigationView.NAME, () -> new NavigationView(trapDataService));
    addViewFactory(TraplineInfoView.NAME, () -> new TraplineInfoView(trapDataService, mapLoadingService));
    addViewFactory(AddTrapView.NAME, () -> new AddTrapView());
    
	addLayerFactory("loading", () -> new LoadingLayer());
}
 

开发者ID:FrancisG-Massey,
项目名称:Capstone2016,
代码行数:16,
代码来源:NestApplication.java

示例16: setupServices

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private void setupServices () throws IOException {
	Services.registerServiceFactory(new AudioServiceFactory());
	LoginService loginService = LoginService.getInstance();
    CachingService cachingService = new DefaultCachingService(new File(appStoragePath, "cache"));
    NetworkService networkService = new RestNetworkService(loginService);
    DefaultTrapDataService trapDataService = new DefaultTrapDataService(cachingService, networkService);
    
    mapLoadingService = new GluonMapLoadingService(appStoragePath);
    
    trapDataService.initialise();
    this.trapDataService = trapDataService;
}
 

开发者ID:FrancisG-Massey,
项目名称:Capstone2016,
代码行数:13,
代码来源:NestApplication.java

示例17: DrawerManager

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public DrawerManager() {
    this.drawer = new NavigationDrawer();

    NavigationDrawer.Header header = new NavigationDrawer.Header("Gluon Mobile",
            "Multi View Project",
            new Avatar(21, new Image(DrawerManager.class.getResourceAsStream("/icon.png"))));
    drawer.setHeader(header);

    for (AppView view : AppViewManager.REGISTRY.getViews()) {
        if (view.isShownInDrawer()) {
            drawer.getItems().add(view.getMenuItem());
        }
    }

    if (Platform.isDesktop()) {
        final Item quitItem = new Item("Quit", MaterialDesignIcon.EXIT_TO_APP.graphic());
        quitItem.selectedProperty().addListener((obs, ov, nv) -> {
            if (nv) {
                Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown);
            }
        });
        drawer.getItems().add(quitItem);
    }

    drawer.addEventHandler(NavigationDrawer.ITEM_SELECTED,
            e -> MobileApplication.getInstance().hideLayer(MENU_LAYER));

    MobileApplication.getInstance().viewProperty().addListener((obs, oldView, newView) -> updateItem(newView.getName()));
    updateItem(MobileApplication.getInstance().getView().getName());
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:31,
代码来源:DrawerManager.java

示例18: update

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private void update() {
    if (currentItem != null) {
        tile.textProperty().setAll(currentItem.getTitle(), 
                                   getSecondLine(currentItem.getText()));
        tile.textProperty().add(dateFormat.format(currentItem.getCreationDate()));
        
        tile.getCenter().setStyle("-fx-font-size: " + 
                (Services.get(DisplayService.class)
                        .map(d -> d.isTablet() ? 1.4 : 1.0)
                        .orElse(1.0) * fontSize) + "pt;");
    } else {
        tile.textProperty().clear();
    }
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:15,
代码来源:NoteCell.java

示例19: initialize

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public void initialize() {
    main.showingProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            AppBar appBar = getApp().getAppBar();
            appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> getApp().showLayer(DRAWER_LAYER)));
            appBar.setTitleText("Native Services");
        }
    });
    
    logButton.setOnAction(e -> {
        String message = String.format("[%s] - %s", Platform.getCurrent().name(), logButton.getText());
        messageLabel.setText(message);
        Services.get(LogService.class).ifPresent(service -> service.log(message));
    });
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:16,
代码来源:MainPresenter.java

示例20: showInstructionsDialog

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private void showInstructionsDialog() {
    boolean show = Services.get(SettingsService.class)
            .map(s -> !"checked".equals(s.retrieve(DONT_SHOW_AGAIN_KEY)))
            .orElse(true);

    if (show) {
        Label title = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.TITLE"));
        Label titleDescription = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.TITLE_DESCRIPTION"));
        Label listenTitle = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.LISTEN_TITLE"));
        Label listenDescription = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.LISTEN_DESCRIPTION"));
        Label drawTitle = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.DRAW_TITLE"));
        Label drawDescription = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.DRAW_DESCRIPTION"));
        Label cutTitle = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.CUT_TITLE"));
        Label cutDescription = new Label(OTNBundle.getString("OTN.BADGE.DIALOG.CUT_DESCRIPTION"));

        ImageView listenImageView = new ImageView(BadgePresenter.class.getResource("EAR_Listen.png").toExternalForm());
        ImageView drawImageView = new ImageView(BadgePresenter.class.getResource("FINGER_Draw.png").toExternalForm());
        ImageView cutImageView = new ImageView(BadgePresenter.class.getResource("QRCODE_Cut.png").toExternalForm());

        // FIXME: Get rid of VBox's and use only GridPane
        VBox mainContainer = new VBox();
        GridPane contentContainer = new GridPane();
        VBox titleContainer = new VBox();
        VBox listenContainer = new VBox();
        VBox drawContainer = new VBox();
        VBox cutContainer = new VBox();

        CheckBox checkBox = new CheckBox(OTNBundle.getString("OTN.DIALOG.DONT_SHOW_AGAIN"));

        titleContainer.getChildren().addAll(title, titleDescription);
        listenContainer.getChildren().addAll(listenTitle, listenDescription);
        drawContainer.getChildren().addAll(drawTitle, drawDescription);
        cutContainer.getChildren().addAll(cutTitle, cutDescription);

        contentContainer.add(listenImageView, 0, 0);
        contentContainer.add(listenContainer, 1, 0);
        contentContainer.add(drawImageView, 0, 1);
        contentContainer.add(drawContainer, 1, 1);
        contentContainer.add(cutImageView, 0, 2);
        contentContainer.add(cutContainer, 1, 2);

        mainContainer.getChildren().addAll(contentContainer, checkBox);

        title.getStyleClass().add("dialog-badge-title");
        titleDescription.getStyleClass().add("dialog-badge-description");
        listenTitle.getStyleClass().add("dialog-badge-title");
        listenDescription.getStyleClass().add("dialog-badge-description");
        drawTitle.getStyleClass().add("dialog-badge-title");
        drawDescription.getStyleClass().add("dialog-badge-description");
        cutTitle.getStyleClass().add("dialog-badge-title");
        cutDescription.getStyleClass().add("dialog-badge-description");
        titleContainer.getStyleClass().add("dialog-badge-container");
        listenContainer.getStyleClass().add("dialog-badge-container");
        drawContainer.getStyleClass().add("dialog-badge-container");
        cutContainer.getStyleClass().add("dialog-badge-container");
        contentContainer.getStyleClass().add("dialog-badge-grid");
        checkBox.getStyleClass().add("dialog-badge-checkbox");
        mainContainer.getStyleClass().add("dialog-badge-main-container");

        Dialog instructionsDialog = new Dialog();
        instructionsDialog.setTitle(titleContainer);
        instructionsDialog.setContent(mainContainer);

        Button okButton = new Button(OTNBundle.getString("OTN.BUTTON.OK"));
        okButton.setOnAction(event -> {
            if (checkBox.isSelected()) {
                Services.get(SettingsService.class).ifPresent(s -> s.store(DONT_SHOW_AGAIN_KEY, "checked"));
            }
            instructionsDialog.hide();
        });
        instructionsDialog.getButtons().add(okButton);

        instructionsDialog.showAndWait();
    }
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:76,
代码来源:BadgePresenter.java

示例21: isEulaAccepted

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static boolean isEulaAccepted() {
    return Services.get(SettingsService.class)
            .map(s -> "Done".equals(s.retrieve("EULA")))
            .orElse(false);
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:6,
代码来源:EulaManager.java

示例22: acceptEula

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static void acceptEula() {
    Services.get(SettingsService.class).ifPresent(s -> s.store("EULA", "Done"));
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:4,
代码来源:EulaManager.java

示例23: OTNNotifications

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public OTNNotifications() {
    notificationsService = Services.get(LocalNotificationsService.class);
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:4,
代码来源:OTNNotifications.java

示例24: setLastVoteCast

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public static void setLastVoteCast(long updatedLastVoteCast) {
    lastVoteCast = updatedLastVoteCast;
    Services.get(SettingsService.class).ifPresent(s -> s.store("LAST_VOTE_CAST", String.valueOf(lastVoteCast)));
}
 

开发者ID:gluonhq,
项目名称:javaone2016,
代码行数:5,
代码来源:OTNSettings.java

示例25: initControls

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
/**
   * Constructs & adds the controls used by the view
   */
  private void initControls () {
  	HBox topBox = new HBox();
  	topBox.setId("top-box");
  	
  	topBox.setAlignment(Pos.CENTER);
  	
  	Label distanceLabel = new Label("0.0");
      distanceLabel.setId("distance-label");
      distanceLabel.visibleProperty().bind(Bindings.isNotNull(trapPositionLayer.currentPositionProperty()));
      
      distanceLabel.textProperty().bind(Bindings.format("%1.0f m", distanceToTrap));
      HBox.setHgrow(distanceLabel, Priority.ALWAYS);
              
      setTop(topBox);
      
      prev.toFront();
      prev.getStyleClass().add("prev");
      
      next.toFront();
      prev.getStyleClass().add("next");
      
      topBox.getChildren().addAll(prev, distanceLabel, next);        
      
      Button logCatch = new Button();
      logCatch.getStyleClass().add("large-button");
      logCatch.setText("Log Catch");
      logCatch.setOnAction(evt -> {
      	showLogCatchDialog();
      });
      setBottom(logCatch);
      
      
      trapProperty.bind(Bindings.valueAt(orderedTraps, currentTrapIndex));

      trapPositionLayer.activeTrapProperty().bind(trapProperty);

map.setZoom(MapLoadingService.ZOOM);
map.addLayer(trapPositionLayer);
  	
  	
  	trapProperty.addListener((obs, oldV, newV) -> {
  		LOG.log(Level.INFO, "Selected trap: "+newV);
  		if (newV == null) {
  			targetCoordsProperty.set(null);
  		} else {
  			targetCoordsProperty.set(new Position(newV.getLatitude(), newV.getLongitude()));
  			prev.setVisible(hasPreviousTrap(false));
  			next.setVisible(hasNextTrap(false));
  		}
  	});
  	
  	Optional<VibrationService> vibrationService = Services.get(VibrationService.class);
  	Optional<AudioService> audioService = Services.get(AudioService.class);
  	
  	distanceToTrap.addListener((obs, oldDist, newDist) -> {
  		Distance oldDistance = Distance.getForDistance(oldDist.doubleValue());
  		Distance newDistance = Distance.getForDistance(newDist.doubleValue());
  		if (oldDistance != newDistance) {
  			distanceLabel.pseudoClassStateChanged(oldDistance.cssPseudoClass, false);
  			distanceLabel.pseudoClassStateChanged(newDistance.cssPseudoClass, true);
  			if (oldDist.doubleValue() > newDist.doubleValue()) {
  				//Send both audio and vibration signals
  				audioService.ifPresent(service -> {
  					String audioName = newDistance.audioTrack;
  	    			if (Platform.isDesktop()) {
  	    				audioName = getClass().getResource("/"+newDistance.audioTrack).toExternalForm();
  	    			}
  	    			LOG.log(Level.INFO, "Trying to play audio: "+audioName);
  	    			service.play(audioName, 1.0);
  				});
  				vibrationService.ifPresent(service -> service.vibrate());
  			}
  		}
  	});
  }
 

开发者ID:FrancisG-Massey,
项目名称:Capstone2016,
代码行数:79,
代码来源:NavigationView.java

示例26: initPositionMonitor

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private void initPositionMonitor () {
	Services.get(PositionService.class).ifPresent(gpsService -> 
		trapPositionLayer.currentPositionProperty().bind(gpsService.positionProperty()));
}
 

开发者ID:FrancisG-Massey,
项目名称:Capstone2016,
代码行数:5,
代码来源:AddTrapView.java

示例27: LoginService

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
private LoginService () {
	settingService = Services.get(SettingsService.class);
}
 

开发者ID:FrancisG-Massey,
项目名称:Capstone2016,
代码行数:4,
代码来源:LoginService.java

示例28: initPositionService

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
@BeforeClass
public static void initPositionService() {
	when(posServiceFactory.getServiceType()).thenReturn(PositionService.class);
	when(posServiceFactory.getInstance()).thenReturn(Optional.of(posService));
	Services.registerServiceFactory(posServiceFactory);
}
 

开发者ID:FrancisG-Massey,
项目名称:Capstone2016,
代码行数:7,
代码来源:TestPositionLoading.java

示例29: main

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // get rid of INFO messages from gluon maps
    // https://stackoverflow.com/questions/13760095/java-dynamically-change-logging-level
    final Handler[] handlers = Logger.getLogger("").getHandlers();
    for (Handler handler : handlers) {
        handler.setLevel(Level.WARNING);
    }
    
    // set cache for mapo tile to avoid error message java.io.IOException: Storage Service is not available
    // https://github.com/gluonhq/maps/issues/8#issuecomment-310389905
    if(PlatformUtil.isWindows() || PlatformUtil.isMac() || PlatformUtil.isUnix()) {
        System.setProperty("javafx.platform" , "Desktop");
    }

    // define service for desktop
    StorageService storageService = new StorageService() {
        @Override
        public Optional<File> getPrivateStorage() {
            // user home app config location (linux: /home/[yourname]/.gluonmaps)
            return Optional.of(new File(System.getProperty("user.home")));
        }

        @Override
        public Optional<File> getPublicStorage(String subdirectory) {
            // this should work on desktop systems because home path is public
            return getPrivateStorage();
        }

        @Override
        public boolean isExternalStorageWritable() {
            //noinspection ConstantConditions
            return getPrivateStorage().get().canWrite();
        }

        @Override
        public boolean isExternalStorageReadable() {
            //noinspection ConstantConditions
            return getPrivateStorage().get().canRead();
        }
    };

    // define service factory for desktop
    ServiceFactory<StorageService> storageServiceFactory = new ServiceFactory<StorageService>() {
        @Override
        public Class<StorageService> getServiceType() {
            return StorageService.class;
        }

        @Override
        public Optional<StorageService> getInstance() {
            return Optional.of(storageService);
        }
    };

    // register service
    Services.registerServiceFactory(storageServiceFactory);
    
    launch(GPXEditorManager.class, args);
}
 

开发者ID:ThomasDaheim,
项目名称:GPXEditor,
代码行数:63,
代码来源:GPXEditorManager.java

示例30: setHost

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
static final void setHost( String newHost ) {
    Services.get(SettingsService.class).ifPresent(service -> {
        service.store(HOST_KEY, newHost);
    });
    HOST = newHost;
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:7,
代码来源:TicTacToe.java

示例31: initialize

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public void initialize() {
    edition.setShowTransitionFactory(BounceInRightTransition::new);
    PseudoClass pseudoClassDisable = PseudoClass.getPseudoClass("disabled");
            
    edition.showingProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            
            submit.disableProperty().unbind();
                
            Comment activeComment = service.activeCommentProperty().get();
            if (activeComment != null) {
                // disable avatar in case comment is not editable
                // content is enabled if user is its author
                commentsText.setDisable(!activeComment.getNetworkId().equals(service.getUser().getNetworkId()));
                avatar.pseudoClassStateChanged(pseudoClassDisable, commentsText.isDisable());
                avatar.setImage(Service.getUserImage(activeComment.getImageUrl()));
            
                authorText.setText(activeComment.getAuthor());
                commentsText.setText(activeComment.getContent());
                
                submit.setText("Apply");
                submit.disableProperty().bind(Bindings.createBooleanBinding(()->{
                    return authorText.textProperty()
                            .isEqualTo(activeComment.getAuthor())
                            .and(commentsText.textProperty()
                                    .isEqualTo(activeComment.getContent())).get();
                    }, authorText.textProperty(),commentsText.textProperty()));
                editMode = true;
            } else {
                commentsText.setDisable(false);
                avatar.pseudoClassStateChanged(pseudoClassDisable, false);
                avatar.setImage(Service.getUserImage(service.getUser().getPicture()));
                authorText.setText(service.getUser().getName());
                
                submit.setText("Submit");
                submit.disableProperty().bind(Bindings.createBooleanBinding(() -> {
                        return authorText.textProperty()
                                .isEmpty()
                                .or(commentsText.textProperty()
                                        .isEmpty()).get();
                    }, authorText.textProperty(), commentsText.textProperty()));
                editMode = false;
            }
            
            authorText.setDisable(!authorText.getText().isEmpty());
            
            AppBar appBar = getApp().getAppBar();
            appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> 
                    getApp().showLayer(DRAWER_LAYER)));
            appBar.setTitleText("Edition");
        } else {
            authorText.clear();
            commentsText.clear();
        }
    });
    
    Services.get(DisplayService.class)
            .ifPresent(d -> {
                if (d.isTablet()) {
                    avatar.getStyleClass().add("tablet");
                }
            });
    avatar.setImage(Service.getUserImage(service.getUser().getPicture()));
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:65,
代码来源:EditionPresenter.java

示例32: CommentListCell

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public CommentListCell(Service service, Consumer<Comment> consumerLeft, Consumer<Comment> consumerRight) {
    this.service = service;
    
    tile = new ListTile();
    avatar = new Avatar();
    Services.get(DisplayService.class)
            .ifPresent(d -> {
                if (d.isTablet()) {
                    avatar.getStyleClass().add("tablet");
                }
            });
    
    tile.setPrimaryGraphic(avatar);
    slidingTile = new SlidingListTile(tile, true, MaterialDesignIcon.DELETE.text, MaterialDesignIcon.EDIT.text);
    
    slidingTile.swipedLeftProperty().addListener((obs, ov, nv) -> {
        if (nv && consumerRight != null) {
            consumerRight.accept(currentItem);
        }
        slidingTile.resetTilePosition();
    });
    
    // delete mode, swipping from left to right
    slidingTile.swipedRightProperty().addListener((obs, ov, nv) -> {
        if (nv && consumerLeft != null) {
            consumerLeft.accept(currentItem);
        }
        slidingTile.resetTilePosition();
    });
    
    commentChangeListener = (obs, ov, nv) -> {
        // make sure text updates are run on the JavaFX thread, because the change can come from
        // an sse event from gluon cloud when another application updates a currentItem
        Platform.runLater(() -> {
            if (currentItem != null) {
                tile.textProperty().setAll(currentItem.getAuthor());
                tile.textProperty().addAll(getContent(currentItem));
            } else {
                tile.textProperty().clear();
            }
        });
    };
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:44,
代码来源:CommentListCell.java

示例33: BasicView

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public BasicView(String name) {
    super(name);

    AudioRecordingService audioRecordingService = Services.get(AudioRecordingService.class)
            .orElseThrow(() -> new RuntimeException("Could not find Audio Recording service."));

    Button start = new Button("Start Recording", new Icon(MaterialDesignIcon.MIC));
    start.setOnAction(e -> {
        audioRecordingService.clearAudioFolder();
        audioRecordingService.startRecording(8000.0f, 16, 2, 60);
    });
    start.disableProperty().bind(audioRecordingService.recordingProperty());

    Button stop = new Button("Stop Recording", new Icon(MaterialDesignIcon.STOP));
    stop.setOnAction(e -> audioRecordingService.stopRecording());
    stop.disableProperty().bind(audioRecordingService.recordingProperty().not());

    DataClient dataClient = DataClientBuilder.create().build();

    TextArea responseDebug = new TextArea();

    Button upload = new Button("Upload Audio", new Icon(MaterialDesignIcon.CLOUD_UPLOAD));
    upload.setOnAction(e -> {
        responseDebug.clear();
        for (String audioChunk : audioRecordingService.getAudioChunkFiles()) {
            File audioChunkFile = new File(audioRecordingService.getAudioFolder(), audioChunk);
            try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
                 FileInputStream fis = new FileInputStream(audioChunkFile)) {
                int bytesRead;
                byte[] bytes = new byte[4096];
                while ((bytesRead = fis.read(bytes)) != -1) {
                    baos.write(bytes, 0, bytesRead);
                }

                RemoteFunction storeAudio = RemoteFunctionBuilder.create("storeAudio")
                        .param("s3Key", audioChunk)
                        .rawBody(baos.toByteArray())
                        .build();

                GluonObservableObject<String> response = DataProvider.retrieveObject(dataClient.createObjectDataReader(storeAudio, String.class));
                response.stateProperty().addListener((obs, ov, nv) -> {
                    if (nv == ConnectState.FAILED) {
                        response.getException().printStackTrace();
                    } else if (nv == ConnectState.SUCCEEDED) {
                        responseDebug.appendText("Audio File " + audioChunk + " successfully uploaded to Amazon S3 bucket.");
                        responseDebug.appendText("\nResponse from AWS Lambda was:");
                        responseDebug.appendText("\n" + response.get());
                        responseDebug.appendText("\n===================");
                    }
                });
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    upload.disableProperty().bind(audioRecordingService.recordingProperty()
            .or(audioRecordingService.getAudioChunkFiles().emptyProperty()));

    VBox controls = new VBox(15.0, start, stop, upload, responseDebug);
    controls.setAlignment(Pos.CENTER);

    setCenter(controls);
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:64,
代码来源:BasicView.java

示例34: RestObjectView

点赞 2

import com.gluonhq.charm.down.Services; //导入依赖的package包/类
public RestObjectView(String name) {
    super(name);

    Label lbQuestionId = new Label();
    Label lbTitle = new Label();
    Hyperlink hlLink = new Hyperlink();

    GridPane gridPane = new GridPane();
    gridPane.setVgap(5.0);
    gridPane.setHgap(5.0);
    gridPane.setPadding(new Insets(5.0));
    gridPane.addRow(0, new Label("Question ID:"), lbQuestionId);
    gridPane.addRow(1, new Label("Title:"), lbTitle);
    gridPane.addRow(2, new Label("Link:"), hlLink);
    gridPane.getColumnConstraints().add(new ColumnConstraints(75));

    lbQuestionId.setWrapText(true);
    lbTitle.setWrapText(true);
    hlLink.setWrapText(true);

    hlLink.setOnAction(e -> {
        if (Platform.isDesktop()) {
            getApplication().getHostServices().showDocument(hlLink.getText());
        } else {
            Services.get(BrowserService.class).ifPresent(service -> {
                try {
                    service.launchExternalBrowser(hlLink.getText());
                } catch (IOException | URISyntaxException ex) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Failed to open URL");
                    alert.setContentText("Failed to open URL. Reason: " + ex.getMessage());
                    alert.showAndWait();
                }
            });
        }
    });

    setCenter(gridPane);

    // create a RestClient to the specific URL
    RestClient restClient = RestClient.create()
            .method("GET")
            .host("https://api.stackexchange.com")
            .path("/2.2/questions/36243147")
            .queryParam("order", "desc")
            .queryParam("sort", "activity")
            .queryParam("site", "stackoverflow");

    // create a custom Converter that is able to parse the response into a single object
    InputStreamInputConverter<Question> converter = new SingleItemInputConverter<>(Question.class);

    // retrieve an object from the DataProvider
    GluonObservableObject<Question> question = DataProvider.retrieveObject(restClient.createObjectDataReader(converter));

    // when the object is initialized, bind its properties to the JavaFX UI controls
    question.initializedProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            lbQuestionId.textProperty().bind(question.get().questionIdProperty().asString());
            lbTitle.textProperty().bind(question.get().titleProperty());
            hlLink.textProperty().bind(question.get().linkProperty());
        }
    });
}
 

开发者ID:gluonhq,
项目名称:gluon-samples,
代码行数:64,
代码来源:RestObjectView.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)