Java源码示例:com.transitionseverywhere.TransitionManager

示例1
@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null) {
        return;
    }
    String artist = intent.getStringExtra("artist");
    String track = intent.getStringExtra("track");
    if (mViewGroup != null) {
        mViewGroup.setVisibility(View.VISIBLE);
        TransitionManager.beginDelayedTransition(mViewGroup, new ChangeText().setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN));
        if (mTitle != null) {
            mTitle.setText(track);
        }
        if (mText != null) {
            mText.setText(artist);
        }
    }

}
 
示例2
@Override
public void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback) {
    if(DispatcherUtils.isPreviousKeySameAsNewKey(traversal.origin, traversal.destination)) { //short circuit on same key
        callback.onTraversalCompleted();
        return;
    }
    final Object newKey = DispatcherUtils.getNewKey(traversal);
    int newKeyLayout = getLayout(newKey);

    final ViewGroup root = rootHolder.getRoot();
    final View previousView = root.getChildAt(0);
    DispatcherUtils.persistViewToStateAndNotifyRemoval(traversal, previousView);

    Context internalContext = traversal.createContext(newKey, baseContext);
    LayoutInflater layoutInflater = LayoutInflater.from(internalContext);
    final View newView = layoutInflater.inflate(newKeyLayout, root, false);

    DispatcherUtils.restoreViewFromState(traversal, newView);

    TransitionManager.beginDelayedTransition(root);
    if(previousView != null) {
        root.removeView(previousView);
    }
    root.addView(newView);
    callback.onTraversalCompleted();
}
 
示例3
private void onClose() {
    if (mOnVisibilityChangeListener != null) {
        mOnVisibilityChangeListener.onDismiss();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
            && mAdapter != null && mAdapter.getItemCount() > 0) {

        TransitionSet transition = new SizeTransition()
                .setDuration(ANIMATOR_MIN_SUGGESTION_DURATION)
                .setInterpolator(new LinearInterpolator())
                .addListener(mSuggestionsDismissListener);

        TransitionManager.beginDelayedTransition(mSearchOverlay, transition);

        mSuggestionsRegion.setLayoutParams(new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT,
                0));
    } else {
        animateDismiss(mSearchOverlay, mSearchRegion, mMenuItemId);
    }
}
 
示例4
@Override
protected void onShowSearchAnimationEnd() {
    mShowSearchAnimationFinished = true;

    if (mAdapter != null && mAdapter.getItemCount() > 0) {
        mSuggestionsView.setAdapter(mAdapter);

        int itemHeight = ((VerticalLinearLayoutManager) mSuggestionsView.getLayoutManager()).getChildHeight();
        int itemCount = mAdapter.getItemCount();

        long duration = Math.max(
                ANIMATOR_MIN_SUGGESTION_DURATION,
                Math.min(ANIMATOR_MAX_SUGGESTION_DURATION, itemCount * itemHeight));

        TransitionSet transition = new SizeTransition()
                .setDuration(duration)
                .setInterpolator(new LinearInterpolator());

        TransitionManager.beginDelayedTransition(mRoot, transition);

        mSuggestionsRegion.setLayoutParams(new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT));
    }
}
 
示例5
private void changeVisibility() {
    View music_info_cardView = findViewById(R.id.music_info_cardView);
    View control_layout = findViewById(R.id.control_layout);
    View seekbar_layout = findViewById(R.id.seekbar_layout);
    View lrcView = findViewById(R.id.other_lrc_view);
    View gradient = findViewById(R.id.gradient);
    View gradient_bottom = findViewById(R.id.gradient_bottom);
    View gradient_top = findViewById(R.id.gradient_top);
    TransitionManager.beginDelayedTransition(transitionsContainer, new TransitionSet().addTransition(new Fade()).setInterpolator(visible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator()));
    if (music_info_cardView.getVisibility() == VISIBLE) {
        music_info_cardView.setVisibility(GONE);
        control_layout.setVisibility(GONE);
        seekbar_layout.setVisibility(GONE);
        lrcView.setVisibility(VISIBLE);
        gradient.setVisibility(VISIBLE);
        gradient_bottom.setVisibility(VISIBLE);
        gradient_top.setVisibility(VISIBLE);
    } else {
        music_info_cardView.setVisibility(VISIBLE);
        control_layout.setVisibility(VISIBLE);
        seekbar_layout.setVisibility(VISIBLE);
        lrcView.setVisibility(GONE);
        gradient.setVisibility(GONE);
        gradient_bottom.setVisibility(GONE);
        gradient_top.setVisibility(GONE);
    }
    visible = !visible;
}
 
