Home | History | Annotate | Download | only in os
      1 /*
      2  * Copyright (C) 2011 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 androidx.core.os;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 /**
     23  * Helper for accessing features in {@link android.os.Parcelable}.
     24  *
     25  * @deprecated Use {@link android.os.Parcelable.ClassLoaderCreator} directly.
     26  */
     27 @Deprecated
     28 public final class ParcelableCompat {
     29 
     30     /**
     31      * Factory method for {@link Parcelable.Creator}.
     32      *
     33      * @param callbacks Creator callbacks implementation.
     34      * @return New creator.
     35      *
     36      * @deprecated Use {@link android.os.Parcelable.ClassLoaderCreator} directly.
     37      */
     38     @Deprecated
     39     public static <T> Parcelable.Creator<T> newCreator(
     40             ParcelableCompatCreatorCallbacks<T> callbacks) {
     41         return new ParcelableCompatCreatorHoneycombMR2<T>(callbacks);
     42     }
     43 
     44     static class ParcelableCompatCreatorHoneycombMR2<T>
     45             implements Parcelable.ClassLoaderCreator<T> {
     46         private final ParcelableCompatCreatorCallbacks<T> mCallbacks;
     47 
     48         ParcelableCompatCreatorHoneycombMR2(ParcelableCompatCreatorCallbacks<T> callbacks) {
     49             mCallbacks = callbacks;
     50         }
     51 
     52         @Override
     53         public T createFromParcel(Parcel in) {
     54             return mCallbacks.createFromParcel(in, null);
     55         }
     56 
     57         @Override
     58         public T createFromParcel(Parcel in, ClassLoader loader) {
     59             return mCallbacks.createFromParcel(in, loader);
     60         }
     61 
     62         @Override
     63         public T[] newArray(int size) {
     64             return mCallbacks.newArray(size);
     65         }
     66     }
     67 
     68     private ParcelableCompat() {}
     69 }
     70