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

Hold off handling hover events untill map has been created #10142

Merged
merged 1 commit into from
Oct 10, 2017
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 @@ -2,8 +2,8 @@

import android.content.Context;
import android.graphics.PointF;
import android.os.Build;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.IntDef;
Expand Down Expand Up @@ -47,9 +47,9 @@

import timber.log.Timber;

import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;
import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_MAP_NORTH_ANIMATION;
import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_WAIT_IDLE;
import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;

/**
* <p>
Expand Down Expand Up @@ -382,7 +382,7 @@ public void onDestroy() {

@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isMapInitialized()) {
if (!isMapInitialized() || !isZoomButtonControllerInitialized()) {
return super.onTouchEvent(event);
}

Expand Down Expand Up @@ -419,6 +419,10 @@ public boolean onGenericMotionEvent(MotionEvent event) {

@Override
public boolean onHoverEvent(MotionEvent event) {
if (!isZoomButtonControllerInitialized()) {
return super.onHoverEvent(event);
}

switch (event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_MOVE:
Expand Down Expand Up @@ -506,7 +510,9 @@ protected void onSizeChanged(int width, int height, int oldw, int oldh) {
@CallSuper
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mapZoomButtonController.setVisible(false);
if (isZoomButtonControllerInitialized()) {
mapZoomButtonController.setVisible(false);
}
}

// Called when view is hidden and shown
Expand All @@ -516,7 +522,7 @@ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
return;
}

if (mapZoomButtonController != null) {
if (isZoomButtonControllerInitialized()) {
mapZoomButtonController.setVisible(visibility == View.VISIBLE);
}
}
Expand Down Expand Up @@ -582,6 +588,10 @@ private boolean isMapInitialized() {
return nativeMapView != null;
}

private boolean isZoomButtonControllerInitialized() {
return mapZoomButtonController != null;
}

MapboxMap getMapboxMap() {
return mapboxMap;
}
Expand Down