mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-04-06 07:00:01 +03:00
Fix a crash when adding a media
This commit is contained in:
parent
65dea8bf56
commit
ab30fc7bf2
2 changed files with 11 additions and 9 deletions
|
@ -1152,15 +1152,17 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class);
|
||||
statusesVM.getAttachment(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, attachment.id)
|
||||
.observe((LifecycleOwner) context, attachmentReceived -> {
|
||||
List<Attachment> attachments = statusList.get(position).media_attachments;
|
||||
for(Attachment attach : attachments) {
|
||||
if(attach.id.equals(attachment.id)) {
|
||||
statusList.get(position).media_attachments.remove(attachment);
|
||||
break;
|
||||
if(attachmentReceived != null) {
|
||||
List<Attachment> attachments = statusList.get(position).media_attachments;
|
||||
for(Attachment attach : attachments) {
|
||||
if(attach.id != null && attach.id.equals(attachment.id)) {
|
||||
statusList.get(position).media_attachments.remove(attachment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
statusList.get(position).media_attachments.add(attachmentReceived);
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
statusList.get(position).media_attachments.add(attachmentReceived);
|
||||
notifyItemChanged(position);
|
||||
});
|
||||
}
|
||||
ComposeAttachmentItemBinding composeAttachmentItemBinding = ComposeAttachmentItemBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
||||
|
|
|
@ -135,9 +135,9 @@ public class StatusDraftAdapter extends RecyclerView.Adapter<StatusDraftAdapter.
|
|||
}
|
||||
}
|
||||
//If there are media, we need to remove them first.
|
||||
if (attachments.size() > 0) {
|
||||
if (!attachments.isEmpty()) {
|
||||
for (Attachment attachment : attachments) {
|
||||
if (attachment.local_path != null) {
|
||||
if (attachment != null && attachment.local_path != null) {
|
||||
File fileToDelete = new File(attachment.local_path);
|
||||
if (fileToDelete.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
|
|
Loading…
Reference in a new issue