Skip to content

Instantly share code, notes, and snippets.

View rcmkt's full-sized avatar

Dmitry Berdnikov rcmkt

  • Moscow
View GitHub Profile
// Набор эвентов в файле Events.kt
interface Event
class OpenLinkEvent(val link: String) : Event
class ShowSnackbarEvent(val message: String) : Event
class ShareEvent(val link: String) : Event
class OpenEmailAppEvent(val email: String) : Event
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
parentFragment?.also { parentFragment ->
NewsTransitioner.setupFirstFragment(parentFragment)
parentFragment.postponeEnterTransition()
}
// Initialization UI
}
class ChangeOutlineRadiusTransition(
private val startRadius: Int,
private val endRadius: Int
) : Transition() {
private companion object {
/**
* Unique key for start and end values to be kept in [TransitionValues] [TransitionValues]
*/
private const val RADIUS = "ChangeOutlineRadiusTransition:outlineRadius"
@rcmkt
rcmkt / GlideListener.kt
Last active September 26, 2019 09:34
GlideListener.kt
object : RequestListener<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: com.bumptech.glide.request.target.Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
scheduleStartPostponedTransitions()
return false
}
@rcmkt
rcmkt / glide.kt
Created September 26, 2019 09:31
glide.kt
Glide
.with(target)
.load(url)
.apply(
RequestOptions().dontTransform() // this line
)
@rcmkt
rcmkt / FirstFragment.kt
Created September 26, 2019 09:40
FirstFragment
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
parentFragment?.also { parentFragment ->
NewsTransitioner.setupFirstFragment(parentFragment)
parentFragment.postponeEnterTransition()
}
// Initialization UI
}
@rcmkt
rcmkt / Transitioner.kt
Last active September 26, 2019 13:13
Transitioner
fragment.sharedElementEnterTransition = TransitionSet().apply {
addTransition(ChangeImageTransform())
addTransition(ChangeBounds())
addTransition(ChangeTransform())
addTransition(ChangeOutlineRadiusTransition(animationRadiusData.startRadius,
animationRadiusData.endRadius)) // add this Transition
}
@rcmkt
rcmkt / RecyclerViewFix.kt
Created September 26, 2019 13:15
RecyclerViewFix
val transitionNameImage = context.getString(R.string.transition_image, title)