How to block Activity at the time of loading of files?

Hello! I have an activity that displays a button to download the books from the server. When the button is clicked I want to show progressbar on all the time while the files are downloaded. In General, a typical problem. But files loaded few, by using libraries . And I can't figure out how to block the action in the activity and bring the progressbar to the loading time of ALL files. Library downloads files in a separate thread.
Maybe I should ship the files directly in the UI thread, without the library? Then definitely the user will not do anything until the files are loaded. But this is a bad idea, IMHO, if the connection is not very going failures.
Prompt, in what side to "dig", maybe there are some examples?

Here is the method I have loads of files and records in the memory:

private void downloadFilesBook(String[] urlsFiles) {
 mFetch = Fetch.newInstance(this);
 String folderB = "bookfiles_" + bookId;
 String fileNameForWrite = "book_" + bookId + ".json";

 File bookfolder = new File(String.valueOf(getExternalFilesDir(folderB)));
 ArrayList<string> pagesFiles = new ArrayList<>();

 for (int i = 0; i < urlsFiles.length; i++) {
 String url = urlsFiles[i];
 String path = String.valueOf(bookfolder);
 String fileName = Uri.parse(url).getLastPathSegment();
 Log.d("my2", fileName);
 Request request = new Request(url, path, fileName);
 PageFilePath String = path + "/" + fileName;
 Log.d("my2", pageFilePath);
 downloadId = mFetch.enqueue(request);

 BookFiles bookFiles = new BookFiles();

 ArrayList<string> pagesPath = getPagesArray(pagesFiles);
 ArrayList<string> soundsPath = getSoundsArray(pagesFiles);

 Gson11 Gson = new Gson();
 String filesJson = gson11.toJson(bookFiles);

 MyJSON.saveData(getApplicationContext(), filesJson, fileNameForWrite);
June 8th 19 at 17:08
1 answer
June 8th 19 at 17:10
you can use ProgressDialog - putting setCancelable(false) in the Builder.
or, preferably, to do a custom DialogFragment that mDialog.setCancelable(false) in onCreateDialog()
progressdialog deprecated - Rowland.Gulgowski12 commented on June 8th 19 at 17:13

Find more questions by tags Android