FileDocCategorySizeDatePackage
MediaRouteSelector.javaAPI DocAndroid 5.1 API10324Thu Mar 12 22:22:56 GMT 2015android.support.v7.media

MediaRouteSelector

public final class MediaRouteSelector extends Object
Describes the capabilities of routes that applications would like to discover and use.

This object is immutable once created using a {@link Builder} instance.

Example

MediaRouteSelector selectorBuilder = new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.build();

MediaRouter router = MediaRouter.getInstance(context);
router.addCallback(selector, callback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);

Fields Summary
private static final String
KEY_CONTROL_CATEGORIES
private final android.os.Bundle
mBundle
private List
mControlCategories
public static final MediaRouteSelector
EMPTY
An empty media route selector that will not match any routes.
Constructors Summary
private MediaRouteSelector(android.os.Bundle bundle, List controlCategories)


         
        mBundle = bundle;
        mControlCategories = controlCategories;
    
Methods Summary
public android.os.BundleasBundle()
Converts this object to a bundle for serialization.

return
The contents of the object represented as a bundle.

        return mBundle;
    
public booleancontains(android.support.v7.media.MediaRouteSelector selector)
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.

        if (selector != null) {
            ensureControlCategories();
            selector.ensureControlCategories();
            return mControlCategories.containsAll(selector.mControlCategories);
        }
        return false;
    
private voidensureControlCategories()

        if (mControlCategories == null) {
            mControlCategories = mBundle.getStringArrayList(KEY_CONTROL_CATEGORIES);
            if (mControlCategories == null || mControlCategories.isEmpty()) {
                mControlCategories = Collections.<String>emptyList();
            }
        }
    
public booleanequals(java.lang.Object o)

        if (o instanceof MediaRouteSelector) {
            MediaRouteSelector other = (MediaRouteSelector)o;
            ensureControlCategories();
            other.ensureControlCategories();
            return mControlCategories.equals(other.mControlCategories);
        }
        return false;
    
public static android.support.v7.media.MediaRouteSelectorfromBundle(android.os.Bundle bundle)
Creates an instance from a bundle.

param
bundle The bundle, or null if none.
return
The new instance, or null if the bundle was null.

        return bundle != null ? new MediaRouteSelector(bundle, null) : null;
    
public java.util.ListgetControlCategories()
Gets the list of {@link MediaControlIntent media control categories} in the selector.

return
The list of categories.

        ensureControlCategories();
        return mControlCategories;
    
public booleanhasControlCategory(java.lang.String category)
Returns true if the selector contains the specified category.

param
category The category to check.
return
True if the category is present.

        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;
    
public inthashCode()

        ensureControlCategories();
        return mControlCategories.hashCode();
    
public booleanisEmpty()
Returns true if the selector does not specify any capabilities.

        ensureControlCategories();
        return mControlCategories.isEmpty();
    
public booleanisValid()
Returns true if the selector has all of the required fields.

        ensureControlCategories();
        if (mControlCategories.contains(null)) {
            return false;
        }
        return true;
    
public booleanmatchesControlFilters(java.util.List filters)
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.

        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;
    
public java.lang.StringtoString()

        StringBuilder result = new StringBuilder();
        result.append("MediaRouteSelector{ ");
        result.append("controlCategories=").append(
                Arrays.toString(getControlCategories().toArray()));
        result.append(" }");
        return result.toString();