use of com.klinker.android.twitter.utils.api_helper.TwitPicHelper 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;
}
}
Aggregations