use of com.klinker.android.twitter.adapters.PicturesGridAdapter in project Talon-for-Twitter by klinker24.
the class ProfilePicturesFragment method doSearch.
public void doSearch() {
spinner.setVisibility(View.VISIBLE);
new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
ResponseList<Status> result;
try {
result = twitter.getUserTimeline(screenName, paging);
} catch (OutOfMemoryError e) {
return;
}
tweets.clear();
for (twitter4j.Status status : result) {
tweets.add(status);
}
if (result.size() > 17) {
hasMore = true;
} else {
hasMore = false;
}
for (Status s : tweets) {
String[] links = TweetLinkUtils.getLinksInStatus(s);
if (!links[1].equals("")) {
pics.add(links[1]);
tweetsWithPics.add(s);
}
}
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
Display display = ((Activity) context).getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int numColumns;
int currentOrientation = getResources().getConfiguration().orientation;
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
numColumns = 5;
} else {
numColumns = 3;
}
adapter = new PicturesGridAdapter(context, pics, tweetsWithPics, width / numColumns);
listView.setAdapter(adapter);
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);
canRefresh = false;
}
});
}
}
}).start();
}