fix expandable contact clicks handling

This commit is contained in:
kosyak 2023-10-30 19:59:37 +01:00
parent 2d92736810
commit b5b47f8d7d

View file

@ -1575,6 +1575,27 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
super.setAdapter(adapter);
}
}
@Override
public void setOnItemClickListener(OnItemClickListener l) {
setOnChildClickListener((parent, v, groupPosition, childPosition, id) -> {
ExpandableListAdapter expandableAdapter = getExpandableListAdapter();
if (!(expandableAdapter instanceof ExpandableListItemAdapter)) return false;
ExpandableListItemAdapter adapter = (ExpandableListItemAdapter) expandableAdapter;
Object child = expandableAdapter.getChild(groupPosition, childPosition);
for(int i=0;i<adapter.getCount();i++) {
if (child == adapter.getItem(i)) {
l.onItemClick(parent, v, i, id);
return true;
}
}
return false;
});
}
}
class ExpandableListItemAdapter extends ListItemAdapter implements ExpandableListAdapter {
@ -1690,7 +1711,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
return true;
}
@Override
@ -1712,9 +1733,5 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
public long getCombinedGroupId(long groupId) {
return (groupId & 0x7FFFFFFF) << 32;
}
private int dpToPx(int dp) {
return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}
}
}