Fix issue #486 - Empty images when sharing from another app.
This commit is contained in:
parent
2f9b1e9bcf
commit
b334a5b655
|
@ -676,20 +676,18 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
}
|
||||
|
||||
if (sharedUriList != null && sharedUriList.size() > 0) {
|
||||
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(() -> {
|
||||
List<Uri> uris = new ArrayList<>(sharedUriList);
|
||||
composeAdapter.addAttachment(-1, uris);
|
||||
}, 1000);
|
||||
List<Uri> uris = new ArrayList<>(sharedUriList);
|
||||
Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> {
|
||||
composeAdapter.addAttachment(-1, attachment);
|
||||
});
|
||||
} else if (sharedUri != null && !sharedUri.toString().startsWith("http")) {
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(() -> {
|
||||
List<Uri> uris = new ArrayList<>();
|
||||
uris.add(sharedUri);
|
||||
composeAdapter.addAttachment(-1, uris);
|
||||
}, 1000);
|
||||
List<Uri> uris = new ArrayList<>();
|
||||
uris.add(sharedUri);
|
||||
Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> {
|
||||
composeAdapter.addAttachment(-1, attachment);
|
||||
});
|
||||
} else if (shareURL != null) {
|
||||
|
||||
Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() {
|
||||
@Override
|
||||
public void onDownloaded(String saveFilePath, String downloadUrl, Error error) {
|
||||
|
|
|
@ -178,6 +178,30 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an attachment from ComposeActivity
|
||||
*
|
||||
* @param position int - position of the drawer that added a media
|
||||
* @param attachment Attachment - media attachment
|
||||
*/
|
||||
public void addAttachment(int position, Attachment attachment) {
|
||||
if (position == -1) {
|
||||
position = statusList.size() - 1;
|
||||
}
|
||||
// position = statusCount-1+position;
|
||||
if (statusList.get(position).media_attachments == null) {
|
||||
statusList.get(position).media_attachments = new ArrayList<>();
|
||||
}
|
||||
if (promptDraftListener != null) {
|
||||
promptDraftListener.promptDraft();
|
||||
}
|
||||
int finalPosition = position;
|
||||
statusList.get(finalPosition).media_attachments.add(attachment);
|
||||
notifyItemChanged(finalPosition);
|
||||
|
||||
}
|
||||
|
||||
private static void updateCharacterCount(ComposeViewHolder composeViewHolder) {
|
||||
int charCount = MastodonHelper.countLength(composeViewHolder);
|
||||
composeViewHolder.binding.characterCount.setText(String.valueOf(charCount));
|
||||
|
|
Loading…
Reference in New Issue