Example usage for android.app ProgressDialog show

List of usage examples for android.app ProgressDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:app.view.chat.ContactListFragment.java

/**
 * ?/*  w w w  . j ava  2  s. c o m*/
 *
 * @param tobeDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("...");
    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());
                DemoApplication.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(), ": " + e.getMessage(), Toast.LENGTH_LONG)
                                .show();
                    }
                });

            }

        }
    }).start();

}

From source file:app.view.chat.ContactListFragment.java

/**
 * user???// w w  w  . ja  v  a2  s .c  o m
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("???...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, true);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "????", Toast.LENGTH_SHORT).show();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:net.palacesoft.cngstation.client.StationActivity.java

private void startTrackingMyLocation(final int zoomLevel) {

    final ProgressDialog progressDialog = createProgressDialog("Trying to find your location...");
    progressDialog.show();
    myLocationOverlay.runOnFirstFix(new Runnable() {
        @Override//from  w w w.  ja v a 2 s  .  co m
        public void run() {
            currentLocation = myLocationOverlay.getLastFix();
            runOnUiThread(new Runnable() {
                public void run() {
                    progressDialog.dismiss();
                    if (currentLocation != null) {

                        try {
                            currentLocationAddress = lookupAddressFromLocation(currentLocation);
                            new StationLoader(StationActivity.this, currentLocationAddress, zoomLevel,
                                    STATIONS_URL).execute();
                        } catch (AddressEmptyException e) {
                            BugSenseHandler.log("Could not determine the user's location ", e);
                            showInfoMessage("Could not determine your location. Refresh option might help");
                        } catch (IOException e) {
                            //ignore
                        }
                    }
                }
            });
        }
    });
}

From source file:net.kourlas.voipms_sms.gcm.Gcm.java

/**
 * Registers for Google Cloud Messaging. Sends the registration token to the application servers.
 *
 * @param activity     The activity that initiated the registration.
 * @param showFeedback If true, shows a dialog at the end of the registration process indicating the success or
 *                     failure of the process.
 * @param force        If true, retrieves a new registration token even if one is already stored.
 *///from ww w .  j  ava  2  s .c o  m
