Class SplashView

  • All Implemented Interfaces:
    Styleable, EventTarget

    public class SplashView
    extends View
    SplashView is a subclass of View intended to be used only as a first-time splash view. It will be the first view displayed and, should a Duration be specified, it will be hidden after that time passes, switching to the home view, or to any other specific view. Otherwise, it will be the developer's responsibility managing that transition. It should provide minimum content so it can be loaded fast enough to prevent a black screen on a mobile device, that most of the times may occur due to complex content loaded at startup. SplashView will be added to the factory of views with the key AppManager.SPLASH_VIEW. There are a few constructors available. If Duration is not specified as an argument, hiding the splash and switching to the first view will be responsibility of the developer. Typically this can be done by directly calling hideSplashView(), as a result of some event:
     
     addViewFactory(MobileApplication.SPLASH_VIEW, () -> {
         SplashView splashView = new SplashView();
         Button button = new Button("Click to close");
         button.setOnAction(e -> splashView.hideSplashView());
         splashView.setCenter(button);
         return splashView;
     });
    Or fired when a transition ends, like in this case that makes use of a PauseTransition:
     
     addViewFactory(MobileApplication.SPLASH_VIEW, () -> {
         SplashView splashView = new SplashView(new Label("This is a splash"));
         splashView.setOnShown(e -> {
             PauseTransition pause = new PauseTransition(Duration.seconds(3));
             pause.setOnFinished(e -> splashView.hideSplashView());
             pause.play());
         }); 
         return splashView;
     });
    On the contrary, if Duration is set, the lifecycle of the splash view will be managed internally:
     
     addViewFactory(MobileApplication.SPLASH_VIEW, () -> {
         return new SplashView(HOME_VIEW, 
                      new Label("This is a splash"), 
                      Duration.seconds(3));
     });
    Note that the SplashView will be removed from the factory after it is hidden, to avoid returning to it if the Android Back button is pressed. The only way to load the splash again will be registering it and calling MobileApplication.switchView(SPLASH_VIEW)
    Since:
    3.0.1
    • Property Detail

      • nextView

        public final ReadOnlyStringProperty nextViewProperty
        A read only string property with the name of the view that will be loaded after the splash is hidden
        See Also:
        getNextView()
      • duration

        public final ReadOnlyObjectProperty<Duration> durationProperty
        A read only object property with the duration of the pause transition used to hide the splash, if the duration is set with the three-argument constructor, or null otherwise.
        See Also:
        getDuration()
    • Constructor Detail

      • SplashView

        public SplashView()
        Default empty constructor. Creates a Splash View, that will switch to the HOME_VIEW after the splash is hidden. Developer has to provide its content, as in a regular View, and also a way to hide the splash (calling hideSplashView()) or switch to another view.
      • SplashView

        public SplashView​(String nextView)
        Creates a Splash View, that will switch to the view registered in the factory with the key "nextView", after the splash is hidden. Developer has to provide its content, as in a regular View, and also a way to hide the splash (calling hideSplashView()) or switch to another view.
        Parameters:
        nextView - The name of the view that will be loaded after the splash is hidden
      • SplashView

        public SplashView​(Node content)
        Creates a Splash View with the defined content placed at its center, and it will switch to the HOME_VIEW after the splash is hidden. Developer has to provide a way to hide the splash (calling hideSplashView()) or switch to another view.
        Parameters:
        content - The content of the splash view to be placed at the center of the view
      • SplashView

        public SplashView​(String nextView,
                          Node content)
        Creates a Splash View with the defined content placed at its center, that will switch to the view registered in the factory with the key "nextView", after the splash is hidden. Developer has to provide a way to hide the splash (calling hideSplashView()) or switch to another view.
        Parameters:
        nextView - The name of the view that will be loaded after the splash is hidden
        content - The content of the splash view to be placed at the center of the view
      • SplashView

        public SplashView​(String nextView,
                          Node content,
                          Duration duration)
        Creates a Splash View with the defined content placed at its center, that will switch to the view registered in the factory with the key "nextView", when a pause transition with the defined duration, and starting after the splash view is shown, finishes.
        Parameters:
        nextView - The name of the view that will be loaded after the splash is hidden
        content - The content of the splash view to be placed at the center of the view
        duration - of the PauseTransition
    • Method Detail

      • getNextView

        public final String getNextView()
        Gets the value of the property nextView.
        Property description:
        A read only string property with the name of the view that will be loaded after the splash is hidden
      • nextViewProperty

        public final ReadOnlyStringProperty nextViewProperty()
        A read only string property with the name of the view that will be loaded after the splash is hidden
        See Also:
        getNextView()
      • getDuration

        public final Duration getDuration()
        Gets the value of the property duration.
        Property description:
        A read only object property with the duration of the pause transition used to hide the splash, if the duration is set with the three-argument constructor, or null otherwise.
      • durationProperty

        public final ReadOnlyObjectProperty<Duration> durationProperty()
        A read only object property with the duration of the pause transition used to hide the splash, if the duration is set with the three-argument constructor, or null otherwise.
        See Also:
        getDuration()
      • hideSplashView

        public void hideSplashView()
        If Duration is not specified as an argument when creating the SplashView, hiding the splash and switching to the first view will be responsibility of the developer. This method can be called at the desired time to switch to the nextView View, hidding the splash in the process.
      • updateAppBar

        protected void updateAppBar​(AppBar appBar)
        If the view uses an AppBar it is the responsibility of the developer to appropriately set it up in this method. Every time the view is shown, this method will be called with a "clean" AppBar i.e. without any elements in it.
        Overrides:
        updateAppBar in class View
        Parameters:
        appBar - the AppBar
        See Also:
        AppBar.clear()