Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Infer Nullity #13071

Merged
merged 2 commits into from
Oct 12, 2018
Merged

Infer Nullity #13071

merged 2 commits into from
Oct 12, 2018

Conversation

tobrun
Copy link
Member

@tobrun tobrun commented Oct 10, 2018

Closes #11886 , This PR improves consuming our library from kotlin by applying as much as possible @Nullable/@NonNull annotations. Most changes were performed automatically using Analyze > Infer Nullity... in Android Studio.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Oct 10, 2018
@tobrun tobrun added this to the android-v6.7.0 milestone Oct 10, 2018
@tobrun tobrun self-assigned this Oct 10, 2018
@tobrun tobrun force-pushed the tvn-kotlin-compability branch 4 times, most recently from 94ae262 to b6d3289 Compare October 11, 2018 08:54
…k, removes necessity to add question mark to all mapboxMap invocations
Copy link
Member

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

This is great! The converter tool (and any tweaks you added) looks really reliable. I love how builders will be cleaned up in the Kotlin code :)

I added comments wherever I've seen obvious adjustments, we can continue with the rest as we go. Also, do you think we need annotations on private fields? Lint is not great at picking up when assigning anything but a raw null to the field and it doesn't improve Kotlin interop by much, but adds a lot of lines of code and makes it less readable.

private Path path = new Path();

Bubble(RectF rect, ArrowDirection arrowDirection, float arrowWidth, float arrowHeight, float arrowPosition,
Bubble(RectF rect, @NonNull ArrowDirection arrowDirection, float arrowWidth, float arrowHeight, float arrowPosition,
Copy link
Member

Choose a reason for hiding this comment

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

rect should not be null

@@ -81,7 +84,7 @@ public int getIntrinsicHeight() {
return (int) rect.height();
}

private void initPath(ArrowDirection arrowDirection, Path path, float strokeWidth) {
private void initPath(ArrowDirection arrowDirection, @NonNull Path path, float strokeWidth) {
Copy link
Member

Choose a reason for hiding this comment

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

arrowDirection should not be null

@@ -111,6 +112,7 @@ public ArrowDirection getArrowDirection() {
* @param arrowDirection The direction of the arrow
* @return this
*/
@NonNull
public BubbleLayout setArrowDirection(ArrowDirection arrowDirection) {
Copy link
Member

Choose a reason for hiding this comment

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

arrowDirection should not be null

@@ -53,11 +55,11 @@
initialize(view, mapboxMap);
}

InfoWindow(View view, MapboxMap mapboxMap) {
InfoWindow(@NonNull View view, MapboxMap mapboxMap) {
Copy link
Member

Choose a reason for hiding this comment

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

mapboxMap should not be null

initialize(view, mapboxMap);
}

private void initialize(View view, MapboxMap mapboxMap) {
private void initialize(@NonNull View view, MapboxMap mapboxMap) {
Copy link
Member

Choose a reason for hiding this comment

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

mapboxMap should not be null

@@ -540,7 +555,7 @@ private void resolveForMarker(MarkerHit markerHit, Marker marker) {
hitTestMarker(markerHit, marker, hitRectMarker);
}

private void hitTestMarker(MarkerHit markerHit, Marker marker, RectF hitRectMarker) {
private void hitTestMarker(MarkerHit markerHit, @NonNull Marker marker, RectF hitRectMarker) {
Copy link
Member

Choose a reason for hiding this comment

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

hitRectMarker should not be null

@@ -112,8 +117,8 @@ public void run() {
}

@UiThread
final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
final MapboxMap.CancelableCallback callback, boolean isDismissable) {
final void easeCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
Copy link
Member

Choose a reason for hiding this comment

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

update should not be null

@@ -118,7 +122,7 @@ void requestRender() {
/**
* May be called from any thread
*/
void queueEvent(Runnable runnable) {
void queueEvent(@Nullable Runnable runnable) {
Copy link
Member

Choose a reason for hiding this comment

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

runnable should not be null

private void drawAttribution(MapSnapshot mapSnapshot, Canvas canvas,
AttributionMeasure measure, AttributionLayout layout) {
private void drawAttribution(@NonNull MapSnapshot mapSnapshot, @NonNull Canvas canvas,
@NonNull AttributionMeasure measure, AttributionLayout layout) {
Copy link
Member

Choose a reason for hiding this comment

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

layout should not be null

Copy link
Member

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

Also seems like #11886 (comment) has not been fixed.

@tobrun
Copy link
Member Author

tobrun commented Oct 12, 2018

@LukasPaczos comments have been adressed, except #13071 (review). It seems to be the same as the proposed change in #11886 (comment).

  // MapView.java
  public void addOnMapChangedListener(@NonNull OnMapChangedListener listener) {
  }
  public void removeOnMapChangedListener(@NonNull OnMapChangedListener listener) {
  }

Copy link
Member

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

@tobrun that's right, seems like it has been handled with a different PR 🚀

@tobrun tobrun merged commit 6177427 into master Oct 12, 2018
@tobrun tobrun deleted the tvn-kotlin-compability branch October 12, 2018 16:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants