androidx.transition.TransitionManager Java Examples

The following examples show how to use androidx.transition.TransitionManager. 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: MainActivity.java    From c3nav-android with Apache License 2.0 6 votes vote down vote up
protected void showLogoScreen() {
    if (!splashScreenDone) {
        logoScreen.setVisibility(View.VISIBLE);
        skipSplash(false);
    } else if (logoScreenIsVisible || loginScreenIsActive) {
        TransitionManager.go(new Scene((ViewGroup) logoScreen.getParent()), new AutoTransition());
    } else {
        TransitionManager.go(new Scene((ViewGroup) logoScreen.getParent()), new Slide(Gravity.RIGHT));
    }
    logoScreen.setVisibility(View.VISIBLE);
    logoScreenMessage.setVisibility(View.GONE);
    authUsername.setVisibility(View.GONE);
    authPassword.setVisibility(View.GONE);
    authMessage.setVisibility(View.GONE);
    authLoginButton.setVisibility(View.GONE);
    logoScreenIsVisible = true;
}
 
Example #2
Source File: ListVideoUtil.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 如果是5.0的动画开始位置
 */
private void resolveMaterialAnimation() {
    listItemRect = new int[2];
    listItemSize = new int[2];
    saveLocationStatus(context, hideStatusBar, hideActionBar);
    FrameLayout.LayoutParams lpParent = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundColor(Color.BLACK);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(listItemSize[0], listItemSize[1]);
    lp.setMargins(listItemRect[0], listItemRect[1], 0, 0);
    frameLayout.addView(gsyVideoPlayer, lp);
    fullViewContainer.addView(frameLayout, lpParent);
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            //开始动画
            TransitionManager.beginDelayedTransition(fullViewContainer);
            resolveMaterialFullVideoShow(gsyVideoPlayer);
            resolveChangeFirstLogic(600);
        }
    }, 300);
}
 
Example #3
Source File: TransitionMusicLibraryDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/**
 * Add or replace the RecyclerView containing the list of albums with a new RecyclerView that is
 * either a list/grid and sorted/unsorted according to the given arguments.
 */
private void setList(boolean listTypeGrid, boolean listSorted, Transition transition) {
  this.listTypeGrid = listTypeGrid;
  this.listSorted = listSorted;

  // Use a Transition to animate the removal and addition of the RecyclerViews.
  RecyclerView recyclerView = createRecyclerView(listTypeGrid);
  transition.addTarget(recyclerView);
  View currentRecyclerView = listContainer.getChildAt(0);
  if (currentRecyclerView != null) {
    transition.addTarget(currentRecyclerView);
  }
  TransitionManager.beginDelayedTransition(listContainer, transition);

  AlbumsAdapter adapter = new AlbumsAdapter(this, listTypeGrid);
  recyclerView.setAdapter(adapter);
  List<Album> albums = new ArrayList<>(MusicData.ALBUMS);
  if (!listSorted) {
    Collections.reverse(albums);
  }
  adapter.submitList(albums);

  listContainer.removeAllViews();
  listContainer.addView(recyclerView);
}
 
Example #4
Source File: TransitionContainerTransformViewDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void showEndView(@Nullable View startView) {
  // Save a reference to the start view that triggered the transition in order to know which view
  // to transition into during the return transition.
  this.startView = startView;

  // Construct a container transform transition between two views.
  MaterialContainerTransform transition = buildContainerTransform(true);
  transition.setStartView(startView);
  transition.setEndView(endCard);

  // Add a single target to avoid the container transform from running on both the start
  // and end view
  transition.addTarget(startView);

  // Trigger the container transform transition.
  TransitionManager.beginDelayedTransition(root, transition);
  if (startView != null) {
    startView.setVisibility(View.INVISIBLE);
  }
  if (endCard != null) {
    endCard.setVisibility(View.VISIBLE);
  }
}
 
Example #5
Source File: TransitionContainerTransformViewDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void showStartView() {
  // Construct a container transform transition between two views.
  MaterialContainerTransform transition = buildContainerTransform(false);
  transition.setStartView(endCard);
  transition.setEndView(startView);

  // Add a single target to avoid the container transform from running on both the start
  // and end view
  transition.addTarget(startView);

  // Trigger the container transform transition.
  TransitionManager.beginDelayedTransition(root, transition);
  if (startView != null) {
    startView.setVisibility(View.VISIBLE);
  }
  if (endCard != null) {
    endCard.setVisibility(View.INVISIBLE);
  }
}
 
