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.andrewshu.android.reddit.reddits.PickSubredditActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;//w  w  w .  j av  a2s  . c o m
    ProgressDialog pdialog;

    switch (id) {
    // "Please wait"
    case Constants.DIALOG_LOADING_REDDITS_LIST:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Loading your reddits...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.esri.arcgisruntime.generateofflinemapoverrides.MainActivity.java

/**
 * Shows a progress dialog for the given job.
 *
 * @param job to track progress from/* www.ja  v  a 2  s.  c  o m*/
 */
private void showProgressDialog(Job job) {
    // create a progress dialog to show download progress
    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setTitle("Generate Offline Map Job");
    progressDialog.setMessage("Taking map offline...");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgress(0);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> job.cancel());
    progressDialog.show();

    // show the job's progress with the progress dialog
    job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress()));

    // dismiss dialog when job is done
    job.addJobDoneListener(progressDialog::dismiss);
}

From source file:org.telegram.ui.PrivacySettingsActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from ww w .  j  a va 2  s.  c o  m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i == blockedRow) {
                presentFragment(new BlockedUsersActivity());
            } else if (i == sessionsRow) {
                presentFragment(new SessionsActivity());
            } else if (i == deleteAccountRow) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle));
                builder.setItems(
                        new CharSequence[] { LocaleController.formatPluralString("Months", 1),
                                LocaleController.formatPluralString("Months", 3),
                                LocaleController.formatPluralString("Months", 6),
                                LocaleController.formatPluralString("Years", 1) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                int value = 0;
                                if (which == 0) {
                                    value = 30;
                                } else if (which == 1) {
                                    value = 90;
                                } else if (which == 2) {
                                    value = 182;
                                } else if (which == 3) {
                                    value = 365;
                                }
                                final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
                                progressDialog
                                        .setMessage(LocaleController.getString("Loading", R.string.Loading));
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog.setCancelable(false);
                                progressDialog.show();

                                final TLRPC.TL_account_setAccountTTL req = new TLRPC.TL_account_setAccountTTL();
                                req.ttl = new TLRPC.TL_accountDaysTTL();
                                req.ttl.days = value;
                                ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                    @Override
                                    public void run(final TLObject response, final TLRPC.TL_error error) {
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                try {
                                                    progressDialog.dismiss();
                                                } catch (Exception e) {
                                                    FileLog.e("tmessages", e);
                                                }
                                                if (response instanceof TLRPC.TL_boolTrue) {
                                                    ContactsController.getInstance()
                                                            .setDeleteAccountTTL(req.ttl.days);
                                                    listAdapter.notifyDataSetChanged();
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == lastSeenRow) {
                presentFragment(new PrivacyControlActivity(false));
            } else if (i == groupsRow) {
                presentFragment(new PrivacyControlActivity(true));
            } else if (i == passwordRow) {
                presentFragment(new TwoStepVerificationActivity(0));
            } else if (i == passcodeRow) {
                if (UserConfig.passcodeHash.length() > 0) {
                    presentFragment(new PasscodeActivity(2));
                } else {
                    presentFragment(new PasscodeActivity(0));
                }
            } else if (i == secretWebpageRow) {
                if (MessagesController.getInstance().secretWebpagePreview == 1) {
                    MessagesController.getInstance().secretWebpagePreview = 0;
                } else {
                    MessagesController.getInstance().secretWebpagePreview = 1;
                }
                ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE)
                        .edit().putInt("secretWebpage2", MessagesController.getInstance().secretWebpagePreview)
                        .commit();
                if (view instanceof TextCheckCell) {
                    ((TextCheckCell) view)
                            .setChecked(MessagesController.getInstance().secretWebpagePreview == 1);
                }
            }
        }
    });

    return fragmentView;
}

From source file:com.doplgangr.secrecy.views.VaultsListFragment.java

void add() {
    final View dialogView = View.inflate(context, R.layout.new_credentials, null);
    final EditText password = new EditText(context);
    password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    new AlertDialog.Builder(context).setTitle(getString(R.string.Vault__new)).setView(dialogView)
            .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String name = ((EditText) dialogView.findViewById(R.id.newName)).getText().toString();
                    String password = ((EditText) dialogView.findViewById(R.id.stealth_keycode)).getText()
                            .toString();
                    String Confirmpassword = ((EditText) dialogView.findViewById(R.id.confirmPassword))
                            .getText().toString();
                    File directory = new File(Storage.getRoot().getAbsolutePath() + "/" + name);
                    if (!password.equals(Confirmpassword) || "".equals(password))
                        passwordWrong();
                    else if (directory.mkdirs()) {
                        // Create vault to initialize the vault header
                        ProgressDialog progress = new ProgressDialog(context);
                        progress.setIndeterminate(true);
                        progress.setMessage(getString(R.string.Vault__initializing));
                        progress.setCancelable(false);
                        progress.show();
                        createVaultInBackground(name, password, directory, dialog, progress);
                    } else
                        failedtocreate();

                }//from  w  ww .ja v  a 2s  .  co  m
            }).setNegativeButton(getString(R.string.CANCEL), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing.
                }
            }).show();
}

From source file:com.nxt.njitong.ContactlistActivity.java

