下面列出了android.support.annotation.TransitionRes#android.transition.TransitionInflater 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Prepares the shared element transition to the pager fragment, as well as the other transitions
* that affect the flow.
*/
private void prepareTransitions() {
setExitTransition(TransitionInflater.from(getContext())
.inflateTransition(R.transition.grid_exit_transition));
// A similar mapping is set at the ImagePagerFragment with a setEnterSharedElementCallback.
setExitSharedElementCallback(
new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
// Locate the ViewHolder for the clicked position.
RecyclerView.ViewHolder selectedViewHolder = recyclerView
.findViewHolderForAdapterPosition(MainActivity.currentPosition);
if (selectedViewHolder == null) {
return;
}
// Map the first shared element name to the child ImageView.
sharedElements
.put(names.get(0), selectedViewHolder.itemView.findViewById(R.id.card_image));
}
});
}
private static Transition loadTransition(Context context, TypedArray typedArray,
Transition currentValue, Transition defaultValue, int id) {
if (currentValue != defaultValue) {
return currentValue;
}
int transitionId = typedArray.getResourceId(id, 0);
Transition transition = defaultValue;
if (transitionId != 0 && transitionId != com.android.internal.R.transition.no_transition) {
TransitionInflater inflater = TransitionInflater.from(context);
transition = inflater.inflateTransition(transitionId);
if (transition instanceof TransitionSet &&
((TransitionSet)transition).getTransitionCount() == 0) {
transition = null;
}
}
return transition;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
TextView sportsTitle = findViewById(R.id.titleDetail);
ImageView sportsImage = findViewById(R.id.sportsImageDetail);
TextView sportsDetail = findViewById(R.id.subTitleDetail);
getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element));
Intent intent = getIntent();
String titleString = intent.getStringExtra("title");
int imageInt = intent.getIntExtra("image_resource", 0);
String details = intent.getStringExtra("details");
sportsTitle.setText(titleString);
Glide.with(this).load(imageInt).into(sportsImage);
sportsDetail.setText(details);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
TextView sportsTitle = findViewById(R.id.titleDetail);
ImageView sportsImage = findViewById(R.id.sportsImageDetail);
TextView sportsDetail = findViewById(R.id.subTitleDetail);
getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element));
Intent intent = getIntent();
String titleString = intent.getStringExtra("title");
int imageInt = intent.getIntExtra("image_resource", 0);
String details = intent.getStringExtra("details");
sportsTitle.setText(titleString);
Glide.with(this).load(imageInt).into(sportsImage);
sportsDetail.setText(details);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
TextView sportsTitle = findViewById(R.id.titleDetail);
ImageView sportsImage = findViewById(R.id.sportsImageDetail);
TextView sportsDetail = findViewById(R.id.subTitleDetail);
getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element));
Intent intent = getIntent();
String titleString = intent.getStringExtra("title");
int imageInt = intent.getIntExtra("image_resource", 0);
String details = intent.getStringExtra("details");
sportsTitle.setText(titleString);
Glide.with(this).load(imageInt).into(sportsImage);
sportsDetail.setText(details);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(getSupportActionBar()!=null) {
getSupportActionBar().hide();
}
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_image_ff);
photoView = findViewById(R.id.photoView);
Picasso.with(getApplicationContext()).load(getIntent().getStringExtra("photoURI")).into(photoView);
getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.image_transition));
photoView.setTransitionName("photoTransition");
}
private void switchToPreview(Uri uri) {
Fragment fragment = FragmentPreview.instance(uri);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
Slide slideTransition = new Slide(Gravity.LEFT);
slideTransition.setDuration(duration);
setExitTransition(slideTransition);
Slide slideTransition2 = new Slide(Gravity.RIGHT);
slideTransition2.setDuration(duration);
fragment.setEnterTransition(slideTransition2);
TransitionInflater inflater = TransitionInflater.from(getContext());
Transition transition = inflater.inflateTransition(R.transition.transition_default);
fragment.setSharedElementEnterTransition(transition);
}
getFragmentManager()
.beginTransaction()
.replace(R.id.frg_docker, fragment)
.addSharedElement(mBtnFindWrapper, ViewCompat.getTransitionName(mBtnFindWrapper))
.addToBackStack("select")
.commitAllowingStateLoss();
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
orderSelection = new OrderSelection();
selectedViewTransition = TransitionInflater.from(getContext())
.inflateTransition(R.transition.transition_selected_view);
binding.setProduct(getProduct());
binding.imgProduct.setImageDrawable(createProductImageDrawable(getProduct()));
binding.btnGo.setBackground(new ColorDrawable(ContextCompat.getColor(
getContext(), getProduct().color)));
initOrderStepOneView(binding.layoutStep1);
}
@SuppressLint("RtlHardcoded")
private TransitionAnimation createSlideAnimation(boolean forward, AnimationData animationData) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Transition enterTransition = forward ? new Slide(Gravity.RIGHT) : new Slide(Gravity.LEFT);
Transition exitTransition = forward ? new Slide(Gravity.LEFT) : new Slide(Gravity.RIGHT);
LollipopTransitionAnimation animation = new LollipopTransitionAnimation(enterTransition, exitTransition);
animation.setAllowEnterTransitionOverlap(false);
Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (currentFragment instanceof SharedElementProvider) {
SharedElementProvider sharedElementProvider = (SharedElementProvider) currentFragment;
View sharedElement = sharedElementProvider.getSharedElement(animationData);
String shareElementName = sharedElementProvider.getSharedElementName(animationData);
animation.addSharedElement(sharedElement, shareElementName);
Transition moveTransition = TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move);
moveTransition.setDuration(600);
animation.setSharedElementTransition(moveTransition);
}
return animation;
} else {
int enterAnimRes = forward ? R.anim.slide_in_right : R.anim.slide_in_left;
int exitAnimRes = forward ? R.anim.slide_out_left : R.anim.slide_out_right;
return new SimpleTransitionAnimation(enterAnimRes, exitAnimRes);
}
}
@TargetApi(21)
public static void navigateToAlbum(Activity context, long albumID, Pair<View, String> transitionViews) {
FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
Fragment fragment;
if (TimberUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) {
Transition changeImage = TransitionInflater.from(context).inflateTransition(R.transition.image_transform);
transaction.addSharedElement(transitionViews.first, transitionViews.second);
fragment = AlbumDetailFragment.newInstance(albumID, true, transitionViews.second);
fragment.setSharedElementEnterTransition(changeImage);
} else {
transaction.setCustomAnimations(R.anim.activity_fade_in,
R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out);
fragment = AlbumDetailFragment.newInstance(albumID, false, null);
}
transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.add(R.id.fragment_container, fragment);
transaction.addToBackStack(null).commit();
}
@TargetApi(21)
public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) {
FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
Fragment fragment;
if (TimberUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) {
Transition changeImage = TransitionInflater.from(context).inflateTransition(R.transition.image_transform);
transaction.addSharedElement(transitionViews.first, transitionViews.second);
fragment = ArtistDetailFragment.newInstance(artistID, true, transitionViews.second);
fragment.setSharedElementEnterTransition(changeImage);
} else {
transaction.setCustomAnimations(R.anim.activity_fade_in,
R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out);
fragment = ArtistDetailFragment.newInstance(artistID, false, null);
}
transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.add(R.id.fragment_container, fragment);
transaction.addToBackStack(null).commit();
}
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
switch (v.getId()) {
case R.id.exlpode:
transition = TransitionInflater.from(this).inflateTransition(R.transition.explode);
break;
case R.id.slide:
transition = TransitionInflater.from(this).inflateTransition(R.transition.slide);
break;
default:
break;
}
//退出时使用
getWindow().setExitTransition(transition);
//第一次进入时使用
getWindow().setEnterTransition(transition);
//再次进入时使用
getWindow().setReenterTransition(transition);
Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle();
Intent intent = new Intent(mContext, TweenedAnimationActivity.class);
startActivity(intent,bundle);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content);
ButterKnife.bind(this);
if (getIntent() != null) {
int avatar = getIntent().getIntExtra(getString(R.string.transition_shared_avatar), 0);
String title = getIntent().getStringExtra(getString(R.string.transition_shared_title));
if (avatar > 0) {
imageAvatar.setImageResource(avatar);
colorize(((BitmapDrawable) imageAvatar.getDrawable()).getBitmap());
}
if (title != null) {
textTitle.setText(title);
}
Transition transition =
TransitionInflater.from(this).inflateTransition(R.transition.slide_bottom);
getWindow().setEnterTransition(transition);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
pager.setAdapter(new AboutPagerAdapter(AboutActivity.this));
pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_normal));
pageIndicator.setViewPager(pager);
draggableFrame.addListener(
new ElasticDragDismissFrameLayout.SystemChromeFader(this) {
@Override
public void onDragDismissed() {
// if we drag dismiss downward then the default reversal of the enter
// transition would slide content upward which looks weird. So reverse it.
if (draggableFrame.getTranslationY() > 0) {
getWindow().setReturnTransition(
TransitionInflater.from(AboutActivity.this)
.inflateTransition(R.transition.about_return_downward));
}
finishAfterTransition();
}
});
}
@TargetApi(21) private void initTransitions() {
Window window = getActivity().getWindow();
window.setEnterTransition(
new ExplodeFadeEnterTransition(senderNameView, senderMailView, separatorLine));
window.setExitTransition(new ExcludedExplodeTransition());
window.setReenterTransition(new ExcludedExplodeTransition());
window.setReturnTransition(new ExcludedExplodeTransition());
TransitionSet textSizeSet = new TransitionSet();
textSizeSet.addTransition(
TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move));
TextSizeTransition textSizeTransition = new TextSizeTransition();
textSizeTransition.addTarget(R.id.subject);
textSizeTransition.addTarget(getString(R.string.shared_mail_subject));
textSizeSet.addTransition(textSizeTransition);
textSizeSet.setOrdering(TransitionSet.ORDERING_TOGETHER);
window.setSharedElementEnterTransition(textSizeSet);
getActivity().setEnterSharedElementCallback(
new TextSizeEnterSharedElementCallback(getActivity()));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setupVariables();
View v = inflater.inflate(R.layout.recycler_layout, container, false);
rv = v.findViewById(R.id.rv);
rv.setHasFixedSize(true);
rv.setFastScrollEnabled(false);
setupAdapter();
if (savedInstanceState == null) {
animateToolbar();
postponeEnterTransition();
}
setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition));
return v;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setupVariables();
View v = inflater.inflate(R.layout.overview_list, container, false);
list = (ListView) v.findViewById(R.id.list);
list.setFastScrollEnabled(true);
setupAdapter();
if (savedInstanceState == null) {
animateToolbar();
postponeEnterTransition();
}
setEnterTransition(new Slide(Gravity.LEFT));
setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition));
return v;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setupVariables();
View v = inflater.inflate(R.layout.recycler_layout, container, false);
rv = v.findViewById(R.id.rv);
rv.setLayoutManager(new LinearLayoutManager(getActivity()));
rv.setHasFixedSize(true);
rv.setVerticalScrollBarEnabled(false);
setupAdapter();
if (savedInstanceState == null) {
animateToolbar();
postponeEnterTransition();
}
setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition));
return v;
}
/**
* Sets up the transition for the exiting fragment
* @param fragment
*/
@TargetApi(21)
public void setupExitTransition(Context context, Fragment fragment) {
Transition fade = TransitionInflater
.from(context)
.inflateTransition(android.R.transition.fade);
fragment.setExitTransition(fade);
fragment.setReenterTransition(fade);
fragment.setExitSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
// Clearing must be done in the reentering fragment
// as this is called last. Otherwise, the app will crash during transition setup. Not sure, but might
// be a v4 support package bug.
if (clearSharedElements) {
names.clear();
sharedElements.clear();
clearSharedElements = false;
}
}
});
}
@TargetApi(21)
private void startFragment(AbstractFragment fragment) {
// Replace list fragment
FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction();
// Set up transitions
if (Utils.isLollipopOrLater()) {
fragment.setEnterTransition(
TransitionInflater.from(this).inflateTransition(R.transition.media_details));
fragment.setReturnTransition(null);
} else {
fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0);
}
fragTrans.replace(R.id.fragment_container, fragment)
.addToBackStack(null)
.commit();
}
public void setTransition() {
if (isHasTransition() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
// transition animation
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
Transition explode =
TransitionInflater.from(this).inflateTransition(android.R.transition.explode);
getWindow().setEnterTransition(explode);
}
}
@Override
public void onQrDataFound(final String data) {
Util.runOnMain(() -> {
((Vibrator)getSystemService(Context.VIBRATOR_SERVICE)).vibrate(50);
Uri uri = Uri.parse(data);
deviceLinkFragment.setLinkClickedListener(uri, DeviceActivity.this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
deviceAddFragment.setSharedElementReturnTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(R.transition.fragment_shared));
deviceAddFragment.setExitTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(android.R.transition.fade));
deviceLinkFragment.setSharedElementEnterTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(R.transition.fragment_shared));
deviceLinkFragment.setEnterTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(android.R.transition.fade));
getSupportFragmentManager().beginTransaction()
.addToBackStack(null)
.addSharedElement(deviceAddFragment.getDevicesImage(), "devices")
.replace(android.R.id.content, deviceLinkFragment)
.commit();
} else {
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.slide_from_bottom, R.anim.slide_to_bottom,
R.anim.slide_from_bottom, R.anim.slide_to_bottom)
.replace(android.R.id.content, deviceLinkFragment)
.addToBackStack(null)
.commit();
}
});
}
/**
* Prepares the shared element transition from and back to the grid fragment.
*/
private void prepareSharedElementTransition() {
Transition transition =
TransitionInflater.from(getContext())
.inflateTransition(R.transition.image_shared_element_transition);
setSharedElementEnterTransition(transition);
// A similar mapping is set at the GridFragment with a setExitSharedElementCallback.
setEnterSharedElementCallback(
new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
// Locate the image view at the primary fragment (the ImageFragment that is currently
// visible). To locate the fragment, call instantiateItem with the selection position.
// At this stage, the method will simply return the fragment at the position and will
// not create a new one.
Fragment currentFragment = (Fragment) viewPager.getAdapter()
.instantiateItem(viewPager, MainActivity.currentPosition);
View view = currentFragment.getView();
if (view == null) {
return;
}
// Map the first shared element name to the child ImageView.
sharedElements.put(names.get(0), view.findViewById(R.id.image));
}
});
}
/**
* Create a new instance with details for a given {@link Gallery}.
*
* @param context The context this runs in.
* @param gallery The gallery of which the details should be displayed.
* @return A newly instantiated fragment.
*/
public static DetailFragment newInstance(@NonNull Context context, @NonNull Gallery gallery,
@NonNull CameraPosition cameraPosition) {
DetailFragment fragment = new DetailFragment();
Bundle args = new Bundle();
args.putParcelable(IntentKeys.GALLERY, gallery);
args.putParcelable(IntentKeys.CAMERA_POSITION, cameraPosition);
fragment.setArguments(args);
final TransitionInflater inflater = TransitionInflater.from(context);
fragment.setSharedElementEnterTransition(
inflater.inflateTransition(R.transition.detail_shared_enter));
fragment.setEnterTransition(new Fade());
return fragment;
}
public void goAnimate(View view) {
//Resource file solution
ViewGroup root = findViewById(R.id.layout);
Scene scene = Scene.getSceneForLayout(root, R.layout.activity_main_end, this);
Transition transition = TransitionInflater.from(this)
.inflateTransition(R.transition.transition_move);
TransitionManager.go(scene, transition);
//Code only solution
// ViewGroup root = findViewById(R.id.layout);
// Scene scene = new Scene(root);
//
// Transition transition = new ChangeBounds();
// TransitionManager.beginDelayedTransition(root,transition);
//
// TextView textViewTop = findViewById(R.id.textViewTop);
// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)textViewTop.getLayoutParams();
// params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,1);
// params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
// textViewTop.setLayoutParams(params);
//
// TextView textViewBottom = findViewById(R.id.textViewBottom);
// params = (RelativeLayout.LayoutParams) textViewBottom.getLayoutParams();
// params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,0);
// params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1);
// textViewBottom.setLayoutParams(params);
//
// TransitionManager.go(scene);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_seat_selection);
pos = getIntent().getIntExtra("pos",0);
init();
regularFontChanger.replaceFonts((ViewGroup)this.findViewById(android.R.id.content));
Picasso.with(getApplicationContext()).load(GlobalData.posters[pos]).into(backdropIV);
Picasso.with(getApplicationContext()).load(GlobalData.posters[pos]).into(posterIV);
if(getIntent().getStringExtra("pos1").equals("Picture")){
posterIV.setVisibility(View.VISIBLE);
videoLL.setVisibility(View.GONE);
}
else{
posterIV.setVisibility(View.GONE);
videoLL.setVisibility(View.VISIBLE);
}
getWindow().setSharedElementEnterTransition(TransitionInflater.from(getApplicationContext()).inflateTransition(R.transition.detail_activity_enter_transition));
final Rotate3dAnimation rotate3dAnimation = new Rotate3dAnimation(0,-20,0,0,0,0);
rotate3dAnimation.setDuration(300);
rotate3dAnimation.setFillAfter(true);
rotate3dAnimation.setFillEnabled(true);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
moviePosterCV.startAnimation(rotate3dAnimation);
if(getIntent().getStringExtra("pos1").equals("Video")){
videoPlayer.seekTo(getIntent().getIntExtra("currentPos",0));
}
supportStartPostponedEnterTransition();
}
},200);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_ff);
photoView = findViewById(R.id.photoView);
Picasso.with(getApplicationContext()).load(getIntent().getStringExtra("photoURI")).into(photoView);
getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.image_transition));
photoView.setTransitionName("photoTransition");
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
postponeEnterTransition();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(android.R.transition.move));
}
}
@OnClick(R.id.btn_start_process)
void onClick(View view) {
String type = getType();
String rate = getRate();
String noise = getNoise();
Fragment fragment = FragmentProcess.instance(mUri, type, rate, noise);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
Slide slideTransition = new Slide(Gravity.LEFT);
slideTransition.setDuration(duration);
setExitTransition(slideTransition);
Slide slideTransition2 = new Slide(Gravity.RIGHT);
slideTransition2.setDuration(duration);
fragment.setEnterTransition(slideTransition2);
TransitionInflater inflater = TransitionInflater.from(getContext());
Transition transition = inflater.inflateTransition(R.transition.transition_default);
fragment.setSharedElementEnterTransition(transition);
}
getFragmentManager()
.beginTransaction()
.replace(R.id.frg_docker, fragment)
.addToBackStack("preview")
.addSharedElement(mIvPreview, ViewCompat.getTransitionName(mIvPreview))
.commitAllowingStateLoss();
}
@Override
public void onResponse(Call<Bitmap> call, Response<Bitmap> response) {
Bitmap image = response.body();
if (null == image) {
Toast.makeText(getActivity(), "缩放图片失败", Toast.LENGTH_LONG).show();
getFragmentManager().popBackStack();
return;
}
Fragment fragment = FragmentResult.instance(mUri);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
Slide slideTransition = new Slide(Gravity.LEFT);
slideTransition.setDuration(duration);
setExitTransition(slideTransition);
Slide slideTransition2 = new Slide(Gravity.RIGHT);
slideTransition2.setDuration(duration);
fragment.setEnterTransition(slideTransition2);
TransitionInflater inflater = TransitionInflater.from(getContext());
Transition transition = inflater.inflateTransition(R.transition.transition_default);
fragment.setSharedElementEnterTransition(transition);
}
IActivity activity = (IActivity) getActivity();
activity.setImage(image);
getFragmentManager()
.beginTransaction()
.replace(R.id.frg_docker, fragment)
.addSharedElement(mIvProcess, ViewCompat.getTransitionName(mIvProcess))
.commitAllowingStateLoss();
}