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:cmu.cconfs.instantMessage.activities.SettingsFragment.java

void logout() {
    ParseUser.logOut();/*from  w ww. j av  a 2 s. c o m*/
    PreferencesManager mPreferencesManager = new PreferencesManager(getActivity());
    mPreferencesManager.writeBooleanPreference("LoggedIn", false);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    IMHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((IMMainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), cmu.cconfs.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:com.m2dl.mini_projet.mini_projet_android.MainActivity.java

public void refreshPhoto() {
    for (Marker marker : myPhotoMarkers.keySet()) {
        marker.remove();/*from w ww .  j a va2 s  .c  o  m*/
    }
    final boolean[] loaded = { false };
    myPhotoMarkers.clear();
    Callback<List<Image>> callback = new Callback<List<Image>>() {
        @Override
        public void success(List<Image> images, Response response) {
            List<Photo> photos = new ArrayList<>();
            for (Image p : images) {
                Photo photo = new Photo(p.getAuthor(), p.getCoordLat(), p.getCoordLong(), p.getDate(), p.url());
                photo.setTag(p.getTags());
                String[] myTags = p.getTags().split(",");
                for (String tag : myTags) {
                    Tag myTag = new Tag(tag.replaceAll("\\s", ""));
                    photo.putTag(myTag);
                }
                photos.add(photo);
            }
            allTags.clear();
            allTags.addAll(TagUtil.extractTags(photos));

            if (selectedTags.size() == 0)
                selectedTags.addAll(allTags);
            showPhotoMarker(photos);
            loaded[0] = true;
        }

        @Override
        public void failure(RetrofitError error) {
            System.err.println("not good ...");
        }
    };

    SimpleImageTag imageTag = ServiceGenerator.createService(SimpleImageTag.class);
    imageTag.getImages(callback);
    final ProgressDialog progDialog = ProgressDialog.show(this,
            "Rcupration des points d'intrt en cours...", "Veuillez patienter", true);
    new Thread() {
        public void run() {
            try {
                while (!loaded[0])
                    ;
            } catch (Exception e) {
                Log.e(TAG, e.getMessage());
            }
            progDialog.dismiss();
        }
    }.start();
}

From source file:com.mobicage.rogerthat.registration.OauthRegistrationActivity.java

private void registerWithOauthCode(final String code, final String state) {
    final String timestamp = "" + mWiz.getTimestamp();
    final String deviceId = mWiz.getDeviceId();
    final String registrationId = mWiz.getRegistrationId();
    final String installId = mWiz.getInstallationId();
    // Make call to Rogerthat
    final ProgressDialog progressDialog = UIUtils.showProgressDialog(OauthRegistrationActivity.this, null,
            getString(R.string.loading), true, false);
    final SafeRunnable showErrorDialog = new SafeRunnable() {
        @Override//from   w  ww . ja va  2 s  .c o  m
        protected void safeRun() throws Exception {
            T.UI();
            progressDialog.dismiss();
            UIUtils.showDialog(OauthRegistrationActivity.this, null, R.string.registration_error);
        }
    };

    runOnWorker(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.REGISTRATION();
            String version = "3";
            String signature = SecurityUtils.sha256(version + " " + installId + " " + timestamp + " " + deviceId
                    + " " + registrationId + " " + code + state + CloudConstants.REGISTRATION_MAIN_SIGNATURE);

            HttpPost httppost = HTTPUtil.getHttpPost(mService,
                    CloudConstants.REGISTRATION_OAUTH_REGISTERED_URL);
            try {
                List<NameValuePair> nameValuePairs = HTTPUtil.getRegistrationFormParams(mService);
                nameValuePairs.add(new BasicNameValuePair("version", version));
                nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp));
                nameValuePairs.add(new BasicNameValuePair("device_id", deviceId));
                nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId));
                nameValuePairs.add(new BasicNameValuePair("signature", signature));
                nameValuePairs.add(new BasicNameValuePair("install_id", installId));
                nameValuePairs.add(new BasicNameValuePair("code", code));
                nameValuePairs.add(new BasicNameValuePair("state", state));
                nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", getGCMRegistrationId()));

                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                // Execute HTTP Post Request
                HttpResponse response = mHttpClient.execute(httppost);

                int statusCode = response.getStatusLine().getStatusCode();
                HttpEntity entity = response.getEntity();

                if (entity == null) {
                    runOnUI(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            mErrorTextView.setText(R.string.registration_error);
                            showErrorDialog.run();
                        }
                    });
                    return;
                }

                @SuppressWarnings("unchecked")
                final Map<String, Object> responseMap = (Map<String, Object>) JSONValue
                        .parse(new InputStreamReader(entity.getContent()));

                if (statusCode != 200 || responseMap == null) {
                    if (statusCode == 500 && responseMap != null) {
                        final String errorMessage = (String) responseMap.get("error");
                        if (errorMessage != null) {
                            progressDialog.dismiss();
                            runOnUI(new SafeRunnable() {
                                @Override
                                protected void safeRun() throws Exception {
                                    T.UI();
                                    mErrorTextView.setText(errorMessage);
                                    UIUtils.showDialog(OauthRegistrationActivity.this, null, errorMessage);
                                }
                            });
                            return;
                        }
                    }
                    runOnUI(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            mErrorTextView.setText(R.string.registration_error);
                            showErrorDialog.run();
                        }
                    });
                    return;
                }

                Boolean hasDevices = (Boolean) responseMap.get("has_devices");
                final String email = (String) responseMap.get("email");
                if (hasDevices) {
                    final JSONArray deviceNames = (JSONArray) responseMap.get("device_names");
                    runOnUI(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            T.UI();
                            mErrorTextView.setText(R.string.authenticate_first);
                            progressDialog.dismiss();
                            mWiz.setEmail(email);
                            mWiz.setDeviceNames(deviceNames);
                            mWiz.proceedToNextPage();
                        }
                    });
                } else {
                    JSONObject account = (JSONObject) responseMap.get("account");
                    setAgeAndGenderSet((Boolean) responseMap.get("age_and_gender_set"));
                    final RegistrationInfo info = new RegistrationInfo(email,
                            new Credentials((String) account.get("account"), (String) account.get("password")));
                    runOnUI(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            T.UI();
                            mWiz.setEmail(email);
                            mWiz.save();
                            tryConnect(progressDialog, 1, getString(R.string.registration_establish_connection,
                                    email, getString(R.string.app_name)) + " ", info);
                        }
                    });
                }

            } catch (Exception e) {
                L.d(e);
                runOnUI(new SafeRunnable() {
                    @Override
                    protected void safeRun() throws Exception {
                        mErrorTextView.setText(R.string.registration_error);
                        showErrorDialog.run();
                    }
                });
            }
        }
    });
}

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

