@Test public void addView_withVisibleView_shouldAddVisibleViewToTrackedViews() throws Exception { subject.addView(view, MIN_PERCENTAGE_VIEWED); assertThat(trackedViews).hasSize(1); }
void addView(@NonNull final View view, final int minPercentageViewed) { TrackingInfo trackingInfo = mTrackedViews.get(view); if (trackingInfo == null) { trackingInfo = new TrackingInfo(); mTrackedViews.put(view, trackingInfo); scheduleVisibilityCheck(); } trackingInfo.mMinViewablePercent = minPercentageViewed; trackingInfo.mAccessOrder = mAccessCounter; mAccessCounter++; if (mAccessCounter % NUM_ACCESSES_BEFORE_TRIMMING == 0) { trimTrackedViews(mAccessCounter - NUM_ACCESSES_BEFORE_TRIMMING); } }
VisibilityTracker { void addView(@NonNull final View view, final int minPercentageViewed) { TrackingInfo trackingInfo = mTrackedViews.get(view); if (trackingInfo == null) { trackingInfo = new TrackingInfo(); mTrackedViews.put(view, trackingInfo); scheduleVisibilityCheck(); } trackingInfo.mMinViewablePercent = minPercentageViewed; trackingInfo.mAccessOrder = mAccessCounter; mAccessCounter++; if (mAccessCounter % NUM_ACCESSES_BEFORE_TRIMMING == 0) { trimTrackedViews(mAccessCounter - NUM_ACCESSES_BEFORE_TRIMMING); } } }
VisibilityTracker { void addView(@NonNull final View view, final int minPercentageViewed) { TrackingInfo trackingInfo = mTrackedViews.get(view); if (trackingInfo == null) { trackingInfo = new TrackingInfo(); mTrackedViews.put(view, trackingInfo); scheduleVisibilityCheck(); } trackingInfo.mMinViewablePercent = minPercentageViewed; trackingInfo.mAccessOrder = mAccessCounter; mAccessCounter++; if (mAccessCounter % NUM_ACCESSES_BEFORE_TRIMMING == 0) { trimTrackedViews(mAccessCounter - NUM_ACCESSES_BEFORE_TRIMMING); } } VisibilityTracker(@NonNull final Context context); @VisibleForTesting  VisibilityTracker(@NonNull final Context context,
            @NonNull final Map<View, TrackingInfo> trackedViews,
            @NonNull final VisibilityChecker visibilityChecker,
            @NonNull final Handler visibilityHandler); }
VisibilityTracker { void addView(@NonNull final View view, final int minPercentageViewed) { TrackingInfo trackingInfo = mTrackedViews.get(view); if (trackingInfo == null) { trackingInfo = new TrackingInfo(); mTrackedViews.put(view, trackingInfo); scheduleVisibilityCheck(); } trackingInfo.mMinViewablePercent = minPercentageViewed; trackingInfo.mAccessOrder = mAccessCounter; mAccessCounter++; if (mAccessCounter % NUM_ACCESSES_BEFORE_TRIMMING == 0) { trimTrackedViews(mAccessCounter - NUM_ACCESSES_BEFORE_TRIMMING); } } VisibilityTracker(@NonNull final Context context); @VisibleForTesting  VisibilityTracker(@NonNull final Context context,
            @NonNull final Map<View, TrackingInfo> trackedViews,
            @NonNull final VisibilityChecker visibilityChecker,
            @NonNull final Handler visibilityHandler);  }
VisibilityTracker { void addView(@NonNull final View view, final int minPercentageViewed) { TrackingInfo trackingInfo = mTrackedViews.get(view); if (trackingInfo == null) { trackingInfo = new TrackingInfo(); mTrackedViews.put(view, trackingInfo); scheduleVisibilityCheck(); } trackingInfo.mMinViewablePercent = minPercentageViewed; trackingInfo.mAccessOrder = mAccessCounter; mAccessCounter++; if (mAccessCounter % NUM_ACCESSES_BEFORE_TRIMMING == 0) { trimTrackedViews(mAccessCounter - NUM_ACCESSES_BEFORE_TRIMMING); } } VisibilityTracker(@NonNull final Context context); @VisibleForTesting  VisibilityTracker(@NonNull final Context context,
            @NonNull final Map<View, TrackingInfo> trackedViews,
            @NonNull final VisibilityChecker visibilityChecker,
            @NonNull final Handler visibilityHandler);   }