public void registerForGcm(final Activity activity, final boolean showFeedback, boolean force) {
    if (!preferences.getNotificationsEnabled()) {
        return;
    }
    if (preferences.getDid().equals("")) {
        // Do not show an error; this method should never be called unless a DID is set
        return;
    }
    if (!checkPlayServices(activity, showFeedback)) {
        return;
    }

    final ProgressDialog progressDialog = new ProgressDialog(activity);
    if (showFeedback) {
        progressDialog.setMessage(applicationContext.getString(R.string.notifications_gcm_progress));
        progressDialog.setCancelable(false);
        progressDialog.show();
    }

    final InstanceID instanceIdObj = InstanceID.getInstance(applicationContext);
    final String instanceId = instanceIdObj.getId();
    if (preferences.getGcmToken().equals("") || !instanceId.equals(preferences.getGcmInstanceId()) || force) {
        new AsyncTask<Boolean, Void, Boolean>() {
            @Override
            protected Boolean doInBackground(Boolean... params) {
                try {
                    String token = instanceIdObj.getToken(
                            applicationContext.getString(R.string.notifications_gcm_sender_id),
                            GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

                    String registrationBackendUrl = "https://voipmssms-kourlas.rhcloud.com/register?" + "did="
                            + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "reg_id="
                            + URLEncoder.encode(token, "UTF-8");
                    JSONObject result = Utils.getJson(registrationBackendUrl);
                    String status = result.optString("status");
                    if (status == null || !status.equals("success")) {
                        return false;
                    }

                    preferences.setGcmInstanceId(instanceId);
                    preferences.setGcmToken(token);

                    return true;
                } catch (Exception ex) {
                    return false;
                }
            }

            @Override
            protected void onPostExecute(Boolean success) {
                if (showFeedback) {
                    progressDialog.hide();
                    if (!success) {
                        Utils.showInfoDialog(activity,
                                applicationContext.getResources().getString(R.string.notifications_gcm_fail));
                    } else {
                        Utils.showInfoDialog(activity, applicationContext.getResources()
                                .getString(R.string.notifications_gcm_success));
                    }
                }
            }
        }.execute();
    } else if (showFeedback) {
        Utils.showInfoDialog(activity,
                applicationContext.getResources().getString(R.string.notifications_gcm_success));
    }
}

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

/**
 * /*from   w  ww .j a  v a  2  s . c  om*/
 * 
 * @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:net.kourlas.voipms_sms.Notifications.java

/**
 * Enable SMS notifications by configuring the VoIP.ms URL callback, registering for GCM and making the appropriate
 * changes to the application preferences.
 *
 * @param activity The source activity./*from  www  . j a  v  a 2 s. c o m*/
 */
public void enableNotifications(final Activity activity) {
    if (preferences.getEmail().equals("") || preferences.getPassword().equals("")
            || preferences.getDid().equals("")) {
        Utils.showInfoDialog(activity,
                applicationContext.getString(R.string.notifications_callback_username_password_did));
        return;
    }

    final ProgressDialog progressDialog = new ProgressDialog(activity);
    progressDialog.setMessage(activity.getString(R.string.notifications_callback_progress));
    progressDialog.setCancelable(false);
    progressDialog.show();

    new AsyncTask<Boolean, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Boolean... params) {
            try {
                String url = "https://www.voip.ms/api/v1/rest.php?" + "api_username="
                        + URLEncoder.encode(preferences.getEmail(), "UTF-8") + "&" + "api_password="
                        + URLEncoder.encode(preferences.getPassword(), "UTF-8") + "&" + "method=setSMS" + "&"
                        + "did=" + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "enable=1" + "&"
                        + "url_callback_enable=1" + "&" + "url_callback=" + URLEncoder
                                .encode("http://voipmssms-kourlas.rhcloud.com/sms_callback?did={TO}", "UTF-8")
                        + "&" + "url_callback_retry=0";

                JSONObject result = Utils.getJson(url);
                String status = result.optString("status");
                return !(status == null || !status.equals("success"));
            } catch (Exception ex) {
                return false;
            }
        }

        @Override
        protected void onPostExecute(Boolean success) {
            progressDialog.hide();

            DialogInterface.OnClickListener gcmOnClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    gcm.registerForGcm(activity, true, true);
                }
            };

            if (!success) {
                Utils.showAlertDialog(activity, null,
                        applicationContext.getString(R.string.notifications_callback_fail),
                        applicationContext.getString(R.string.ok), gcmOnClickListener, null, null);
            } else {
                Utils.showAlertDialog(activity, null,
                        applicationContext.getString(R.string.notifications_callback_success),
                        applicationContext.getString(R.string.ok), gcmOnClickListener, null, null);
            }
        }
    }.execute();
}

From source file:com.smapley.vehicle.activity.SetActivity.java

private void updatePic(File file) {
    if (file != null) {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage("");
        RequestParams params = new RequestParams(Constant.URL_ADDPHOTO);
        params.addBodyParameter("ukey", (String) SP.getUser("ukey"));
        params.addBodyParameter("name", file);
        dialog.show();
        x.http().post(params, new BaseCallback<Map>(dialog) {
            @Override//from   ww  w .j a va 2  s .c o m
            public void success(Map result) {
                if (StringUtils.isNoneEmpty(result.get("filename").toString()))
                    x.image().bind(image, Constant.URL_IMG + result.get("filename"), circleImage);
            }
        });
    }

}

From source file:ablgroup.daily2.authentification.AuthentificationFragment.java