Example #6
Source File: EditImageActivity.java    From PhotoEditor with MIT License 6 votes vote down vote up
void showFilter(boolean isVisible) {
    mIsFilterVisible = isVisible;
    mConstraintSet.clone(mRootView);

    if (isVisible) {
        mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.START);
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START,
                ConstraintSet.PARENT_ID, ConstraintSet.START);
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.END,
                ConstraintSet.PARENT_ID, ConstraintSet.END);
    } else {
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START,
                ConstraintSet.PARENT_ID, ConstraintSet.END);
        mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.END);
    }

    ChangeBounds changeBounds = new ChangeBounds();
    changeBounds.setDuration(350);
    changeBounds.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
    TransitionManager.beginDelayedTransition(mRootView, changeBounds);

    mConstraintSet.applyTo(mRootView);
}
 
Example #7
Source File: MainActivity.java    From c3nav-android with Apache License 2.0 6 votes vote down vote up
protected void showLoginScreen(String message) {
    if (!logoScreenIsVisible) showLogoScreen();
    logoScreenMessage.setText(R.string.auth_title);
    authMessage.setText(message);
    authUsername.setEnabled(true);
    authPassword.setEnabled(true);
    authLoginButton.setEnabled(true);

    if (loginScreenIsActive) return;

    logoScreen.postDelayed(new Runnable() {
        @Override
        public void run() {
            TransitionManager.go(new Scene((ViewGroup) logoScreen.getParent()), new AutoTransition());
            logoScreenMessage.setVisibility(View.VISIBLE);
            authUsername.setVisibility(View.VISIBLE);
            authPassword.setVisibility(View.VISIBLE);
            authMessage.setVisibility(View.VISIBLE);
            authLoginButton.setVisibility(View.VISIBLE);
        }
    }, 500);
    loginScreenIsActive = true;
}
 
Example #8
Source File: ChangeTextSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_change_text, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final TextView textView = transitionsContainer.findViewById(R.id.text1);

    textView.setText(TEXT_1);
    textView.setOnClickListener(new View.OnClickListener() {

        boolean mSecondText;

        @Override
        public void onClick(View v) {
            mSecondText = !mSecondText;
            TransitionManager.beginDelayedTransition(transitionsContainer,
                new ChangeText().setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN));
            textView.setText(mSecondText ? TEXT_2 : TEXT_1);
        }

    });

    return view;
}
 
Example #9
Source File: AutoTransitionSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_autotransition, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final TextView text = transitionsContainer.findViewById(R.id.text);

    transitionsContainer.findViewById(R.id.button).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionManager.beginDelayedTransition(transitionsContainer);
            // it is the same as
            // TransitionManager.beginDelayedTransition(transitionsContainer, new AutoTransition());
            // where AutoTransition is the set of Fade and ChangeBounds transitions
            text.setVisibility(visible ? View.VISIBLE : View.GONE);
        }

    });

    return view;
}
 
Example #10
Source File: ScenesSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(final RadioGroup group, int checkedId) {
    switch (checkedId) {
        case R.id.select_scene_1: {
            // You can start an automatic transition with TransitionManager.go().
            TransitionManager.go(mScene1);
            break;
        }
        case R.id.select_scene_2: {
            TransitionSet set = new TransitionSet();
            Slide slide = new Slide(Gravity.LEFT);
            slide.addTarget(R.id.transition_title);
            set.addTransition(slide);
            set.addTransition(new ChangeBounds());
            set.setOrdering(TransitionSet.ORDERING_TOGETHER);
            set.setDuration(350);
            TransitionManager.go(mScene2, set);
            break;
        }
        case R.id.select_scene_3: {
            // You can also start a transition with a custom TransitionManager.
            mTransitionManagerForScene3.transitionTo(mScene3);
            break;
        }
    }
}
 
Example #11
Source File: SlideSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_slide, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final TextView text = transitionsContainer.findViewById(R.id.text);

    transitionsContainer.findViewById(R.id.button).setOnClickListener(new VisibleToggleClickListener() {
        @Override
        protected void changeVisibility(boolean visible) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Slide(Gravity.RIGHT));
            text.setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    });

    return view;
}
 
Example #12
Source File: RotateSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_rotate, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final View icon = transitionsContainer.findViewById(R.id.icon);

    icon.setOnClickListener(new View.OnClickListener() {

        boolean mRotated;

        @Override
        public void onClick(View v) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Rotate());

            mRotated = !mRotated;
            icon.setRotation(mRotated ? 135 : 0);
        }

    });

    return view;
}
 
Example #13
Source File: RecolorSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_recolor, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final Button button = transitionsContainer.findViewById(R.id.button1);

    button.setOnClickListener(new View.OnClickListener() {

        boolean mColorsInverted;

        @Override
        public void onClick(View v) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Recolor());

            mColorsInverted = !mColorsInverted;
            button.setTextColor(getResources().getColor(!mColorsInverted ? R.color.second_accent : R.color.accent));
            button.setBackgroundDrawable(
                new ColorDrawable(getResources().getColor(!mColorsInverted ? R.color.accent : R.color.second_accent)));
        }

    });

    return view;
}
 
Example #14
Source File: EditImageActivity.java    From indigenous-android with GNU General Public License v3.0 6 votes vote down vote up
void showFilter(boolean isVisible) {
    mIsFilterVisible = isVisible;
    mConstraintSet.clone(mRootView);

    if (isVisible) {
        mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.START);
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START,
                ConstraintSet.PARENT_ID, ConstraintSet.START);
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.END,
                ConstraintSet.PARENT_ID, ConstraintSet.END);
    } else {
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START,
                ConstraintSet.PARENT_ID, ConstraintSet.END);
        mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.END);
    }

    ChangeBounds changeBounds = new ChangeBounds();
    changeBounds.setDuration(350);
    changeBounds.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
    TransitionManager.beginDelayedTransition(mRootView, changeBounds);

    mConstraintSet.applyTo(mRootView);
}
 
Example #15
Source File: BottomNavigationMenuView.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
public void updateMenuView() {
  if (menu == null || buttons == null) {
    return;
  }

  final int menuSize = menu.size();
  if (menuSize != buttons.length) {
    // The size has changed. Rebuild menu view from scratch.
    buildMenuView();
    return;
  }

  int previousSelectedId = selectedItemId;

  for (int i = 0; i < menuSize; i++) {
    MenuItem item = menu.getItem(i);
    if (item.isChecked()) {
      selectedItemId = item.getItemId();
      selectedItemPosition = i;
    }
  }
  if (previousSelectedId != selectedItemId) {
    // Note: this has to be called before BottomNavigationItemView#initialize().
    TransitionManager.beginDelayedTransition(this, set);
  }

  boolean shifting = isShifting(labelVisibilityMode, menu.getVisibleItems().size());
  for (int i = 0; i < menuSize; i++) {
    presenter.setUpdateSuspended(true);
    buttons[i].setLabelVisibilityMode(labelVisibilityMode);
    buttons[i].setShifting(shifting);
    buttons[i].initialize((MenuItemImpl) menu.getItem(i), 0);
    presenter.setUpdateSuspended(false);
  }
}
 
Example #16
Source File: ListVideoUtil.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 动画回到正常效果
 */
private void resolveMaterialToNormal(final GSYVideoPlayer gsyVideoPlayer) {
    if (showFullAnimation && fullViewContainer instanceof FrameLayout) {
        int delay = orientationUtils.backToProtVideo();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                TransitionManager.beginDelayedTransition(fullViewContainer);
                FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) gsyVideoPlayer.getLayoutParams();
                lp.setMargins(listItemRect[0], listItemRect[1], 0, 0);
                lp.width = listItemSize[0];
                lp.height = listItemSize[1];
                //注意配置回来,不然动画效果会不对
                lp.gravity = Gravity.NO_GRAVITY;
                gsyVideoPlayer.setLayoutParams(lp);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        resolveToNormal();
                    }
                }, 400);
            }
        }, delay);
    } else {
        resolveToNormal();
    }
}
 
Example #17
Source File: GSYBaseVideoPlayer.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 回到正常效果
 */
@SuppressWarnings("ResourceType")
protected void backToNormal() {

    final ViewGroup vp = getViewGroup();

    final View oldF = vp.findViewById(getFullId());
    final GSYVideoPlayer gsyVideoPlayer;
    if (oldF != null) {
        gsyVideoPlayer = (GSYVideoPlayer) oldF;
        //如果暂停了
        pauseFullBackCoverLogic(gsyVideoPlayer);
        if (mShowFullAnimation) {
            TransitionManager.beginDelayedTransition(vp);

            LayoutParams lp = (LayoutParams) gsyVideoPlayer.getLayoutParams();
            lp.setMargins(mListItemRect[0], mListItemRect[1], 0, 0);
            lp.width = mListItemSize[0];
            lp.height = mListItemSize[1];
            //注意配置回来,不然动画效果会不对
            lp.gravity = Gravity.NO_GRAVITY;
            gsyVideoPlayer.setLayoutParams(lp);

            mInnerHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    resolveNormalVideoShow(oldF, vp, gsyVideoPlayer);
                }
            }, 400);
        } else {
            resolveNormalVideoShow(oldF, vp, gsyVideoPlayer);
        }

    } else {
        resolveNormalVideoShow(null, vp, null);
    }
}
 
