Fix[modloader]: move detachments into onStop()

Some actions executed by the futures or the ModloaderDownloadListener may invoke operations which can only be performed when the fragment state is not yet saved. So this commit moves them into onStop, which is executed before saving the state.

For reference: https://developer.android.com/static/images/guide/fragments/fragment-view-lifecycle.png
This commit is contained in:
artdeell 2023-09-04 20:25:27 +03:00
parent 322837e533
commit 781a31a2d9
2 changed files with 4 additions and 4 deletions

View File

@ -82,14 +82,14 @@ public abstract class FabriclikeInstallFragment extends Fragment implements Modl
}
@Override
public void onDestroyView() {
super.onDestroyView();
public void onStop() {
cancelFutureChecked(mGameVersionFuture);
cancelFutureChecked(mLoaderVersionFuture);
ModloaderListenerProxy proxy = getListenerProxy();
if(proxy != null) {
proxy.detachListener();
}
super.onStop();
}
private void onClickStart(View v) {

View File

@ -58,10 +58,10 @@ public abstract class ModVersionListFragment<T> extends Fragment implements Runn
}
@Override
public void onDestroyView() {
public void onStop() {
ModloaderListenerProxy taskProxy = getTaskProxy();
if(taskProxy != null) taskProxy.detachListener();
super.onDestroyView();
super.onStop();
}
@Override