I try to call the dialog for the duration of the file upload queue. It does not work, what's the problem?
private void DownloadFilesBook(String[] urlsFiles) { final Fetch mFetch = Fetch.newInstance(this); String folderB = "bookfiles_" + bookId; String fileNameForWrite = "book_" + bookId + ".json"; mFetch.addFetchListener(new FetchListener() { @Override public void onUpdate(long id, int status, int progress, long downloadedBytes, long fileSize, int error) { if(id == downloadId) { switch (status) { case Fetch.STATUS_DOWNLOADING: { mProgressDialog = new ProgressDialog(getApplicationContext()); mProgressDialog.setMessage("Идет загрузка..."); //do work like update progress // break; } case Fetch.STATUS_ERROR: { //Check error and take action. Retry?fetch.retry(downloadId); break; } default: //general action } } } }); File bookfolder = new File(String.valueOf(getExternalFilesDir(folderB))); List<Request> requestListPages = new ArrayList<>(); ArrayList<String> pagesFiles = new ArrayList<>(); // String resultD; // mFetch = Fetch.newInstance(getApplicationContext()); // mFetch.removeRequests(); //чистим базу запросов 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); requestListPages.add(request); String pageFilePath = path + "/" + fileName; Log.d("my2", pageFilePath); pagesFiles.add(pageFilePath); } mFetch.enqueue(requestListPages); BookFiles bookFiles = new BookFiles(); bookFiles.setBookID(bookId); ArrayList<String> pagesPath = getPagesArray(pagesFiles); ArrayList<String> soundsPath = getSoundsArray(pagesFiles); bookFiles.setPagesPath(pagesPath); bookFiles.setSoundsPath(soundsPath); Gson gson11 = new Gson(); String filesJson = gson11.toJson(bookFiles); MyJSON.saveData(getApplicationContext(), filesJson, fileNameForWrite); }