Commit 3e43f04a authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update FrescoHelper class.

parent 4f3302bf
......@@ -9,37 +9,36 @@ import com.facebook.drawee.drawable.ProgressBarDrawable
import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.view.SimpleDraweeView
class FrescoHelper {
companion object {
@JvmStatic fun loadImage(simpleDraweeView: SimpleDraweeView, imageUri: String, placeholderDrawable: Drawable) {
simpleDraweeView.hierarchy.setPlaceholderImage(placeholderDrawable)
simpleDraweeView.controller = Fresco.newDraweeControllerBuilder().setUri(imageUri).setAutoPlayAnimations(true).build()
}
object FrescoHelper {
/** TODO
* Replace with:
* @JvmStatic fun loadImageWithCustomization(draweeView: SimpleDraweeView,
* imageUri: String,
* placeholderImageDrawableId : Int = R.drawable.image_dummy,
failureImageDrawableId: Int = R.drawable.image_error) {
* [...]
* }
* It is need to convert java files which uses loadImageWithCustomization(...) method to use the above method signature.
* See: https://kotlinlang.org/docs/reference/functions.html#default-arguments.
*/
@JvmStatic fun loadImageWithCustomization(draweeView: SimpleDraweeView, imageUri: String) {
val hierarchy: GenericDraweeHierarchy = draweeView.hierarchy
hierarchy.setPlaceholderImage(VectorDrawableCompat.create(draweeView.resources, R.drawable.image_dummy, null))
hierarchy.setFailureImage(VectorDrawableCompat.create(draweeView.resources, R.drawable.image_error, null))
hierarchy.setProgressBarImage(ProgressBarDrawable())
fun loadImage(simpleDraweeView: SimpleDraweeView, imageUri: String, placeholderDrawable: Drawable) {
simpleDraweeView.hierarchy.setPlaceholderImage(placeholderDrawable)
simpleDraweeView.controller = Fresco.newDraweeControllerBuilder().setUri(imageUri).setAutoPlayAnimations(true).build()
}
/** TODO
* Replace with:
* fun loadImageWithCustomization(draweeView: SimpleDraweeView,
* imageUri: String,
* placeholderImageDrawableId : Int = R.drawable.image_dummy,
* failureImageDrawableId: Int = R.drawable.image_error) {
* [...]
* }
* It is need to convert java files which uses loadImageWithCustomization(...) method to use the above method signature.
* See: https://kotlinlang.org/docs/reference/functions.html#default-arguments.
*/
fun loadImageWithCustomization(draweeView: SimpleDraweeView, imageUri: String) {
val hierarchy: GenericDraweeHierarchy = draweeView.hierarchy
hierarchy.setPlaceholderImage(VectorDrawableCompat.create(draweeView.resources, R.drawable.image_dummy, null))
hierarchy.setFailureImage(VectorDrawableCompat.create(draweeView.resources, R.drawable.image_error, null))
hierarchy.setProgressBarImage(ProgressBarDrawable())
val controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(imageUri))
.setAutoPlayAnimations(true)
.setTapToRetryEnabled(true)
.build()
val controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(imageUri))
.setAutoPlayAnimations(true)
.setTapToRetryEnabled(true)
.build()
draweeView.controller = controller
}
draweeView.controller = controller
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment