use of androidx.transition.Fade in project Transitions-Everywhere by andkulikov.
the class ExplodeAndEpicenterExample method letsExplodeIt.
private void letsExplodeIt(View clickedView) {
// save rect of view in screen coordinated
final Rect viewRect = new Rect();
clickedView.getGlobalVisibleRect(viewRect);
final Explode explode = new Explode();
explode.setEpicenterCallback(new Transition.EpicenterCallback() {
@Override
public Rect onGetEpicenter(Transition transition) {
return viewRect;
}
});
explode.excludeTarget(clickedView, true);
TransitionSet set = new TransitionSet().addTransition(explode).addTransition(new Fade().addTarget(clickedView)).addListener(new TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
transition.removeListener(this);
getActivity().onBackPressed();
}
});
TransitionManager.beginDelayedTransition(mRecyclerView, set);
// remove all views from Recycler View
mRecyclerView.setAdapter(null);
}
use of androidx.transition.Fade in project IITB-App by wncc.
the class Utils method updateSharedElementFragment.
public static void updateSharedElementFragment(final Fragment fragment, final Fragment currentFragment, Map<View, String> sharedElements) {
FragmentTransaction ft = currentFragment.getActivity().getSupportFragmentManager().beginTransaction();
Transition transition = new DetailsTransition();
/* Set up transitions */
fragment.setSharedElementEnterTransition(transition);
fragment.setEnterTransition(new Slide());
currentFragment.setExitTransition(new Fade());
fragment.setSharedElementReturnTransition(transition);
/* Set transition for parent in case it is a child */
if (currentFragment instanceof TransitionTargetChild) {
((TransitionTargetChild) currentFragment).getParent().setExitTransition(new Fade());
}
transition.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
}
@Override
public void onTransitionEnd(Transition transition) {
if (fragment instanceof TransitionTargetFragment) {
((TransitionTargetFragment) fragment).transitionEnd();
}
if (currentFragment instanceof TransitionTargetFragment) {
((TransitionTargetFragment) currentFragment).transitionEnd();
}
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
/* Add all shared elements */
for (Map.Entry<View, String> entry : sharedElements.entrySet()) {
ft.addSharedElement(entry.getKey(), entry.getValue());
}
/* Update the fragment */
ft.replace(R.id.framelayout_for_fragment, fragment, getTag(fragment)).addToBackStack(getTag(fragment)).commit();
}
use of androidx.transition.Fade in project Transitions-Everywhere by andkulikov.
the class ScaleSample method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_scale, container, false);
final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
final TextView text1 = transitionsContainer.findViewById(R.id.text1);
transitionsContainer.findViewById(R.id.button1).setOnClickListener(new VisibleToggleClickListener() {
@Override
protected void changeVisibility(boolean visible) {
TransitionManager.beginDelayedTransition(transitionsContainer, new Scale());
text1.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
});
final TextView text2 = transitionsContainer.findViewById(R.id.text2);
transitionsContainer.findViewById(R.id.button2).setOnClickListener(new VisibleToggleClickListener() {
@Override
protected void changeVisibility(boolean visible) {
TransitionSet set = new TransitionSet().addTransition(new Scale(0.7f)).addTransition(new Fade()).setInterpolator(visible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
TransitionManager.beginDelayedTransition(transitionsContainer, set);
text2.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
});
return view;
}
Aggregations