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();
}
}
});
});
}
Aggregations