Example usage for android.app ProgressDialog setMessage

List of usage examples for android.app ProgressDialog setMessage

Introduction

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

Prototype

@Override
    public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.youti.chat.activity.ContactlistFragment.java

/**
 * ?//from www.ja v a2 s .com
 * 
 * @param toDeleteUser
 */
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());
                YoutiApplication.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(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.clearcenter.mobile_demo.mdAuthenticatorActivity.java

protected Dialog onCreateDialog(int id) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage(getText(R.string.login_activity_authenticating));
    dialog.setIndeterminate(true);/* w w w  .  j a v  a 2  s  .co  m*/
    dialog.setCancelable(true);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            Log.i(TAG, "user cancelling authentication");
            if (auth_task != null) {
                auth_task.cancel(true);
            }
        }
    });
    // We save off the progress dialog in a field so that we can dismiss
    // it later. We can't just call dismissDialog(0) because the system
    // can lose track of our dialog if there's an orientation change.
    progress_dialog = dialog;
    return dialog;
}

From source file:id.nci.stm_9.ProgressDialogFragment.java

/**
 * Creates dialog//www  .ja  v a 2  s.  c  o m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();

    ProgressDialog dialog = new ProgressDialog(activity);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);

    int messageId = getArguments().getInt(ARG_MESSAGE_ID);
    int style = getArguments().getInt(ARG_STYLE);

    dialog.setMessage(getString(messageId));
    dialog.setProgressStyle(style);

    // Disable the back button
    OnKeyListener keyListener = new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK) {
                return true;
            }
            return false;
        }

    };
    dialog.setOnKeyListener(keyListener);

    return dialog;
}

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

/**
 * /*from  w w  w  .j  a va2s .co 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:cn.kangeqiu.kq.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*from   w  w  w . j  a v  a 2 s .  c  om*/
    BaseApplication.getInstance().logout(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) {

        }
    });
}

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

void doRecoveryInstall() {
    final ProgressDialog dlg = new ProgressDialog(this);
    dlg.setTitle(R.string.installing);/*from   ww w . j a  va2  s .c  o m*/
    dlg.setMessage(getString(R.string.installing_superuser));
    dlg.setIndeterminate(true);
    dlg.show();
    new Thread() {
        void doEntry(ZipOutputStream zout, String entryName, String dest) throws IOException {
            ZipFile zf = new ZipFile(getPackageCodePath());
            ZipEntry ze = zf.getEntry(entryName);
            zout.putNextEntry(new ZipEntry(dest));
            InputStream in;
            StreamUtility.copyStream(in = zf.getInputStream(ze), zout);
            zout.closeEntry();
            in.close();
            zf.close();
        }

        public void run() {
            try {
                File zip = getFileStreamPath("superuser.zip");
                ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(zip));
                doEntry(zout, "assets/update-binary", "META-INF/com/google/android/update-binary");
                doEntry(zout, "assets/install-recovery.sh", "install-recovery.sh");
                zout.close();

                ZipFile zf = new ZipFile(getPackageCodePath());
                ZipEntry ze = zf.getEntry("assets/" + getArch() + "/reboot");
                InputStream in;
                FileOutputStream reboot;
                StreamUtility.copyStream(in = zf.getInputStream(ze),
                        reboot = openFileOutput("reboot", MODE_PRIVATE));
                reboot.close();
                in.close();

                final File su = extractSu();

                String command = String.format("cat %s > /cache/superuser.zip\n", zip.getAbsolutePath())
                        + String.format("cat %s > /cache/su\n", su.getAbsolutePath())
                        + String.format("cat %s > /cache/Superuser.apk\n", getPackageCodePath())
                        + "mkdir /cache/recovery\n"
                        + "echo '--update_package=CACHE:superuser.zip' > /cache/recovery/command\n"
                        + "chmod 644 /cache/superuser.zip\n" + "chmod 644 /cache/recovery/command\n" + "sync\n"
                        + String.format("chmod 755 %s\n", getFileStreamPath("reboot").getAbsolutePath())
                        + "reboot recovery\n";
                Process p = Runtime.getRuntime().exec("su");
                p.getOutputStream().write(command.getBytes());
                p.getOutputStream().close();
                File rebootScript = getFileStreamPath("reboot.sh");
                StreamUtility.writeFile(rebootScript,
                        "reboot recovery ; " + getFileStreamPath("reboot").getAbsolutePath() + " recovery ;");
                p.waitFor();
                Runtime.getRuntime().exec(new String[] { "su", "-c", ". " + rebootScript.getAbsolutePath() });
                if (p.waitFor() != 0)
                    throw new Exception("non zero result");
            } catch (Exception ex) {
                ex.printStackTrace();
                dlg.dismiss();

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                        builder.setPositiveButton(android.R.string.ok, null);
                        builder.setTitle(R.string.install);
                        builder.setMessage(R.string.install_error);
                        builder.create().show();
                    }
                });
            }
        }
    }.start();
}

