Hello i developed app for showing tweets in list.. I am getting all twitter ids from parse.com Code for that.
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
"Twitter");
ob = query.find();
String[] strings = new String[ob.size()];
// for (ParseObject imageupload : ob) {
for (int i = 0; i < strings.length; i++) {
ParseObject object = ob.get(i);
strings[i] = object.getString("TwitterId");
// images.add(map);
}
if (isNetworkAvailable()) {
new DownloadTwitterTask(getActivity(), list, images, bar)
.execute(strings);
}
And then i am passing array of twitter ids to async task
@Override
protected String[] doInBackground(final String... screenNames) {
// String result = null;
String rString[] = new String[screenNames.length];
for (int i = 0; i < rString.length; i++) {
rString[i] = getTwitterStream(screenNames[i]);
//
}
return rString;
}
// onPostExecute convert the JSON results into a Twitter object (which is an
// Array list of tweets
@Override
protected void onPostExecute(String[] result) {
Twitter twitter = new Twitter();
for (int i = 0; i < result.length; i++) {
twitter.addAll(jsonToTwitter(result[i]));
Collections.sort(twitter, new SimpleDate());
}
adapter = new StreamListAdapter(context, twitter);
list.setAdapter(adapter);
bar.setVisibility(View.GONE);
}
The problem is that the async task load tweets from all twitter ids and then it displayed in list..
I want to load some tweets and then display it while other tweets are loading in background
0 comments:
Post a Comment