code style fixes - naming, indentation, etc.
This commit is contained in:
parent
418d4fa4d4
commit
69c0022472
@ -97,11 +97,11 @@
|
|||||||
android:summary="@string/pref_queueAddToFront_sum"
|
android:summary="@string/pref_queueAddToFront_sum"
|
||||||
android:title="@string/pref_queueAddToFront_title"/>
|
android:title="@string/pref_queueAddToFront_title"/>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:key="prefQueueKeepInProgressAtFront"
|
android:key="prefQueueKeepInProgressAtFront"
|
||||||
android:summary="@string/pref_queueKeepInProgressAtFront_sum"
|
android:summary="@string/pref_queueKeepInProgressAtFront_sum"
|
||||||
android:title="@string/pref_queueKeepInProgressAtFront_title"/>
|
android:title="@string/pref_queueKeepInProgressAtFront_title"/>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
@ -38,8 +38,8 @@ class ItemEnqueuePositionCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final @NonNull
|
@NonNull
|
||||||
Options options;
|
private final Options options;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
DownloadStateProvider downloadStateProvider = DownloadRequester.getInstance();
|
DownloadStateProvider downloadStateProvider = DownloadRequester.getInstance();
|
||||||
@ -66,18 +66,18 @@ class ItemEnqueuePositionCalculator {
|
|||||||
curQueue.get(0).getMedia() != null &&
|
curQueue.get(0).getMedia() != null &&
|
||||||
curQueue.get(0).getMedia().isInProgress()) {
|
curQueue.get(0).getMedia().isInProgress()) {
|
||||||
// leave the front in progress item at the front
|
// leave the front in progress item at the front
|
||||||
return getPositionOf1stNonDownloadingItem(positionAmongToAdd + 1, curQueue);
|
return getPositionOfFirstNonDownloadingItem(positionAmongToAdd + 1, curQueue);
|
||||||
} else { // typical case
|
} else { // typical case
|
||||||
// return NOT 0, so that when a list of items are inserted, the items inserted
|
// return NOT 0, so that when a list of items are inserted, the items inserted
|
||||||
// keep the same order. Returning 0 will reverse the order
|
// keep the same order. Returning 0 will reverse the order
|
||||||
return getPositionOf1stNonDownloadingItem(positionAmongToAdd, curQueue);
|
return getPositionOfFirstNonDownloadingItem(positionAmongToAdd, curQueue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return curQueue.size();
|
return curQueue.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPositionOf1stNonDownloadingItem(int startPosition, List<FeedItem> curQueue) {
|
private int getPositionOfFirstNonDownloadingItem(int startPosition, List<FeedItem> curQueue) {
|
||||||
final int curQueueSize = curQueue.size();
|
final int curQueueSize = curQueue.size();
|
||||||
for (int i = startPosition; i < curQueueSize; i++) {
|
for (int i = startPosition; i < curQueueSize; i++) {
|
||||||
if (!isItemAtPositionDownloading(i, curQueue)) {
|
if (!isItemAtPositionDownloading(i, curQueue)) {
|
||||||
@ -95,9 +95,9 @@ class ItemEnqueuePositionCalculator {
|
|||||||
curItem = null;
|
curItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curItem != null &&
|
if (curItem != null
|
||||||
curItem.getMedia() != null &&
|
&& curItem.getMedia() != null
|
||||||
downloadStateProvider.isDownloadingFile(curItem.getMedia())) {
|
&& downloadStateProvider.isDownloadingFile(curItem.getMedia())) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,7 +26,7 @@ import static org.mockito.Mockito.stub;
|
|||||||
public class ItemEnqueuePositionCalculatorTest {
|
public class ItemEnqueuePositionCalculatorTest {
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public static class IEPCBasicTest {
|
public static class BasicTest {
|
||||||
@Parameters(name = "{index}: case<{0}>, expected:{1}")
|
@Parameters(name = "{index}: case<{0}>, expected:{1}")
|
||||||
public static Iterable<Object[]> data() {
|
public static Iterable<Object[]> data() {
|
||||||
Options optDefault = new Options();
|
Options optDefault = new Options();
|
||||||
@ -90,7 +90,7 @@ public class ItemEnqueuePositionCalculatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public static class IEPCKeepInProgressAtFrontTest extends IEPCBasicTest {
|
public static class KeepInProgressAtFrontTest extends BasicTest {
|
||||||
@Parameters(name = "{index}: case<{0}>, expected:{1}")
|
@Parameters(name = "{index}: case<{0}>, expected:{1}")
|
||||||
public static Iterable<Object[]> data() {
|
public static Iterable<Object[]> data() {
|
||||||
Options optKeepInProgressAtFront =
|
Options optKeepInProgressAtFront =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user