@Test public void onTextChanged() { when(mFileManager.searchCity(cityName)).thenReturn(Observable.just(CITIES.get(0))); mPresenter.textChanged(cityName); }
@Override public void textChanged(String text) { EspressoIdlingResource.increment(); mSubscriptions.clear(); mView.setCityListVisible(false); mView.clearCities(); mView.setProgressBarVisible(true); Subscription subscription = mFileManager.searchCity(text) .subscribeOn(mBackgroundScheduler) .observeOn(mMainScheduler) .subscribe( city -> { mView.setImageViewVisible(false); mView.setSearchStateVisible(false); mView.setCityListVisible(true); mView.addCityToList(city); }, throwable -> { EspressoIdlingResource.decrement(); mView.showCouldNotFindCity(); mView.setSearchStateVisible(true); mView.setImageViewVisible(true); mView.setProgressBarVisible(false); mView.setCityListVisible(false); throwable.printStackTrace(); }, () -> { EspressoIdlingResource.decrement(); mView.setProgressBarVisible(false); } ); mSubscriptions.add(subscription); }
AddCityPresenter implements AddCityContract.Presenter { @Override public void textChanged(String text) { EspressoIdlingResource.increment(); mSubscriptions.clear(); mView.setCityListVisible(false); mView.clearCities(); mView.setProgressBarVisible(true); Subscription subscription = mFileManager.searchCity(text) .subscribeOn(mBackgroundScheduler) .observeOn(mMainScheduler) .subscribe( city -> { mView.setImageViewVisible(false); mView.setSearchStateVisible(false); mView.setCityListVisible(true); mView.addCityToList(city); }, throwable -> { EspressoIdlingResource.decrement(); mView.showCouldNotFindCity(); mView.setSearchStateVisible(true); mView.setImageViewVisible(true); mView.setProgressBarVisible(false); mView.setCityListVisible(false); throwable.printStackTrace(); }, () -> { EspressoIdlingResource.decrement(); mView.setProgressBarVisible(false); } ); mSubscriptions.add(subscription); } }
AddCityPresenter implements AddCityContract.Presenter { @Override public void textChanged(String text) { EspressoIdlingResource.increment(); mSubscriptions.clear(); mView.setCityListVisible(false); mView.clearCities(); mView.setProgressBarVisible(true); Subscription subscription = mFileManager.searchCity(text) .subscribeOn(mBackgroundScheduler) .observeOn(mMainScheduler) .subscribe( city -> { mView.setImageViewVisible(false); mView.setSearchStateVisible(false); mView.setCityListVisible(true); mView.addCityToList(city); }, throwable -> { EspressoIdlingResource.decrement(); mView.showCouldNotFindCity(); mView.setSearchStateVisible(true); mView.setImageViewVisible(true); mView.setProgressBarVisible(false); mView.setCityListVisible(false); throwable.printStackTrace(); }, () -> { EspressoIdlingResource.decrement(); mView.setProgressBarVisible(false); } ); mSubscriptions.add(subscription); } AddCityPresenter(AddCityContract.View view, RepositoryDataSource repository, FileSource fileManager,
                            Scheduler background, Scheduler main); }
AddCityPresenter implements AddCityContract.Presenter { @Override public void textChanged(String text) { EspressoIdlingResource.increment(); mSubscriptions.clear(); mView.setCityListVisible(false); mView.clearCities(); mView.setProgressBarVisible(true); Subscription subscription = mFileManager.searchCity(text) .subscribeOn(mBackgroundScheduler) .observeOn(mMainScheduler) .subscribe( city -> { mView.setImageViewVisible(false); mView.setSearchStateVisible(false); mView.setCityListVisible(true); mView.addCityToList(city); }, throwable -> { EspressoIdlingResource.decrement(); mView.showCouldNotFindCity(); mView.setSearchStateVisible(true); mView.setImageViewVisible(true); mView.setProgressBarVisible(false); mView.setCityListVisible(false); throwable.printStackTrace(); }, () -> { EspressoIdlingResource.decrement(); mView.setProgressBarVisible(false); } ); mSubscriptions.add(subscription); } AddCityPresenter(AddCityContract.View view, RepositoryDataSource repository, FileSource fileManager,
                            Scheduler background, Scheduler main); @Override void subscribe(); @Override void unsubscribe(); @Override void onItemClick(OrmCity city); @Override void textChanged(String text); }
AddCityPresenter implements AddCityContract.Presenter { @Override public void textChanged(String text) { EspressoIdlingResource.increment(); mSubscriptions.clear(); mView.setCityListVisible(false); mView.clearCities(); mView.setProgressBarVisible(true); Subscription subscription = mFileManager.searchCity(text) .subscribeOn(mBackgroundScheduler) .observeOn(mMainScheduler) .subscribe( city -> { mView.setImageViewVisible(false); mView.setSearchStateVisible(false); mView.setCityListVisible(true); mView.addCityToList(city); }, throwable -> { EspressoIdlingResource.decrement(); mView.showCouldNotFindCity(); mView.setSearchStateVisible(true); mView.setImageViewVisible(true); mView.setProgressBarVisible(false); mView.setCityListVisible(false); throwable.printStackTrace(); }, () -> { EspressoIdlingResource.decrement(); mView.setProgressBarVisible(false); } ); mSubscriptions.add(subscription); } AddCityPresenter(AddCityContract.View view, RepositoryDataSource repository, FileSource fileManager,
                            Scheduler background, Scheduler main); @Override void subscribe(); @Override void unsubscribe(); @Override void onItemClick(OrmCity city); @Override void textChanged(String text);  }