Created
April 30, 2012 02:49
-
-
Save xuwei-k/2555107 to your computer and use it in GitHub Desktop.
scala android Parcelable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.{Parcel,Parcelable} | |
class A(in:Parcel) extends android.os.Parcelable{ | |
override def describeContents():Int = 0 | |
override def writeToParcel(out:Parcel,flag:Int){ | |
} | |
val CREATOR:Parcelable.Creator[A] = new Parcelable.Creator[A]() { | |
def createFromParcel(in:Parcel):A = { | |
new A(in) | |
} | |
def newArray(size:Int):Array[A] = { | |
new Array[A](size) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.9.2" | |
libraryDependencies += "com.google.android" % "android" % "4.0.1.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class A extends java.lang.Object implements android.os.Parcelable,scala.ScalaObject{ | |
public static final android.os.Parcelable$Creator CREATOR; | |
public static {}; | |
public int describeContents(); | |
public void writeToParcel(android.os.Parcel, int); | |
public android.os.Parcelable$Creator CREATOR(); | |
public A(android.os.Parcel); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. Can you explain why/how this code generates STATIC field? Previously I've heard that this is not possible in scala without writing compiler plugins. So this is very interesting.