/* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.support.v7.media; import android.content.IntentFilter; import android.os.Bundle; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; /** * 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. *
*/ public final class MediaRouteProviderDescriptor { static final String KEY_ROUTES = "routes"; final Bundle mBundle; List* 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. *
*/ public boolean isValid() { 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; } @Override public String toString() { 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(); } /** * Converts this object to a bundle for serialization. * * @return The contents of the object represented as a bundle. */ public Bundle asBundle() { return mBundle; } /** * 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. */ public static MediaRouteProviderDescriptor fromBundle(Bundle bundle) { return bundle != null ? new MediaRouteProviderDescriptor(bundle, null) : null; } /** * Builder for {@link MediaRouteProviderDescriptor media route provider descriptors}. */ public static final class Builder { private final Bundle mBundle; private ArrayList