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

Commit

Permalink
[android] - remove view tree observer
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Oct 18, 2018
1 parent 201db67 commit 4f877e0
Showing 1 changed file with 1 addition and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.graphics.PointF;
import android.graphics.drawable.ColorDrawable;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.IntDef;
Expand All @@ -20,7 +19,6 @@
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;
Expand Down Expand Up @@ -149,8 +147,7 @@ protected void initialize(@NonNull final Context context, @NonNull final MapboxM
// add accessibility support
setContentDescription(context.getString(R.string.mapbox_mapActionDescription));
setWillNotDraw(false);

getViewTreeObserver().addOnGlobalLayoutListener(new MapViewLayoutListener(this, options));
initialiseDrawingSurface(options);
}

private void initialiseMap() {
Expand Down Expand Up @@ -1373,30 +1370,6 @@ public interface OnMapChangedListener {
void onMapChanged(@MapChange int change);
}

private static class MapViewLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {

private WeakReference<MapView> mapViewWeakReference;
private MapboxMapOptions options;

MapViewLayoutListener(MapView mapView, MapboxMapOptions options) {
this.mapViewWeakReference = new WeakReference<>(mapView);
this.options = options;
}

@Override
public void onGlobalLayout() {
MapView mapView = mapViewWeakReference.get();
if (mapView != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mapView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
mapView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
mapView.initialiseDrawingSurface(options);
}
}
}

private class FocalPointInvalidator implements FocalPointChangeListener {

private final List<FocalPointChangeListener> focalPointChangeListeners = new ArrayList<>();
Expand Down

0 comments on commit 4f877e0

Please sign in to comment.