@Test public void getUntriggeredTrackersBefore_withTriggeredTrackers_shouldNotReturnTriggered() throws Exception { VastVideoConfiguration vastVideoConfiguration = new VastVideoConfiguration(); vastVideoConfiguration.setDiskMediaFileUrl("disk_video_path"); vastVideoConfiguration.addFractionalTrackers(Arrays.asList(new VastFractionalProgressTracker("first", 0.25f), new VastFractionalProgressTracker("second", 0.5f), new VastFractionalProgressTracker("third", 0.75f))); vastVideoConfiguration.addAbsoluteTrackers(Arrays.asList(new VastAbsoluteProgressTracker("5secs", 5000), new VastAbsoluteProgressTracker("10secs", 10000))); bundle.putSerializable(VAST_VIDEO_CONFIGURATION, vastVideoConfiguration); initializeSubject(); spyOnVideoView(); setVideoViewParams(11000, 11000); final List<VastTracker> untriggeredTrackers = subject.getUntriggeredTrackersBefore(11000, 11000); assertThat(untriggeredTrackers).hasSize(5); untriggeredTrackers.get(0).setTracked(); final List<VastTracker> secondTrackersList = subject.getUntriggeredTrackersBefore(11000, 11000); assertThat(secondTrackersList).hasSize(4); }
@NonNull List<VastTracker> getUntriggeredTrackersBefore(int currentPositionMillis, int videoLengthMillis) { if (Preconditions.NoThrow.checkArgument(videoLengthMillis > 0)) { float progressFraction = currentPositionMillis / (float) (videoLengthMillis); List<VastTracker> untriggeredTrackers = new ArrayList<VastTracker>(); final ArrayList<VastAbsoluteProgressTracker> absoluteTrackers = mVastVideoConfiguration.getAbsoluteTrackers(); VastAbsoluteProgressTracker absoluteTest = new VastAbsoluteProgressTracker("", currentPositionMillis); int absoluteTrackerCount = absoluteTrackers.size(); for (int i = 0; i < absoluteTrackerCount; i++) { VastAbsoluteProgressTracker tracker = absoluteTrackers.get(i); if (tracker.compareTo(absoluteTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } final ArrayList<VastFractionalProgressTracker> fractionalTrackers = mVastVideoConfiguration.getFractionalTrackers(); final VastFractionalProgressTracker fractionalTest = new VastFractionalProgressTracker("", progressFraction); int fractionalTrackerCount = fractionalTrackers.size(); for (int i = 0; i < fractionalTrackerCount; i++) { VastFractionalProgressTracker tracker = fractionalTrackers.get(i); if (tracker.compareTo(fractionalTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } return untriggeredTrackers; } else { return Collections.emptyList(); } }
VastVideoViewController extends BaseVideoViewController implements DownloadTask.DownloadTaskListener { @NonNull List<VastTracker> getUntriggeredTrackersBefore(int currentPositionMillis, int videoLengthMillis) { if (Preconditions.NoThrow.checkArgument(videoLengthMillis > 0)) { float progressFraction = currentPositionMillis / (float) (videoLengthMillis); List<VastTracker> untriggeredTrackers = new ArrayList<VastTracker>(); final ArrayList<VastAbsoluteProgressTracker> absoluteTrackers = mVastVideoConfiguration.getAbsoluteTrackers(); VastAbsoluteProgressTracker absoluteTest = new VastAbsoluteProgressTracker("", currentPositionMillis); int absoluteTrackerCount = absoluteTrackers.size(); for (int i = 0; i < absoluteTrackerCount; i++) { VastAbsoluteProgressTracker tracker = absoluteTrackers.get(i); if (tracker.compareTo(absoluteTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } final ArrayList<VastFractionalProgressTracker> fractionalTrackers = mVastVideoConfiguration.getFractionalTrackers(); final VastFractionalProgressTracker fractionalTest = new VastFractionalProgressTracker("", progressFraction); int fractionalTrackerCount = fractionalTrackers.size(); for (int i = 0; i < fractionalTrackerCount; i++) { VastFractionalProgressTracker tracker = fractionalTrackers.get(i); if (tracker.compareTo(fractionalTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } return untriggeredTrackers; } else { return Collections.emptyList(); } } }
VastVideoViewController extends BaseVideoViewController implements DownloadTask.DownloadTaskListener { @NonNull List<VastTracker> getUntriggeredTrackersBefore(int currentPositionMillis, int videoLengthMillis) { if (Preconditions.NoThrow.checkArgument(videoLengthMillis > 0)) { float progressFraction = currentPositionMillis / (float) (videoLengthMillis); List<VastTracker> untriggeredTrackers = new ArrayList<VastTracker>(); final ArrayList<VastAbsoluteProgressTracker> absoluteTrackers = mVastVideoConfiguration.getAbsoluteTrackers(); VastAbsoluteProgressTracker absoluteTest = new VastAbsoluteProgressTracker("", currentPositionMillis); int absoluteTrackerCount = absoluteTrackers.size(); for (int i = 0; i < absoluteTrackerCount; i++) { VastAbsoluteProgressTracker tracker = absoluteTrackers.get(i); if (tracker.compareTo(absoluteTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } final ArrayList<VastFractionalProgressTracker> fractionalTrackers = mVastVideoConfiguration.getFractionalTrackers(); final VastFractionalProgressTracker fractionalTest = new VastFractionalProgressTracker("", progressFraction); int fractionalTrackerCount = fractionalTrackers.size(); for (int i = 0; i < fractionalTrackerCount; i++) { VastFractionalProgressTracker tracker = fractionalTrackers.get(i); if (tracker.compareTo(fractionalTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } return untriggeredTrackers; } else { return Collections.emptyList(); } } VastVideoViewController(final Context context,
            final Bundle bundle,
            final long broadcastIdentifier,
            final BaseVideoViewControllerListener baseVideoViewControllerListener); }
VastVideoViewController extends BaseVideoViewController implements DownloadTask.DownloadTaskListener { @NonNull List<VastTracker> getUntriggeredTrackersBefore(int currentPositionMillis, int videoLengthMillis) { if (Preconditions.NoThrow.checkArgument(videoLengthMillis > 0)) { float progressFraction = currentPositionMillis / (float) (videoLengthMillis); List<VastTracker> untriggeredTrackers = new ArrayList<VastTracker>(); final ArrayList<VastAbsoluteProgressTracker> absoluteTrackers = mVastVideoConfiguration.getAbsoluteTrackers(); VastAbsoluteProgressTracker absoluteTest = new VastAbsoluteProgressTracker("", currentPositionMillis); int absoluteTrackerCount = absoluteTrackers.size(); for (int i = 0; i < absoluteTrackerCount; i++) { VastAbsoluteProgressTracker tracker = absoluteTrackers.get(i); if (tracker.compareTo(absoluteTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } final ArrayList<VastFractionalProgressTracker> fractionalTrackers = mVastVideoConfiguration.getFractionalTrackers(); final VastFractionalProgressTracker fractionalTest = new VastFractionalProgressTracker("", progressFraction); int fractionalTrackerCount = fractionalTrackers.size(); for (int i = 0; i < fractionalTrackerCount; i++) { VastFractionalProgressTracker tracker = fractionalTrackers.get(i); if (tracker.compareTo(fractionalTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } return untriggeredTrackers; } else { return Collections.emptyList(); } } VastVideoViewController(final Context context,
            final Bundle bundle,
            final long broadcastIdentifier,
            final BaseVideoViewControllerListener baseVideoViewControllerListener); @Override boolean backButtonEnabled(); @Override void onComplete(String url, DownloadResponse downloadResponse); }
VastVideoViewController extends BaseVideoViewController implements DownloadTask.DownloadTaskListener { @NonNull List<VastTracker> getUntriggeredTrackersBefore(int currentPositionMillis, int videoLengthMillis) { if (Preconditions.NoThrow.checkArgument(videoLengthMillis > 0)) { float progressFraction = currentPositionMillis / (float) (videoLengthMillis); List<VastTracker> untriggeredTrackers = new ArrayList<VastTracker>(); final ArrayList<VastAbsoluteProgressTracker> absoluteTrackers = mVastVideoConfiguration.getAbsoluteTrackers(); VastAbsoluteProgressTracker absoluteTest = new VastAbsoluteProgressTracker("", currentPositionMillis); int absoluteTrackerCount = absoluteTrackers.size(); for (int i = 0; i < absoluteTrackerCount; i++) { VastAbsoluteProgressTracker tracker = absoluteTrackers.get(i); if (tracker.compareTo(absoluteTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } final ArrayList<VastFractionalProgressTracker> fractionalTrackers = mVastVideoConfiguration.getFractionalTrackers(); final VastFractionalProgressTracker fractionalTest = new VastFractionalProgressTracker("", progressFraction); int fractionalTrackerCount = fractionalTrackers.size(); for (int i = 0; i < fractionalTrackerCount; i++) { VastFractionalProgressTracker tracker = fractionalTrackers.get(i); if (tracker.compareTo(fractionalTest) > 0) { break; } if (!tracker.isTracked()) { untriggeredTrackers.add(tracker); } } return untriggeredTrackers; } else { return Collections.emptyList(); } } VastVideoViewController(final Context context,
            final Bundle bundle,
            final long broadcastIdentifier,
            final BaseVideoViewControllerListener baseVideoViewControllerListener); @Override boolean backButtonEnabled(); @Override void onComplete(String url, DownloadResponse downloadResponse);  }