Java Code Examples for android.os.Parcelable#Creator
The following examples show how to use
android.os.Parcelable#Creator .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParcelableUtil.java From px-android with MIT License | 5 votes |
@Nullable public static <T> T unmarshall(@NonNull final byte[] bytes, @NonNull final Parcelable.Creator<T> creator) { final Parcel parcel = unmarshall(bytes); final T result = creator.createFromParcel(parcel); parcel.recycle(); return result; }
Example 2
Source File: CacheUtils.java From LLApp with Apache License 2.0 | 5 votes |
private static <T> T bytes2Parcelable(byte[] bytes, Parcelable.Creator<T> creator) { if (bytes == null) return null; Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0); T result = creator.createFromParcel(parcel); parcel.recycle(); return result; }
Example 3
Source File: ParcelableCompat.java From adt-leanback-support with Apache License 2.0 | 5 votes |
/** * Factory method for {@link Parcelable.Creator}. * * @param callbacks Creator callbacks implementation. * @return New creator. */ public static <T> Parcelable.Creator<T> newCreator( ParcelableCompatCreatorCallbacks<T> callbacks) { if (android.os.Build.VERSION.SDK_INT >= 13) { ParcelableCompatCreatorHoneycombMR2Stub.instantiate(callbacks); } return new CompatCreator<T>(callbacks); }
Example 4
Source File: ParcelableAdapter.java From paperparcel with Apache License 2.0 | 4 votes |
public ParcelableAdapter(@Nullable Parcelable.Creator<T> creator) { this.creator = creator; }
Example 5
Source File: ParcelUtil.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public static <T> T deserialize(byte[] bytes, Parcelable.Creator<T> creator) { Parcel parcel = deserialize(bytes); return creator.createFromParcel(parcel); }
Example 6
Source File: SQLiteStore.java From android-sdk with MIT License | 4 votes |
public static <T> T unmarshall(byte[] bytes, Parcelable.Creator<T> creator) { Parcel parcel = unmarshall(bytes); return creator.createFromParcel(parcel); }
Example 7
Source File: UtilsBridge.java From AndroidUtilCode with Apache License 2.0 | 4 votes |
static <T> T bytes2Parcelable(final byte[] bytes, final Parcelable.Creator<T> creator) { return ConvertUtils.bytes2Parcelable(bytes, creator); }
Example 8
Source File: Topics.java From Jager with GNU General Public License v3.0 | 4 votes |
public static Parcelable.Creator<Topics> getCREATOR () { return CREATOR; }
Example 9
Source File: TimerRingtoneService.java From ClockPlus with GNU General Public License v3.0 | 4 votes |
@Override protected Parcelable.Creator<Timer> getParcelableCreator() { return Timer.CREATOR; }
Example 10
Source File: AndroidLocationPlayServiceManager.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public static <T> T unmarshall(byte[] bytes, Parcelable.Creator<T> creator) { Parcel parcel = unmarshall(bytes); T result = creator.createFromParcel(parcel); parcel.recycle(); return result; }
Example 11
Source File: ParcelableTestUtils.java From material-components-android with Apache License 2.0 | 4 votes |
public static <T> T parcelAndCreate(Parcelable parcelable, Parcelable.Creator<T> creator) { Parcel parcel = Parcel.obtain(); parcelable.writeToParcel(parcel, /* flags= */ 0); parcel.setDataPosition(0); return creator.createFromParcel(parcel); }
Example 12
Source File: Posts.java From Jager with GNU General Public License v3.0 | 4 votes |
public static Parcelable.Creator<Posts> getCREATOR () { return CREATOR; }
Example 13
Source File: AlarmActivity.java From ClockPlus with GNU General Public License v3.0 | 4 votes |
@Override protected Parcelable.Creator<Alarm> getParcelableCreator() { return Alarm.CREATOR; }
Example 14
Source File: CacheDiskUtils.java From AndroidUtilCode with Apache License 2.0 | 3 votes |
/** * Return the parcelable in cache. * * @param key The key of cache. * @param creator The creator. * @param defaultValue The default value if the cache doesn't exist. * @param <T> The value type. * @return the parcelable if cache exists or defaultValue otherwise */ public <T> T getParcelable(@NonNull final String key, @NonNull final Parcelable.Creator<T> creator, final T defaultValue) { byte[] bytes = realGetBytes(TYPE_PARCELABLE + key); if (bytes == null) return defaultValue; return UtilsBridge.bytes2Parcelable(bytes, creator); }
Example 15
Source File: Postman.java From postman with MIT License | 3 votes |
/** * Get a {@link Creator} that can be used for the {@code CREATOR} field of a {@link * Parcelable}. * * @param clazz The class associated with the type the the Creator will create. * @param <T> The type the Creator will create. * * @return A fully implemented Creator for the specified type. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. */ public static <T> Parcelable.Creator<T> getCreator(Class<T> clazz) throws PostmanException { @SuppressWarnings("unchecked") Parcelable.Creator<T> creator = (Parcelable.Creator<T>) creatorMap.get(clazz); if (creator == null) { creator = newCreator(clazz); creatorMap.put(clazz, creator); } return creator; }
Example 16
Source File: CacheUtils.java From LLApp with Apache License 2.0 | 2 votes |
/** * 缓存中读取Parcelable * * @param key 键 * @param creator 建造器 * @param defaultValue 默认值 * @return 存在且没过期返回对应值,否则返回默认值{@code defaultValue} */ public <T> T getParcelable(@NonNull String key, @NonNull Parcelable.Creator<T> creator, T defaultValue) { byte[] bytes = getBytes(key); if (bytes == null) return defaultValue; return CacheHelper.bytes2Parcelable(bytes, creator); }
Example 17
Source File: CacheDiskStaticUtils.java From AndroidUtilCode with Apache License 2.0 | 2 votes |
/** * Return the parcelable in cache. * * @param key The key of cache. * @param creator The creator. * @param defaultValue The default value if the cache doesn't exist. * @param <T> The value type. * @return the parcelable if cache exists or defaultValue otherwise */ public static <T> T getParcelable(@NonNull final String key, @NonNull final Parcelable.Creator<T> creator, final T defaultValue) { return getParcelable(key, creator, defaultValue, getDefaultCacheDiskUtils()); }
Example 18
Source File: CacheDiskStaticUtils.java From AndroidUtilCode with Apache License 2.0 | 2 votes |
/** * Return the parcelable in cache. * * @param key The key of cache. * @param creator The creator. * @param cacheDiskUtils The instance of {@link CacheDiskUtils}. * @param <T> The value type. * @return the parcelable if cache exists or null otherwise */ public static <T> T getParcelable(@NonNull final String key, @NonNull final Parcelable.Creator<T> creator, @NonNull final CacheDiskUtils cacheDiskUtils) { return cacheDiskUtils.getParcelable(key, creator); }
Example 19
Source File: CacheUtils.java From LLApp with Apache License 2.0 | 2 votes |
/** * 缓存中读取Parcelable * * @param key 键 * @param creator 建造器 * @return 存在且没过期返回对应值,否则返回{@code null} */ public <T> T getParcelable(@NonNull String key, @NonNull Parcelable.Creator<T> creator) { return getParcelable(key, creator, null); }
Example 20
Source File: BaseParceledListSlice.java From android_9.0.0_r45 with Apache License 2.0 | votes |
protected abstract Parcelable.Creator<?> readParcelableCreator(Parcel from, ClassLoader loader);