Merge "MediaBrowser: Make EXTRA_PAGE zero-based" into nyc-dev

am: 16bbf7d

* commit '16bbf7d8eddf4778b415e8871ab04885250dbd94':
  MediaBrowser: Make EXTRA_PAGE zero-based

Change-Id: I75f1786e6a2acb2a06e11f1af7856a7344593104
This commit is contained in:
Sungsoo Lim
2016-04-04 07:06:15 +00:00
committed by android-build-merger
3 changed files with 5 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ public final class MediaBrowser {
/**
* Used as an int extra field to denote the page number to subscribe.
* The value of {@code EXTRA_PAGE} should be greater than or equal to 1.
* The value of {@code EXTRA_PAGE} should be greater than or equal to 0.
*
* @see #EXTRA_PAGE_SIZE
*/

View File

@@ -50,7 +50,7 @@ public class MediaBrowserUtils {
startIndex1 = 0;
endIndex1 = Integer.MAX_VALUE;
} else {
startIndex1 = pageSize1 * (page1 - 1);
startIndex1 = pageSize1 * page1;
endIndex1 = startIndex1 + pageSize1 - 1;
}
@@ -58,7 +58,7 @@ public class MediaBrowserUtils {
startIndex2 = 0;
endIndex2 = Integer.MAX_VALUE;
} else {
startIndex2 = pageSize2 * (page2 - 1);
startIndex2 = pageSize2 * page2;
endIndex2 = startIndex2 + pageSize2 - 1;
}

View File

@@ -657,9 +657,9 @@ public abstract class MediaBrowserService extends Service {
if (page == -1 && pageSize == -1) {
return list;
}
int fromIndex = pageSize * (page - 1);
int fromIndex = pageSize * page;
int toIndex = fromIndex + pageSize;
if (page < 1 || pageSize < 1 || fromIndex >= list.size()) {
if (page < 0 || pageSize < 1 || fromIndex >= list.size()) {
return Collections.EMPTY_LIST;
}
if (toIndex > list.size()) {