Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 6th, 2012  |  syntax: None  |  size: 2.27 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ProgressDialog does not disappear after executing dismiss, hide or cancel?
  2. public class LODOverlay extends Overlay implements OnClickListener {
  3.  
  4.  
  5.  
  6. private Dialog overlayDialog;
  7.  
  8. private ProgressDialog progressDialog;
  9.  
  10.        ..............
  11.  
  12.  
  13. @Override
  14. public void onClick(View view) {
  15.  
  16.                    .......
  17.  
  18.         final Context ctx = view.getContext();
  19.         this.progressDialog = new ProgressDialog(ctx);
  20.         ListView lv = new ListView(ctx);
  21.         ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx, R.layout.layerlist, names);
  22.         lv.setAdapter(adapter);
  23.         final LODOverlay obj = this;
  24.         lv.setOnItemClickListener(new OnItemClickListener() {
  25.             public void onItemClick(AdapterView<?> parent, View view,
  26.                 int position, long id) {
  27.                 String name = ((TextView) view).getText().toString();
  28.         Intent getFloorIntent = new Intent(Map.RENDERER);
  29.         getFloorIntent.putExtra("type", "onGetBuildingLayer");
  30.         getFloorIntent.putExtra("id", name);
  31.         view.getContext().sendBroadcast(getFloorIntent);
  32.         overlayDialog.dismiss();
  33.  
  34.         obj.waitingForLayer = name;
  35.  
  36.         progressDialog.show(ctx, "Loading...", "Wait!!!");
  37.  
  38.  
  39.             }
  40.         });
  41.  
  42.     .......
  43. }
  44.  
  45.  
  46. public void buildingLoaded(String id) {
  47.     if (null != this.progressDialog) {
  48.         if (id.equals(this.waitingForLayer)) {
  49.             this.progressDialog.hide();
  50.             this.progressDialog.dismiss();
  51.  
  52.     ............
  53.  
  54.             Map.flipper.showNext();  // changes the view
  55.         }
  56.     }
  57. }
  58.        
  59. public static ProgressDialog show (Context context, CharSequence title, CharSequence message)
  60.        
  61. progressDialog.setTitle("Loading...");
  62. progressDialog.setMessage("Wait!!!");
  63. progressDialog.show();
  64.        
  65. progressDialog = ProgressDialog.show(ctx, "Loading...", "Wait!!!");
  66.        
  67. public static ProgressDialog show(Context context, CharSequence title,
  68.         CharSequence message, boolean indeterminate,
  69.         boolean cancelable, OnCancelListener cancelListener) {
  70.     ProgressDialog dialog = new ProgressDialog(context);
  71.     dialog.setTitle(title);
  72.     dialog.setMessage(message);
  73.     dialog.setIndeterminate(indeterminate);
  74.     dialog.setCancelable(cancelable);
  75.     dialog.setOnCancelListener(cancelListener);
  76.     dialog.show();
  77.     return dialog;
  78. }