@Override
  public final void onLoadCleared(@Nullable Drawable placeholder) {
    sizeDeterminer.clearCallbacksAndListener();

    onResourceCleared(placeholder);
    if (!isClearedByUs) {
      maybeRemoveAttachStateListener();
    }
  }
@Test
  public void onLoadCleared_withoutClearOnDetach_doesNotRemoveListeners() {
    final AtomicInteger count = new AtomicInteger();
    OnAttachStateChangeListener expected =
        new OnAttachStateChangeListener() {
          @Override
          public void onViewAttachedToWindow(View v) {
            count.incrementAndGet();
          }

          @Override
          public void onViewDetachedFromWindow(View v) {
            // Intentionally Empty.
          }
        };
    view.addOnAttachStateChangeListener(expected);

    attachStateTarget.onLoadCleared(/* placeholder= */ null);

    activity.visible();

    Truth.assertThat(count.get()).isEqualTo(1);
  }