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:
parent
561f94ae58
commit
b4a5b185fc
|
@ -135,13 +135,33 @@ public class ImcStateFragment extends Fragment implements VpnStateListener
|
|||
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
|
||||
public void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
if (mService != null)
|
||||
{
|
||||
mService.unregisterListener(this);
|
||||
getActivity().getApplicationContext().unbindService(mServiceConnection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||
super.onStart();
|
||||
if (mService != null)
|
||||
{
|
||||
mService.registerListener(this);
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
|
@ -152,6 +153,10 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||
public void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
if (mService != null)
|
||||
{
|
||||
mService.unregisterListener(this);
|
||||
}
|
||||
hideErrorDialog();
|
||||
hideProgressDialog();
|
||||
}
|
||||
|
@ -162,7 +167,6 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
|||
super.onDestroy();
|
||||
if (mService != null)
|
||||
{
|
||||
mService.unregisterListener(this);
|
||||
getActivity().getApplicationContext().unbindService(mServiceConnection);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue