Example usage for android.app ProgressDialog STYLE_SPINNER

List of usage examples for android.app ProgressDialog STYLE_SPINNER

Introduction

In this page you can find the example usage for android.app ProgressDialog STYLE_SPINNER.

Prototype

int STYLE_SPINNER

To view the source code for android.app ProgressDialog STYLE_SPINNER.

Click Source Link

Document

Creates a ProgressDialog with a circular, spinning progress bar.

Usage

From source file:org.travey.travey.SurveysFragment.java

public void loadTrips() {
    if (this.isVisible() && this.getUserVisibleHint()) {
        dialog = new ProgressDialog(getActivity());
        dialog.setMessage(getResources().getString(R.string.surveys_search));
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setIndeterminate(true);//from  w  w  w . java 2 s  . c o  m
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
        timerDelayRemoveDialog(8000, dialog);
    }
    myPrefs = getActivity().getSharedPreferences("myPrefs", getActivity().MODE_PRIVATE);
    participantID = myPrefs.getString("participantID", "");
    Resources res = getResources();
    String RESTFUL_URL = res.getString(R.string.restful_url);
    String url = RESTFUL_URL + "?method=get-trips-no-survey&format=json&pid=" + participantID;
    Log.i("**************", "url=" + url);
    dataConnection.connect(getActivity(), url);
    //the rest of the action happens in processFinish(String output)
}

From source file:com.bruce.study.demo.base.BaseFragment.java

/**
 * @param msg ???// w  ww. j  a v a  2s . c o  m
 * @return
 */
public ProgressDialog initProgressDialog(String msg) {
    pd_waiting = new ProgressDialog(getActivity());
    pd_waiting.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pd_waiting.setTitle("??");
    pd_waiting.setMessage(msg);
    pd_waiting.setIcon(R.drawable.icon_workdemo);
    pd_waiting.setIndeterminate(false);
    pd_waiting.setCancelable(false);
    pd_waiting.setCanceledOnTouchOutside(false);
    return pd_waiting;
}

From source file:com.uraroji.garage.android.arrraycopybench.MainActivity.java

