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) 

Source Link

Document

Creates and shows a ProgressDialog.

Usage

From source file:net.evecom.androidecssp.activity.WelcomeActivity.java

/**
 * /*from w  w w  .  j a v a 2s  . c o m*/
 */
private void loginsubmit(final String username, final String password) {
    if (islogining) {
        return;
    }

    /**  */
    final Editor editor = passnameSp.edit();
    editor.putString("username", username);
    editor.putString("password", password);
    editor.commit();

    //
    loginProgressDialog = ProgressDialog.show(this, "", "...");
    loginProgressDialog.setCancelable(true);

    //
    new Thread(new Runnable() {
        @Override
        public void run() {
            Log.v("mars", EncryptUtil.getInstance().AESencode(password.trim()));
            try {
                //  
                Message loginMessage = new Message();
                HashMap<String, String> hashMap = new HashMap<String, String>();
                hashMap.put("pwd", password.trim());
                loginResult = connServerForResultPost("jfs/ecssp/mobile/accessCtr/login", hashMap);

                // 
                if (loginResult.length() > 0) {
                    try {
                        BaseModel resultObj = getObjInfo(loginResult);
                        Boolean success = resultObj.get("sys_success");
                        if (null != success && success) {
                            loginMessage.what = MESSAGETYPE_01;// 
                            BaseModel organization = getObjInfo(resultObj.get("organization").toString());
                            BaseModel userdata = getObjInfo(resultObj.get("userdata").toString());
                            BaseModel userInfo = getObjInfo(resultObj.get("userInfo").toString());
                            String code = resultObj.get("code").toString();
                            //--
                            String username = userNmaeEditText.getText().toString();
                            editor.putString("username", userdata.getStr("loginname"));
                            editor.putString("userid", userdata.getStr("id"));
                            editor.putString("usernameCN", userInfo.getStr("name"));
                            editor.putString("sex", userInfo.get("sex") + "");
                            editor.putString("mobile_In_clound", userInfo.get("mobile") + "");
                            editor.putString("orgid", organization.getStr("id"));
                            editor.putString("orgname", organization.getStr("name"));
                            editor.putString("code", code);
                            editor.commit();
                        } else {
                            loginMessage.what = MESSAGETYPE_02;// 
                        }
                    } catch (JSONException e) {
                        loginMessage.what = MESSAGETYPE_02;// 
                    }
                } else {
                    loginMessage.what = MESSAGETYPE_03;//  
                }
                loginRequestHandler.sendMessage(loginMessage);

            } catch (ClientProtocolException e) {
            } catch (IOException e) {
            }
        }
    }).start();
}

From source file:net.evecom.android.log.DailyLogAddActivity.java

/**
 * //from  w  w w .  j a va  2 s. c  o  m
 */
