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.35k stars 190 forks source link

RecyclerView item disappears after Transformation #12

Closed masterj3y closed 4 years ago

masterj3y commented 4 years ago

when i Transform into DetailsActivity from a RecyclerView and then come back to RecyclerView, the item that i Clicked on will disappear

MovieDetialsActivity:

class MovieDetailsActivity : TransformationAppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_movie_details)

        intent.getParcelableExtra<Movie>(MOVIE_DETAILS_KEY)?.let {
            movieDetailsPoster.loadFromUrl(it.poster)
            movieDetailsTitle.text = it.title
        }
    }

    companion object {

        private const val MOVIE_DETAILS_KEY = "key:movie-details"

        fun startActivity(
            context: Context,
            transformationLayout: TransformationLayout,
            movie: Movie
        ) {
            val intent = Intent(context, MovieDetailsActivity::class.java)
            intent.putExtra(MOVIE_DETAILS_KEY, movie)
            TransformationCompat.startActivity(transformationLayout, intent)
        }
    }

}

calling Transform to MovieDetailsActivity from RecyclerViewCallback:

private fun showMovieDetails(movie: Movie, transformationLayout: TransformationLayout,  position: Int) {
   context?.let { MovieDetailsActivity.startActivity(it, transformationLayout, movie) }
}

RecyclerView item layout:

<?xml version="1.0" encoding="utf-8"?>
<com.skydoves.transformationlayout.TransformationLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/searchMoviesItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:transformation_duration="500"
    app:transformation_pathMode="arc">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="240dp"
        android:layout_margin="2dp">

        <ImageView
            android:id="@+id/searchMoviesItemPoster"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </FrameLayout>

</com.skydoves.transformationlayout.TransformationLayout>
skydoves commented 4 years ago

Hi @masterj3y, thank you for your issue :) Is the same issue occur in the other devices or emulator?

masterj3y commented 4 years ago

hi mate, yes i tried on Emulator but with the same Android version TBH.

skydoves commented 4 years ago

Hmm, Did you run using this demo project?

masterj3y commented 4 years ago

i ran it today, it works fine. as you can see my codes i wrote my code exactly like demo project. what's wrong?

masterj3y commented 4 years ago

the problem solved i put this code onTransformationStartContainer() before super.onCreate() of parent of that fragment which RecyclerView is in