mapbox / mapbox-gl-native-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
218 stars 116 forks source link

Offline API nullability #236

Open tobrun opened 5 years ago

tobrun commented 5 years ago

We are missing nullability annotations on the offline API callbacks. This makes it hard for it to be consumed from kotlin. For example:

OfflineManager.getInstance(rule.activity).createOfflineRegion(
        createTestRegionDefinition(),
        ByteArray(0),
        object : OfflineManager.CreateOfflineRegionCallback {
          override fun onCreate(region: OfflineRegion?) {
            // region will be non-null but we need to check it anyway
            region?.let {

            }
          }
        })
    }
tobrun commented 5 years ago

Similar issue with SnapshotCallback:

  public interface SnapshotReadyCallback {
    void onSnapshotReady(MapSnapshot var1);
  }
tobrun commented 5 years ago

Capturing from @LukasPaczos that clients can however choose when consuming callbacks to indicate the null ability on their end. This mitigates the issue from OP. Adding nullability annotations is a semver major change and we need to wait for a major release before making this change.

xit0c commented 4 years ago

Hi there! Happy to see this is an open issue. Do you plan to add annotations to all offline-related API callbacks? It would be great! I'm talking about: