blob: 16b4f3f6456d64803eb9e1b21e601154dd7c74ec [file] [log] [blame]
Winson Chung3fb0f252019-01-08 17:41:55 -08001/*
2 * Copyright (C) 2018 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
17package android.app.contentsuggestions;
18
19import android.annotation.NonNull;
20import android.annotation.SystemApi;
21import android.os.Bundle;
22import android.os.Parcel;
23import android.os.Parcelable;
24
25/**
Zak Cohenb399c842019-01-18 14:36:55 -080026 * Represents a suggested selection within a set of on screen content. The result of a
27 * {@link SelectionsRequest} to {@link ContentSuggestionsManager}.
28 *
Winson Chung3fb0f252019-01-08 17:41:55 -080029 * @hide
30 */
31@SystemApi
32public final class ContentSelection implements Parcelable {
33 @NonNull
34 private final String mSelectionId;
35 @NonNull
36 private final Bundle mExtras;
37
Zak Cohenb399c842019-01-18 14:36:55 -080038 /**
39 * Default constructor.
40 *
41 * @param selectionId implementation specific id for the selection.
42 * @param extras containing the data that represents the selection.
43 */
Winson Chung3fb0f252019-01-08 17:41:55 -080044 public ContentSelection(@NonNull String selectionId, @NonNull Bundle extras) {
45 mSelectionId = selectionId;
46 mExtras = extras;
47 }
48
49 /**
50 * Return the selection id.
51 */
Zak Cohenb399c842019-01-18 14:36:55 -080052 public @NonNull String getId() {
Winson Chung3fb0f252019-01-08 17:41:55 -080053 return mSelectionId;
54 }
55
56 /**
57 * Return the selection extras.
58 */
Zak Cohenb399c842019-01-18 14:36:55 -080059 public @NonNull Bundle getExtras() {
Winson Chung3fb0f252019-01-08 17:41:55 -080060 return mExtras;
61 }
62
63 @Override
64 public int describeContents() {
65 return 0;
66 }
67
68 @Override
69 public void writeToParcel(Parcel dest, int flags) {
70 dest.writeString(mSelectionId);
71 dest.writeBundle(mExtras);
72 }
73
74 public static final Creator<ContentSelection> CREATOR =
75 new Creator<ContentSelection>() {
76 @Override
77 public ContentSelection createFromParcel(Parcel source) {
78 return new ContentSelection(
79 source.readString(),
80 source.readBundle());
81 }
82
83 @Override
84 public ContentSelection[] newArray(int size) {
85 return new ContentSelection[size];
86 }
87 };
88}