use of androidx.transition.TransitionSet 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.TransitionSet in project Transitions-Everywhere by andkulikov.
the class ImageTransformSample method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_image_transform, container, false);
final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
final ImageView imageView = transitionsContainer.findViewById(R.id.image);
imageView.setOnClickListener(new View.OnClickListener() {
boolean mExpanded;
@Override
public void onClick(View v) {
mExpanded = !mExpanded;
TransitionManager.beginDelayedTransition(transitionsContainer, new TransitionSet().addTransition(new ChangeBounds()).addTransition(new ChangeImageTransform()));
ViewGroup.LayoutParams params = imageView.getLayoutParams();
params.height = mExpanded ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
imageView.setLayoutParams(params);
imageView.setScaleType(mExpanded ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_CENTER);
}
});
return view;
}
use of androidx.transition.TransitionSet 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