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

Remove view tree observer #13133

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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