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:edu.usf.cutr.opentripplanner.android.tasks.ServerSelector.java

protected void onPreExecute() {
    if ((activity.get() != null) && showDialog) {
        progressDialog.setIndeterminate(true);
        progressDialog.setCancelable(true);
        progressDialog = ProgressDialog.show(activity.get(), "",
                context.getResources().getString(R.string.server_selector_progress), true);
    }/*from w w w  .  j  av  a2  s  .  c  o  m*/

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    isAutoDetectEnabled = prefs.getBoolean(OTPApp.PREFERENCE_KEY_AUTO_DETECT_SERVER, true);
}

From source file:org.ueu.uninet.it.IragarkiaBidali.java

/**
 * Prestatu iragarki berria bidaltzeko formularioa
 *///  ww  w  .ja  va  2s.c  om
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.iragarkia_bidali);

    this.ekintza = this;
    this.izena = (EditText) findViewById(R.id.editTextIzena);
    this.izenburua = (EditText) findViewById(R.id.editTextIzenburua);
    this.eposta = (EditText) findViewById(R.id.editTextEposta);
    this.telefonoa = (EditText) findViewById(R.id.editTextTelefonoa);
    this.mezua = (EditText) findViewById(R.id.editTextDeskribapena);
    this.ohar_legala = (CheckBox) findViewById(R.id.checkBoxlegalAdviceBidali);
    this.errobota = (EditText) findViewById(R.id.editTextErrobota);

    this.atala = (Spinner) findViewById(R.id.spinnerAtala);
    imgView = (ImageView) findViewById(R.id.ImageView);
    upload = (Button) findViewById(R.id.Upload);
    bidali = (Button) findViewById(R.id.iragarkiaBidali);

    // Iragarkiak irudirik badu galeriatik kargatu
    upload.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Aukeratu irudi bat.", Toast.LENGTH_SHORT).show();
            try {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent, "Irudia aukeratu"), PICK_IMAGE);
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    });

    // Formularioa bidali
    bidali.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (balidatu()) {
                dialog = ProgressDialog.show(IragarkiaBidali.this, "Fitxategia igotzen eta mezua bidaltzen",
                        "Itxaron mesedez...", true);
                //Formularioa eta irudia bidali
                new ImageUploadTask().execute();
            }

        }
    });

    ArrayAdapter<String> iragarki_motak = new ArrayAdapter<String>(this, R.layout.spinner_view,
            getResources().getStringArray(R.array.iragarki_kategoriak));
    iragarki_motak.setDropDownViewResource(R.layout.spinner_view_dropdown);
    this.atala.setAdapter(iragarki_motak);

    // Sareko monitora prestatu
    NetworkConnectivity.sharedNetworkConnectivity().configure(this);
    NetworkConnectivity.sharedNetworkConnectivity().addNetworkMonitorListener(this);
    NetworkConnectivity.sharedNetworkConnectivity().startNetworkMonitor();

}

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

/** Called when the activity is first created. */
@Override//from  w  ww  .  ja  v a  2  s  .  co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setTitle(R.string.projects);
    registerForContextMenu(getListView());

    mSifterHelper = new SifterHelper(this);
    boolean haveKeys;
    try {
        haveKeys = mSifterHelper.getKey();
    } catch (Exception e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return;
    }
    if (haveKeys) {
        mDomain = mSifterHelper.mDomain;
        mAccessKey = mSifterHelper.mAccessKey;
    } else {
        mLoginError = mSifterHelper.mLoginError;
        loginKeys();
        return;
    }
    String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
    URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
    if (sifterConnection == null) {
        loginKeys();
        return;
    }
    mDialog = ProgressDialog.show(this, "", "Loading ...", true);
    new DownloadSifterTask().execute(sifterConnection);
}

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

