Ejemplo n.º 1
0
  public Bitmap loadImage(String path) throws OutOfMemoryError {
    Bitmap bitsat;

    try {
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inPreferredConfig = Bitmap.Config.ARGB_8888;
      options.inJustDecodeBounds = true;
      Bitmap b = BitmapFactory.decodeFile(path, options);

      options.inSampleSize = Futils.calculateInSampleSize(options, px, px);

      // Decode bitmap with inSampleSize set
      options.inJustDecodeBounds = false;

      Bitmap bit;
      if (path.startsWith("smb:/")) bit = BitmapFactory.decodeStream(new SmbFileInputStream(path));
      else bit = BitmapFactory.decodeFile(path, options);

      bitsat =
          bit; // decodeFile(path);//.createScaledBitmap(bits,imageViewReference.get().getHeight(),imageViewReference.get().getWidth(),true);
    } catch (Exception e) {
      Drawable img = ContextCompat.getDrawable(mContext, R.drawable.ic_doc_image);
      Bitmap img1 = ((BitmapDrawable) img).getBitmap();
      bitsat = img1;
    }
    return bitsat;
  }
Ejemplo n.º 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);
    }
  }