Java Code Examples for android.app.progressdialog#setMax()

The following examples show how to use android.app.progressdialog#setMax() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Downloadfile_activity.java    From Android-Example with Apache License 2.0 6 votes vote down vote up
/**
 * Showing Dialog
 * */
@Override
protected Dialog onCreateDialog(int id) {
	switch (id) {
	case progress_bar_type:
		pDialog = new ProgressDialog(this);
		pDialog.setMessage("Downloading file. Please wait...");
		pDialog.setIndeterminate(false);
		pDialog.setMax(100);
		pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		pDialog.setCancelable(true);
		pDialog.show();
		return pDialog;
	default:
		return null;
	}
}
 
Example 2
Source File: StringAsyncTask.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    if (doProgress) {
        progressDialog = new ProgressDialog(context);
        if (title == null) {
            progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        } else {
            progressDialog.setTitle(title);
        }
        progressDialog.setMessage(message);
        progressDialog.setCancelable(cancelable);
        if (max == null) {
            progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progressDialog.setIndeterminate(true);
        } else {
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setIndeterminate(false);
            progressDialog.setProgress(0);
            progressDialog.setMax(max);
        }
        progressDialog.show();
    }
}
 
Example 3
Source File: FirHelper.java    From HaiNaBaiChuan with Apache License 2.0 6 votes vote down vote up
public static void show(Context context) {
    // 创建进度对话框
    pd = new ProgressDialog(context);
    pd.setMax(100);
    // 设置对话框标题
    pd.setTitle("下载更新");
    // 设置对话框显示的内容
    pd.setMessage("进度...");
    // 设置对话框不能用取"消按"钮关闭
    pd.setCancelable(false);
    // 设置对话框的进度条风格
    // pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    // 设置对话框的进度条是否显示进度
    pd.setIndeterminate(false);
    pd.show();
}
 
Example 4
Source File: ProgressFragmentDialog.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setRetainInstance(true);

    Bundle bundle = getArguments();
    if (bundle != null) {
        mMessage = bundle.getString(kParamMessage);
    }

    mDialog = new ProgressDialog(getActivity());
    mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mDialog.setMax(100);
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setCancelable(true);

    updateUI();

    return mDialog;
}
 
Example 5
Source File: MainActivity.java    From BaoKanAndroid with MIT License 5 votes vote down vote up
/**
 * 弹出下载对话框
 */
public void showDownloadDialog() {
    mDownloadDialog = new ProgressDialog(mContext);
    mDownloadDialog.setIcon(R.mipmap.ic_launcher);
    mDownloadDialog.setTitle("版本更新");
    mDownloadDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mDownloadDialog.setMessage("正在玩命下载中......");
    mDownloadDialog.getWindow().setGravity(Gravity.CENTER);
    mDownloadDialog.setMax(100);
    mDownloadDialog.show();
}
 
Example 6
Source File: MainActivity.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
/**
 * 弹出下载对话框
 */
public void showDownloadDialog() {
    mDownloadDialog = new ProgressDialog(mContext);
    mDownloadDialog.setIcon(R.mipmap.ic_launcher);
    mDownloadDialog.setTitle("版本更新");
    mDownloadDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mDownloadDialog.setMessage("正在玩命下载中......");
    mDownloadDialog.getWindow().setGravity(Gravity.CENTER);
    mDownloadDialog.setMax(100);
    mDownloadDialog.show();
}
 
Example 7
Source File: ProgressDialogFragment.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@NonNull @Override 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;
}
 
Example 8
Source File: MailChatterCompose.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();
    progressDialog = new ProgressDialog(MailChatterCompose.this);
    progressDialog.setTitle(R.string.title_working);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMessage("Uploading attachments...");
    progressDialog.setMax(horizontalScrollView.getChildCount());
    progressDialog.setCancelable(false);
    progressDialog.setProgress(1);
    progressDialog.show();
}
 