示例6
private void setEnterSearchAnimation() {
    TransitionSet transitionSet = new TransitionSet();
    if (mClearableEditText != null) {
        transitionSet.addTransition(
                new Slide(Gravity.TOP).addTarget(mClearableEditText).setDuration(150));
    }
    if (mCloseSearchButton != null) {
        transitionSet.addTransition(new Fade(Fade.IN).addTarget(mCloseSearchButton));
    }
    if (mLeftButton != null) {
        transitionSet.addTransition(new Fade(Fade.OUT).addTarget(mLeftButton));
    }
    if (mLeftImageButton != null) {
        transitionSet.addTransition(new Fade(Fade.OUT).addTarget(mLeftImageButton));
    }
    if (mTitleTextView != null) {
        transitionSet.addTransition(new Fade(Fade.OUT).addTarget(mTitleTextView).setDuration(
                150));
    }
    if (mRightButton != null) {
        transitionSet.addTransition(new Fade(Fade.OUT).addTarget(mRightButton));
    }
    if (mRightImageButton != null) {
        transitionSet.addTransition(new Fade(Fade.OUT).addTarget(mRightImageButton));
    }

    TransitionManager.beginDelayedTransition(this, transitionSet);
}
 
示例7
private void showPanel() {
    TransitionManager.beginDelayedTransition(mContainer);
    mTextView.setVisibility(View.VISIBLE);
    mTextView2.setVisibility(View.VISIBLE);
    mTextView3.setVisibility(View.VISIBLE);
    mTextView.postDelayed(mHidingRunnable, 2000);
    mIsShowing = true;
    mMoveDownY = 0;
    mMoveUpY = 0;
}
 
示例8
private void hidePanel() {
    mTextView.removeCallbacks(mHidingRunnable);
    TransitionManager.beginDelayedTransition(mContainer);
    mTextView.setVisibility(View.GONE);
    mTextView2.setVisibility(View.GONE);
    mTextView3.setVisibility(View.GONE);
    mIsShowing = false;
    mMoveDownY = 0;
    mMoveUpY = 0;
}
 
示例9
@Override
    protected void onCreate( Bundle savedInstanceState ){
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main );

        container = findViewById(R.id.container);
        button1 = findViewById( R.id.button1 );
        button2 = findViewById( R.id.button2 );


        music = findViewById( R.id.music );

        // music.setEnabled( false ); // if you want to disable click
//        PushDownAnim.setPushDownAnimTo( music )
//                .setScale( PushDownAnim.MODE_STATIC_DP, 2 )
//                .setOnClickListener( getClickListener() )
//                .setOnLongClickListener( getLongClickListener() );
//
//        PushDownAnim.setPushDownAnimTo( button1 )
//                .setOnClickListener( getClickListener() )
//                .setOnLongClickListener( getLongClickListener() );
//
//        PushDownAnim.setPushDownAnimTo( button2 )
//                .setOnClickListener( getClickListener() )
//                .setOnLongClickListener( getLongClickListener() );

//        [equal]
//        PushDownAnim.setPushDownAnimTo( button )
//                .setScale( PushDownAnim.MODE_SCALE , PushDownAnim.DEFAULT_PUSH_SCALE )
//                .setDurationPush( PushDownAnim.DEFAULT_PUSH_DURATION )
//                .setDurationRelease( PushDownAnim.DEFAULT_RELEASE_DURATION )
//                .setInterpolatorPush( PushDownAnim.DEFAULT_INTERPOLATOR )
//                .setInterpolatorRelease( PushDownAnim.DEFAULT_INTERPOLATOR
//                .setOnClickListener( getClickListener() )
//                .setOnLongClickListener( getLongClickListener() );
//        [equal]
        PushDownAnim.setPushDownAnimTo( music, button1, button2 )
                .setScale( PushDownAnim.MODE_STATIC_DP , 2 )
                .setDurationPush( PushDownAnim.DEFAULT_PUSH_DURATION )
                .setDurationRelease( PushDownAnim.DEFAULT_RELEASE_DURATION )
                .setInterpolatorPush( PushDownAnim.DEFAULT_INTERPOLATOR )
                .setInterpolatorRelease( PushDownAnim.DEFAULT_INTERPOLATOR )
                .setOnClickListener( getClickListener() )
                .setOnLongClickListener( getLongClickListener() );


        // delay show view to check PushDownAnim.MODE_STATIC_DP not calculate size of view is zero.
        button2.setVisibility(View.GONE);
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    TransitionSet set = new TransitionSet()
                            .addTransition(new Scale())
                            .addTransition(new Fade())
                            .setDuration(200)
                            .setInterpolator(new OvershootInterpolator(1.0f));
                    TransitionManager.beginDelayedTransition(container, set);
                    TransitionManager.beginDelayedTransition(container);
                    button2.setVisibility(View.VISIBLE);
                }
            }
        }, 1000);


    }
 
示例10
void bindDateView(TestBean s) {
    TransitionManager.beginDelayedTransition((ViewGroup) itemView, new ChangeText().setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_KEEP));
    mTv.setText(s.getName());
    mCheckBox.setVisibility(View.GONE);
}
 
示例11
private void setLeaveSearchAnimation() {
    TransitionManager.beginDelayedTransition(this);
}
 
示例12
private void showDetail() {
    if (mDetailContainer.getVisibility() != VISIBLE) {
        TransitionManager.beginDelayedTransition(this, new Explode());
        mDetailContainer.setVisibility(VISIBLE);
    }
}
 
示例13
private void dismissDetail() {
    if (mDetailContainer.getVisibility() == VISIBLE) {
        TransitionManager.beginDelayedTransition(this, new Explode());
        mDetailContainer.setVisibility(GONE);
    }
}