Java Code Examples for android.transition.TransitionInflater#from()

The following examples show how to use android.transition.TransitionInflater#from() . 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: Fragment.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
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 3
Source File: DetailFragment.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
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: LockActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void initPushInAnim() {

        Window window = getWindow();
        window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);

        TransitionInflater inflater = TransitionInflater.from(mContext);
        Transition pushDownIn = inflater.inflateTransition(R.transition.explode_in);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.setEnterTransition(pushDownIn); // 第一次进入时使用
            window.setReenterTransition(pushDownIn); // 再次进入时使用
            window.setExitTransition(pushDownIn);
        }

    }
 
Example 7
Source File: SearchActivity.java    From Melophile with Apache License 2.0 4 votes vote down vote up
private Transition getTransition(@TransitionRes int transitionId) {
  TransitionInflater inflater = TransitionInflater.from(this);
  return inflater.inflateTransition(transitionId);
}