-
- combos.add(combo);
- tagBars.add(combo);
- }
-
- // async, add children of tag, NULL = base tags
- private void addTagBar(final SearchableTag tag, final Runnable inUi) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- BasicSearchable searchable = BasicSearchable
- .getSearchable(supportType);
-
- List<SearchableTag> children = new ArrayList<SearchableTag>();
- if (tag == null) {
- try {
- List<SearchableTag> baseTags = searchable.getTags();
- children = baseTags;
- } catch (IOException e) {
- error(e);
- }
- } else {
- try {
- searchable.fillTag(tag);
- } catch (IOException e) {
- error(e);
- }
-
- if (!tag.isLeaf()) {
- children = tag.getChildren();
- } else {
- children = null;
- }
- }
-
- final List<SearchableTag> fchildren = children;
- inUi(new Runnable() {
- @Override
- public void run() {
- if (fchildren != null) {
- addTagBar(fchildren, tag);
- }
-
- if (inUi != null) {
- inUi.run();
- }
- }
- });
- }
- }).start();
- }
-
- // item 0 = no selection, else = default selection
- public void search(final SupportType searchOn, final String keywords,
- final int page, final int item) {
-
- setWaitingScreen(true);
-
- updateSupportType(searchOn);
- updateSearchBy(false);
- updateKeywords(keywords);
- updatePages(page, maxPage);
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- BasicSearchable search = BasicSearchable
- .getSearchable(searchOn);
-
- int maxPage = -1;
- try {
- maxPage = search.searchPages(keywords);
- } catch (IOException e) {
- error(e);
- }
-
- if (page <= 0) {
- updateBooks(new ArrayList<GuiReaderBookInfo>());
- updatePages(0, maxPage);
- } else {
- List<MetaData> results;
- try {
- results = search.search(keywords, page);
- } catch (IOException e) {
- error(e);
- results = new ArrayList<MetaData>();
- }
-
- search(results, page, maxPage, item);
-
- // ! 1-based index !
- if (item > 0 && item <= books.getBooksCount()) {
- // TODO: "click" on item ITEM
- }
- }
-
- setWaitingScreen(false);
- }
- }).start();