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.example.polytech.orientatewatch.ForecastFragment.java

public void moreResults() {
    FetchWeatherTask weatherTask = new FetchWeatherTask();
    myProgressDialog = ProgressDialog.show(getActivity(), "", "Chargement", true);
    weatherTask.execute(Utility.actualRange);
}

From source file:au.com.wallaceit.reddinator.ViewAllSubredditsActivity.java

private void search(final String query) {
    //System.out.println("Searching: " + query);
    if (dlpopulartask != null) {
        dlpopulartask.cancel(true);/*from ww w  . j  a v  a2s . c  o  m*/
    }
    // use a thread for searching
    final ProgressDialog sdialog = ProgressDialog.show(ViewAllSubredditsActivity.this, "", ("Searching..."),
            true);
    Thread t = new Thread() {
        public void run() {
            // get all popular subreddits
            try {
                srjson = global.mRedditData.getSubredditSearch(query);
            } catch (RedditData.RedditApiException e) {
                e.printStackTrace();
            }
            // put into arraylist
            sreddits = new ArrayList<>();
            int i = 0;
            while (i < srjson.length()) {
                try {
                    sreddits.add(srjson.getJSONObject(i).getJSONObject("data").getString("display_name"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                i++;
            }
            //System.out.println("search complete");
            runOnUiThread(new Runnable() {
                public void run() {
                    setListAdaptor();
                    if (sreddits.size() == 0) {
                        // set no result text in no items view
                        emptyview.setText("No subreddits found");
                    }
                    sdialog.dismiss();
                }
            });

        }
    };
    t.start();
}

From source file:com.z.stproperty.PropertyDetail.java

@SuppressWarnings("unchecked")
@Override//from   w  w  w . j a v a2  s. c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pdetail);
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
    try {
        pripertyDetail = (HashMap<String, String>) getIntent().getExtras().get("propertyDetail");
        title = pripertyDetail.get("title");
        propertyId = pripertyDetail.get("pID");
        SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        mPrefs.edit().putString("propertyId", propertyId).commit();
        dialog = ProgressDialog.show(PropertyDetail.this, "", "Loading. Please wait...", true);

        checkUpdate();
        ((Button) findViewById(R.id.ShareIcon)).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), ShareContent.class);
                startActivityForResult(intent, Constants.REQUEST_SHARE);
            }
        });
        trimCache();
    } catch (Exception e) {
        Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e);
    }
}

From source file:or.tango.android.activity.PicActivity.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.right_btn) {
        if (uploadFile.exists()) {//
            getRightBtn().setEnabled(false);

            uploadingTipDialog = ProgressDialog.show(PicActivity.this, "", "...", true);
            uploadingTipDialog.show();/*  w w w. j av a2  s . c om*/
            singleThread.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        PictureUpload.upload(uploadFile, uploadProgressHandler, singleThread);
                    } catch (Exception e) {
                        e.printStackTrace();//
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                uploadingTipDialog.dismiss();
                                getRightBtn().setEnabled(true);
                                showToastMsg("ip?");
                            }
                        });
                    }
                }
            });
        } else {
            showToastMsg("?");
        }
    }
}

From source file:at.tugraz.kmi.energy2live.remote.E2LNetworkConnection.java

private void postData(final ACTION a, final String url, final List<NameValuePair> nameValuePairs) {
    String message = null;//w  w w  .j  a  v a2s  . co m
    switch (a) {
    case LOGIN:
        message = mContext.getString(R.string.msg_remote_post_login);
        break;
    case REGISTER:
        message = mContext.getString(R.string.msg_remote_post_register);
        break;
    case ACTIVITY:
        message = mContext.getString(R.string.msg_remote_post_activity);
        break;
    }
    final ProgressDialog progressDialog = ProgressDialog.show(mContext, "", message, true);
    Thread thread = new Thread() {
        @Override
        public void run() {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 4000);
            HttpClient httpclient = new DefaultHttpClient(httpParameters);
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = null;

            try {
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                response = httpclient.execute(httppost);
            } catch (ClientProtocolException e) {
                Log.e("E2L", "Cannot post data\n", e);
            } catch (IOException e) {
                Log.e("E2L", "Cannot post data\n", e);
            } finally {
                progressDialog.dismiss();
                postDataDone(a, response);
            }
        }
    };
    thread.start();
}

From source file:com.progym.custom.fragments.FoodProgressDailyPieFragment.java

