-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
Description
Glide Version: 3.7.0
Integration libraries: no
Device/Android Version: GT-I9500 5.0.1
Issue details / Repro steps / Use case background:
- if pathToImage = null for load function - I get exception callback (this is right) with Exception object is null (this is incorrect)
- If pathToImage = null why not loading 'error' resource which was set on start loading image ?
- Perhaps, if error would be call right (my point 2), result would not be transformer by setting callback function.
- About placeholder. If I need set placeholder as resource drawable (not as color in my code below), then It would not be transformer by callback function. For example, I can do shape with dublicate round fill color. What about if I need user image for placeholder ? I need transfrom not only correct result, but all results and placeholder too.
Glide load line / GlideModule
(if any) / list Adapter code (if any):
in class which is extends from ImageView
Glide.with(getContext())
.load(pathToImage)
.bitmapTransform(new RoundedCornersTransformation(getContext(), 100, 0))
.placeholder(R.color.orange_red)
.error(defaultPhotoId)
.dontAnimate()
.listener(this)
.into(this);
Layout XML:
<com.application.ImageGlide
android:id="@+id/avatar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
I user only square image
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int width = MeasureSpec.getSize(widthMeasureSpec);
if (width > 0) {
setMeasuredDimension(width, width);
}
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
TWiStErRob commentedon Mar 21, 2016
It's also worth noting that Drawables are not Bitmaps, so you cannot transform them. Think about a VectorDrawable or PictureDrawable, how do you expect that to be blurred or round-cropped for example? For placeholder-like drawables you'll have to define a shape in XML similar to your transformation.
load(null)
: .load(null) can be a valid .load request #268 so you just need to do.error(R.drawable.x).fallback(R.drawable.x)
if you want to treat null as error.TWiStErRob commentedon Mar 21, 2016
Btw, why did you close the issue? Accident or found a solution?
gromiloff commentedon Mar 21, 2016
@TWiStErRob error resource would be use if for 'onException' callback return false.
But now I can see what error resource is use transform before display.
As placeholder I use shape (it's not problem). But if I use non solid drawable (vector for example) - it is'not use transformation. And this is really bad, because need preparatory work for placeholder.
bumptech/glide#1077 rounded placeholder
TWiStErRob commentedon Mar 21, 2016
Yes, you need to do some work on the placeholder, because there's no general way to do transforms.
You have two options:
play around with XML enough to be able to round-crop any drawable, shape, mask, etc.
programmatically render and crop it (once!) before using as a placeholder in the list.
For full example see TWiStErRob/glide-support@1b4d9d3
[-]Error resource using issue[/-][+].error() resource not used when loading null[/+]gromiloff commentedon Mar 21, 2016
Ty
MichaelJokAr commentedon Dec 8, 2017
it's not work for
MultiTransformation
?I'm using CenterCrop and RoundedCorners to load image. and use the
transformDrawable()
methd to load placeholder.but it's not working. this is my code:chitrang200889 commentedon Sep 11, 2020
@TWiStErRob when you say "Once!" does it mean we have to keep global reference for that BitmapDrawable, say when we load the app and later we can use same reference everywhere throughout the app? Please correct me if I am wrong. Thanks.