@Test public void testGetLibraryRoot() throws InterruptedException { prepareLooper(); final Bundle param = new Bundle(); param.putString(TAG, TAG); final CountDownLatch latch = new CountDownLatch(1); final BrowserCallback callback = new BrowserCallback() { @Override public void onGetLibraryRootDone(MediaBrowser2 browser, Bundle rootHints, String rootMediaId, Bundle rootExtra) { assertTrue(TestUtils.equals(param, rootHints)); assertEquals(ROOT_ID, rootMediaId); assertTrue(TestUtils.contains(rootExtra, EXTRAS)); latch.countDown(); } }; final SessionToken2 token = MockMediaLibraryService2.getToken(mContext); MediaBrowser2 browser = (MediaBrowser2) createController(token, true, callback); browser.getLibraryRoot(param); assertTrue(latch.await(WAIT_TIME_MS, TimeUnit.MILLISECONDS)); }
public void getLibraryRoot(@Nullable final Bundle extras) { final MediaBrowserCompat browser = getBrowserCompat(extras); if (browser != null) { getCallbackExecutor().execute(new Runnable() { @Override public void run() { getCallback().onGetLibraryRootDone(MediaBrowser2.this, extras, browser.getRoot(), browser.getExtras()); } }); } else { getCallbackExecutor().execute(new Runnable() { @Override public void run() { MediaBrowserCompat newBrowser = new MediaBrowserCompat(getContext(), getSessionToken().getComponentName(), new GetLibraryRootCallback(extras), extras); synchronized (mLock) { mBrowserCompats.put(extras, newBrowser); } newBrowser.connect(); } }); } }
MediaBrowser2 extends MediaController2 { public void getLibraryRoot(@Nullable final Bundle extras) { final MediaBrowserCompat browser = getBrowserCompat(extras); if (browser != null) { getCallbackExecutor().execute(new Runnable() { @Override public void run() { getCallback().onGetLibraryRootDone(MediaBrowser2.this, extras, browser.getRoot(), browser.getExtras()); } }); } else { getCallbackExecutor().execute(new Runnable() { @Override public void run() { MediaBrowserCompat newBrowser = new MediaBrowserCompat(getContext(), getSessionToken().getComponentName(), new GetLibraryRootCallback(extras), extras); synchronized (mLock) { mBrowserCompats.put(extras, newBrowser); } newBrowser.connect(); } }); } } }
MediaBrowser2 extends MediaController2 { public void getLibraryRoot(@Nullable final Bundle extras) { final MediaBrowserCompat browser = getBrowserCompat(extras); if (browser != null) { getCallbackExecutor().execute(new Runnable() { @Override public void run() { getCallback().onGetLibraryRootDone(MediaBrowser2.this, extras, browser.getRoot(), browser.getExtras()); } }); } else { getCallbackExecutor().execute(new Runnable() { @Override public void run() { MediaBrowserCompat newBrowser = new MediaBrowserCompat(getContext(), getSessionToken().getComponentName(), new GetLibraryRootCallback(extras), extras); synchronized (mLock) { mBrowserCompats.put(extras, newBrowser); } newBrowser.connect(); } }); } } MediaBrowser2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull /*@CallbackExecutor*/ Executor executor, @NonNull BrowserCallback callback); }
MediaBrowser2 extends MediaController2 { public void getLibraryRoot(@Nullable final Bundle extras) { final MediaBrowserCompat browser = getBrowserCompat(extras); if (browser != null) { getCallbackExecutor().execute(new Runnable() { @Override public void run() { getCallback().onGetLibraryRootDone(MediaBrowser2.this, extras, browser.getRoot(), browser.getExtras()); } }); } else { getCallbackExecutor().execute(new Runnable() { @Override public void run() { MediaBrowserCompat newBrowser = new MediaBrowserCompat(getContext(), getSessionToken().getComponentName(), new GetLibraryRootCallback(extras), extras); synchronized (mLock) { mBrowserCompats.put(extras, newBrowser); } newBrowser.connect(); } }); } } 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 getLibraryRoot(@Nullable final Bundle extras) { final MediaBrowserCompat browser = getBrowserCompat(extras); if (browser != null) { getCallbackExecutor().execute(new Runnable() { @Override public void run() { getCallback().onGetLibraryRootDone(MediaBrowser2.this, extras, browser.getRoot(), browser.getExtras()); } }); } else { getCallbackExecutor().execute(new Runnable() { @Override public void run() { MediaBrowserCompat newBrowser = new MediaBrowserCompat(getContext(), getSessionToken().getComponentName(), new GetLibraryRootCallback(extras), extras); synchronized (mLock) { mBrowserCompats.put(extras, newBrowser); } newBrowser.connect(); } }); } } 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; }