void prepareView() { if (myTree == null) { myTree = NetworkLibrary.Instance().getRootTree(); setListAdapter(new LibraryAdapter()); getListView().invalidateViews(); } }
private void runLanguageFilterDialog() { final NetworkLibrary library = NetworkLibrary.Instance(); final List<String> allLanguageCodes = library.languageCodes(); Collections.sort(allLanguageCodes, new ZLLanguageUtil.CodeComparator()); final Collection<String> activeLanguageCodes = library.activeLanguageCodes(); final CharSequence[] languageNames = new CharSequence[allLanguageCodes.size()]; final boolean[] checked = new boolean[allLanguageCodes.size()]; for (int i = 0; i < allLanguageCodes.size(); ++i) { final String code = allLanguageCodes.get(i); languageNames[i] = ZLLanguageUtil.languageName(code); checked[i] = activeLanguageCodes.contains(code); } final DialogInterface.OnMultiChoiceClickListener listener = new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int which, boolean isChecked) { checked[which] = isChecked; } }; final ZLResource dialogResource = ZLResource.resource("dialog"); final AlertDialog dialog = new AlertDialog.Builder(this) .setMultiChoiceItems(languageNames, checked, listener) .setTitle( dialogResource.getResource("languageFilterDialog").getResource("title").getValue()) .setPositiveButton( dialogResource.getResource("button").getResource("ok").getValue(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { final TreeSet<String> newActiveCodes = new TreeSet<String>(new ZLLanguageUtil.CodeComparator()); for (int i = 0; i < checked.length; ++i) { if (checked[i]) { newActiveCodes.add(allLanguageCodes.get(i)); } } library.setActiveLanguageCodes(newActiveCodes); library.synchronize(); NetworkView.Instance().fireModelChanged(); } }) .create(); dialog.show(); }
@Override public boolean onSearchRequested() { if (searchIsInProgress()) { return false; } final NetworkLibrary library = NetworkLibrary.Instance(); startSearch(library.NetworkSearchPatternOption.getValue(), true, null, false); return true; }
@Override protected void onStart() { super.onStart(); myAllItems.clear(); final Intent intent = getIntent(); myAllItems.add(new SectionItem("enabled")); final List<String> enabledIds = intent.getStringArrayListExtra(NetworkLibraryActivity.ENABLED_CATALOG_IDS_KEY); if (enabledIds.size() > 0) { final TreeSet<CatalogItem> cItems = new TreeSet<CatalogItem>(); for (String id : enabledIds) { final NetworkTree tree = NetworkLibrary.Instance().getCatalogTreeByUrlAll(id); if (tree != null && tree.getLink() != null) { cItems.add(new CatalogItem(id, true, tree)); } } myAllItems.addAll(cItems); mySelectedItems.addAll(cItems); } myAllItems.add(new SectionItem("disabled")); final List<String> disabledIds = intent.getStringArrayListExtra(NetworkLibraryActivity.DISABLED_CATALOG_IDS_KEY); if (disabledIds.size() > 0) { final TreeSet<CatalogItem> cItems = new TreeSet<CatalogItem>(); for (String id : disabledIds) { cItems.add( new CatalogItem(id, false, NetworkLibrary.Instance().getCatalogTreeByUrlAll(id))); } myAllItems.addAll(cItems); } setListAdapter(new CatalogsListAdapter()); }
private static boolean searchIsInProgress() { return ItemsLoadingService.getRunnable(NetworkLibrary.Instance().getSearchItemTree()) != null; }
public SectionItem(String key) { Title = NetworkLibrary.resource().getResource("manageCatalogs").getResource(key).getValue(); }