/** * When {@link android.app.ActivityOptions#makeSceneTransitionAnimation(Activity, * android.view.View, String)} was used to start an Activity, <var>listener</var> * will be called to handle shared elements on the <i>launching</i> Activity. Most * calls will only come when returning from the started Activity. * This requires {@link Window#FEATURE_CONTENT_TRANSITIONS}. * * @param listener Used to manipulate shared element transitions on the launching Activity. */ public void setExitSharedElementCallback(SharedElementCallback listener) { ActivityCompat.setExitSharedElementCallback(this, listener); }
ActivityCompat.setExitSharedElementCallback(this, new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
@Override protected void initView() { mRlOriginal = findViewById(R.id.ry_original); mRlOriginal.setLayoutManager(new GridLayoutManager(this, 3)); mRlCompress = findViewById(R.id.ry_compress); mRlCompress.setLayoutManager(new GridLayoutManager(this, 3)); mBtnCompress = findViewById(R.id.btn_compress); ActivityCompat.setExitSharedElementCallback(this, new android.support.v4.app.SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { super.onMapSharedElements(names, sharedElements); LogUtils.w("initView--", PairHelp.PREVIEW_POSITION + ""); switch (mPreviewStatus) { case 0: sharedElements.put(PairHelp.transitionName(), mRlOriginal.findViewHolderForAdapterPosition(PairHelp.PREVIEW_POSITION).itemView); break; case 1: sharedElements.put(PairHelp.transitionName(), mRlCompress.findViewHolderForAdapterPosition(PairHelp.PREVIEW_POSITION).itemView); break; } } }); }