Skip to content

[google_maps_flutter_android] Fix Android lint warnings #3751

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

Merged
merged 12 commits into from
Apr 25, 2023
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.12

* Fixes Java warnings.

## 2.4.11

* Adds a namespace for compatibility with AGP 8.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ android {
checkAllWarnings true
warningsAsErrors true
disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
baseline file("lint-baseline.xml")
}

dependencies {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,17 @@ private void invalidateMapIfNeeded() {
}
loadedCallbackPending = true;
googleMap.setOnMapLoadedCallback(
new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
loadedCallbackPending = false;
postFrameCallback(
() -> {
postFrameCallback(
() -> {
if (mapView != null) {
mapView.invalidate();
}
});
});
}
() -> {
loadedCallbackPending = false;
postFrameCallback(
() -> {
postFrameCallback(
() -> {
if (mapView != null) {
mapView.invalidate();
}
});
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package io.flutter.plugins.googlemaps;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.maps.model.CameraPosition;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.StandardMessageCodec;
Expand All @@ -30,7 +32,8 @@ public class GoogleMapFactory extends PlatformViewFactory {

@SuppressWarnings("unchecked")
@Override
public PlatformView create(Context context, int id, Object args) {
@NonNull
public PlatformView create(@NonNull Context context, int id, @Nullable Object args) {
Map<String, Object> params = (Map<String, Object>) args;
final GoogleMapBuilder builder = new GoogleMapBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
*/
public class GoogleMapsPlugin implements FlutterPlugin, ActivityAware {

@Nullable private Lifecycle lifecycle;
@Nullable Lifecycle lifecycle;

private static final String VIEW_TYPE = "plugins.flutter.dev/google_maps_android";

@SuppressWarnings("deprecation")
public static void registerWith(
final io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
@NonNull final io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
final Activity activity = registrar.activity();
if (activity == null) {
// When a background flutter view tries to register the plugin, the registrar has no activity.
Expand Down Expand Up @@ -70,7 +70,7 @@ public GoogleMapsPlugin() {}
// FlutterPlugin

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
binding
.getPlatformViewRegistry()
.registerViewFactory(
Expand All @@ -88,12 +88,12 @@ public Lifecycle getLifecycle() {
}

@Override
public void onDetachedFromEngine(FlutterPluginBinding binding) {}
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {}

// ActivityAware

@Override
public void onAttachedToActivity(ActivityPluginBinding binding) {
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
}

Expand All @@ -103,7 +103,7 @@ public void onDetachedFromActivity() {
}

@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
onAttachedToActivity(binding);
}

Expand All @@ -124,7 +124,7 @@ private static final class ProxyLifecycleProvider
private final LifecycleRegistry lifecycle = new LifecycleRegistry(this);
private final int registrarActivityHashCode;

private ProxyLifecycleProvider(Activity activity) {
ProxyLifecycleProvider(Activity activity) {
this.registrarActivityHashCode = activity.hashCode();
activity.getApplication().registerActivityLifecycleCallbacks(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class TileProviderController implements TileProvider {

private static final String TAG = "TileProviderController";

private final String tileOverlayId;
private final MethodChannel methodChannel;
private final Handler handler = new Handler(Looper.getMainLooper());
protected final String tileOverlayId;
protected final MethodChannel methodChannel;
protected final Handler handler = new Handler(Looper.getMainLooper());

TileProviderController(MethodChannel methodChannel, String tileOverlayId) {
this.tileOverlayId = tileOverlayId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_android
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.4.11
version: 2.4.12

environment:
sdk: ">=2.17.0 <4.0.0"
Expand Down