proper usage of progress dialog

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

proper usage of progress dialog

Postby chouman » Mon Nov 10, 2008 9:09 pm

I am having a little problem of using progress dialog. Trying to figure out how and the optimal way of using the progress dialog. My application needs to grab information from different servers, so I am trying to show the progress dialog at the appropriate moment.

I am trying to use a gallery to grab different images. At the start of the activity, I will have a pop up that says loading, and then spin off a different thread to start retrieving images in the background and store the images in a bitmap array. And once I get the first few images, the thread would send a message to the activity to let it know that it can set up the adapter and start displaying the first few images. The user then can start flipping through different images. In the adapter getView method, I will check the bitmap array from the thread to see if the image in the specific position that the user is trying to view is loaded yet. If the bitmap array for the position is null then the adapter will send a message to the activity and asks the activity to display the progress dialog and at the same time the adapter will tell the thread that the user is trying to view the image at that specific position. Then the thread will then send a message to the activity to dismiss the progress dialog once the image of that specific position has been loaded.

That's the general idea, but for some reason the message been sent from the adapter to the activity for showing the progress dialog is not working. I can see the message been send because the logging is been printed out in the message handler but the dialog is not showing up. Anyone has a clue?
chouman
Developer
Developer
 
Posts: 27
Joined: Thu Jan 03, 2008 2:59 pm

Top

Postby chouman » Mon Nov 10, 2008 9:19 pm

CORRECTION: it seems like the ProgressDialog is there but just not showing on the top.
this is how i set up the handler

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. private ProgressDialog myProgressDialog;
  5.  
  6.  
  7.  
  8.         public Handler handler = new Handler()
  9.  
  10.         {
  11.  
  12.                 public void handleMessage(Message msg)
  13.  
  14.                 {
  15.  
  16.                         switch (msg.what)
  17.  
  18.                         {
  19.  
  20.                                 case MESSAGE_SHOW_PROGRESSDIALOG:
  21.  
  22.                                         myProgressDialog = ProgressDialog.show(MyApp.this, MyApp.this.getResources().getString(R.string.app_name), "Loading...");
  23.  
  24.                                         break;
  25.  
  26.                                 case MESSAGE_DISMISS_PROGRESSDIALOG:
  27.  
  28.                                         if(myProgressDialog.isShowing())
  29.  
  30.                                                 myProgressDialog.dismiss();
  31.  
  32.                                         break; 
  33.  
  34.                         }
  35.  
  36.                 }
  37.  
  38.         };
  39.  
  40.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
chouman
Developer
Developer
 
Posts: 27
Joined: Thu Jan 03, 2008 2:59 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 28 guests