本文整理汇总了Java中com.gluonhq.charm.glisten.control.LifecycleEvent类的典型用法代码示例。如果您正苦于以下问题:Java LifecycleEvent类的具体用法?Java LifecycleEvent怎么用?Java LifecycleEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LifecycleEvent类属于com.gluonhq.charm.glisten.control包,在下文中一共展示了LifecycleEvent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.gluonhq.charm.glisten.control.LifecycleEvent; //导入依赖的package包/类
@Override
public final void init() {
nativePlatform = NativePlatformFactory.getPlatform();
Log.overrideDefaultLogger(nativePlatform.getLogger());
final OrientationHandler orientationHandler = new OrientationHandler();
final ViewHandler viewHandler = new ViewHandler(this);
/*
* Loading Screen
*/
addViewFactory(HOME_VIEW, new Supplier<View>() {
@Override
public View get() {
View v = new View(HOME_VIEW);
final ImageView imageView = new ImageView(new Image(QuarkFXApplication.class.getResourceAsStream("/logo.jpg")));
imageView.setPreserveRatio(true);
imageView.setFitWidth(150);
v.setCenter(imageView);
v.setBottom(new Label("Loading ..."));
v.setOnShown(new EventHandler<LifecycleEvent>() {
@Override
public void handle(LifecycleEvent event) {
QuarkFXApplication.this.getAppBar().setVisible(false);
//TODO is this good?
OrientationEventDispatcher.register(orientationHandler, QuarkFXApplication.this.getGlassPane());
viewHandler.startUp(orientationHandler);
QuarkFXApplication.this.triggerStartup();
Log.d("### initial switch ###");
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Platform.runLater(new Runnable() {
@Override
public void run() {
viewHandler.switchToHome(ViewStackPolicy.SKIP);
}
});
//explicitly end timer: when you don't there could be a running thread on application stop that blocks other threads
timer.cancel();
timer.purge();
}
}, 1500);
}
}
);
return v;
}
}
);
initApp(viewHandler);
}
示例2: initialize
import com.gluonhq.charm.glisten.control.LifecycleEvent; //导入依赖的package包/类
public void initialize() {
comments.showingProperty().addListener((obs, oldValue, newValue) -> {
if (newValue) {
AppBar appBar = getApp().getAppBar();
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e ->
getApp().showLayer(DRAWER_LAYER)));
appBar.setTitleText("Comments");
}
});
FloatingActionButton floatingActionButton = new FloatingActionButton();
floatingActionButton.textProperty().bind(new When(userProperty().isNotNull())
.then(MaterialDesignIcon.ADD.text)
.otherwise(MaterialDesignIcon.CLOUD_DOWNLOAD.text));
floatingActionButton.setOnAction(e -> {
if (service.getUser() == null) {
service.retrieveComments();
} else {
EDITION_VIEW.switchView();
}
});
comments.getLayers().add(floatingActionButton.getLayer());
commentsList.setCellFactory(cell -> {
final CommentListCell commentListCell = new CommentListCell(
service,
// left button: delete comment, only author's comment can delete it
c -> {
if (service.getUser().getNetworkId().equals(c.getNetworkId())) {
showDialog(c);
}
},
// right button: edit comment, everybody can view it, only author can edit it
c -> {
service.activeCommentProperty().set(c);
EDITION_VIEW.switchView();
});
// notify view that cell is sliding
sliding.bind(commentListCell.slidingProperty());
return commentListCell;
});
final Label label = new Label(SIGN_IN_MESSAGE);
label.textProperty().bind(new When(userProperty().isNotNull())
.then(NO_COMMENTS_MESSAGE)
.otherwise(SIGN_IN_MESSAGE));
commentsList.setPlaceholder(label);
commentsList.disableProperty().bind(service.userProperty().isNull());
commentsList.setItems(service.commentsProperty());
comments.addEventHandler(LifecycleEvent.SHOWN, new EventHandler<LifecycleEvent>() {
@Override
public void handle(LifecycleEvent event) {
comments.removeEventHandler(LifecycleEvent.SHOWN, this);
service.retrieveComments();
}
});
// block scrolling when sliding
comments.addEventFilter(ScrollEvent.ANY, e -> {
if (sliding.get() && e.getDeltaY() != 0) {
e.consume();
}
});
}