Search in sources :

Example 1 with MaterialProgressBar

use of me.zhanghai.android.materialprogressbar.MaterialProgressBar in project Shuttle by timusus.

the class CustomMediaScanner method scanFile.

// Todo: Remove context requirement
public static Disposable scanFile(Context context, FolderObject folderObject) {
    @SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.dialog_progress, null);
    TextView pathsTextView = view.findViewById(R.id.paths);
    pathsTextView.setText(folderObject.path);
    MaterialProgressBar indeterminateProgress = view.findViewById(R.id.indeterminateProgress);
    MaterialProgressBar horizontalProgress = view.findViewById(R.id.horizontalProgress);
    MaterialDialog dialog = new MaterialDialog.Builder(context).title(R.string.scanning).customView(view, false).negativeText(R.string.close).show();
    return FileHelper.getPathList(new File(folderObject.path), true, false).observeOn(AndroidSchedulers.mainThread()).subscribe(paths -> {
        ViewUtils.fadeOut(indeterminateProgress, null);
        ViewUtils.fadeIn(horizontalProgress, null);
        horizontalProgress.setMax(paths.size());
        CustomMediaScanner.scanFiles(context, paths, new ScanCompletionListener() {

            @Override
            public void onPathScanned(String path) {
                horizontalProgress.setProgress(horizontalProgress.getProgress() + 1);
                pathsTextView.setText(path);
            }

            @Override
            public void onScanCompleted() {
                if (dialog.isShowing()) {
                    dialog.dismiss();
                }
            }
        });
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) MaterialProgressBar(me.zhanghai.android.materialprogressbar.MaterialProgressBar) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) File(java.io.File)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 TextView (android.widget.TextView)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 File (java.io.File)1 MaterialProgressBar (me.zhanghai.android.materialprogressbar.MaterialProgressBar)1