public void setPieData(final Date dateToSetUp, final boolean isLeftIn) {

    final ProgressDialog ringProgressDialog = ProgressDialog.show(getActivity(),
            getResources().getString(R.string.please_wait), getResources().getString(R.string.populating_data),
            true);//from  ww  w .  ja  va  2s .  c om
    ringProgressDialog.setCancelable(true);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                DATE = dateToSetUp;
                totalProtein = 0;
                totalFat = 0;
                totalCarbs = 0;
                totalCallories = 0;
                final String date = Utils.formatDate(DATE, DataBaseUtils.DATE_PATTERN_YYYY_MM_DD);
                List<Ingridient> ingridients = DataBaseUtils.getProductsOnPlate(date);
                if (null != ingridients) {

                    for (Ingridient ingridient : ingridients) {
                        totalProtein += ingridient.protein;
                        totalFat += ingridient.fat;
                        totalCarbs += ingridient.carbohydrates;
                        totalCallories += ingridient.kkal;
                        Utils.log(String.format(
                                "==========prot:%s == carbs:%s == name:%s == fat %s============",
                                ingridient.protein, ingridient.carbohydrates, ingridient.name, ingridient.fat));
                    }

                    getActivity().runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            twCurrentDay.setText(Utils.formatDate(dateToSetUp, "EEEE") + " - "
                                    + Utils.formatDate(dateToSetUp, "dd") + " of "
                                    + Utils.formatDate(dateToSetUp, "MMM"));

                        }
                    });

                    setUpPieChart(totalProtein, totalFat, totalCarbs, isLeftIn);

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            ringProgressDialog.dismiss();
        }
    }).start();
}

From source file:fyp.project.S_File.S_Activities.java

public void showRecord(Integer val) {
    mProgressDialog = ProgressDialog.show(activity, "", "Downloading...", true);
    mProgressDialog.setCancelable(false);
    //  tvOutput.setText(val);
}

From source file:eu.thecoder4.gpl.pleftdroid.EventDetailActivity.java

/** Called when the activity is first created. */
@Override//from   w w  w  . j a  v a 2s. com
public void onCreate(Bundle savedInstanceState) {
    if (AppPreferences.INSTANCE.getUsePleftTheme()) {
        setTheme(R.style.Theme_Pleft);
    }

    super.onCreate(savedInstanceState);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    initOK = true;

    Bundle extras = getIntent().getExtras();
    aid = extras.getInt(AID);
    theurl = extras.getString(THEURL);

    if (extras.getString(FROMHL) != null) {
        back2main = true;
    }

    setContentView(R.layout.event_detail);

    // Initialize Adapters and ListViews
    lvd = (ListView) findViewById(R.id.pdateslv);
    adates = new ArrayList<ADate>();
    adateadapter = new ADateAdapter(this, R.layout.detail_invitee_rowc, adates);
    voteadateadapter = new VoteADateAdapter(this, R.layout.detail_voting_rowdbc, adates);
    lvd.setAdapter(voteadateadapter);

    lvp = (ListView) findViewById(R.id.peoplelv);
    apeople = new ArrayList<APerson>();
    apeopleadapter = new APersonAdapter(this, R.layout.detail_ppl_row, apeople);
    lvp.setAdapter(apeopleadapter);

    lvp.setOnItemClickListener(this);

    lvp.setSelection(curppos);
    lvp.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    initEvent = new Runnable() {
        @Override
        public void run() {
            initializeEventDetail(theurl);
        }
    };
    Thread thread = new Thread(null, initEvent, "Initializer");
    thread.start();

    mProgressDialog = ProgressDialog.show(this, this.getString(R.string.dialog_title_pleasewaitdetails),
            this.getString(R.string.dialog_msg_pleasewaitdetails), true);

    //Toast.makeText(this, ev.toString(), Toast.LENGTH_LONG).show();

}

From source file:com.sakisds.icymonitor.activities.AddServerActivity.java

