Source:
private void doTitlePrefixSearch(final String searchTerm, boolean force) { cancelSearchTask(); final long startTime = System.nanoTime(); updateProgressBar(true); disposables.add(Observable.timer(force ? 0 : DELAY_MILLIS, TimeUnit.MILLISECONDS).flatMap(timer -> Observable.zip(ServiceFactory.get(WikiSite.forLanguageCode(getSearchLanguageCode())).prefixSearch(searchTerm, BATCH_SIZE, searchTerm), Observable.fromCallable(() -> ReadingListDbHelper.instance().findPageForSearchQueryInAnyList(currentSearchTerm)), Observable.fromCallable(() -> HistoryDbHelper.INSTANCE.findHistoryItem(currentSearchTerm)), (searchResponse, readingListSearchResults, historySearchResults) -> { SearchResults searchResults; if (searchResponse != null && searchResponse.query() != null && searchResponse.query().pages() != null) { searchResults = new SearchResults(searchResponse.query().pages(), WikiSite.forLanguageCode(getSearchLanguageCode()), searchResponse.continuation(), searchResponse.suggestion()); } else { searchResults = new SearchResults(); } handleSuggestion(searchResults.getSuggestion()); List<SearchResult> resultList = new ArrayList<>(readingListSearchResults.getResults()); resultList.addAll(historySearchResults.getResults()); addSearchResultsFromTabs(resultList); resultList.addAll(searchResults.getResults()); return resultList; })) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> updateProgressBar(false)) .subscribe(results -> { searchErrorView.setVisibility(GONE); handleResults(results, searchTerm, startTime); }, caught -> { searchErrorView.setVisibility(View.VISIBLE); searchErrorView.setVisibility(VISIBLE); searchErrorView.setError(caught); searchResultsContainer.setVisibility(GONE); logError(false, startTime); })); }

Target:
private void doTitlePrefixSearch(final String searchTerm, boolean force) { cancelSearchTask(); final long startTime = System.nanoTime(); updateProgressBar(true); disposables.add(Observable.timer(force ? 0 : DELAY_MILLIS, TimeUnit.MILLISECONDS).flatMap(timer -> Observable.zip(ServiceFactory.get(WikiSite.forLanguageCode(getSearchLanguageCode())).prefixSearch(searchTerm, BATCH_SIZE, searchTerm), Observable.fromCallable(() -> ReadingListDbHelper.instance().findPageForSearchQueryInAnyList(currentSearchTerm)), Observable.fromCallable(() -> HistoryDbHelper.INSTANCE.findHistoryItem(currentSearchTerm)), (searchResponse, readingListSearchResults, historySearchResults) -> { SearchResults searchResults; if (searchResponse != null && searchResponse.query() != null && searchResponse.query().pages() != null) { searchResults = new SearchResults(searchResponse.query().pages(), WikiSite.forLanguageCode(getSearchLanguageCode()), searchResponse.continuation(), searchResponse.suggestion()); } else { searchResults = new SearchResults(); } handleSuggestion(searchResults.getSuggestion()); List<SearchResult> resultList = new ArrayList<>(readingListSearchResults.getResults()); resultList.addAll(historySearchResults.getResults()); addSearchResultsFromTabs(resultList); resultList.addAll(searchResults.getResults()); return resultList; })) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> updateProgressBar(false)) .subscribe(results -> { searchErrorView.setVisibility(GONE); handleResults(results, searchTerm, startTime); }, caught -> { searchErrorView.setVisibility(VISIBLE); searchErrorView.setError(caught); searchResultsContainer.setVisibility(GONE); logError(false, startTime); })); }