Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

In this page you can find the example usage for android.app ProgressDialog dismiss.

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:cn.ucai.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//from   w w w  . j  a va 2  s.c om
 * 
 * @param tobeDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_LONG).show();
                    }
                });

            }

        }
    }).start();

}

From source file:fm.smart.r1.activity.ItemActivity.java

public void addToList(final String item_id) {
    final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
    myOtherProgressDialog.setTitle("Please Wait ...");
    myOtherProgressDialog.setMessage("Adding item to study list ...");
    myOtherProgressDialog.setIndeterminate(true);
    myOtherProgressDialog.setCancelable(true);

    final Thread add = new Thread() {
        public void run() {
            ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, item_id,
                    ItemActivity.this);

            myOtherProgressDialog.dismiss();
            ItemActivity.this.runOnUiThread(new Thread() {
                public void run() {
                    final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                    dialog.setTitle(ItemActivity.add_item_result.getTitle());
                    dialog.setMessage(ItemActivity.add_item_result.getMessage());
                    ItemActivity.add_item_result = null;
                    dialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                        }//from w  w  w  .j  a v  a 2 s. co  m
                    });

                    dialog.show();
                }
            });

        }
    };
    myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            add.interrupt();
        }
    });
    OnCancelListener ocl = new OnCancelListener() {
        public void onCancel(DialogInterface arg0) {
            add.interrupt();
        }
    };
    myOtherProgressDialog.setOnCancelListener(ocl);
    closeMenu();
    myOtherProgressDialog.show();
    add.start();
}

From source file:org.akvo.caddisfly.sensor.ec.CalibrateSensorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calibrate_sensor);

    mContext = this;

    //final Intent intent = getIntent();
    //String mUuid = intent.getStringExtra(Constant.UUID);
    //CaddisflyApp.getApp().loadTestConfigurationByUuid(mUuid);
    mCurrentTestInfo = CaddisflyApp.getApp().getCurrentTestInfo();

    mHandler = new UsbDataHandler(this);

    viewAnimator = (ViewAnimator) findViewById(R.id.viewAnimator);

    Button buttonStartCalibrate = (Button) findViewById(R.id.buttonStartCalibrate);
    Button buttonFinishCalibrate = (Button) findViewById(R.id.buttonFinishCalibrate);
    Button buttonNext = (Button) findViewById(R.id.buttonNext);

    fabEdit = (FloatingActionButton) findViewById(R.id.fabEdit);

    if (!mCurrentTestInfo.getName().isEmpty()) {
        ((TextView) findViewById(R.id.textTitle)).setText(mCurrentTestInfo.getName());
    }//from ww w . j  av a  2s . co m

    calibrationPoints = mCurrentTestInfo.getRangeValues();
    textHeading = (TextView) findViewById(R.id.textHeading);
    textSubtitle = (TextView) findViewById(R.id.textSubtitle);
    textInformation = (TextView) findViewById(R.id.textInformation);
    textId = (TextView) findViewById(R.id.textId);

    fabEdit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showEditDetailsDialog();
        }
    });

    buttonStartCalibrate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (usbService.isUsbConnected()) {

                final ProgressDialog connectingProgressDialog = ProgressDialog.show(mContext,
                        getString(R.string.pleaseWait), getString(R.string.deviceConnecting), true, false);

                new Handler().postDelayed(runnable, 100);

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (deviceHasId) {
                            viewAnimator.showNext();
                            fabEdit.setVisibility(View.VISIBLE);
                            textSubtitle.setText(R.string.verifySensorDetails);

                        } else {
                            showEditDetailsDialog();
                        }
                        connectingProgressDialog.dismiss();
                    }
                }, INITIAL_DELAY_MILLIS);

            } else {
                alertSensorNotFound();
            }
        }
    });

    buttonNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (deviceHasId) {
                viewAnimator.showNext();
                fabEdit.setVisibility(View.INVISIBLE);

                displayInformation(calibrationIndex);
            } else {
                showEditDetailsDialog();
            }

        }
    });

    buttonFinishCalibrate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (usbService.isUsbConnected()) {
                calibratePoint(calibrationPoints, calibrationIndex);
                calibrationIndex++;
            } else {
                alertSensorNotFound();
            }
        }
    });
}

From source file:com.softminds.matrixcalculator.OperationFragments.InverseFragment.java

@Override
public void onListItemClick(ListView L, View V, int position, long id) {
    ProgressDialog progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(getString(R.string.Calculating));
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();/*from w  w w. j  a va2s.c o  m*/
    progress = progressDialog;

    if (SquareList.get(position).getJamaMatrix().det() != 0) {
        if (ENABLED_NO_DECIMAL)
            RunAndGetDeterminantWithAdjoint(position, progressDialog);
        else
            RunNewGetInverse(position, progressDialog);
    } else {
        new AlertDialog.Builder(getContext())
                .setMessage("The Determinant of the matrix was Zero and Hence its Inverse does not exist")
                .setTitle("No Inverse Exist")
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).show();
        progressDialog.dismiss();
    }

}

From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java

/**
 * ?/*from  w  ww.  j  a v a  2  s. co  m*/
 * 
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });

            }

        }
    }).start();

}

From source file:cn.ucai.superwechat.fragment.ContactlistFragment.java

