RequestUtils.java revision 07c7077c54717dbbf2c401ea32d00fa6df6d77c6
107c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik/*
207c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * Copyright (C) 2014 The Android Open Source Project
307c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik *
407c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * Licensed under the Apache License, Version 2.0 (the "License");
507c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * you may not use this file except in compliance with the License.
607c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * You may obtain a copy of the License at
707c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik *
807c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik *      http://www.apache.org/licenses/LICENSE-2.0
907c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik *
1007c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * Unless required by applicable law or agreed to in writing, software
1107c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * distributed under the License is distributed on an "AS IS" BASIS,
1207c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * See the License for the specific language governing permissions and
1407c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik * limitations under the License.
1507c7077c54717dbbf2c401ea32d00fa6df6d77c6RoboErik */
16bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErikpackage com.android.onemedia.playback;
17bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
18bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErikimport android.os.Bundle;
19bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErikimport android.support.v7.media.MediaItemMetadata;
20bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
21bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErikimport java.util.HashMap;
22bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErikimport java.util.Map;
23bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
24bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik/**
25bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik * TODO: Insert description here. (generated by epastern)
26bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik */
27bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErikpublic class RequestUtils {
28bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    public static final String ACTION_SET_CONTENT = "set_content";
29bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    public static final String ACTION_SET_NEXT_CONTENT = "set_next_content";
30bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
31bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    public static final String EXTRA_KEY_SOURCE = "source";
32bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    public static final String EXTRA_KEY_METADATA = "metadata";
33bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    public static final String EXTRA_KEY_HEADERS = "headers";
34bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
35bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    private RequestUtils() {
36bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    }
37bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
38bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    public static class ContentBuilder {
39bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        private Bundle mBundle;
40bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
41bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        public ContentBuilder() {
42bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            mBundle = new Bundle();
43bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        }
44bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
45bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        public ContentBuilder setSource(String source) {
46bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            mBundle.putString(EXTRA_KEY_SOURCE, source);
47bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            return this;
48bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        }
49bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
50bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        /**
51bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik         * @see MediaItemMetadata
52bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik         * @param metadata The metadata for this item
53bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik         */
54bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        public ContentBuilder setMetadata(Bundle metadata) {
55bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            mBundle.putBundle(EXTRA_KEY_METADATA, metadata);
56bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            return this;
57bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        }
58bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
59bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        public ContentBuilder setHeaders(HashMap<String, String> headers) {
60bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            mBundle.putSerializable(EXTRA_KEY_HEADERS, headers);
61bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            return this;
62bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        }
63bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik
64bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        public Bundle build() {
65bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik            return mBundle;
66bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik        }
67bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik    }
68bfa153b64b4e8c2faa39a15e87fc9f0300335f20RoboErik}
69