Implement cross-fade for story thumb shared element animation.

This commit is contained in:
Alex Hart
2022-04-07 16:08:05 -03:00
committed by Cody Henthorne
parent cb63fe600c
commit a894ba7a51
30 changed files with 629 additions and 120 deletions

View File

@@ -0,0 +1,32 @@
package org.thoughtcrime.securesms.util
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
/**
* Performs actions in onResourceReady and onLoadFailed
*/
class ActionRequestListener<T>(
private val onResourceReady: Runnable,
private val onLoadFailed: Runnable
) : RequestListener<T> {
companion object {
@JvmStatic
fun <T> onEither(onEither: Runnable): ActionRequestListener<T> {
return ActionRequestListener(onEither, onEither)
}
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<T>?, isFirstResource: Boolean): Boolean {
onLoadFailed.run()
return false
}
override fun onResourceReady(resource: T, model: Any?, target: Target<T>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
onResourceReady.run()
return false
}
}