burhanrashid52 / PhotoEditor

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
MIT License
4.16k stars 992 forks source link

Shared Element Transition is not working #375

Closed wasim15185 closed 3 years ago

wasim15185 commented 3 years ago

Describe the bug If Shared Transition between ImageView of Fragment A , ImageView of Fragment B then it transition Work fine But If Shared Transition between PhotoEditorView of Fragment A , PhotoEditorView of Fragment B then it is not working

Some Preview

ImageView to ImageView Transition animation (and want to achieve this)

img

PhotoEditorView to PhotoEditorView Transition animation This is the PROBLEM img

I have Simplified the Code

" PhotoEditorView " is not working with Shared Element Transition between Fragment A to Fragment B

Code is Fragment A

<androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/edit_motion_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layoutDescription="@xml/fragment_main_edit_screen_xml_coordinator_layout_scene"
        tools:context=".screens.MainEditScreenFragment">

        <ja.burhanrashid52.photoeditor.PhotoEditorView
            android:id="@+id/photoEditorView"
            android:layout_width="match_parent"
            android:transitionName="img_small"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:photo_src="@drawable/img_surma" />

.
.
.
<Button
     android:id="@+id/sticker"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="sticker" />

<androidx.constraintlayout.widget.ConstraintLayout/>

Fragment A in Kotlin

binding.sticker.setOnClickListener {

            extraNavigate(R.id.mainEditScreenFragment_to_stickerFragment)

        }

  private fun extraNavigate(navigationId: Int){

        val extra= FragmentNavigatorExtras(binding.photoEditorView to "big_img" )

        findNavController().navigate(
            navigationId,
            null,
            null,
            extra

        )

    }

Code of Fragment B

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".screens.StickerFragment">

        <ja.burhanrashid52.photoeditor.PhotoEditorView
            android:id="@+id/imageView2"
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:scaleType="fitXY"
            android:transitionName="big_img"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:photo_src="@drawable/img_surma"  />
    </androidx.constraintlayout.widget.ConstraintLayout>

Fragment B in Kotlin

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val animation= TransitionInflater.from(context).inflateTransition(android.R.transition.move)
        sharedElementEnterTransition=animation
        sharedElementReturnTransition=animation

    }

Current Using Device Divice Name :- Xiaomi Poco 1 Version :- Android 10

burhanrashid52 commented 3 years ago

The transition name of the view should be same. In the above example it's different.

Fragment A

<ja.burhanrashid52.photoeditor.PhotoEditorView
    android:transitionName="img_small" />

Fragment B

<ja.burhanrashid52.photoeditor.PhotoEditorView
     android:transitionName="big_img" />

Also PhotoEditorView is ViewGroup which extends RelatvieLayout If you want do something on image then use photoEditorView.getSource() which return theImageView

wasim15185 commented 3 years ago

Thank You :) . I solved the problem .

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 4 days.

github-actions[bot] commented 3 years ago

This issue was closed because it has been stalled for 5 days with no activity.