Reputation: 141
I'm using Glide 4.3.1 for loading Image. There are two conditions:
into(ImageView)
, placeholder()
works wellinto(new SimpleTarget() {...})
, placeholder()
is not workingThis is my code of target:
RequestBuilder drawableTypeRequest = Glide.with(MainActivity.this).asBitmap().load(uri);
drawableTypeRequest.apply(new RequestOptions().override(100, 100).placeholder(R.drawable.add_driver_photo)).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) {
imageView.setImageBitmap(resource);
}
});
This is my working code
RequestBuilder drawableTypeRequest = Glide.with(MainActivity.this).asBitmap().load(uri);
drawableTypeRequest.apply(new RequestOptions().override(100, 100).placeholder(R.drawable.add_driver_photo)).into(imageView);
And I find somebody ask similar question in stackoverflow: glide:4.3.1 override and placeholder features not work, But it not my disk.
Can anybody solve my doubt? Thank you!
Upvotes: 0
Views: 836
Reputation: 28
As a ten years android developer, I should tell you , if you use the first codes, Glide don't know which target the placeholder should place, you don't assign a imageView to the placeholder, as we talked face to face, you should use ImageViewTarget instead of SimpleTarget, the constructor of ImageViewTarget has a param view, you can pass your imageView into there
Upvotes: 1