From source file:org.protocoder.appApi.ProtoScripts.java

public void shareProtoFileDialog(String folder, String name) {
    final ProgressDialog progress = new ProgressDialog(mProtocoder.a);
    progress.setTitle("Exporting .proto");
    progress.setMessage("Your project will be ready soon!");
    progress.setCancelable(true);//  w  w w .j av  a 2 s.co m
    progress.setCanceledOnTouchOutside(false);
    progress.show();

    String zipFilePath = exportProto(folder, name);

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(zipFilePath)));
    shareIntent.setType("application/zip");

    progress.dismiss();

    mProtocoder.a.startActivity(
            Intent.createChooser(shareIntent, mProtocoder.a.getResources().getText(R.string.share_proto_file)));
}

From source file:com.avcall.app.ui.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*from   w  w w .  j  av  a2s .co m*/
    AvcallHelper.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(), 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:fm.smart.r1.CreateExampleActivity.java

public void onClick(View v) {
    EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence);
    EditText translationInput = (EditText) findViewById(R.id.create_example_translation);
    EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration);
    EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration);
    final String example = exampleInput.getText().toString();
    final String translation = translationInput.getText().toString();
    if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) {
        Toast t = Toast.makeText(this, "Example and translation are required fields", 150);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();// w  ww.java 2s  .co  m
    } else {
        final String example_language_code = Utils.LANGUAGE_MAP.get(example_language);
        final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language);
        final String example_transliteration = exampleTransliterationInput.getText().toString();
        final String translation_transliteration = translationTransliterationInput.getText().toString();

        if (LoginActivity.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
            // navigation
            // back to this?
            LoginActivity.return_to = CreateExampleActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("goal_id", goal_id);
            LoginActivity.params.put("item_id", item_id);
            LoginActivity.params.put("example", example);
            LoginActivity.params.put("translation", translation);
            LoginActivity.params.put("example_language", example_language);
            LoginActivity.params.put("translation_language", translation_language);
            LoginActivity.params.put("example_transliteration", example_transliteration);
            LoginActivity.params.put("translation_transliteration", translation_transliteration);
            startActivity(intent);
        } else {

            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Creating Example ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread create_example = new Thread() {
                public void run() {
                    // TODO make this interruptable .../*if
                    // (!this.isInterrupted())*/
                    try {
                        // TODO failures here could derail all ...
                        CreateExampleActivity.add_item_goal_result = new AddItemResult(
                                Main.lookup.addItemToGoal(Main.transport, goal_id, item_id, null));

                        Result result = null;
                        try {
                            result = Main.lookup.createExample(Main.transport, translation,
                                    translation_language_code, translation, null, null, null);
                            JSONObject json = new JSONObject(result.http_response);
                            String text = json.getString("text");
                            String translation_id = json.getString("id");
                            result = Main.lookup.createExample(Main.transport, example, example_language_code,
                                    example_transliteration, translation_id, item_id, goal_id);
                        } catch (UnsupportedEncodingException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        CreateExampleActivity.create_example_result = new CreateExampleResult(result);

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    myOtherProgressDialog.dismiss();

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

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

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("..");
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*w  w w .  ja  v  a2  s .c  om*/
    AlUApplication.getInstance().logout(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) {

        }
    });
}