/** Called when the activity is first created. */
@Override/*from   www.ja v  a2 s.com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setTitle(R.string.projects);
    registerForContextMenu(getListView());

    mSifterHelper = new SifterHelper(this);
    boolean haveKeys;
    try {
        haveKeys = mSifterHelper.getKey();
    } catch (Exception e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return;
    }
    if (haveKeys) {
        mDomain = mSifterHelper.mDomain;
        mAccessKey = mSifterHelper.mAccessKey;
    } else {
        mLoginError = mSifterHelper.mLoginError;
        loginKeys(null);
        return;
    }
    String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
    URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
    if (sifterConnection == null) {
        loginKeys(null);
        return;
    }
    mDialog = ProgressDialog.show(this, "", "Loading ...", true);
    new DownloadSifterTask().execute(sifterConnection);
}

From source file:com.kii.world.MainActivity.java

public void addItem(View v) {

    // show a progress dialog to the user
    mProgress = ProgressDialog.show(MainActivity.this, "", "Creating Object...", true);

    // create an incremented title for the object
    // String value = "MyObject " + (++mObjectCount);

    Kii.serverCodeEntry("favoriteSite").execute(KiiServerCodeEntryArgument.newArgument(new JSONObject()),
            new KiiServerCodeEntryCallback() {
                @Override//from   w w  w.j av a  2s.  c om
                public void onExceuted(KiiServerCodeEntry entry, KiiServerCodeEntryArgument argument,
                        KiiServerCodeExecResult execResult, Exception e) {
                    // get a reference to a KiiBucket
                    KiiBucket bucket = KiiUser.getCurrentUser().bucket(BUCKET_NAME);

                    // create a new KiiObject and set a key/value
                    KiiObject obj = bucket.object();
                    if (execResult != null)
                        try {
                            obj.set(OBJECT_KEY, execResult.getReturnedValue().getJSONObject("returnedValue")
                                    .getString("message"));
                        } catch (JSONException e1) {
                            Log.e(TAG, "Error while parsing JSON", e1);
                        }
                    else if (e != null) {
                        obj.set(OBJECT_KEY, e.getMessage());
                    } else
                        obj.set(OBJECT_KEY, "Nothing " + new Random().nextInt());

                    // save the object asynchronously
                    obj.save(new KiiObjectCallBack() {

                        // catch the callback's "done" request
                        public void onSaveCompleted(int token, KiiObject o, Exception e) {

                            // hide our progress UI element
                            mProgress.dismiss();

                            // check for an exception (successful request if
                            // e==null)
                            if (e == null) {

                                // tell the console and the user it was a
                                // success!
                                Toast.makeText(MainActivity.this, "Created object", Toast.LENGTH_SHORT).show();
                                Log.d(TAG, "Created object: " + o.toString());

                                // insert this object into the beginning of
                                // the list adapter
                                MainActivity.this.mListAdapter.insert(o, 0);

                            }

                            // otherwise, something bad happened in the
                            // request
                            else {

                                // tell the console and the user there was a
                                // failure
                                Toast.makeText(MainActivity.this, "Error creating object", Toast.LENGTH_SHORT)
                                        .show();
                                Log.d(TAG, "Error creating object: " + e.getLocalizedMessage());
                            }

                        }
                    });

                }
            });

}

From source file:com.iverson.toby.rhealth.MainActivity.java

public void openMenu() {

    setContentView(R.layout.open);/* w  w  w  . jav a 2 s  .co  m*/

    final EditText restSearch = (EditText) findViewById(R.id.editsearch);
    Button sbtn = (Button) findViewById(R.id.search_button);
    Button lbtn = (Button) findViewById(R.id.location_button);

    // search button
    sbtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String psearch = restSearch.getText().toString();

            setContentView(R.layout.httptestlist);

            //getting rid of special characters
            psearch = psearch.toUpperCase();
            psearch = psearch.replaceAll(" ", "%20");
            psearch = psearch.replaceAll("&", "%26");
            psearch = psearch.replaceAll("!", "%21");
            if (psearch.contains("'")) {
                psearch = psearch.substring(0, psearch.indexOf("'"));
            }

            //creating query
            queryGoogle = new StringBuilder();
            queryGoogle.append("https://maps.googleapis.com/maps/api/place/textsearch/xml?");
            queryGoogle.append("location=44.9756997,-93.2664641&");
            queryGoogle.append("radius=10000&");
            queryGoogle.append("types=" + type + "&");
            queryGoogle.append("query=" + psearch + "&");
            queryGoogle.append("key=" + APIKEY);

            new SearchGooglePlaces().execute(queryGoogle.toString());

        }
    });
    //location button
    lbtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            setContentView(R.layout.httptestlist);

            LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            LocationListener myLocationListener = new MyLocationListener();

            locationResult = new MyLocation.LocationResult() {
                @Override
                public void gotLocation(Location location) {
                    latitude = String.valueOf(location.getLatitude());
                    longitude = String.valueOf(location.getLongitude());
                    progressDialog.dismiss();
                    new GetCurrentLocation().execute(latitude, longitude);
                }
            };

            /*****Enter lat lon for testing*****/
            //latitude = String.valueOf(44.9157615);
            //longitude = String.valueOf(-93.2629201);

            MyRunnable myRun = new MyRunnable();
            myRun.run();

            progressDialog = ProgressDialog.show(MainActivity.this, "Finding your location", "Please wait...",
                    true);
            queryGoogle = new StringBuilder();
            queryGoogle.append("https://maps.googleapis.com/maps/api/place/nearbysearch/xml?");
            queryGoogle.append("location=" + latitude + "," + longitude + "&");
            queryGoogle.append("radius=" + radius + "&");
            queryGoogle.append("types=" + type + "&");
            queryGoogle.append("sensor=true&"); //Must be true if queried from a device with GPS
            queryGoogle.append("key=" + APIKEY);
            new QueryGooglePlaces().execute(queryGoogle.toString());

        }
    });

}

