public void run() {
    final ZLTextHyperlink hyperlink = Reader.getTextView().getCurrentHyperlink();
    if (hyperlink != null) {
      switch (hyperlink.Type) {
        case FBHyperlinkType.EXTERNAL:
          openInBrowser(hyperlink.Id);
          break;
        case FBHyperlinkType.INTERNAL:
          Reader.tryOpenFootnote(hyperlink.Id);
          break;
      }
      return;
    }

    DictionaryUtil.openWordInDictionary(myBaseActivity, Reader.getTextView().getSelectedText());
  }
Ejemplo n.º 2
0
  @Override
  protected void run(Object... params) {
    final ZLTextRegion region = Reader.getTextView().getSelectedRegion();
    if (region == null) {
      return;
    }

    final ZLTextRegion.Soul soul = region.getSoul();
    if (soul instanceof ZLTextHyperlinkRegionSoul) {
      Reader.getTextView().hideSelectedRegionBorder();
      Reader.getViewWidget().repaint();
      final ZLTextHyperlink hyperlink = ((ZLTextHyperlinkRegionSoul) soul).Hyperlink;
      switch (hyperlink.Type) {
        case FBHyperlinkType.EXTERNAL:
          openInBrowser(hyperlink.Id);
          break;
        case FBHyperlinkType.INTERNAL:
          Reader.Model.Book.markHyperlinkAsVisited(hyperlink.Id);
          Reader.tryOpenFootnote(hyperlink.Id);
          break;
      }
    } else if (soul instanceof ZLTextImageRegionSoul) {
      Reader.getTextView().hideSelectedRegionBorder();
      Reader.getViewWidget().repaint();
      final String uriString = ((ZLTextImageRegionSoul) soul).ImageElement.URI;
      if (uriString != null) {
        try {
          final Intent intent = new Intent();
          intent.setClass(BaseActivity, ImageViewActivity.class);
          intent.setData(Uri.parse(uriString));
          intent.putExtra(
              ImageViewActivity.BACKGROUND_COLOR_KEY,
              Reader.ImageViewBackgroundOption.getValue().getIntValue());
          BaseActivity.startActivity(intent);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    } else if (soul instanceof ZLTextWordRegionSoul) {
      DictionaryUtil.openWordInDictionary(BaseActivity, ((ZLTextWordRegionSoul) soul).Word, region);
    }
  }
Ejemplo n.º 3
0
 public void run() {
   final ZLTextElementRegion region = Reader.getTextView().getSelectedRegion();
   if (region instanceof ZLTextHyperlinkRegion) {
     Reader.getTextView().hideSelectedRegionBorder();
     Reader.getViewWidget().repaint();
     final ZLTextHyperlink hyperlink = ((ZLTextHyperlinkRegion) region).Hyperlink;
     switch (hyperlink.Type) {
       case FBHyperlinkType.EXTERNAL:
         if (hyperlink.Id.startsWith(ACTION_LINK_PREFIX)) {
           Reader.doAction(hyperlink.Id.substring(ACTION_LINK_PREFIX.length()));
         } else {
           openInBrowser(hyperlink.Id);
         }
         break;
       case FBHyperlinkType.INTERNAL:
         Reader.Model.Book.markHyperlinkAsVisited(hyperlink.Id);
         Reader.tryOpenFootnote(hyperlink.Id);
         break;
     }
   } else if (region instanceof ZLTextImageRegion) {
     Reader.getTextView().hideSelectedRegionBorder();
     Reader.getViewWidget().repaint();
     final String uriString = ((ZLTextImageRegion) region).ImageElement.URI;
     if (uriString != null) {
       try {
         final Intent intent = new Intent();
         intent.setClass(myBaseActivity, ImageViewActivity.class);
         intent.setData(Uri.parse(uriString));
         intent.putExtra(
             ImageViewActivity.BACKGROUND_COLOR_KEY,
             Reader.ImageViewBackgroundOption.getValue().getIntValue());
         myBaseActivity.startActivity(intent);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } else if (region instanceof ZLTextWordRegion) {
     DictionaryUtil.openWordInDictionary(myBaseActivity, (ZLTextWordRegion) region);
   }
 }