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:org.loon.framework.android.game.LGameAndroid2DActivity.java

/**
 * ??Progress//from  ww  w.  j a  v  a  2 s .c o m
 * 
 * @param title
 * @param message
 * @return
 */
public AlertDialog showAndroidProgress(final String title, final String message) {
    if (alert == null || !alert.isShowing()) {
        Runnable showProgress = new Runnable() {
            public void run() {
                alert = ProgressDialog.show(LGameAndroid2DActivity.this, title, message);
            }
        };
        runOnUiThread(showProgress);
    }
    return alert;
}

From source file:com.kdao.cmpe235_project.UploadActivity.java

private void addUploadedFIleToDB(final String APIurl, String treeId, String fileName) {
    class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
        @Override/*from  ww w .  jav  a 2s.com*/
        protected void onPreExecute() {
            super.onPreExecute();
            progressDialog = ProgressDialog.show(UploadActivity.this, "", Config.SAVE_TO_DB);
        }

        @Override
        protected String doInBackground(String... params) {
            String uploadFileName = params[0];
            String treeId = params[1];
            String APIurl = params[2];
            HttpClient httpClient = new DefaultHttpClient();
            HttpPut httpPut = new HttpPut(Config.BASE_URL + APIurl);
            org.json.JSONObject json = new org.json.JSONObject();
            try {
                json.put("filename", uploadFileName);
                json.put("treeId", treeId);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            try {
                StringEntity se = new StringEntity(json.toString());
                se.setContentEncoding("UTF-8");
                httpPut.setEntity(se);
                try {
                    HttpResponse httpResponse = httpClient.execute(httpPut);
                    InputStream inputStream = httpResponse.getEntity().getContent();
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                    StringBuilder stringBuilder = new StringBuilder();
                    String bufferedStrChunk = null;
                    while ((bufferedStrChunk = bufferedReader.readLine()) != null) {
                        stringBuilder.append(bufferedStrChunk);
                    }
                    return stringBuilder.toString();
                } catch (Exception e) {
                    System.out
                            .println("An Exception given because of UrlEncodedFormEntity " + "argument :" + e);
                    e.printStackTrace();
                }
            } catch (Exception uee) {
                System.out.println("An Exception given because of UrlEncodedFormEntity argument :" + uee);
                uee.printStackTrace();
            }
            return "error";
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            progressDialog.dismiss();
            if (result == "error") { //error case
                Toast.makeText(getApplicationContext(), Config.SERVER_ERR, Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(getApplicationContext(), Config.DB_WRITE_SUCCEED, Toast.LENGTH_LONG).show();
            }
        }
    }
    SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
    sendPostReqAsyncTask.execute(fileName, treeId, APIurl);
}

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

/**
 * /*from www .jav  a 2  s .c  o m*/
 * 
 * @param v
 */
public void daily_log_more_delete(View v) {

    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, "", "...");

            formSubmit1();

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

}

From source file:eu.operando.operandoapp.OperandoProxyStatus.java

private void installCert()
        throws RootCertificateException, GeneralSecurityException, OperatorCreationException, IOException {

    new AsyncTask<Void, Void, Certificate>() {
        Exception error;/*from   w ww. j  av  a 2s  .c  o m*/
        ProgressDialog dialog;

        @Override
        protected void onPreExecute() {
            dialog = ProgressDialog.show(MainActivity.this, null, "Generating SSL certificate...");
            dialog.setCancelable(false);
        }

        @Override
        protected Certificate doInBackground(Void... params) {
            try {
                Certificate cert = BouncyCastleSslEngineSource
                        .initializeKeyStoreStatic(mainContext.getAuthority());
                return cert;
            } catch (Exception e) {
                error = e;
                return null;
            }
        }

        @Override
        protected void onPostExecute(Certificate certificate) {
            dialog.dismiss();
            if (certificate != null) {
                Intent intent = KeyChain.createInstallIntent();
                try {
                    intent.putExtra(KeyChain.EXTRA_CERTIFICATE, certificate.getEncoded());
                } catch (CertificateEncodingException e) {
                    e.printStackTrace();
                }
                intent.putExtra(KeyChain.EXTRA_NAME, mainContext.getAuthority().commonName());
                startActivityForResult(intent, 1);
            } else {
                Toast.makeText(MainActivity.this, "Failed to load certificates, exiting: " + error.getMessage(),
                        Toast.LENGTH_LONG).show();
                finish();
            }
        }
    }.execute();

}

From source file:gr.scify.newsum.ui.ViewActivity.java

