List of usage examples for twitter4j DirectMessage getCreatedAt
Date getCreatedAt();
From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java
License:Apache License
public static ServerMessage buildMessage(final String queueName, final DirectMessage dm) { final ServerMessage msg = new ServerMessageImpl(dm.getId(), InternalTwitterConstants.INITIAL_MESSAGE_BUFFER_SIZE); msg.setAddress(new SimpleString(queueName)); msg.setDurable(true);// w ww . j av a 2s . c o m msg.putStringProperty(TwitterConstants.KEY_MSG_TYPE, MessageType.DM.toString()); msg.putStringProperty(TwitterConstants.KEY_ID, read(dm.getId())); msg.putStringProperty(TwitterConstants.KEY_TEXT, read(dm.getText())); msg.putStringProperty(TwitterConstants.KEY_CREATED_AT, read(dm.getCreatedAt())); if (dm.getSender() != null) { buildUserData(InternalTwitterConstants.KEY_USER_SENDER_PREFIX, dm.getSender(), msg); } if (dm.getRecipient() != null) { buildUserData(InternalTwitterConstants.KEY_USER_RECIPIENT_PREFIX, dm.getRecipient(), msg); } msg.putStringProperty(TwitterConstants.KEY_RAW_JSON, dm.toString()); return msg; }
From source file:com.daiv.android.twitter.data.sq_lite.DMDataSource.java
License:Apache License
public synchronized void createDirectMessage(DirectMessage status, int account) { ContentValues values = new ContentValues(); long time = status.getCreatedAt().getTime(); values.put(DMSQLiteHelper.COLUMN_ACCOUNT, account); values.put(DMSQLiteHelper.COLUMN_TEXT, TweetLinkUtils.getLinksInStatus(status)[0]); values.put(DMSQLiteHelper.COLUMN_TWEET_ID, status.getId()); values.put(DMSQLiteHelper.COLUMN_NAME, status.getSender().getName()); values.put(DMSQLiteHelper.COLUMN_PRO_PIC, status.getSender().getOriginalProfileImageURL()); values.put(DMSQLiteHelper.COLUMN_SCREEN_NAME, status.getSender().getScreenName()); values.put(DMSQLiteHelper.COLUMN_TIME, time); values.put(DMSQLiteHelper.COLUMN_RETWEETER, status.getRecipientScreenName()); values.put(DMSQLiteHelper.COLUMN_EXTRA_ONE, status.getRecipient().getOriginalProfileImageURL()); values.put(DMSQLiteHelper.COLUMN_EXTRA_TWO, status.getRecipient().getName()); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, TweetLinkUtils.getLinksInStatus(status)[1]); MediaEntity[] entities = status.getMediaEntities(); if (entities.length > 0) { values.put(DMSQLiteHelper.COLUMN_PIC_URL, entities[0].getMediaURL()); }//from w ww . j a v a 2 s .c o m URLEntity[] urls = status.getURLEntities(); for (URLEntity url : urls) { Log.v("inserting_dm", "url here: " + url.getExpandedURL()); values.put(DMSQLiteHelper.COLUMN_URL, url.getExpandedURL()); } try { database.insert(DMSQLiteHelper.TABLE_DM, null, values); } catch (Exception e) { open(); database.insert(DMSQLiteHelper.TABLE_DM, null, values); } }
From source file:com.dwdesign.tweetings.model.ParcelableDirectMessage.java
License:Open Source License
public ParcelableDirectMessage(final DirectMessage message, final long account_id, final boolean is_gap) { this.account_id = account_id; this.is_gap = is_gap; final User sender = message.getSender(), recipient = message.getRecipient(); message_id = message.getId();// www .ja v a 2s . co m message_timestamp = getTime(message.getCreatedAt()); sender_id = sender != null ? sender.getId() : -1; recipient_id = recipient != null ? recipient.getId() : -1; text = message.getText(); sender_name = sender != null ? sender.getName() : null; recipient_name = recipient != null ? recipient.getName() : null; sender_screen_name = sender != null ? sender.getScreenName() : null; recipient_screen_name = recipient != null ? recipient.getScreenName() : null; sender_profile_image_url = sender != null ? sender.getProfileImageURL() : null; recipient_profile_image_url = recipient != null ? recipient.getProfileImageURL() : null; }
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues makeDirectMessageContentValues(final DirectMessage message, final long account_id) { if (message == null || message.getId() <= 0) return null; final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; values.put(DirectMessages.ACCOUNT_ID, account_id); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); values.put(DirectMessages.SENDER_ID, sender.getId()); values.put(DirectMessages.RECIPIENT_ID, recipient.getId()); values.put(DirectMessages.TEXT, message.getText()); values.put(DirectMessages.SENDER_NAME, sender.getName()); values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName()); values.put(DirectMessages.RECIPIENT_NAME, recipient.getName()); values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName()); final URL sender_profile_image_url = sender.getProfileImageURL(); final URL recipient_profile_image_url = recipient.getProfileImageURL(); if (sender_profile_image_url != null) { values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, sender_profile_image_url.toString()); }//from w w w .j a va2s . c o m if (recipient_profile_image_url != null) { values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, recipient_profile_image_url.toString()); } return values; }
From source file:com.marpies.ane.twitter.utils.DirectMessageUtils.java
License:Apache License
public static JSONObject getJSON(DirectMessage message) throws JSONException { JSONObject dmJSON = new twitter4j.JSONObject(); dmJSON.put("id", message.getId()); dmJSON.put("idStr", String.valueOf(message.getId())); dmJSON.put("text", message.getText()); dmJSON.put("createdAt", message.getCreatedAt()); dmJSON.put("recipient", UserUtils.getJSON(message.getRecipient())); dmJSON.put("sender", UserUtils.getJSON(message.getSender())); return dmJSON; }
From source file:de.vanita5.twittnuker.model.ParcelableDirectMessage.java
License:Open Source License
public ParcelableDirectMessage(final DirectMessage message, final long account_id, final boolean is_outgoing) { this.account_id = account_id; this.is_outgoing = is_outgoing; final User sender = message.getSender(), recipient = message.getRecipient(); final String sender_profile_image_url_string = sender != null ? ParseUtils.parseString(sender.getProfileImageUrlHttps()) : null;/* w w w. j a v a 2 s. co m*/ final String recipient_profile_image_url_string = recipient != null ? ParseUtils.parseString(recipient.getProfileImageUrlHttps()) : null; id = message.getId(); timestamp = getTime(message.getCreatedAt()); sender_id = sender != null ? sender.getId() : -1; recipient_id = recipient != null ? recipient.getId() : -1; text_html = formatDirectMessageText(message); text_plain = message.getText(); sender_name = sender != null ? sender.getName() : null; recipient_name = recipient != null ? recipient.getName() : null; sender_screen_name = sender != null ? sender.getScreenName() : null; recipient_screen_name = recipient != null ? recipient.getScreenName() : null; sender_profile_image_url = sender_profile_image_url_string; recipient_profile_image_url = recipient_profile_image_url_string; text_unescaped = toPlainText(text_html); medias = ParcelableMedia.fromEntities(message); first_media = medias != null && medias.length > 0 ? medias[0].url : null; }
From source file:de.vanita5.twittnuker.util.ContentValuesCreator.java
License:Open Source License
public static ContentValues makeDirectMessageContentValues(final DirectMessage message, final long account_id, final boolean is_outgoing, final boolean large_profile_image) { if (message == null || message.getId() <= 0) return null; final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; final String sender_profile_image_url = ParseUtils.parseString(sender.getProfileImageUrlHttps()); final String recipient_profile_image_url = ParseUtils.parseString(recipient.getProfileImageUrlHttps()); values.put(DirectMessages.ACCOUNT_ID, account_id); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); values.put(DirectMessages.SENDER_ID, sender.getId()); values.put(DirectMessages.RECIPIENT_ID, recipient.getId()); final String text_html = Utils.formatDirectMessageText(message); values.put(DirectMessages.TEXT_HTML, text_html); values.put(DirectMessages.TEXT_PLAIN, message.getText()); values.put(DirectMessages.TEXT_UNESCAPED, toPlainText(text_html)); values.put(DirectMessages.IS_OUTGOING, is_outgoing); values.put(DirectMessages.SENDER_NAME, sender.getName()); values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName()); values.put(DirectMessages.RECIPIENT_NAME, recipient.getName()); values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName()); values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, large_profile_image ? getBiggerTwitterProfileImage(sender_profile_image_url) : sender_profile_image_url); values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, large_profile_image ? getBiggerTwitterProfileImage(recipient_profile_image_url) : recipient_profile_image_url); final ParcelableMedia[] mediaArray = ParcelableMedia.fromEntities(message); if (mediaArray != null) { values.put(DirectMessages.MEDIA, JSONSerializer.toJSONArrayString(mediaArray)); values.put(DirectMessages.FIRST_MEDIA, mediaArray[0].url); }/*w w w . j a v a2 s.co m*/ return values; }
From source file:main.TwitterController.java
License:Open Source License
public void listDirectMessages() throws TwitterException { List<DirectMessage> statusList = null; int counter = 0; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); statusList = twitter.getDirectMessages(); Iterator<DirectMessage> iterator = statusList.iterator(); while (iterator.hasNext()) { DirectMessage s = iterator.next(); System.out.println(++counter + " [" + s.getCreatedAt().toString() + "] " + printUser(s.getSender()) + " to " + printUser(s.getRecipient()) + ": " + s.getText()); if (counter % 10 == 0) { System.out.print("Hit [Enter] to continue, or type q to break: "); String str = null;/*from w ww .ja v a2 s . c o m*/ try { str = in.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (str.length() > 0 && (str.charAt(0) == 'Q' || str.charAt(0) == 'q')) return; } } }
From source file:net.lacolaco.smileessence.view.dialog.MessageDetailDialogFragment.java
License:Open Source License
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); final Account account = activity.getCurrentAccount(); DirectMessage selectedMessage = DirectMessageCache.getInstance().get(getMessageID()); if (selectedMessage == null) { Notificator.publish(getActivity(), R.string.notice_error_get_messages); return new DisposeDialog(getActivity()); }/*ww w . j a va 2 s . c o m*/ View header = getTitleView(activity, account, selectedMessage); ListView listView = (ListView) header.findViewById(R.id.listview_status_detail_reply_to); final MessageListAdapter adapter = new MessageListAdapter(getActivity()); listView.setAdapter(adapter); long replyToMessageId = -1; ArrayList<DirectMessage> allMessages = Lists.newArrayList(DirectMessageCache.getInstance().all()); Collections.sort(allMessages, new Comparator<DirectMessage>() { @Override public int compare(DirectMessage lhs, DirectMessage rhs) { return rhs.getCreatedAt().compareTo(lhs.getCreatedAt()); } }); for (DirectMessage directMessage : allMessages) { if (selectedMessage.getId() == directMessage.getId()) { continue; } if (directMessage.getCreatedAt().getTime() > selectedMessage.getCreatedAt().getTime()) { continue; } if (directMessage.getSenderId() == selectedMessage.getRecipientId() && directMessage.getRecipientId() == selectedMessage.getSenderId()) { replyToMessageId = directMessage.getId(); break; } } if (replyToMessageId == -1) { listView.setVisibility(View.GONE); } else { TwitterUtils.tryGetMessage(account, replyToMessageId, new TwitterUtils.MessageCallback() { @Override public void success(DirectMessage message) { adapter.addToTop(new MessageViewModel(message, account)); adapter.updateForce(); } @Override public void error() { } }); } return new AlertDialog.Builder(getActivity()).setView(header).create(); }
From source file:net.lacolaco.smileessence.viewmodel.MessageViewModel.java
License:Open Source License
public MessageViewModel(DirectMessage directMessage, Account account) { id = directMessage.getId();//from w w w . ja v a 2 s. c o m UserCache.getInstance().put(directMessage.getSender()); senderID = directMessage.getSenderId(); senderScreenName = directMessage.getSenderScreenName(); senderName = directMessage.getSender().getName(); senderIconURL = directMessage.getSender().getProfileImageURL(); recipientId = directMessage.getRecipientId(); recipientScreenName = directMessage.getRecipientScreenName(); text = directMessage.getText(); createdAt = directMessage.getCreatedAt(); myMessage = isMyMessage(account); }