Pass along View's context on destroy if available

This commit is contained in:
EricKuck
2022-07-05 10:43:06 -05:00
parent ba98e3b165
commit 63a92db540
@@ -1035,7 +1035,11 @@ public abstract class Controller {
}
private void removeViewReference() {
Context context = null;
if (view != null) {
context = view.getContext();
if (!isBeingDestroyed && !hasSavedViewState) {
saveViewState(view);
}
@@ -1071,7 +1075,7 @@ public abstract class Controller {
}
if (isBeingDestroyed) {
performDestroy();
performDestroy(context);
}
}
@@ -1148,9 +1152,13 @@ public abstract class Controller {
}
}
private void performDestroy() {
private void performDestroy(@Nullable Context context) {
if (context == null) {
context = getActivity();
}
if (isContextAvailable) {
onContextUnavailable(getActivity());
onContextUnavailable(context);
}
if (!destroyed) {