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 static ProgressDialog show(Context context, CharSequence title, CharSequence message,
        boolean indeterminate) 

Source Link

Document

Creates and shows a ProgressDialog.

Usage

From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java

/**
 * ProgressDialog should be cancelable (useful for slow connections).
 * @param message (loading by default)/*  w w  w  .j a  va  2 s.  c  o  m*/
 */
public void showProgressDialog(String s) {
    if (s == null) {
        s = getString(R.string.loading);
    }
    progressDialog = ProgressDialog.show(this, "", s, true);
    progressDialog.setCancelable(true);

    dialogStyle(progressDialog);
}

From source file:com.phonegap.DroidGap.java

/**
 * Load the url into the webview./*  w  w  w.  j a  va 2  s  .  c  o m*/
 * 
 * @param url
 */
public void loadUrl(final String url) {
    System.out.println("loadUrl(" + url + ")");
    this.url = url;
    int i = url.lastIndexOf('/');
    if (i > 0) {
        this.baseUrl = url.substring(0, i);
    } else {
        this.baseUrl = this.url;
    }
    System.out.println("url=" + url + " baseUrl=" + baseUrl);

    mydialog = ProgressDialog.show(this, "su...", "Loading", true);

    // Load URL on UI thread
    final DroidGap me = this;
    this.runOnUiThread(new Runnable() {
        public void run() {

            // Handle activity parameters
            me.handleActivityParameters();

            // Initialize callback server
            me.callbackServer.init(url);

            // If loadingDialog, then show the App loading dialog
            String loading = me.getStringProperty("loadingDialog", null);
            if (loading != null) {

                String title = "";
                String message = "Loading Application...";

                if (loading.length() > 0) {
                    int comma = loading.indexOf(',');
                    if (comma > 0) {
                        title = loading.substring(0, comma);
                        message = loading.substring(comma + 1);
                    } else {
                        title = "";
                        message = loading;
                    }
                }
                JSONArray parm = new JSONArray();
                parm.put(title);
                parm.put(message);
                me.pluginManager.exec("Notification", "activityStart", null, parm.toString(), false);
            }

            // Create a timeout timer for loadUrl
            final int currentLoadUrlTimeout = me.loadUrlTimeout;
            Runnable runnable = new Runnable() {
                public void run() {
                    try {
                        synchronized (this) {
                            wait(me.loadUrlTimeoutValue);
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    // If timeout, then stop loading and handle error
                    if (me.loadUrlTimeout == currentLoadUrlTimeout) {
                        me.appView.stopLoading();
                        me.webViewClient.onReceivedError(me.appView, -6,
                                "The connection to the server was unsuccessful.", url);
                    }
                }
            };
            Thread thread = new Thread(runnable);
            thread.start();
            me.appView.loadUrl(url);
        }
    });
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

static private void install() {
    progDialog = ProgressDialog.show(activity, "Please Wait", "Installing Files...", true);
    a = new Installer();
    a.execute();//from www  . j  a  va 2 s .c o  m
}

From source file:com.google.plus.wigwamnow.social.FacebookProvider.java

/**
 * Display a String in a progress dialog.
 * //w  w  w . java 2  s. co m
 * @param message the String to display
 */
private void showProgressDialog(String message, Activity activity) {
    mProgressDialog = ProgressDialog.show(activity, "", message, true);
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void getOPSIDepotConfig(final String depot) {
    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            String.format(getString(R.string.pd_getdepotconfigfor), depot), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/*from ww w.j  a  v a2  s. c om*/
            if (GlobalVar.getInstance().getError().equals("null")) {
                Intent i = new Intent(Main.this, ShowOpsiHostParamsListView.class);
                Bundle b = new Bundle();
                b.putString("hostparams", opsiresult.toString());
                b.putString("pc", choosendepot);
                b.putString("opsitype", "OpsiConfigserver");
                i.putExtras(b);
                startActivityForResult(i, SHOW_OPSI_DEPOT_REQUEST);
            } else {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }

        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray JSONparams = new JSONArray();
            JSONparams.put(depot);
            opsiresult = new JSONObject();
            opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                    serverport, "getDepot_hash", JSONparams, serverusername, serverpasswd);
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}

From source file:com.BreakingBytes.SifterReader.SifterReader.java

/** Determine activity by result code. */
@Override//from   ww w  .  jav  a  2 s. c  o  m
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (intent == null)
        return;

    Bundle extras = intent.getExtras();
    if (extras == null)
        return;

    switch (requestCode) {
    case ACTIVITY_LOGIN:
        mDomain = extras.getString(DOMAIN);
        mAccessKey = extras.getString(ACCESS_KEY);
        mSifterHelper = new SifterHelper(this, mAccessKey);
        if (mDomain.length() == 0 || mAccessKey.length() == 0) {
            try {
                mLoginError = mSifterHelper.onMissingToken();
                loginKeys();
            } catch (Exception e) {
                e.printStackTrace();
                mSifterHelper.onException(e.toString());
                return;
            }
            break;
        } // if keys are empty return to LoginActivity
        String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
        URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
        if (sifterConnection == null) {
            loginKeys();
            break;
        } // if URL misformatted return to LoginActivity
        mDialog = ProgressDialog.show(this, "", "Loading ...", true);
        new DownloadSifterTask().execute(sifterConnection);
        break;
    }
}

From source file:com.qbcps.sifterclient.SifterReader.java

/** Determine activity by result code. */
@Override/*  ww  w . j  a v  a 2s.  c  o  m*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (intent == null)
        return;

    Bundle extras = intent.getExtras();
    if (extras == null)
        return;

    switch (requestCode) {
    case ACTIVITY_LOGIN:
        mDomain = extras.getString(DOMAIN);
        mAccessKey = extras.getString(ACCESS_KEY);
        mSifterHelper = new SifterHelper(this, mAccessKey);
        if (mDomain.length() == 0 || mAccessKey.length() == 0) {
            try {
                mLoginError = mSifterHelper.onMissingToken();
                loginKeys(null);
            } catch (Exception e) {
                e.printStackTrace();
                mSifterHelper.onException(e.toString());
                return;
            }
            break;
        } // if keys are empty return to LoginActivity
        String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
        URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
        if (sifterConnection == null) {
            loginKeys(null);
            break;
        } // if URL misformatted return to LoginActivity
        mDialog = ProgressDialog.show(this, "", "Loading ...", true);
        new DownloadSifterTask().execute(sifterConnection);
        break;
    }
}

From source file:com.doplgangr.secrecy.settings.SettingsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE_SET_VAULT_ROOT:
        // If the file selection was successful
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                // Get the URI of the selected file
                final Uri uri = data.getData();
                try {
                    // Get the file path from the URI
                    final String path = FileUtils.getPath(context, uri);
                    Storage.setRoot(path);
                    Preference vault_root = findPreference(Config.VAULT_ROOT);
                    vault_root.setSummary(Storage.getRoot().getAbsolutePath());
                } catch (Exception e) {
                    Log.e("SettingsFragment", "File select error", e);
                }//  w w w. j a v a 2s. c om
            }
        }
        break;
    case REQUEST_CODE_MOVE_VAULT:
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                // Get the URI of the selected file
                final Uri uri = data.getData();
                try {
                    // Get the file path from the URI
                    final String path = FileUtils.getPath(context, uri);
                    if (path.contains(Storage.getRoot().getAbsolutePath())) {
                        Util.alert(context, getString(R.string.Settings__cannot_move_vault),
                                getString(R.string.Settings__cannot_move_vault_message),
                                Util.emptyClickListener, null);
                        break;
                    }
                    Util.alert(context, getString(R.string.Settings__move_vault),
                            String.format(getString(R.string.move_message), Storage.getRoot().getAbsolutePath(),
                                    path),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    String[] children = new File(path).list();
                                    if (children.length == 0) {
                                        final ProgressDialog progressDialog = ProgressDialog.show(context, null,
                                                context.getString(R.string.Settings__moving_vault), true);
                                        new Thread(new Runnable() {
                                            public void run() {
                                                moveStorageRoot(path, progressDialog);
                                            }
                                        }).start();
                                    } else
                                        Util.alert(context, getString(R.string.Error__files_exist),
                                                getString(R.string.Error__files_exist_message),
                                                Util.emptyClickListener, null);
                                }
                            }, Util.emptyClickListener);
                } catch (Exception e) {
                    Log.e("SettingsFragment", "File select error", e);
                }
            }
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.MultiContactsPlugin.java

/**
 * Prepares page UI or starts ContactDetailsActivity if there is only one
 * person.//  ww  w  .j  a  v  a 2 s . c o m
 *
 * @return true if there is only one person, false othrwise
 */
private boolean prepareUI() {
    if (persons.size() == 1) {
        try {
            Intent details = new Intent(this, ContactDetailsActivity.class);
            details.putExtra("Widget", widget);
            details.putExtra("person", persons.get(0));
            details.putExtra("single", true);
            details.putExtra("isdark", Statics.isLight);
            details.putExtra("hasschema", PluginData.getInstance().isHasColorSchema());
            details.putExtra("homebtn", true);
            finish();
            startActivity(details);
            overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_scale);
            return true;
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
            e.printStackTrace();
        }
    }
    setContentView(R.layout.grouped_contacts_main);

    setTopBarTitle(TextUtils.isEmpty(widget.getTitle()) ? "" : widget.getTitle());
    setTopBarLeftButtonTextAndColor(getResources().getString(R.string.common_home_upper),
            getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    finish();
                    overridePendingTransition(R.anim.activity_open_scale, R.anim.activity_close_translate);
                }
            });
    setTopBarTitleColor(ContextCompat.getColor(this, android.R.color.black));

    clearSearch = (ImageView) findViewById(R.id.grouped_contacts_delete_search);
    separator = findViewById(R.id.gc_head_separator);
    backSeparator = findViewById(R.id.gc_back_separator);

    clearSearch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            searchContactsEditText.setText("");
            noFoundText.setVisibility(View.GONE);
        }
    });
    clearSearch.setVisibility(View.INVISIBLE);

    resources = getResources();
    inputSearchLayout = (RelativeLayout) findViewById(R.id.grouped_contacts_input_search_layout);
    multicontactsSearchLayout = (LinearLayout) findViewById(R.id.grouped_contacts_search_layout);
    moveLayout = (LinearLayout) findViewById(R.id.grouped_contacts_move_layout);

    backSeparator.setBackgroundColor(Statics.color1);
    if (Statics.isLight)
        separator.setBackgroundColor(Color.parseColor("#4d000000"));
    else
        separator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));

    ViewUtils.setBackgroundLikeHeader(multicontactsSearchLayout, Statics.color1);
    multicontactsSearchLayout.setVisibility(View.GONE);
    searchContactsEditText = (EditText) findViewById(R.id.grouped_contacts_input_search);
    if (getPackageName().endsWith("p638839")) {
        searchContactsEditText.setHint("Search by Location");
    }
    searchContactsEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {

        }
    });
    searchContactsEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (charSequence.length() == 0) {
                List<String> cats = PluginData.getInstance().getCategories();

                clearSearch.setVisibility(View.INVISIBLE);
                noFoundText.setVisibility(View.GONE);

                if (cats.size() > 1) {
                    GroupContactsAdapter adapter = new GroupContactsAdapter(MultiContactsPlugin.this, cats,
                            Statics.isLight);

                    listView.setAdapter(adapter);

                    listView.setOnItemClickListener(new OnItemClickListener() {
                        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                            showCategoryPersons(arg2);
                        }
                    });
                } else {
                    multicontactsSearchLayout.setVisibility(View.GONE);
                    neededPersons = new ArrayList<>();
                    neededPersons.addAll(persons);
                    MultiContactsAdapter adapter = new MultiContactsAdapter(MultiContactsPlugin.this,
                            neededPersons, Statics.isLight);

                    listView.setAdapter(adapter);
                    listView.setOnItemClickListener(new OnItemClickListener() {
                        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                            showPersonDetails(arg2);
                        }
                    });
                    listView.setVisibility(View.VISIBLE);
                }

                listView.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.VISIBLE);
                if (!isLeftPostition) {
                    moveToLeft();
                    isLeftPostition = true;
                }

                List<Person> persons = PluginData.getInstance().searchByString(charSequence.toString());
                neededPersons = new ArrayList<>();
                neededPersons.addAll(persons);
                if (neededPersons.size() == 0) {
                    noFoundText.setVisibility(View.VISIBLE);
                    listView.setVisibility(View.GONE);
                } else {
                    MultiContactsAdapter adapter = new MultiContactsAdapter(MultiContactsPlugin.this,
                            neededPersons, Statics.isLight);

                    listView.setAdapter(adapter);

                    listView.setOnItemClickListener(new OnItemClickListener() {
                        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                            showPersonDetails(arg2);
                        }
                    });

                    listView.setDivider(null);
                    listView.setVisibility(View.VISIBLE);
                    noFoundText.setVisibility(View.GONE);
                }
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    searchContactsEditText.clearFocus();
    cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

    root = (LinearLayout) findViewById(R.id.grouped_contacts_main_root);
    listView = (ListView) findViewById(R.id.grouped_contacts_list);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setDivider(null);

    noFoundText = (TextView) findViewById(R.id.no_found_text);
    noFoundText.setTextColor(Statics.color3);

    progressDialog = ProgressDialog.show(this, null, getString(R.string.common_loading_upper), true);
    progressDialog.setCancelable(true);
    progressDialog.setOnCancelListener(new OnCancelListener() {
        public void onCancel(DialogInterface di) {
            handler.sendEmptyMessage(LOADING_ABORTED);
        }
    });

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    return false;
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void getOPSIDepots() {

    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            getString(R.string.pd_getdepots), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/*from w  ww . j  a v  a 2  s  .  c o m*/
            if (GlobalVar.getInstance().getError().equals("null")) {
                if (doit.equals("true")) {

                    JSONArray result = new JSONArray();
                    try {
                        result = opsiresult.getJSONArray("result");
                        depots = new String[result.length()];
                        for (int i = 0; i < result.length(); i++) {
                            depots[i] = result.getString(i);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
                    builder.setTitle(getString(R.string.gen_choose));
                    builder.setSingleChoiceItems(depots, -1, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int item) {
                            dialog.dismiss();
                            String depot = depots[item];
                            choosendepot = depot;

                            getOPSIDepotConfig(depot);

                        }
                    });
                    AlertDialog alert = builder.create();
                    alert.show();

                } else if (doit.equals("serverdown")) {
                    Toast.makeText(Main.this, String.format(getString(R.string.to_servernotrechable), serverip),
                            // serverip + " "
                            // + getString(R.string.to_servernotrechable),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }

        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray JSONparams = new JSONArray();
            if (Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) {
                opsiresult = new JSONObject();
                opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                        serverport, "getDepotIds_list", JSONparams, serverusername, serverpasswd);
                doit = "true";
            } else {
                doit = "serverdown";
                //
            }
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}