How to use image loading within ListView?
See original GitHub issue- Markwon version: 4.3.1
- Glide version: 4.11.0
I have a ListView which items are markwon-powered TextViews. (In fact, items are a bit more complex but it is not the case)
So, it looks like this – two items for two lines of text:
ListView’s attribute transcriptMode
is set to normal
, so “The list will automatically scroll to the bottom when a data set change notification is received and only if the last item is already visible on screen” as said in docs.
Let’s check.
Initial status | When new item added | When keyboard shown |
---|---|---|
Everything is fine – ListView stays at its bottom.
But when text contains small square picture(s) (something like emoji) strange things occur.
Initial status | When new item added | When keyboard shown |
---|---|---|
As you can see, ListView is somehow “unpinned” from its bottom position and stopped autoscroll.
I suppose it is somehow related to dimensions of loaded image because “emoji” blinks (dissapears and reappears in a single moment) when new item is added to list.
As for code, I use GlideImagesPlugin
in that way:
Markwon.Builder b = Markwon.builder(context)
.usePlugin(MovementMethodPlugin.create(ScrollingMovementMethod.getInstance()));
b.usePlugin(GlideImagesPlugin.create(new GlideImagesPlugin.GlideStore() {
@NonNull
@Override
public RequestBuilder<Drawable> load(@NonNull AsyncDrawable drawable) {
return Glide.with(context)
.load(drawable.getDestination())
.placeholder(emojiPlaceholder)
.error(emojiPlaceholder)
.fallback(emojiPlaceholder)
.override(emojiSide, emojiSide)
.centerCrop();
}
@Override
public void cancel(@NonNull Target<?> target) {
Glide.with(context).clear(target);
}
}));
markwon = b.build();
and when it comes to getView()
I just call markwon:
markwon.setMarkdown(message, text);
Expected behavior: listview should stay at its bottom.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@ubuntudroid wrong size: placeholder height is bigger/smaller than size of actual image; proper size: placeholder is exact tall as loaded image;
How it works: when using wrong placeholder, item changes its height after actual image been loaded that forces listview to “unpin” list from bottom of the screen.
@iillyyaa2033 could you elaborate? What do you mean by wrong/proper placeholder sizes?