Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.app.contentsuggestions; |
| 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.SystemApi; |
| 21 | import android.os.Bundle; |
| 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | |
| 25 | /** |
Zak Cohen | b399c84 | 2019-01-18 14:36:55 -0800 | [diff] [blame] | 26 | * Represents the classification of a content suggestion. The result of a |
| 27 | * {@link ClassificationsRequest} to {@link ContentSuggestionsManager}. |
| 28 | * |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 29 | * @hide |
| 30 | */ |
| 31 | @SystemApi |
| 32 | public final class ContentClassification implements Parcelable { |
| 33 | @NonNull |
| 34 | private final String mClassificationId; |
| 35 | @NonNull |
| 36 | private final Bundle mExtras; |
| 37 | |
Zak Cohen | b399c84 | 2019-01-18 14:36:55 -0800 | [diff] [blame] | 38 | /** |
| 39 | * Default constructor. |
| 40 | * |
| 41 | * @param classificationId implementation specific id for the selection / classification. |
| 42 | * @param extras containing the classification data. |
| 43 | */ |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 44 | public ContentClassification(@NonNull String classificationId, @NonNull Bundle extras) { |
| 45 | mClassificationId = classificationId; |
| 46 | mExtras = extras; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Return the classification id. |
| 51 | */ |
Zak Cohen | b399c84 | 2019-01-18 14:36:55 -0800 | [diff] [blame] | 52 | public @NonNull String getId() { |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 53 | return mClassificationId; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Return the classification extras. |
| 58 | */ |
Zak Cohen | b399c84 | 2019-01-18 14:36:55 -0800 | [diff] [blame] | 59 | public @NonNull Bundle getExtras() { |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 60 | 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(mClassificationId); |
| 71 | dest.writeBundle(mExtras); |
| 72 | } |
| 73 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 74 | public static final @android.annotation.NonNull Creator<ContentClassification> CREATOR = |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 75 | new Creator<ContentClassification>() { |
| 76 | @Override |
| 77 | public ContentClassification createFromParcel(Parcel source) { |
| 78 | return new ContentClassification( |
| 79 | source.readString(), |
| 80 | source.readBundle()); |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public ContentClassification[] newArray(int size) { |
| 85 | return new ContentClassification[size]; |
| 86 | } |
| 87 | }; |
| 88 | } |