Source:
public static List<SearchResult> performSearch(final Context context, final String query, final long selectedFeed) { final int values[] = {2, 1, 0, 0, 0, 0}; final String[] subtitles = {context.getString(R.string.found_in_title_label), context.getString(R.string.found_in_chapters_label), context.getString(R.string.found_in_shownotes_label), context.getString(R.string.found_in_shownotes_label), context.getString(R.string.found_in_authors_label), context.getString(R.string.found_in_feeds_label)}; final List<SearchResult> result = new ArrayList<>(); List<FutureTask<List<FeedItem>>> tasks = new ArrayList<>(); tasks.add(DBTasks.searchFeedItemTitle(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemChapters(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemDescription(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemContentEncoded(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemAuthor(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemFeedIdentifier(context, selectedFeed, query)); for (FutureTask<List<FeedItem>> task : tasks) { task.run(); } try { Set<Long> set = new HashSet<>(); for (int i = 0; i < tasks.size(); i++) { FutureTask<List<FeedItem>> task = tasks.get(i); List<FeedItem> items = task.get(); for (FeedItem item : items) { if (!set.contains(item.getId())) { result.add(new SearchResult(item, values[i], subtitles[i])); set.add(item.getId()); } } } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } Collections.sort(result, new SearchResultValueComparator()); Collections.sort(result, new InReverseChronologicalOrder ()); return result; }

Target:
public static List<SearchResult> performSearch(final Context context, final String query, final long selectedFeed) { final int values[] = {2, 1, 0, 0, 0, 0}; final String[] subtitles = {context.getString(R.string.found_in_title_label), context.getString(R.string.found_in_chapters_label), context.getString(R.string.found_in_shownotes_label), context.getString(R.string.found_in_shownotes_label), context.getString(R.string.found_in_authors_label), context.getString(R.string.found_in_feeds_label)}; final List<SearchResult> result = new ArrayList<>(); List<FutureTask<List<FeedItem>>> tasks = new ArrayList<>(); tasks.add(DBTasks.searchFeedItemTitle(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemChapters(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemDescription(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemContentEncoded(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemAuthor(context, selectedFeed, query)); tasks.add(DBTasks.searchFeedItemFeedIdentifier(context, selectedFeed, query)); for (FutureTask<List<FeedItem>> task : tasks) { task.run(); } try { Set<Long> set = new HashSet<>(); for (int i = 0; i < tasks.size(); i++) { FutureTask<List<FeedItem>> task = tasks.get(i); List<FeedItem> items = task.get(); for (FeedItem item : items) { if (!set.contains(item.getId())) { result.add(new SearchResult(item, values[i], subtitles[i])); set.add(item.getId()); } } } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } Collections.sort(result, new InReverseChronologicalOrder()); return result; }