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:cm.aptoide.pt.RemoteInTab.java

public boolean updateRepos() {
    pd = ProgressDialog.show(this, "Please Wait", "Updating applications list...", true);
    pd.setIcon(android.R.drawable.ic_dialog_info);

    //Check for connection first!
    ConnectivityManager netstate = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    if (netstate.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED
            || netstate.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED) {
        db.removeAll();// w w  w.  jav a 2  s.  c  om
        myTabHost.setCurrentTabByTag("inst");
        new Thread() {
            public void run() {
                try {
                    Vector<ServerNode> serv = db.getServers();
                    for (ServerNode node : serv) {
                        if (node.inuse) {
                            downloadList(node.uri);
                            xmlPass(node.uri, true);
                        }
                    }
                } catch (Exception e) {
                }
                update_handler.sendEmptyMessage(0);
            }
        }.start();
        return true;
    } else {
        pd.dismiss();
        Toast.makeText(RemoteInTab.this, "Could not connect to the network.", Toast.LENGTH_LONG).show();
        return false;
    }
}

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

void performDelete(int position) {

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

    // get the object to delete based on the index of the row that was
    // tapped/*w  w  w .  j  ava  2 s  .c  om*/
    final KiiObject o = MainActivity.this.mListAdapter.getItem(position);

    // delete the object asynchronously
    o.delete(new KiiObjectCallBack() {

        // catch the callback's "done" request
        public void onDeleteCompleted(int token, 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, "Deleted object", Toast.LENGTH_SHORT).show();
                Log.d(TAG, "Deleted object: " + o.toString());

                // remove the object from the list adapter
                MainActivity.this.mListAdapter.remove(o);

            }

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

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

        }
    });
}