Example 9
Source File: MainActivity.java    From QNRTC-Android with Apache License 2.0 5 votes vote down vote up
private void createProgressDialog() {
    mProgressDialog = new ProgressDialog(MainActivity.this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(getString(R.string.updating));
    mProgressDialog.setIndeterminate(false);
    mProgressDialog.setMax(100);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setCanceledOnTouchOutside(false);
    mProgressDialog.show();
}
 
Example 10
Source File: UploadHelper.java    From LollipopShowcase with Apache License 2.0 5 votes vote down vote up
public void showProgress(Activity act) {
    mProgressDialog = new ProgressDialog(act);
    mProgressDialog.setTitle(R.string.dialog_uploading);
    mProgressDialog.setMessage(act.getString(R.string.dialog_processinganduploading));
    mProgressDialog.setIndeterminate(false);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMax(applicationList.size());
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.show();
}
 
Example 11
Source File: FontListFragment.java    From fontster with Apache License 2.0 5 votes vote down vote up
private void downloadFontList() {
  final boolean previewsCached = mPreferences.getBoolean(Key.TRUEFONTS_CACHED);

  if (!previewsCached) {
    mProgressDialog = new ProgressDialog(mActivity);
    mProgressDialog.setMessage(mActivity.getString(R.string.font_list_download_progress));
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setMax(mFontList.size());
    mProgressDialog.show();
  }

  if (mErrorContainer.getVisibility() == View.VISIBLE) mErrorContainer.setVisibility(View.GONE);
  mDownloadProgress.setVisibility(View.VISIBLE);

  final List<FontPackage> fontPackages = new ArrayList<>(mFontList.size());
  for (String fontName : mFontList) fontPackages.add(new FontPackage(fontName));

  FontDownloader.downloadStyleFromPackages(fontPackages, Style.REGULAR)
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(
          font -> {
            Timber.i("downloadFontList: onNext: " + font.getParentFile().getName());
            if (mProgressDialog != null) mProgressDialog.incrementProgressBy(1);
          },
          this::handleDownloadFailure,
          this::handleDownloadSuccess);
}
 
Example 12
Source File: NovelReaderActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNC() {
	List<NameValuePair> targVar = new ArrayList<NameValuePair>();
	targVar.add(Wenku8Interface.getNovelContent(currentAid, currentCid,
			GlobalConfig.getFetchLanguage()));

	final asyncNovelContentTask ast = new asyncNovelContentTask();
	ast.execute(targVar);

	pDialog = new ProgressDialog(parentActivity);
	pDialog.setTitle(getResources().getString(R.string.load_status));
	pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	pDialog.setCancelable(true);
	pDialog.setOnCancelListener(new OnCancelListener() {
		@Override
		public void onCancel(DialogInterface dialog) {
			// TODO Auto-generated method stub
			ast.cancel(true);
			pDialog.dismiss();
			pDialog = null;
		}

	});
	pDialog.setMessage(getResources().getString(R.string.load_loading));
	pDialog.setProgress(0);
	pDialog.setMax(1);
	pDialog.show();

	return;
}
 
Example 13
Source File: DownloadFromUrlActivity.java    From Instagram-Profile-Downloader with MIT License 5 votes vote down vote up
protected void onPreExecute() {
    super.onPreExecute();
    progressDialog = new ProgressDialog(context);
    progressDialog.setMessage("Downloading video...");
    progressDialog.setProgressStyle(1);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setMax(100);
    progressDialog.show();
    //Toast.makeText(getActivity(), "Downloading video....", Toast.LENGTH_SHORT).show();
}
 
Example 14
Source File: ProgressDialogFragment.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@NonNull @Override 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;
}
 
Example 15
Source File: DownloadIGTVFragment.java    From Instagram-Profile-Downloader with MIT License 5 votes vote down vote up
protected void onPreExecute() {
    super.onPreExecute();
    progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage("Downloading ...");
    progressDialog.setProgressStyle(1);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setMax(100);
    progressDialog.show();
    //Toast.makeText(getActivity(), "Downloading video....", Toast.LENGTH_SHORT).show();
}
 
Example 16
Source File: MainActivity.java    From MalwareBuster with Apache License 2.0 5 votes vote down vote up
@SuppressLint("DefaultLocale")
private void loadApps(ProgressDialog dialog) {

    appList.clear();

    PackageManager pm = getPackageManager();
    List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);
    dialog.setMax(pkgs.size());
    int i = 1;
    for (PackageInfo pkgInfo : pkgs) {
        dialog.setProgress(i++);

        if ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)
            continue;

        ApplicationInfo appInfo = pkgInfo.applicationInfo;
        if (appInfo == null)
            continue;

        appInfo.name = appInfo.loadLabel(pm).toString();
        appList.add(appInfo);
    }

    Collections.sort(appList, new Comparator<ApplicationInfo>() {
        @Override
        public int compare(ApplicationInfo lhs, ApplicationInfo rhs) {
            if (lhs.name == null) {
                return -1;
            } else if (rhs.name == null) {
                return 1;
            } else {
                return lhs.name.toUpperCase().compareTo(rhs.name.toUpperCase());
            }
        }
    });
}
 
Example 17
Source File: BottomSheetSlotsDialogFragment.java    From intra42 with Apache License 2.0 5 votes vote down vote up
private boolean deleteSlot(ProgressDialog progressDialog) {
    if (!deleteSlotCanBeProceed(progressDialog)) return true;
    SparseArray<Slots> verifySlots = deleteSlotGetVerificationData();

    boolean isSuccess = true;
    progressDialog.setMax(slotsGroup.group.size());
    int i = 0;

    for (Slots slot : slotsGroup.group) {
        progressDialog.setProgress(i);
        ++i;

        Slots apiData = verifySlots.get(slot.id);
        if (apiData != null && apiData.isBooked != slot.isBooked) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(activity, R.string.slots_delete_dialog_error_booked, Toast.LENGTH_SHORT).show();
                }
            });
            continue;
        }

        ApiService api = app.getApiService();
        Call<Slots> call = api.destroySlot(slot.id);

        try {
            if (!call.execute().isSuccessful())
                isSuccess = false;
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (dialogFragment.isAdded() && !dialogFragment.isStateSaved())
        progressDialog.dismiss();
    return isSuccess;
}
 
