@Override public boolean onChildClick( ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { final IndexItem e = (IndexItem) ((DownloadIndexAdapter) getListAdapter()).getChild(groupPosition, childPosition); String key = e.getFileName(); final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item); if (ch.isChecked()) { ch.setChecked(!ch.isChecked()); entriesToDownload.remove(key); if (entriesToDownload.isEmpty()) { int x = getListView().getScrollX(); int y = getListView().getScrollY(); findViewById(R.id.DownloadButton).setVisibility(View.GONE); getListView().scrollTo(x, y); } return true; } final DownloadEntry entry = e.createDownloadEntry(DownloadIndexActivity.this); if (entry != null) { // if(!fileToUnzip.exists()){ // builder.setMessage(MessageFormat.format(getString(R.string.download_question), baseName, // extractDateAndSize(e.getValue()))); entriesToDownload.put(e.getFileName(), entry); int x = getListView().getScrollX(); int y = getListView().getScrollY(); findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE); getListView().scrollTo(x, y); ch.setChecked(!ch.isChecked()); } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == RELOAD_ID) { // re-create the thread downloadListIndexThread = new DownloadIndexListThread(this); downloadIndexList(); } else { final DownloadIndexAdapter listAdapter = (DownloadIndexAdapter) getExpandableListAdapter(); if (item.getItemId() == SELECT_ALL_ID) { int selected = 0; for (int i = 0; i < listAdapter.getChildrenCount(0); i++) { IndexItem es = listAdapter.getChild(0, i); if (!entriesToDownload.containsKey(es.getFileName())) { selected++; entriesToDownload.put( es.getFileName(), es.createDownloadEntry(DownloadIndexActivity.this)); } } AccessibleToast.makeText( this, MessageFormat.format(getString(R.string.items_were_selected), selected), Toast.LENGTH_SHORT) .show(); listAdapter.notifyDataSetInvalidated(); if (selected > 0) { findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE); } } else if (item.getItemId() == FILTER_EXISTING_REGIONS) { final Collection<String> listAlreadyDownloaded = listAlreadyDownloadedWithAlternatives(); final List<IndexItem> filtered = new ArrayList<IndexItem>(); for (String file : listAlreadyDownloaded) { IndexItem fileItem = listAdapter.getIndexFiles().get(file); if (fileItem != null) { filtered.add(fileItem); } } listAdapter.setIndexFiles(filtered); } else if (item.getItemId() == DESELECT_ALL_ID) { entriesToDownload.clear(); listAdapter.notifyDataSetInvalidated(); findViewById(R.id.DownloadButton).setVisibility(View.GONE); } else { return false; } } return true; }