/** * Creates and shows an indeterminate progress dialog. Once the progress dialog is shown, it * will be shown for at least the minDisplayTime (in milliseconds), so that the progress dialog * does not flash in and out to quickly. */ public static IndeterminateProgressDialog show(FragmentManager fragmentManager, CharSequence title, CharSequence message, long minDisplayTime) { IndeterminateProgressDialog dialogFragment = new IndeterminateProgressDialog(); dialogFragment.mTitle = title; dialogFragment.mMessage = message; dialogFragment.mMinDisplayTime = minDisplayTime; dialogFragment.show(fragmentManager, TAG); dialogFragment.mShowTime = System.currentTimeMillis(); dialogFragment.setCancelable(false); return dialogFragment; }
@Override public void onClick(DialogInterface dialog, int which) { if (!PermissionsUtil.hasContactsPermissions(context)) { return; } final IndeterminateProgressDialog progressDialog = IndeterminateProgressDialog.show( getFragmentManager(), getString(R.string.clearFrequentsProgress_title), null, 500); final AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { resolver.delete(ContactsContract.DataUsageFeedback.DELETE_USAGE_URI, null, null); return null; } @Override protected void onPostExecute(Void result) { progressDialog.dismiss(); } }; task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } };