List of usage examples for twitter4j Trend getName
String getName();
From source file:Trending.java
private void printAvailableTrends() { for (int i = 0; i < size; i++) { System.out.println("\nFor " + countries[i] + "\n"); for (Trend trend : trends[i].getTrends()) { System.out.println(trend.getName()); }/*www . j a v a2 s. co m*/ } }
From source file:com.daiv.android.twitter.ui.drawer_activities.discover.trends.LocalTrends.java
License:Apache License
public void getTrends() { new Thread(new Runnable() { @Override/*from ww w. j a v a2 s .co m*/ public void run() { try { Twitter twitter = Utils.getTwitter(context, DrawerActivity.settings); int i = 0; while (!connected && i < 5) { try { Thread.sleep(1500); } catch (Exception e) { } i++; } twitter4j.Trends trends; if (sharedPrefs.getBoolean("manually_config_location", false)) { trends = twitter.getPlaceTrends(sharedPrefs.getInt("woeid", 2379574)); // chicago to default } else { Location location = mLastLocation; ResponseList<twitter4j.Location> locations = twitter .getClosestTrends(new GeoLocation(location.getLatitude(), location.getLongitude())); trends = twitter.getPlaceTrends(locations.get(0).getWoeid()); } final ArrayList<String> currentTrends = new ArrayList<String>(); for (Trend t : trends.getTrends()) { String name = t.getName(); currentTrends.add(name); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { try { if (currentTrends != null) { listView.setAdapter(new TrendsArrayAdapter(context, currentTrends)); listView.setVisibility(View.VISIBLE); } else { Toast.makeText(context, getResources().getString(R.string.no_location), Toast.LENGTH_SHORT).show(); } LinearLayout spinner = (LinearLayout) layout.findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); } catch (Exception e) { // not attached to activity } } }); HashtagDataSource source = HashtagDataSource.getInstance(context); for (String s : currentTrends) { Log.v("Test_hashtag", "trend: " + s); if (s.contains("#")) { // we want to add it to the auto complete Log.v("Test_hashtag", "adding: " + s); // could be much more efficient by querying and checking first, but I // just didn't feel like it when there is only ever 10 of them here source.deleteTag(s); // add it to the userAutoComplete database source.createTag(s); } } } catch (Throwable e) { e.printStackTrace(); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { try { Toast.makeText(context, getResources().getString(R.string.no_location), Toast.LENGTH_SHORT).show(); } catch (Exception e) { // not attached to activity } } }); } } }).start(); }
From source file:com.daiv.android.twitter.ui.drawer_activities.discover.trends.WorldTrends.java
License:Apache License
public void getTrends() { new Thread(new Runnable() { @Override/*w w w . jav a 2 s .c o m*/ public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); twitter4j.Trends trends = twitter.getPlaceTrends(1); final ArrayList<String> currentTrends = new ArrayList<String>(); for (Trend t : trends.getTrends()) { String name = t.getName(); currentTrends.add(name); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { if (currentTrends != null) { listView.setAdapter(new TrendsArrayAdapter(context, currentTrends)); } listView.setVisibility(View.VISIBLE); LinearLayout spinner = (LinearLayout) layout.findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); } }); HashtagDataSource source = HashtagDataSource.getInstance(context); for (String s : currentTrends) { if (s.contains("#")) { // we want to add it to the userAutoComplete Log.v("Test_hashtag", "adding: " + s); // could be much more efficient by querying and checking first, but I // just didn't feel like it when there is only ever 10 of them here source.deleteTag(s); // add it to the userAutoComplete database source.createTag(s); } } } catch (Throwable e) { e.printStackTrace(); } } }).start(); }
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues[] makeTrendsContentValues(final List<Trends> trends_list) { if (trends_list == null) return new ContentValues[0]; final List<ContentValues> result_list = new ArrayList<ContentValues>(); for (final Trends trends : trends_list) { if (trends == null) { continue; }/*w w w . ja v a 2 s.co m*/ final long timestamp = trends.getTrendAt().getTime(); for (final Trend trend : trends.getTrends()) { final ContentValues values = new ContentValues(); values.put(CachedTrends.NAME, trend.getName()); values.put(CachedTrends.TIMESTAMP, timestamp); result_list.add(values); } } return result_list.toArray(new ContentValues[result_list.size()]); }
From source file:com.fsatir.twitter.TwitterManagedBean.java
public void pullTrendTopicImages() { try {/*from www . j a va2 s . c o m*/ Twitter twitter = bringMyTwitterInstance(); Trends trends = twitter.getPlaceTrends(TURKEY_WOEID); int counter = 0; for (Trend trend : trends.getTrends()) { trendImageList(twitter, trend.getName()); counter++; } showMessage(counter + " adet sonu getirildi.!"); FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("myMediaListFiltered", myMediaListFiltered); } catch (TwitterException ex) { ex.printStackTrace(); } }
From source file:com.javielinux.adapters.TrendingTopicsAdapter.java
License:Apache License
@Override public View getView(int position, View convertView, ViewGroup parent) { Trend item = elements.get(position); View view = null;// ww w . j a va 2 s .c om if (null == convertView) { view = View.inflate(mContext, R.layout.row_trending_topics, null); } else { view = convertView; } view.setBackgroundDrawable(ImageUtils.createStateListDrawable(mContext, new ThemeManager(mContext).getColor("list_background_row_color"))); TextView location_name = (TextView) view.findViewById(R.id.trend_name); location_name.setText(item.getName()); return view; }
From source file:com.klinker.android.twitter.activities.drawer_activities.discover.trends.LocalTrends.java
License:Apache License
public void getTrends() { new Thread(new Runnable() { @Override// w w w. ja v a 2s .c o m public void run() { try { Twitter twitter = Utils.getTwitter(context, DrawerActivity.settings); int i = 0; while (!connected && i < 5) { try { Thread.sleep(1500); } catch (Exception e) { } i++; } twitter4j.Trends trends; if (sharedPrefs.getBoolean("manually_config_location", false)) { trends = twitter.getPlaceTrends(sharedPrefs.getInt("woeid", 2379574)); // chicago to default } else { Location location = mLastLocation; ResponseList<twitter4j.Location> locations = twitter .getClosestTrends(new GeoLocation(location.getLatitude(), location.getLongitude())); trends = twitter.getPlaceTrends(locations.get(0).getWoeid()); } final ArrayList<String> currentTrends = new ArrayList<String>(); for (Trend t : trends.getTrends()) { String name = t.getName(); currentTrends.add(name); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { try { if (currentTrends != null) { listView.setAdapter(new TrendsArrayAdapter(context, currentTrends)); listView.setVisibility(View.VISIBLE); } else { Toast.makeText(context, getResources().getString(R.string.no_location), Toast.LENGTH_SHORT).show(); } LinearLayout spinner = (LinearLayout) layout.findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); } catch (Exception e) { // not attached to activity } } }); HashtagDataSource source = HashtagDataSource.getInstance(context); for (String s : currentTrends) { Log.v("talon_hashtag", "trend: " + s); if (s.contains("#")) { // we want to add it to the auto complete Log.v("talon_hashtag", "adding: " + s); // could be much more efficient by querying and checking first, but I // just didn't feel like it when there is only ever 10 of them here source.deleteTag(s); // add it to the userAutoComplete database source.createTag(s); } } } catch (Throwable e) { e.printStackTrace(); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { try { Toast.makeText(context, getResources().getString(R.string.no_location), Toast.LENGTH_SHORT).show(); } catch (Exception e) { // not attached to activity } } }); } } }).start(); }
From source file:com.klinker.android.twitter.activities.drawer_activities.discover.trends.WorldTrends.java
License:Apache License
public void getTrends() { new Thread(new Runnable() { @Override//from w w w .j a va 2s . c o m public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); twitter4j.Trends trends = twitter.getPlaceTrends(1); final ArrayList<String> currentTrends = new ArrayList<String>(); for (Trend t : trends.getTrends()) { String name = t.getName(); currentTrends.add(name); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { if (currentTrends != null) { listView.setAdapter(new TrendsArrayAdapter(context, currentTrends)); } listView.setVisibility(View.VISIBLE); LinearLayout spinner = (LinearLayout) layout.findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); } }); HashtagDataSource source = HashtagDataSource.getInstance(context); for (String s : currentTrends) { if (s.contains("#")) { // we want to add it to the userAutoComplete Log.v("talon_hashtag", "adding: " + s); // could be much more efficient by querying and checking first, but I // just didn't feel like it when there is only ever 10 of them here source.deleteTag(s); // add it to the userAutoComplete database source.createTag(s); } } } catch (Throwable e) { e.printStackTrace(); } } }).start(); }
From source file:com.klinker.android.twitter.ui.drawer_activities.discover.trends.LocalTrends.java
License:Apache License
public void getTrends() { new Thread(new Runnable() { @Override//from ww w. j a v a2 s .c o m public void run() { try { Twitter twitter = Utils.getTwitter(context, DrawerActivity.settings); int i = 0; while (!connected && i < 5) { try { Thread.sleep(1500); } catch (Exception e) { } i++; } twitter4j.Trends trends; if (sharedPrefs.getBoolean("manually_config_location", false)) { trends = twitter.getPlaceTrends(sharedPrefs.getInt("woeid", 2379574)); // chicago to default } else { Location location = mLocationClient.getLastLocation(); ResponseList<twitter4j.Location> locations = twitter .getClosestTrends(new GeoLocation(location.getLatitude(), location.getLongitude())); trends = twitter.getPlaceTrends(locations.get(0).getWoeid()); } final ArrayList<String> currentTrends = new ArrayList<String>(); for (Trend t : trends.getTrends()) { String name = t.getName(); currentTrends.add(name); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { try { if (currentTrends != null) { listView.setAdapter(new TrendsArrayAdapter(context, currentTrends)); listView.setVisibility(View.VISIBLE); } else { Toast.makeText(context, getResources().getString(R.string.no_location), Toast.LENGTH_SHORT).show(); } LinearLayout spinner = (LinearLayout) layout.findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); } catch (Exception e) { // not attached to activity } } }); HashtagDataSource source = HashtagDataSource.getInstance(context); for (String s : currentTrends) { Log.v("talon_hashtag", "trend: " + s); if (s.contains("#")) { // we want to add it to the auto complete Log.v("talon_hashtag", "adding: " + s); // could be much more efficient by querying and checking first, but I // just didn't feel like it when there is only ever 10 of them here source.deleteTag(s); // add it to the userAutoComplete database source.createTag(s); } } } catch (Throwable e) { e.printStackTrace(); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { try { Toast.makeText(context, getResources().getString(R.string.no_location), Toast.LENGTH_SHORT).show(); } catch (Exception e) { // not attached to activity } } }); } } }).start(); }
From source file:com.mmiagency.knime.nodes.twitter.util.TrendRow.java
License:Open Source License
private static DataCell[] createCells(final Location location, final Trend trend) { List<DataCell> cells = new ArrayList<DataCell>(); if (location.getCountryName() == null) { cells.add(new StringCell(location.getName())); } else {/* ww w.j a v a2s .com*/ cells.add(new StringCell(location.getCountryName() + " - " + location.getName())); } cells.add(new StringCell(trend.getName())); cells.add(new StringCell(trend.getQuery())); cells.add(new StringCell(trend.getURL())); return cells.toArray(new DataCell[cells.size()]); }