private void createAccount(String email, String password) {
    Log.d(TAG, "createAccount:" + email);
    if (!validateForm()) {
        return;/*from   ww  w.j a v a  2 s  . c om*/
    }

    final ProgressDialog pd = new ProgressDialog(AuthentificationFragment.this);
    pd.setMessage("loading");
    pd.show();

    // [START create_user_with_email]
    mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this,
            new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
                    if (!task.isSuccessful()) {
                        Toast.makeText(AuthentificationFragment.this, R.string.auth_failed, Toast.LENGTH_SHORT)
                                .show();
                    }
                    pd.hide();
                }
            });
    // [END create_user_with_email]
}

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

/**
 * // w ww .j  av a  2 s.  c  o  m
 * 
 * @param view
 */
public void register(View view) {

    final String pwd = passwordEditText.getText().toString().trim();
    String confirm_pwd = confirmPwdEditText.getText().toString().trim();
    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;
    }

    RegisterRequest registerReq = new RegisterRequest();

    registerReq.setPassword(pwd);
    registerReq.setUsername(username);
    NetManager.execute(NetManager.REGISTER_REQUEST_OPERATION, registerReq, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            //pd.dismiss();
            Log.e("login_check", " response:" + response.toString());
            //Toast.makeText(getApplicationContext(), ": " + , 0).show();

            //RegisterResponse regResp = (RegisterResponse)response;

            // ?????
            //AlUApplication.getInstance().setUserName(username);
            //AlUApplication.getInstance().setPassword(password);

            /*runOnUiThread(new Runnable() {
               public void run() {
                  pd.setMessage("???...");
               }
            });*/
            try {

                RegisterResponse regResp = new RegisterResponse();
                regResp.setJsonObject(response);
                Log.e("AAAAAAAAAA", "" + regResp.getCode());
                if (regResp.getCode()) {
                    Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getApplicationContext(), ": " + regResp.getInfo(),
                            Toast.LENGTH_SHORT).show();
                }
                // ** ?logout??
                // ** manually load all local groups and
                // conversations in case we are auto login
                //EMGroupManager.getInstance().loadAllGroups();
                //EMChatManager.getInstance().loadAllConversations();

                // demo??????username??
                /*List<String> usernames = EMContactManager.getInstance().getContactUserNames();
                EMLog.d("roster", "contacts size: " + usernames.size());
                        
                for (String username : usernames) {
                   User user = new User();
                   user.setUsername(username);
                   setUserHearder(username, user);
                   userlist.put(username, user);
                }*/
                /*Map<String, User> userlist = new HashMap<String, User>();
                // user""
                User newFriends = new User();
                newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
                newFriends.setNick("");
                newFriends.setHeader("");
                userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
                // "?"
                User groupUser = new User();
                groupUser.setUsername(Constant.GROUP_USERNAME);
                groupUser.setNick("?");
                groupUser.setHeader("");
                userlist.put(Constant.GROUP_USERNAME, groupUser);*/

                // 
                //AlUApplication.getInstance().setContactList(userlist);
                // db
                //UserDao dao = new UserDao(LoginActivity.this);
                //List<User> users = new ArrayList<User>(userlist.values());
                //dao.saveContactList(users);

                // ??(??groupidgroupname????members),sdkdb
                //EMGroupManager.getInstance().getGroupsFromServer();*/
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), ": " + e.getMessage(), Toast.LENGTH_SHORT)
                        .show();
                //e.printStackTrace();
            }

            Log.e("login_check", "1111111111111111111");
            //?nickname ios?nick
            //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick);
            //if (!updatenick) {
            //   EMLog.e("LoginActivity", "update current user nick fail");
            //}

            //if (!LoginActivity.this.isFinishing())
            //pd.dismiss();
            // ?
            startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
            finish();
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject jsonObj) {
            //   Log.e("register", throwable.getMessage());
            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();
                    Log.e("register", responseString);
                    finish();
                }
            });
        }
    });

    //
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        pd.show();
        new Thread(new Runnable() {
            public void run() {
                try {
                    // sdk
                    EMChatManager.getInstance().createAccountOnServer(username, pwd);
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            // ???
                            AlUApplication.getInstance().setUserName(username);
                            Toast.makeText(getApplicationContext(), "?", 0).show();
                            finish();
                        }
                    });
                } catch (final EaseMobException e) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            int errorCode = e.getErrorCode();
                            if (errorCode == EMError.NONETWORK_ERROR) {
                                Toast.makeText(getApplicationContext(), "?",
                                        Toast.LENGTH_SHORT).show();
                            } else if (errorCode == EMError.USER_ALREADY_EXISTS) {
                                Toast.makeText(getApplicationContext(), "?",
                                        Toast.LENGTH_SHORT).show();
                            } else if (errorCode == EMError.UNAUTHORIZED) {
                                Toast.makeText(getApplicationContext(), "???",
                                        Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(getApplicationContext(), ": " + e.getMessage(),
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
            }
        }).start();

    }
    //
}

