List of usage examples for twitter4j Status getId
long getId();
From source file:net.lacolaco.smileessence.data.FavoriteCache.java
License:Open Source License
public void put(Status status, boolean favorited) { if (status.isRetweet()) { cache.put(status.getRetweetedStatus().getId(), favorited); } else {// w w w. ja v a 2 s .co m cache.put(status.getId(), favorited); } }
From source file:net.lacolaco.smileessence.data.StatusCache.java
License:Open Source License
/** * Put status into cache/*from w w w. ja v a 2 s.c o m*/ * * @param status * @return the previous value associated with key, or null if there was no mapping for key */ public Status put(Status status) { if (status.isRetweet()) { put(status.getRetweetedStatus()); } if (cache.containsKey(status.getId())) { cache.remove(status.getId()); } return cache.put(status.getId(), status); }
From source file:net.lacolaco.smileessence.IntentRouter.java
License:Open Source License
private static void showStatusDialog(final MainActivity activity, long id) { if (id != -1) { TwitterUtils.tryGetStatus(activity.getCurrentAccount(), id, new TwitterUtils.StatusCallback() { @Override/*from ww w. jav a2s . c om*/ public void success(Status status) { StatusDetailDialogFragment fragment = new StatusDetailDialogFragment(); fragment.setStatusID(status.getId()); DialogHelper.showDialog(activity, fragment); } @Override public void error() { Notificator.publish(activity, R.string.error_intent_status_cannot_load, NotificationType.ALERT); } }); } else { Notificator.publish(activity, R.string.error_intent_status_cannot_load, NotificationType.ALERT); } }
From source file:net.lacolaco.smileessence.twitter.task.DeleteStatusTask.java
License:Open Source License
@Override protected void onPostExecute(twitter4j.Status status) { if (status != null) { StatusCache.getInstance().remove(status.getId()); new Notificator(activity, R.string.notice_status_delete_succeeded).publish(); } else {// w w w . j a va 2 s.c o m new Notificator(activity, R.string.notice_status_delete_failed, NotificationType.ALERT).publish(); } }
From source file:net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment.java
License:Open Source License
private View getTitleView(MainActivity activity, Account account, Status status) { View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null); View statusHeader = view.findViewById(R.id.layout_status_header); StatusViewModel statusViewModel = new StatusViewModel(status, account); statusHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), statusHeader); statusHeader.setClickable(false);//w ww . j ava2 s.c o m int background = ((ColorDrawable) statusHeader.getBackground()).getColor(); view.setBackgroundColor(background); ImageView favCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_fav_count); ImageView rtCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_rt_count); TextView favCountText = (TextView) view.findViewById(R.id.textview_status_detail_fav_count); TextView rtCountText = (TextView) view.findViewById(R.id.textview_status_detail_rt_count); int favoriteCount = TwitterUtils.getOriginalStatus(status).getFavoriteCount(); if (favoriteCount == 0) { favCountIcon.setVisibility(View.GONE); favCountText.setVisibility(View.GONE); } else { favCountText.setText(Integer.toString(favoriteCount)); } int retweetCount = TwitterUtils.getOriginalStatus(status).getRetweetCount(); if (retweetCount == 0) { rtCountIcon.setVisibility(View.GONE); rtCountText.setVisibility(View.GONE); } else { rtCountText.setText(Integer.toString(retweetCount)); } ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu); ImageButton message = (ImageButton) view.findViewById(R.id.button_status_detail_reply); ImageButton retweet = (ImageButton) view.findViewById(R.id.button_status_detail_retweet); ImageButton favorite = (ImageButton) view.findViewById(R.id.button_status_detail_favorite); ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete); menu.setOnClickListener(this); message.setOnClickListener(this); retweet.setOnClickListener(this); favorite.setOnClickListener(this); delete.setOnClickListener(this); if (isNotRetweetable(account, status)) { retweet.setVisibility(View.GONE); } else if (isRetweetDeletable(account, status)) { retweet.setImageDrawable(getResources().getDrawable(R.drawable.icon_retweet_on)); retweet.setTag(status.getId()); } else { retweet.setTag(-1L); } favorite.setTag(statusViewModel.isFavorited()); if (statusViewModel.isFavorited()) { favorite.setImageDrawable(getResources().getDrawable(R.drawable.icon_favorite_on)); } boolean deletable = isDeletable(account, status); delete.setVisibility(deletable ? View.VISIBLE : View.GONE); LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu); commandsLayout.setClickable(true); ArrayList<Command> commands = getCommands(activity, status, account); Command.filter(commands); for (final Command command : commands) { View commandView = command.getView(activity, activity.getLayoutInflater(), null); commandView.setBackgroundColor(getResources().getColor(R.color.transparent)); commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override public void run() { command.execute(); dismiss(); } })); commandsLayout.addView(commandView); } return view; }
From source file:net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment.java
License:Open Source License
private void replyToStatus(MainActivity activity, Status status) { Status originalStatus = TwitterUtils.getOriginalStatus(status); TweetBuilder builder = new TweetBuilder().addScreenName(originalStatus.getUser().getScreenName()); String text = builder.buildText(); PostState.newState().beginTransaction().setText(text).setInReplyToStatusID(originalStatus.getId()) .moveCursor(text.length()).commitWithOpen(activity); }
From source file:net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment.java
License:Open Source License
private void toggleFavorite(MainActivity activity, Account account, Status status, Boolean isFavorited) { long statusID = status.isRetweet() ? status.getRetweetedStatus().getId() : status.getId(); if (isFavorited) { new UnfavoriteTask(TwitterApi.getTwitter(account), statusID, activity).execute(); } else {/*from w w w. jav a 2 s . c o m*/ new FavoriteTask(TwitterApi.getTwitter(account), statusID, activity).execute(); } dismiss(); }
From source file:net.lacolaco.smileessence.viewmodel.EventViewModel.java
License:Open Source License
public EventViewModel(EnumEvent event, User source, Status status) { this.event = event; this.createdAt = new Date(); this.sourceUserID = source.getId(); this.sourceScreenName = source.getScreenName(); this.sourceName = source.getName(); this.iconURL = source.getProfileImageURL(); if (status != null) { if (event == EnumEvent.RETWEETED) { this.targetStatusID = status.getRetweetedStatus().getId(); this.targetText = status.getRetweetedStatus().getText(); } else {/*from w w w . j av a 2s. c o m*/ this.targetStatusID = status.getId(); this.targetText = status.getText(); } } else { this.targetStatusID = -1L; this.targetText = ""; } }
From source file:net.lacolaco.smileessence.viewmodel.StatusViewModel.java
License:Open Source License
public StatusViewModel(Status status, Account account) { if (status.isRetweet()) { retweetedStatus = new StatusViewModel(status.getRetweetedStatus(), account); }//www. j a va2 s.com id = status.getId(); text = TwitterUtils.replaceURLEntities(status.getText(), status.getURLEntities(), false); createdAt = status.getCreatedAt(); source = status.getSource(); mentions = status.getUserMentionEntities(); hashtags = status.getHashtagEntities(); media = status.getMediaEntities(); urls = status.getURLEntities(); symbols = status.getSymbolEntities(); User user = status.getUser(); UserCache.getInstance().put(user); userID = user.getId(); screenName = user.getScreenName(); name = user.getName(); iconURL = user.getProfileImageURLHttps(); isProtected = user.isProtected(); setMention(isMention(account.screenName)); setMyStatus(isMyStatus(account.userID)); setRetweetOfMe(isRetweetOfMe(account.userID)); }
From source file:nl.b3p.viewer.stripes.TwitterActionBean.java
License:Open Source License
public Resolution create() throws JSONException { JSONObject json = new JSONObject(); json.put("success", Boolean.FALSE); String error = null;/*from www . j a va 2 s .c o m*/ try { // The factory instance is re-useable and thread safe. Twitter twitter = new TwitterFactory().getInstance(); Query query = new Query(term); if (latestId != null) { Long longVal = Long.valueOf(latestId); query.setSinceId(longVal); } QueryResult result = twitter.search(query); JSONArray tweets = new JSONArray(); for (Status tweet : result.getTweets()) { //System.out.println(tweet.getFromUser() + ":" + tweet.getText()); JSONObject t = new JSONObject(); t.put("id_str", String.valueOf(tweet.getId())); t.put("text", tweet.getText()); t.put("user_from", tweet.getUser().getScreenName()); t.put("img_url", tweet.getUser().getProfileImageURL()); JSONObject geo = new JSONObject(); if (tweet.getGeoLocation() != null) { geo.put("lat", tweet.getGeoLocation().getLatitude()); geo.put("lon", tweet.getGeoLocation().getLongitude()); } t.put("geo", geo); tweets.put(t); } json.put("tweets", tweets); if (tweets.length() > 0) { json.put("maxId", String.valueOf(result.getMaxId())); } else { json.put("maxId", String.valueOf(latestId)); } json.put("success", Boolean.TRUE); } catch (Exception e) { error = e.toString(); if (e.getCause() != null) { error += "; cause: " + e.getCause().toString(); } } if (error != null) { json.put("error", error); } return new StreamingResolution("application/json", new StringReader(json.toString())); }