@Test public void load3SearchProjects() throws Exception { final Project project0 = ProjectFactory.allTheWayProject(); final Project project1 = ProjectFactory.almostCompletedProject(); final Project project2 = ProjectFactory.backedProject(); this.adapter.loadSearchProjects(Arrays.asList(project0, project1, project2)); final List<List<Pair<Project, Boolean>>> data = Arrays.asList( Collections.emptyList(), Collections.singletonList(Pair.create(project0, true)), Arrays.asList(Pair.create(project1, false), Pair.create(project2, false)) ); assertEquals(data, this.adapter.sections()); }
public void loadSearchProjects(final @NonNull List<Project> newProjects) { clearSections(); if (newProjects.size() > 0) { this.insertSection(SECTION_POPULAR_TITLE, Collections.emptyList()); this.insertSection( SECTION_FEATURED_PROJECT, Collections.singletonList( Pair.create(newProjects.get(0), true) ) ); this.insertSection( SECTION_PROJECT, Observable.from(newProjects.subList(1, newProjects.size())) .map(p -> Pair.create(p, false)) .toList().toBlocking().first() ); } notifyDataSetChanged(); }
SearchAdapter extends KSAdapter { public void loadSearchProjects(final @NonNull List<Project> newProjects) { clearSections(); if (newProjects.size() > 0) { this.insertSection(SECTION_POPULAR_TITLE, Collections.emptyList()); this.insertSection( SECTION_FEATURED_PROJECT, Collections.singletonList( Pair.create(newProjects.get(0), true) ) ); this.insertSection( SECTION_PROJECT, Observable.from(newProjects.subList(1, newProjects.size())) .map(p -> Pair.create(p, false)) .toList().toBlocking().first() ); } notifyDataSetChanged(); } }
SearchAdapter extends KSAdapter { public void loadSearchProjects(final @NonNull List<Project> newProjects) { clearSections(); if (newProjects.size() > 0) { this.insertSection(SECTION_POPULAR_TITLE, Collections.emptyList()); this.insertSection( SECTION_FEATURED_PROJECT, Collections.singletonList( Pair.create(newProjects.get(0), true) ) ); this.insertSection( SECTION_PROJECT, Observable.from(newProjects.subList(1, newProjects.size())) .map(p -> Pair.create(p, false)) .toList().toBlocking().first() ); } notifyDataSetChanged(); } SearchAdapter(final @NonNull Delegate delegate); }
SearchAdapter extends KSAdapter { public void loadSearchProjects(final @NonNull List<Project> newProjects) { clearSections(); if (newProjects.size() > 0) { this.insertSection(SECTION_POPULAR_TITLE, Collections.emptyList()); this.insertSection( SECTION_FEATURED_PROJECT, Collections.singletonList( Pair.create(newProjects.get(0), true) ) ); this.insertSection( SECTION_PROJECT, Observable.from(newProjects.subList(1, newProjects.size())) .map(p -> Pair.create(p, false)) .toList().toBlocking().first() ); } notifyDataSetChanged(); } SearchAdapter(final @NonNull Delegate delegate); void loadPopularProjects(final @NonNull List<Project> newProjects); void loadSearchProjects(final @NonNull List<Project> newProjects); }
SearchAdapter extends KSAdapter { public void loadSearchProjects(final @NonNull List<Project> newProjects) { clearSections(); if (newProjects.size() > 0) { this.insertSection(SECTION_POPULAR_TITLE, Collections.emptyList()); this.insertSection( SECTION_FEATURED_PROJECT, Collections.singletonList( Pair.create(newProjects.get(0), true) ) ); this.insertSection( SECTION_PROJECT, Observable.from(newProjects.subList(1, newProjects.size())) .map(p -> Pair.create(p, false)) .toList().toBlocking().first() ); } notifyDataSetChanged(); } SearchAdapter(final @NonNull Delegate delegate); void loadPopularProjects(final @NonNull List<Project> newProjects); void loadSearchProjects(final @NonNull List<Project> newProjects);  }