Example #1
0
  protected int extractParameterFromLink(Element link, String parameter) {
    Pattern pattern = Pattern.compile(".*(?:" + parameter + ")=(\\d*)");
    String text = link.attr("href");

    if (!TextUtils.isEmpty(text)) {
      Matcher matcher = pattern.matcher(text);
      if (matcher.find()) return Integer.parseInt(matcher.group(1));
      else Utils.appendLog("Href doesn't contain such parameter");
    } else Utils.appendLog("Element does not contain href");

    return 0;
  }
Example #2
0
  protected Element getElement(int column, String select) {
    Element element = tempColumns.get(column).select(select).first();
    if (element != null) return element;
    else Utils.appendLog("No such element `" + select + "`");

    return null;
  }
Example #3
0
  protected Date parseDate(String text) {
    try {
      if (!text.equals("--")) return PARSING_FORMAT.parse(text);
    } catch (ParseException e) {
      Utils.appendLog("Error while parsing time string: `" + text + "`");
    }

    return new Date(0L);
  }
Example #4
0
  protected T getFromFile(Context context, int id) {
    String filename = ParentEntity.getFileName(getGenericTypeClass(), id);

    T object = null;
    FileInputStream fis = null;
    ObjectInputStream is = null;

    try {
      fis = context.openFileInput(filename);
      is = new ObjectInputStream(fis);
      object = (T) is.readObject();
      object.isKeptLocally = true;
      return object;
    } catch (FileNotFoundException e) {
      return null;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    } finally {
      Utils.close(fis);
      Utils.close(is);
    }
  }