From source file:com.acceleratedio.pac_n_zoom.AnimActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anm);
    orgnlImageView = (ImageView) findViewById(R.id.imageView);
    orgnlImageView.setMaxHeight(800);/*from   w w w  .  jav  a2  s. c om*/
    orgnlImageView.setMaxWidth(600);
    crt_ctx = this;

    BitmapFactory.Options bmp_opt = new BitmapFactory.Options();
    bmp_opt.inTargetDensity = DisplayMetrics.DENSITY_DEFAULT;

    // - Now we need to set the GUI ImageView data with data read from the picked file.
    DcodRszdBmpFil dcodRszdBmpFil = new DcodRszdBmpFil();
    Bitmap bmp = dcodRszdBmpFil.DcodRszdBmpFil(SelectImageActivity.orgFil, bmp_opt);

    // Now we need to set the GUI ImageView data with the orginal file selection.
    orgnlImageView.setImageBitmap(bmp);
    orgnl_iv_wdth = bmp.getWidth();
    orgnl_iv_hght = bmp.getHeight();
    final RelativeLayout rel_anm_lo = (RelativeLayout) findViewById(R.id.activity_anm_lo);
    scaleGestureDetector = new ScaleGestureDetector(this, new simpleOnScaleGestureListener());

    orgnlImageView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (event.getPointerCount() > 1 || flgInScale) {

                scaleGestureDetector.onTouchEvent(event);
                return true;
            }

            int end_hrz;
            int end_vrt;
            final int pointerIndex;

            switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:

                pointerIndex = MotionEventCompat.getActionIndex(event);
                bgn_hrz = (int) MotionEventCompat.getX(event, pointerIndex);
                bgn_vrt = (int) MotionEventCompat.getY(event, pointerIndex);

                String log_str = "Beginning coordinates: Horz = " + String.valueOf(bgn_hrz) + "; Vert = "
                        + String.valueOf(bgn_vrt);

                Log.d("OnTouchListener", log_str);
                orlp = (RelativeLayout.LayoutParams) orgnlImageView.getLayoutParams();
                bgn_top = (int) orlp.topMargin;
                bgn_lft = (int) orlp.leftMargin;

                // To prevent an initial jump of the magnifier, aposX and aPosY must
                // have the values from the magnifier frame
                if (aPosX == 0)
                    aPosX = orgnlImageView.getX();
                if (aPosY == 0)
                    aPosY = orgnlImageView.getY();
                break;

            case MotionEvent.ACTION_MOVE:

                pointerIndex = MotionEventCompat.getActionIndex(event);
                float crt_hrz = MotionEventCompat.getX(event, pointerIndex);
                float crt_vrt = MotionEventCompat.getY(event, pointerIndex);
                final float dx = crt_hrz - bgn_hrz;
                final float dy = crt_vrt - bgn_vrt;
                aPosX += dx;
                aPosY += dy;
                orgnlImageView.setX(aPosX);
                orgnlImageView.setY(aPosY);

                log_str = "Current Position: Horz = " + String.valueOf(crt_hrz) + "; Vert = "
                        + String.valueOf(crt_vrt);

                Log.d("OnTouchListener", log_str);

                break;

            case MotionEvent.ACTION_UP:

                pointerIndex = MotionEventCompat.getActionIndex(event);
                end_hrz = (int) MotionEventCompat.getX(event, pointerIndex);
                end_vrt = (int) MotionEventCompat.getY(event, pointerIndex);
            }

            rel_anm_lo.invalidate();
            return true;
        }
    });

    sav_anm_btn = (Button) findViewById(R.id.sav_btn);

    sav_anm_btn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View vw) {

            onClickFlg = 1;
            RelativeLayout rel_anm_lo = (RelativeLayout) findViewById(R.id.activity_anm_lo);
            rel_anm_lo.removeView(vw);
            Bitmap tnBmp = getWrtBmp("thumbnail", rel_anm_lo, 40);
            tnBmp.recycle();
            int vw_nmbr = anmViews.size();

            for (int vw_mbr = 1; vw_mbr < vw_nmbr; vw_mbr += 1) {

                anim_view = anmViews.get(vw_mbr);

                if (anim_view != null) {

                    Animation crt_anm = anim_view.getAnimation();

                    if (crt_anm != null)
                        crt_anm.cancel();

                    anim_view.setAnimation(null);
                    rel_anm_lo.removeView(anim_view);

                    // Garbage collect the bitmap
                    Drawable drawable = anim_view.getDrawable();

                    if (drawable instanceof BitmapDrawable) {
                        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
                        Bitmap anim_bmp = bitmapDrawable.getBitmap();
                        anim_bmp.recycle();
                    }
                }
            }

            Bitmap orgnlImageBmp = getWrtBmp("bgimg", rel_anm_lo, 90);
            orgnlImageWdth = Integer.toString(orgnlImageBmp.getWidth());
            orgnlImageHght = Integer.toString(orgnlImageBmp.getHeight());
            anmViews.clear();
            unbindDrawables(rel_anm_lo);
            ((RelativeLayout) rel_anm_lo).removeAllViews();
            orgnlImageBmp.recycle();
            crt_ctx = null;
            orgnlImageView = null;

            Intent intent = new Intent(AnimActivity.this, com.acceleratedio.pac_n_zoom.SaveAnmActivity.class);

            startActivity(intent);
        }
    });

    progress = ProgressDialog.show(crt_ctx, "Loading the animation", "dialog message", true);
    GetRequest get_svg_img = new GetRequest();
    get_svg_img.execute("");
}

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

