Пример #1
0
  // Returns true iff all items in subset are in superset, treating null and
  // empty collections as
  // the same.
  public static <T> boolean isSubset(Collection<T> subset, Collection<T> superset) {
    if ((superset == null) || (superset.size() == 0)) {
      return ((subset == null) || (subset.size() == 0));
    }

    HashSet<T> hash = new HashSet<T>(superset);
    for (T t : subset) {
      if (!hash.contains(t)) {
        return false;
      }
    }
    return true;
  }
Пример #2
0
  private void onFriendPickerDone(FriendPickerFragment fragment) {
    FragmentManager fm = getSupportFragmentManager();
    fm.popBackStack();

    String results = "";

    Collection<GraphUser> selection = fragment.getSelection();
    if (selection != null && selection.size() > 0) {
      ArrayList<String> names = new ArrayList<String>();
      for (GraphUser user : selection) {
        names.add(user.getName());
      }
      results = TextUtils.join(", ", names);
    } else {
      results = "no friends";
    }

    showAlert("rar", results);
  }
 /**
  * Gets the currently-selected place.
  *
  * @return the currently-selected place, or null if there is none
  */
 public GraphPlace getSelection() {
   Collection<GraphPlace> selection = getSelectedGraphObjects();
   return (selection != null && !selection.isEmpty()) ? selection.iterator().next() : null;
 }
Пример #4
0
 public static <T> boolean isNullOrEmpty(Collection<T> c) {
   return (c == null) || (c.size() == 0);
 }