code style / comment tweak per review

This commit is contained in:
orionlee 2019-11-05 10:14:07 -08:00
parent b80973bc30
commit 6e019f72de
2 changed files with 4 additions and 10 deletions

View File

@ -40,8 +40,10 @@ class ItemEnqueuePositionCalculator {
case BACK: case BACK:
return curQueue.size(); return curQueue.size();
case FRONT: case FRONT:
// return NOT 0, so that when a list of items are inserted, the items inserted // Return not necessarily 0, so that when a list of items are downloaded and enqueued
// keep the same order. Returning 0 will reverse the order // in succession of calls (e.g., users manually tapping download one by one),
// the items enqueued are kept the same order.
// Simply returning 0 will reverse the order.
return getPositionOfFirstNonDownloadingItem(0, curQueue); return getPositionOfFirstNonDownloadingItem(0, curQueue);
case AFTER_CURRENTLY_PLAYING: case AFTER_CURRENTLY_PLAYING:
int currentlyPlayingPosition = getCurrentlyPlayingPosition(curQueue, currentPlaying); int currentlyPlayingPosition = getCurrentlyPlayingPosition(curQueue, currentPlaying);

View File

@ -189,17 +189,13 @@ public class ItemEnqueuePositionCalculatorTest {
// A shallow copy, as the test code will manipulate the queue // A shallow copy, as the test code will manipulate the queue
List<FeedItem> queue = new ArrayList<>(queueInitial); List<FeedItem> queue = new ArrayList<>(queueInitial);
// Test body // Test body
Playable currentlyPlaying = getCurrentlyPlaying(idCurrentlyPlaying); Playable currentlyPlaying = getCurrentlyPlaying(idCurrentlyPlaying);
// User clicks download on feed item 101 // User clicks download on feed item 101
FeedItem tFI101 = setAsDownloading(101, stubDownloadStateProvider); FeedItem tFI101 = setAsDownloading(101, stubDownloadStateProvider);
doAddToQueueAndAssertResult(message + " (1st download)", doAddToQueueAndAssertResult(message + " (1st download)",
calculator, tFI101, queue, currentlyPlaying, calculator, tFI101, queue, currentlyPlaying,
idsExpectedAfter101); idsExpectedAfter101);
// Then user clicks download on feed item 102 // Then user clicks download on feed item 102
FeedItem tFI102 = setAsDownloading(102, stubDownloadStateProvider); FeedItem tFI102 = setAsDownloading(102, stubDownloadStateProvider);
doAddToQueueAndAssertResult(message + " (2nd download, it should preserve order of download)", doAddToQueueAndAssertResult(message + " (2nd download, it should preserve order of download)",
@ -225,10 +221,6 @@ public class ItemEnqueuePositionCalculatorTest {
} }
// Common helpers:
// - common queue (of items) for tests
// - construct FeedItems for tests
static void doAddToQueueAndAssertResult(String message, static void doAddToQueueAndAssertResult(String message,
ItemEnqueuePositionCalculator calculator, ItemEnqueuePositionCalculator calculator,
FeedItem itemToAdd, FeedItem itemToAdd,