/** start project details activities (milestones, categories, people, issues) */
private void getProjDetail(long id, String PROJ_DETAIL_URL, String PROJ_DETAIL, Class<?> cls) {
    String projDetailURL = null;/*from   ww  w  .  j a va  2 s . c  o m*/
    try {
        projDetailURL = mAllProjects[(int) id].getString(PROJ_DETAIL_URL);
        // TODO use safe long typecast to int
    } catch (JSONException e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return;
    }
    String issuesURL = projDetailURL;
    if (PROJ_DETAIL.equals(ISSUES)) {
        projDetailURL += getFilterSlug();
    }
    URLConnection sifterConnection = mSifterHelper.getSifterConnection(projDetailURL);
    if (sifterConnection == null)
        return;
    mDialog = ProgressDialog.show(this, "", "Loading ...", true);
    new DownloadSifterDetailTask().execute(sifterConnection, issuesURL, PROJ_DETAIL, cls);
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java

public void broadcastGps() {
    final CharSequence[] items = { "5 minutes", "15 minutes", "1 hour", " 24 hours" };

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Choose duration of broadcast");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, final int item) {
            AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
            alert.setMessage("Enter a secret key if you want to:");
            final EditText input = new EditText(getActivity());
            alert.setView(input);/*from w  ww  .  jav  a 2  s.c o m*/
            alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    final String password = input.getText().toString();
                    myLocation = new MyLocation();
                    locationResult = new MyLocation.LocationResult() {
                        final ProgressDialog dialog = ProgressDialog.show(getActivity(), "",
                                "Preparing broadcast...", true);

                        @Override
                        public void gotLocation(final Location location) {
                            //Got the location!
                            try {
                                int minutes;
                                if (item == 0) {
                                    minutes = 5;
                                } else if (item == 1) {
                                    minutes = 15;
                                } else if (item == 2) {
                                    minutes = 60;
                                } else if (item == 3) {
                                    minutes = 1440;
                                } else {
                                    minutes = 5;
                                }

                                Uri uri = new Uri.Builder().scheme("http").authority("suif.stanford.edu")
                                        .path("dungbeetle/nearby.php").build();

                                StringBuffer sb = new StringBuffer();
                                DefaultHttpClient client = new DefaultHttpClient();
                                HttpPost httpPost = new HttpPost(uri.toString());

                                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                                nameValuePairs.add(new BasicNameValuePair("group_name", mGroupName));
                                nameValuePairs
                                        .add(new BasicNameValuePair("feed_uri", mExternalFeedUri.toString()));
                                nameValuePairs.add(new BasicNameValuePair("length", Integer.toString(minutes)));
                                nameValuePairs.add(
                                        new BasicNameValuePair("lat", Double.toString(location.getLatitude())));
                                nameValuePairs.add(new BasicNameValuePair("lng",
                                        Double.toString(location.getLongitude())));
                                nameValuePairs.add(new BasicNameValuePair("password", password));
                                httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                                try {
                                    HttpResponse execute = client.execute(httpPost);
                                    InputStream content = execute.getEntity().getContent();
                                    BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
                                    String s = "";
                                    while ((s = buffer.readLine()) != null) {
                                        sb.append(s);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                String response = sb.toString();
                                if (response.equals("1")) {
                                    Toast.makeText(getActivity(), "Now broadcasting for " + items[item],
                                            Toast.LENGTH_SHORT).show();
                                } else
                                    Log.w(TAG, "Wtf");

                                Log.w(TAG, "response: " + response);
                            } catch (Exception e) {
                            }

                            dialog.dismiss();
                        }
                    };
                    locationClick();
                }
            });
            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                }
            });
            alert.show();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_Logged.java

public void logout() {

    if (checkInternetConnection() == true) { //If the internet connection is working

        loadingDialog = ProgressDialog.show(this, "Singing Out", "Wait a few seconds", false);

        //Request a session close for the logged user
        _piggate.RequestCloseSession().setListenerRequest(new Piggate.PiggateCallBack() {

            //Method onComplete for JSONObject
            @Override/*from  w  w w  .  j a va 2 s  . c om*/
            public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {

                loadingDialog.dismiss();
                Service_Notify.logout = true;

                //Go back to the main activity
                Intent slideactivity = new Intent(Activity_Logged.this, Activity_Main.class);
                slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright)
                        .toBundle();
                startActivity(slideactivity, bndlanimation);
            }

            //Method onError for JSONObject
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                Service_Notify.logout = false;
                loadingDialog.dismiss();
                errorDialog.show();
                _piggate.reload();
            }

            //Method onComplete for JSONArray
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }

            //Method onError for JSONArray
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }
        }).exec();

    } else { //If internet conexion is not working displays an error message
        networkErrorDialog.show();
    }
}

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

