mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Set fragment title and [un]register callbacks in onStart/onStop
onStart() is called when the fragment is made visible, whereas onPause() is called when the fragment looses focus e.g. if a dialog is shown. Thus: - there is no need to set the activity's title everytime the fragment regains focus, - it is better to listen to event tasks and refresh the state of the UI while the fragment is actually visible, listening to events until the fragment is destroyed is useless: if an event is received between onStop() and onDestroy(), there will be some processing but nothing will be shown because the fragment is no longer visible.
This commit is contained in:
parent
e9f04256c9
commit
dc316c5669
@ -98,15 +98,15 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getActivity().setTitle(R.string.install);
|
||||
CallbackHandler.register(blockDetectionDone, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onStop() {
|
||||
CallbackHandler.unRegister(blockDetectionDone, this);
|
||||
super.onStop();
|
||||
}
|
||||
}
|
||||
|
@ -70,11 +70,16 @@ public class LogFragment extends Fragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getActivity().setTitle(R.string.log);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
new LogManager().read();
|
||||
getActivity().setTitle(R.string.log);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,8 +93,8 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getActivity().setTitle(R.string.magiskhide);
|
||||
CallbackHandler.register(packageLoadDone, this);
|
||||
if (packageLoadDone.isTriggered) {
|
||||
@ -103,9 +103,9 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
public void onStop() {
|
||||
CallbackHandler.unRegister(packageLoadDone, this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,16 +93,16 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
CallbackHandler.register(moduleLoadDone, this);
|
||||
getActivity().setTitle(R.string.modules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onStop() {
|
||||
CallbackHandler.unRegister(moduleLoadDone, this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
|
@ -109,16 +109,16 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
CallbackHandler.register(repoLoadDone, this);
|
||||
getActivity().setTitle(R.string.downloads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onStop() {
|
||||
CallbackHandler.unRegister(repoLoadDone, this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void reloadRepos() {
|
||||
|
@ -141,8 +141,8 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
CallbackHandler.register(updateCheckDone, this);
|
||||
CallbackHandler.register(safetyNetDone, this);
|
||||
if (updateCheckDone.isTriggered) {
|
||||
@ -155,10 +155,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
public void onStop() {
|
||||
CallbackHandler.unRegister(updateCheckDone, this);
|
||||
CallbackHandler.unRegister(safetyNetDone, this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private static void checkMagiskInfo() {
|
||||
|
Loading…
Reference in New Issue
Block a user