Merge existing bundle with ActivityOptions
Use Bundle.putAll() to take both the bundle passed in to the startActivity(Intent, Bundle) and also the new created ActivityOptions bundle, so no extra info will be lost. Test: rebuild and add log to make sure all bundle info are kept Bug: 187471344 Change-Id: I802e17893b86fd4eacb812b4a7ab20b5167790fe
This commit is contained in:
@@ -78,6 +78,10 @@ public abstract class SettingsTransitionActivity extends FragmentActivity {
|
||||
super.startActivity(intent, options);
|
||||
return;
|
||||
}
|
||||
if (options != null) {
|
||||
super.startActivity(intent, getMergedBundleForTransition(options));
|
||||
return;
|
||||
}
|
||||
super.startActivity(intent, getActivityOptionsBundle(toolbar));
|
||||
}
|
||||
|
||||
@@ -110,6 +114,11 @@ public abstract class SettingsTransitionActivity extends FragmentActivity {
|
||||
super.startActivityForResult(intent, requestCode, options);
|
||||
return;
|
||||
}
|
||||
if (options != null) {
|
||||
super.startActivityForResult(intent, requestCode,
|
||||
getMergedBundleForTransition(options));
|
||||
return;
|
||||
}
|
||||
super.startActivityForResult(intent, requestCode, getActivityOptionsBundle(toolbar));
|
||||
}
|
||||
|
||||
@@ -133,4 +142,15 @@ public abstract class SettingsTransitionActivity extends FragmentActivity {
|
||||
return ActivityOptions.makeSceneTransitionAnimation(this, toolbar,
|
||||
"shared_element_view").toBundle();
|
||||
}
|
||||
|
||||
private Bundle getMergedBundleForTransition(@NonNull Bundle options) {
|
||||
final Toolbar toolbar = getToolbar();
|
||||
final Bundle mergedBundle = new Bundle();
|
||||
mergedBundle.putAll(options);
|
||||
final Bundle activityOptionsBundle = getActivityOptionsBundle(toolbar);
|
||||
if (activityOptionsBundle != null) {
|
||||
mergedBundle.putAll(activityOptionsBundle);
|
||||
}
|
||||
return mergedBundle;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user