public void RunNewGetInverse(final int pos, final ProgressDialog pq) {
    Runnable runnable = new Runnable() {
        @Override//from   www .  j a v  a2 s.  c  o  m
        public void run() {
            MatrixV2 res = SquareList.get(pos).getInverse(pq);
            Message message = new Message();
            if (res != null) {
                message.setData(res.getDataBundled());
                myHandler.sendMessage(message);
            } else {
                myHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getContext(), R.string.NoInverse, Toast.LENGTH_SHORT).show();
                    }
                }, 0);
                pq.dismiss();
            }
        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
}

From source file:com.imalu.alyou.activity.MySettingActivity.java

public void modifySetting(View v) {

    final ProgressDialog pd = new ProgressDialog(MySettingActivity.this);
    pd.setCanceledOnTouchOutside(false);

    nickname = (EditText) findViewById(R.id.nickname);

    final String name = nickname.getText().toString();

    ModifyUserRequest userInfo = new ModifyUserRequest();
    userInfo.setName(name);/*  w ww.  jav a  2 s  .  c o m*/
    userInfo.setRealname(name);
    userInfo.setPhoneNum(AlUApplication.getMyInfo().getPhoneNum());
    userInfo.setPassword(AlUApplication.getMyInfo().getPassword());

    NetManager.execute(NetManager.MODIFY_USER_REQUEST_OPERATION, userInfo, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {

            try {

                pd.dismiss();
                Log.e("login_check", " response:" + response.toString());

                OperationResponse operationRes = new OperationResponse();
                operationRes.setJsonObject(response);

                AlUApplication.getMyInfo().setUsername(name);

            } catch (Exception e) {
                e.printStackTrace();
            }

            finish();
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, final String responseString,
                Throwable throwable) {

            runOnUiThread(new Runnable() {
                public void run() {
                    //pd.dismiss();
                    Toast.makeText(getApplicationContext(), ": " + responseString, 0).show();

                }
            });
        }
    });

}

From source file:com.zigvine.zagriculture.UIActivity.java

private void manualUpdateCheck() {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("");
    pd.setCanceledOnTouchOutside(false);
    pd.show();// www .j a va2  s . c o m
    MainApp.getInstance().startCheck(new UpdateCheckListener() {
        @Override
        public void onCheckedOver(int result) {
            pd.dismiss();
            if (result == MainApp.CHECKED_NO_NEED) {
                UI.toast("?");
            } else if (result == MainApp.UNCHECKED) {
                UI.toast("");
            }
        }
    }, true);
}

From source file:com.koushikdutta.superuser.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Settings.applyDarkThemeSetting(this, R.style.SuperuserDarkActivity);
    super.onCreate(savedInstanceState);

    if (Settings.getBoolean(this, "first_run", true)) {
        saveWhatsNew();// w  ww. ja v a  2 s  .  c o  m
        Settings.setBoolean(this, "first_run", false);
    }

    final ProgressDialog dlg = new ProgressDialog(this);
    dlg.setTitle(R.string.superuser);
    dlg.setMessage(getString(R.string.checking_superuser));
    dlg.setIndeterminate(true);
    dlg.show();
    new Thread() {
        public void run() {
            boolean _error = false;
            try {
                SuHelper.checkSu(MainActivity.this);
            } catch (Exception e) {
                e.printStackTrace();
                _error = true;
            }
            final boolean error = _error;
            dlg.dismiss();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (error) {
                        doInstall();
                    } else {
                        doWhatsNew();
                    }
                }
            });
        };
    }.start();
}

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

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(cn.ucai.foraging.R.string.Are_logged_out);
    pd.setMessage(st);/*w w w . ja 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() {
                    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:com.lykj.weixun.ui.chat.ui.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);/*from   ww  w  .  j a  v a2s  .c om*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // show login screen
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), com.lykj.weixun.ui.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:cn.ucai.yizhesale.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(cn.ucai.yizhesale.R.string.Are_logged_out);
    pd.setMessage(st);//ww  w  .j  av a 2 s. co m
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    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();

                }
            });
        }
    });
}