44fb756c5ef5f1f1f8d809e37d7ae14f48b333f0 — Christopher Vollick 1 year, 10 days ago 69f6220
Clear Command Buttons in Message View

We setup the buttons, but never clear them, so when a person has enough
messages in their view and one of them has a button, as they scroll
around and views get recycled the button can be attached onto any
message and not just the ones that actually specify it.

The documentation makes it a bit unclear if the adapter can be set to
null or not... so I just clear it instead. I could leave it, I suppose,
but that feels a bit weird, and the next time we go through this code
we'll just replace it with another one anyway.
1 files changed, 9 insertions(+), 0 deletions(-)

M src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
M src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java => src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +9 -0
@@ 28,6 28,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

@@ 909,6 910,14 @@ public class MessageAdapter extends ArrayAdapter<Message> {
                viewHolder.commands_list.setOnItemClickListener((p, v, pos, id) -> {
                    ((Conversation) conversation).startCommand(adapter.getItem(pos), activity.xmppConnectionService);
            } else {
                // It's unclear if we can set this to null...
                ListAdapter adapter = viewHolder.commands_list.getAdapter();
                if (adapter instanceof ArrayAdapter) {
                    ((ArrayAdapter<?>) adapter).clear();

            if (isInValidSession) {