I have an activity which has Fragment StatsDetailFragment loaded by default.
On press of a button, I'm replacing the fragment with another using the following code.
getSupportFragmentManager().beginTransaction()
.replace(R.id.stats_detail_container, projectEntryListFragment, ProjectEntryListFragment.FRAGMENT_ID)
.addToBackStack(FRAGMENT_CHART)
.commit();
I'm setting up an Enter Transition for ProjectEntryListFragment using the custom transition class
public class RevealTransition extends Visibility {
private final Point mEpicenter;
private final int mSmallRadius;
private final int mBigRadius;
private final long mDuration;
public RevealTransition(Point epicenter, int smallRadius, int bigRadius, long duration) {
mEpicenter = epicenter;
mSmallRadius = smallRadius;
mBigRadius = bigRadius;
mDuration = duration;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
Animator animator = ViewAnimationUtils.createCircularReveal(view, mEpicenter.x, mEpicenter.y,
mSmallRadius, mBigRadius);
animator.setDuration(mDuration);
return new WrapperAnimator(animator);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
Animator animator = ViewAnimationUtils.createCircularReveal(view, mEpicenter.x, mEpicenter.y,
mBigRadius, mSmallRadius);
animator.setDuration(mDuration);
return new WrapperAnimator(animator);
}
}
The transition works well. But the problem I'm facing is that when the reveal animation is performed on ProjectEntryListFragment, the StatsDetailFragment is already removed and that results in the reveal animation playing on top of a blank background. I would prefer it to be played over the StatsDetailFragment so that the StatsDetailFragment is visible as the reveal transition is played on ProjectListFragment.
I tried just adding the new fragment, but that just gives me an error on popping the backstack.
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v4.app.Fragment.getAllowReturnTransitionOverlap()' on a null object reference
Any help will be hugely appreciated.