Пример #1
0
  public void add(LinkFilter linkCount, Util.Lang lang) {

    // make sure linkCount is unique. technically should be overriding equals() in LinkFilter, but
    // this actually isn't a strict definition right n
    boolean exists = false;
    ListIterator<LinkFilter> linkIt = linkSelectorQueue.listIterator(0);
    while (linkIt.hasNext()) {
      LinkFilter tempLC = linkIt.next();
      if (LinkFilter.pseudoEquals(tempLC, linkCount)) {
        exists = true;
        break;
      }
    }
    if (!exists) {
      if (linkSelectorQueue.size() >= MAX_NUM_LINK_SELECTORS) linkSelectorQueue.remove();
      linkSelectorQueue.add(linkCount);
    }

    update(linkCount, lang);
  }
Пример #2
0
  // if currLinkCount == null, all linkSelectorBarButtons will be gray
  public void update(LinkFilter currLinkCount, Util.Lang lang) {
    this.currLinkCount = currLinkCount;
    selectorListLayout.removeAllViews();
    if (linkSelectorQueue == null) return;
    ListIterator<LinkFilter> linkIt = linkSelectorQueue.listIterator(linkSelectorQueue.size());
    while (linkIt.hasPrevious()) {
      // add children in reverse order
      LinkFilter tempLC = linkIt.previous();
      LinkSelectorBarButton lssb =
          new LinkSelectorBarButton(activity, tempLC, activity.getBook(), lang);
      lssb.setOnClickListener(linkSelectorBarButtonClick);
      selectorListLayout.addView(lssb);

      if (!LinkFilter.pseudoEquals(tempLC, currLinkCount)) {
        lssb.setTextColor(Util.getColor(activity, R.attr.text_chapter_header_color));
      }
    }

    Settings.Link.setLinks(activity.getBook().getTitle(Util.Lang.EN), linkSelectorQueue);
  }
Пример #3
0
 // segment is used to update segment list
 public void setCurrLinkCount(LinkFilter linkCount, Segment segment) {
   // try not to update too often
   if (!linkCount.equals(currLinkCount)) {
     currLinkCount = linkCount;
     if (segment
         != null) // o/w no need to update itemList. You probably just initialized LinkTextAdapter
     try {
         setItemList(Link.getLinkedTexts(segment, currLinkCount));
       } catch (API.APIException e) {
         setItemList(new ArrayList<Segment>());
         API.makeAPIErrorToast(activity);
       } catch (Exception e) {
         setItemList(new ArrayList<Segment>());
         try {
           Toast.makeText(
                   activity, MyApp.getRString(R.string.error_getting_links), Toast.LENGTH_SHORT)
               .show();
         } catch (Exception e1) {
           e1.printStackTrace();
         }
       }
   }
 }