Java Code Examples for android.support.v4.app.Fragment#setSharedElementEnterTransition()

The following examples show how to use android.support.v4.app.Fragment#setSharedElementEnterTransition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentSelect.java    From imageres_resolution with MIT License 6 votes vote down vote up
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();
}
 
Example 2
Source File: ScreenCoordinator.java    From native-navigation with MIT License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupFragmentForSharedElement(
        Fragment outFragment, Fragment inFragment, FragmentTransaction transaction, Bundle options) {
  FragmentSharedElementTransition transition = new FragmentSharedElementTransition();
  inFragment.setSharedElementEnterTransition(transition);
  inFragment.setSharedElementReturnTransition(transition);
  Fade fade = new Fade();
  inFragment.setEnterTransition(fade);
  inFragment.setReturnTransition(fade);
  ViewGroup rootView = (ViewGroup) outFragment.getView();
  ViewGroup transitionGroup = ViewUtils.findViewGroupWithTag(
          rootView,
          R.id.react_shared_element_group_id,
          options.getString(TRANSITION_GROUP));
  AutoSharedElementCallback.addSharedElementsToFragmentTransaction(transaction, transitionGroup);
}
 
Example 3
Source File: NavigationUtils.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
@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();

}
 
Example 4
Source File: NavigationUtils.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
@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();

}
 
Example 5
Source File: Demo0Fragment.java    From Android-UtilCode with Apache License 2.0 5 votes vote down vote up
private Fragment addSharedElement(Fragment fragment) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fragment.setSharedElementEnterTransition(new DetailTransition());
        fragment.setEnterTransition(new Fade());
        fragment.setSharedElementReturnTransition(new DetailTransition());
    }
    return fragment;
}
 
Example 6
Source File: FragmentPreview.java    From imageres_resolution with MIT License 5 votes vote down vote up
@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();
}
 
Example 7
Source File: FragmentProcess.java    From imageres_resolution with MIT License 5 votes vote down vote up
@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();
}