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) {
|
if (sharedUriList != null && sharedUriList.size() > 0) {
|
||||||
|
List<Uri> uris = new ArrayList<>(sharedUriList);
|
||||||
Handler handler = new Handler();
|
Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> {
|
||||||
handler.postDelayed(() -> {
|
composeAdapter.addAttachment(-1, attachment);
|
||||||
List<Uri> uris = new ArrayList<>(sharedUriList);
|
});
|
||||||
composeAdapter.addAttachment(-1, uris);
|
|
||||||
}, 1000);
|
|
||||||
} else if (sharedUri != null && !sharedUri.toString().startsWith("http")) {
|
} else if (sharedUri != null && !sharedUri.toString().startsWith("http")) {
|
||||||
Handler handler = new Handler();
|
List<Uri> uris = new ArrayList<>();
|
||||||
handler.postDelayed(() -> {
|
uris.add(sharedUri);
|
||||||
List<Uri> uris = new ArrayList<>();
|
Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> {
|
||||||
uris.add(sharedUri);
|
composeAdapter.addAttachment(-1, attachment);
|
||||||
composeAdapter.addAttachment(-1, uris);
|
});
|
||||||
}, 1000);
|
|
||||||
} else if (shareURL != null) {
|
} else if (shareURL != null) {
|
||||||
|
|
||||||
Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() {
|
Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void onDownloaded(String saveFilePath, String downloadUrl, Error error) {
|
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) {
|
private static void updateCharacterCount(ComposeViewHolder composeViewHolder) {
|
||||||
int charCount = MastodonHelper.countLength(composeViewHolder);
|
int charCount = MastodonHelper.countLength(composeViewHolder);
|
||||||
composeViewHolder.binding.characterCount.setText(String.valueOf(charCount));
|
composeViewHolder.binding.characterCount.setText(String.valueOf(charCount));
|
||||||
|
|
Loading…
Reference in New Issue