當前位置: 首頁>>代碼示例>>Java>>正文


Java LifecycleEvent類代碼示例

本文整理匯總了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);
}
 
開發者ID:Ciruman,項目名稱:QuarkFX,代碼行數:59,代碼來源:QuarkFXApplication.java

示例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();
        }
    });
}
 
開發者ID:gluonhq,項目名稱:gluon-samples,代碼行數:69,代碼來源:CommentsPresenter.java


注:本文中的com.gluonhq.charm.glisten.control.LifecycleEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。