Example usage for android.app ProgressDialog STYLE_HORIZONTAL

List of usage examples for android.app ProgressDialog STYLE_HORIZONTAL

Introduction

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

Prototype

int STYLE_HORIZONTAL

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

Click Source Link

Document

Creates a ProgressDialog with a horizontal progress bar.

Usage

From source file:com.gimranov.zandy.app.LookupActivity.java

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_PROGRESS:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setMax(100);/*from w w w .  j  a  v a 2 s .c om*/
        return mProgressDialog;
    default:
        Log.e(TAG, "Invalid dialog requested");
        return null;
    }
}

From source file:xyz.jamescarroll.genipass.SettingsDetailActivity.java

private void createProgress() {
    mProgress = new ProgressDialog(this);
    mProgress.setTitle("Running Crypto Test");
    mProgress.setMessage("Please wait.");
    mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgress.setCanceledOnTouchOutside(false);
    mProgress.setCancelable(false);/* w  w w.  j  a va 2s  .co  m*/
    mProgress.setProgress(0);
    mProgress.setMax(5);
    mProgress.setButton(DialogInterface.BUTTON_POSITIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            AsyncTestVector test = TestManager.getInstance().getmAsyncTestVector();

            if (test != null && !test.isCancelled()) {
                test.cancel(true);
            }

            TestManager.getInstance().endTest();

            handleProgressOnResult();
            finish();
        }
    });
}

From source file:com.softminds.matrixcalculator.OperationFragments.InverseFragment.java

@Override
public void onListItemClick(ListView L, View V, int position, long id) {
    ProgressDialog progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(getString(R.string.Calculating));
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();//from w w  w.j  a va2s.  c  om
    progress = progressDialog;

    if (SquareList.get(position).getJamaMatrix().det() != 0) {
        if (ENABLED_NO_DECIMAL)
            RunAndGetDeterminantWithAdjoint(position, progressDialog);
        else
            RunNewGetInverse(position, progressDialog);
    } else {
        new AlertDialog.Builder(getContext())
                .setMessage("The Determinant of the matrix was Zero and Hence its Inverse does not exist")
                .setTitle("No Inverse Exist")
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).show();
        progressDialog.dismiss();
    }

}

From source file:com.example.android.MainActivity.java

/**Display JSON data in table format on the user interface of android app
 * by clicking on the button 'Start'*/
@Override//w ww .  j  a  v  a2  s .co  m
protected void onCreate(Bundle savedInstanceState) {
    /**
     * Declares TextView, Button and Tablelayout to retrieve the widgets 
     * from User Interface. Insert the TableRow into Table and set the 
     * gravity, font size  and id of table rows and columns.
     * 
     * Due to great amount of JSON data, 'for' loop method is used to insert 
     * the new rows and columns in the table. In each loop, each of rows and 
     * columns are set to has its own unique id. This purpose of doing this 
     * is to allows the user to read and write the text of specific rows and 
     * columns easily.
     */
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    progress = new ProgressDialog(this);
    StartDisplay = (Button) findViewById(R.id.btnDisplay);
    profile = (TableLayout) findViewById(R.id.tableLayout1);
    profile.setStretchAllColumns(true);
    profile.bringToFront();

    for (int i = 1; i < 11; i++) {
        TableRow tr = new TableRow(this);
        TextView c1 = new TextView(this);
        TextView c2 = new TextView(this);
        c1.setId(i * 10 + 1);
        c1.setTextSize(12);
        c1.setGravity(Gravity.CENTER);
        c2.setId(i * 10 + 2);
        c2.setTextSize(12);
        c2.setGravity(Gravity.CENTER);
        tr.addView(c1);
        tr.addView(c2);
        tr.setGravity(Gravity.CENTER_HORIZONTAL);
        profile.addView(tr);
    }

    /**
    * onClick: Executes the DownloadWebPageTask once OnClick event occurs. 
    * When user click on the "Start" button, 
    * 1)the JSON data will be read from URL 
    * 2)Progress bar will be shown till all data is read and displayed in
    * table form. Once it reaches 100%, it will be dismissed. 
    * 
    * Progress Bar: The message of the progress bar is obtained from strings.xml.
    * New thread is created to handle the action of the progress bar. 
    */
    StartDisplay.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            final String TAG = "MyActivity";
            progress.setMessage(getResources().getString(R.string.ProgressBar_message));
            progress.setCancelable(true);
            progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progress.setProgress(0);
            progress.setMax(100);
            progress.show();
            new Thread(new Runnable() {

                public void run() {
                    while (ProgressBarStatus < 100) {

                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            Log.e(TAG, Log.getStackTraceString(e));
                        }
                        progressBarbHandler.post(new Runnable() {
                            public void run() {
                                progress.setProgress(ProgressBarStatus);
                            }
                        });
                    }

                    if (ProgressBarStatus >= 100) {

                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            Log.e(TAG, Log.getStackTraceString(e));
                        }

                        progress.dismiss();
                    }
                }
            }).start();
            DownloadWebPageTask task = new DownloadWebPageTask();
            task.execute("http://private-ae335-pgserverapi.apiary.io/user/profile/234");
            StartDisplay.setClickable(false);
        }
    });

}