@SuppressWarnings("ConstantConditions")
@Override//from w w w .java  2  s.  c  o m
public void onClick(View view) {
    // Check if name is empty
    if (mEditText_name.getText().toString().equals("")) {
        mEditText_name.setError(getResources().getString(R.string.error_empty_name));
        mEditText_name.requestFocus();
    } else if (mEditText_port.getText().toString().equals("")) {
        mEditText_port.setError(getString(R.string.error_empty_port));
        mEditText_port.requestFocus();
    } else if (mEditText_address.getText().toString().equals("")) {
        mEditText_address.setError(getString(R.string.error_empty_address));
        mEditText_address.requestFocus();
    } else { // If it's not
        // Validate URL
        String url = mEditText_address.getText().toString();
        // Add http:// if needed
        if (!url.substring(0, 7).equals("http://")) {
            url = "http://" + url;
        }
        url += ":" + mEditText_port.getText().toString();
        url = url.replace(" ", "");
        if (!URLUtil.isValidUrl(url)) { // If invalid
            mEditText_address.setError(getResources().getString(R.string.error_invalid_address));
            mEditText_address.requestFocus();
        } else { // If URL is valid
            // Create a dialog
            final ProgressDialog progress = ProgressDialog.show(this, "",
                    getResources().getString(R.string.connecting), false);

            // Store actual URL
            final String actualURL = url;

            // Check if auth is enabled
            mClient.get(url + "/authEnabled", null, new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(JSONObject response) {
                    try {
                        if (response.getBoolean("AuthEnabled")) {
                            progress.setMessage(getString(R.string.check_computer));
                        }
                    } catch (JSONException ignored) {
                    } // If there are issues they will be dealt with later
                }
            });

            // Register
            RequestParams params = new RequestParams();
            params.put("name", android.os.Build.MODEL);
            params.put("id", String.valueOf(mSettings.getLong("device_id", -2)));
            params.put("gcm", mGCMID);
            params.put("ask", "true");

            JsonHttpResponseHandler handler = new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(JSONObject response) {
                    try {
                        // Get string
                        String version = response.getString("Version");

                        // Parse response
                        if (version.equals(ConnectionActivity.ACCEPTED_SERVER_VERSION)) {
                            String regStatus = response.getString("Status");

                            if (regStatus.equals("ALLOWED")) {
                                saveServer(actualURL);
                                progress.dismiss();
                                mResponseReady = true;
                            } else if (regStatus.equals("DENIED")) {
                                mEditText_address.setError(getResources().getString(R.string.error_rejected));
                                mEditText_address.requestFocus();
                                progress.dismiss();
                                mResponseReady = true;
                            }
                        } else {
                            mEditText_address
                                    .setError(getResources().getString(R.string.error_outdated_server));
                            mEditText_address.requestFocus();
                            progress.dismiss();
                            mResponseReady = true;
                        }
                    } catch (JSONException e) {
                        mEditText_address.setError(getResources().getString(R.string.error_invalid_response));
                        mEditText_address.requestFocus();
                        progress.dismiss();
                        mResponseReady = true;
                    }
                }

                @Override
                public void onFailure(Throwable e, JSONObject errorResponse) {
                    progress.dismiss();
                    mEditText_address.setError(getResources().getString(R.string.error_could_not_reach_host));
                    mEditText_address.requestFocus();
                    mResponseReady = true;
                }
            };

            mClient.get(url + "/register", params, handler);
            params.remove("ask");

            WaitingTask task = new WaitingTask();

            task.mUrl = url + "/register";
            task.mParams = params;
            task.mHandler = handler;

            task.execute();
        }
    }
}

From source file:com.loadsensing.app.LoginActivity.java

public void onClick(View v) {

    // this gets the resources in the xml file
    // and assigns it to a local variable of type EditText
    EditText usernameEditText = (EditText) findViewById(R.id.txt_username);
    EditText passwordEditText = (EditText) findViewById(R.id.txt_password);

    // the getText() gets the current value of the text box
    // the toString() converts the value to String data type
    // then assigns it to a variable of type String
    String sUserName = usernameEditText.getText().toString();
    String sPassword = passwordEditText.getText().toString();

    // Definimos constructor de alerta para los avisos posteriores
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog = new AlertDialog.Builder(this).create();

    // call the backend using Get parameters
    String address = SERVER_HOST + "?user=" + sUserName + "&pass=" + sPassword + "";

    if (sUserName.equals("") || sPassword.equals("")) {
        // error alert
        alertDialog.setTitle(getResources().getString(R.string.error));
        alertDialog.setMessage(getResources().getString(R.string.empty_fields));
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }//www.  ja  va 2  s.  co  m
        });
        alertDialog.show();
    } else if (!checkConnection(this.getApplicationContext())) {
        alertDialog.setTitle(getResources().getString(R.string.error));
        alertDialog.setMessage(getResources().getString(R.string.error_no_internet));
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        alertDialog.show();
    } else {
        try {
            showBusyCursor(true);
            progress = ProgressDialog.show(this, getResources().getString(R.string.pantalla_espera_title),
                    getResources().getString(R.string.iniciando_sesion), true);

            Log.d(DEB_TAG, "Requesting to " + address);

            JSONObject json = JsonClient.connectJSONObject(address);

            CheckBox rememberUserPassword = (CheckBox) findViewById(R.id.remember_user_password);
            if (rememberUserPassword.isChecked()) {
                setSharedPreference("login", sUserName);
                setSharedPreference("password", sPassword);
            } else {
                setSharedPreference("login", "");
                setSharedPreference("password", "");
            }

            if (json.getString("session") != "0") {
                progress.dismiss();
                // Guardamos la session en SharedPreferences para utilizarla
                // posteriormente
                setSharedPreference("session", json.getString("session"));
                // Sessin correcta. StartActivity de la home
                Intent intent = new Intent();
                intent.setClass(this.getApplicationContext(), HomeActivity.class);
                startActivity(intent);

            } else {
                progress.dismiss();
                alertDialog.setTitle(getResources().getString(R.string.error));
                alertDialog.setMessage(getResources().getString(R.string.error_login));
                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
                alertDialog.show();
            }

        } catch (JSONException e) {
            progress.dismiss();
            Log.d(DEB_TAG, "Error parsing data " + e.toString());
        }

        showBusyCursor(false);
    }
}