Java Code Examples for android.support.v4.app.fragment#setEnterTransition()

The following examples show how to use android.support.v4.app.fragment#setEnterTransition() . 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: 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 4
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 5
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();
}
 
Example 6
Source File: HolderFragment.java    From FragmentStateManager with MIT License 5 votes vote down vote up
@Override
public void showNewCounter(int count) {
    Fragment fragment = CountingFragment.newInstance(count);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fragment.setEnterTransition(new Slide(Gravity.END));
    }

    getChildFragmentManager().beginTransaction()
            .addToBackStack(null)
            .setReorderingAllowed(true)
            .replace(R.id.holderFrame, fragment)
            .commitAllowingStateLoss();
}
 
Example 7
Source File: MainActivity.java    From BLEMeshChat with Mozilla Public License 2.0 4 votes vote down vote up
@Override
    public void onMessageSelected(View identictionView, View usernameView, int messageId, int peerId) {
        // Create new fragment to add (Fragment B)
        Peer peer = mClient.getDataStore().getPeerById(peerId);
        if (peer == null) {
            Log.w(TAG, "Could not lookup peer. Cannot show profile");
            return;
        }

        setTitle(peer.getAlias());

//        identictionView.setTransitionName(getString(R.string.identicon_transition_name));
//        usernameView.setTransitionName(getString(R.string.username_transition_name));

        Fragment profileFragment = ProfileFragment.createForPeer(mClient.getDataStore(), peer);

//        final TransitionSet sharedElementTransition = new TransitionSet();
//        sharedElementTransition.addTransition(new ChangeBounds());
//        sharedElementTransition.addTransition(new ChangeTransform());
//        sharedElementTransition.setInterpolator(new AccelerateDecelerateInterpolator());
//        sharedElementTransition.setDuration(200);

        final TransitionSet slideTransition = new TransitionSet();
        slideTransition.addTransition(new Slide());
        slideTransition.setInterpolator(new AccelerateDecelerateInterpolator());
        slideTransition.setDuration(300);

        profileFragment.setEnterTransition(slideTransition);
        profileFragment.setReturnTransition(slideTransition);
//        profileFragment.setSharedElementEnterTransition(sharedElementTransition);
        profileFragment.setAllowEnterTransitionOverlap(false);
        profileFragment.setAllowReturnTransitionOverlap(false);

        // Message fragment performs an exit when Profile is added, and an enter when profile is popped
//        getFragmentManager().findFragmentByTag("messaging").setReenterTransition(slideTransition);
//        getFragmentManager().findFragmentByTag("messaging").setExitTransition(slideTransition);
//        getFragmentManager().findFragmentByTag("messaging").setSharedElementEnterTransition(sharedElementTransition);

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, profileFragment)
                .addToBackStack("profile")
//                .addSharedElement(identictionView, getString(R.string.identicon_transition_name))
//                .addSharedElement(usernameView, getString(R.string.username_transition_name))
                .commit();

        Bitmap bitmap = Notification.loadBitmapFromView(identictionView, 100, 100);
        Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
            public void onGenerated(Palette p) {
                mPalette = p;
                tintSystemBars(getResources().getColor(R.color.primary), getResources().getColor(R.color.primaryDark),
                        p.getVibrantColor(R.color.primary), p.getDarkVibrantColor(R.color.primaryDark));

            }
        });

        // Hack animate the drawer icon
        ValueAnimator drawerAnimator = ValueAnimator.ofFloat(0, 1f);
        drawerAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mDrawerToggle.onDrawerSlide(null, (Float) animation.getAnimatedValue());
            }
        });
        drawerAnimator.start();
    }