From source file:com.primitive.library.task.DownloadTask.java

@Override
protected void onPreExecute() {
    this.progress = new ProgressDialog(this.owner);
    this.progress.setMessage("Downloading...");
    this.progress.setIndeterminate(false);
    this.progress.setCancelable(false);
    this.progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    // this.mProgressDialog.setMax(1);
    this.progress.show();
}

From source file:nmtysh.android.test.speedtest.SpeedTestActivity.java

private void runHttpClient() {
    final String url = urlEdit.getText().toString();
    if (url == null || (!url.startsWith("http://") && !url.startsWith("https://"))) {
        list.add("URL error!");
        adapter.notifyDataSetChanged();/*  w  w w. j av a2  s . c om*/
        return;
    }
    task = new AsyncTask<Void, Integer, Void>() {
        long startTime;
        ProgressDialog progress;

        // ??
        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            progress = new ProgressDialog(SpeedTestActivity.this);
            progress.setMessage(getString(R.string.progress_message));
            progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progress.setIndeterminate(false);
            progress.setCancelable(true);
            progress.setOnCancelListener(new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    task.cancel(true);
                }
            });
            progress.setMax(10);
            progress.setProgress(0);
            progress.show();

            startTime = System.currentTimeMillis();
        }

        // ???
        @Override
        protected Void doInBackground(Void... params) {
            // 10?????
            for (int i = 0; i < 10; i++) {
                HttpClient client = new DefaultHttpClient();
                InputStreamReader in = null;
                // BufferedReader br = null;
                try {
                    HttpGet get = new HttpGet(url);
                    HttpResponse response = client.execute(get);
                    if (response.getStatusLine().getStatusCode() < 400) {
                        in = new InputStreamReader(response.getEntity().getContent());
                        // br = new BufferedReader(in);
                        // while (br.readLine() != null) {
                        long len = 0;
                        while (in.read() != -1) {
                            len++;
                        }
                        Log.i("HttpClient", len + " Bytes");
                    }
                } catch (IOException e) {
                } finally {
                    /*
                     * if (br != null) { try { br.close(); } catch
                     * (IOException e) { } br = null; }
                     */
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                        }
                        in = null;
                    }
                    // ?
                    client.getConnectionManager().shutdown();
                    client = null;
                }
                publishProgress(i + 1);
                // Dos????????
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            super.onProgressUpdate(values);
            if (progress == null) {
                return;
            }
            progress.setProgress(values[0]);
        }

        // 
        @Override
        protected void onPostExecute(Void result) {
            long endTime = System.currentTimeMillis();

            // 
            progress.cancel();
            progress = null;

            list.add("HttpClient:" + url + " " + (endTime - startTime) + "msec/10" + " "
                    + (endTime - startTime) / 10 + "msec");
            adapter.notifyDataSetChanged();
        }

        @Override
        protected void onCancelled() {
            super.onCancelled();
            progress.dismiss();
            progress = null;
        }
    }.execute();
}

From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncAutoGetAlbumArtTask.java

public void onPreExecute() {
    super.onPreExecute();

    pd = new ProgressDialog(mActivity);
    pd.setTitle(R.string.downloading_album_art);
    pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    pd.setCancelable(false);/*from w  w w .j av a2s  . c  om*/
    pd.setCanceledOnTouchOutside(false);
    pd.setMessage(mContext.getResources().getString(R.string.scanning_for_missing_art));
    pd.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getResources().getString(R.string.cancel),
            new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    task.cancel(true);

                }

            });

    pd.show();

}

From source file:com.osama.cryptofm.tasks.DeleteTask.java

@Override
protected void onPreExecute() {
    mProgressDialog.setTitle("Deleting file(s)");
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.show();//from  w w w  . jav  a2  s .  c o m
}

From source file:tv.loilo.promise.samples.progress.SampleProgressBarDialogFragment.java

@NonNull
@Override/*from   w  ww .  java2  s.  co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final ProgressDialog progressDialog = new ProgressDialog(getContext(), getTheme());
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMax(100);
    progressDialog.setMessage("Loading...");
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    return progressDialog;
}

From source file:org.gnucash.android.export.ExportAsyncTask.java

@Override
@TargetApi(11)/*from   www . j a  va  2 s .co  m*/
protected void onPreExecute() {
    super.onPreExecute();
    if (mContext instanceof Activity) {
        mProgressDialog = new ProgressDialog(mContext);
        mProgressDialog.setTitle(R.string.title_progress_exporting_transactions);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
            mProgressDialog.setProgressNumberFormat(null);
            mProgressDialog.setProgressPercentFormat(null);
        }
        mProgressDialog.show();
    }
}