Search in sources :

Example 1 with SharedElementCallback

use of android.support.v4.app.SharedElementCallback in project kickmaterial by byoutline.

the class ProjectDetailsActivity method animateAlphaAfterTransition.

private void animateAlphaAfterTransition(final View view) {
    view.setAlpha(0);
    ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {

        @Override
        public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
            Animator alphaAnimator = AnimatorUtils.getAlphaAnimator(view);
            alphaAnimator.setDuration(600);
            alphaAnimator.start();
            ActivityCompat.setEnterSharedElementCallback(ProjectDetailsActivity.this, null);
        }
    });
}
Also used : Animator(android.animation.Animator) SharedElementCallback(android.support.v4.app.SharedElementCallback) View(android.view.View) ObservableScrollView(com.byoutline.kickmaterial.views.ObservableScrollView)

Example 2 with SharedElementCallback

use of android.support.v4.app.SharedElementCallback in project Douya by DreaminginCodeZH.

the class BroadcastFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mBroadcastAndCommentListResource = BroadcastAndCommentListResource.attachTo(mBroadcastId, mBroadcast, this);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setTitle(getTitle());
    activity.setSupportActionBar(mToolbar);
    mContainerLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ActivityCompat.finishAfterTransition(getActivity());
        }
    });
    ViewCompat.setTransitionName(mSharedView, Broadcast.makeTransitionName(mBroadcastId));
    // This magically gives better visual effect when the broadcast is partially visible. Using
    // setEnterSharedElementCallback() disables this hack when no transition is used to start
    // this Activity.
    ActivityCompat.setEnterSharedElementCallback(activity, new SharedElementCallback() {

        @Override
        public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
            mBroadcastCommentList.scrollToPosition(0);
        }
    });
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mBroadcastAndCommentListResource.loadBroadcast();
            mBroadcastAndCommentListResource.loadCommentList(false);
        }
    });
    mBroadcastCommentList.setHasFixedSize(true);
    mBroadcastCommentList.setItemAnimator(new NoChangeAnimationItemAnimator());
    mBroadcastCommentList.setLayoutManager(new LinearLayoutManager(activity));
    mBroadcastAdapter = new SingleBroadcastAdapter(null, this);
    setBroadcast(mBroadcastAndCommentListResource.getBroadcast());
    mCommentAdapter = new CommentAdapter(mBroadcastAndCommentListResource.getCommentList(), new ClickableSimpleAdapter.OnItemClickListener<Comment, CommentAdapter.ViewHolder>() {

        @Override
        public void onItemClick(RecyclerView parent, Comment item, CommentAdapter.ViewHolder holder) {
            onShowCommentAction(item);
        }
    });
    mAdapter = new LoadMoreAdapter(R.layout.load_more_item, mBroadcastAdapter, mCommentAdapter);
    mBroadcastCommentList.setAdapter(mAdapter);
    mBroadcastCommentList.addOnScrollListener(new OnVerticalScrollListener() {

        public void onScrolledToBottom() {
            mBroadcastAndCommentListResource.loadCommentList(true);
        }
    });
    CheatSheetUtils.setup(mSendButton);
    mSendButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            onSendComment();
        }
    });
    updateSendCommentStatus();
    if (savedInstanceState == null) {
        if (mShowSendComment) {
            TransitionUtils.postAfterTransition(this, new Runnable() {

                @Override
                public void run() {
                    onShowSendComment();
                }
            });
        }
    }
    TransitionUtils.setEnterReturnExplode(this);
    TransitionUtils.setupTransitionOnActivityCreated(this);
}
Also used : Comment(me.zhanghai.android.douya.network.api.info.apiv2.Comment) AppCompatActivity(android.support.v7.app.AppCompatActivity) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) SharedElementCallback(android.support.v4.app.SharedElementCallback) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)

Example 3 with SharedElementCallback

use of android.support.v4.app.SharedElementCallback in project kickmaterial by byoutline.

the class CategoriesListActivity method launchPostTransitionAnimations.

private void launchPostTransitionAnimations() {
    if (category != null) {
        int color = ContextCompat.getColor(this, category.colorResId);
        binding.categoryCircleIv.setColorFilter(color);
        binding.selectedCategoryIv.setImageResource(category.drawableResId);
        binding.selectCategoryTv.setBackgroundColor(color);
        binding.selectCategoryTv.getBackground().setAlpha(85);
    }
    if (LUtils.hasL()) {
        binding.closeCategoriesIv.setScaleX(0);
        binding.closeCategoriesIv.setScaleY(0);
        ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {

            @Override
            public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                binding.closeCategoriesIv.postDelayed(() -> {
                    // remove listener, we do not want to trigger this animation on exit
                    ActivityCompat.setEnterSharedElementCallback(CategoriesListActivity.this, null);
                    if (isFinishing()) {
                        return;
                    }
                    AnimatorSet closeCategoryAnim = AnimatorUtils.getScaleAnimator(binding.closeCategoriesIv, 0, 1);
                    closeCategoryAnim.setInterpolator(new OvershootInterpolator());
                    closeCategoryAnim.start();
                }, 160);
            }
        });
    }
    binding.categoriesRv.post(() -> binding.categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_from_bottom)));
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) AnimatorSet(android.animation.AnimatorSet) SharedElementCallback(android.support.v4.app.SharedElementCallback) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

SharedElementCallback (android.support.v4.app.SharedElementCallback)3 View (android.view.View)3 RecyclerView (android.support.v7.widget.RecyclerView)2 Animator (android.animation.Animator)1 AnimatorSet (android.animation.AnimatorSet)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 BindView (butterknife.BindView)1 ObservableScrollView (com.byoutline.kickmaterial.views.ObservableScrollView)1 Comment (me.zhanghai.android.douya.network.api.info.apiv2.Comment)1 LoadMoreAdapter (me.zhanghai.android.douya.ui.LoadMoreAdapter)1 NoChangeAnimationItemAnimator (me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)1 OnVerticalScrollListener (me.zhanghai.android.douya.ui.OnVerticalScrollListener)1