コード例 #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);
  }
コード例 #3
0
 public static <T> boolean isNullOrEmpty(Collection<T> c) {
   return (c == null) || (c.size() == 0);
 }