Пример #1
0
 /*
  * Get a specific thng from its id.
  *
  */
 private static Thng getThngById(String thngId) {
   ThngService thngService = api.thngService();
   try {
     return thngService.thngReader(thngId).execute();
   } catch (EvrythngException e) {
     e.printStackTrace();
     return null;
   }
 }
Пример #2
0
  /*
   * Get all the thngs ordered by ordernumber and cache them.
   *
   */
  private static List<Thng> getThngs() throws EvrythngException, EvrythngClientException {
    if (things != null) return things;

    ThngService thngService = api.thngService();
    List<Thng> thngs = thngService.thngsReader().execute();
    Collections.sort(
        thngs,
        new Comparator<Thng>() {
          @Override
          public int compare(Thng t1, Thng t2) {
            Integer ft1 = Integer.parseInt(t1.getCustomFields().get("ordernumber"));
            Integer ft2 = Integer.parseInt(t2.getCustomFields().get("ordernumber"));
            return ft1.compareTo(ft2);
          }
        });
    things = thngs;
    return thngs;
  }