Пример #1
0
 /** Returns true if the selector has all of the required fields. */
 public boolean isValid() {
   ensureControlCategories();
   if (mControlCategories.contains(null)) {
     return false;
   }
   return true;
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
    /**
     * 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);
      }
    }
Пример #4
0
 @Override
 public boolean equals(Object o) {
   if (o instanceof MediaRouteSelector) {
     MediaRouteSelector other = (MediaRouteSelector) o;
     ensureControlCategories();
     other.ensureControlCategories();
     return mControlCategories.equals(other.mControlCategories);
   }
   return false;
 }
Пример #5
0
 /**
  * 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;
 }
Пример #6
0
 /**
  * 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;
 }
Пример #7
0
 /**
  * Gets the list of {@link MediaControlIntent media control categories} in the selector.
  *
  * @return The list of categories.
  */
 public List<String> getControlCategories() {
   ensureControlCategories();
   return mControlCategories;
 }
Пример #8
0
 @Override
 public int hashCode() {
   ensureControlCategories();
   return mControlCategories.hashCode();
 }
Пример #9
0
 /** Returns true if the selector does not specify any capabilities. */
 public boolean isEmpty() {
   ensureControlCategories();
   return mControlCategories.isEmpty();
 }