/** Returns true if the selector has all of the required fields. */ public boolean isValid() { ensureControlCategories(); if (mControlCategories.contains(null)) { return false; } return true; }
/** * Returns true if this selector contains all of the capabilities described by the specified * selector. * * @param selector The selector to be examined. * @return True if this selector contains all of the capabilities described by the specified * selector. */ public boolean contains(MediaRouteSelector selector) { if (selector != null) { ensureControlCategories(); selector.ensureControlCategories(); return mControlCategories.containsAll(selector.mControlCategories); } return false; }
/** * Creates a media route selector descriptor builder whose initial contents are copied from an * existing selector. */ public Builder(MediaRouteSelector selector) { if (selector == null) { throw new IllegalArgumentException("selector must not be null"); } selector.ensureControlCategories(); if (!selector.mControlCategories.isEmpty()) { mControlCategories = new ArrayList<String>(selector.mControlCategories); } }
@Override public boolean equals(Object o) { if (o instanceof MediaRouteSelector) { MediaRouteSelector other = (MediaRouteSelector) o; ensureControlCategories(); other.ensureControlCategories(); return mControlCategories.equals(other.mControlCategories); } return false; }
/** * Returns true if the selector contains the specified category. * * @param category The category to check. * @return True if the category is present. */ public boolean hasControlCategory(String category) { if (category != null) { ensureControlCategories(); final int categoryCount = mControlCategories.size(); for (int i = 0; i < categoryCount; i++) { if (mControlCategories.get(i).equals(category)) { return true; } } } return false; }
/** * Returns true if the selector matches at least one of the specified control filters. * * @param filters The list of control filters to consider. * @return True if a match is found. */ public boolean matchesControlFilters(List<IntentFilter> filters) { if (filters != null) { ensureControlCategories(); final int categoryCount = mControlCategories.size(); if (categoryCount != 0) { final int filterCount = filters.size(); for (int i = 0; i < filterCount; i++) { final IntentFilter filter = filters.get(i); if (filter != null) { for (int j = 0; j < categoryCount; j++) { if (filter.hasCategory(mControlCategories.get(j))) { return true; } } } } } } return false; }
/** * Gets the list of {@link MediaControlIntent media control categories} in the selector. * * @return The list of categories. */ public List<String> getControlCategories() { ensureControlCategories(); return mControlCategories; }
@Override public int hashCode() { ensureControlCategories(); return mControlCategories.hashCode(); }
/** Returns true if the selector does not specify any capabilities. */ public boolean isEmpty() { ensureControlCategories(); return mControlCategories.isEmpty(); }