Skip to content

Commit 488074d

Browse files
committed
ImageView.loadPortrait: 使用placeholder
1 parent cb5f72c commit 488074d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

app/src/main/kotlin/com/rayfantasy/icode/extension/_ImageView.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ import com.amulyakhare.textdrawable.TextDrawable
2121
import com.bumptech.glide.Glide
2222
import com.rayfantasy.icode.postutil.PostUtil
2323
import jp.wasabeef.glide.transformations.CropCircleTransformation
24-
import org.jetbrains.anko.image
2524

26-
fun ImageView.loadPortrait(username: String, errorRes: Int? = null) {
27-
val errorIcon = errorRes?.let { resources.getDrawable(errorRes) } ?:
25+
fun ImageView.loadPortrait(username: String, placeholderRes: Int? = null) {
26+
val placeholder = placeholderRes?.let { resources.getDrawable(placeholderRes) } ?:
2827
TextDrawable
2928
.builder().buildRound(username[0].toString().toUpperCase(),
3029
username.hashCode().alpha(0xff).shadowColor())
31-
image = errorIcon
3230
Glide.with(context)
3331
.load(PostUtil.getProfilePicUrl(username))
34-
.error(errorIcon)
32+
.placeholder(placeholder)
33+
.error(placeholder)
3534
.bitmapTransform(CropCircleTransformation(context))
3635
.into(this)
3736
}

0 commit comments

Comments
 (0)