Created
April 22, 2020 21:12
-
-
Save cdmunoz/3a1e93697f96508029f7eaf328723547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhotoDetailsFragment : Fragment() { | |
companion object { | |
private val TAG = PhotoDetailsFragment::class.java.name | |
const val PHOTO_ARG = "PHOTO_ARG" | |
} | |
private lateinit var binding: FragmentPhotoDetailsBinding | |
private lateinit var photo: Photo | |
private var shortAnimationDuration: Int = 0 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
loadArguments() | |
} | |
private fun loadArguments() { | |
arguments?.getParcelable<Photo>(PHOTO_ARG)?.let { | |
photo = it | |
} | |
} | |
override fun onCreateView(inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle?): View? { | |
binding = FragmentPhotoDetailsBindingImpl.inflate(inflater) | |
binding.photoBinding = photo | |
binding.lifecycleOwner = this@PhotoDetailsFragment | |
setHasOptionsMenu(true) | |
return binding.root | |
} | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
// Retrieve and cache the system's default "short" animation time. | |
shortAnimationDuration = resources.getInteger(android.R.integer.config_shortAnimTime) | |
binding.photoDetailsImageZoom.setImageFromUrl(photo.imgSrc) | |
with(binding.photoDetailsImage) { | |
setImageFromUrlWithProgressBar(photo.imgSrc, binding.photoDetailsProgress) | |
setOnClickListener { | |
zoomImageFromThumb(binding.photoDetailsImageZoom, | |
binding.photoDetailsContainer, | |
shortAnimationDuration) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment