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:com.piusvelte.sonet.core.SonetCreatePost.java

protected void getPhoto(Uri uri) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Uri, Void, String> asyncTask = new AsyncTask<Uri, Void, String>() {
        @Override/*from   w  ww .  j  av  a2s.c  o m*/
        protected String doInBackground(Uri... imgUri) {
            String[] projection = new String[] { MediaStore.Images.Media.DATA };
            String path = null;
            Cursor c = getContentResolver().query(imgUri[0], projection, null, null, null);
            if ((c != null) && c.moveToFirst()) {
                path = c.getString(c.getColumnIndex(projection[0]));
            } else {
                // some file manages send the path through the uri
                path = imgUri[0].getPath();
            }
            c.close();
            return path;
        }

        @Override
        protected void onPostExecute(String path) {
            if (loadingDialog.isShowing())
                loadingDialog.dismiss();
            if (path != null)
                setPhoto(path);
            else
                (Toast.makeText(SonetCreatePost.this, "error retrieving the photo path", Toast.LENGTH_LONG))
                        .show();
        }
    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute(uri);
}

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

/**
 * ?//from  w  w  w .  j  a v  a  2 s  .c  o m
 * 
 * @param
 */
public void deleteContact(final Contact tobeDeleteUser) {
    String st1 = getResources().getString(cn.ucai.superwechat.R.string.deleting);
    final String st2 = getResources().getString(cn.ucai.superwechat.R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    try {
        String path = new ApiParams()
                .with(I.Contact.USER_NAME, superWeChatApplication.getInstance().getUserName())
                .with(I.Contact.CU_NAME, tobeDeleteUser.getMUserName()).getRequestUrl(I.REQUEST_DELETE_CONTACT);
        ((MainActivity) getActivity()).executeRequest(new GsonRequest<Boolean>(path, Boolean.class,
                responseDeleteContactListener(tobeDeleteUser), ((MainActivity) getActivity()).errorListener()));
    } catch (Exception e) {
        e.printStackTrace();
    }
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getMContactCname());
                // db?
                EMUserDao dao = new EMUserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getMContactCname());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getMContactCname());
                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:au.com.wallaceit.reddinator.SubredditSelectActivity.java

private void refreshMultireddits() {

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);/*from   www.ja  v  a 2  s . com*/
    final ProgressDialog sdialog = ProgressDialog.show(SubredditSelectActivity.this, "Refreshing Multis",
            "One moment...", true);
    Thread t = new Thread() {
        public void run() {

            final int listLength;
            try {
                listLength = global.loadAccountMultis();
            } catch (final RedditData.RedditApiException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        sdialog.dismiss();
                        // check login required
                        if (e.isAuthError())
                            global.mRedditData.initiateLogin(SubredditSelectActivity.this);
                        // show error
                        Toast.makeText(SubredditSelectActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
                    }
                });
                return;
            }
            runOnUiThread(new Runnable() {
                public void run() {
                    sdialog.dismiss();
                    if (listLength == 0) {
                        Toast.makeText(SubredditSelectActivity.this,
                                "No multis in your account \nClick the add multi button to create some",
                                Toast.LENGTH_LONG).show();
                    }
                    mMultiAdapter.refreshMultis();
                }
            });
        }
    };
    t.start();
}

From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java

private void refreshSubreddits() {

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);//w  w w  . j  av  a2s.c o m
    final ProgressDialog sdialog = ProgressDialog.show(SubredditSelectActivity.this, "Refreshing Subreddits",
            "One moment...", true);
    Thread t = new Thread() {
        public void run() {

            final int listLength;
            try {
                listLength = global.loadAccountSubreddits();
            } catch (final RedditData.RedditApiException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        sdialog.dismiss();
                        // check login required
                        if (e.isAuthError())
                            global.mRedditData.initiateLogin(SubredditSelectActivity.this);
                        // show error
                        Toast.makeText(SubredditSelectActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
                    }
                });
                return;
            }
            runOnUiThread(new Runnable() {
                public void run() {
                    sdialog.dismiss();
                    if (listLength == 0) {
                        Toast.makeText(SubredditSelectActivity.this,
                                "No subscriptions in your account, \nSuscribe to some subreddits",
                                Toast.LENGTH_LONG).show();
                    }
                    refreshSubredditsList();
                }
            });
        }
    };
    t.start();
}

From source file:com.ccxt.whl.activity.RegisterActivity.java

/**
 * /*  w ww  .jav  a2s.c o m*/
 * 
 * @param view
 */
public void register(View view) {
    final String email = emailEditText.getText().toString().trim();
    final String username = userNameEditText.getText().toString().trim();
    final String pwd = passwordEditText.getText().toString().trim();
    String confirm_pwd = confirmPwdEditText.getText().toString().trim();
    if (TextUtils.isEmpty(email)) {
        Toast.makeText(this, "??", Toast.LENGTH_SHORT).show();
        emailEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(username)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        userNameEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        passwordEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(confirm_pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        confirmPwdEditText.requestFocus();
        return;
    } else if (!pwd.equals(confirm_pwd)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        return;
    } else if (sex == null) {
        Toast.makeText(this, "?", Toast.LENGTH_SHORT).show();
        return;
    }

    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        pd.show();
        RequestParams params = new RequestParams();
        params.add("tel_email", email);
        params.add("nickname", username);
        params.add("pwd", MD5.MD5Hash(pwd));
        params.add("sex", sex);
        params.add("uid", uid);

        HttpRestClient.get(Constant.REGISTER_URL, params, new BaseJsonHttpResponseHandler() {

            @Override
            public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) {
                Log.d("login_res_json" + rawJsonResponse);

                if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                    Toast.makeText(getApplicationContext(), "?,?", 0)
                            .show();
                    return;
                }
                Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);

                if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) {
                    Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                    String resultStr = "status:" + lm.get("status") + "\n" + "message:" + lm.get("message")
                            + "\n" + "result:" + lm.get("result") + "\n" + "user:" + result.get("user") + "\n"
                            + "pwd:" + result.get("pwd") + "\n";

                    Log.d("login_res_obj" + resultStr);
                    pd.dismiss();

                    //Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                    //reg(result.get("user").toString(),result.get("pwd").toString());
                    Toast.makeText(getApplicationContext(), lm.get("message").toString(), 0).show();
                } else {
                    Toast.makeText(getApplicationContext(), lm.get("message").toString(), 0).show();
                    pd.dismiss();
                }

            }

            @Override
            public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                    Object errorResponse) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "?,?", 0).show();
            }

            @Override
            protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
                // TODO Auto-generated method stub
                return null;
            }

        });

    }
}

From source file:nl.eduvpn.app.fragment.HomeFragment.java

/**
 * Now that we have the key pair, we can download the profile.
 *
 * @param instance      The API instance definition.
 * @param discoveredAPI The discovered API URLs.
 * @param savedKeyPair  The private key and certificate used to generate the profile.
 * @param profile       The profile to create.
 * @param dialog        Loading dialog which should be dismissed when finished.
 */// w  w  w. java 2  s.  c  o  m
private void _downloadProfileWithKeyPair(final Instance instance, DiscoveredAPI discoveredAPI,
        final SavedKeyPair savedKeyPair, final Profile profile, final AuthState authState,
        final ProgressDialog dialog) {
    dialog.setMessage(getString(R.string.vpn_profile_download_message));
    String requestData = "?profile_id=" + profile.getProfileId();
    _apiService.getString(discoveredAPI.getProfileConfigEndpoint() + requestData, authState,
            new APIService.Callback<String>() {
                @Override
                public void onSuccess(String vpnConfig) {
                    // The downloaded profile misses the <cert> and <key> fields. We will insert that via the saved key pair.
                    String configName = FormattingUtils.formatProfileName(getContext(), instance, profile);
                    VpnProfile vpnProfile = _vpnService.importConfig(vpnConfig, configName, savedKeyPair);
                    if (vpnProfile != null && getActivity() != null) {
                        // Cache the profile
                        SavedProfile savedProfile = new SavedProfile(instance, profile,
                                vpnProfile.getUUIDString());
                        _historyService.cacheSavedProfile(savedProfile);
                        // Connect with the profile
                        dialog.dismiss();
                        _vpnService.connect(getActivity(), vpnProfile);
                        ((MainActivity) getActivity()).openFragment(new ConnectionStatusFragment(), false);
                    } else {
                        dialog.dismiss();
                        _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title,
                                R.string.error_importing_profile);
                    }
                }

                @Override
                public void onError(String errorMessage) {
                    dialog.dismiss();
                    _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title,
                            getString(R.string.error_fetching_profile, errorMessage));
                    Log.e(TAG, "Error fetching profile: " + errorMessage);
                }
            });
}

From source file:com.shafiq.myfeedle.core.MyfeedleCreatePost.java

protected void getPhoto(Uri uri) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Uri, Void, String> asyncTask = new AsyncTask<Uri, Void, String>() {
        @Override//from w ww  .ja va  2 s  .  c  om
        protected String doInBackground(Uri... imgUri) {
            String[] projection = new String[] { MediaStore.Images.Media.DATA };
            String path = null;
            Cursor c = getContentResolver().query(imgUri[0], projection, null, null, null);
            if ((c != null) && c.moveToFirst()) {
                path = c.getString(c.getColumnIndex(projection[0]));
            } else {
                // some file manages send the path through the uri
                path = imgUri[0].getPath();
            }
            c.close();
            return path;
        }

        @Override
        protected void onPostExecute(String path) {
            if (loadingDialog.isShowing())
                loadingDialog.dismiss();
            if (path != null)
                setPhoto(path);
            else
                (Toast.makeText(MyfeedleCreatePost.this, "error retrieving the photo path", Toast.LENGTH_LONG))
                        .show();
        }
    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute(uri);
}

From source file:br.com.indigo.android.facebook.SocialFacebook.java

public void commentPost(final Activity activity, final String postId, final NewObjectListener listener) {

    if (!mFacebook.isSessionValid()) {
        login(activity, new SimpleRequestListener() {

            public void onComplete() {
                commentPost(activity, postId, listener);
            }//ww  w  .  j a v a2 s  .c o m

            public void onFail(Throwable thr) {
                listener.onFail(thr);
            }

            public void onCancel() {
                listener.onCancel();
            }
        });
    } else {

        final FbTextDialog dialog = new FbTextDialog(activity);
        dialog.setDialogListener(new DialogListener() {

            public void onComplete(Bundle values) {

                final ProgressDialog spinner = new ProgressDialog(activity);
                spinner.setMessage(spinner.getContext().getString(R.string.loading));
                spinner.setCancelable(false);
                spinner.show();

                facebookRequest(activity, postId + "/comments", values, "POST", true, new RequestAdapter() {

                    public void onFail(Throwable thr, Object state) {
                        listener.onFail(thr);
                        spinner.dismiss();
                        dialog.dismiss();
                    }

                    public void onComplete(JSONObject jsonResponse, Object state) {
                        listener.onComplete(jsonResponse.optString("id"));
                        spinner.dismiss();
                        dialog.dismiss();
                    }

                    public void onCancel() {
                        listener.onCancel();
                        spinner.dismiss();
                        dialog.dismiss();
                    }
                });
            }

            public void onFacebookError(FacebookError e) {
                listener.onFail(e);
            }

            public void onError(DialogError e) {
                listener.onFail(e);
            }

            public void onCancel() {
                listener.onCancel();
            }
        });

        dialog.show();
    }
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

/**
 * Returns a response handler that displays a loading message for the RECENT
 * api//from  w ww  . ja  v  a  2  s  . c o m
 * 
 * @return SamKnowsResponseHandler
 */
private SamKnowsResponseHandler getRecentLoadingResponseHandler(String message) {
    final ProgressDialog dialog = getProgressDialog(message);
    return new SamKnowsResponseHandler() {
        public void onSuccess(JSONObject result, Date date, String start_date) {
            dialog.dismiss();
            // setRecentData(result);
        }

        public void onFailure(Throwable error) {
            dialog.dismiss();
        }
    };
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

/**
 * Returns a response handler that displays a loading message
 * //from  w  w  w  .  j  ava  2  s .c o m
 * @return SamKnowsResponseHandler
 */
private SamKnowsResponseHandler getLoadingResponseHandler(String message) {
    final ProgressDialog dialog = getProgressDialog(message);
    return new SamKnowsResponseHandler() {
        public void onSuccess(JSONObject result, Date date, String start_date) {
            dialog.dismiss();
            // setStartDate(start_date);
            // setData(result);
            // setDate(date);
        }

        public void onFailure(Throwable error) {
            Logger.e(SamKnowsAggregateStatViewerActivity.class, "failed to get data", error);
            dialog.dismiss();
        }
    };
}