Пример #1
0
 @Override
 public void downloadedIndexes() {
   for (WeakReference<Fragment> ref : fragList) {
     Fragment f = ref.get();
     if (f instanceof LocalIndexesFragment) {
       if (!f.isDetached()) {
         ((LocalIndexesFragment) f).reloadData();
       }
     } else if (f instanceof DownloadIndexFragment) {
       if (!f.isDetached()) {
         DownloadIndexAdapter adapter =
             ((DownloadIndexAdapter) ((DownloadIndexFragment) f).getExpandableListAdapter());
         if (adapter != null) {
           adapter.setLoadedFiles(getIndexActivatedFileNames(), getIndexFileNames());
         }
       }
     }
   }
 }
Пример #2
0
 @Override
 protected void onPostExecute(String result) {
   if (result != null && result.length() > 0) {
     AccessibleToast.makeText(ctx, result, Toast.LENGTH_LONG).show();
   }
   currentDownloads.clear();
   if (uiActivity != null) {
     View mainView = uiActivity.findViewById(R.id.MainLayout);
     if (mainView != null) {
       mainView.setKeepScreenOn(false);
     }
     DownloadIndexAdapter adapter =
         ((DownloadIndexAdapter) uiActivity.getExpandableListAdapter());
     if (adapter != null) {
       adapter.setLoadedFiles(indexActivatedFileNames, indexFileNames);
     }
   }
   currentRunningTask.remove(this);
   if (uiActivity != null) {
     uiActivity.updateProgress(false);
   }
 }
Пример #3
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == RELOAD_ID) {
     // re-create the thread
     downloadListIndexThread = new DownloadIndexListThread();
     downloadIndexList();
   } else {
     final DownloadIndexAdapter listAdapter = (DownloadIndexAdapter) getListAdapter();
     if (item.getItemId() == SELECT_ALL_ID) {
       int selected = 0;
       for (int i = 0; i < listAdapter.getCount(); i++) {
         IndexItem es = listAdapter.getItem(i);
         if (!entriesToDownload.containsKey(es.getFileName())) {
           selected++;
           entriesToDownload.put(es.getFileName(), createDownloadEntry(es));
         }
       }
       Toast.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.clear();
       for (IndexItem fileItem : filtered) {
         listAdapter.add(fileItem);
       }
     } else if (item.getItemId() == DESELECT_ALL_ID) {
       entriesToDownload.clear();
       listAdapter.notifyDataSetInvalidated();
       findViewById(R.id.DownloadButton).setVisibility(View.GONE);
     } else {
       return false;
     }
   }
   return true;
 }