@Test public void testGetChildrenEmptyResult() throws InterruptedException { prepareLooper(); final String parentId = MockMediaLibraryService2.PARENT_ID_NO_CHILDREN; final CountDownLatch latch = new CountDownLatch(1); final BrowserCallback callback = new BrowserCallback() { @Override public void onGetChildrenDone(MediaBrowser2 browser, String parentIdOut, int pageOut, int pageSizeOut, List<MediaItem2> result, Bundle extrasOut) { assertNotNull(result); assertEquals(0, result.size()); latch.countDown(); } }; final SessionToken2 token = MockMediaLibraryService2.getToken(mContext); MediaBrowser2 browser = (MediaBrowser2) createController(token, true, callback); browser.getChildren(parentId, 1, 1, null); assertTrue(latch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); }
public void getChildren(@NonNull String parentId, int page, int pageSize, @Nullable Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } if (page < 1 || pageSize < 1) { throw new IllegalArgumentException("Neither page nor pageSize should be less than 1"); } MediaBrowserCompat browser = getBrowserCompat(); if (browser == null) { return; } Bundle options = MediaUtils2.createBundle(extras); options.putInt(MediaBrowserCompat.EXTRA_PAGE, page); options.putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, pageSize); browser.subscribe(parentId, options, new GetChildrenCallback(parentId, page, pageSize)); }
MediaBrowser2 extends MediaController2 { public void getChildren(@NonNull String parentId, int page, int pageSize, @Nullable Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } if (page < 1 || pageSize < 1) { throw new IllegalArgumentException("Neither page nor pageSize should be less than 1"); } MediaBrowserCompat browser = getBrowserCompat(); if (browser == null) { return; } Bundle options = MediaUtils2.createBundle(extras); options.putInt(MediaBrowserCompat.EXTRA_PAGE, page); options.putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, pageSize); browser.subscribe(parentId, options, new GetChildrenCallback(parentId, page, pageSize)); } }
MediaBrowser2 extends MediaController2 { public void getChildren(@NonNull String parentId, int page, int pageSize, @Nullable Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } if (page < 1 || pageSize < 1) { throw new IllegalArgumentException("Neither page nor pageSize should be less than 1"); } MediaBrowserCompat browser = getBrowserCompat(); if (browser == null) { return; } Bundle options = MediaUtils2.createBundle(extras); options.putInt(MediaBrowserCompat.EXTRA_PAGE, page); options.putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, pageSize); browser.subscribe(parentId, options, new GetChildrenCallback(parentId, page, pageSize)); } MediaBrowser2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull /*@CallbackExecutor*/ Executor executor, @NonNull BrowserCallback callback); }
MediaBrowser2 extends MediaController2 { public void getChildren(@NonNull String parentId, int page, int pageSize, @Nullable Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } if (page < 1 || pageSize < 1) { throw new IllegalArgumentException("Neither page nor pageSize should be less than 1"); } MediaBrowserCompat browser = getBrowserCompat(); if (browser == null) { return; } Bundle options = MediaUtils2.createBundle(extras); options.putInt(MediaBrowserCompat.EXTRA_PAGE, page); options.putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, pageSize); browser.subscribe(parentId, options, new GetChildrenCallback(parentId, page, pageSize)); } MediaBrowser2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull /*@CallbackExecutor*/ Executor executor, @NonNull BrowserCallback callback); @Override void close(); void getLibraryRoot(@Nullable final Bundle extras); void subscribe(@NonNull String parentId, @Nullable Bundle extras); void unsubscribe(@NonNull String parentId); void getChildren(@NonNull String parentId, int page, int pageSize,
            @Nullable Bundle extras); void getItem(@NonNull final String mediaId); void search(@NonNull String query, @Nullable Bundle extras); void getSearchResult(final @NonNull String query, final int page, final int pageSize,
            final @Nullable Bundle extras); }
MediaBrowser2 extends MediaController2 { public void getChildren(@NonNull String parentId, int page, int pageSize, @Nullable Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } if (page < 1 || pageSize < 1) { throw new IllegalArgumentException("Neither page nor pageSize should be less than 1"); } MediaBrowserCompat browser = getBrowserCompat(); if (browser == null) { return; } Bundle options = MediaUtils2.createBundle(extras); options.putInt(MediaBrowserCompat.EXTRA_PAGE, page); options.putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, pageSize); browser.subscribe(parentId, options, new GetChildrenCallback(parentId, page, pageSize)); } MediaBrowser2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull /*@CallbackExecutor*/ Executor executor, @NonNull BrowserCallback callback); @Override void close(); void getLibraryRoot(@Nullable final Bundle extras); void subscribe(@NonNull String parentId, @Nullable Bundle extras); void unsubscribe(@NonNull String parentId); void getChildren(@NonNull String parentId, int page, int pageSize,
            @Nullable Bundle extras); void getItem(@NonNull final String mediaId); void search(@NonNull String query, @Nullable Bundle extras); void getSearchResult(final @NonNull String query, final int page, final int pageSize,
            final @Nullable Bundle extras); @RestrictTo(LIBRARY_GROUP)
    static final String EXTRA_ITEM_COUNT; @RestrictTo(LIBRARY_GROUP)
    static final String MEDIA_BROWSER2_SUBSCRIBE; }