Search in sources :

Example 1 with TweetUpdate

use of org.nuclearfog.twidda.backend.api.holder.TweetUpdate in project Shitter by nuclearfog.

the class TweetUpdater method doInBackground.

@Override
protected Void doInBackground(TweetUpdate... tweets) {
    TweetUpdate update = tweets[0];
    try {
        // upload media first
        MediaStream[] mediaStreams = update.getMediaStreams();
        long[] 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]);
        }
        // upload tweet
        if (!isCancelled()) {
            twitter.uploadTweet(update, mediaIds);
        }
    } catch (TwitterException twException) {
        this.twException = twException;
    } finally {
        // close inputstreams
        update.close();
    }
    return null;
}
Also used : MediaStream(org.nuclearfog.twidda.backend.api.holder.MediaStream) TweetUpdate(org.nuclearfog.twidda.backend.api.holder.TweetUpdate) TwitterException(org.nuclearfog.twidda.backend.api.TwitterException)

Aggregations

TwitterException (org.nuclearfog.twidda.backend.api.TwitterException)1 MediaStream (org.nuclearfog.twidda.backend.api.holder.MediaStream)1 TweetUpdate (org.nuclearfog.twidda.backend.api.holder.TweetUpdate)1