use of com.klinker.android.twitter.adapters.TimelineArrayAdapter in project Talon-for-Twitter by klinker24.
the class SearchedTrendsActivity method doSearch.
public void doSearch(final String mQuery) {
spinner.setVisibility(View.VISIBLE);
new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
Log.v("talon_search", "search query: " + mQuery);
query = new Query();
if (mQuery.contains(" TOP")) {
query.setResultType(Query.ResultType.popular);
}
query.setQuery(mQuery.replace(" TOP", ""));
QueryResult result;
try {
result = twitter.search(query);
} catch (OutOfMemoryError e) {
return;
}
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() {
adapter = new TimelineArrayAdapter(context, tweets);
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);
}
});
}
}
}).start();
}
use of com.klinker.android.twitter.adapters.TimelineArrayAdapter in project Talon-for-Twitter by klinker24.
the class ProfileFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mCache = App.getInstance(context).getBitmapCache();
settings = AppSettings.getInstance(context);
screenName = getArguments().getString("screen_name");
isMyProfile = settings.myScreenName.equals(screenName);
sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
inflater = LayoutInflater.from(context);
layout = inflater.inflate(R.layout.list_fragment, null);
LinearLayout spin = (LinearLayout) layout.findViewById(R.id.spinner);
spin.setVisibility(View.GONE);
AsyncListView listView = (AsyncListView) layout.findViewById(R.id.listView);
listView.setVisibility(View.VISIBLE);
BitmapLruCache cache = App.getInstance(context).getBitmapCache();
ArrayListLoader loader = new ArrayListLoader(cache, context);
builder = new ItemManager.Builder(loader);
builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
builder.setThreadPoolSize(4);
listView.setItemManager(builder.build());
View header;
boolean fromAddon = false;
if (!settings.addonTheme) {
header = inflater.inflate(R.layout.user_profile_header, null);
} else {
try {
Context viewContext = null;
Resources res = context.getPackageManager().getResourcesForApplication(settings.addonThemePackage);
try {
viewContext = context.createPackageContext(settings.addonThemePackage, Context.CONTEXT_IGNORE_SECURITY);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
if (res != null && viewContext != null) {
int id = res.getIdentifier("user_profile_header", "layout", settings.addonThemePackage);
header = LayoutInflater.from(viewContext).inflate(res.getLayout(id), null);
fromAddon = true;
} else {
header = inflater.inflate(R.layout.user_profile_header, null);
}
} catch (Exception e) {
e.printStackTrace();
header = inflater.inflate(R.layout.user_profile_header, null);
}
}
listView.addHeaderView(header);
listView.setAdapter(new TimelineArrayAdapter(context, new ArrayList<Status>(0)));
followers = new ArrayList<User>();
following = new ArrayList<User>();
setUpUI(fromAddon, header, layout);
return layout;
}
use of com.klinker.android.twitter.adapters.TimelineArrayAdapter 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 com.klinker.android.twitter.adapters.TimelineArrayAdapter 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 com.klinker.android.twitter.adapters.TimelineArrayAdapter in project Talon-for-Twitter by klinker24.
the class ConversationFragment method getReplies.
public void getReplies(final ListView listView, final long tweetId, final LinearLayout progressSpinner, final HoloTextView none) {
Thread getReplies = new Thread(new Runnable() {
@Override
public void run() {
if (!isRunning) {
return;
}
Twitter twitter = Utils.getTwitter(context, settings);
replies = new ArrayList<twitter4j.Status>();
try {
status = twitter.showStatus(tweetId);
if (status.isRetweet()) {
status = status.getRetweetedStatus();
}
twitter4j.Status replyStatus = twitter.showStatus(status.getInReplyToStatusId());
try {
while (!replyStatus.getText().equals("")) {
if (!isRunning) {
return;
}
replies.add(replyStatus);
Log.v("reply_status", replyStatus.getText());
replyStatus = twitter.showStatus(replyStatus.getInReplyToStatusId());
}
} catch (Exception e) {
// the list of replies has ended, but we dont want to go to null
}
} catch (TwitterException e) {
e.printStackTrace();
}
if (status != null && replies.size() > 0) {
replies.add(0, status);
}
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (replies.size() > 0) {
ArrayList<twitter4j.Status> reversed = new ArrayList<twitter4j.Status>();
for (int i = replies.size() - 1; i >= 0; i--) {
reversed.add(replies.get(i));
}
replies = reversed;
adapter = new TimelineArrayAdapter(context, replies);
listView.setAdapter(adapter);
listView.setVisibility(View.VISIBLE);
progressSpinner.setVisibility(View.GONE);
} else {
}
} catch (Exception e) {
// none and it got the null object
}
if (status != null) {
// everything here worked, so get the discussion on the tweet
getDiscussion(listView, tweetId, progressSpinner, none, status);
}
}
});
}
});
getReplies.setPriority(7);
getReplies.start();
}
Aggregations