Skip to content

feat(android): upgrade version, improve code#717

Open
m1ga wants to merge 1 commit into
tidev:masterfrom
m1ga:androidUpgrade
Open

feat(android): upgrade version, improve code#717
m1ga wants to merge 1 commit into
tidev:masterfrom
m1ga:androidUpgrade

Conversation

@m1ga

@m1ga m1ga commented Jul 19, 2026

Copy link
Copy Markdown
Contributor
  • update library versions
  • AI code improvements

Real bugs fixed

  • PolylineBoundary.getDistance() — double diffY = point2.y - point.y used the instance field point (the clicked location) instead of the parameter point1. Every polyline click hit-test was computing distance against a malformed segment vector. One-character fix, but it silently corrupted all polyline click events.
  • ViewProxy.showAnnotations() — the non-UI-thread path sent obtainMessage(MSG_SHOW_ANNOTATIONS) with no payload, but the handler does ((AsyncResult) msg.obj).getArg() → guaranteed NPE. Calling showAnnotations() off the main thread always crashed. Now passes the argument via sendBlockingMainMessage like every sibling method.
  • ViewProxy.addPolylines() — filtered the incoming array with instanceof AnnotationProxy instead of PolylineProxy, so when the polylines property already held an array, new polylines were silently dropped from the JS-side property (they still rendered — so the property and the map disagreed).
  • PolylineProxy.processPatternDefinition(HashMap) — unboxed (Integer) definition.get("type") before the == null check, so the "no pattern type specified" fallback was unreachable and a missing type or gapLength threw NPE. Now null-checks first and uses TiConvert.toInt with the existing defaults.
  • CameraProxy.updateCamera() — CameraPosition.Builder().target(null) throws when a Camera is created without centerCoordinates. Now leaves cameraPosition null, which getCamera() already handles. Also added the missing getApiName().
  • TiClusterRenderer.onBeforeClusterItemRendered() — centerOffset divides by iconImageWidth/Height, which stay 0 unless an image was set, yielding ±Infinity anchors. Now falls back to the default icon dimensions, matching what AnnotationProxy.processOptions() already did.
  • AnnotationProxy.updateImage() — clearing image did defaultMarker(TiConvert.toFloat(getProperty(PINCOLOR))), NPE when no pinColor was set. Now uses the plain defaultMarker() in that case.
  • TiUIMapView.showAnnotations() — LatLngBounds.Builder.build() throws IllegalStateException when nothing was included; an empty array, or clustered annotations whose getPosition() is null, crashed it.

Robustness / leaks

  • handleGetZoomLevel(), handleAddAnnotation(), handleRemoveAnnotation(), handleShowAnnotations() dereferenced peekView()/getMap() without checks — NPE if called before the map was ready.
  • loadJSONFromAsset() leaked the InputStream on IO failure → try-with-resources; setStyle() now handles its null return instead of JSONTokener(null).
  • analyzeTouchEvent() never recycled its MotionEvent.obtain() copy — recycled in a finally.
  • AnnotationProxy.release() leaked the TiMapInfoWindow (and its child views) and the delegate; the actual cleanup was sitting commented out.
  • AnnotationProxy message handlers called marker.getMarker() on a possibly-null marker → extracted a null-safe getNativeMarker().
  • release() in TiUIMapView nulled currentCircles/Polygons/Polylines while removeCircle() etc. still read them — now cleared, not nulled, and image overlays are cleared too.
  • Null guards on getCircle()/getPolygon()/getPolyline()/getGroundOverlay() in the remove paths, and on getCircle() in the onMapClick hit-test.
  • ViewProxy.clearPreloadObjects() didn't clear preloadOverlaysList, so image overlays were re-added on view recreation.
  • setUserLocationEnabled() — dropped the dead SDK_INT < 23 branch, accepts ACCESS_COARSE_LOCATION, and no longer logs a permission error when disabling or when map is null.
  • Deduplicated the three copies of bitmap-loading; replaced silent empty catch blocks and an e.printStackTrace() with real logging; removed unused imports and a raw DefaultClusterRenderer type.

Tested in an app with clusters, litemode and header/footerView in a listview example from #703

ti.map-android-5.8.0.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant