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

MediaRouteProviderDescriptor

public final class MediaRouteProviderDescriptor extends Object
Describes the state of a media route provider and the routes that it publishes.

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

Fields Summary
private static final String
KEY_ROUTES
private final android.os.Bundle
mBundle
private List
mRoutes
Constructors Summary
private MediaRouteProviderDescriptor(android.os.Bundle bundle, List routes)


      
              
        mBundle = bundle;
        mRoutes = routes;
    
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;
    
private voidensureRoutes()

        if (mRoutes == null) {
            ArrayList<Bundle> routeBundles = mBundle.<Bundle>getParcelableArrayList(KEY_ROUTES);
            if (routeBundles == null || routeBundles.isEmpty()) {
                mRoutes = Collections.<MediaRouteDescriptor>emptyList();
            } else {
                final int count = routeBundles.size();
                mRoutes = new ArrayList<MediaRouteDescriptor>(count);
                for (int i = 0; i < count; i++) {
                    mRoutes.add(MediaRouteDescriptor.fromBundle(routeBundles.get(i)));
                }
            }
        }
    
public static android.support.v7.media.MediaRouteProviderDescriptorfromBundle(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 MediaRouteProviderDescriptor(bundle, null) : null;
    
public java.util.ListgetRoutes()
Gets the list of all routes that this provider has published.

        ensureRoutes();
        return mRoutes;
    
public booleanisValid()
Returns true if the route provider descriptor and all of the routes that it contains have all of the required fields.

This verification is deep. If the provider descriptor is known to be valid then it is not necessary to call {@link #isValid} on each of its routes.

        ensureRoutes();
        final int routeCount = mRoutes.size();
        for (int i = 0; i < routeCount; i++) {
            MediaRouteDescriptor route = mRoutes.get(i);
            if (route == null || !route.isValid()) {
                return false;
            }
        }
        return true;
    
public java.lang.StringtoString()

        StringBuilder result = new StringBuilder();
        result.append("MediaRouteProviderDescriptor{ ");
        result.append("routes=").append(
                Arrays.toString(getRoutes().toArray()));
        result.append(", isValid=").append(isValid());
        result.append(" }");
        return result.toString();