Skip to content
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

Remove NavigationViewModel as lifecycle observer #643

Merged
merged 2 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
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 @@ -174,6 +174,7 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
*/
public void onDestroy() {
mapView.onDestroy();
navigationViewModel.onDestroy();
}

/**
Expand Down Expand Up @@ -480,7 +481,6 @@ private void initLifecycleObservers() {
try {
((LifecycleOwner) getContext()).getLifecycle().addObserver(locationLayer);
((LifecycleOwner) getContext()).getLifecycle().addObserver(locationViewModel);
((LifecycleOwner) getContext()).getLifecycle().addObserver(navigationViewModel);
} catch (ClassCastException exception) {
throw new ClassCastException("Please ensure that the provided Context is a valid LifecycleOwner");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.OnLifecycleEvent;
import android.content.Context;
import android.content.SharedPreferences;
import android.location.Location;
Expand Down Expand Up @@ -37,7 +34,7 @@

import java.text.DecimalFormat;

public class NavigationViewModel extends AndroidViewModel implements LifecycleObserver, ProgressChangeListener,
public class NavigationViewModel extends AndroidViewModel implements ProgressChangeListener,
OffRouteListener, MilestoneEventListener, NavigationEventListener {

public final MutableLiveData<InstructionModel> instructionModel = new MutableLiveData<>();
Expand Down Expand Up @@ -67,7 +64,6 @@ public NavigationViewModel(Application application) {
initDecimalFormat();
}

@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
endNavigation();
deactivateInstructionPlayer();
Expand Down