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.acceleratedio.pac_n_zoom.SaveAnmActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_save_anm);
    EventBus.getDefault().register(this);
    crt_ctx = this;
    tagText = (EditText) findViewById(R.id.sav_tags);

    tagText.addTextChangedListener(new TextWatcher() {

        @Override//from  w  ww.  ja  va  2  s  . com
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence key_sqnc, int start, int before, int count) {

            final StringBuilder strBldr = new StringBuilder(key_sqnc.length());
            strBldr.append(key_sqnc);
            srch_str = strBldr.toString();
            dsply_tags();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    tagText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;
            tags_str = tagText.getText().toString();

            if (actionId == EditorInfo.IME_ACTION_SEND) {

                progress = ProgressDialog.show(crt_ctx, "Saving the animation", "dialog message", true);
                MakePostRequest savAnimation = new MakePostRequest();
                savAnimation.execute();
                handled = true;
            }

            return handled;
        }
    });

    fil_tags = PickAnmActivity.orgnl_tags.split("(\\s*,\\s*)|(\\s* \\s*)");
    Arrays.sort(fil_tags, String.CASE_INSENSITIVE_ORDER);
    dsply_tags();
}

From source file:com.swissbit.homeautomation.asyncTask.AuthenticationAsync.java

@Override
protected void onPreExecute() {
    progressDialog = ProgressDialog.show(ActivityContexts.getMainActivityContext(),
            "Authenticating with Server", "Please Wait", true);
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_add_notification);
    mSettings = getSharedPreferences(MainViewActivity.SHAREDPREFS_FILE, 0);

    // Prepare buttons
    findViewById(R.id.button_add).setOnClickListener(this);
    findViewById(R.id.button_cancel).setOnClickListener(this);
    findViewById(R.id.button_notification_help).setOnClickListener(this);

    // Prepare spinners
    mDeviceSpinner = (Spinner) findViewById(R.id.spinner_device);
    mTypeSpinner = (Spinner) findViewById(R.id.spinner_type);
    mSensorSpinner = (Spinner) findViewById(R.id.spinner_sensor);
    mConditionSpinner = (Spinner) findViewById(R.id.spinner_condition);

    // Edittext//from   ww  w .  j  a  va  2  s  .  c  om
    mSensorValue = (EditText) findViewById(R.id.editText_value);

    // Checkbox
    mRingOnceCheckbox = (CheckBox) findViewById(R.id.checkbox_notif_ringonce);

    // URL
    mURL = getIntent().getExtras().getString(MainViewActivity.EXTRA_ADDRESS);

    // Client
    mClient.setMaxRetriesAndTimeout(2, 2000);

    // Retrieve sensors
    AsyncHttpClient client = new AsyncHttpClient();
    RequestParams params = new RequestParams();
    params.put("type", "listdev");
    params.put("id", String.valueOf(mSettings.getLong("device_id", -2)));

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

    mClient.get(mURL, params, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(JSONObject response) {
            try {
                // System
                JSONArray systemResponse = response.getJSONArray("System");

                int len = systemResponse.length();
                int lenTemp = 0;
                int lenFan = 0;
                int lenVolt = 0;

                for (int i = 0; i < len; i++) {
                    Sensor sensor = new Sensor(systemResponse.getJSONObject(i));

                    if (sensor.getType().equals("Temperature")) {
                        lenTemp++;
                    } else if (sensor.getType().equals("Fan")) {
                        lenFan++;
                    } else if (sensor.getType().equals("Voltage")) {
                        lenVolt++;
                    }
                }

                mSystemTempSensors = new Sensor[lenTemp];
                mSystemFanSensors = new Sensor[lenFan];
                mSystemVoltSensors = new Sensor[lenVolt];

                int iTemp = 0;
                int iFan = 0;
                int iVolt = 0;

                for (int i = 0; i < len; i++) {
                    Sensor sensor = new Sensor(systemResponse.getJSONObject(i));

                    if (sensor.getType().equals("Temperature")) {
                        mSystemTempSensors[iTemp] = sensor;
                        iTemp++;
                    } else if (sensor.getType().equals("Fan")) {
                        mSystemFanSensors[iFan] = sensor;
                        iFan++;
                    } else if (sensor.getType().equals("Voltage")) {
                        mSystemVoltSensors[iVolt] = sensor;
                        iVolt++;
                    }
                }

                // CPU
                JSONArray cpuResponse = response.getJSONArray("CPU");

                len = cpuResponse.length();
                lenTemp = 0;
                int lenLoad = 0;
                int lenClock = 0;
                int lenPower = 0;

                for (int i = 0; i < len; i++) {
                    Sensor sensor = new Sensor(cpuResponse.getJSONObject(i));

                    if (sensor.getType().equals("Temperature")) {
                        lenTemp++;
                    } else if (sensor.getType().equals("Load")) {
                        lenLoad++;
                    } else if (sensor.getType().equals("Clock")) {
                        lenClock++;
                    } else if (sensor.getType().equals("Power")) {
                        lenPower++;
                    }
                }

                mCPUTempSensors = new Sensor[lenTemp];
                mCPULoadSensors = new Sensor[lenLoad];
                mCPUPowerSensors = new Sensor[lenPower];
                mCPUClockSensors = new Sensor[lenClock];

                iTemp = 0;
                int iLoad = 0;
                int iPower = 0;
                int iClock = 0;

                for (int i = 0; i < len; i++) {
                    Sensor sensor = new Sensor(cpuResponse.getJSONObject(i));

                    if (sensor.getType().equals("Temperature")) {
                        mCPUTempSensors[iTemp] = sensor;
                        iTemp++;
                    } else if (sensor.getType().equals("Power")) {
                        mCPUPowerSensors[iPower] = sensor;
                        iPower++;
                    } else if (sensor.getType().equals("Clock")) {
                        mCPUClockSensors[iClock] = sensor;
                        iClock++;
                    } else if (sensor.getType().equals("Load")) {
                        mCPULoadSensors[iLoad] = sensor;
                        iLoad++;
                    }
                }

                // GPU
                JSONArray gpuResponse = response.getJSONArray("GPU");

                len = gpuResponse.length();
                lenTemp = 0;
                lenLoad = 0;
                lenClock = 0;
                lenFan = 0;

                for (int i = 0; i < len; i++) {
                    Sensor sensor = new Sensor(gpuResponse.getJSONObject(i));

                    if (sensor.getType().equals("Temperature")) {
                        lenTemp++;
                    } else if (sensor.getType().equals("Load")) {
                        lenLoad++;
                    } else if (sensor.getType().equals("Clock")) {
                        lenClock++;
                    } else if (sensor.getType().equals("Fan")) {
                        lenFan++;
                    }
                }

                mGPUTempSensors = new Sensor[lenTemp];
                mGPULoadSensors = new Sensor[lenLoad];
                mGPUFanSensors = new Sensor[lenFan];
                mGPUClockSensors = new Sensor[lenClock];

                iTemp = 0;
                iLoad = 0;
                iClock = 0;
                iFan = 0;

                for (int i = 0; i < len; i++) {
                    Sensor sensor = new Sensor(gpuResponse.getJSONObject(i));

                    if (sensor.getType().equals("Temperature")) {
                        mGPUTempSensors[iTemp] = sensor;
                        iTemp++;
                    } else if (sensor.getType().equals("Fan")) {
                        mGPUFanSensors[iFan] = sensor;
                        iFan++;
                    } else if (sensor.getType().equals("Clock")) {
                        mGPUClockSensors[iClock] = sensor;
                        iClock++;
                    } else if (sensor.getType().equals("Load")) {
                        mGPULoadSensors[iLoad] = sensor;
                        iLoad++;
                    }
                }

                // Prepare spinners
                setAdapter(mSensorSpinner, mSystemTempSensors);

                mTypeSpinner.setOnItemSelectedListener(new TypeOnItemSelectedListener());
                mDeviceSpinner.setOnItemSelectedListener(new DeviceOnItemSelectedListener());

                // Close window
                progress.hide();
            } catch (JSONException e) {
                Toast.makeText(context, getString(R.string.error_could_not_reach_host), Toast.LENGTH_LONG)
                        .show();
                progress.hide();
            }
        }

        @Override
        public void onFailure(Throwable error, String content) {
            Toast.makeText(context, getString(R.string.error_could_not_reach_host) + ":" + error.getMessage(),
                    Toast.LENGTH_LONG).show();
            finish();
            progress.hide();
            Log.e("Notif", error.getMessage());
        }
    });
}

From source file:com.crossword.activity.FeedbackActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.feed_send:
        final ProgressDialog progress = ProgressDialog.show(FeedbackActivity.this, "",
                getResources().getString(R.string.feedback_sending), true);
        new Thread((new Runnable() {
            @Override// w  w w. j a  v a  2s  .com
            public void run() {
                postMessage();
                progress.dismiss();
                runOnUiThread(new Runnable() {
                    public void run() {
                        new AlertDialog.Builder(FeedbackActivity.this).setMessage(FeedbackActivity.this.error)
                                .setCancelable(false)
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();
                                    }
                                }).create().show();
                    }
                });
            }
        })).start();
    }
}

From source file:com.gelecekonline.android.uploadornek.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    selectedImageView = (ImageView) findViewById(R.id.selectedImageView);
    selectImageButton = (Button) findViewById(R.id.selectImageButton);
    selectImageButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                //Resim secen Intent tanimlamasi
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)),
                        SELECT_IMAGE_INTENT_ID);
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), getString(R.string.select_image_problem),
                        Toast.LENGTH_LONG).show();
            }/*w  w  w .  j  a  v a2 s .  c o m*/
        }
    });

    uploadButton = (Button) findViewById(R.id.uploadButton);
    uploadButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (selectedImageView.getDrawable() == null) {
                Toast.makeText(getApplicationContext(), getString(R.string.please_select_image),
                        Toast.LENGTH_LONG).show();
            } else {
                dialog = ProgressDialog.show(MainActivity.this, getString(R.string.image_uploading),
                        getString(R.string.please_wait), true);
                if (uploadImageTask == null || uploadImageTask.getStatus() == AsyncTask.Status.FINISHED) {
                    uploadImageTask = new UploadImageTask();
                }
                uploadImageTask.execute();
            }
        }
    });
}

