-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/glide fallback placeholder #7976
Changes from 3 commits
a32d216
0e0539e
049bfb9
0781bdf
2827a8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.wordpress.android.util.image | ||
|
||
import org.wordpress.android.R | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class ImagePlaceholderManager @Inject constructor() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love this class 👍 Is it worth testing it? It's probably not necessary |
||
fun getErrorImage(imgType: ImageType): Int? { | ||
return when (imgType) { | ||
ImageType.PHOTO -> R.color.grey_lighten_30 | ||
ImageType.VIDEO -> R.color.grey_lighten_30 | ||
ImageType.AVATAR -> R.drawable.ic_placeholder_gravatar_grey_lighten_20_100dp | ||
ImageType.BLAVATAR -> R.drawable.ic_placeholder_blavatar_grey_lighten_20_40dp | ||
} | ||
} | ||
|
||
fun getPlaceholderImage(imgType: ImageType): Int? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe let's rename both to |
||
return when (imgType) { | ||
ImageType.PHOTO -> R.color.grey_light | ||
ImageType.VIDEO -> R.color.grey_light | ||
ImageType.AVATAR -> R.drawable.shape_oval_grey_light | ||
ImageType.BLAVATAR -> R.color.grey_light | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.wordpress.android.util.image | ||
|
||
enum class ImageType { | ||
PHOTO, | ||
VIDEO, | ||
AVATAR, | ||
BLAVATAR | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be a good usecase for a private extension function, especially since this is basically a builder pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, it looks better now!