wdtinc / mapbox-vector-tile-java

Java Mapbox Vector Tile Library for Encoding/Decoding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android pre API 24 language support

snodnipper opened this issue · comments

I haven't done much android in a while, but I heard they support java 8 via desugar and deprecated Jack? Would this be valid on old android versions? How far back are you needing to go?
https://developer.android.com/studio/write/java8-support.html

https://developer.android.com/reference/java/util/Collections.html#emptyList()
https://developer.android.com/reference/java/util/List.html#toArray()

So we have Java 8 syntax support but the APIs are not (currently) ported back beyond API 24, which is Android 7.0 (Nougat).

https://developer.android.com/studio/write/java8-support.html#supported_features

I have altered the wdtinc code for the moment in our vt-support library.

You can get a rough idea of what has changed in my repo.

I need to get a demo working for tomorrow (I have not got this fresh code running yet) so I'll feedback any issues.

Happy to help as necessary (e.g. PR Java 1.7 code, add CircleCI config if you'd like CI deployments in the project etc.)

-    final Integer mapIndex = keys.putIfAbsent(key, nextIndex);
+    // Android API 24 call
+    // final Integer mapIndex = keys.putIfAbsent(key, nextIndex);
+    final Integer mapIndex;
+    if (!vals.containsKey(key)) {
+      mapIndex = vals.put(key, nextIndex);
+    }
+    else {
+      mapIndex = vals.get(key);
+    }

Minor things like this. It is not pretty but is documented. https://developer.android.com/reference/java/util/Map.html#putIfAbsent(K, V)

It certainly isn't a pleasurable experience...because usually Java version defines allowed syntax and methods that can be called.

Continuing...

Added travis ci to run 'mvn clean test' to master.

Created branch 'android_api_24_support'

Sweet - I'll commit the changes currently visible in our vt-support lib and start a PR.

Added bug label since several issues were picked up by findbugs.

@snodnipper Since you've tested with API 21 mentioned in #14 I may go ahead and update the readme to reflect that.

Closed via #14 and #16

Thanks @ShibaBandit and folks for commenting etc. to help push this over the line.

If anyone wants to talk about functionality etc. I am happy to talk on the http://thespatialcommunity.org/ slack channel - e.g. very old Android support etc.

👍