@Test public void testGetUserNoListener() { client.getUser("username", null); verify(TestRestServiceFactory.hnRestService, never()).userRx(any()); }
@Override public void getUser(String username, final ResponseListener<User> listener) { if (listener == null) { return; } mRestService.userRx(username) .map(userItem -> { if (userItem != null) { userItem.setSubmittedItems(toItems(userItem.getSubmitted())); } return userItem; }) .subscribeOn(mIoScheduler) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); }
HackerNewsClient implements ItemManager, UserManager { @Override public void getUser(String username, final ResponseListener<User> listener) { if (listener == null) { return; } mRestService.userRx(username) .map(userItem -> { if (userItem != null) { userItem.setSubmittedItems(toItems(userItem.getSubmitted())); } return userItem; }) .subscribeOn(mIoScheduler) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } }
HackerNewsClient implements ItemManager, UserManager { @Override public void getUser(String username, final ResponseListener<User> listener) { if (listener == null) { return; } mRestService.userRx(username) .map(userItem -> { if (userItem != null) { userItem.setSubmittedItems(toItems(userItem.getSubmitted())); } return userItem; }) .subscribeOn(mIoScheduler) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } @Inject  HackerNewsClient(RestServiceFactory factory,
                            SessionManager sessionManager,
                            FavoriteManager favoriteManager); }
HackerNewsClient implements ItemManager, UserManager { @Override public void getUser(String username, final ResponseListener<User> listener) { if (listener == null) { return; } mRestService.userRx(username) .map(userItem -> { if (userItem != null) { userItem.setSubmittedItems(toItems(userItem.getSubmitted())); } return userItem; }) .subscribeOn(mIoScheduler) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } @Inject  HackerNewsClient(RestServiceFactory factory,
                            SessionManager sessionManager,
                            FavoriteManager favoriteManager); @Override void getStories(@FetchMode String filter, @CacheMode int cacheMode,
                           final ResponseListener<Item[]> listener); @Override void getItem(final String itemId, @CacheMode int cacheMode, ResponseListener<Item> listener); @Override Item[] getStories(String filter, @CacheMode int cacheMode); @Override Item getItem(String itemId, @CacheMode int cacheMode); @Override void getUser(String username, final ResponseListener<User> listener); }
HackerNewsClient implements ItemManager, UserManager { @Override public void getUser(String username, final ResponseListener<User> listener) { if (listener == null) { return; } mRestService.userRx(username) .map(userItem -> { if (userItem != null) { userItem.setSubmittedItems(toItems(userItem.getSubmitted())); } return userItem; }) .subscribeOn(mIoScheduler) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } @Inject  HackerNewsClient(RestServiceFactory factory,
                            SessionManager sessionManager,
                            FavoriteManager favoriteManager); @Override void getStories(@FetchMode String filter, @CacheMode int cacheMode,
                           final ResponseListener<Item[]> listener); @Override void getItem(final String itemId, @CacheMode int cacheMode, ResponseListener<Item> listener); @Override Item[] getStories(String filter, @CacheMode int cacheMode); @Override Item getItem(String itemId, @CacheMode int cacheMode); @Override void getUser(String username, final ResponseListener<User> listener); static final String HOST; static final String BASE_WEB_URL; static final String WEB_ITEM_PATH; }