android: Don't update state fragments when they are not displayed
Besides that updates don't make much sense when the fragments are not displayed this fixes the following exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
This commit is contained in:
@@ -135,13 +135,33 @@ public class ImcStateFragment extends Fragment implements VpnStateListener
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
super.onStart();
|
||||||
|
if (mService != null)
|
||||||
|
{
|
||||||
|
mService.registerListener(this);
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
super.onStop();
|
||||||
|
if (mService != null)
|
||||||
|
{
|
||||||
|
mService.unregisterListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy()
|
public void onDestroy()
|
||||||
{
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (mService != null)
|
if (mService != null)
|
||||||
{
|
{
|
||||||
mService.unregisterListener(this);
|
|
||||||
getActivity().getApplicationContext().unbindService(mServiceConnection);
|
getActivity().getApplicationContext().unbindService(mServiceConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
if (mService != null)
|
if (mService != null)
|
||||||
{
|
{
|
||||||
|
mService.registerListener(this);
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,6 +153,10 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
public void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
if (mService != null)
|
||||||
|
{
|
||||||
|
mService.unregisterListener(this);
|
||||||
|
}
|
||||||
hideErrorDialog();
|
hideErrorDialog();
|
||||||
hideProgressDialog();
|
hideProgressDialog();
|
||||||
}
|
}
|
||||||
@@ -162,7 +167,6 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (mService != null)
|
if (mService != null)
|
||||||
{
|
{
|
||||||
mService.unregisterListener(this);
|
|
||||||
getActivity().getApplicationContext().unbindService(mServiceConnection);
|
getActivity().getApplicationContext().unbindService(mServiceConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user