Is it possible to provide addTag(String text, in color) method?
I am using 2 layouts in one activity and adding moving tags with color information from one to another.
For example
List<int[]> selectedTagsColors = new ArrayList<>();
List<String> availableTags = new ArrayList<>();
List<int[]> availableTagsColors = new ArrayList<>();
for (Tag t : tags) {
RecordingAndTags recordingAndTags = RecordingAndTagRepo.getInstance().getByRecordingAndTagId(recordingFile.getId(), t.getId());
int bg = t.getRealColor(context);
if (recordingAndTags == null) {
availableTagsColors.add(new int[]{bg, Color.TRANSPARENT, getContrastColor(bg)});
availableTags.add(t.getName());
} else {
selectedTagsColors.add(new int[]{bg, Color.TRANSPARENT, getContrastColor(bg)});
selectedTags.add(t.getName());
}
}
availableTagEditorContainerLayout.setTags(availableTags, availableTagsColors);
selectedTagEditorContainerLayout.setTags(selectedTags, selectedTagsColors);```
and on clicks
availableTagEditorContainerLayout.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(int position, String text) {
//get tag
Tag tag = TagsRepo.getInstance().getByName(availableTagEditorContainerLayout.getTagText(position));
//create relation
RecordingAndTags recordingAndTags = new RecordingAndTags();
recordingAndTags.setRecordingId(recordingFile.getId());
recordingAndTags.setTagId(tag.getId());
//add to list
recordingAndTagsToAdd.add(recordingAndTags);
selectedTagEditorContainerLayout.addTag(text);
availableTagEditorContainerLayout.removeTag(position);
}
@Override
public void onTagLongClick(final int position, String text) {
}
@Override
public void onTagCrossClick(int position) {
}
});
selectedTagEditorContainerLayout.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(int position, String text) {
Tag tag = TagsRepo.getInstance().getByName(selectedTagEditorContainerLayout.getTagText(position));
RecordingAndTags recordingAndTags = RecordingAndTagRepo.getInstance().getByRecordingAndTagId(recordingFile.getId(), tag.getId());
if (recordingAndTags != null) {
recordingAndTagsToRemove.add(recordingAndTags);
}
availableTagEditorContainerLayout.addTag(text);
selectedTagEditorContainerLayout.removeTag(position);
}
@Override
public void onTagLongClick(int position, String text) {
}
@Override
public void onTagCrossClick(int position) {
}
});
I get Java.lang.IndexOutOfBoundsException on addTag(text).
I understand why this as there is no way to remove items from colorlist . An addTag with color method would be very useful.
Is it possible to provide addTag(String text, in color) method? I am using 2 layouts in one activity and adding moving tags with color information from one to another. For example