skydoves / TransformationLayout

🌠 Transform between two Views, Activities, and Fragments, or a View to a Fragment with container transform animations for Android.
Apache License 2.0
2.38k stars 194 forks source link

It not working with navigation component #20

Open sunny0092 opened 3 years ago

sunny0092 commented 3 years ago

Please complete the following information:

Describe the Bug: I using navigation component call Home fragment => Home Detail Fragment, it not working with navigation component. Can you please give me more instructions

====>RecyclerView Adapter

 holder.binding.transformationLayout.transitionName = data[position].id.toString()
        holder.binding.layoutRoot.setOnClickListener {
            onItemClickListener?.let {
                onItemClickListener?.onItemClick(
                    holder.binding.transformationLayout,
                    holder.binding.transformationLayout,
                    data[position]
                )
            }
        }

====>Home Fragment

  override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        onTransformationStartContainer()
    }

  val bundle = itemView.getBundle(Constants.PARAMS_LAYOUT_KEY)
        bundle.putParcelable("detail_feature_key", item)
        val extras = FragmentNavigatorExtras(view to Constants.PARAMS_LAYOUT_KEY)
        findNavController().navigate(
            R.id.action_global_homeFeatureDetailFragment,
            bundle,
            null,
            extras
        )

=====>Home Detail Fragment

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move)
        arguments?.let {
            paramsLayout = it.getParcelable(PARAMS_LAYOUT_KEY)
            if(paramsLayout != null) {
                onTransformationEndContainer(paramsLayout)
            }
        }
    }
skydoves commented 3 years ago

Hi, onTransformationStartContainer() and onTransformationEndContainer must be called before super.onCreate.

sunny0092 commented 3 years ago

I have followed the instructions but still have not solved the problem, when clicking on the item it blinks https://drive.google.com/drive/folders/1nl08FknTsuXeqzyD_FrzCBRQGYIMpBWp?usp=sharing