use of twitter4j.Twitter in project Talon-for-Twitter by klinker24.
the class ProfilePager method getUser.
public void getUser() {
Thread getUser = new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
thisUser = twitter.showUser(screenName);
} catch (Exception e) {
thisUser = null;
}
if (thisUser != null) {
try {
FollowersDataSource.getInstance(context).createUser(thisUser, sharedPrefs.getInt("current_account", 1));
} catch (Exception e) {
// the user already exists. don't know if this is more efficient than querying the db or not.
}
final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
suggestions.saveRecentQuery("@" + thisUser.getScreenName(), null);
}
new GetActionBarInfo().execute();
}
});
getUser.setPriority(Thread.MAX_PRIORITY);
getUser.start();
}
use of twitter4j.Twitter in project Talon-for-Twitter by klinker24.
the class TwitterSearchFragment method findStatus.
public void findStatus(final long statusid) {
listView.setVisibility(View.GONE);
spinner.setVisibility(View.VISIBLE);
hasMore = false;
new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
Status status = twitter.showStatus(statusid);
final ArrayList<Status> statuses = new ArrayList<Status>();
statuses.add(status);
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
TimelineArrayAdapter adapter = new TimelineArrayAdapter(context, statuses, onlyStatus);
listView.setAdapter(adapter);
listView.setVisibility(View.VISIBLE);
spinner.setVisibility(View.GONE);
}
});
} catch (Exception e) {
e.printStackTrace();
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setVisibility(View.GONE);
}
});
hasMore = false;
}
}
}).start();
}
use of twitter4j.Twitter in project Talon-for-Twitter by klinker24.
the class TwitterSearchFragment method onRefreshStarted.
public void onRefreshStarted() {
new Thread(new Runnable() {
@Override
public void run() {
final long topId;
if (tweets.size() > 0) {
topId = tweets.get(0).getId();
} else {
topId = 0;
}
try {
Twitter twitter = Utils.getTwitter(context, settings);
query = new Query(searchQuery);
if (topTweets) {
query.setResultType(Query.POPULAR);
} else {
query.setResultType(null);
}
QueryResult result = twitter.search(query);
tweets.clear();
for (twitter4j.Status status : result.getTweets()) {
tweets.add(status);
}
if (result.hasNext()) {
query = result.nextQuery();
hasMore = true;
} else {
hasMore = false;
}
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
int top = 0;
for (int i = 0; i < tweets.size(); i++) {
if (tweets.get(i).getId() == topId) {
top = i;
break;
}
}
adapter = new TimelineArrayAdapter(context, tweets, onlyStatus);
listView.setAdapter(adapter);
listView.setVisibility(View.VISIBLE);
listView.setSelection(top);
spinner.setVisibility(View.GONE);
mPullToRefreshLayout.setRefreshing(false);
}
});
} catch (Exception e) {
e.printStackTrace();
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setVisibility(View.GONE);
mPullToRefreshLayout.setRefreshing(false);
}
});
}
}
}).start();
}
use of twitter4j.Twitter in project Talon-for-Twitter by klinker24.
the class UserSearchFragment method getMoreUsers.
public void getMoreUsers(final String mQuery) {
if (hasMore) {
canRefresh = false;
mPullToRefreshLayout.setRefreshing(true);
new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
ResponseList<User> result = twitter.searchUsers(mQuery, userPage);
userPage++;
for (User u : result) {
users.add(u);
}
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
if (peopleAdapter != null) {
peopleAdapter.notifyDataSetChanged();
}
mPullToRefreshLayout.setRefreshing(false);
}
});
} catch (Exception e) {
e.printStackTrace();
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
mPullToRefreshLayout.setRefreshing(false);
}
});
hasMore = false;
}
}
}).start();
}
}
use of twitter4j.Twitter in project Talon-for-Twitter by klinker24.
the class UserSearchFragment method doUserSearch.
public void doUserSearch(final String mQuery) {
listView.setVisibility(View.GONE);
spinner.setVisibility(View.VISIBLE);
hasMore = true;
canRefresh = false;
new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
ResponseList<User> result = twitter.searchUsers(mQuery, userPage);
userPage++;
if (result.size() < 18) {
hasMore = false;
canRefresh = false;
}
users = new ArrayList<User>();
for (User u : result) {
users.add(u);
}
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
peopleAdapter = new PeopleArrayAdapter(context, users, onlyProfile);
listView.setAdapter(peopleAdapter);
listView.setVisibility(View.VISIBLE);
spinner.setVisibility(View.GONE);
canRefresh = true;
}
});
} catch (Exception e) {
e.printStackTrace();
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setVisibility(View.GONE);
}
});
hasMore = false;
canRefresh = true;
}
}
}).start();
}
Aggregations