List of usage examples for twitter4j User getScreenName
String getScreenName();
From source file:com.daiv.android.twitter.adapters.PicturesArrayAdapter.java
License:Apache License
public void bindView(final View view, Context mContext, final String url, final Status status) { final ViewHolder holder = (ViewHolder) view.getTag(); Log.v("Test_picture", "text: " + status.getText()); Status thisStatus;/*from w w w.ja va2 s . c o m*/ String retweeter; final long time = status.getCreatedAt().getTime(); long originalTime = 0; if (status.isRetweet()) { retweeter = status.getUser().getScreenName(); thisStatus = status.getRetweetedStatus(); originalTime = thisStatus.getCreatedAt().getTime(); } else { retweeter = ""; thisStatus = status; } final String fRetweeter = retweeter; final long fOriginalTime = originalTime; User user = thisStatus.getUser(); final long id = thisStatus.getId(); final String profilePic = user.getBiggerProfileImageURL(); String tweetTexts = thisStatus.getText(); final String name = user.getName(); final String screenname = user.getScreenName(); String[] html = TweetLinkUtils.getLinksInStatus(thisStatus); final String tweetText = html[0]; final String picUrl = html[1]; final String otherUrl = html[2]; final String hashtags = html[3]; final String users = html[4]; holder.url = url; holder.iv.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() { @Override public void onImageLoaded(CacheableBitmapDrawable result) { holder.iv.setBackgroundDrawable(null); } }); holder.iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String link; boolean displayPic = !picUrl.equals(""); if (displayPic) { link = picUrl; } else { link = otherUrl.split(" ")[0]; } Log.v("tweet_page", "clicked"); } }); }
From source file:com.daiv.android.twitter.adapters.TimelineArrayAdapter.java
License:Apache License
public void bindView(final View view, Status status, int position) { final ViewHolder holder = (ViewHolder) view.getTag(); if (holder.expandArea.getVisibility() == View.VISIBLE) { removeExpansionNoAnimation(holder); }//from w w w.j av a 2 s . co m Status thisStatus; String retweeter; final long time = status.getCreatedAt().getTime(); long originalTime = 0; if (status.isRetweet()) { retweeter = status.getUser().getScreenName(); thisStatus = status.getRetweetedStatus(); originalTime = thisStatus.getCreatedAt().getTime(); } else { retweeter = ""; thisStatus = status; } final long fOriginalTime = originalTime; User user = thisStatus.getUser(); holder.tweetId = thisStatus.getId(); final long id = holder.tweetId; final String profilePic = user.getOriginalProfileImageURL(); String tweetTexts = thisStatus.getText(); final String name = user.getName(); final String screenname = user.getScreenName(); String[] html = TweetLinkUtils.getLinksInStatus(thisStatus); final String tweetText = html[0]; final String picUrl = html[1]; holder.picUrl = picUrl; final String otherUrl = html[2]; final String hashtags = html[3]; final String users = html[4]; final boolean inAConversation = thisStatus.getInReplyToStatusId() != -1; holder.gifUrl = TweetLinkUtils.getGIFUrl(status, otherUrl); if (holder.isAConversation != null) { if (inAConversation) { if (holder.isAConversation.getVisibility() != View.VISIBLE) { holder.isAConversation.setVisibility(View.VISIBLE); } } else { if (holder.isAConversation.getVisibility() != View.GONE) { holder.isAConversation.setVisibility(View.GONE); } } } if (!settings.reverseClickActions) { final String fRetweeter = retweeter; holder.background.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { String link; boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty(); boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube") && !(hasGif); if (displayPic) { link = holder.picUrl; } else { link = otherUrl.split(" ")[0]; } Log.v("tweet_page", "clicked"); return true; } }); holder.background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (holder.preventNextClick) { holder.preventNextClick = false; return; } if (holder.expandArea.getVisibility() == View.GONE) { addExpansion(holder, screenname, users, otherUrl.split(" "), holder.picUrl, id); } else { removeExpansionWithAnimation(holder); removeKeyboard(holder); } } }); } else { final String fRetweeter = retweeter; holder.background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (holder.preventNextClick) { holder.preventNextClick = false; return; } String link; boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty(); boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube") && !(hasGif); if (displayPic) { link = holder.picUrl; } else { link = otherUrl.split(" ")[0]; } Log.v("tweet_page", "clicked"); } }); holder.background.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (holder.expandArea.getVisibility() == View.GONE) { addExpansion(holder, screenname, users, otherUrl.split(" "), holder.picUrl, id); } else { removeExpansionWithAnimation(holder); removeKeyboard(holder); } return true; } }); } if (!screenname.equals(username)) { } else { // need to clear the click listener so it isn't left over from another profile holder.profilePic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); holder.profilePic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { return true; } }); } if (TestLayout == AppSettings.LAYOUT_FULL_SCREEN || (settings.nameAndHandleOnTweet && settings.addonTheme)) { if (holder.screenTV.getVisibility() == View.GONE) { holder.screenTV.setVisibility(View.VISIBLE); } holder.screenTV.setText("@" + screenname); holder.name.setText(name); } else { if (!settings.showBoth) { holder.name.setText(settings.displayScreenName ? "@" + screenname : name); } else { if (holder.screenTV.getVisibility() == View.GONE) { holder.screenTV.setVisibility(View.VISIBLE); } holder.name.setText(name); holder.screenTV.setText("@" + screenname); } } if (!settings.absoluteDate) { holder.time.setText(Utils.getTimeAgo(time, context)); } else { Date date = new Date(time); holder.time .setText(timeFormatter.format(date).replace("24:", "00:") + ", " + dateFormatter.format(date)); } holder.tweet.setText(tweetText); boolean picture = false; if (settings.inlinePics) { if (holder.picUrl.equals("")) { if (holder.image.getVisibility() != View.GONE) { holder.image.setVisibility(View.GONE); } if (holder.playButton.getVisibility() == View.VISIBLE) { holder.playButton.setVisibility(View.GONE); } } else { if (holder.picUrl.contains("youtube") || (holder.gifUrl != null && !android.text.TextUtils.isEmpty(holder.gifUrl))) { if (holder.playButton.getVisibility() == View.GONE) { holder.playButton.setVisibility(View.VISIBLE); } final String fRetweeter = retweeter; holder.image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String link; boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty(); boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube") && !(hasGif); if (displayPic) { link = holder.picUrl; } else { link = otherUrl.split(" ")[0]; } } }); holder.image.setImageDrawable(transparent); picture = true; } else { holder.image.setImageDrawable(transparent); picture = true; if (holder.playButton.getVisibility() == View.VISIBLE) { holder.playButton.setVisibility(View.GONE); } } if (holder.image.getVisibility() == View.GONE) { holder.image.setVisibility(View.VISIBLE); } } } if (type == NORMAL) { if (retweeter.length() > 0) { holder.retweeter.setText(context.getResources().getString(R.string.retweeter) + retweeter); holder.retweeterName = retweeter; holder.retweeter.setVisibility(View.VISIBLE); } else if (holder.retweeter.getVisibility() == View.VISIBLE) { holder.retweeter.setVisibility(View.GONE); } } else if (type == RETWEET) { int count = status.getRetweetCount(); if (count > 1) { holder.retweeter.setText( status.getRetweetCount() + " " + context.getResources().getString(R.string.retweets_lower)); holder.retweeter.setVisibility(View.VISIBLE); } else if (count == 1) { holder.retweeter.setText( status.getRetweetCount() + " " + context.getResources().getString(R.string.retweet_lower)); holder.retweeter.setVisibility(View.VISIBLE); } } if (picture) { CacheableBitmapDrawable wrapper = mCache.getFromMemoryCache(holder.picUrl); if (wrapper != null) { holder.image.setImageDrawable(wrapper); picture = false; } } final boolean hasPicture = picture; mHandler[currHandler].removeCallbacksAndMessages(null); mHandler[currHandler].postDelayed(new Runnable() { @Override public void run() { if (holder.tweetId == id) { if (hasPicture) { loadImage(context, holder, holder.picUrl, mCache, id); } if (settings.useEmoji && (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || EmojiUtils.ios)) { String text = holder.tweet.getText().toString(); if (EmojiUtils.emojiPattern.matcher(text).find()) { final Spannable span = EmojiUtils.getSmiledText(context, Html.fromHtml(tweetText)); holder.tweet.setText(span); } } holder.tweet.setSoundEffectsEnabled(false); holder.tweet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!TouchableMovementMethod.touched) { // we need to manually set the background for click feedback because the spannable // absorbs the click on the background if (!holder.preventNextClick) { holder.background.getBackground() .setState(new int[] { android.R.attr.state_pressed }); new Handler().postDelayed(new Runnable() { @Override public void run() { holder.background.getBackground() .setState(new int[] { android.R.attr.state_empty }); } }, 25); } holder.background.performClick(); } } }); holder.tweet.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (!TouchableMovementMethod.touched) { holder.background.performLongClick(); holder.preventNextClick = true; } return false; } }); if (holder.retweeter.getVisibility() == View.VISIBLE) { holder.retweeter.setSoundEffectsEnabled(false); holder.retweeter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!TouchableMovementMethod.touched) { if (!holder.preventNextClick) { holder.background.getBackground() .setState(new int[] { android.R.attr.state_pressed }); new Handler().postDelayed(new Runnable() { @Override public void run() { holder.background.getBackground() .setState(new int[] { android.R.attr.state_empty }); } }, 25); } holder.background.performClick(); } } }); holder.retweeter.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (!TouchableMovementMethod.touched) { holder.background.performLongClick(); holder.preventNextClick = true; } return false; } }); } TextUtils.linkifyText(context, holder.tweet, holder.background, true, otherUrl, false); TextUtils.linkifyText(context, holder.retweeter, holder.background, true, "", false); } } }, 400); currHandler++; if (currHandler == 10) { currHandler = 0; } if (openFirst && position == 0) { holder.background.performClick(); } }
From source file:com.daiv.android.twitter.adapters.UserListMembersArrayAdapter.java
License:Apache License
@Override public void bindView(final View view, int position, final User user) { final ViewHolder holder = (ViewHolder) view.getTag(); final long id = user.getId(); holder.userId = id;//from w w w . jav a 2s .c o m holder.name.setText(user.getName()); holder.screenName.setText("@" + user.getScreenName()); final String url = user.getBiggerProfileImageURL(); if (settings.roundContactImages) { mHandler.postDelayed(new Runnable() { @Override public void run() { if (holder.userId == id) { loadCircleImage(context, holder, url, mCache, id); } } }, 500); } else { mHandler.postDelayed(new Runnable() { @Override public void run() { if (holder.userId == id) { loadImage(context, holder, url, mCache, id); } } }, 500); } holder.background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new AlertDialog.Builder(context).setTitle(context.getResources().getString(R.string.remove_user)) .setMessage(context.getResources().getString(R.string.remove) + " " + user.getName() + " " + context.getResources().getString(R.string.from_list) + "?") .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { new RemoveUser().execute(user.getId() + ""); } catch (Exception e) { e.printStackTrace(); } } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).create().show(); } }); }
From source file:com.daiv.android.twitter.data.sq_lite.FavoriteUsersDataSource.java
License:Apache License
public synchronized void createUser(User user, int account) { ContentValues values = new ContentValues(); long id = user.getId(); String screenName = user.getScreenName(); String name = user.getName(); String proPicUrl = user.getOriginalProfileImageURL(); values.put(FavoriteUsersSQLiteHelper.COLUMN_ACCOUNT, account); values.put(FavoriteUsersSQLiteHelper.COLUMN_ID, id); values.put(FavoriteUsersSQLiteHelper.COLUMN_NAME, name); values.put(FavoriteUsersSQLiteHelper.COLUMN_PRO_PIC, proPicUrl); values.put(FavoriteUsersSQLiteHelper.COLUMN_SCREEN_NAME, screenName); try {/*from w w w . j a v a 2 s . co m*/ database.insert(FavoriteUsersSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { open(); database.insert(FavoriteUsersSQLiteHelper.TABLE_HOME, null, values); } }
From source file:com.daiv.android.twitter.data.sq_lite.FollowersDataSource.java
License:Apache License
public synchronized void createUser(User user, int account) { ContentValues values = new ContentValues(); long id = user.getId(); String screenName = user.getScreenName(); String name = user.getName(); String proPicUrl = user.getOriginalProfileImageURL(); values.put(FollowersSQLiteHelper.COLUMN_ACCOUNT, account); values.put(FollowersSQLiteHelper.COLUMN_ID, id); values.put(FollowersSQLiteHelper.COLUMN_NAME, name); values.put(FollowersSQLiteHelper.COLUMN_PRO_PIC, proPicUrl); values.put(FollowersSQLiteHelper.COLUMN_SCREEN_NAME, screenName); if (database == null || !database.isOpen()) { open();//from ww w . j a v a2 s . co m } try { database.insert(FollowersSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { // already exist. primary key must be unique } }
From source file:com.daiv.android.twitter.data.sq_lite.InteractionsDataSource.java
License:Apache License
public synchronized void createMention(Context context, Status status, int account) { ContentValues values = new ContentValues(); long id = status.getId(); long time = new GregorianCalendar().getTime().getTime(); // current time int type = TYPE_MENTION; User user = status.getUser(); String users = "@" + user.getScreenName() + " "; String text = status.getText(); String title = context.getResources().getString(R.string.mentioned_by) + " <b>@" + user.getScreenName() + "</b>"; values.put(InteractionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(InteractionsSQLiteHelper.COLUMN_TEXT, text); values.put(InteractionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, user.getOriginalProfileImageURL()); values.put(InteractionsSQLiteHelper.COLUMN_TIME, time); values.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1); values.put(InteractionsSQLiteHelper.COLUMN_USERS, users); values.put(InteractionsSQLiteHelper.COLUMN_TYPE, type); values.put(InteractionsSQLiteHelper.COLUMN_TITLE, title); try {//from w ww . j a v a2 s . c om database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } catch (Exception e) { open(); database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } }
From source file:com.daiv.android.twitter.data.sq_lite.InteractionsDataSource.java
License:Apache License
public synchronized void createFavoriteUserInter(Context context, Status status, int account) { ContentValues values = new ContentValues(); long id = status.getId(); long time = new GregorianCalendar().getTime().getTime(); // current time int type = TYPE_FAV_USER; User user = status.getUser(); String users = "@" + user.getScreenName() + " "; String text = status.getText(); String title = "<b>@" + user.getScreenName() + "</b> " + context.getResources().getString(R.string.tweeted); values.put(InteractionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(InteractionsSQLiteHelper.COLUMN_TEXT, text); values.put(InteractionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, user.getOriginalProfileImageURL()); values.put(InteractionsSQLiteHelper.COLUMN_TIME, time); values.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1); values.put(InteractionsSQLiteHelper.COLUMN_USERS, users); values.put(InteractionsSQLiteHelper.COLUMN_TYPE, type); values.put(InteractionsSQLiteHelper.COLUMN_TITLE, title); try {/*from w w w . ja v a2 s . c om*/ database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } catch (Exception e) { open(); database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } }
From source file:com.daiv.android.twitter.data.sq_lite.InteractionsDataSource.java
License:Apache License
public synchronized void createInteraction(Context context, User source, Status status, int account, int type) { ContentValues values = new ContentValues(); long id;/*from w w w .j a va2 s . co m*/ if (status != null) { id = status.getId(); } else { id = 0; // 0 will be used for whenever it is just a follow } long time = new GregorianCalendar().getTime().getTime(); // current time String users = "@" + source.getScreenName() + " "; String text = ""; String title = ""; switch (type) { case TYPE_FAVORITE: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.favorited); text = status.getText(); break; case TYPE_RETWEET: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.retweeted); text = status.getRetweetedStatus().getText(); break; case TYPE_FOLLOWER: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.followed); break; case TYPE_QUOTED_TWEET: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.quoted); text = status.getText(); break; } values.put(InteractionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(InteractionsSQLiteHelper.COLUMN_TEXT, text); values.put(InteractionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, source.getOriginalProfileImageURL()); values.put(InteractionsSQLiteHelper.COLUMN_TIME, time); values.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1); values.put(InteractionsSQLiteHelper.COLUMN_USERS, users); values.put(InteractionsSQLiteHelper.COLUMN_TYPE, type); values.put(InteractionsSQLiteHelper.COLUMN_TITLE, title); try { database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } catch (Exception e) { open(); database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } }
From source file:com.daiv.android.twitter.data.sq_lite.InteractionsDataSource.java
License:Apache License
public synchronized void updateInteraction(Context context, User source, Status status, int account, int type) { if (type == TYPE_RETWEET) { status = status.getRetweetedStatus(); }/* w w w .j a v a 2 s.c o m*/ Cursor cursor = interactionExists(status.getId(), account); if (cursor.getCount() > 0) { // it does exist // i want to do the updating stuff if (cursor.moveToFirst()) { String users = cursor.getString(cursor.getColumnIndex(InteractionsSQLiteHelper.COLUMN_USERS)); String title = ""; users += "@" + source.getScreenName() + " "; String[] x = users.split(" "); if (type == TYPE_RETWEET) { // retweet title = x.length + " " + context.getResources().getString(R.string.new_retweets); } else if (type == TYPE_FAVORITE) { // favorite title = x.length + " " + context.getResources().getString(R.string.new_favorites); } else { title = x.length + " " + context.getResources().getString(R.string.new_quotes); } ContentValues cv = new ContentValues(); cv.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1); cv.put(InteractionsSQLiteHelper.COLUMN_USERS, users); cv.put(InteractionsSQLiteHelper.COLUMN_TITLE, title); cv.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, source.getOriginalProfileImageURL()); cv.put(InteractionsSQLiteHelper.COLUMN_TIME, new GregorianCalendar().getTimeInMillis()); try { database.update(InteractionsSQLiteHelper.TABLE_INTERACTIONS, cv, InteractionsSQLiteHelper.COLUMN_TWEET_ID + " = ?", new String[] { status.getId() + "" }); } catch (Exception e) { open(); database.update(InteractionsSQLiteHelper.TABLE_INTERACTIONS, cv, InteractionsSQLiteHelper.COLUMN_TWEET_ID + " = ?", new String[] { status.getId() + "" }); } } } else { // this creates the entry createInteraction(context, source, status, account, type); } }
From source file:com.daiv.android.twitter.ui.profile_viewer.fragments.ProfileFragment.java
License:Apache License
public void getFollowingStatus(final TextView statement, final User user) { new Thread(new Runnable() { @Override// www. j a v a2s. c o m public void run() { try { if (user.getScreenName().equals(settings.myScreenName)) { return; } final String followingStatus = Utils.getTwitter(context, settings) .showFriendship(settings.myScreenName, thisUser.getScreenName()) .isTargetFollowingSource() ? getResources().getString(R.string.follows_you) : getResources().getString(R.string.not_following_you); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { statement.append("\n\n" + followingStatus); } }); } catch (Exception e) { } } }).start(); }