progressbar for loading rss feed?

Put your problem here if it does not fit any of the other categories.

progressbar for loading rss feed?

Postby Kalder » Tue Jan 24, 2012 1:19 am

I'm currently working on an rss parser (edited example from Robhinds rssreader) it works so far, however, it takes almost a minute to start the app and it just displays a blank screen for like half a minute.
Now I was wondering how I can set up a progressbar that functions as a loading splash screen.

this is the starting activity, app starts here:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package;
  3. import;
  4. import java.util.ArrayList;
  5. import java.util.List;
  7. import org.json.JSONObject;
  9. import;
  10. import android.content.Intent;
  11. import;
  12. import android.os.Bundle;
  13. import android.util.Log;
  14. import android.view.View;
  15. import android.widget.ListView;
  17. import;
  18. import;
  21. public class RssActivity extends ListActivity {
  22.         /** Called when the activity is first created. */
  23.         @Override
  24.         public void onCreate(Bundle savedInstanceState) {
  25.                 super.onCreate(savedInstanceState);
  26.                 List<JSONObject> jobs = new ArrayList<JSONObject>();
  27.                 try {
  28.                         jobs = RssReader.getLatestRssFeed();
  29.                 } catch (Exception e) {
  30.                         Log.e("RSS ERROR",
  31.                                         "Error loading RSS Feed Stream >> " + e.getMessage()
  32.                                                         + " //" + e.toString());
  33.                 }
  35.                 RssListAdapter adapter = new RssListAdapter(this, jobs);
  36.                 setListAdapter(adapter);
  38.         }
  41.         @Override
  42.         public void onBackPressed() {
  43.                 // TODO Auto-generated method stub
  44.                 super.onBackPressed();
  47.         }
  49.         @Override
  50.         protected void onListItemClick(ListView l, View v, int position, long id) {
  51.                 // TODO Auto-generated method stub
  52.                 super.onListItemClick(l, v, position, id);
  53.                 URL webURL = Article.url;
  56.                 Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webURL
  57.                                 .toString()));
  59.                 startActivity(myIntent);
  61.         }
  62. }
Parsed in 0.013 seconds, using GeSHi

Now i've been wondering if it is somehow possible to do this with onPreExcecute, but i haven't gotton to far with that.

these are the classes i'm working with:
Code: Select all

Any help, suggestions, pointings in the right directions or even better... a solution? :P
Junior Developer
Junior Developer
Posts: 17
Joined: Sun Jul 24, 2011 8:20 pm


Re: progressbar for loading rss feed?

Postby Phyll » Tue Jan 24, 2012 4:28 am

Hi Kalder,

I don't know exactly what is taking all the time in loading the feed or processing it. I would guess processing. But it looks like you have an opportunity to monitor the filling of the list in the RSSReader class. You could send status percentages out from the fillData method.

In the RSSHandler there is no clear cut number, this is where they are counted it seems. You could use the upper limit for articles as 100% and just show progress towards that as each articles end tags are found in the endElement method.

I didn't see any kind of call backs built in to this code.

I guess the hard part of making this into some kind of activity that preceeds the selection list part is how to pass its output on to the next part. I think it looks like a good candidate for global variables at the application level. See this: ... -variables
Or something I might do, cache it locally in a file that matches your list and pass the list to the next activity.

Anybody have any better ideas?

Hope this helps.

Master Developer
Master Developer
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: progressbar for loading rss feed?

Postby Kalder » Fri Jan 27, 2012 7:38 pm

Hello, thanks for the reply, although i must say i do not understand much of the info. I do not know how to use the fillData method.
Anyway, I set up a splashscreen xml with a text an image and a button and made a startsplash activity, now when i press the button it is supposed to set a new intent (the RSSactivity) but before that show a progressdialog that shows the progress of the loaded rss items, but it doesn't do much, it only shows 0/25 and 0% and then goes to the RSSActivity which load the items properly.
But why won't it update the progress?
Can anyone help me out with this?

here is the startsplash class:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class startSplash extends Activity  {
  3.         @Override
  4.         public void onCreate(Bundle savedInstanceState) {
  5.                 // TODO Auto-generated method stub
  6.                 super.onCreate(savedInstanceState);
  7.                 setContentView(R.layout.splash);
  9.                 final ProgressDialog dialog = new ProgressDialog(this);
  10.                 dialog.setCancelable(true);
  11.                 dialog.setMessage("Loading...");
  12.                 dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  13.                 dialog.setProgress(0);
  14.                 dialog.setMax(RSSHandler.ARTICLES_LIMIT);
  16.                 final Thread StartApp = new Thread() {
  17.                         public void run() {
  18.                                 Intent intent = new Intent(startSplash.this, RssActivity.class);
  19.                                 startActivity(intent);
  20.                         }
  21.                 };
  24.                 final Thread LoadingStatus = new Thread() {
  25.                         public void run() {
  26.                                 do {
  28.                                         dialog.setProgress(RSSHandler.articleCount);
  30.                                         if (dialog.getProgress() >= dialog.getMax()) {
  31.                                                 dialog.dismiss();
  32.                                         } else {
  33.                                                 dialog.cancel();
  34.                                         }
  35.                                 } while (dialog.getProgress() != dialog.getMax());                             
  36.                         }              
  37.                 };
  40.                 Button bt1 = (Button) findViewById(;
  41.                 bt1.setOnClickListener(new View.OnClickListener() {
  43.                         @Override
  44.                         public void onClick(View v) {
  45.                                 // TODO Auto-generated method stub
  46.                       ;
  47.                                 LoadingStatus.start();
  48.                                 StartApp.start();      
  50.                         }
  51.                 });
  52.         }
  53. }
Parsed in 0.012 seconds, using GeSHi

It does display the splashScreen layout and the progressdialog untill all the feeds have been loaded then it shows the listview, i see that the log strings are popping up while the splashscreen is still active.
Junior Developer
Junior Developer
Posts: 17
Joined: Sun Jul 24, 2011 8:20 pm

Re: progressbar for loading rss feed?

Postby Phyll » Fri Jan 27, 2012 8:33 pm

Hi Kalder,

Do you have anything in the activity you start for loading to update the progress bar?

How does it know where the progress bar is?

If loading is another activty, is the progress bar even showing?

The way I did it was to add a piece of code to the loader that could send out how it was doing. I also had to send, where the handler (I used messages) was for the progress bar in the constructor of the reader. I also used the application wide global variables for all the pieces that need them.

It was all built around this tutorial which is excellent: ... tion4.html

I'm going to attach this project so you can see what I did.

RSS Reader Example
(88.26 KiB) Downloaded 152 times
Master Developer
Master Developer
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: progressbar for loading rss feed?

Postby Kalder » Fri Jan 27, 2012 10:39 pm

Thank you for your reply, i'm obviously not skilled enough to understand all what's going on in that RSSReader app, but I'm going to give that tutorial from IBM a shot, that surely will help improve my skills in android developing :)

edit: I have tried applying the rss feed i use in my app on your app, it isn't compatible with it though, it displays wrong info and in some cases even a wrong / weird title.
But I like the speed of the app, so i'm still going to follow the tutorial to see if i can learn some new stuff.
Junior Developer
Junior Developer
Posts: 17
Joined: Sun Jul 24, 2011 8:20 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 7 guests