Reputation: 11
So I have a recycler view item that looks like this: Transition View Start
And I want to end up with this: Transition View End
The problem I keep getting is an index out-of-bounds exception. So the start has 6 views that transition and all have the appropriate transition name based on a unique id. The end view has all 6 but 2 more, the small water and thermometer images. Those two have no transition names. Yet they keep getting added to a list that stores the transition views. The following code is in DefaultSpecialEffectsController.java - line 701
void captureTransitioningViews(ArrayList<View> transitioningViews, View view) {
if (view instanceof ViewGroup) {
if (!transitioningViews.contains(view)
&& ViewCompat.getTransitionName(view) != null) {
transitioningViews.add(view);
}
ViewGroup viewGroup = (ViewGroup) view;
int count = viewGroup.getChildCount();
for (int i = 0; i < count; i++) {
View child = viewGroup.getChildAt(i);
if (child.getVisibility() == View.VISIBLE) {
captureTransitioningViews(transitioningViews, child);
}
}
} else {
if (!transitioningViews.contains(view)) {
transitioningViews.add(view);
}
}
}
And the index out of bounds occurs here FragmentTranstionImpl.java - line 176
void setNameOverridesReordered(final View sceneRoot,
final ArrayList<View> sharedElementsOut, final ArrayList<View> sharedElementsIn,
final ArrayList<String> inNames, final Map<String, String> nameOverrides) {
final int numSharedElements = sharedElementsIn.size();
final ArrayList<String> outNames = new ArrayList<>();
for (int i = 0; i < numSharedElements; i++) {
final View view = sharedElementsOut.get(i);
final String name = ViewCompat.getTransitionName(view);
outNames.add(name);
if (name == null) {
continue;
}
ViewCompat.setTransitionName(view, null);
final String inName = nameOverrides.get(name);
for (int j = 0; j < numSharedElements; j++) {
if (inName.equals(inNames.get(j))) {
ViewCompat.setTransitionName(sharedElementsIn.get(j), name);
break;
}
}
}
Is it possible to add the two small icons and in general any view, without them being in the starting transition view in recycler view in Fragment A?
Upvotes: 1
Views: 63
Reputation: 200120
This is a bug in Fragments , specifically fixed in Fragment 1.3.5. You'll need to upgrade to that version.
implementation "androidx.fragment:fragment:1.3.5"
Upvotes: 1