Search in sources :

Example 1 with TwitLongerHelper

use of com.klinker.android.twitter.utils.api_helper.TwitLongerHelper in project Talon-for-Twitter by klinker24.

the class SendTweet method sendTweet.

public boolean sendTweet(AppSettings settings, Context context) {
    try {
        Twitter twitter = getTwitter();
        if (remainingChars < 0 && !pwiccer) {
            // twitlonger goes here
            TwitLongerHelper helper = new TwitLongerHelper(message, twitter);
            helper.setInReplyToStatusId(tweetId);
            return helper.createPost() != 0;
        } else {
            twitter4j.StatusUpdate reply = new twitter4j.StatusUpdate(message);
            reply.setInReplyToStatusId(tweetId);
            if (!attachedUri.equals("")) {
                // context being the Activity pointer
                File outputDir = context.getCacheDir();
                File f = File.createTempFile("compose", "picture", outputDir);
                Bitmap bitmap = getBitmapToSend(Uri.parse(attachedUri), context);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
                byte[] bitmapdata = bos.toByteArray();
                FileOutputStream fos = new FileOutputStream(f);
                fos.write(bitmapdata);
                fos.flush();
                fos.close();
                if (!settings.twitpic) {
                    reply.setMedia(f);
                    twitter.updateStatus(reply);
                    return true;
                } else {
                    TwitPicHelper helper = new TwitPicHelper(twitter, message, f, context);
                    helper.setInReplyToStatusId(tweetId);
                    return helper.createPost() != 0;
                }
            } else {
                // no picture
                twitter.updateStatus(reply);
                return true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : Bitmap(android.graphics.Bitmap) TwitPicHelper(com.klinker.android.twitter.utils.api_helper.TwitPicHelper) FileOutputStream(java.io.FileOutputStream) Twitter(twitter4j.Twitter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) TwitLongerHelper(com.klinker.android.twitter.utils.api_helper.TwitLongerHelper) IOException(java.io.IOException)

Example 2 with TwitLongerHelper

use of com.klinker.android.twitter.utils.api_helper.TwitLongerHelper in project Talon-for-Twitter by klinker24.

the class SendScheduledTweet method sendTweet.

public boolean sendTweet(AppSettings settings, Context context, String message, int account) {
    try {
        Twitter twitter;
        if (account == settings.currentAccount) {
            twitter = Utils.getTwitter(context, settings);
        } else {
            twitter = Utils.getSecondTwitter(context);
        }
        int size = getCount(message);
        Log.v("talon_queued", "sending: " + message);
        if (size > AppSettings.getInstance(this).tweetCharacterCount && settings.twitlonger) {
            // twitlonger goes here
            TwitLongerHelper helper = new TwitLongerHelper(message, twitter);
            return helper.createPost() != 0;
        } else if (size <= AppSettings.getInstance(this).tweetCharacterCount) {
            twitter4j.StatusUpdate reply = new twitter4j.StatusUpdate(message);
            twitter.updateStatus(reply);
        } else {
            return false;
        }
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : Twitter(twitter4j.Twitter) TwitLongerHelper(com.klinker.android.twitter.utils.api_helper.TwitLongerHelper)

Example 3 with TwitLongerHelper

use of com.klinker.android.twitter.utils.api_helper.TwitLongerHelper in project Talon-for-Twitter by klinker24.

the class SendQueue method sendTweet.

public boolean sendTweet(AppSettings settings, Context context, String message) {
    try {
        Twitter twitter = Utils.getTwitter(context, settings);
        int size = getCount(message);
        Log.v("talon_queued", "sending: " + message);
        if (size > AppSettings.getInstance(this).tweetCharacterCount && settings.twitlonger) {
            // twitlonger goes here
            TwitLongerHelper helper = new TwitLongerHelper(message, twitter);
            return helper.createPost() != 0;
        } else if (size <= AppSettings.getInstance(this).tweetCharacterCount) {
            twitter4j.StatusUpdate reply = new twitter4j.StatusUpdate(message);
            twitter.updateStatus(reply);
        } else {
            return false;
        }
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : Twitter(twitter4j.Twitter) TwitLongerHelper(com.klinker.android.twitter.utils.api_helper.TwitLongerHelper)

Aggregations

TwitLongerHelper (com.klinker.android.twitter.utils.api_helper.TwitLongerHelper)3 Twitter (twitter4j.Twitter)3 Bitmap (android.graphics.Bitmap)1 TwitPicHelper (com.klinker.android.twitter.utils.api_helper.TwitPicHelper)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1