/**
 * user???//www. j ava  2  s .c o  m
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(cn.ucai.superwechat.R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(cn.ucai.superwechat.R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(cn.ucai.superwechat.R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:cn.ucai.superwechart.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);//from   w  w  w  . j a v a2  s  .  c  o m
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    SuperWeChatApplication.getInstance().setUa(null);
                    SuperWeChatApplication.getInstance().getUserContactList().clear();
                    SuperWeChatApplication.getInstance().getContactMap().clear();
                    SuperWeChatApplication.getInstance().getGaList().clear();
                    SuperWeChatApplication.getInstance().getGaMap().clear();
                    SuperWeChatApplication.getInstance().getMuaMap().clear();
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}

From source file:de.gebatzens.sia.SetupActivity.java

public void startDownloadingSchool() {
    final ProgressDialog d = new ProgressDialog(this);
    d.setTitle(SIAApp.SIA_APP.school.name);
    d.setMessage(getString(R.string.downloading_image));
    d.setCancelable(false);//from w ww . j  a  v  a2s  .c  o m
    d.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    d.show();

    new Thread() {
        @Override
        public void run() {
            if (!School.downloadImage(SIAApp.SIA_APP.school.image)) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Snackbar.make(getWindow().getDecorView().findViewById(R.id.coordinator_layout),
                                getString(R.string.download_error), Snackbar.LENGTH_LONG).show();
                    }
                });
            }

            //workaround for a bug that causes an endless loading screen
            Subst.GGPlans subst = SIAApp.SIA_APP.api.getPlans(false);
            subst.save();
            SIAApp.SIA_APP.school.fragments.getByType(FragmentData.FragmentType.PLAN).get(0).setData(subst);

            if (d.isShowing())
                d.dismiss();
            Intent i = new Intent(SetupActivity.this, MainActivity.class);
            //i.putExtra("reload", true);
            startActivity(i);
            finish();

        }
    }.start();
}

From source file:com.callba.phone.ui.GroupSimpleDetailActivity.java

public void addToGroup(View view) {
    String st1 = getResources().getString(R.string.Is_sending_a_request);
    final String st2 = getResources().getString(R.string.Request_to_join);
    final String st3 = getResources().getString(R.string.send_the_request_is);
    final String st4 = getResources().getString(R.string.Join_the_group_chat);
    final String st5 = getResources().getString(R.string.Failed_to_join_the_group_chat);
    final ProgressDialog pd = new ProgressDialog(this);
    //      getResources().getString(R.string)
    pd.setMessage(st1);// www .j  a  va 2  s.c o  m
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //membersOnly??join
                if (group.isMembersOnly()) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showDialog();
                        }
                    });
                } else {
                    EMClient.getInstance().groupManager().joinGroup(groupid);
                    LocalBroadcastManager.getInstance(GroupSimpleDetailActivity.this)
                            .sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
                }
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        btn_add_group.setEnabled(false);
                        if (!group.isMembersOnly()) {
                            Toast.makeText(GroupSimpleDetailActivity.this, st4, Toast.LENGTH_SHORT).show();
                            finish();
                        }
                    }
                });
            } catch (final HyphenateException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(GroupSimpleDetailActivity.this, st5 + e.getMessage(), Toast.LENGTH_SHORT)
                                .show();
                        btn_add_group.setEnabled(true);
                    }
                });
            }
        }
    }).start();
}

From source file:nf.frex.android.FrexActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) {
        return;/*from w w w  .j  a va  2  s. com*/
    }
    if (requestCode == R.id.manage_fractals && data.getAction().equals(Intent.ACTION_VIEW)) {
        final Uri imageUri = data.getData();
        if (imageUri != null) {
            File imageFile = new File(imageUri.getPath());
            String configName = FrexIO.getFilenameWithoutExt(imageFile);
            File paramFile = new File(imageFile.getParent(), configName + FrexIO.PARAM_FILE_EXT);
            try {
                FileInputStream fis = new FileInputStream(paramFile);
                try {
                    readFrexDoc(fis, configName);
                } finally {
                    fis.close();
                }
            } catch (IOException e) {
                Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()),
                        Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == R.id.settings) {
        view.getGenerator().setNumTasks(SettingsActivity.getNumTasks(this));
    } else if (requestCode == SELECT_PICTURE_REQUEST_CODE) {
        final Uri imageUri = data.getData();
        final ColorQuantizer colorQuantizer = new ColorQuantizer();
        final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this);
        final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
                colorQuantizer.cancel();
            }
        };
        final ColorQuantizer.ProgressListener progressListener = new ColorQuantizer.ProgressListener() {
            @Override
            public void progress(final String msg, final int iter, final int maxIter) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        progressDialog.setMessage(msg);
                        progressDialog.setProgress(iter);
                    }
                });
            }
        };

        progressDialog.setTitle(getString(R.string.get_pal_from_img_title));
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setCancelable(true);
        progressDialog.setOnCancelListener(cancelListener);
        progressDialog.setMax(colorQuantizer.getMaxIterCount());
        progressDialog.show();

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                Bitmap bitmap;
                try {
                    bitmap = FrexIO.readBitmap(getContentResolver(), imageUri, 256);
                } catch (IOException e) {
                    alert("I/O error: " + e.getLocalizedMessage());
                    return;
                }
                ColorScheme colorScheme = colorQuantizer.quantize(bitmap, progressListener);
                progressDialog.dismiss();
                if (colorScheme != null) {
                    Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: Got colorScheme");
                    String colorSchemeId = "$" + imageUri.toString();
                    colorSchemes.add(colorSchemeId, colorScheme);
                    view.setColorSchemeId(colorSchemeId);
                    view.setColorScheme(colorScheme);
                    view.recomputeColors();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: showDialog(R.id.colors)");
                            showDialog(R.id.colors);
                        }
                    });

                }
            }
        });
        thread.start();
    }
}