@TargetApi(21) private void setCallback(final int enterPosition) { this.enterPosition = enterPosition; setExitSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { if (exitPosition != enterPosition && names.size() > 0 && exitPosition < sharedViews.length) { names.clear(); sharedElements.clear(); View view = sharedViews[exitPosition]; names.add(view.getTransitionName()); sharedElements.put(view.getTransitionName(), view); } setExitSharedElementCallback((SharedElementCallback) null); sharedViews = null; } }); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_restaurant); if (!getIntent().getExtras().containsKey(ARG_RESTAURANT)) { throw new RuntimeException("Restaurant missing."); } mRestaurant = getIntent().getExtras().getParcelable(ARG_RESTAURANT); ButterKnife.bind(this); initToolbar(); Glide.with(this).load(mRestaurant.mCoverUrl).into(mCover); initList(); initPresenter(); if (getIntent().getBooleanExtra(ARG_ANIMATION, false)) { mFoodRecycler.setAlpha(0); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { mFoodRecycler.animate().setDuration(500).alpha(1).start(); } }); } }
@TargetApi(21) private void setSharedElementCallback(final View view) { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { names.clear(); sharedElements.clear(); names.add(view.getTransitionName()); sharedElements.put(view.getTransitionName(), view); } }); }
private void initEnterSharedElement() { ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { sharedElements.clear(); sharedElements.put(SHARE_IMAGE, getBinding().image); } }); }
private void initEnterSharedElement() { ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { Image image = mImages[getBinding().pager.getCurrentItem()]; sharedElements.clear(); sharedElements.put(String.format("%s.image", image.url), getCurrent().getSharedElement()); } }); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void initViews() { showProgress(); realm = Realm.getDefaultInstance(); gankMeizis = realm.where(GankMeizi.class).findAll(); initRecycleView(); RxBus.getInstance().toObserverable(Intent.class) .compose(this.bindToLifecycle()) .subscribe(intent -> { imageIndex = intent.getIntExtra("index", -1); scrollIndex(); finishTask(); }, throwable -> { LogUtil.all(throwable.getMessage()); }); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { super.onMapSharedElements(names, sharedElements); String newTransitionName = gankMeizis.get(imageIndex).getUrl(); View newSharedView = mRecyclerView.findViewWithTag(newTransitionName); if (newSharedView != null) { names.clear(); names.add(newTransitionName); sharedElements.clear(); sharedElements.put(newTransitionName, newSharedView); } } }); }
void setEnterSharedElementCallback(final CallVoid1<SharedElementCallback> superCall, final SharedElementCallback callback) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setEnterSharedElementCallback(callback); } }
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall, final SharedElementCallback callback) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setExitSharedElementCallback(callback); } }
void setEnterSharedElementCallback(final CallVoid1<android.app.SharedElementCallback> superCall, final android.app.SharedElementCallback callback) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setEnterSharedElementCallback(callback); } }
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall, final SharedElementCallback listener) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setExitSharedElementCallback(listener); } }
void setExitSharedElementCallback(final CallVoid1<android.app.SharedElementCallback> superCall, final android.app.SharedElementCallback callback) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setExitSharedElementCallback(callback); } }
private void launchPostTransitionAnimations() { if (LUtils.hasL()) { ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() { @Override public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { binding.detailsContainer.postDelayed(() -> { binding.detailsContainer.startAnimation(LUtils.loadAnimationWithLInterpolator(ProjectDetailsActivity.this, R.anim.slide_from_top)); binding.scrollView.startAnimation(LUtils.loadAnimationWithLInterpolator(ProjectDetailsActivity.this, R.anim.slide_from_top_long)); }, 0); } }); } // categoriesRv.post(() -> categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_from_bottom))); }
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); } }); }
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))); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // image_detail_fragment.xml contains just an ImageView final View v = inflater.inflate(R.layout.anime_recycler_layout, container, false); if (!BuildUtils.isHoneycombOrLater()) v.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor(v.getContext())); mRecyclerView = (GridRecyclerView) v.findViewById(R.id.list); if (mRecyclerView != null) { mRecyclerView.setPopupTextColor(ThemeManager.getInstance().getTextColor()); mRecyclerView.setPopupBgColor(ThemeManager.getInstance().getPrimaryColor(v.getContext())); mRecyclerView.setThumbColor(ThemeManager.getInstance().getPrimaryDarkColor(v.getContext())); mRecyclerView.setTrackColor(ThemeManager.getInstance().getAccentColor(v.getContext())); } //mRecyclerView.setItemAnimator(AnimatorManager.getInstance().getAnimator()); mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_container); if (mSwipeRefreshLayout != null) { mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(ThemeManager.getInstance().getAccentColorResId())); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { updateFavorites(); } }); } ActivityCompat.setExitSharedElementCallback(getActivity(), new SharedElementCallback() { @Override public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) { int bitmapWidth = Math.round(screenBounds.width()); int bitmapHeight = Math.round(screenBounds.height()); Bitmap bitmap = null; if (bitmapWidth > 0 && bitmapHeight > 0) { Matrix matrix = new Matrix(); matrix.set(viewToGlobalMatrix); matrix.postTranslate(-screenBounds.left, -screenBounds.top); bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.concat(matrix); sharedElement.draw(canvas); } return bitmap; } }); return v; }
@Override public void initViews() { type = getArguments().getString(EXTRA_TYPE); showProgress(); realm = Realm.getDefaultInstance(); meizis = realm.where(MeiziTu.class) .equalTo("type", type) .findAll(); initRecycleView(); RxBus.getInstance().toObserverable(Intent.class) .compose(this.bindToLifecycle()) .subscribe(intent -> { imageIndex = intent.getIntExtra("index", -1); scrollIndex(); finishTask(); }, throwable -> { LogUtil.all(throwable.getMessage()); }); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { super.onMapSharedElements(names, sharedElements); String newTransitionName = meizis.get(imageIndex).getImageurl(); View newSharedView = mRecyclerView.findViewWithTag(newTransitionName); if (newSharedView != null) { names.clear(); names.add(newTransitionName); sharedElements.clear(); sharedElements.put(newTransitionName, newSharedView); } } }); }
@Override public void initViews() { cid = getArguments().getInt(EXTRA_CID); type = getArguments().getInt(EXTRA_TYPE); showProgress(); realm = Realm.getDefaultInstance(); doubanMeizis = realm.where(DoubanMeizi.class) .equalTo("type", type) .findAll(); initRecycleView(); RxBus.getInstance().toObserverable(Intent.class) .compose(this.bindToLifecycle()) .subscribe(intent -> { imageIndex = intent.getIntExtra("index", -1); scrollIndex(); finishTask(); }, throwable -> { LogUtil.all(throwable.getMessage()); }); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { super.onMapSharedElements(names, sharedElements); String newTransitionName = doubanMeizis.get(imageIndex).getUrl(); View newSharedView = mRecyclerView.findViewWithTag(newTransitionName); if (newSharedView != null) { names.clear(); names.add(newTransitionName); sharedElements.clear(); sharedElements.put(newTransitionName, newSharedView); } } }); }
@Override public void setEnterSharedElementCallback(final SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
@Override public void setEnterSharedElementCallback(final android.app.SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
@Override public void setExitSharedElementCallback(final SharedElementCallback listener) { super.setExitSharedElementCallback(listener); }
@Override public void setExitSharedElementCallback(final android.app.SharedElementCallback callback) { super.setExitSharedElementCallback(callback); }
@Override public void setExitSharedElementCallback(final SharedElementCallback callback) { super.setExitSharedElementCallback(callback); }
public void setEnterSharedElementCallback(final SharedElementCallback callback) { verifyMethodCalledFromDelegate("setEnterSharedElementCallback(SharedElementCallback)"); ((CallVoid1<SharedElementCallback>) mSuperListeners.pop()).call(callback); }
public void setExitSharedElementCallback(final SharedElementCallback callback) { verifyMethodCalledFromDelegate("setExitSharedElementCallback(SharedElementCallback)"); ((CallVoid1<SharedElementCallback>) mSuperListeners.pop()).call(callback); }
public void setEnterSharedElementCallback(final SharedElementCallback callback) { mFragmentDelegate.setEnterSharedElementCallback(callback); }
public void setExitSharedElementCallback(final SharedElementCallback callback) { mFragmentDelegate.setExitSharedElementCallback(callback); }
@Override public void setEnterSharedElementCallback(final SharedElementCallback callback) { delegate.setEnterSharedElementCallback(callback); }
@Override public void setExitSharedElementCallback(final SharedElementCallback callback) { delegate.setExitSharedElementCallback(callback); }
@Override public void super_setEnterSharedElementCallback(final SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
@Override public void super_setExitSharedElementCallback(final SharedElementCallback callback) { super.setExitSharedElementCallback(callback); }