From source file:samples.piggate.com.piggateInfoDemo.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object

    getSupportActionBar().setTitle("Piggate Info Demo");

    networkErrorDialog = new AlertDialog.Builder(this).create();
    networkErrorDialog.setTitle("Network error");
    networkErrorDialog.setMessage("There is an error with the network connection");
    networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override//from   w w w. j  av  a2 s  .  c  om
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    setContentView(R.layout.activity_main);
    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (Service_Notify.logout == false) {
        if (checkInternetConnection()) {

            loadingDialog = ProgressDialog.show(this, "Singing In", "Wait a few seconds", true);
            _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {
                //Method onComplete for JSONObject
                //If the request is completed correctly the user is redirected to Activity_Logged
                @Override
                public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {

                    loadingDialog.dismiss();
                    Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(),
                            R.anim.slidefromright, R.anim.slidetoleft).toBundle();
                    startActivity(slideactivity, bndlanimation);
                }

                //Method onError for JSONObject
                //When we have an error, reload the Piggate object
                @Override
                public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                    loadingDialog.dismiss();
                    _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 {
            networkErrorDialog.show();
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object

    getSupportActionBar().setTitle("Piggate Offers Demo");

    networkErrorDialog = new AlertDialog.Builder(this).create();
    networkErrorDialog.setTitle("Network error");
    networkErrorDialog.setMessage("There is an error with the network connection");
    networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override/*from w  w  w . ja v a 2 s .  co  m*/
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    setContentView(R.layout.activity_main);
    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (Service_Notify.logout == false) {
        if (checkInternetConnection()) {

            loadingDialog = ProgressDialog.show(this, "Singing In", "Wait a few seconds", true);
            _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {
                //Method onComplete for JSONObject
                //If the request is completed correctly the user is redirected to Activity_Logged
                @Override
                public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {

                    loadingDialog.dismiss();
                    Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(),
                            R.anim.slidefromright, R.anim.slidetoleft).toBundle();
                    startActivity(slideactivity, bndlanimation);
                }

                //Method onError for JSONObject
                //When we have an error, reload the Piggate object
                @Override
                public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                    loadingDialog.dismiss();
                    _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 {
            networkErrorDialog.show();
        }
    }
}

From source file:org.openhab.habdroid.ui.OpenHABStartupActivity.java

private void initPage() {

    if (!tryManualUrl()) {
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
                Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetworkInfo != null) {
            Log.i(TAG, "Network is connected");
            if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI
                    || activeNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
                Log.i(TAG, "Network is WiFi or Ethernet");
                AsyncServiceResolver serviceResolver = new AsyncServiceResolver(this, openHABServiceType);
                if (!this.isFinishing())
                    progressDialog = ProgressDialog.show(OpenHABStartupActivity.this, "",
                            "Discovering openHAB. Please wait...", true);
                serviceResolver.start();
            } else if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
                Log.i(TAG, "Network is Mobile (" + activeNetworkInfo.getSubtypeName() + ")");
                onAlternativeUrl();/* w w w .  ja v  a 2 s.c o m*/
            } else {
                Log.i(TAG, "Network type (" + activeNetworkInfo.getTypeName() + ") is unsupported");
            }
        } else {
            Log.i(TAG, "Network is not available");
            Toast.makeText(getApplicationContext(), "@string/error_network_not_available", Toast.LENGTH_LONG)
                    .show();
        }
    }

}

