List of usage examples for twitter4j Status getUser
User getUser();
From source file:com.klinker.android.twitter.services.TalonPullNotificationService.java
License:Apache License
public void downloadImages(Status status) { String profilePic = status.getUser().getBiggerProfileImageURL(); String imageUrl = TweetLinkUtils.getLinksInStatus(status)[1]; CacheableBitmapDrawable wrapper = null; try {//from www. j av a2 s .c o m wrapper = mCache.get(profilePic); } catch (OutOfMemoryError e) { } if (wrapper == null) { try { HttpURLConnection conn = (HttpURLConnection) new URL(profilePic).openConnection(); InputStream is = new BufferedInputStream(conn.getInputStream()); Bitmap image = decodeSampledBitmapFromResourceMemOpt(is, 500, 500); try { is.close(); } catch (Exception e) { } try { conn.disconnect(); } catch (Exception e) { } if (settings.roundContactImages) { image = ImageUtils.getCircle(image, this); } mCache.put(profilePic, image); } catch (Throwable e) { } } if (!imageUrl.equals("")) { try { wrapper = mCache.get(imageUrl); } catch (OutOfMemoryError e) { wrapper = null; } if (wrapper == null) { try { if (!imageUrl.contains(" ")) { HttpURLConnection conn = (HttpURLConnection) new URL(imageUrl).openConnection(); InputStream is = new BufferedInputStream(conn.getInputStream()); Bitmap image = decodeSampledBitmapFromResourceMemOpt(is, 1000, 1000); try { is.close(); } catch (Exception e) { } try { conn.disconnect(); } catch (Exception e) { } mCache.put(imageUrl, image); } else { String[] pics = imageUrl.split(" "); Bitmap[] bitmaps = new Bitmap[pics.length]; // need to download all of them, then combine them for (int i = 0; i < pics.length; i++) { String s = pics[i]; // The bitmap isn't cached so download from the web HttpURLConnection conn = (HttpURLConnection) new URL(s).openConnection(); InputStream is = new BufferedInputStream(conn.getInputStream()); Bitmap b = decodeSampledBitmapFromResourceMemOpt(is, 1000, 1000); try { is.close(); } catch (Exception e) { } try { conn.disconnect(); } catch (Exception e) { } // Add to cache try { mCache.put(s, b); // throw it into our bitmap array for later bitmaps[i] = b; } catch (Exception e) { } } // now that we have all of them, we need to put them together Bitmap combined = ImageUtils.combineBitmaps(this, bitmaps); try { mCache.put(imageUrl, combined); } catch (Exception e) { } } } catch (Throwable e) { } } } }
From source file:com.klinker.android.twitter.ui.tweet_viewer.ViewRetweeters.java
License:Apache License
public void onRefreshStarted() { new Thread(new Runnable() { @Override/*from w w w. j a va 2 s.c o m*/ public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); Status stat = twitter.showStatus(tweetId); if (stat.isRetweet()) { tweetId = stat.getRetweetedStatus().getId(); } // can get 100 retweeters is all ResponseList<twitter4j.Status> lists = twitter.getRetweets(tweetId); users.clear(); for (Status status : lists) { users.add(status.getUser()); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { adapter = new PeopleArrayAdapter(context, users); listView.setAdapter(adapter); listView.setVisibility(View.VISIBLE); spinner.setVisibility(View.GONE); if (users.size() == 0) { noContent.setVisibility(View.VISIBLE); } mPullToRefreshLayout.setRefreshing(false); } }); } catch (Exception e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } } }).start(); }
From source file:com.krossovochkin.kwitter.adapters.TimelineAdapter.java
License:Apache License
@Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { ViewHolder holder = (ViewHolder) viewHolder; Status status = mData.get(position); holder.setText(status.getText());//from w w w . j a v a 2 s . c o m holder.setImage(status.getUser().getBiggerProfileImageURLHttps()); holder.setUserName(status.getUser().getScreenName()); holder.setText(mData.get(position).getText()); holder.initButtons(mListener, position); }
From source file:com.krossovochkin.kwitter.fragments.SendTweetFragment.java
License:Apache License
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final EditText tweetEditText = (EditText) getView().findViewById(R.id.tweet_edit_text); final FloatingActionButton sendTweetButton = (FloatingActionButton) getView() .findViewById(R.id.send_tweet_button); final TextView symbolCounterTextView = (TextView) getView().findViewById(R.id.char_counter_text_view); tweetEditText.addTextChangedListener(new TextWatcher() { @Override/*from ww w .j a va 2 s. c o m*/ public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { if (tweetEditText.getText() != null) { int charsLeft = getResources().getInteger(R.integer.max_tweet_char_length) - tweetEditText.getText().length(); symbolCounterTextView.setText(String.valueOf(charsLeft)); if (charsLeft < 0) { sendTweetButton.setEnabled(false); } else { sendTweetButton.setEnabled(true); } } } }); if (isReply()) { Status status = (Status) getArguments().getSerializable(Constants.STATUS_KEY); StringBuilder mentions = new StringBuilder(); mentions.append("@"); mentions.append(status.getUser().getScreenName()); mentions.append(" "); for (UserMentionEntity mentionEntity : status.getUserMentionEntities()) { mentions.append("@"); mentions.append(mentionEntity.getScreenName()); mentions.append(" "); } tweetEditText.setText(mentions.toString()); } sendTweetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (twitterActionListener != null) { if (tweetEditText.getText() != null) { if (isReply()) { Status status = (Status) getArguments().getSerializable(Constants.STATUS_KEY); twitterActionListener.sendReplyRequest(status, tweetEditText.getText().toString()); } else { twitterActionListener.sendTweetRequest(tweetEditText.getText().toString()); } getFragmentManager().popBackStack(); } else { Log.e(TAG, "tweetEditText has no text"); } } else { Log.e(TAG, "twitterActionListener from SendTweetFragment is null, did the fragment" + "is attached to activity?"); } } }); KeyboardHelper.showSoftKeyboard(getActivity(), tweetEditText); }
From source file:com.lambda.stack.UserMapper.java
@Override public Iterable<Tuple2<String, Integer>> call(Status t) throws Exception { return Collections.singletonList(new Tuple2<>(t.getUser().getName(), Integer.valueOf(1))); }
From source file:com.lbarriosh.sentimentanalyzer.main.Main.java
License:Open Source License
private static void printTweets(List<Status> tweets) { for (Status tweet : tweets) { System.out.println("@" + tweet.getUser().getName() + ": " + tweet.getText()); }// w w w . j a v a2 s .co m }
From source file:com.learnncode.twitter.TweetViewHolder.java
License:Apache License
public void populateView(final Context context, final Status status) { mContext = context;/*from ww w .j av a 2 s. c o m*/ if (status.getUser().getId() != AppSettings.getTwitterUserId(mContext)) { retweetTextView.setEnabled(true); } else { retweetTextView.setEnabled(false); } retweetTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.retweet_action_selector, 0); aQuery = new AQuery(mContext); aQuery.id(userProfileImageView).image(status.getUser().getBiggerProfileImageURL(), true, true, userProfileImageView.getWidth(), 0, null, 0); userNameTextView.setText(status.getUser().getName()); twitterHandlerTextView.setText("@" + status.getUser().getScreenName()); setMessage(mContext, tweetTextView, status.getText()); favoriteTextView.setText(" " + status.getFavoriteCount()); retweetTextView.setText(" " + status.getRetweetCount()); timeTextView.setText(AppUtilities.getConvertDate(status.getCreatedAt().toString())); twitter4j.MediaEntity[] entity = status.getMediaEntities(); int count = entity.length; if (count > 0) { imageContainer.setVisibility(View.VISIBLE); imageWithTweet.setVisibility(View.VISIBLE); for (int i = 0; i < count; i++) { mImageLink = entity[i].getMediaURL(); aQuery.id(imageWithTweet).image(entity[i].getMediaURL(), true, true, userProfileImageView.getWidth(), 0, null, 0); } } else { imageContainer.setVisibility(View.GONE); imageWithTweet.setVisibility(View.GONE); } imageWithTweet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(context, UIImagePreview.class); intent.putExtra("url", mImageLink); context.startActivity(intent); } }); }
From source file:com.lorenzobraghetto.speakbird.View.MentionsAdapter.java
License:Open Source License
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder;/*www. j a v a2 s.com*/ if (convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.mentionslist, null); holder.imgViewLogo = (ImageView) convertView.findViewById(R.id.personImage); holder.txtViewNick = (TextView) convertView.findViewById(R.id.personName); holder.txtViewText = (TextView) convertView.findViewById(R.id.testo); holder.txtViewTime = (TextView) convertView.findViewById(R.id.time); holder.background = (RelativeLayout) convertView.findViewById(R.id.layout); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); long d; String urlimg; String nick; String text; if (type.compareTo("mentions") == 0) { Status bean = (Status) itemList.get(position); d = bean.getCreatedAt().getTime(); urlimg = bean.getUser().getProfileImageURL() + ""; nick = bean.getUser().getScreenName(); text = bean.getText(); } else { DirectMessage bean = (DirectMessage) itemList.get(position); d = bean.getCreatedAt().getTime(); urlimg = bean.getSender().getProfileImageURL() + ""; nick = bean.getSender().getScreenName(); text = bean.getText(); } long now = System.currentTimeMillis(); long elapsed = now - d; int minutes = (int) ((elapsed / (1000 * 60)) % 60); int hours = (int) ((elapsed / (1000 * 60 * 60)) % 24); int days = (int) ((elapsed / (1000 * 60 * 60 * 24))); UrlImageViewHelper.setUrlDrawable(holder.imgViewLogo, urlimg); holder.txtViewNick.setText("@" + nick); holder.txtViewText.setText(text); if (days > 0 && hours > 0 && minutes > 0) holder.txtViewTime.setText(days + "d " + hours + "h " + minutes + "m "); else if (hours > 0 && minutes > 0) holder.txtViewTime.setText(hours + "h " + minutes + "m "); else holder.txtViewTime.setText(minutes + "m "); if (position == itemColored) { holder.background.setBackgroundColor(0xffa4a4a4); } else if (first == d) { holder.background .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sfondotweetunonove)); } else { holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sfondotweetnove)); } return convertView; }
From source file:com.marklogic.tweetdeck.LoadRawJSON.java
License:Apache License
/** * Usage: java twitter4j.examples.json.LoadRawJSON * * @param args String[]/*from w w w.j av a2 s. com*/ */ public static void main(String[] args) { try { File[] files = new File("statuses").listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".json"); } }); for (File file : files) { String rawJSON = readFirstLine(file); Status status = TwitterObjectFactory.createStatus(rawJSON); System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } System.exit(0); } catch (IOException ioe) { ioe.printStackTrace(); System.out.println("Failed to store tweets: " + ioe.getMessage()); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }
From source file:com.marpies.ane.twitter.utils.StatusUtils.java
License:Apache License
public static JSONObject getJSON(Status status) throws JSONException { JSONObject statusJSON = new JSONObject(); statusJSON.put("id", status.getId()); statusJSON.put("idStr", String.valueOf(status.getId())); statusJSON.put("text", status.getText()); statusJSON.put("replyToUserID", status.getInReplyToUserId()); statusJSON.put("replyToStatusID", status.getInReplyToStatusId()); statusJSON.put("likesCount", status.getFavoriteCount()); statusJSON.put("retweetCount", status.getRetweetCount()); statusJSON.put("isRetweet", status.isRetweet()); statusJSON.put("isSensitive", status.isPossiblySensitive()); statusJSON.put("createdAt", status.getCreatedAt()); Status retweetedStatus = status.getRetweetedStatus(); if (retweetedStatus != null) { statusJSON.put("retweetedStatus", getJSON(retweetedStatus)); }// w ww. j a va 2 s.c o m User user = status.getUser(); if (user != null) { statusJSON.put("user", UserUtils.getJSON(user)); } return statusJSON; }