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:id.nci.stm_9.ProgressDialogFragment.java

/**
 * Creates dialog//from  www  .java 2 s  . co m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();

    ProgressDialog dialog = new ProgressDialog(activity);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);

    int messageId = getArguments().getInt(ARG_MESSAGE_ID);
    int style = getArguments().getInt(ARG_STYLE);

    dialog.setMessage(getString(messageId));
    dialog.setProgressStyle(style);

    // Disable the back button
    OnKeyListener keyListener = new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK) {
                return true;
            }
            return false;
        }

    };
    dialog.setOnKeyListener(keyListener);

    return dialog;
}

From source file:eu.codeplumbers.cosi.api.tasks.DeleteFileTask.java

public DeleteFileTask(FileManagerFragment fileManagerFragment) {
    this.fileManagerFragment = fileManagerFragment;

    Device device = Device.registeredDevice();

    // delete all local notes
    new Delete().from(Note.class).execute();

    // cozy register device url
    this.url = device.getUrl() + "/ds-api/data/";

    // concatenate username and password with colon for authentication
    final String credentials = device.getLogin() + ":" + device.getPassword();
    authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);

    dialog = new ProgressDialog(fileManagerFragment.getActivity());
    dialog.setCancelable(false);/*from   w  ww .  ja v a2 s  .co  m*/
    dialog.setProgress(0);
    dialog.setMax(100);
    dialog.setMessage("Please wait");
    dialog.setIndeterminate(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.show();

}

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

@Override
protected void onPreExecute() {
    super.onPreExecute();
    mProgressDialog = new ProgressDialog(mContext);
    mProgressDialog.setTitle(R.string.title_progress_exporting_transactions);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.show();//from www.  j a  va  2 s. c o m
}

From source file:com.yandex.disk.rest.example.MakeFolderFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new ProgressDialog(getActivity());
    dialog.setTitle(R.string.example_progress_mkfolder_title);
    dialog.setIndeterminate(true);//from w ww .  j a v  a 2s.  co  m
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setButton(ProgressDialog.BUTTON_NEUTRAL, getText(R.string.example_make_folder_negative_button),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    onCancel();
                }
            });
    return dialog;
}

From source file:com.yandex.disk.rest.example.DownloadFileFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new ProgressDialog(getActivity());
    dialog.setTitle(R.string.example_loading_file_title);
    dialog.setMessage(item.getName());/*from  w ww .  j ava 2  s.  co  m*/
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setIndeterminate(true);
    dialog.setButton(ProgressDialog.BUTTON_NEUTRAL, getString(R.string.example_loading_file_cancel_button),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    onCancel();
                }
            });
    dialog.setOnCancelListener(this);
    dialog.show();
    return dialog;
}

From source file:com.lostad.app.base.util.DownloadUtil.java