private void addNotification() {
    // Error checking
    if (mSensorValue.getText().length() == 0) {
        mSensorValue.setError(getString(R.string.error_empty_value));
        return;//from   w  w  w.jav a 2  s. c om
    }

    final ProgressDialog progress = ProgressDialog.show(this, "",
            getResources().getString(R.string.adding_notification), false);

    NotificationInfo notificationInfo = null;
    String condition = "";
    switch (mConditionSpinner.getSelectedItemPosition()) {
    case 0:
        condition = ">=";
        break;
    case 1:
        condition = "=<";
        break;
    }

    Boolean ringOnce = mRingOnceCheckbox.isChecked();

    switch (mDeviceSpinner.getSelectedItemPosition()) {
    case 0: // System
        switch (mTypeSpinner.getSelectedItemPosition()) {
        case 0: // Temperature
            notificationInfo = new NotificationInfo(
                    mSystemTempSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 1: // Fan
            notificationInfo = new NotificationInfo(
                    mSystemFanSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 2: // Voltage
            notificationInfo = new NotificationInfo(
                    mSystemVoltSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        }
        break;
    case 1: // CPU
        switch (mTypeSpinner.getSelectedItemPosition()) {
        case 0: // Temp
            notificationInfo = new NotificationInfo(
                    mCPUTempSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 1: // Power
            notificationInfo = new NotificationInfo(
                    mCPUPowerSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 2: // Load
            notificationInfo = new NotificationInfo(
                    mCPULoadSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 3: // Clock
            notificationInfo = new NotificationInfo(
                    mCPUClockSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        }
        break;
    case 2: // GPU
        switch (mTypeSpinner.getSelectedItemPosition()) {
        case 0: // Temp
            notificationInfo = new NotificationInfo(
                    mGPUTempSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 1: // Fan
            notificationInfo = new NotificationInfo(
                    mGPUFanSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 2: // Load
            notificationInfo = new NotificationInfo(
                    mGPULoadSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        case 3: // Clock
            notificationInfo = new NotificationInfo(
                    mGPUClockSensors[mSensorSpinner.getSelectedItemPosition()].getName(), "Temperature",
                    condition, mSensorValue.getText().toString(), ringOnce);
            break;
        }
    }

    // Add notification
    RequestParams params = new RequestParams();
    params.put("type", "addnotif");
    params.put("id", String.valueOf(mSettings.getLong("device_id", -2)));

    params.put("name", notificationInfo.getNotificationName());
    params.put("ntype", notificationInfo.getNotificationType());
    params.put("condition", notificationInfo.getCondition());
    params.put("value", notificationInfo.getNotificationValue());
    params.put("ringonce", notificationInfo.getRingOnce().toString());

    final Activity context = this;

    mClient.get(mURL, params, new TextHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, String responseBody) {
            progress.hide();
            Toast.makeText(context, "Notification added", Toast.LENGTH_SHORT).show();
            finish();
        }

        @Override
        public void onFailure(String responseBody, Throwable error) {
            progress.hide();
            Toast.makeText(context, "Could not add notification: " + error.getMessage(), Toast.LENGTH_LONG)
                    .show();
        }
    });
}

From source file:sjizl.com.FileUploadTest2.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode == RESULT_OK) {
        Uri selectedImageUri = data.getData();
        if (requestCode == SELECT_FILE1) {
            selectedPath1 = getPath(selectedImageUri);
            progressDialog = ProgressDialog.show(FileUploadTest2.this, "", "Uploading files to server.....",
                    false);//  w  w  w . j a  v a  2s.  c om
            Thread thread = new Thread(new Runnable() {
                public void run() {
                    doFileUpload();
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (progressDialog.isShowing())
                                progressDialog.dismiss();
                        }
                    });
                }
            });
            thread.start();
        }
        finish();
    }
}

From source file:ca.rmen.android.scrumchatter.main.MainActivity.java

/**
 * Import the given database file. This will replace the current database.
 *//*from w w  w.  j  ava 2s  . co m*/
private void importDB(final Uri uri) {
    ScrumChatterDialog.showDialog(this, getString(R.string.import_confirm_title),
            getString(R.string.import_confirm_message, uri.getEncodedPath()), new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (which == DialogInterface.BUTTON_POSITIVE) {
                        AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
                            private ProgressDialog mProgressDialog;

                            @Override
                            protected void onPreExecute() {
                                mProgressDialog = ProgressDialog.show(MainActivity.this, null,
                                        getString(R.string.progress_dialog_message), true);
                            }

                            @Override
                            protected Boolean doInBackground(Void... params) {
                                try {
                                    Log.v(TAG, "Importing db from " + uri);
                                    DBImport.importDB(MainActivity.this, uri);
                                } catch (Exception e) {
                                    Log.e(TAG, "Error importing db: " + e.getMessage(), e);
                                    return false;
                                }
                                return true;
                            }

                            @Override
                            protected void onPostExecute(Boolean result) {
                                mProgressDialog.cancel();
                                Toast.makeText(MainActivity.this,
                                        result ? R.string.import_result_success : R.string.import_result_failed,
                                        Toast.LENGTH_SHORT).show();
                            }

                        };
                        task.execute();
                    }
                }
            });

}