Example usage for android.app ProgressDialog setMax

List of usage examples for android.app ProgressDialog setMax

Introduction

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

Prototype

public void setMax(int max) 

Source Link

Document

Sets the maximum allowed progress value.

Usage

From source file:com.github.yuukis.businessmap.app.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    boolean cancelable = getArguments().getBoolean(CANCELABLE, false);
    setCancelable(cancelable);/*from w w w  .  j a  v a 2  s.co  m*/

    String title = getArguments().getString(TITLE);
    String message = getArguments().getString(MESSAGE);
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setIndeterminate(false);
    dialog.setCanceledOnTouchOutside(false);

    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setMax(getArguments().getInt(MAX));

    return dialog;
}

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

@NonNull
@Override/*from  ww w  .j  av  a2s.  c  o  m*/
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;
}

From source file:com.anandbibek.notifyme.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (!access) {
        ProgressDialog pDialog = new ProgressDialog(this);
        pDialog.setMessage(getResources().getString(R.string.main_check_checking));
        pDialog.setMax(3000);
        pDialog.setCancelable(false);//from  w  ww.  j ava2 s. c om
        pDialog.show();
        stuff = new CheckAccessibilityTask();
        stuff.execute(pDialog);
        return;
    }
    ListView mainFilterList = (ListView) this.findViewById(R.id.main_filter_list);
    String[] filterApps = new String[prefs.getNumberOfFilters() + 1];
    for (int i = 0; i < filterApps.length; i++) {
        if (i == prefs.getNumberOfFilters()) {
            filterApps[i] = "JOKER";
        } else {
            filterApps[i] = prefs.getFilterApp(i);
        }
    }
    ArrayAdapter<String> adapter = new MainFilterAdapter(this, filterApps);
    mainFilterList.setAdapter(adapter);
    mainFilterList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent editFilterIntent = new Intent(parent.getContext(), EditFilterActivity.class);
            if (position == prefs.getNumberOfFilters()) {
                editFilterIntent.setAction("new");
            } else {
                editFilterIntent.setAction("edit");
                editFilterIntent.putExtra("filter", position);
            }
            startActivity(editFilterIntent);
        }
    });
    mainFilterList.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final int filter = position;
            if (filter == prefs.getNumberOfFilters())
                return true;
            final View finalView = view;
            AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
            try {
                builder.setTitle(getResources().getString(R.string.main_remove_title1) + " "
                        + ((TextView) ((RelativeLayout) view).getChildAt(1)).getText() + " "
                        + getResources().getString(R.string.main_remove_title2));
                builder.setIcon(((ImageView) ((RelativeLayout) view).getChildAt(0)).getDrawable());
            } catch (Exception e) {

            }
            builder.setPositiveButton(R.string.main_remove_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    prefs.removeFilter(filter);
                    startActivity(new Intent(finalView.getContext(), MainActivity.class).setAction("redraw"));
                }
            });
            builder.setNegativeButton(R.string.main_remove_cancel, null);
            builder.show();
            return true;
        }
    });
}

From source file:jp.co.noxi.app.NXProgressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final ProgressDialog dialog = mProgressDialog = new ProgressDialog(getActivity());
        dialog.setProgressStyle(mStyle);
        dialog.setIndeterminate(mIndeterminate);
        if (mMax > 0) {
            dialog.setMax(mMax);
        }/*from   ww w.jav  a  2 s.c  om*/
        if (mProgressVal > 0) {
            dialog.setProgress(mProgressVal);
        }
        if (mSecondaryProgressVal > 0) {
            dialog.setSecondaryProgress(mSecondaryProgressVal);
        }
        if (mMessage != null) {
            dialog.setMessage(mMessage);
        }
        if (mFormat != null) {
            dialog.setProgressNumberFormat(mFormat);
        }
        return dialog;
    } else {
        final ProgressDialogGB dialog = mProgressDialogGB = new ProgressDialogGB(getActivity());
        dialog.setProgressStyle(mStyle);
        dialog.setIndeterminate(mIndeterminate);
        if (mMax > 0) {
            dialog.setMax(mMax);
        }
        if (mProgressVal > 0) {
            dialog.setProgress(mProgressVal);
        }
        if (mSecondaryProgressVal > 0) {
            dialog.setSecondaryProgress(mSecondaryProgressVal);
        }
        if (mMessage != null) {
            dialog.setMessage(mMessage);
        }
        if (mFormat != null) {
            dialog.setProgressNumberFormat(mFormat);
        }
        return dialog;
    }
}

From source file:com.ntsync.android.sync.activities.ImportProgressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setMessage(getText(R.string.import_activity_progress));
    dialog.setIndeterminate(false);// w  ww .j  a v a 2 s.com
    if (acInfo != null) {
        dialog.setMax(acInfo.getContactCount());
    }
    return dialog;
}

From source file:it.scoppelletti.mobilepower.app.ProgressDialogFragment.java

/**
 * Crea il dialogo.//from  w w  w  . j  ava2s.c  o  m
 * 
 * @param  savedInstanceState Stato dell&rsquo;istanza.
 * @return                    Dialogo.
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int max, resId;
    ProgressDialog dlg;
    Bundle args = getArguments();

    dlg = new ProgressDialog(getActivity(), AppUtils.getDialogTheme());

    resId = args.getInt(ProgressDialogFragment.ARG_TITLEID);
    dlg.setTitle(getString(resId));
    max = args.getInt(ProgressDialogFragment.ARG_MAX, -1);

    if (max > 0) {
        dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dlg.setIndeterminate(false);
        dlg.setMax(max);
    } else {
        dlg.setIndeterminate(true);
        dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }

    dlg.setCancelable(args.getBoolean(ProgressDialogFragment.ARG_CANCELABLE));
    dlg.setCanceledOnTouchOutside(false);

    return dlg;
}

From source file:com.eleybourn.bookcatalogue.utils.SimpleTaskQueueProgressFragment.java

/**
 * Method, run in the UI thread, that updates the various dialog fields.
 *///from  w w w.  j a  v  a2  s.c o  m
private void updateProgress() {
    ProgressDialog d = (ProgressDialog) getDialog();
    if (d != null) {
        synchronized (this) {
            if (mMaxChanged) {
                d.setMax(mMax);
                mMaxChanged = false;
            }
            if (mNumberFormatChanged) {
                if (Build.VERSION.SDK_INT >= 11) {
                    // Called in a separate function so we can set API attributes
                    setDialogNumberFormat(d);
                }
                mNumberFormatChanged = false;
            }
            if (mMessageChanged) {
                d.setMessage(mMessage);
                mMessageChanged = false;
            }

            if (mProgressChanged) {
                d.setProgress(mProgress);
                mProgressChanged = false;
            }

        }
    }
}

From source file:org.alfresco.mobile.android.application.fragments.operations.OperationWaitingDialogFragment.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    setRetainInstance(true);//  ww w .  j a  va  2  s .  c  o m
    if (getArguments() != null) {
        operationType = getArguments().getInt(PARAM_TYPEID);
        intentId = getArguments().getString(PARAM_INTENTID);
        iconId = getArguments().getInt(PARAM_ICONID);
        title = getArguments().getString(PARAM_TITLEID);
        message = getArguments().getString(PARAM_MESSAGEID);
        parent = getArguments().getParcelable(PARAM_NODEID);
        nbItems = getArguments().getInt(PARAM_SIZE);
    }

    ProgressDialog dialog = new ProgressDialog(getActivity());
    if (iconId == 0) {
        iconId = R.drawable.ic_alfresco_logo;
    }
    dialog.setIcon(iconId);
    dialog.setTitle(title);
    if (message == null) {
        message = getString(R.string.waiting_operations);
    }
    dialog.setMessage(message);
    boolean indeterminate = true;
    if (nbItems > 0) {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        dialog.setMax(nbItems);
        indeterminate = false;
    } else {
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(false);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

    getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this);

    return dialog;
}

From source file:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    if (getArguments() != null) {
        operationType = getArguments().getInt(ARGUMENT_TYPEID);
        intentId = getArguments().getString(ARGUMENT_INTENTID);
        iconId = getArguments().getInt(ARGUMENT_ICONID);
        title = getArguments().getString(ARGUMENT_TITLEID);
        message = getArguments().getString(ARGUMENT_MESSAGEID);
        parent = getArguments().getParcelable(ARGUMENT_NODEID);
        nbItems = getArguments().getInt(ARGUMENT_SIZE);
        operationId = getArguments().getString(ARGUMENT_OPERATIONID);
    }//from  w  w  w  .ja  v  a2 s  . c  o m

    ProgressDialog dialog = new ProgressDialog(getActivity());
    if (iconId == 0) {
        iconId = R.drawable.ic_application_logo;
    }
    dialog.setIcon(iconId);
    dialog.setTitle(title);
    if (message == null) {
        message = getString(R.string.waiting_operations);
    }
    dialog.setMessage(message);
    boolean indeterminate = true;
    if (nbItems > 0) {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        dialog.setMax(nbItems);
        indeterminate = false;
    } else {
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(false);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (operationId != null) {
                        Operator.with(getActivity()).cancel(operationId);
                    }
                    dialog.dismiss();
                }
            });

    getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this);

    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);
    // ?/*  w  w w  .  j a  v  a  2s .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();

}