Example #18
Source File: InterpolatorDurationStartDelaySample.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_interpolator, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final View button = transitionsContainer.findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {

        boolean mToRightAnimation;

        @Override
        public void onClick(View v) {
            mToRightAnimation = !mToRightAnimation;

            Transition transition = new ChangeBounds();
            transition.setDuration(mToRightAnimation ? 700 : 300);
            transition.setInterpolator(mToRightAnimation ? new FastOutSlowInInterpolator() : new AccelerateInterpolator());
            transition.setStartDelay(mToRightAnimation ? 0 : 500);
            TransitionManager.beginDelayedTransition(transitionsContainer, transition);

            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
            params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.TOP) : (Gravity.LEFT | Gravity.TOP);
            button.setLayoutParams(params);
        }

    });

    return view;
}
 
Example #19
Source File: TransitionFadeDemoFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void toggleFabVisibilityWithTransition() {
  ViewGroup sceneRoot = (ViewGroup) requireView();

  boolean entering = fadeFab.getVisibility() == View.GONE;
  MaterialFade materialFade = new MaterialFade();
  materialFade.setDuration(entering ? DURATION_ENTER : DURATION_RETURN);
  TransitionManager.beginDelayedTransition(sceneRoot, materialFade);
  fadeFab.setVisibility(entering ? View.VISIBLE : View.GONE);
  fadeButton.setText(
      entering
          ? R.string.cat_transition_fade_button_hide_fab
          : R.string.cat_transition_fade_button_show_fab);
}
 
Example #20
Source File: PathMotionSample.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_path, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final View button = transitionsContainer.findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {

        boolean mToRightAnimation;

        @Override
        public void onClick(View v) {
            final ChangeBounds changeBounds = new ChangeBounds();
            changeBounds.setPathMotion(new ArcMotion());
            changeBounds.setDuration(500);
            TransitionManager.beginDelayedTransition(transitionsContainer, changeBounds);

            mToRightAnimation = !mToRightAnimation;
            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
            params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.BOTTOM) :
                (Gravity.LEFT | Gravity.TOP);
            button.setLayoutParams(params);
        }

    });

    return view;
}
 
Example #21
Source File: UserActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawProfile(@Nullable User user) {
    if (user == null) {
        return;
    }
    if (user.isComplete() && userProfileView.getState() == UserProfileView.STATE_LOADING) {
        TransitionManager.beginDelayedTransition(container);
        userProfileView.drawUserInfo(this, user);
    } else if (userProfileView.getState() == UserProfileView.STATE_NORMAL) {
        userProfileView.setRippleButtonState(user);
    }
}
 
Example #22
Source File: MeActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawProfile() {
    TransitionManager.beginDelayedTransition(container);
    if (AuthManager.getInstance().getUser() != null) {
        profile.drawMeProfile(this, AuthManager.getInstance().getUser());
    }
    if (AuthManager.getInstance().getUser() != null) {
        drawTabTitles(AuthManager.getInstance().getUser());
    }
}
 
Example #23
Source File: ScrollGalleryView.java    From ScrollGalleryView with MIT License 5 votes vote down vote up
private void setThumbnailsTransition() {
    if (thumbnailsTransition == null && useDefaultThumbnailsTransition) {
        TransitionManager.beginDelayedTransition(horizontalScrollView);
    } else if (thumbnailsTransition != null) {
        TransitionManager.beginDelayedTransition(horizontalScrollView, thumbnailsTransition);
    }
}
 
Example #24
Source File: GSYVideoHelper.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 动画回到正常效果
 */
private void resolveMaterialToNormal(final GSYVideoPlayer gsyVideoPlayer) {
    if (mVideoOptionBuilder.isShowFullAnimation() && mFullViewContainer instanceof FrameLayout) {
        int delay = mOrientationUtils.backToProtVideo();
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                TransitionManager.beginDelayedTransition(mFullViewContainer);
                FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) gsyVideoPlayer.getLayoutParams();
                lp.setMargins(mNormalItemRect[0], mNormalItemRect[1], 0, 0);
                lp.width = mNormalItemSize[0];
                lp.height = mNormalItemSize[1];
                //注意配置回来,不然动画效果会不对
                lp.gravity = Gravity.NO_GRAVITY;
                gsyVideoPlayer.setLayoutParams(lp);
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        resolveToNormal();
                    }
                }, 400);
            }
        }, delay);
    } else {
        resolveToNormal();
    }
}
 