/**
 * user???/*  ww w. j  av  a2 s. c  o  m*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(context);
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:net.kazzz.NFCTagReader.java

public void onClick(final View v) {
    try {//  w w w  .  ja va2  s . c  om
        final int id = v.getId();

        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setIndeterminate(true);

        AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
            @Override
            protected void onPreExecute() {
                switch (id) {
                case R.id.btn_read:
                    dialog.setMessage("?????...");
                    break;
                case R.id.btn_write:
                    dialog.setMessage("???????...");
                    break;
                case R.id.btn_hitory:
                    dialog.setMessage("????...");
                    break;
                }
                dialog.show();
            }

            @Override
            protected String doInBackground(Void... arg0) {
                switch (id) {
                case R.id.btn_read:
                    try {
                        return mLastFragment.dumpTagData();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case R.id.btn_write:
                    try {
                        Intent intent = new Intent(NFCTagReader.this, NFCTagWriter.class);
                        intent.putExtra("nfcTag", mLastFragment.getNfcTag());
                        startActivity(intent);
                        return "";
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case R.id.btn_hitory:
                    try {
                        if (mLastFragment != null && mLastFragment instanceof NfcFeliCaTagFragment) {
                            NfcFeliCaTagFragment nfcf = (NfcFeliCaTagFragment) mLastFragment;
                            return nfcf.dumpFeliCaHistoryData();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                default:
                    break;
                }
                return "";
            }

            /* (non-Javadoc)
             * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
             */
            @Override
            protected void onPostExecute(String result) {
                dialog.dismiss();
                TextView tv_tag = (TextView) findViewById(R.id.result_tv);
                if (result != null && result.length() > 0)
                    tv_tag.setText(result);
            }
        };

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

From source file:com.chaturs.notepad.NoteEditor.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {

    case SELECT_STUDY_GROUP:

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(" Select Study Group(s)");
        final CharSequence[] charArray = new CharSequence[studyGroupNames.size()];

        for (int i = 0; i < studyGroupNames.size(); i++) {
            charArray[i] = studyGroupNames.get(i).substring(0);
        }/*from www  . j  av a  2s.  c  o m*/

        builder.setMultiChoiceItems(charArray, null, new DialogInterface.OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                if (isChecked) {
                    selectedStudyGroupList.add(studyGroupList.get(which));
                } else {
                    if (!selectedStudyGroupList.isEmpty()) {
                        selectedStudyGroupList.remove(studyGroupList.get(which));
                    }
                }
            }
        });

        builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

                if (selectedStudyGroupList.isEmpty()) {
                    Toast.makeText(getApplicationContext(), "No option selected to send", Toast.LENGTH_SHORT)
                            .show();
                    return;
                }

                if (title == null) {
                    title = "Sample Note";
                }

                DatabaseHandler databaseHandler = DatabaseHandler.getInstance();
                String text = mText.getText().toString();
                if (text == null || text.length() == 0) {
                    text = "empty Note";
                }

                StringBuffer Ids = new StringBuffer();
                for (int i = 0; i < selectedStudyGroupList.size(); i++) {
                    if (Ids.length() > 0) {
                        Ids.append("|");
                    }
                    long id = selectedStudyGroupList.get(i).getServerId();
                    Ids.append(id);
                }
                String user = preferences.getString(KEY_USERNAME, "android");
                note = new Note(Ids.toString(), title, text, user, "");
                selectedStudyGroupList.clear();

                dismissDialog(SELECT_STUDY_GROUP);
                showDialog(PROGRESS_DIALOG_KEY);

                new Thread(new Runnable() {
                    public void run() {
                        response = postData();
                        handler.sendEmptyMessage(0);
                    }
                }).start();
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

            }
        });
        Dialog dialog = builder.create();
        return dialog;

    case PROGRESS_DIALOG_KEY:
        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("sending....");
        progressDialog.setIndeterminate(true);
        return progressDialog;

    }
    return null;
}

From source file:cn.ucai.wechat.ui.SettingsActivity.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(SettingsActivity.this);
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();//from  w  w  w. j  a v  a2s .  c  o m
    WeChatHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    finish();
                    // show login screen
                    MFGT.gotoLoginActivity(SettingsActivity.this);

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(SettingsActivity.this, "unbind devicetokens failed", Toast.LENGTH_SHORT)
                            .show();
                }
            });
        }
    });
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

/** Dialog creation method.
*
* Includes Thread bookkeeping to prevent not leaking Views on orientation changes.
*//*from   ww  w  .j  av a  2  s  .co  m*/
@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case VibeVault.LOADING_DIALOG_ID:

        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage("Loading");
        return dialog;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 * Set up the FAB and ensure internect connectivity exists before
 * getting map ready./*from  w  w w  .  ja v a2  s  .  c  o  m*/
 * @param savedInstanceState Bundle
 */
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    /*
     * If you have a basic license key, uncomment line 102.
     * See directions in the README about how to Configure a Basic License
     */

    //   ArcGISRuntimeEnvironment.setLicense(BuildConfig.LICENSE_KEY);

    // Initially hide the FAB
    mFab = (FloatingActionButton) findViewById(R.id.fab);
    if (mFab != null) {
        mFab.setVisibility(View.INVISIBLE);
        mFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                } else if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                }

            }
        });
    }

    // Check for internet connectivity
    if (!checkForInternetConnectivity()) {
        final ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage(getString(R.string.internet_connectivity));
        progressDialog.setTitle(getString(R.string.wireless_problem));
        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "CANCEL",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        progressDialog.dismiss();
                        finish();
                    }
                });
        progressDialog.show();

    } else {
        // Get data access setup
        mDataManager = DataManager.getDataManagerInstance(getApplicationContext());

        // Set up fragments
        setUpMagFragment();

        setUpBottomSheetFragment();
    }
}