Commit ab30fc7b authored by Thomas's avatar Thomas
Browse files

Fix a crash when adding a media

parent 65dea8bf
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -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 -> {
                                    if(attachmentReceived != null) {
                                        List<Attachment> attachments = statusList.get(position).media_attachments;
                                        for(Attachment attach : attachments) {
                                        if(attach.id.equals(attachment.id)) {
                                            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);
                                    }
                                });
                    }
                    ComposeAttachmentItemBinding composeAttachmentItemBinding = ComposeAttachmentItemBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
+2 −2
Original line number Diff line number Diff line
@@ -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