public static void downFileAsyn(final Activity ctx, final String upgradeUrl, final String savedPath,
        final MyCallback<Boolean> callback) {
    final ProgressDialog xh_pDialog = new ProgressDialog(ctx);
    // ?/*www .  j  a v  a2  s  .  c  o m*/
    xh_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    // ProgressDialog 
    xh_pDialog.setTitle("???");
    // ProgressDialog???
    xh_pDialog.setMessage("...");
    // ProgressDialog
    // xh_pDialog.setIcon(R.drawable.img2);
    // ProgressDialog ??? false ??
    xh_pDialog.setIndeterminate(false);
    // ProgressDialog ?
    // xh_pDialog.setProgress(100);
    // ProgressDialog ???
    xh_pDialog.setCancelable(true);
    // ProgressDialog
    xh_pDialog.show();

    new Thread() {
        public void run() {

            boolean downloadSuccess = true;
            FileOutputStream fileOutputStream = null;
            try {
                Looper.prepare();
                HttpClient client = new DefaultHttpClient();
                HttpGet get = new HttpGet(upgradeUrl);

                File f = new File(savedPath);
                if (!f.exists()) {
                    f.createNewFile();
                }

                HttpResponse response = client.execute(get);
                HttpEntity entity = response.getEntity();
                // ?
                Long length = entity.getContentLength();
                xh_pDialog.setMax(length.intValue());
                //
                InputStream is = entity.getContent();
                fileOutputStream = null;

                if (is != null && length > 0) {

                    fileOutputStream = new FileOutputStream(f);

                    byte[] buf = new byte[1024];
                    int ch = -1;
                    int count = 0;
                    while ((ch = is.read(buf)) != -1) {

                        if (xh_pDialog.isShowing()) {
                            fileOutputStream.write(buf, 0, ch);
                            // ?
                            count += ch;
                            xh_pDialog.setProgress(count);
                        } else {
                            downloadSuccess = false;
                            break;// ?
                        }
                    }

                } else {
                    callback.onCallback(false);
                }

                if (downloadSuccess && fileOutputStream != null) {
                    xh_pDialog.dismiss();
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    callback.onCallback(true);// ?
                }
                Looper.loop();
            } catch (FileNotFoundException e) {
                xh_pDialog.dismiss();
                e.printStackTrace();
                callback.onCallback(false);
                xh_pDialog.dismiss();
            } catch (Exception e) {
                xh_pDialog.dismiss();
                e.printStackTrace();
                callback.onCallback(false);
            } finally {
                try {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }.start();

}

From source file:com.yandex.disk.rest.example.RenameMoveItemFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new ProgressDialog(getActivity());
    dialog.setTitle(R.string.example_move_rename_item_title);
    dialog.setMessage(dstPath);// w  ww.j a v  a2  s .  c o  m
    dialog.setIndeterminate(true);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setButton(ProgressDialog.BUTTON_NEUTRAL, getText(R.string.example_make_folder_negative_button),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    onCancel();
                }
            });
    return dialog;
}

From source file:id.nci.stm_9.DeleteFileDialogFragment.java

/**
 * Creates dialog//from  w ww.  j  av a2  s . co m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String deleteFile = getArguments().getString(ARG_DELETE_FILE);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(android.R.drawable.ic_dialog_alert);
    alert.setTitle(R.string.warning);
    alert.setMessage(this.getString(R.string.file_delete_confirmation, deleteFile));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            // Send all information needed to service to edit key in other thread
            Intent intent = new Intent(activity, KeychainIntentService.class);

            // fill values for this action
            Bundle data = new Bundle();

            intent.setAction(KeychainIntentService.ACTION_DELETE_FILE_SECURELY);
            data.putString(KeychainIntentService.DELETE_FILE, deleteFile);
            intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

            ProgressDialogFragment deletingDialog = ProgressDialogFragment
                    .newInstance(R.string.progress_deleting_securely, ProgressDialog.STYLE_HORIZONTAL);

            // Message is received after deleting is done in ApgService
            KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity,
                    deletingDialog) {
                public void handleMessage(Message message) {
                    // handle messages by standard ApgHandler first
                    super.handleMessage(message);

                    if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                        Toast.makeText(activity, R.string.file_delete_successful, Toast.LENGTH_SHORT).show();
                    }
                };
            };

            // Create a new Messenger for the communication back
            Messenger messenger = new Messenger(saveHandler);
            intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);

            // show progress dialog
            deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog");

            // start service with intent
            activity.startService(intent);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });
    alert.setCancelable(true);

    return alert.create();
}

From source file:com.esri.arcgisruntime.sample.generateofflinemapwithlocalbasemap.ProgressDialogFragment.java

@NonNull
@Override//  w w w  .  j a  v  a  2 s  . c  om
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    // create a dialog to show progress
    final ProgressDialog progressDialog = new ProgressDialog(getActivity());
    progressDialog.setTitle(mTitle);
    progressDialog.setMessage(mMessage);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMax(100);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mCancel, (dialog, which) -> onDismiss(dialog));
    return progressDialog;
}