I want to implement a feature that is sorta like a focus mode, essentially when someone clicks on a image view when looking at an image the tool bar would disappear unless it is reclicked. I believe this allows users to focus more on the image instead of toolbar unless they want information on the image. I have tinkered with this idea and tried to set an onclick feature on the image view, so that once clicked it would turn the visibility on the toolbar to invisible and when its clicked again it would make it visible. The problem is that I can only access the image view in the adapter I set for it and even when I got the alogrithm right (as in I put print statements to see what if statement I enter, and that works successfully) but what happens is that the toolbar doesn't react to it as if I cannot communicate with it.
from adapter
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val page_layout: View = inflater.inflate(R.layout.activity_viewer, container, false)
val presenter: Toolbar = page_layout.findViewById<View>(R.id.presenter) as Toolbar
val image_layout: View = inflater.inflate(R.layout.view_pager_item, container, false)
val page_image: PhotoView = image_layout.findViewById<View>(R.id.page_image) as PhotoView
Picasso.get().load(PageList[position].link).into(page_image)
page_image.setOnClickListener(View.OnClickListener {
println("clicked")
println(presenter.visibility)
if (presenter.visibility == View.INVISIBLE) {
println("outside")
presenter.visibility = View.VISIBLE
} else {
println("inside")
presenter.visibility = View.INVISIBLE
}
})
container.addView(image_layout)
return image_layout
}
from onCreate method from activity
class Page_Activity : AppCompatActivity() {
lateinit var lstPages: MutableList<Page>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_viewer)
lstPages = ArrayList()
mangaPages()
val myrv = findViewById<View>(R.id.view_page) as ViewPager
myViewPager = PageViewAdapter(this, lstPages)
myrv.adapter = myViewPager
the foucus on the activity is to make the call so that there is an array full of image link which gets throws into the adapter so that I can display it back in the activity. Nevertheless, I tested with this concept with a framelayout where I attack a onClickListener, but for someone reason when I do it to an image view in an adapter it act different. Anyways any help with this would be much appreciated!!! Thank you!
Your toolbar doesn't behave as you want because you are inflating a new toolbar in your adapter.
In this code
val page_layout: View = inflater.inflate(R.layout.activity_viewer, container, false)
val presenter: Toolbar = page_layout.findViewById<View>(R.id.presenter) as Toolbar
So, in order to access the toolbar that you have inflated in your Page_Activity, you can implement a callback from your adapter to your Page_Activity, like this
First, create a callback
interface PageImageCallback {
fun onClick()
}
Then, create a variable, setter function and call onClick function in your adapter class
class Adapter() {
private lateinit var pageImageCallback: PageImageCallback
fun setPageImageCallback(pageImageCallback: PageImageCallback) {
this.pageImageCallback = pageImageCallback
}
...
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val image_layout: View = inflater.inflate(R.layout.view_pager_item, container, false)
val page_image: PhotoView = image_layout.findViewById<View>(R.id.page_image) as PhotoView
Picasso.get().load(PageList[position].link).into(page_image)
page_image.setOnClickListener(View.OnClickListener {
println("clicked")
pageImageCallback.onClick()
})
container.addView(image_layout)
return image_layout
}
}
Lastly, implement the callback in Page_Activity
class Page_Activity : AppCompatActivity(), PageImageCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_viewer)
...
myViewPager.setPageImageCallback(this)
}
...
override fun onClick() {
if (presenter.visibility == View.INVISIBLE) {
println("outside")
presenter.visibility = View.VISIBLE
} else {
println("inside")
presenter.visibility = View.INVISIBLE
}
}
}
Related
I am using the following fragment to show an onboarding screen on the first launch of the application. Should I inflate my layout in onCreateView or in onViewCreated? I don't quite understand how to decide on this. Also, do I need to create a ViewModel for my code?
class OnBoardingFragment : Fragment() {
private lateinit var viewPager: ViewPager
private lateinit var dotsLayout: LinearLayout
private lateinit var sliderAdapter: SliderAdapter
private lateinit var dots: Array<TextView?>
private lateinit var letsGetStarted: Button
private lateinit var next: Button
private lateinit var animation: Animation
private var currentPos: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val navOptions = NavOptions.Builder().setPopUpTo(R.id.onBoardingFragment, true).build()
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_onboarding, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewPager = view.findViewById(R.id.slider);
dotsLayout = view.findViewById(R.id.dots);
letsGetStarted = view.findViewById(R.id.get_started_btn);
next = view.findViewById(R.id.next_btn)
sliderAdapter = SliderAdapter(requireContext())
viewPager.adapter = sliderAdapter;
addDots(0);
viewPager.addOnPageChangeListener(changeListener);
next.setOnClickListener {
viewPager.currentItem = currentPos + 1
}
letsGetStarted.setOnClickListener {
findNavController().navigate(R.id.action_onBoardingFragment_to_loginFragment)
}
}
private fun addDots(position: Int) {
dots = arrayOfNulls(2)
dotsLayout.removeAllViews();
for (i in dots.indices) {
dots[i] = TextView(requireContext())
dots[i]!!.text = HtmlCompat.fromHtml("•", HtmlCompat.FROM_HTML_MODE_LEGACY)
dots[i]!!.setTextColor(
ContextCompat.getColor(
requireContext(),
android.R.color.darker_gray
)
)
dots[i]!!.textSize = 35F
dotsLayout.addView(dots[i])
}
if (dots.isNotEmpty()) {
dots[position]!!.setTextColor(
ContextCompat.getColor(
requireContext(),
R.color.wine_red
)
)
}
}
private var changeListener: ViewPager.OnPageChangeListener =
object : ViewPager.OnPageChangeListener {
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) {
addDots(position)
currentPos = position
animation =
AnimationUtils.loadAnimation(requireContext(), android.R.anim.fade_in)
if (position == 0) {
letsGetStarted.visibility = View.INVISIBLE
next.animation = animation
next.visibility = View.VISIBLE
} else {
letsGetStarted.animation = animation
letsGetStarted.visibility = View.VISIBLE
next.visibility = View.INVISIBLE
}
}
override fun onPageScrollStateChanged(state: Int) {}
}
}`
The Android framework calls Fragment's onCreateView to create the view object hierarchy. Therefore, it's correct to inflate the layout here as you did.
onViewCreated is called afterwards, usually you find views and setup them. So, your code is ok.
Regarding the ViewModel, in your sample code you're just configuring the UI so you won't need it. If instead, you need to obtain some data from an API service, transform it, show the states of "loading data", "data retrieved" and "there was an error retrieving data", then you would like not to do those things in the fragment and you could consider using an MVVM approach.
Some references:
https://developer.android.com/guide/fragments/lifecycle#fragment_created_and_view_initialized
https://guides.codepath.com/android/Creating-and-Using-Fragments
https://developer.android.com/topic/architecture
onCreateView is where you inflate the view hierarchy, and return it (so the Fragment can display it). If you're handling that inflation yourself, you need to override onCreateView so you can take care of it when the system makes that request. That's why it's named that way - when the view (displayed layout) is being created, this function is called, and it provides a View.
onViewCreated is called after the Fragment's view has already been created and provided to it for display. You get a reference to that view passed in, so you can do setup stuff like assigning click listeners, observing View Models that update UI elements, etc. You don't inflate your layout here because it won't be displayed (unless you're explicitly inflating other stuff and adding it to the existing view for some reason, which is more advanced and probably not what you're talking about).
So onCreateView is really concerned with creating a view hierarchy for display, and onViewCreated is for taking that displayed hierarchy and initialising your stuff. You might not need to implement onCreateView at all (e.g. if you use the Fragment constructor that takes a layout ID, so it sets it up for you) in which case you'd just implement onViewCreated instead. Or if you are handling it yourself in onCreateView, and you don't have much setup code, you might run that on the View you've inflated before you return it, and not bother with onViewCreated at all.
It's worth getting familiar with the Fragment lifecycle if you haven't already, just so you know the basic way the system moves between states and the callbacks it calls as it does so (and have a look at the documentation for the callback methods too!)
I'm developing an app to store TV shows informations. The use can add shows and then view its collection. I want, when adding a show, to be able to also add seasons to it, and several if need be.
I have Show and Season models, and I've created an AddShowActivity with its add_show_activity layout. I've started using Android Studio not long ago so maybe this is not optimal, but I thought of using a RecyclerView inside of my layout, and then recycle an item_add_season layout in order to add as many seasons as I want while creating a show.
However, this has caused several problems to me, to which I couldn't find any answer and am currently lost as to what to do. I've put an Add Season button in my add_show_activity, which is supposed to add a new item_add_season to my RecyclerView, however I didn't know how I should go about doing that. And even if I still haven't tried it, I'm wondering how I'll be able to retrieve my data from outside of my Adapter.
So I've been wondering if it was possible to use a RecyclerView like that in order to add several seasons to my form ? And if not, how should I go about doing that ?
Below are my AddShowActivity and my AddSeasonAdapter (the recyclerview adapter).
class AddShowActivity : AppCompatActivity() {
private lateinit var editTextName: EditText
private lateinit var editTextNote: EditText
private lateinit var confirmButton: Button
private lateinit var addSeasonButton: Button
private lateinit var seasonsRecyclerView: RecyclerView
#SuppressLint("NewApi")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_show)
editTextName = findViewById(R.id.name_input)
editTextNote = findViewById(R.id.note_input)
seasonsRecyclerView = findViewById(R.id.seasons_recycler_view)
seasonsRecyclerView.adapter = AddSeasonAdapter(this, 0, R.layout.item_add_season)
seasonsRecyclerView.layoutManager = LinearLayoutManager(this)
confirmButton = findViewById(R.id.confirm_button)
confirmButton.setOnClickListener{
sendForm()
}
addSeasonButton = findViewById(R.id.add_season_button)
addSeasonButton.setOnClickListener {
// Add a season to the RecyclerView and update its seasonsCount
}
}
#SuppressLint("NewApi")
private fun sendForm(){
val repo = ShowRepository()
val showName = editTextName.text.toString()
val showNote = parseInt(editTextNote.text.toString())
val seasonsList = arrayListOf<SeasonModel>() // Get info from seasons adapter and create seasons list
val show = ShowModel(UUID.randomUUID().toString(), showName, showNote, seasonsList)
repo.insertShow(show)
this.finish()
}
}
class AddSeasonAdapter(val context: AddShowActivity, private var seasonsCount: Int, private val layoutId: Int) : RecyclerView.Adapter<AddSeasonAdapter.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(layoutId, parent, false)
return ViewHolder(view)
}
#SuppressLint("NewApi")
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
}
override fun getItemCount(): Int = seasonsCount
}
I've found a YouTube video explaining exactly how to do it (this one for those who wanna see it).
So basically, the solution is not to use a RecyclerView but instead a LinearLayout in which the seasons are added when clicking on the 'Add season' button. This is quite easy to do, as the only thing to do is to inflate the layout, here my item_add_season, and then add it to the LinearLayout.
So like that:
// The LinearLayout in which items are added
val seasonsList = findViewById<LinearLayout>(R.id.seasons_list)
addSeasonButton.setOnClickListener {
val seasonView: View = layoutInflater.inflate(R.layout.item_add_season, null, false)
// Initialize the seasons items components
val seasonNumber = seasonView.findViewById<EditText>(R.id.season_number_input)
val seasonNote = seasonView.findViewById<EditText>(R.id.season_note_input)
val imageClose = seasonView.findViewById<ImageView>(R.id.image_close)
imageClose.setOnClickListener {
seasonsList.removeView(seasonView)
}
// Add the add_season_layout to the linearLayout
seasonsList.addView(seasonView)
}
So basically I'm making an activity in which in button click one alert dialog displays on screen and it contain recyclerview with cardview and one close button. now, by clicking on cardview I have successfully toast a message but now there is requirement to get the image of cardview and then set it into imageview of different xml file (that cardview is also in different kt file). In short the main problem is i can not find that imageview into that different kt file.
So, I have tried few approaches mentioned below
First Approach -> view.findViewById (in this case the error is view.findViewById(R.id.custom_image_view) must not be null)
Second Approach -> by using view.find (in this case the error is null cannot be cast to non-null type android.widget.ImageView)
Third Approach -> accessing using className().imageview (in this case the error is lateinit property is not been initialized) method but the problem is still there.
So, below code contains button for displaying alert dialog.code file named as CreateCustomImageActivity.kt
class CreateCustomImageActivity : AppCompatActivity(), View.OnTouchListener {
/* some code */
lateinit var imageView: ImageView
/* some code */
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_create_custom_image)
/* below is the imageView in which I want to set image */
imageView = findViewById(R.id.custom_image_view)
/* below is the imageButton on which by clicking alert dialog with recyclerView
with cardView is displaying */
val image = findViewById<ImageButton>(R.id.bg_image)
image.setOnClickListener {
val selectImageDialog = LayoutInflater.from(this)
.inflate(R.layout.activity_choose_background_image_list, null)
val builder = AlertDialog.Builder(this).setView(selectImageDialog)
val showDialog = builder.show()
showDialog.window?.setGravity(Gravity.BOTTOM)
val close = selectImageDialog.findViewById<Button>(R.id.choose_image)
val recyclerImageList = selectImageDialog.findViewById<RecyclerView>(R.id.image_list_recycler_view)
val imageCard = ArrayList<backgroundImageListDatabase>()
imageCard.add(backgroundImageListDatabase(R.drawable.o))
imageCard.add(backgroundImageListDatabase(R.drawable.t))
imageCard.add(backgroundImageListDatabase(R.drawable.th))
imageCard.add(backgroundImageListDatabase(R.drawable.f))
imageCard.add(backgroundImageListDatabase(R.drawable.fi))
imageCard.add(backgroundImageListDatabase(R.drawable.s))
imageCard.add(backgroundImageListDatabase(R.drawable.se))
recyclerImageList.setLayoutManager(
GridLayoutManager(this,2,
GridLayoutManager.VERTICAL,false)
)
val adapter = BackgroundImageCardAdapter(imageCard)
recyclerImageList.setAdapter(adapter)
close.setOnClickListener {
showDialog.dismiss()
}
}
}
}
And below code contains the Adapter class for binding cardView to recyclerView. Code file named as ChooseBackgroundImageListActivity.kt
class BackgroundImageCardAdapter(val backgroundImageCardDetails: ArrayList<backgroundImageListDatabase>) :
RecyclerView.Adapter<BackgroundImageCardAdapter.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
// var bgImageView: ImageView = view.find(R.id.custom_image_view)
fun bindItems(details: backgroundImageListDatabase) {
val imageView = itemView.findViewById<ImageView>(R.id.background_image_card_image)
imageView.setImageResource(details.image)
imageView.setOnClickListener {
// bgImageView.setImageResource(details.image)
Toast.makeText(imageView.context,details.image.toString(),Toast.LENGTH_SHORT).show()
Log.d(" - CARD CLICK EVENT - ","Clicked")
}
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val cardView: View = LayoutInflater.from(parent.context).inflate(R.layout.choose_background_image_card,parent,false)
return ViewHolder(cardView)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bindItems(backgroundImageCardDetails[position])
// holder.itemView.setOnClickListener {
// Toast.makeText(holder.itemView.context,"CARD CLICKED",Toast.LENGTH_SHORT).show()
// Log.d(" - CARD CLICK EVENT - ","Clicked")
// }
}
override fun getItemCount(): Int {
return backgroundImageCardDetails.size
}
}
Thanks in Advance.
Its not about putting them in the same or different kt file, You cant access any view until you have its reference.
I mean you have only access to your imageView when your dialog is on the screen and you can access its value with selectImageDialog.findViewById
The best option here is using Callbacks(when you click on a image in your adapter the parent of your adapter should get noticed that new image is clicked)
first create your callback:
interface CardAdapterCallback {
fun onImageClicked(resId : Int)
}
then change your adapter constructor and add your callback:
class BackgroundImageCardAdapter(
val backgroundImageCardDetails: ArrayList<backgroundImageListDatabase>,
val callback : CardAdapterCallback
) :RecyclerView.Adapter<BackgroundImageCardAdapter.ViewHolder>() {...}
then when you click on a image in your adapter bindItems function send your callback to your activity:
fun bindItems(details: backgroundImageListDatabase) {
val imageView = itemView.findViewById<ImageView>(R.id.background_image_card_image)
imageView.setImageResource(details.image)
imageView.setOnClickListener {
callback.onImageClicked(details.image)
}
}
Updated
change your adapter creating in your activity to this:
val adapter = BackgroundImageCardAdapter(
imageCard,
object : CardAdapterCallback {
override fun onImageClicked(resId : Int){
imageView.setImageResource(resId)
}
})
(object:CardAdapterCallback{} is for fixing your parameter error)
And to fix your callback variable error in bindItems function change this line in your BackgroundImageCardAdapter:
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindItems(details: backgroundImageListDatabase) {
val imageView = itemView.findViewById<ImageView>(R.id.background_image_card_image)
imageView.setImageResource(details.image)
imageView.setOnClickListener {
callback.onImageClicked(details.image)
}
}
}
with that inner keyword, you will be able to call callback.onImageClicked(details.image) in your bindItems function
I use a recyclerview in a viewpager an when I want to scroll to a position using smothScrollToPosition I see no change in the current page but when I slide I see that the change has been applied to the next or the previous page. I have define a function in the sliderAdapter call scrollTo in this method I call smothScrollToPosition.The method scrollTo is call when the user click on a button in the MainActivity
MainActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val pager = findViewById<ViewPager>(R.id.view_pager)
val adapter = SlideAdapter(this)
pager.adapter = adapter
findViewById<Button>(R.id.button).setOnClickListener {
adapter.scrollTo(30)
}
}
}
SlideAdapter
class SlideAdapter(val context: Context) : PagerAdapter() {
lateinit var recyclerView: RecyclerView
lateinit var viewManager : LinearLayoutManager
fun scrollTo(position: Int) {
viewManager.scrollToPositionWithOffset(position, 0)
}
override fun isViewFromObject(view: View, `object`: Any): Boolean = view == `object` as RelativeLayout
override fun getCount() = 5
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val view = LayoutInflater.from(context)
.inflate(R.layout.slide, container, false) as RelativeLayout
val list = mutableListOf<String>()
for (i in 0..50)
list.add("Element $i")
val viewAdapter = Adapter(context, list)
viewManager = LinearLayoutManager(context)
recyclerView = view.findViewById(R.id.recyclerView)
recyclerView.apply {
setHasFixedSize(true)
layoutManager = viewManager
adapter = viewAdapter
}
container.addView(view)
return view
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
container.removeView(`object` as RelativeLayout)
}
}
IMAGE PAGE 1 I CLICK ON THE BUTTON AND I SEE NO CHANGE
IMAGE PAGE 2 I SLIDE AND SEE THAT THE CHANGE HAS BEEN APPLIED ON THIS PAGE.
I need help please ^_^
From JavaDOC of method scrollToPositionWithOffset:
Note that scroll position change will not be reflected until the next layout call.
If you are just trying to make a position visible, use {#link #scrollToPosition(int)}.
May be here is the problem?
I have a weird behavior with share elements and I don't know if it comes from a mistunderstanding of share element or a bad implementation.
I looked up on Google and no one seems to suffer from the problem I have.
Let me explain. I have two Fragments, Fragment A is containing a RecyclerView, Fragment B is a detailed view of recyclerview items. Both have a custom toolbar containing a TextView.
I wanted to share the textview of recyclerview items in A to the toolbar textview of B. Currently, the enter share element transition is working (A-->B) but it does not work in the other way (A<--B).
During the return transition, the toolbar textview of B stays in the toolbar and disappears with the B return transition.
But the share element transition works and another textview appears from the top of the recyclerview of A and does its job.
There it is the problem. After onBackPressed, the toolbar textview is not shared anymore and a copy of this toolbar textview is made and animated (only in the recyclerview, it doesn't come from the toolbar) instead of share the B toolbar textview to A recyclerview item
I don't get where is the problem. Transition names are good otherwise animations couldn't work. Any idea? (I am coding under Kotlin)
FragmentActivity
override fun onBackPressed() {
if(supportFragmentManager.backStackEntryCount > 1){
supportFragmentManager.popBackStackImmediate()
} else {
super.onBackPressed()
}
}
Fragment A Adapter ViewHolder
class AnimationRecyclerViewHolder(val view: View, val listener: AnimationRecyclerCallBack) : RecyclerView.ViewHolder(view) {
val text: TextView = view.animation_recycler_text
fun bind(data: AnimationRecyclerData) {
text.text = data.description
text.transitionName = "textTransitionName$layoutPosition"
view.setOnClickListener {
listener.callback(data, view)
}
}
}
Fragment A
override fun callback(data: AnimationRecyclerData, view: View) {
val frag = AnimationPageFragment.newInstance(data.type, this)
val transac = activity!!.supportFragmentManager.beginTransaction()
transac.shareText(view.animation_recycler_text, context!!, this, frag)
transac.replace(activity!!.fragContainerCatalogue.id, frag).addToBackStack(null).commit()
}
shareText method
fun FragmentTransaction.shareText(textview: TextView, context: Context, currentFrag: AbstractAnimationFragment, nextFrag: AbstractAnimationFragment) : FragmentTransaction {
val sharedTransitionName = textview.transitionName
val bundle = nextFrag.arguments ?: Bundle()
bundle.putString("sharedTransitionKey", sharedTransitionName)
bundle.putString("nextTitle", textview.text.toString())
nextFrag.arguments = bundle
nextFrag.enterTransition = Fade()
nextFrag.sharedElementEnterTransition = nextFrag.createShareTransition(sharedTransitionName, currentFrag.context!!)
currentFrag.activity!!.window.sharedElementsUseOverlay = false
return this.addSharedElement(textview, sharedTransitionName)
}
Fragment B
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
var rootView = inflater.inflate(R.layout.animation_page_fragment_content, container, false)
toolbar = inflatedView.findViewById(R.id.toolbarShared)
titleToolbar = inflatedView.findViewById(R.id.toolbarTitleShared)
toolbar.setBackgroundColor(Color.RED)
titleToolbar.textSize = 25f
titleToolbar.setTextColor(Color.BLACK)
val bundle = this.arguments ?: Bundle()
val transitionName = bundle.getString("sharedTransitionKey")
val titleName = bundle.getString("nextTitle")
titleToolbar.text = titleName
titleToolbar.transitionName = transitionName
activity!!.window.sharedElementsUseOverlay = true
sharedElementEnterTransition = createShareTransition(titleToolbar.transitionName, context!!)
return rootView
}
I found out the solution.
The issue was indeed related to my RecyclerView.
I never said that my recyclerview was also animated when it is appearing.
I had an enter animation when the recyclerview appears and an animation when user is scrolling. I disabled both and it worked properly.
Now, I just have to find a way to disable RecyclerView animations on return and everything will be okay.
Thanks for those who read me and tried to help me.
The code I used to solve my issue :
frag.setEnterSharedElementCallback(object : SharedElementCallback() {
override fun onSharedElementEnd(sharedElementNames: MutableList<String>?, sharedElements: MutableList<View>?, sharedElementSnapshots: MutableList<View>?) {
super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots)
viewAdapter.mApplyAnim = true
}
})