• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 package com.android.launcher3.util;
17 
18 import android.content.Intent;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * Utility class which stores information from onActivityResult
24  */
25 public class ActivityResultInfo implements Parcelable {
26 
27     public final int requestCode;
28     public final int resultCode;
29     public final Intent data;
30 
ActivityResultInfo(int requestCode, int resultCode, Intent data)31     public ActivityResultInfo(int requestCode, int resultCode, Intent data) {
32         this.requestCode = requestCode;
33         this.resultCode = resultCode;
34         this.data = data;
35     }
36 
ActivityResultInfo(Parcel parcel)37     private ActivityResultInfo(Parcel parcel) {
38         requestCode = parcel.readInt();
39         resultCode = parcel.readInt();
40         data = parcel.readInt() != 0 ? Intent.CREATOR.createFromParcel(parcel) : null;
41     }
42 
43     @Override
describeContents()44     public int describeContents() {
45         return 0;
46     }
47 
48     @Override
writeToParcel(Parcel dest, int flags)49     public void writeToParcel(Parcel dest, int flags) {
50         dest.writeInt(requestCode);
51         dest.writeInt(resultCode);
52         if (data != null) {
53             dest.writeInt(1);
54             data.writeToParcel(dest, flags);
55         } else {
56             dest.writeInt(0);
57         }
58     }
59 
60     public static final Parcelable.Creator<ActivityResultInfo> CREATOR =
61             new Parcelable.Creator<ActivityResultInfo>() {
62                 public ActivityResultInfo createFromParcel(Parcel source) {
63                     return new ActivityResultInfo(source);
64                 }
65 
66                 public ActivityResultInfo[] newArray(int size) {
67                     return new ActivityResultInfo[size];
68                 }
69             };
70 }
71