Skip to content

Commit b08788f

Browse files
fix(android): lifecycle listeners and states (#14189)
* fix(android): properly save the activity state * chore(android): add support to remove base-activity lifecycle and other related listeners
1 parent ba8d567 commit b08788f

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java

+34-4
Original file line numberDiff line numberDiff line change
@@ -1317,9 +1317,39 @@ public void addOnPrepareOptionsMenuEventListener(OnPrepareOptionsMenuEvent liste
13171317
onPrepareOptionsMenuListeners.add(new WeakReference<>(listener));
13181318
}
13191319

1320-
public void removeOnLifecycleEventListener(OnLifecycleEvent listener)
1320+
public boolean removeOnLifecycleEventListener(OnLifecycleEvent listener)
13211321
{
1322-
// TODO stub
1322+
return lifecycleListeners.remove(listener);
1323+
}
1324+
1325+
public boolean removeOnInstanceStateEventListener(OnInstanceStateEvent listener)
1326+
{
1327+
return instanceStateListeners.remove(listener);
1328+
}
1329+
1330+
public boolean removeOnWindowFocusChangedEventListener(OnWindowFocusChangedEvent listener)
1331+
{
1332+
return windowFocusChangedListeners.remove(listener);
1333+
}
1334+
1335+
public boolean removeInterceptOnBackPressedEventListener(interceptOnBackPressedEvent listener)
1336+
{
1337+
return interceptOnBackPressedListeners.remove(listener);
1338+
}
1339+
1340+
public boolean removeOnActivityResultListener(OnActivityResultEvent listener)
1341+
{
1342+
return onActivityResultListeners.remove(listener);
1343+
}
1344+
1345+
public boolean removeOnCreateOptionsMenuEventListener(OnCreateOptionsMenuEvent listener)
1346+
{
1347+
return onCreateOptionsMenuListeners.remove(listener);
1348+
}
1349+
1350+
public boolean removeOnPrepareOptionsMenuEventListener(OnPrepareOptionsMenuEvent listener)
1351+
{
1352+
return onPrepareOptionsMenuListeners.remove(listener);
13231353
}
13241354

13251355
private void dispatchCallback(String propertyName, KrollDict data)
@@ -1670,8 +1700,6 @@ protected void onDestroy()
16701700
@Override
16711701
protected void onSaveInstanceState(Bundle outState)
16721702
{
1673-
super.onSaveInstanceState(outState);
1674-
16751703
// If activity is being temporarily destroyed, then save settings to be restored when activity is recreated.
16761704
if (!isFinishing()) {
16771705
if (supportHelper != null) {
@@ -1692,6 +1720,8 @@ protected void onSaveInstanceState(Bundle outState)
16921720
}
16931721
}
16941722
}
1723+
1724+
super.onSaveInstanceState(outState);
16951725
}
16961726

16971727
@Override

0 commit comments

Comments
 (0)