@Override public void handleDownloadThreadUpdate() { handler.post( new Runnable() { @Override public void run() { // total_files_to_download = downloadThread.getTotalQueued(); total_files_to_download = links.size(); if (downloadThread != null) { completed_downloads = downloadThread.getTotalCompleted() + initial_value; } else { completed_downloads = readProgress()[0]; } progress_download.setMax(links.size()); // progress_download.incrementProgressBy(1); progress_download.setProgress(0); // need to do it due to a ProgressBar bug progress_download.setProgress(completed_downloads); progress_text.setText( "Downloading " + Integer.toString(completed_downloads + 1) + " of " + Integer.toString(links.size()) + "."); // writeProgress(completed_downloads,total_files_to_download); if (completed_downloads == total_files_to_download) { completed = true; writeProgress(completed_downloads, total_files_to_download); if (resume_pause.VISIBLE != View.GONE) resume_pause.setVisibility(View.GONE); downloadThread.requestStop(); progress_text.setText("Completed."); } } }); }
// Send a message from the SDLMain thread boolean sendCommand(int command, Object data) { Message msg = commandHandler.obtainMessage(); msg.arg1 = command; msg.obj = data; return commandHandler.sendMessage(msg); }