@Override
public void onGesturePerformed(GestureOverlayView overlay, final Gesture gesture) {
    // Get the Topic IDs per Category. Null means that all User Sources are
    // accepted/*from w ww.j av a2 s . c  o m*/
    // User Sources is a separator delimited string containing the URL feeds
    final ProgressDialog pd = ProgressDialog.show(ViewActivity.this, "",
            getResources().getText(R.string.wait_msg));
    new Thread(new Runnable() {

        @Override
        public void run() {

            final Spinner spinner = (Spinner) findViewById(R.id.spinner1);
            ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
            for (Prediction prediction : predictions) {
                if (prediction.score > 1.0) {
                    // track the swipe Action per category
                    if (getAnalyticsPref()) {
                        EasyTracker.getTracker().sendEvent(SWIPING_ACTION, "Normal View", Category, 0l);
                    }
                    if (prediction.name.contains("right")) {
                        if (spinner.getSelectedItemPosition() > 0) {
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    spinner.setSelection(spinner.getSelectedItemPosition() - 1, true);

                                };
                            });

                        }

                    } else {

                        if (spinner.getSelectedItemPosition() < saTopicIDsLength - 1) {
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    spinner.setSelection(spinner.getSelectedItemPosition() + 1, true);
                                };
                            });

                        }

                    }
                }
            }

            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    pd.dismiss();

                }
            });
        }
    }).start();
}

From source file:cmu.cconfs.instantMessage.activities.ChatActivity.java

protected void onChatRoomViewCreation() {
    findViewById(R.id.container_to_group).setVisibility(View.GONE);

    final ProgressDialog pd = ProgressDialog.show(this, "", "Joining......");
    EMChatManager.getInstance().joinChatRoom(toChatUsername, new EMValueCallBack<EMChatRoom>() {

        @Override//from   w w w . j  a va2s .  c o m
        public void onSuccess(EMChatRoom value) {
            // TODO Auto-generated method stub
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    pd.dismiss();
                    room = EMChatManager.getInstance().getChatRoom(toChatUsername);
                    if (room != null) {
                        ((TextView) findViewById(R.id.name)).setText(room.getName());
                    } else {
                        ((TextView) findViewById(R.id.name)).setText(toChatUsername);
                    }
                    EMLog.d(TAG, "join room success : " + room.getName());

                    onConversationInit();

                    onListViewCreation();
                }
            });
        }

        @Override
        public void onError(final int error, String errorMsg) {
            // TODO Auto-generated method stub
            EMLog.d(TAG, "join room failure : " + error);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    pd.dismiss();
                }
            });
            finish();
        }
    });
}

From source file:net.evecom.android.PublicOpinionLookActivity.java

/**
 * //  ww w.  j av a2  s.  co m
 */
private String submit() {
    /**  */
    if (ztEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (fsddEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (lylxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years == 0 || month == 0 || day == 0) {
        DialogToast("");
        return "";
    } else if (lyrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (xxnrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (lxdhEditText.getText().toString().trim().length() >= 1) {
        if (isCellphone(lxdhEditText.getText().toString().trim()) == false) {
            DialogToast("");
            return "";
        }
    }
    if ("4".equals(zt1)) {
        DialogToast("");
        return "";
    } else if ("2".equals(zt1)) {
        DialogToast("");
        return "";
    } else if ("3".equals(zt1)) {
        DialogToast("");
        return "";
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(PublicOpinionLookActivity.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(PublicOpinionLookActivity.this, "", "...");

            formSubmit1();

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

From source file:com.kdao.cmpe235_project.UploadActivity.java

private void getAllTrees() {
    class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
        @Override//from  ww  w .j  av  a2  s.c  o  m
        protected void onPreExecute() {
            super.onPreExecute();
            progressDialog = ProgressDialog.show(UploadActivity.this, "", Config.GET_TREES);
        }

        @Override
        protected String doInBackground(String... params) {
            HttpClient httpClient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(GEL_TREES_URL);
            try {
                try {
                    HttpResponse httpResponse = httpClient.execute(httpGet);
                    InputStream inputStream = httpResponse.getEntity().getContent();
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                    StringBuilder stringBuilder = new StringBuilder();
                    String bufferedStrChunk = null;
                    while ((bufferedStrChunk = bufferedReader.readLine()) != null) {
                        stringBuilder.append(bufferedStrChunk);
                    }
                    return stringBuilder.toString();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } catch (Exception uee) {
                System.out.println("An Exception given because of UrlEncodedFormEntity argument :" + uee);
                uee.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            progressDialog.dismiss();
            try {
                JSONArray arrayObj = null;
                JSONParser jsonParser = new JSONParser();
                arrayObj = (JSONArray) jsonParser.parse(result);
                populateTrees(arrayObj);
                createTreeDrodown();
            } catch (Exception ex) {
                System.out.println(ex);
                Toast.makeText(getApplicationContext(), Config.SCAN_ERR, Toast.LENGTH_LONG).show();
            }
        }
    }
    SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
    sendPostReqAsyncTask.execute();
}