From source file:me.kartikarora.transfersh.activities.TransferActivity.java

private void uploadFile(Uri uri) throws IOException {
    final ProgressDialog dialog = new ProgressDialog(TransferActivity.this);
    dialog.setMessage(getString(R.string.uploading_file));
    dialog.setCancelable(false);//from   w  w w  .j a  va2s .c  o  m
    dialog.show();
    Cursor cursor = getContentResolver().query(uri, null, null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
        final String name = cursor.getString(nameIndex);
        final String mimeType = getContentResolver().getType(uri);
        Log.d(this.getClass().getSimpleName(), cursor.getString(0));
        Log.d(this.getClass().getSimpleName(), name);
        Log.d(this.getClass().getSimpleName(), mimeType);
        InputStream inputStream = getContentResolver().openInputStream(uri);
        OutputStream outputStream = openFileOutput(name, MODE_PRIVATE);
        if (inputStream != null) {
            IOUtils.copy(inputStream, outputStream);
            final File file = new File(getFilesDir(), name);
            TypedFile typedFile = new TypedFile(mimeType, file);
            TransferClient.getInterface().uploadFile(typedFile, name, new ResponseCallback() {
                @Override
                public void success(Response response) {
                    BufferedReader reader;
                    StringBuilder sb = new StringBuilder();
                    try {
                        reader = new BufferedReader(new InputStreamReader(response.getBody().in()));
                        String line;
                        try {
                            while ((line = reader.readLine()) != null) {
                                sb.append(line);
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = sb.toString();
                    Snackbar.make(mCoordinatorLayout, name + " " + getString(R.string.uploaded),
                            Snackbar.LENGTH_SHORT).show();

                    ContentValues values = new ContentValues();
                    values.put(FilesContract.FilesEntry.COLUMN_NAME, name);
                    values.put(FilesContract.FilesEntry.COLUMN_TYPE, mimeType);
                    values.put(FilesContract.FilesEntry.COLUMN_URL, result);
                    values.put(FilesContract.FilesEntry.COLUMN_SIZE, String.valueOf(file.getTotalSpace()));
                    getContentResolver().insert(FilesContract.BASE_CONTENT_URI, values);
                    getSupportLoaderManager().restartLoader(BuildConfig.VERSION_CODE, null,
                            TransferActivity.this);
                    FileUtils.deleteQuietly(file);
                    if (dialog.isShowing())
                        dialog.hide();
                }

                @Override
                public void failure(RetrofitError error) {
                    error.printStackTrace();
                    if (dialog.isShowing())
                        dialog.hide();
                    Snackbar.make(mCoordinatorLayout, R.string.something_went_wrong, Snackbar.LENGTH_INDEFINITE)
                            .setAction(R.string.report, new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    // TODO add feedback code
                                }
                            }).show();
                }
            });
        } else
            Snackbar.make(mCoordinatorLayout, R.string.unable_to_read, Snackbar.LENGTH_SHORT).show();
    }
}