Example 18
Source File: IndexerTask.java    From geopackage-mapcache-android with MIT License 5 votes vote down vote up
/**
 * Index features
 *
 * @param activity
 * @param callback
 * @param database
 * @param tableName
 * @param indexLocation
 */
public static void indexFeatures(Activity activity, IIndexerTask callback,
                                 String database, String tableName,
                                 FeatureIndexType indexLocation) {

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);
    GeoPackage geoPackage = manager.open(database);

    FeatureDao featureDao = geoPackage.getFeatureDao(tableName);

    FeatureIndexManager indexer = new FeatureIndexManager(activity, geoPackage, featureDao);
    indexer.setIndexLocation(indexLocation);

    ProgressDialog progressDialog = new ProgressDialog(activity);
    final IndexerTask indexTask = new IndexerTask(activity,
            callback, progressDialog, geoPackage, indexer);

    int max = featureDao.count();
    indexTask.setMax(max);
    indexer.setProgress(indexTask);

    progressDialog.setMessage(activity
            .getString(R.string.geopackage_table_index_features_index_title)
            + ": "
            + geoPackage.getName() + " - " + tableName);
    progressDialog.setCancelable(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setMax(max);
    progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
            activity.getString(R.string.button_cancel_label),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    indexTask.cancel(true);
                }
            });

    indexTask.execute();
}
 
Example 19
Source File: MainActivity.java    From XposedAppLocale with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    prefsFile.setReadable(true, false);
    mPrefs = getSharedPreferences(Common.PREFS, Context.MODE_WORLD_READABLE);

    languages = new ArrayList<>();
    LocaleList localeList = new LocaleList(getApplicationContext(), "");
    languages.addAll(localeList.getDescriptionList());
    languages.remove(0);

    checkItems = new boolean[languages.size()];
    String[] langs = mPrefs.getString("languages", "").split(",");
    for (int i = 0; i < langs.length; i++) {
        int index = languages.indexOf(localeList.getDescriptionList().get(localeList.getLocalePos(langs[i])));
        if (index > -1) {
            checkItems[index] = true;
        }
    }

    tmpCheckItems = Arrays.copyOf(checkItems, checkItems.length);

    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerDecoration(this));

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mRecyclerView.scrollToPosition(0);
        }
    });

    pm = getPackageManager();
    List<PackageInfo> packages = pm.getInstalledPackages(0);

    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setMax(packages.size());
    mProgressDialog.setMessage(getString(R.string.loading_apps));
    mProgressDialog.setCancelable(false);

    new GetAppsTask().execute(packages);
}
 
Example 20
Source File: QiscusPhotoViewerActivity.java    From qiscus-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_qiscus_photo_viewer);

    presenter = new QiscusPhotoViewerPresenter(this);

    toolbar = findViewById(R.id.toolbar);
    tvTitle = findViewById(R.id.tv_title);
    viewPager = findViewById(R.id.view_pager);
    progressBar = findViewById(R.id.progress_bar);
    senderName = findViewById(R.id.sender_name);
    date = findViewById(R.id.date);
    ImageButton shareButton = findViewById(R.id.action_share);
    infoPanel = findViewById(R.id.info_panel);
    fadein = AnimationUtils.loadAnimation(this, R.anim.qiscus_fadein);
    fadeout = AnimationUtils.loadAnimation(this, R.anim.qiscus_fadeout);

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage(getString(R.string.qiscus_downloading));
    progressDialog.setMax(100);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setOnCancelListener(dialog -> {
        presenter.cancelDownloading();
        showError(getString(R.string.qiscus_redownload_canceled));
        if (ongoingDownload != null) {
            ongoingDownload.setDownloadingListener(null);
            ongoingDownload.setProgressListener(null);
        }
    });

    findViewById(R.id.back).setOnClickListener(v -> onBackPressed());
    setSupportActionBar(toolbar);
    viewPager.addOnPageChangeListener(this);

    resolveData(savedInstanceState);

    presenter.loadQiscusPhotos(qiscusComment.getRoomId());

    if (!Qiscus.getChatConfig().isEnableShareMedia()) {
        shareButton.setVisibility(View.GONE);
    }

    shareButton.setOnClickListener(v -> {
        Pair<QiscusComment, File> qiscusPhoto = qiscusPhotos.get(position);
        shareImage(qiscusPhoto.second);
    });
}