Skip to content
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

Fix a few nullability and other minor warnings #187

Merged
merged 8 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public class ViewScopeProvider implements LifecycleScopeProvider<ViewLifecycleEv
* @param view the view to scope for
* @return a {@link LifecycleScopeProvider} against this view.
*/
public static LifecycleScopeProvider from(View view) {
public static LifecycleScopeProvider<ViewLifecycleEvent> from(View view) {
//noinspection ConstantConditions
if (view == null) {
// check for null anyway for callers that have subpar static analysis
throw new NullPointerException("view == null");
}
return new ViewScopeProvider(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ static final class AutoDisposeParallelFlowable<T> extends ParallelFlowable<T> {
return;
}

Subscriber<? super T>[] newSubscribers = new Subscriber[subscribers.length];
// there's no efficient way to avoid this warning due to generics
@SuppressWarnings("unchecked") Subscriber<? super T>[] newSubscribers = new Subscriber[subscribers.length];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made to not have generics issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, because you can't create an array of a generic type T. There's always going to be some type munging behind the scenes. It's either cast here, or cast somewhere else and either way it's unchecked.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

for (int i = 0; i < subscribers.length; i++) {
AutoDisposingSubscriberImpl<? super T> subscriber =
new AutoDisposingSubscriberImpl<>(scope, subscribers[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public enum ActivityEvent {
return lifecycleEvents.getValue();
}

@Override protected void onCreate(Bundle savedInstanceState) {
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lifecycleEvents.onNext(ActivityEvent.CREATE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ public enum FragmentEvent {
lifecycleEvents.onNext(FragmentEvent.ATTACH);
}

@Override public void onCreate(Bundle savedInstanceState) {
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lifecycleEvents.onNext(FragmentEvent.CREATE);
}

@Override public void onViewCreated(View view, Bundle savedInstanceState) {
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
lifecycleEvents.onNext(FragmentEvent.CREATE_VIEW);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public boolean matches(ExpressionTree tree, VisitorState state) {
private static Matcher<MethodInvocationTree> matcher(List<String> classesWithLifecycle) {
return (Matcher<MethodInvocationTree>) (tree, state) -> {

boolean matchFound = false;
ExpressionTree methodSelectTree = tree.getMethodSelect();

// MemberSelectTree is used only for member access expression.
Expand All @@ -164,7 +163,7 @@ private static Matcher<MethodInvocationTree> matcher(List<String> classesWithLif
return false;
}

matchFound = SUBSCRIBE_MATCHERS
boolean matchFound = SUBSCRIBE_MATCHERS
.stream()
.map(methodNameMatcher -> methodNameMatcher.matches(tree, state))
.filter(Boolean::booleanValue) // Filtering the method invocation with name subscribe
Expand Down