@Override public boolean onChildClick( ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { final IndexItem e = (IndexItem) ((DownloadIndexAdapter) getListAdapter()).getChild(groupPosition, childPosition); final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item); if (ch.isChecked()) { ch.setChecked(!ch.isChecked()); getEntriesToDownload().remove(e); updateDownloadButton(true); return true; } List<DownloadEntry> download = e.createDownloadEntry(getClientContext(), type, new ArrayList<DownloadEntry>()); if (download.size() > 0) { // if(!fileToUnzip.exists()){ // builder.setMessage(MessageFormat.format(getString(R.string.download_question), baseName, // extractDateAndSize(e.getValue()))); getEntriesToDownload().put(e, download); updateDownloadButton(true); ch.setChecked(!ch.isChecked()); } return true; }
public void updateProgress(boolean updateOnlyProgress) { BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = downloadListIndexThread.getCurrentRunningTask(); if (updateOnlyProgress) { if (!basicProgressAsyncTask.isIndeterminate()) { progressPercent.setText(basicProgressAsyncTask.getProgressPercentage() + "%"); determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage()); } } else { boolean visible = basicProgressAsyncTask != null && basicProgressAsyncTask.getStatus() != Status.FINISHED; progressView.setVisibility(visible ? View.VISIBLE : View.GONE); if (visible) { boolean indeterminate = basicProgressAsyncTask.isIndeterminate(); indeterminateProgressBar.setVisibility(!indeterminate ? View.GONE : View.VISIBLE); determinateProgressBar.setVisibility(indeterminate ? View.GONE : View.VISIBLE); cancel.setVisibility(indeterminate ? View.GONE : View.VISIBLE); progressPercent.setVisibility(indeterminate ? View.GONE : View.VISIBLE); progressMessage.setText(basicProgressAsyncTask.getDescription()); if (!indeterminate) { progressPercent.setText(basicProgressAsyncTask.getProgressPercentage() + "%"); determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage()); } } updateDownloadButton(false); } }
private void selectAll() { final DownloadIndexAdapter listAdapter = (DownloadIndexAdapter) getExpandableListAdapter(); int selected = 0; for (int j = 0; j < listAdapter.getGroupCount(); j++) { for (int i = 0; i < listAdapter.getChildrenCount(j); i++) { IndexItem es = listAdapter.getChild(j, i); if (!getEntriesToDownload().containsKey(es)) { selected++; getEntriesToDownload() .put( es, es.createDownloadEntry( getClientContext(), type, new ArrayList<DownloadEntry>(1))); } } } AccessibleToast.makeText( this, MessageFormat.format(getString(R.string.items_were_selected), selected), Toast.LENGTH_SHORT) .show(); listAdapter.notifyDataSetInvalidated(); if (selected > 0) { updateDownloadButton(true); } }