private void startBench() {
    mResultTextView.setText("");

    final String arrayTypeStr = mArrayTypeSpinner.getSelectedItem().toString();
    final int arrayLength = Integer.parseInt(mArrayLengthSpinner.getSelectedItem().toString());
    final int benchTimes = Integer.parseInt(mBenchTimesSpinner.getSelectedItem().toString());

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage(getString(R.string.benchmarking));
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setCancelable(false);/*from  w w w .j a v  a  2  s.  c o  m*/
    dialog.show();

    final Handler handler = new Handler();

    if (arrayTypeStr.equals("byte")) {
        final byte[] src = new byte[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (byte) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("short")) {
        final short[] src = new short[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (short) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("int")) {
        final int[] src = new int[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (int) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("long")) {
        final long[] src = new long[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (long) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("double")) {
        final double[] src = new double[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = (double) i;
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                benchResult = copyNative(src, benchTimes);
                showResult("native", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Object")) {
        final Object[] src = new Object[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Object();
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Byte")) {
        final Byte[] src = new Byte[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Byte((byte) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Integer")) {
        final Integer[] src = new Integer[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Integer((int) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Long")) {
        final Long[] src = new Long[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Long((long) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else if (arrayTypeStr.equals("Double")) {
        final Double[] src = new Double[arrayLength];
        for (int i = 0; i < src.length; ++i) {
            src[i] = new Double((double) i);
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                BenchResult benchResult = null;

                benchResult = copyClone(src, benchTimes);
                showResult("clone", benchResult, handler);

                benchResult = copyArraycopy(src, benchTimes);
                showResult("System.arraycopy", benchResult, handler);

                benchResult = copyArraysCopyOf(src, benchTimes);
                showResult("Arrays.copyOf", benchResult, handler);

                benchResult = copyForLoop(src, benchTimes);
                showResult("for loop", benchResult, handler);

                dialog.dismiss();
            }
        }).start();
    } else {
        dialog.dismiss();
    }
}

From source file:jp.co.tweetmap.util.TweeterStatusLoader.java

/*************************************************************************************
 *                       Override Methods for DialogFragment                         *
 *************************************************************************************/
@Override//from  ww  w  .  j  ava 2  s.co  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.e(TAG, "### onCreateDialog() ###");
    if (null != mProgressDialog) {
        return mProgressDialog;
    }

    String message = getArguments().getString("MESSAGE");

    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setMessage(message);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setCancelable(false);

    return mProgressDialog;
}

From source file:com.microsoft.rightsmanagement.sampleapp.ProgressDialogFragment.java

/**
 * Instantiate the fragment views.// ww w .j av a2  s .  c o m
 * 
 * @param savedInstanceState the saved instance state
 * @return the dialog
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    // Restore the dialog in case of orientation change
    if (savedInstanceState != null) {
        restoreInstance(savedInstanceState);
    }
    mDialog = new ProgressDialog(getActivity(), ProgressDialog.STYLE_SPINNER);
    mDialog.setMessage(mMessage);
    return mDialog;
}

From source file:edu.pdx.its.portal.routelandia.MapsActivity.java

/**
 * Start up the dialog to prevent user from clicking while things are loading...
 *///from   ww w  .  j a va2 s.c  o  m
private void initLoadingDialog() {
    loadingDialog = new ProgressDialog(this);
    loadingDialog.setMessage("Loading highway data...");
    loadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    loadingDialog.setCancelable(false);
    loadingDialog.show();
}

From source file:com.nanosheep.bikeroute.Feedback.java

@Override
public Dialog onCreateDialog(final int id) {
    AlertDialog.Builder builder;//  w w w .  j  av  a2  s.  c o m
    ProgressDialog pDialog;
    Dialog dialog;
    switch (id) {
    case R.id.send:
        pDialog = new ProgressDialog(this);
        pDialog.setCancelable(true);
        pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pDialog.setMessage(getText(R.string.send_msg));
        pDialog.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(final DialogInterface arg0) {
                removeDialog(R.id.send);
            }
        });
        pDialog.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(final DialogInterface arg0) {
                submitHandler.cancel(true);
            }

        });
        dialog = pDialog;
        break;
    case R.id.thanks:
        builder = new AlertDialog.Builder(this);
        builder.setMessage(getText(R.string.thanks_message)).setCancelable(true)
                .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int id) {
                        dialog.dismiss();
                        finish();
                    }
                });
        dialog = builder.create();
        break;
    case R.id.feedback_fail:
        builder = new AlertDialog.Builder(this);
        builder.setMessage(getText(R.string.feedback_fail_message)).setCancelable(true)
                .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int id) {
                        dialog.dismiss();
                    }
                });
        dialog = builder.create();
        break;
    default:
        dialog = null;
    }
    return dialog;
}

From source file:org.montanafoodhub.app.MainActivity.java

private void setupWaitScreen() {
    _waitScreen = new ProgressDialog(this);
    _waitScreen.setMessage(getResources().getString(R.string.appInitializing));
    _waitScreen.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    _waitScreen.setCanceledOnTouchOutside(false);
    _waitScreen.show();/*  w w  w  .j a v  a  2  s  . com*/
}

From source file:com.bruce.study.demo.base.BaseFragmentActivity.java

/**
 * @param msg ???// w w w. j  av  a 2 s  .c o  m
 * @return
 */
public ProgressDialog initProgressDialog(String msg) {
    pd_waiting = new ProgressDialog(this);
    pd_waiting.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pd_waiting.setTitle("??");
    pd_waiting.setMessage(msg);
    pd_waiting.setIcon(R.drawable.icon_workdemo);
    pd_waiting.setIndeterminate(false);
    pd_waiting.setCancelable(false);
    pd_waiting.setCanceledOnTouchOutside(false);
    return pd_waiting;
}

From source file:weavebytes.com.futureerp.activities.LoginActivity.java

public void SendJsonRequest() {
    new AsyncTask<Void, Void, String>() {
        @Override//from  w ww  .  ja  v  a 2 s .  c o  m
        protected void onPreExecute() {
            super.onPreExecute();
            progress.setMessage("Please Wait..");
            progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progress.setCancelable(true);
            progress.show();
        }

        @Override
        protected String doInBackground(Void... params) {

            if (isOnline()) {

                HttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(Config.URL_LOGIN);
                List<NameValuePair> nameValuePair = new ArrayList<>();
                nameValuePair.add(new BasicNameValuePair("username", username));
                nameValuePair.add(new BasicNameValuePair("password", password));

                try {
                    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));

                } catch (UnsupportedEncodingException e) {
                    return e + "";
                }
                try {
                    HttpResponse response = httpClient.execute(httpPost);
                    //Converting Response To JsonString
                    return ConvertResponse_TO_JSON.entityToString(response.getEntity());
                } catch (ClientProtocolException e) {
                    // Log exception
                    e.printStackTrace();
                } catch (IOException e) {
                    // Log exception
                    e.printStackTrace();
                }
                return "Bad NetWork";
            } else {
                return "Check Your Connection";

            }
        }

        @Override
        protected void onPostExecute(String JsonString) {
            JSONObject jsonobj = null;
            progress.dismiss();
            try {

                jsonobj = new JSONObject(JsonString);
                //Parsing JSON and Checking the error_code (username ot password are correct or not)
                if (jsonobj.getString("error").equals("0")) {
                    Config.U_ID = jsonobj.getString("user_id");
                    Intent intent = new Intent(LoginActivity.this, DashBoardActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Toast.makeText(LoginActivity.this, "Invalid User", Toast.LENGTH_SHORT).show();
                }
            } catch (JSONException e) {
                e.printStackTrace();
                //toast(e + " ");
            }
        }
    }.execute();
}