fixed crash when uploading tweet

This commit is contained in:
nuclearfog 2022-01-13 23:36:32 +01:00
parent 62cfab21b4
commit 996ce859fd
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98

View File

@ -40,14 +40,18 @@ public class TweetUpdater extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void[] v) {
try {
long[] mediaIds = {};
String[] mimeTypes = tweet.getMimeTypes();
InputStream[] mediaStreams = tweet.getMediaStreams();
// upload media first
long[] mediaIds = new long[mediaStreams.length];
for (int pos = 0 ; pos < mediaStreams.length ; pos++) {
mediaIds[pos] = twitter.uploadMedia(mediaStreams[pos], mimeTypes[pos]);
mediaStreams[pos].close();
if (mimeTypes != null && mediaStreams !=null) {
// upload media first
mediaIds = new long[mediaStreams.length];
for (int pos = 0; pos < mediaStreams.length; pos++) {
// upload media file and save media ID
mediaIds[pos] = twitter.uploadMedia(mediaStreams[pos], mimeTypes[pos]);
// close stream after upload
mediaStreams[pos].close();
}
}
// upload tweet