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

Commit

Permalink
[android] - harden activation/deactivation of underlying ref counting…
Browse files Browse the repository at this point in the history
… components
  • Loading branch information
tobrun committed Oct 29, 2018
1 parent 3917a0e commit a854f9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private MapKeyListener mapKeyListener;
private MapZoomButtonController mapZoomButtonController;
private Bundle savedInstanceState;
private boolean isActivated;

@UiThread
public MapView(@NonNull Context context) {
Expand Down Expand Up @@ -359,8 +360,11 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
*/
@UiThread
public void onStart() {
ConnectivityReceiver.instance(getContext()).activate();
FileSource.getInstance(getContext()).activate();
if (!isActivated) {
ConnectivityReceiver.instance(getContext()).activate();
FileSource.getInstance(getContext()).activate();
isActivated = true;
}
if (mapboxMap != null) {
mapboxMap.onStart();
}
Expand Down Expand Up @@ -405,8 +409,11 @@ public void onStop() {
mapRenderer.onStop();
}

ConnectivityReceiver.instance(getContext()).deactivate();
FileSource.getInstance(getContext()).deactivate();
if (isActivated) {
ConnectivityReceiver.instance(getContext()).deactivate();
FileSource.getInstance(getContext()).deactivate();
isActivated = false;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ class RecyclerViewActivity : AppCompatActivity() {
}

fun onDestroy() {
mapHolder?.mapView?.onDestroy()
mapHolder?.mapView?.let {
it.onPause()
it.onStop()
it.onDestroy()
}
}

class MapItem
Expand Down

0 comments on commit a854f9d

Please sign in to comment.