List of usage examples for twitter4j AsyncTwitterFactory AsyncTwitterFactory
public AsyncTwitterFactory(String configTreePath)
From source file:com.marpies.ane.twitter.data.TwitterAPI.java
License:Apache License
public static AsyncTwitter getAsyncInstance() { if (mAsyncTwitterFactory == null) { mAsyncTwitterFactory = new AsyncTwitterFactory(mConfiguration); }/*from w ww . j a va 2s. co m*/ return mAsyncTwitterFactory.getInstance(); }
From source file:com.marpies.ane.twitter.data.TwitterAPI.java
License:Apache License
public static AsyncTwitter getAsyncInstance(AccessToken token) { if (mAsyncTwitterFactory == null) { mAsyncTwitterFactory = new AsyncTwitterFactory(mConfiguration); }//from w w w .j av a 2 s . c o m return mAsyncTwitterFactory.getInstance(token); }
From source file:com.soomla.profile.social.twitter.SoomlaTwitter.java
License:Apache License
/** * {@inheritDoc}/*w ww. j ava 2s . c o m*/ */ @Override public void configure(Map<String, String> providerParams) { autoLogin = false; if (providerParams != null) { twitterConsumerKey = providerParams.get("consumerKey"); twitterConsumerSecret = providerParams.get("consumerSecret"); // extract autoLogin String autoLoginStr = providerParams.get("autoLogin"); autoLogin = autoLoginStr != null && Boolean.parseBoolean(autoLoginStr); } SoomlaUtils.LogDebug(TAG, String.format("ConsumerKey:%s ConsumerSecret:%s", twitterConsumerKey, twitterConsumerSecret)); if (TextUtils.isEmpty(twitterConsumerKey) || TextUtils.isEmpty(twitterConsumerSecret)) { SoomlaUtils.LogError(TAG, "You must provide the Consumer Key and Secret in the SoomlaProfile initialization parameters"); isInitialized = false; } else { isInitialized = true; } oauthCallbackURL = "oauth://soomla_twitter" + twitterConsumerKey; ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(twitterConsumerKey); configurationBuilder.setOAuthConsumerSecret(twitterConsumerSecret); Configuration configuration = configurationBuilder.build(); twitter = new AsyncTwitterFactory(configuration).getInstance(); if (!actionsListenerAdded) { SoomlaUtils.LogWarning(TAG, "added action listener"); twitter.addListener(actionsListener); actionsListenerAdded = true; } }
From source file:com.twitt4droid.Twitt4droid.java
License:Apache License
/** * Gets the current AsyncTwitter with consumer and access tokens pre-initialized. * /*from w ww .j a v a 2s . com*/ * @param context the application context. * @return an AsyncTwitter object. */ public static AsyncTwitter getAsyncTwitter(Context context) { return new AsyncTwitterFactory(getCurrentConfig(context)).getInstance(); }
From source file:log4twitter.TwitterWrapper.java
License:Apache License
private void initTwitter() { twitter = null;/*from ww w. java2 s .c o m*/ asyncTwitter = null; if (this.async) { asyncTwitter = new AsyncTwitterFactory("/log4twitter").getInstance(); } else { twitter = new TwitterFactory("/log4twitter").getInstance(); } }
From source file:net.nokok.twitduke.core.factory.TAsyncTwitterFactory.java
License:Open Source License
public static AsyncTwitter newInstance() { return new AsyncTwitterFactory(ConfigurationProvider.getConfiguration()).getInstance(); }
From source file:net.nokok.twitduke.core.factory.TAsyncTwitterFactory.java
License:Open Source License
public static AsyncTwitter newInstance(AccessToken accessToken) { return new AsyncTwitterFactory(ConfigurationProvider.getConfiguration()).getInstance(accessToken); }
From source file:org.webcat.notifications.protocols.TwitterProtocol.java
License:Open Source License
public TwitterProtocol() { twitterFactory = new AsyncTwitterFactory(new Adapter()); }
From source file:t.twitter.TTwitterModule.java
License:Open Source License
@Kroll.method public void connect(HashMap args) { KrollDict arg = new KrollDict(args); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(arg.optString("apikey", "")) .setOAuthConsumerSecret(arg.optString("apisecret", "")) .setOAuthAccessToken(arg.optString("accesstoken", "")) .setOAuthAccessTokenSecret(arg.optString("accesssecret", "")); AsyncTwitterFactory tf = new AsyncTwitterFactory(cb.build()); twitter = tf.getInstance();//from w w w .ja va2 s . c o m twitter.addListener(new TwitterAdapter() { @Override public void updatedStatus(Status status) { Log.d("Twitter", "text: " + status.getText()); } @Override public void searched(QueryResult result) { HashMap<String, KrollDict[]> event = new HashMap<String, KrollDict[]>(); List<Status> tweets = result.getTweets(); KrollDict[] dList = new KrollDict[tweets.size()]; // sort tweets Collections.sort(tweets, new Comparator<Status>() { public int compare(Status o1, Status o2) { if (desc) { if (o2.getId() < o1.getId()) { return 1; } else { return -1; } } else { if (o2.getId() > o1.getId()) { return 1; } else { return -1; } } } }); // return tweets to titanium int i = 0; for (Status tweet : tweets) { if (lastID == -1 || lastID < tweet.getId()) { KrollDict d = new KrollDict(); d.put("username", tweet.getUser().getScreenName()); d.put("userimage", tweet.getUser().getProfileImageURL()); d.put("text", tweet.getText()); d.put("date", tweet.getCreatedAt()); d.put("id", Long.toString(tweet.getId())); dList[i] = d; lastID = tweet.getId(); i++; } } KrollDict[] dList2 = new KrollDict[i]; // shorten array System.arraycopy(dList, 0, dList2, 0, i); event.put("tweets", dList2); success.call(getKrollObject(), event); synchronized (LOCK) { LOCK.notify(); } } @Override public void verifiedCredentials(User user) { HashMap<String, KrollDict> event = new HashMap<String, KrollDict>(); KrollDict d = new KrollDict(); d.put("user_name", user.getName()); d.put("screen_name", user.getScreenName()); d.put("image_path", user.getProfileImageURL()); event.put("user_info", d); success.call(getKrollObject(), event); synchronized (LOCK) { LOCK.notify(); } } @Override public void onException(TwitterException e, TwitterMethod method) { synchronized (LOCK) { LOCK.notify(); } Log.e("twitter", "error: " + e.getErrorMessage()); } }); Log.d("Twitter", "connected"); }
From source file:TweetCollector.ScheduledTrendFetcher.java
private void initialize() { twitter = new AsyncTwitterFactory(Utils.TwitterConfBuilder.buildConf()).getInstance(); twitter.addListener(new AsyncTrendListener()); initialized = true;/*w ww.j a v a2 s .c om*/ }