static void onMount()

in vito/litho-slideshow/src/main/java/com/facebook/fresco/vito/litho/slideshow/FrescoVitoSlideshowComponentSpec.java [64:150]


  static void onMount(
      final ComponentContext c,
      final FrescoVitoSlideshowDrawable slideshowDrawable,
      final @Prop(varArg = "uri") List<Uri> uris,
      final @Prop int photoTransitionMs,
      final @Prop int fadeTransitionMs,
      final @Prop(optional = true) boolean isPlaying,
      final @Prop(optional = true) @Nullable ImageOptions imageOptions,
      final @Prop(optional = true) @Nullable Object callerContext,
      final @TreeProp @Nullable ContextChain contextChain,
      final @State(canUpdateLazily = true) Integer slideshowIndex,
      final @State(canUpdateLazily = true) Timer timer,
      final @State(canUpdateLazily = true) Boolean currentlyPlaying) {
    // Reset mount content
    FrescoController2 controller = FrescoVitoProvider.getController();
    controller.releaseImmediately(slideshowDrawable.getPreviousImage());
    controller.releaseImmediately(slideshowDrawable.getCurrentImage());
    controller.releaseImmediately(slideshowDrawable.getNextImage());
    slideshowDrawable.reset();

    // Configure mount content
    slideshowDrawable.setTransitionDuration(fadeTransitionMs);

    // Load current image
    fetchNextImage(
        c.getResources(),
        slideshowDrawable,
        uris.get(slideshowIndex),
        imageOptions,
        callerContext,
        contextChain);
    // Immediately show current image
    slideshowDrawable.fadeToNext();
    slideshowDrawable.finishTransitionImmediately();

    final int listSize = uris.size();

    if (isPlaying && !currentlyPlaying) {
      // Load next image immediately
      final int nextImageIndex = (slideshowIndex + 1) % listSize;
      fetchNextImage(
          c.getResources(),
          slideshowDrawable,
          uris.get(nextImageIndex),
          imageOptions,
          callerContext,
          contextChain);

      // Set up task for animating to next image
      final Runnable animation =
          new Runnable() {
            int currentIndex = nextImageIndex;

            @Override
            public void run() {
              int nextIndex = (currentIndex + 1) % listSize;
              animateToNextImage(
                  c.getResources(),
                  slideshowDrawable,
                  uris,
                  imageOptions,
                  callerContext,
                  contextChain,
                  nextIndex);
              currentIndex = nextIndex;
              FrescoVitoSlideshowComponent.lazyUpdateSlideshowIndex(c, currentIndex);
            }
          };

      final Handler handler = new Handler(Looper.getMainLooper());
      TimerTask timerTask =
          new TimerTask() {
            @Override
            public void run() {
              handler.post(animation);
            }
          };
      slideshowDrawable.setTimerTask(timerTask);
      timer.scheduleAtFixedRate(timerTask, photoTransitionMs, photoTransitionMs + fadeTransitionMs);
    } else if (!isPlaying && currentlyPlaying) {
      TimerTask animateTask = slideshowDrawable.getTimerTask();
      if (animateTask != null) {
        animateTask.cancel();
      }
      FrescoVitoSlideshowComponent.lazyUpdateCurrentlyPlaying(c, false);
    }
  }