List of usage examples for twitter4j Status getUser
User getUser();
From source file:com.klinker.android.twitter.adapters.TimelineArrayAdapter.java
License:Apache License
public void addExpansion(final ViewHolder holder, String screenname, String users, final String[] otherLinks, final String webpage, final long id) { holder.retweet.setVisibility(View.VISIBLE); holder.retweetCount.setVisibility(View.VISIBLE); holder.favCount.setVisibility(View.VISIBLE); holder.favorite.setVisibility(View.VISIBLE); //holder.reply.setVisibility(View.GONE); try {/*from w w w .ja v a 2 s . c om*/ holder.replyButton.setVisibility(View.GONE); } catch (Exception e) { } holder.screenName = screenname; // used to find the other names on a tweet... could be optimized i guess, but only run when button is pressed final String text = holder.tweet.getText().toString(); String extraNames = ""; if (text.contains("@")) { for (String s : users.split(" ")) { if (!s.equals(settings.myScreenName) && !extraNames.contains(s) && !s.equals(screenname)) { extraNames += "@" + s + " "; } } } try { if (holder.retweeter.getVisibility() == View.VISIBLE && !extraNames.contains(holder.retweeterName)) { extraNames += "@" + holder.retweeterName + " "; } } catch (NullPointerException e) { } if (!screenname.equals(settings.myScreenName)) { holder.reply.setText("@" + screenname + " " + extraNames); } else { holder.reply.setText(extraNames); } holder.reply.setSelection(holder.reply.getText().length()); if (holder.favCount.getText().toString().length() <= 2) { holder.favCount.setText(" -"); holder.retweetCount.setText(" -"); } //ExpansionAnimation expandAni = new ExpansionAnimation(holder.expandArea, 450); holder.expandArea.setVisibility(View.VISIBLE);//startAnimation(expandAni); getCounts(holder, id); holder.favorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new FavoriteStatus(holder, holder.tweetId).execute(); } }); holder.retweet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new RetweetStatus(holder, holder.tweetId).execute(); } }); holder.retweet.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { new AlertDialog.Builder(context).setTitle(context.getResources().getString(R.string.remove_retweet)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new RemoveRetweet(holder.tweetId).execute(); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).create().show(); return false; } class RemoveRetweet extends AsyncTask<String, Void, Boolean> { private long tweetId; public RemoveRetweet(long tweetId) { this.tweetId = tweetId; } protected void onPreExecute() { holder.retweet.clearColorFilter(); Toast.makeText(context, context.getResources().getString(R.string.removing_retweet), Toast.LENGTH_SHORT).show(); } protected Boolean doInBackground(String... urls) { try { Twitter twitter = Utils.getTwitter(context, settings); ResponseList<twitter4j.Status> retweets = twitter.getRetweets(tweetId); for (twitter4j.Status retweet : retweets) { if (retweet.getUser().getId() == settings.myId) twitter.destroyStatus(retweet.getId()); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } protected void onPostExecute(Boolean deleted) { try { if (deleted) { Toast.makeText(context, context.getResources().getString(R.string.success), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, context.getResources().getString(R.string.error), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { // user has gone away from the window } } } }); holder.reply.requestFocus(); removeKeyboard(holder); holder.reply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent compose = new Intent(context, ComposeActivity.class); String string = holder.reply.getText().toString(); try { compose.putExtra("user", string.substring(0, string.length() - 1)); } catch (Exception e) { } compose.putExtra("id", holder.tweetId); compose.putExtra("reply_to_text", "@" + holder.screenName + ": " + text); context.startActivity(compose); removeExpansionWithAnimation(holder); } }); if (holder.replyButton != null) { holder.replyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new ReplyToStatus(holder, holder.tweetId).execute(); } }); } final String name = screenname; try { holder.shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); String text = holder.tweet.getText().toString(); text = TweetLinkUtils.removeColorHtml(text, settings); text = restoreLinks(text); if (!settings.preferRT) { text = "\"@" + name + ": " + text + "\" "; } else { text = " RT @" + name + ": " + text; } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity( Intent.createChooser(intent, context.getResources().getString(R.string.menu_share))); } public String restoreLinks(String text) { String full = text; String[] split = text.split("\\s"); String[] otherLink = new String[otherLinks.length]; for (int i = 0; i < otherLinks.length; i++) { otherLink[i] = "" + otherLinks[i]; } boolean changed = false; if (otherLink.length > 0) { for (int i = 0; i < split.length; i++) { String s = split[i]; //if (Patterns.WEB_URL.matcher(s).find()) { // we know the link is cut off if (s.contains("...")) { // we know the link is cut off String f = s.replace("...", "").replace("http", ""); Log.v("talon_links", ":" + s + ":"); for (int x = 0; x < otherLink.length; x++) { if (otherLink[x].toLowerCase().contains(f.toLowerCase())) { changed = true; // for some reason it wouldn't match the last "/" on a url and it was stopping it from opening try { if (otherLink[x] .substring(otherLink[x].length() - 1, otherLink[x].length()) .equals("/")) { otherLink[x] = otherLink[x].substring(0, otherLink[x].length() - 1); } f = otherLink[x].replace("http://", "").replace("https://", "") .replace("www.", ""); otherLink[x] = ""; } catch (Exception e) { } break; } } if (changed) { split[i] = f; } else { split[i] = s; } } else { split[i] = s; } } } if (!webpage.equals("")) { for (int i = 0; i < split.length; i++) { String s = split[i]; if (s.contains("...")) { s = s.replace("...", ""); if (Patterns.WEB_URL.matcher(s).find() && (s.startsWith("t.co/") || s.contains("twitter.com/"))) { // we know the link is cut off String replace = otherLinks[otherLinks.length - 1]; if (replace.replace(" ", "").equals("")) { replace = webpage; } split[i] = replace; changed = true; } } } } if (changed) { full = ""; for (String p : split) { full += p + " "; } full = full.substring(0, full.length() - 1); } return full; } }); holder.quoteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(context, ComposeActivity.class); intent.setType("text/plain"); String text = holder.tweet.getText().toString(); text = TweetLinkUtils.removeColorHtml(text, settings); text = restoreLinks(text); if (!settings.preferRT) { text = "\"@" + name + ": " + text + "\" "; } else { text = " RT @" + name + ": " + text; } intent.putExtra("user", text); intent.putExtra("id", id); context.startActivity(intent); } public String restoreLinks(String text) { String full = text; String[] split = text.split("\\s"); String[] otherLink = new String[otherLinks.length]; for (int i = 0; i < otherLinks.length; i++) { otherLink[i] = "" + otherLinks[i]; } boolean changed = false; if (otherLink.length > 0) { for (int i = 0; i < split.length; i++) { String s = split[i]; //if (Patterns.WEB_URL.matcher(s).find()) { // we know the link is cut off if (s.contains("...")) { // we know the link is cut off String f = s.replace("...", "").replace("http", ""); Log.v("talon_links", ":" + s + ":"); for (int x = 0; x < otherLink.length; x++) { if (otherLink[x].toLowerCase().contains(f.toLowerCase())) { changed = true; // for some reason it wouldn't match the last "/" on a url and it was stopping it from opening try { if (otherLink[x] .substring(otherLink[x].length() - 1, otherLink[x].length()) .equals("/")) { otherLink[x] = otherLink[x].substring(0, otherLink[x].length() - 1); } f = otherLink[x].replace("http://", "").replace("https://", "") .replace("www.", ""); otherLink[x] = ""; } catch (Exception e) { } break; } } if (changed) { split[i] = f; } else { split[i] = s; } } else { split[i] = s; } } } if (!webpage.equals("")) { for (int i = 0; i < split.length; i++) { String s = split[i]; s = s.replace("...", ""); if (Patterns.WEB_URL.matcher(s).find() && (s.startsWith("t.co/") || s.contains("twitter.com/"))) { // we know the link is cut off String replace = otherLinks[otherLinks.length - 1]; if (replace.replace(" ", "").equals("")) { replace = webpage; } split[i] = replace; changed = true; } } } if (changed) { full = ""; for (String p : split) { full += p + " "; } full = full.substring(0, full.length() - 1); } return full; } }); } catch (Exception e) { // theme made before these were implemented } }
From source file:com.klinker.android.twitter.adapters.TimeLineCursorAdapter.java
License:Apache License
public void addExpansion(final ViewHolder holder, String screenname, String users, final String[] otherLinks, final String webpage, final long tweetId, String[] hashtags) { if (isDM) {// w w w. j a v a 2 s . com holder.retweet.setVisibility(View.GONE); holder.retweetCount.setVisibility(View.GONE); holder.favCount.setVisibility(View.GONE); holder.favorite.setVisibility(View.GONE); } else { holder.retweet.setVisibility(View.VISIBLE); holder.retweetCount.setVisibility(View.VISIBLE); holder.favCount.setVisibility(View.VISIBLE); holder.favorite.setVisibility(View.VISIBLE); } try { holder.replyButton.setVisibility(View.GONE); } catch (Exception e) { } try { holder.charRemaining.setVisibility(View.GONE); } catch (Exception e) { } holder.screenName = screenname; // used to find the other names on a tweet... could be optimized i guess, but only run when button is pressed if (!isDM) { String text = holder.tweet.getText().toString(); String extraNames = ""; if (text.contains("@")) { for (String s : users.split(" ")) { if (!s.equals(settings.myScreenName) && !extraNames.contains(s) && !s.equals(screenname)) { extraNames += "@" + s + " "; } } } try { if (holder.retweeter.getVisibility() == View.VISIBLE && !extraNames.contains(holder.retweeterName)) { extraNames += "@" + holder.retweeterName + " "; } } catch (NullPointerException e) { } if (!screenname.equals(settings.myScreenName)) { holder.reply.setText("@" + screenname + " " + extraNames); } else { holder.reply.setText(extraNames); } if (settings.autoInsertHashtags && hashtags != null) { for (String s : hashtags) { if (!s.equals("")) { holder.reply.append("#" + s + " "); } } } } holder.reply.setSelection(holder.reply.getText().length()); if (holder.favCount.getText().toString().length() <= 2) { holder.favCount.setText(" -"); holder.retweetCount.setText(" -"); } //ExpansionAnimation expandAni = new ExpansionAnimation(holder.expandArea, 450); holder.expandArea.setVisibility(View.VISIBLE);//startAnimation(expandAni); if (holder.favCount.getText().toString().equals(" -")) { getCounts(holder, tweetId); } holder.favorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new FavoriteStatus(holder, holder.tweetId).execute(); } }); holder.retweet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new RetweetStatus(holder, holder.tweetId).execute(); } }); holder.retweet.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { new AlertDialog.Builder(context).setTitle(context.getResources().getString(R.string.remove_retweet)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new RemoveRetweet(holder.tweetId).execute(); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).create().show(); return false; } class RemoveRetweet extends AsyncTask<String, Void, Boolean> { private long tweetId; public RemoveRetweet(long tweetId) { this.tweetId = tweetId; } protected void onPreExecute() { holder.retweet.clearColorFilter(); Toast.makeText(context, context.getResources().getString(R.string.removing_retweet), Toast.LENGTH_SHORT).show(); } protected Boolean doInBackground(String... urls) { try { Twitter twitter = Utils.getTwitter(context, settings); ResponseList<twitter4j.Status> retweets = twitter.getRetweets(tweetId); for (twitter4j.Status retweet : retweets) { if (retweet.getUser().getId() == settings.myId) twitter.destroyStatus(retweet.getId()); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } protected void onPostExecute(Boolean deleted) { try { if (deleted) { Toast.makeText(context, context.getResources().getString(R.string.success), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, context.getResources().getString(R.string.error), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { // user has gone away from the window } } } }); holder.reply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent compose = new Intent(context, ComposeActivity.class); String string = holder.reply.getText().toString(); try { compose.putExtra("user", string.substring(0, string.length() - 1)); } catch (Exception e) { e.printStackTrace(); } compose.putExtra("id", holder.tweetId); compose.putExtra("reply_to_text", "@" + holder.screenName + ": " + holder.tweet.getText().toString()); if (isHomeTimeline) { sharedPrefs.edit().putLong("current_position_" + settings.currentAccount, holder.tweetId) .commit(); } context.startActivity(compose); removeExpansionWithAnimation(holder); } }); holder.reply.requestFocus(); removeKeyboard(holder); // this isn't going to run anymore, but just in case i put it back i guess if (holder.replyButton != null) { holder.replyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new ReplyToStatus(holder, holder.tweetId).execute(); } }); holder.charRemaining.setText(140 - holder.reply.getText().length() + ""); holder.reply.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { hasKeyboard = b; } }); holder.reply.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { holder.charRemaining.setText(140 - holder.reply.getText().length() + ""); } @Override public void afterTextChanged(Editable editable) { } }); } final String name = screenname; try { holder.shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); String text = holder.tweet.getText().toString(); text = restoreLinks(text); text = "@" + name + ": " + text; Log.v("talon_sharing", "text: " + text); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_TEXT, text); if (isHomeTimeline) { sharedPrefs.edit().putLong("current_position_" + settings.currentAccount, holder.tweetId) .commit(); } context.startActivity( Intent.createChooser(intent, context.getResources().getString(R.string.menu_share))); } public String restoreLinks(String text) { String full = text; String[] split = text.split("\\s"); String[] otherLink = new String[otherLinks.length]; for (int i = 0; i < otherLinks.length; i++) { otherLink[i] = "" + otherLinks[i]; } boolean changed = false; if (otherLink.length > 0) { for (int i = 0; i < split.length; i++) { String s = split[i]; if (Patterns.WEB_URL.matcher(s).find()) { // we know the link is cut off String f = s.replace("...", "").replace("http", ""); for (int x = 0; x < otherLink.length; x++) { if (otherLink[x].contains(f)) { changed = true; // for some reason it wouldn't match the last "/" on a url and it was stopping it from opening if (otherLink[x].substring(otherLink[x].length() - 1, otherLink[x].length()) .equals("/")) { otherLink[x] = otherLink[x].substring(0, otherLink[x].length() - 1); } f = otherLink[x]; otherLink[x] = ""; break; } } if (changed) { split[i] = f; } else { split[i] = s; } } else { split[i] = s; } } } if (!webpage.equals("")) { for (int i = 0; i < split.length; i++) { String s = split[i]; if (s.contains("...")) { s = s.replace("...", ""); if (Patterns.WEB_URL.matcher(s).find() && (s.startsWith("t.co/") || s.contains("twitter.com/"))) { // we know the link is cut off String replace = otherLinks[otherLinks.length - 1]; if (replace.replace(" ", "").equals("")) { replace = webpage; } split[i] = replace; changed = true; } } } } if (changed) { full = ""; for (String p : split) { full += p + " "; } full = full.substring(0, full.length() - 1); } return full; } }); holder.quoteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(context, ComposeActivity.class); intent.setType("text/plain"); String text = holder.tweet.getText().toString(); text = TweetLinkUtils.removeColorHtml(text, settings); text = restoreLinks(text); if (!settings.preferRT) { text = "\"@" + name + ": " + text + "\" "; } else { text = " RT @" + name + ": " + text; } intent.putExtra("user", text); intent.putExtra("id", tweetId); if (isHomeTimeline) { sharedPrefs.edit().putLong("current_position_" + settings.currentAccount, holder.tweetId) .commit(); } context.startActivity(intent); } public String restoreLinks(String text) { String full = text; String[] split = text.split("\\s"); String[] otherLink = new String[otherLinks.length]; for (int i = 0; i < otherLinks.length; i++) { otherLink[i] = "" + otherLinks[i]; } boolean changed = false; if (otherLink.length > 0) { for (int i = 0; i < split.length; i++) { String s = split[i]; if (Patterns.WEB_URL.matcher(s).find()) { // we know the link is cut off String f = s.replace("...", "").replace("http", ""); for (int x = 0; x < otherLink.length; x++) { if (otherLink[x].contains(f)) { changed = true; // for some reason it wouldn't match the last "/" on a url and it was stopping it from opening if (otherLink[x].substring(otherLink[x].length() - 1, otherLink[x].length()) .equals("/")) { otherLink[x] = otherLink[x].substring(0, otherLink[x].length() - 1); } f = otherLink[x]; otherLink[x] = ""; break; } } if (changed) { split[i] = f; } else { split[i] = s; } } else { split[i] = s; } } } if (!webpage.equals("")) { for (int i = 0; i < split.length; i++) { String s = split[i]; s = s.replace("...", ""); if (Patterns.WEB_URL.matcher(s).find() && (s.startsWith("t.co/") || s.contains("twitter.com/"))) { // we know the link is cut off String replace = otherLinks[otherLinks.length - 1]; if (replace.replace(" ", "").equals("")) { replace = webpage; } split[i] = replace; changed = true; } } } if (changed) { full = ""; for (String p : split) { full += p + " "; } full = full.substring(0, full.length() - 1); } return full; } }); } catch (Exception e) { // theme made before these were implemented } if (settings.addonTheme) { try { Resources resourceAddon = context.getPackageManager() .getResourcesForApplication(settings.addonThemePackage); int back = resourceAddon.getIdentifier("reply_entry_background", "drawable", settings.addonThemePackage); holder.reply.setBackgroundDrawable(resourceAddon.getDrawable(back)); } catch (Exception e) { // theme does not include a reply entry box } } }
From source file:com.klinker.android.twitter.data.sq_lite.HomeDataSource.java
License:Apache License
public synchronized void createTweet(Status status, int account) { ContentValues values = new ContentValues(); String originalName = ""; long time = status.getCreatedAt().getTime(); long id = status.getId(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }/* ww w. j av a 2s .c om*/ String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, account); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, id); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); try { database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { open(); database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } }
From source file:com.klinker.android.twitter.data.sq_lite.HomeDataSource.java
License:Apache License
public synchronized void createTweet(Status status, int account, boolean initial) { ContentValues values = new ContentValues(); String originalName = ""; long time = status.getCreatedAt().getTime(); long id = status.getId(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }//w w w . java 2 s . c o m String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, account); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, id); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 0); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); try { database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { open(); database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } }
From source file:com.klinker.android.twitter.data.sq_lite.HomeDataSource.java
License:Apache License
public synchronized int insertTweets(List<Status> statuses, int currentAccount, long[] lastIds) { ContentValues[] valueses = new ContentValues[statuses.size()]; for (int i = 0; i < statuses.size(); i++) { Status status = statuses.get(i); Long id = status.getId(); ContentValues values = new ContentValues(); if (id > lastIds[0]) { String originalName = ""; long mId = status.getId(); long time = status.getCreatedAt().getTime(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }/* w w w. ja v a2s . c om*/ String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, currentAccount); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, mId); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); } else { values = null; } valueses[i] = values; } ArrayList<ContentValues> vals = new ArrayList<ContentValues>(); for (ContentValues v : valueses) { if (v != null) { vals.add(v); } } insertMultiple(valueses); return vals.size(); }
From source file:com.klinker.android.twitter.data.sq_lite.ListDataSource.java
License:Apache License
public synchronized void createTweet(Status status, long listId) { ContentValues values = new ContentValues(); String originalName = ""; long time = status.getCreatedAt().getTime(); long id = status.getId(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }//w w w . ja v a2 s . c o m String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; values.put(ListSQLiteHelper.COLUMN_TEXT, text); values.put(ListSQLiteHelper.COLUMN_TWEET_ID, id); values.put(ListSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(ListSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(ListSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(ListSQLiteHelper.COLUMN_TIME, time); values.put(ListSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(ListSQLiteHelper.COLUMN_PIC_URL, media); values.put(ListSQLiteHelper.COLUMN_URL, url); values.put(ListSQLiteHelper.COLUMN_USERS, users); values.put(ListSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(ListSQLiteHelper.COLUMN_LIST_ID, listId); try { database.insert(ListSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { open(); database.insert(ListSQLiteHelper.TABLE_HOME, null, values); } }
From source file:com.klinker.android.twitter.data.sq_lite.ListDataSource.java
License:Apache License
public int insertTweets(List<Status> statuses, long listId) { ContentValues[] valueses = new ContentValues[statuses.size()]; for (int i = 0; i < statuses.size(); i++) { Status status = statuses.get(i); ContentValues values = new ContentValues(); String originalName = ""; long time = status.getCreatedAt().getTime(); long id = status.getId(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }//from www. jav a 2 s . c o m String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; values.put(ListSQLiteHelper.COLUMN_TEXT, text); values.put(ListSQLiteHelper.COLUMN_TWEET_ID, id); values.put(ListSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(ListSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(ListSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(ListSQLiteHelper.COLUMN_TIME, time); values.put(ListSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(ListSQLiteHelper.COLUMN_PIC_URL, media); values.put(ListSQLiteHelper.COLUMN_URL, url); values.put(ListSQLiteHelper.COLUMN_USERS, users); values.put(ListSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(ListSQLiteHelper.COLUMN_LIST_ID, listId); valueses[i] = values; } return insertMultiple(valueses); }
From source file:com.klinker.android.twitter.data.sq_lite.MentionsDataSource.java
License:Apache License
public synchronized void createTweet(Status status, int account, boolean initial) { ContentValues values = new ContentValues(); String originalName = ""; long id = status.getId(); long time = status.getCreatedAt().getTime(); String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0];/*w w w . j ava2s . c o m*/ String media = html[1]; String otherUrl = html[2]; String hashtags = html[3]; String users = html[4]; values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(MentionsSQLiteHelper.COLUMN_TEXT, text); values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(MentionsSQLiteHelper.COLUMN_TIME, time); values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 0); values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media); values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl); values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media); values.put(MentionsSQLiteHelper.COLUMN_USERS, users); values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags); try { database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values); } catch (Exception e) { open(); database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values); } }
From source file:com.klinker.android.twitter.data.sq_lite.MentionsDataSource.java
License:Apache License
public synchronized void createTweet(Status status, int account) { ContentValues values = new ContentValues(); String originalName = ""; long id = status.getId(); long time = status.getCreatedAt().getTime(); String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0];// ww w.j a v a 2 s. com String media = html[1]; String otherUrl = html[2]; String hashtags = html[3]; String users = html[4]; values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(MentionsSQLiteHelper.COLUMN_TEXT, text); values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(MentionsSQLiteHelper.COLUMN_TIME, time); values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 1); values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media); values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl); values.put(MentionsSQLiteHelper.COLUMN_USERS, users); values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags); try { database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values); } catch (Exception e) { open(); database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values); } }
From source file:com.klinker.android.twitter.data.sq_lite.MentionsDataSource.java
License:Apache License
public synchronized int insertTweets(List<Status> statuses, int account) { ContentValues[] valueses = new ContentValues[statuses.size()]; for (int i = 0; i < statuses.size(); i++) { Status status = statuses.get(i); ContentValues values = new ContentValues(); String originalName = ""; long id = status.getId(); long time = status.getCreatedAt().getTime(); String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0];// w w w .j ava 2s . com String media = html[1]; String otherUrl = html[2]; String hashtags = html[3]; String users = html[4]; values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(MentionsSQLiteHelper.COLUMN_TEXT, text); values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(MentionsSQLiteHelper.COLUMN_TIME, time); values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 1); values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media); values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl); values.put(MentionsSQLiteHelper.COLUMN_USERS, users); values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags); valueses[i] = values; } return insertMultiple(valueses); }