• Stars
    star
    656
  • Rank 68,675 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Android Parcelable extension for Google's AutoValue.

AutoValue: Parcel Extension

An extension for Google's AutoValue that supports Android's Parcelable interface.

Usage

Simply include the AutoValue: Parcel Extension in your project and make any of your @AutoValue annotated classed implement Parcelable.

@AutoValue public abstract class Foo implements Parcelable {

  public abstract String bar();

}

Now build your project and enjoy your Parcelable Foo.

TypeAdapters

Out of the box AutoValue: Parcel Extension support all of the types supported by the Parcel class, but sometimes you may need to parcel other types, like SparseArray or ArrayMap. You can do this using a custom TypeAdapter.

TypeAdapter allows you to define custom de/serialization logic for properties by allowing you to parcel and unparcel those properties manually.

public class DateTypeAdapter implements TypeAdapter<Date> {
  public Date fromParcel(Parcel in) {
    return new Date(in.readLong());
  }
  
  public void toParcel(Date value, Parcel dest) {
    dest.writeLong(value.getTime());
  }
}

Once you've defined your custom TypeAdapter, using it on an AutoValue class is as simple as adding the ParcelAdapter annotation to any property you'd like to be serialized with your TypeAdapter.

@AutoValue public abstract class Foo implements Parcelable {
  @ParcelAdapter(DateTypeAdapter.class) public abstract Date date();
}

Since TypeAdapters require a small runtime component, they are optional. To use TypeAdapters in your project you'll have to add a compile dependency on the auto-value-parcel-adapter artifact.

compile 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.9'

Download

Add a Gradle dependency:

annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.9'

// Optionally for TypeAdapter support
compile 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.9'

(Migrating from apt to annotationProcessor)

License

Copyright 2015 Ryan Harter.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

auto-value-gson

AutoValue Extension to add Gson De/Serializer support
Java
604
star
2

auto-value-moshi

AutoValue: Moshi Extension
Java
189
star
3

ViewPager-Android

Based on the Android support library's ViewPager class, this ViewPager supports both horizontal and vertical paging views.
Java
154
star
4

Android-TV-Launcher

An Android Launcher specifically designed for use on the tv. Great for devices like the Geniatech Android TV.
Java
144
star
5

ktor-moshi

Ktor feature that adds Moshi JSON serialization support
Kotlin
82
star
6

android-tooltips

Custom tooltips for android.
Java
78
star
7

kotlinx-serialization-xml

Xml support for KotlinX Serialization
Kotlin
69
star
8

vd-tool

Android Studio's Vector Drawable conversion tool in convenient packaging.
66
star
9

mmmmm

Sample app demonstrating Android Canvas APIs
Kotlin
63
star
10

gradle-git-repo

Gradle plugin to better support using git repositories as a (private) maven repo.
Groovy
38
star
11

docker-goaccess-cloudfront

A Docker container to process and serve website analytics using CloudFront and GoAccess. https://hub.docker.com/r/rharter/goaccess-cloudfront
Shell
18
star
12

android-gesture-sample

Sample app demonstrating using simple GestureDetectors
Java
17
star
13

windy-city-devcon-android

Windy City Devcon Android app
Kotlin
11
star
14

goodreads-api

Android interface to the Goodreads api
Java
11
star
15

AdoptMe

Pet finder Android app that goes along with the tutorial at http://ryanharter.com
Java
10
star
16

autovalue-intro

Provides a simple introduction to AutoValue
Java
8
star
17

gl-helpers

Java
7
star
18

gxeditor

An experiment with the GXUI library.
Go
5
star
19

plex-api

Java interface for Plex Media Server web api
Java
5
star
20

kups

Kotlin Unified Parcel Service
Kotlin
4
star
21

enhanced-gridview

Enhanced Android GridView offering multi-directional scrolling.
Java
3
star
22

mediaman

Media management server written in Go
Go
3
star
23

go-tmdb

Go library to access The Movie Database
Go
3
star
24

tab-width-issue-sample

Demonstrates the tab width issue in the design support library
Java
2
star
25

go-guessit

A Go library interface to the GuessIt web service API.
Go
2
star
26

caster-butterknife

Sample code to accompany the Caster butterknife video series
Java
2
star
27

constraint-layout-merge-error

Simple app to demonstrate that ConstraintLayout can't handle merge tags.
Java
2
star
28

gringotts

Kotlin
2
star
29

tvheadend-postproc

Post-processing script for TVHeadend recordings
Python
2
star
30

imagerow.js

A pure javascript library that sizes rows of images so that they preserve their aspect ratio while filling the row.
HTML
2
star
31

dough.js

Java
2
star
32

helm

A multiplatform navigation and presentation framework based on Jetpack Compose.
Kotlin
2
star
33

github-move-linked-project-cards

Automate linked issues in project boards based on PR status
JavaScript
1
star
34

kube-teamcity

1
star
35

heroku-dough-buildpack

Heroku Buildpack for dough.js
Shell
1
star
36

phunweather

Java
1
star
37

lirc-mplay

lirc with patches for Moneual Moncaso 312/320
C
1
star
38

masker

Native masking tools for bitmaps.
C++
1
star
39

hashnote-issues

Issue tracking for hashnote
1
star
40

bug-viewpagerfragmentstatenpe

Sample project demonstrating the ViewPager Fragment state NPE.
Kotlin
1
star
41

template-dough.js

A template project for dough.js
1
star
42

Goodreads

Java
1
star
43

pager-deep-linking

Demo project for deep linking within lists within a ViewPager
Java
1
star
44

android-libcompat

Android library project for backwards compatibility of Activities based on Google's I/O 2011 app.
Java
1
star
45

migrate

Ruby script to compile SQL migration scripts into a deployable sql script.
Ruby
1
star
46

statusboard

JavaScript
1
star
47

dagger-submodule-issue

Highlights an issue with dagger submodules and visibility.
Kotlin
1
star