-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Search Result page #85
Conversation
…SS if just font size an colour. :)
…or as a substitutable in the project stats string
* Add new event names and missing (clear) event * Fix broken unit tests. * Put back legacy events * added test
…droid-oss into update_search_result_list
… method to insert sections
…droid-oss into update_search_result_list # Conflicts: # app/src/main/assets/json/server-config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woot! think we're done with this one! great job!
@@ -4,6 +4,7 @@ | |||
import android.os.Bundle; | |||
import android.support.annotation.NonNull; | |||
import android.support.annotation.Nullable; | |||
import android.support.v4.util.Pair; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this jazz?
final Intent intent = new Intent(this, ProjectActivity.class) | ||
.putExtra(IntentKey.PROJECT, project) | ||
.putExtra(IntentKey.REF_TAG, RefTag.search()); | ||
.putExtra(IntentKey.REF_TAG, didSearch() ? refTags.first : refTags.second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont wanna put logic here
@@ -27,29 +27,41 @@ public void loadPopularProjects(final @NonNull List<Project> newProjects) { | |||
if (newProjects.size() == 0) { | |||
addSection(Collections.emptyList()); | |||
} else { | |||
addSection(Collections.singletonList(null)); | |||
addSection(getFeatureProject(newProjects)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor this
this.viewModel.outputs.projectName() | ||
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(this::setProjectName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do .subscribe(this.projectNameTextView::setText);
scheduler.advanceTimeBy(300, TimeUnit.MILLISECONDS); | ||
final TestSubscriber<RefTag> projectClicked = new TestSubscriber<>(); | ||
viewModel.outputs.searchProjects().map(sp -> sp.get(0)).subscribe(viewModel.inputs::tappedProject); | ||
viewModel.outputs.goToProject().map(p -> p.second).subscribe(projectClicked); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to attach test subscribers immediately and we shouldn't be hitting vm inputs like that
@@ -38,6 +42,8 @@ | |||
|
|||
/** Emits list of projects matching criteria. */ | |||
Observable<List<Project>> searchProjects(); | |||
|
|||
Observable<Pair<Project, RefTag>> goToProject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpha
@@ -30,6 +32,8 @@ | |||
|
|||
/** Call when text changes in search box. */ | |||
void search(final @NonNull String s); | |||
|
|||
void tappedProject(final @NonNull Project project); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few changes and questions
|
||
protected @Bind(R.id.search_term_text_view) TextView termTextView; | ||
protected @Bind(R.id.search_term_view) LinearLayout layout; | ||
@Bind(R.id.search_term_text_view) TextView termTextView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can name this searchTermTextView
to match the id
@Bind(R.id.project_name_text_view) TextView projectNameTextView; | ||
@Bind(R.id.project_image_view) ImageView projectImageView; | ||
@Bind(R.id.project_stats_text_view_pct_complete_data) TextView projectStatsPctCompleteDataTextView; | ||
@Bind(R.id.project_stats_text_view_pct_complete_string) TextView projectStatsPctCompleteStringTextView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious as to what Pct
stands for? it's not a very intuitive abbreviation for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Percent. What would you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to percent. We can shorten it to something else if you prefer.
|
||
((KSApplication) view.getContext().getApplicationContext()).component().inject(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
niiice
this.viewModel.inputs.configureWith(configData); | ||
} | ||
|
||
void setProjectImage(final String imageUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can mark this and the following method as private
and the param as @NonNull
} else { | ||
projectImageView.setVisibility(View.INVISIBLE); | ||
} | ||
void setProjectStats(final Pair<Integer, Integer> stats) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, private method, nonnull param
android:textColor="@color/gray_black" | ||
tools:text="@string/search_most_popular" /> | ||
|
||
</LinearLayout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
@@ -69,6 +69,8 @@ | |||
<dimen name="comment_body_padding_x">@dimen/grid_7</dimen> | |||
<dimen name="feed_padding_y">@dimen/grid_5_half</dimen> | |||
<dimen name="feed_padding_x">@dimen/grid_2</dimen> | |||
<dimen name="search_padding_y">@dimen/grid_new_2</dimen> | |||
<dimen name="search_padding_x">@dimen/grid_new_2</dimen> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
private final TestSubscriber<String> projectName = new TestSubscriber<>(); | ||
private final TestSubscriber<Pair<Integer, Integer>> projectStats = new TestSubscriber<>(); | ||
|
||
@Before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to have it run before each test we do. I have now made it override parent setUp and passing the resulting environment
|
||
@Before | ||
public void setUpEnvironment() { | ||
this.vm = new ProjectSearchResultHolderViewModel.ViewModel(environment()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know we have access to the environment within our test files, but it's good practice to pass in the environment in the method in case we need to modify it within each test in the future
KoalaEvent.CLEARED_SEARCH_TERM); | ||
} | ||
|
||
void testSearchPagination() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing @Test
annotation, and should be marked public
this.popularProjects.asObservable(), | ||
this.searchProjects.asObservable() | ||
this.popularProjects, | ||
this.searchProjects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh good catch. I did that. didn't know you could merge subjects, thought you had to get into the observable under the hood.
… sensible project names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some more small code style things i've mentioned before, but looks good!
@@ -34,7 +34,7 @@ public KSViewHolder(final @NonNull View view) { | |||
*/ | |||
@Override | |||
public void onClick(final @NonNull View view) { | |||
Timber.d("Default KSViewHolder onClick event"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't change since it's describing the default value, i.e. not every VH onClick will be a project click
|
||
import butterknife.Bind; | ||
import butterknife.BindString; | ||
import butterknife.ButterKnife; | ||
|
||
public final class SearchTermViewHolder extends KSViewHolder { | ||
private DiscoveryParams params; | ||
public class PopularSearchTitleViewHolder extends KSViewHolder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class should be final
, in general make sure our classes are final
this.viewModel.inputs.configureWith(configData); | ||
} | ||
|
||
private void setProjectImage(@NonNull final String imageUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final @NonNull
} else { | ||
projectImageView.setVisibility(View.INVISIBLE); | ||
} | ||
private void setProjectStats(@NonNull final Pair<Integer, Integer> stats) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here final @NonNull
private final PublishSubject<String> search = PublishSubject.create(); | ||
|
||
private final BehaviorSubject<List<Project>> popularProjects = BehaviorSubject.create(); | ||
private final BehaviorSubject<List<Project>> searchProjects = BehaviorSubject.create(); | ||
private final BehaviorSubject<Pair<Project, RefTag>> goToProject = BehaviorSubject.create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can alphabetize this
@Override public void search(final @NonNull String s) { | ||
this.search.onNext(s); | ||
} | ||
|
||
@Override public Observable<Pair<Project, RefTag>> goToProject() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NonNull
observable for all these outputs
android:textColor="@color/gray_black" | ||
tools:text="@string/Popular_Projects" /> | ||
|
||
</LinearLayout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SearchAdapterTest extends KSRobolectricTestCase implements SearchAdapter.Delegate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
, but also 🎉 our first adapter test!!
scheduler.advanceTimeBy(300, TimeUnit.MILLISECONDS); | ||
viewModel.inputs.projectClicked(projects.get(0)); | ||
|
||
goToRefTag.assertValues(RefTag.searchFeatured()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so great to have tests for this kind of business logic
scheduler.advanceTimeBy(300, TimeUnit.MILLISECONDS); | ||
|
||
projectList.assertValueCount(2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline
What