From 6be60844db062575055752b554dbf14941e8e185 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Tue, 30 Jan 2018 14:35:25 +0100 Subject: 8828 - fix EipFragment leak --- app/src/main/java/se/leap/bitmaskclient/EipFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 414b1f2a..4027bc14 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -130,13 +130,13 @@ public class EipFragment extends Fragment implements Observer { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); eipStatus = EipStatus.getInstance(); - eipStatus.addObserver(this); eipReceiver = new EIPReceiver(new Handler()); preferences = getActivity().getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + eipStatus.addObserver(this); View view = inflater.inflate(R.layout.eip_service_fragment, container, false); ButterKnife.inject(this, view); @@ -162,6 +162,12 @@ public class EipFragment extends Fragment implements Observer { getActivity().unbindService(openVpnConnection); } + @Override + public void onDestroyView() { + super.onDestroyView(); + eipStatus.deleteObserver(this); + } + @Override public void onSaveInstanceState(Bundle outState) { outState.putBoolean(IS_CONNECTED, eipStatus.isConnected()); -- cgit v1.2.3