mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
I replaced uploadMediaDetail.get(position) with a direct reference to uploadMediaDetail in 3 locations to avoid out of bounds errors. The usage of RecyclerView in this code is still a bit buggy, and maybe a RecyclerView is not necessary here since the number of items is limited. The fix also revealed problems in the logic of adding the "addButton" only to the last item, which couldn't be reproduced before because the app crashed first. I can submit a new bug for that if this fix goes live. I did not feel very comfortable with the code so I restricted my commit to fixing the first reported crash, which was resolved in my tests.
This commit is contained in:
parent
06e25a074c
commit
8fdfb8e6dc
1 changed files with 3 additions and 12 deletions
|
|
@ -197,14 +197,7 @@ public class UploadMediaDetailAdapter extends
|
|||
*/
|
||||
public void removeDescription(final UploadMediaDetail uploadMediaDetail, final int position) {
|
||||
selectedLanguages.remove(position);
|
||||
int listPosition = 0;
|
||||
List<Integer> keysList = new ArrayList<>(selectedLanguages.keySet());
|
||||
for (Integer key : keysList) {
|
||||
if (key < position) {
|
||||
listPosition++;
|
||||
}
|
||||
}
|
||||
this.uploadMediaDetails.remove(uploadMediaDetails.get(listPosition));
|
||||
this.uploadMediaDetails.remove(uploadMediaDetail);
|
||||
int i = position + 1;
|
||||
while (selectedLanguages.containsKey(i)) {
|
||||
selectedLanguages.remove(i);
|
||||
|
|
@ -311,12 +304,10 @@ public class UploadMediaDetailAdapter extends
|
|||
|
||||
removeButton.setOnClickListener(v -> removeDescription(uploadMediaDetail, position));
|
||||
captionListener = new AbstractTextWatcher(
|
||||
captionText -> uploadMediaDetails.get(position)
|
||||
.setCaptionText(convertIdeographicSpaceToLatinSpace(
|
||||
captionText -> uploadMediaDetail.setCaptionText(convertIdeographicSpaceToLatinSpace(
|
||||
removeLeadingAndTrailingWhitespace(captionText))));
|
||||
descriptionListener = new AbstractTextWatcher(
|
||||
descriptionText -> uploadMediaDetails.get(position)
|
||||
.setDescriptionText(descriptionText));
|
||||
descriptionText -> uploadMediaDetail.setDescriptionText(descriptionText));
|
||||
captionItemEditText.addTextChangedListener(captionListener);
|
||||
initLanguage(position, uploadMediaDetail);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue