@Test public void addView_withDestroyedNativeResponse_shouldNotAddView() { when(nativeResponse.isDestroyed()).thenReturn(true); subject.addView(view, nativeResponse); assertThat(trackedViews).isEmpty(); verify(visibilityTracker, never()) .addView(view, nativeResponse.getImpressionMinPercentageViewed()); }
void addView(final View view, @NonNull final NativeResponse nativeResponse) { if (mTrackedViews.get(view) == nativeResponse) { return; } removeView(view); if (nativeResponse.getRecordedImpression() || nativeResponse.isDestroyed()) { return; } mTrackedViews.put(view, nativeResponse); mVisibilityTracker.addView(view, nativeResponse.getImpressionMinPercentageViewed()); }
ImpressionTracker { void addView(final View view, @NonNull final NativeResponse nativeResponse) { if (mTrackedViews.get(view) == nativeResponse) { return; } removeView(view); if (nativeResponse.getRecordedImpression() || nativeResponse.isDestroyed()) { return; } mTrackedViews.put(view, nativeResponse); mVisibilityTracker.addView(view, nativeResponse.getImpressionMinPercentageViewed()); } }
ImpressionTracker { void addView(final View view, @NonNull final NativeResponse nativeResponse) { if (mTrackedViews.get(view) == nativeResponse) { return; } removeView(view); if (nativeResponse.getRecordedImpression() || nativeResponse.isDestroyed()) { return; } mTrackedViews.put(view, nativeResponse); mVisibilityTracker.addView(view, nativeResponse.getImpressionMinPercentageViewed()); } ImpressionTracker(@NonNull final Context context); @VisibleForTesting  ImpressionTracker(@NonNull final Map<View, NativeResponse> trackedViews,
            @NonNull final Map<View, TimestampWrapper<NativeResponse>> pollingViews,
            @NonNull final VisibilityChecker visibilityChecker,
            @NonNull final VisibilityTracker visibilityTracker,
            @NonNull final Handler handler); }
ImpressionTracker { void addView(final View view, @NonNull final NativeResponse nativeResponse) { if (mTrackedViews.get(view) == nativeResponse) { return; } removeView(view); if (nativeResponse.getRecordedImpression() || nativeResponse.isDestroyed()) { return; } mTrackedViews.put(view, nativeResponse); mVisibilityTracker.addView(view, nativeResponse.getImpressionMinPercentageViewed()); } ImpressionTracker(@NonNull final Context context); @VisibleForTesting  ImpressionTracker(@NonNull final Map<View, NativeResponse> trackedViews,
            @NonNull final Map<View, TimestampWrapper<NativeResponse>> pollingViews,
            @NonNull final VisibilityChecker visibilityChecker,
            @NonNull final VisibilityTracker visibilityTracker,
            @NonNull final Handler handler);  }
ImpressionTracker { void addView(final View view, @NonNull final NativeResponse nativeResponse) { if (mTrackedViews.get(view) == nativeResponse) { return; } removeView(view); if (nativeResponse.getRecordedImpression() || nativeResponse.isDestroyed()) { return; } mTrackedViews.put(view, nativeResponse); mVisibilityTracker.addView(view, nativeResponse.getImpressionMinPercentageViewed()); } ImpressionTracker(@NonNull final Context context); @VisibleForTesting  ImpressionTracker(@NonNull final Map<View, NativeResponse> trackedViews,
            @NonNull final Map<View, TimestampWrapper<NativeResponse>> pollingViews,
            @NonNull final VisibilityChecker visibilityChecker,
            @NonNull final VisibilityTracker visibilityTracker,
            @NonNull final Handler handler);   }