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);
}
});
}
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);
}
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)));
}
Aggregations