From source file:angeloid.sopiane.vegaphoneinfo.Tab_Racer1_Main.java

private void DialogProgressrestore(boolean close) {
    if (!close) {
        dialog_restore = ProgressDialog.show(getActivity(), "", "Loading..", true);
        Handler mHandler2 = new Handler();
        mHandler2.postDelayed(new Runnable() {
            @Override//  w  w w  . ja  v  a  2  s  .  co  m
            public void run() {
                DialogProgressrestore(true); //  .
                Tab_Racer1_Restore.instantExec_racer_restore(getActivity(),
                        "busybox mount -o rw,remount /system ; ");
                StringBuilder restore = new StringBuilder();
                try {
                    Thread.sleep(2000);
                    restore.append("mount -o rw,remount /system;");
                    restore.append("dd if=/sdcard/imeibackup/imei.img of=/dev/block/mmcblk0p10;");
                    restore.append("busybox mount -o ro,remount /system;");

                    try {
                        Thread.sleep(3000);
                        Tab_Racer1_Restore.instantExec_racer_restore(getActivity(), restore.toString());

                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }, 15000);
    } else {
        dialog_restore.dismiss(); // DialogProgress(true) ,false 
        racer_backup_info.setImageResource(R.drawable.not_apply);
        restore.setEnabled(false);
        restore.setFocusable(false);
    }
}

From source file:com.jakebasile.android.linkshrink.ShortenUrl.java

private void shortenWithBitly(final String longUrl, SharedPreferences prefs) {
    final String username = prefs.getString("bitlyUsername", null);
    final String key = prefs.getString("bitlyKey", null);
    if (username == null || key == null) {
        Toast.makeText(getApplicationContext(), R.string.badbitlyconfig, Toast.LENGTH_LONG).show();
        _shortUrl = null;/*  ww w.  ja va2s  .  co  m*/
        finish();
    } else {
        String display = String.format(getResources().getString(R.string.shortening_message), BITLY);
        final ProgressDialog pd = ProgressDialog.show(ShortenUrl.this,
                getResources().getString(R.string.shortening_title), display, true);
        new Thread() {
            @Override
            public void run() {
                try {
                    String requestUrl = String.format(BITLY_URL, longUrl, username.toLowerCase(), key);
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    HttpClient httpClient = new DefaultHttpClient();
                    HttpGet request = new HttpGet(new URI(requestUrl));
                    HttpResponse response = httpClient.execute(request);
                    if (response.getStatusLine().getStatusCode() == 200) {
                        response.getEntity().writeTo(stream);
                        _shortUrl = new String(stream.toByteArray()).trim();
                    } else {
                        _shortUrl = null;
                    }
                    _handler.sendEmptyMessage(0);
                } catch (IOException ex) {
                    _handler.sendEmptyMessage(1);
                } catch (URISyntaxException ex) {
                    _handler.sendEmptyMessage(2);
                } finally {
                    pd.dismiss();
                }
            }
        }.start();
    }
}

From source file:de.teunito.android.cyclelife.RennradNewsShare.java

/** Called when the activity is first created. */
@Override//  w  ww  .  j a  v a  2 s .  c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.share_rennradnews);

    Bundle data = new Bundle();
    data = getIntent().getExtras();
    trackId = data.getLong("trackId");

    mTrackDb = TrackDb.getInstance(getApplicationContext());

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    APIKey = prefs.getString(Preferences.RENNRADNEWS_API_KEY, "");
    bikeId = prefs.getString(Preferences.RENNRADNEWS_BIKE_ID, "");
    weight = prefs.getString(Preferences.WEIGHT, "");

    tv = (TextView) findViewById(R.id.rnsShareTitle);
    tv.setText("Share your track " + trackId + " to rennrad-news.de community!");
    bt = (Button) findViewById(R.id.rnsShareBtn);
    etTemp = (EditText) findViewById(R.id.rnsShareTemp);
    spSports = (Spinner) findViewById(R.id.rnsShareSports);
    spZone = (Spinner) findViewById(R.id.rnsShareZone);
    spWeather = (Spinner) findViewById(R.id.rnsShareWeather);
    spMood = (Spinner) findViewById(R.id.rnsShareMood);

    sportsAdapter = ArrayAdapter.createFromResource(this, R.array.sports, android.R.layout.simple_spinner_item);
    zoneAdapter = ArrayAdapter.createFromResource(this, R.array.zone, android.R.layout.simple_spinner_item);
    weatherAdapter = ArrayAdapter.createFromResource(this, R.array.weather,
            android.R.layout.simple_spinner_item);
    moodAdapter = ArrayAdapter.createFromResource(this, R.array.mood, android.R.layout.simple_spinner_item);

    sportsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    zoneAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    weatherAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    moodAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spSports.setAdapter(sportsAdapter);
    spZone.setAdapter(zoneAdapter);
    spWeather.setAdapter(weatherAdapter);
    spMood.setAdapter(moodAdapter);

    bt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog = ProgressDialog.show(RennradNewsShare.this, "", "Uploading. Please wait...", true);

            sportsID = String.valueOf(spSports.getSelectedItemPosition() + 1);
            zoneId = String.valueOf(spZone.getSelectedItemPosition() + 1);
            weatherId = String.valueOf(spWeather.getSelectedItemPosition() + 1);
            moodId = String.valueOf(spMood.getSelectedItemPosition() + 1);
            temperature = etTemp.getText().toString();

            // execute is a blocking call, it's best to call this code in a thread separate from the ui's
            uploadThread.start();
        }
    });

    handler = new Handler() {
        public void handleMessage(Message msg) {
            String result = msg.getData().getString("result");
            if (result.contains("success")) {
                Toast.makeText(getApplicationContext(), "Uploaded: " + result, Toast.LENGTH_LONG).show();
                finish();
            } else
                Toast.makeText(getApplicationContext(), "Error: " + result, Toast.LENGTH_LONG).show();
        }
    };

    if (APIKey.length() < 20) {
        AlertDialog.Builder builder = new AlertDialog.Builder(RennradNewsShare.this);
        builder.setMessage("Please enter first the rennrad-news.de API-key in the Settings!")
                .setCancelable(false).setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        RennradNewsShare.this.finish();
                        startActivity(new Intent(RennradNewsShare.this, Preferences.class));
                    }
                });
        builder.create().show();
    }
}

From source file:com.cloudkick.DashboardActivity.java

private void refreshNodes() {
    if (api != null) {
        if (!haveNodes) {
            progress = ProgressDialog.show(this, "", "Loading Nodes...", true);
        }//  ww w.j  a  v  a 2  s  .  co  m
        new NodeUpdater().execute();
    }
}