FrensisXh
FrensisXh

Reputation: 157

How to pass an image from one fragment to another using Safe Args?

I want to pass some data from one fragment to another and I have managed to successfully pass every single data except an imageView, I don't know how to do that. Here's my code below passing data:

1st fragment:

val action: NavDirections =
            PartnersFragmentDirections.actionPartnersFragmentToPartnerItemFragment(
                obj.name,
                obj.short_description,
                obj.connection_state,
                obj.logo_path,
                obj.id
            )
        findNavController().navigate(action)

2nd fragment

 if (arguments != null) {
            val arg = PartnerItemFragmentArgs.fromBundle(requireArguments())
            binding.partnerName.text = arg.name
            binding.partnerDescription.text = arg.shortDescription
            connectionState = arg.connectionState.toString()
            id = arg.id.toString()

Upvotes: 1

Views: 649

Answers (1)

FrensisXh
FrensisXh

Reputation: 157

I found a solution about this using Glide.

if (arguments != null) {
            val arg = PartnerFragmentArgs.fromBundle(requireArguments())
            binding.partnerName.text = arg.name
            binding.partnerDescription.text = arg.shortDescription
            connectionState = arg.connectionState.toString()
            val logoPath = arg.logoPath
            Glide
                .with(binding.partnerLogo.context)
                .load(logoPath)
               .into(binding.partnerLogo)
            id = arg.id.toString()
       }

Upvotes: 1

Related Questions