private String submit() {
    /**  */
    if (btEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (sswgButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rzlxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (gzsjButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rznrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years > calendar.get(Calendar.YEAR)) {
        DialogToast("");
        return "";
    } else if (years == calendar.get(Calendar.YEAR)) {
        if (month > calendar.get(Calendar.MONTH) + 1) {
            DialogToast("");
            return "";
        } else if (month == calendar.get(Calendar.MONTH) + 1) {
            if (day > calendar.get(Calendar.DAY_OF_MONTH)) {
                DialogToast("");
                return "";
            }
        }
    }

    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogAddActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogAddActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
    return "1";
}

From source file:be.vbsteven.bmtodesk.RegistrationActivity.java

/**
 * shows progress dialog for login/*from   ww w  .ja va2s  .  c  o  m*/
 */
private void showLoginProgress() {
    if (progress != null) {
        progress.dismiss();
    }

    progress = ProgressDialog.show(this, "Bookmark to Desktop", "Attempting login...");
}

From source file:be.vbsteven.bmtodesk.RegistrationActivity.java

/**
 * shows progress dialog for registration
 *///from   w  w w .  ja v a 2 s .c  o m
private void showRegisterProgress() {
    if (progress != null) {
        progress.dismiss();
    }

    progress = ProgressDialog.show(this, "Bookmark to Desktop", "Creating account...");
}

From source file:eu.operando.proxy.filters.domain.DomainFiltersActivity.java

protected void importExternalFilters(final String importUrl) {
    //String timestap = SimpleDateFormat.getDateTimeInstance().format(new Date().getTime());
    final File tmp = new File(getFilesDir(), "domainfilters_" + System.currentTimeMillis());
    try {/* w  w w.  java2 s .c  o m*/
        new DownloadTask(DomainFiltersActivity.this, new URL(importUrl), tmp, new DownloadTask.Listener() {
            @Override
            public void onCompleted() {
                Toast.makeText(DomainFiltersActivity.this, R.string.msg_downloaded, Toast.LENGTH_LONG).show();

                new AsyncTask<Void, Void, Integer>() {

                    ProgressDialog dialog;

                    @Override
                    protected void onPreExecute() {
                        dialog = ProgressDialog.show(DomainFiltersActivity.this, null,
                                "Parsing downloaded file...");
                        dialog.setCancelable(false);
                    }

                    @Override
                    protected Integer doInBackground(Void... params) {
                        Integer count = 0;
                        BufferedReader br = null;
                        try {
                            br = new BufferedReader(new FileReader(tmp));
                            String line;
                            while ((line = br.readLine()) != null) {
                                int hash = line.indexOf('#');
                                if (hash >= 0)
                                    line = line.substring(0, hash);
                                line = line.trim();

                                if (line.length() > 0) {
                                    String[] words = line.split("\\s+");
                                    if (words.length == 2) {
                                        String blockedDomain = words[1].toLowerCase();
                                        if (blockedDomain.equals("local") || StringUtils.containsAny(
                                                blockedDomain, "localhost", "127.0.0.1", "broadcasthost"))
                                            continue;
                                        DomainFilter domainFilter = new DomainFilter();
                                        domainFilter.setContent(blockedDomain);
                                        domainFilter.setSource(importUrl);
                                        domainFilter.setIsWildcard(false);
                                        db.createDomainFilter(domainFilter);
                                        count++;
                                    } else
                                        Log.i(TAG, "Invalid hosts file line: " + line);
                                }
                            }
                            Log.i(TAG, count + " entries read");
                        } catch (IOException ex) {
                            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                        } finally {
                            if (br != null)
                                try {
                                    br.close();
                                } catch (IOException exex) {
                                    Log.e(TAG, exex.toString() + "\n" + Log.getStackTraceString(exex));
                                }
                        }

                        return count;
                    }

                    @Override
                    protected void onPostExecute(Integer count) {
                        dialog.dismiss();
                        if (count > 0) {
                            updateFiltersList();
                            externalDomainFiltersAdapter.notifyDataSetChanged();
                        }
                    }
                }.execute();
            }

            @Override
            public void onCancelled() {
                if (tmp.exists())
                    tmp.delete();
            }

            @Override
            public void onException(Throwable ex) {
                if (tmp.exists())
                    tmp.delete();

                ex.printStackTrace();
                Toast.makeText(DomainFiltersActivity.this, ex.getMessage(), Toast.LENGTH_LONG).show();
            }
        }).execute();
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
        Toast.makeText(DomainFiltersActivity.this, ex.toString(), Toast.LENGTH_LONG).show();
    }
}

From source file:eu.operando.operandoapp.filters.domain.DomainFiltersActivity.java

protected void importExternalFilters(final String importUrl) {
    final File tmp = new File(getFilesDir(), "domainfilters_" + System.currentTimeMillis());
    try {/*www .java2s  .  c o  m*/
        new DownloadTask(DomainFiltersActivity.this, new URL(importUrl), tmp, new DownloadTask.Listener() {
            @Override
            public void onCompleted() {
                //Toast.makeText(DomainFiltersActivity.this, R.string.msg_downloaded, Toast.LENGTH_LONG).show();

                new AsyncTask<Void, Void, Integer>() {

                    ProgressDialog dialog;

                    @Override
                    protected void onPreExecute() {
                        dialog = ProgressDialog.show(DomainFiltersActivity.this, null,
                                "Parsing downloaded file...");
                        dialog.setCancelable(false);
                    }

                    @Override
                    protected Integer doInBackground(Void... params) {
                        Integer count = 0;
                        BufferedReader br = null;
                        try {
                            br = new BufferedReader(new FileReader(tmp));
                            String line;
                            while ((line = br.readLine()) != null) {
                                int hash = line.indexOf('#');
                                if (hash >= 0)
                                    line = line.substring(0, hash);
                                line = line.trim();
                                try {
                                    String blockedDomain = line;
                                    if (blockedDomain.equals("local") || StringUtils.containsAny(blockedDomain,
                                            "localhost", "127.0.0.1", "broadcasthost"))
                                        continue;
                                    DomainFilter domainFilter = new DomainFilter();
                                    domainFilter.setContent(blockedDomain);
                                    domainFilter.setSource(importUrl);
                                    domainFilter.setIsWildcard(false);
                                    db.createDomainFilter(domainFilter);
                                    count++;
                                } catch (Exception e) {
                                    Log.i(TAG, "Invalid hosts file line: " + line);
                                }
                            }
                            Log.i(TAG, count + " entries read");
                        } catch (IOException ex) {
                            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                        } finally {
                            if (br != null)
                                try {
                                    br.close();
                                } catch (IOException exex) {
                                    Log.e(TAG, exex.toString() + "\n" + Log.getStackTraceString(exex));
                                }
                        }

                        return count;
                    }

                    @Override
                    protected void onPostExecute(Integer count) {
                        dialog.dismiss();
                        if (count > 0) {
                            updateFiltersList();
                            externalDomainFiltersAdapter.notifyDataSetChanged();
                        }
                    }
                }.execute();
            }

            @Override
            public void onCancelled() {
                if (tmp.exists())
                    tmp.delete();
            }

            @Override
            public void onException(Throwable ex) {
                if (tmp.exists())
                    tmp.delete();

                ex.printStackTrace();
                Toast.makeText(DomainFiltersActivity.this, ex.getMessage(), Toast.LENGTH_LONG).show();
            }
        }).execute();
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
        Toast.makeText(DomainFiltersActivity.this, ex.toString(), Toast.LENGTH_LONG).show();
    }
}

From source file:com.pandoroid.PandoroidPlayer.java

/**
 * Description: Shows a waiting/ProgressDialog with the specified message.
 * @param message -The String to show in the ProgressDialog.
 *//*from  ww  w .j a v a2  s.com*/
private void showWaiting(String message) {
    dismissWaiting();
    m_waiting = ProgressDialog.show(this, "", message);
    m_waiting.show();
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private void showDonateDialog() {
    RelativeLayout layout = new RelativeLayout(this);
    int pixel = getPixel(0x30);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(pixel, pixel);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(new ProgressBar(this), params);
    donateDialog = ProgressDialog.show(this, null, null);
    donateDialog.setContentView(layout);
    donateDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, pixel * 0x4);
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java

/**
 * Private helper method to reload data, presenting dialog on failure.
 *//* www  .j  a  v a 2s.  c  o  m*/
private void reloadData() {

    final ProgressDialog progressDialog = ProgressDialog.show(MainActivity.this, "", "Loading...");

    // If successful, notify all that that refreshed.
    Runnable successHandler = new Runnable() {
        @Override
        public void run() {
            synchronized (RHCareerFairLayout.refreshCompaniesNotifier) {
                RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged();
            }
            synchronized (RHCareerFairLayout.refreshMapNotifier) {
                RHCareerFairLayout.refreshMapNotifier.notifyChanged();
            }

            progressDialog.dismiss();
        }
    };

    // If exception or failure, show error message, and ask if they want to retry.
    Runnable exceptionHandler = new Runnable() {
        @Override
        public void run() {

            progressDialog.dismiss();

            runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    DialogFragment df = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                            builder.setTitle("Error");
                            builder.setMessage(
                                    getResources().getString(R.string.loadingStatus_errorDownloadingData));
                            builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {

                                    dismiss();

                                    reloadData();

                                }
                            });
                            builder.setNegativeButton(android.R.string.cancel,
                                    new DialogInterface.OnClickListener() {

                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            dismiss();
                                        }
                                    });
                            return builder.create();
                        }
                    };
                    df.show(getFragmentManager(), null);
                }
            });
        }
    };

    Runnable failHandler = new Runnable() {
        @Override
        public void run() {

            progressDialog.dismiss();

            runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    DialogFragment df = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                            builder.setTitle("Error");
                            builder.setMessage(
                                    getResources().getString(R.string.loadingStatus_errorParsingData));
                            builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {

                                    dismiss();

                                    reloadData();

                                }
                            });
                            builder.setNegativeButton(android.R.string.cancel,
                                    new DialogInterface.OnClickListener() {

                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            dismiss();
                                        }
                                    });
                            return builder.create();
                        }
                    };
                    df.show(getFragmentManager(), null);
                }
            });
        }
    };

    GetAllDataRequest req = new GetAllDataRequest(successHandler, exceptionHandler, failHandler);

    Log.d(RHCareerFairLayout.RH_CFL, "Data not saved or outdated. Downloading.");
    ConnectionManager.enqueueRequest(req);
}

From source file:net.evecom.android.log.DailyLogLookActivity.java

/**
 * /*from   w w w  .  jav  a2 s. c  o m*/
 */
private String submit() {
    /**  */
    if (btEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (gzsjButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rzlxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rznrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years > calendar.get(Calendar.YEAR)) {
        DialogToast("");
        return "";
    } else if (years == calendar.get(Calendar.YEAR)) {
        if (month > calendar.get(Calendar.MONTH) + 1) {
            DialogToast("");
            return "";
        } else if (month == calendar.get(Calendar.MONTH) + 1) {
            if (day > calendar.get(Calendar.DAY_OF_MONTH)) {
                DialogToast("");
                return "";
            }
        }
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogLookActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogLookActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
    return "1";
}