/**
   * Handle the button push events.
   *
   * @param evt, the associated ActionEvent object.
   */
  public void actionPerformed(ActionEvent evt) {

    Object source = evt.getSource();

    // Handle button events
    if (source instanceof JButton) {
      if (source == pbImport) {

        Thread thread = new Thread("UIImportXMLDialog: Import") { // $NON-NLS-1$
              public void run() {
                onImport();
              }
            };
        thread.run();

      } else if (source == pbClose) {
        onCancel();
      }
    }
  }
예제 #2
0
  @Override
  public void run() {
    // TODO: Implement this method
    super.run();
    start = 0;
    end = 0;

    LoadPageImage imp;
    HashMap<String, Object> map = new HashMap<String, Object>();
    try {

      start = html.indexOf("page-submission", 0);
      start = html.indexOf("small_url =", start);
      end = html.indexOf("var full_url", start);
      s = "http:" + html.substring(start + 13, end - 3);
      final String img = s;
      map.put("img", s);
      end = html.indexOf(">Download<", end);
      start = html.lastIndexOf("href=", end);
      s = "http:" + html.substring(start + 6, end - 1);
      map.put("download", s);
      int std = s.lastIndexOf("/");
      String name = PageActivity.HOME_PATH + s.substring(std + 1, s.length());
      File f = new File(name);
      if (f.exists()) {
        Bitmap b;
        b = BitmapFactory.decodeFile(f.getPath());
        map.put("bitmap", b);
      } else {
        name = PageActivity.HOME_PATH + "s-" + s.substring(std + 1, s.length());
        f = new File(name);
        if (f.exists()) {
          Bitmap b;
          b = BitmapFactory.decodeFile(f.getPath());
          map.put("bitmap", b);
        } else {
          imp = new LoadPageImage();
          imp.start(img, -1, now);
        }
      }
      end = html.indexOf("Main Gallery", end);
      start = html.lastIndexOf("href=", end);
      end = html.indexOf("class=", start);
      s = html.substring(start + 6, end - 2);
      map.put("gallery", s);
      start = html.indexOf("<tr>\n<td", end);
      start = html.indexOf("<b>", start);
      end = html.indexOf("</b>", start);
      s = html.substring(start + 3, end);
      map.put("title", s);
      start = html.indexOf("href=", start);
      end = html.indexOf("><img", start);
      s = "http://www.furaffinity.net" + html.substring(start + 6, end - 1);
      map.put("userlink", s);
      start = html.indexOf("alt=", end);
      end = html.indexOf("\" src", start);
      s = html.substring(start + 5, end);
      map.put("username", s);
      start = html.indexOf("src=", end);
      end = html.indexOf("></a>", start);
      s = "http:" + html.substring(start + 5, end - 1);
      imp = new LoadPageImage();
      imp.start(s, -2, now);
      map.put("usericon", s);
      start = html.indexOf("<br/><br/>", end);
      end = html.indexOf("</td>\n</tr>", start);
      int st = start;
      int ed = start - 2;
      String t = "";
      s = "";
      while (html.indexOf("<br/>", st + 1) < end - 6) {
        st = html.indexOf("<br/>", ed);
        ed = html.indexOf("<br/>", st + 1);
        t = html.substring(st + 5, ed);
        if (t.indexOf("href=") != -1) {
          int i1;
          int i2;
          i1 = t.indexOf("alt=\"", 0);
          i2 = t.indexOf("\"/>", i1);
          try {
            t = " @ " + t.substring(i1 + 5, i2) + " ";
          } catch (Exception e) {
            t = "";
          }
        }
        t = t.replace("</td>", "");
        t = t.replace("<td>", "");
        t = t.replace("</tr>", "");
        t = t.replace("<tr>", "");
        t = t.replace("</table>", "");
        t = t.replace("<table>", "");
        t = t.replace("<br>", "");
        t = t.replace("</br>", "");
        if (t.indexOf("bbcode") != -1) {
          t = "";
        }
        s += t;
      }

      map.put("info", s);
      if (now == PageActivity.now) {
        Message msg = Message.obtain();
        msg.arg2 = now;
        msg.obj = map;
        msg.what = 5;
        PageActivity.hander.sendMessage(msg);
      }
    } catch (Exception e) {
      File f = new File(PageActivity.HOME_PATH + "LOG/lastPage.html");
      if (f.exists()) {
        f.renameTo(new File(PageActivity.HOME_PATH + "LOG/lastErrorPage.html"));
      }
      Message msg = Message.obtain();
      msg.arg2 = now;
      msg.obj = map;
      msg.what = 998;
      PageActivity.hander.sendMessage(msg);
    }
  }