Example #25
Source File: MainActivity.java    From c3nav-android with Apache License 2.0 5 votes vote down vote up
protected void hideLoginScreen() {
    TransitionManager.go(new Scene((ViewGroup) logoScreen.getParent()), new Slide(Gravity.LEFT));
    logoScreen.setVisibility(View.GONE);
    logoScreenMessage.setVisibility(View.GONE);
    authUsername.setVisibility(View.GONE);
    authPassword.setVisibility(View.GONE);
    authMessage.setVisibility(View.GONE);
    authLoginButton.setVisibility(View.GONE);
    loginScreenIsActive = false;
    logoScreenIsVisible = false;
}
 
Example #26
Source File: ImageTransformSample.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #27
Source File: GSYVideoHelper.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 如果是5.0的动画开始位置
 */
private void resolveMaterialAnimation() {
    mNormalItemRect = new int[2];
    mNormalItemSize = new int[2];
    saveLocationStatus(mContext, mVideoOptionBuilder.isHideActionBar(), mVideoOptionBuilder.isHideStatusBar());
    FrameLayout.LayoutParams lpParent = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    FrameLayout frameLayout = new FrameLayout(mContext);
    frameLayout.setBackgroundColor(Color.BLACK);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(mNormalItemSize[0], mNormalItemSize[1]);
    lp.setMargins(mNormalItemRect[0], mNormalItemRect[1], 0, 0);
    frameLayout.addView(mGsyVideoPlayer, lp);
    if (mFullViewContainer != null) {
        mFullViewContainer.addView(frameLayout, lpParent);
    } else {
        mWindowViewContainer.addView(frameLayout, lpParent);
    }
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            //开始动画
            if (mFullViewContainer != null) {
                TransitionManager.beginDelayedTransition(mFullViewContainer);
            } else {
                TransitionManager.beginDelayedTransition(mWindowViewContainer);
            }
            resolveMaterialFullVideoShow(mGsyVideoPlayer);
            resolveChangeFirstLogic(600);
        }
    }, 300);
}
 
Example #28
Source File: WebRtcCallView.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void fadeControls(int visibility) {
  Transition transition = new AutoTransition().setDuration(TRANSITION_DURATION_MILLIS);

  TransitionManager.beginDelayedTransition(parent, transition);

  ConstraintSet constraintSet = new ConstraintSet();
  constraintSet.clone(parent);

  for (View view : visibleViewSet) {
    constraintSet.setVisibility(view.getId(), visibility);
  }

  constraintSet.applyTo(parent);
}
 
Example #29
Source File: UCropActivity.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
private void changeSelectedTab(int stateViewId) {
    TransitionManager.beginDelayedTransition((ViewGroup) findViewById(R.id.ucrop_photobox), mControlsTransition);

    mWrapperStateScale.findViewById(R.id.text_view_scale).setVisibility(stateViewId == R.id.state_scale ? View.VISIBLE : View.GONE);
    mWrapperStateAspectRatio.findViewById(R.id.text_view_crop).setVisibility(stateViewId == R.id.state_aspect_ratio ? View.VISIBLE : View.GONE);
    mWrapperStateRotate.findViewById(R.id.text_view_rotate).setVisibility(stateViewId == R.id.state_rotate ? View.VISIBLE : View.GONE);

}
 
Example #30
Source File: UCropFragment.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
private void changeSelectedTab(int stateViewId) {
    if (getView() != null) {
        TransitionManager.beginDelayedTransition((ViewGroup) getView().findViewById(R.id.ucrop_photobox), mControlsTransition);
    }
    mWrapperStateScale.findViewById(R.id.text_view_scale).setVisibility(stateViewId == R.id.state_scale ? View.VISIBLE : View.GONE);
    mWrapperStateAspectRatio.findViewById(R.id.text_view_crop).setVisibility(stateViewId == R.id.state_aspect_ratio ? View.VISIBLE : View.GONE);
    mWrapperStateRotate.findViewById(R.id.text_view_rotate).setVisibility(stateViewId == R.id.state_rotate ? View.VISIBLE : View.GONE);
}