Ejemplo n.º 1
0
 public static ServiceLookup getServiceLookup(List<ServiceEvent> services) {
   ArrayList<ServiceLookup> lookups = new ArrayList<>();
   for (ServiceEvent service : services) {
     ServiceLookup lookup = ServiceLookup.get(service.getType());
     if (lookup != null && lookup.getPriority() > 0) {
       lookups.add(lookup);
     }
   }
   Timber.v("lookups for " + services + " are " + lookups);
   if (lookups.isEmpty()) {
     return null;
   }
   Collections.sort(lookups);
   return lookups.get(lookups.size() - 1);
 }
Ejemplo n.º 2
0
  public FlameHost(List<ServiceEvent> services) {
    mServices = services;
    if (services.size() == 0) {
      return;
    }

    Collections.sort(
        services,
        new Comparator<ServiceEvent>() {
          @Override
          public int compare(ServiceEvent lhs, ServiceEvent rhs) {
            ServiceLookup left = ServiceLookup.get(lhs.getType());
            ServiceLookup right = ServiceLookup.get(rhs.getType());
            if (left != null && right != null) {
              return Integer.valueOf(left.getPriority()).compareTo(right.getPriority());
            } else if (left != null && right == null) {
              // left wins
              return -1;
            } else {
              return lhs.getName().compareToIgnoreCase(rhs.getName());
            }
          }
        });

    mIdentifer = hostIdentifierForService(services.get(0));
    mLookup = ServiceLookup.get(services.get(0).getType());
  }
Ejemplo n.º 3
0
 public int getImageResource() {
   if (mLookup != null) {
     return mLookup.getDrawable();
   }
   return 0;
 }