From source file:com.newtifry.android.remote.BackendRequest.java

/**
 * Fire off this request in a thread in the background.
 * @param context The context for this request.
 * @param statusMessage If provided, show a progress dialog with this message. If NULL, no progress dialog is shown.
 * @param accountName The account name to perform the request under.
 *//*w ww .  java  2s . c  o m*/
public void startInThread(final Context context, final String statusMessage, final String accountName) {
    // Set up the dialog.
    if (statusMessage != null) {
        this.dialog = ProgressDialog.show(context, context.getString(R.string.app_name), statusMessage, true);
    }

    // Create a new thread.
    Thread thread = new Thread() {
        public void run() {
            // Create a client.
            BackendClient client = new BackendClient(context, accountName);

            BackendResponse result;
            try {
                Log.i(TAG, "Beginning request...");
                //               dumpRequest();
                result = client.request(thisRequest);

                // Was it successful?
                if (result.isError()) {
                    Log.d(TAG, "Error: " + result.getError());
                } else {
                    Log.d(TAG, "Success! Server returned: " + result.getJSON().toString());
                }

                // Prepare the message to send back.
                Message message = Message.obtain();
                message.obj = result;

                // Post it to ourselves - it will then post it back to the real thread.
                handler.sendMessage(message);
            } catch (Exception e) {
                Log.e(TAG, "Generic exception: " + e.getMessage() + " of type " + e.getClass().toString());
            }
        }
    };

    // And start the request.
    thread.start();
}

From source file:com.notifry.android.remote.BackendRequest.java

/**
 * Fire off this request in a thread in the background.
 * @param context The context for this request.
 * @param statusMessage If provided, show a progress dialog with this message. If NULL, no progress dialog is shown.
 * @param accountName The account name to perform the request under.
 *///from ww w.  j  av  a 2 s  .c o  m
public void startInThread(final Context context, final String statusMessage, final String accountName) {
    // Set up the dialog.
    if (statusMessage != null) {
        this.dialog = ProgressDialog.show(context, context.getString(R.string.app_name), statusMessage, true);
    }

    // Create a new thread.
    Thread thread = new Thread() {
        public void run() {
            // Create a client.
            BackendClient client = new BackendClient(context, accountName);

            BackendResponse result;
            try {
                //Log.i(TAG, "Beginning request...");
                result = client.request(thisRequest);

                // Was it successful?
                /*if( result.isError() )
                {
                   Log.e(TAG, "Error: " + result.getError());
                }
                else
                {
                   Log.e(TAG, "Success! Server returned: " + result.getJSON().toString());
                }*/

                // Prepare the message to send back.
                Message message = Message.obtain();
                message.obj = result;

                // Post it to ourselves - it will then post it back to the real thread.
                handler.sendMessage(message);
            } catch (Exception e) {
                Log.e(TAG, "Generic exception: " + e.getMessage() + " of type " + e.getClass().toString());
            }
        }
    };

    // And start the request.
    thread.start();
}