1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.support.v7.app;
18 
19 import android.support.annotation.NonNull;
20 
21 /**
22  * The media route dialog factory is responsible for creating the media route
23  * chooser and controller dialogs as needed.
24  * <p>
25  * The application can customize the dialogs by providing a subclass of the
26  * dialog factory to the {@link MediaRouteButton} using the
27  * {@link MediaRouteButton#setDialogFactory setDialogFactory} method.
28  * </p>
29  */
30 public class MediaRouteDialogFactory {
31     private static final MediaRouteDialogFactory sDefault = new MediaRouteDialogFactory();
32 
33     /**
34      * Creates a default media route dialog factory.
35      */
MediaRouteDialogFactory()36     public MediaRouteDialogFactory() {
37     }
38 
39     /**
40      * Gets the default factory instance.
41      *
42      * @return The default media route dialog factory, never null.
43      */
44     @NonNull
getDefault()45     public static MediaRouteDialogFactory getDefault() {
46         return sDefault;
47     }
48 
49     /**
50      * Called when the chooser dialog is being opened and it is time to create the fragment.
51      * <p>
52      * Subclasses may override this method to create a customized fragment.
53      * </p>
54      *
55      * @return The media route chooser dialog fragment, must not be null.
56      */
57     @NonNull
onCreateChooserDialogFragment()58     public MediaRouteChooserDialogFragment onCreateChooserDialogFragment() {
59         return new MediaRouteChooserDialogFragment();
60     }
61 
62     /**
63      * Called when the controller dialog is being opened and it is time to create the fragment.
64      * <p>
65      * Subclasses may override this method to create a customized fragment.
66      * </p>
67      *
68      * @return The media route controller dialog fragment, must not be null.
69      */
70     @NonNull
onCreateControllerDialogFragment()71     public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
72         return new MediaRouteControllerDialogFragment();
73     }
74 }
75