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
why place holder doesnt remove #67
Comments
Hi, @amirhrezf . What version of library do you use? |
1.0.8 |
Can you solve this problem? |
@amirhrezf I have just run your code and found why it's happening. It's because you call .addMedia(MediaInfo.mediaLoader(new MediaLoader() {
@Override public boolean isImage() {
return true;
}
@Override public void loadMedia(Context context, ImageView imageView,
MediaLoader.SuccessCallback callback) {
// you should set image bitmap here
callback.onSuccess();
}
@Override public void loadThumbnail(Context context, ImageView thumbnailView,
MediaLoader.SuccessCallback callback) {
// and set thumbnail bitmap here
callback.onSuccess();
}
})) If you look up to the README example, here we set bitmaps for both ImageView's: .addMedia(MediaInfo.mediaLoader(new MediaLoader() {
@Override public boolean isImage() {
return true;
}
@Override public void loadMedia(Context context, ImageView imageView,
MediaLoader.SuccessCallback callback) {
imageView.setImageBitmap(toBitmap(R.drawable.wallpaper3)); // <-- here
callback.onSuccess();
}
@Override public void loadThumbnail(Context context, ImageView thumbnailView,
MediaLoader.SuccessCallback callback) {
thumbnailView.setImageBitmap(toBitmap(R.drawable.wallpaper3)); // <-- and here
callback.onSuccess();
}
})) I'm going to provide better API in the next release cause sometimes it's not obvious how to add media to the library. |
I changed my code to what you sayed but just first image changed. I dont want to change it i want to load and image from web: my code: .setThumbnailSize(200)
.setZoom(true)
.setFragmentManager(getSupportFragmentManager())
.addMedia(MediaInfo.mediaLoader(new MediaLoader() {
@Override public boolean isImage() {
return true;
}
@Override public void loadMedia(Context context, ImageView imageView,
MediaLoader.SuccessCallback callback) {
imageView.setImageBitmap(toBitmap(R.drawable.add)); // <-- here
callback.onSuccess();
}
@Override public void loadThumbnail(Context context, ImageView thumbnailView,
MediaLoader.SuccessCallback callback) {
thumbnailView.setImageBitmap(toBitmap(R.drawable.add)); // <-- and here
callback.onSuccess();
}
}))
.addMedia(infos);
}
private Bitmap toBitmap(int image) {
return ((BitmapDrawable) getResources().getDrawable(image)).getBitmap();
} and still my first gallery pic is somthing that i dont want. You know i dont get it why we are using this line thumbnailView.setImageBitmap(toBitmap(R.drawable.wallpaper3)); // <-- and here We can easily add place holder like this in PicassoImageLoader @Override
public void loadThumbnail(Context context, final ImageView thumbnailView, final SuccessCallback callback) {
Picasso.get()
.load(url)
.resize(thumbnailWidth == null ? 300 : thumbnailWidth,
thumbnailHeight == null ? 300 : thumbnailHeight)
.centerInside()
.placeholder(R.drawable.add) //this line
.into(thumbnailView, new ImageCallback(callback));
} Its just an idea i tested and work but not using it becuase still my app looks like this. |
@amirhrezf if you want to load images by urls - just use ArrayList<String> strings = new ArrayList<>();
strings.add("http://img1.goodfon.ru/original/1920x1080/d/f5/aircraft-jet-su-47-berkut.jpg");
strings.add("http://img1.goodfon.ru/original/1920x1080/d/f5/aircraft-jet-su-47-berkut.jpg");
strings.add("http://img1.goodfon.ru/original/1920x1080/d/f5/aircraft-jet-su-47-berkut.jpg");
List<MediaInfo> infos = new ArrayList<>(strings.size());
for (String url : strings) infos.add(MediaInfo.mediaLoader(new PicassoImageLoader(url)));
scrollGalleryView = findViewById(R.id.scroll_gallery_view);
scrollGalleryView
.setThumbnailSize(200)
.setZoom(true)
.setFragmentManager(getSupportFragmentManager())
.addMedia(infos);
} In that case you don't need to provide custom .addMedia(MediaInfo.mediaLoader(new MediaLoader() {
@Override public boolean isImage() {
return true;
}
@Override public void loadMedia(Context context, ImageView imageView,
MediaLoader.SuccessCallback callback) {
imageView.setImageBitmap(toBitmap(R.drawable.add)); // <-- here
callback.onSuccess();
}
@Override public void loadThumbnail(Context context, ImageView thumbnailView,
MediaLoader.SuccessCallback callback) {
thumbnailView.setImageBitmap(toBitmap(R.drawable.add)); // <-- and here
callback.onSuccess();
}
})) So you don't need to use this line: thumbnailView.setImageBitmap(toBitmap(R.drawable.wallpaper3)); // <-- and here cause it's only used in the case when you want to provide your custom |
Thanks so much. Everythings working find. I will tell my friends to use your lib. |
Why what ever i do my first position is place holder icon?!
And this is my code:
And for PicassoImageLoader:
The text was updated successfully, but these errors were encountered: