package vandy.mooc.common; import java.io.Serializable; import android.content.Context; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; /** * @@ TO DO */ public abstract class ParcelableCommand implements Serializable, Parcelable { /** * A UID generated by Eclipse for serialization purposes. */ private static final long serialVersionUID = 2915895796465718372L; /** * Default constructor. */ public ParcelableCommand() { } /** * Execute the command in a particular @a context, passing in * the @a args. */ public abstract void execute(Context context, Bundle args); /** * Unexecute the command in a particular @a context. */ public abstract void unexecute(Context context); /* * BELOW THIS is related to Parcelable Interface. */ /** * A bitmask indicating the set of special object types marshaled * by the Parcelable. */ @Override public int describeContents() { return 0; } /** * Write this instance out to byte contiguous memory. */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeSerializable(this); } /** * Private constructor provided for the CREATOR interface, which * is used to de-marshal an SongPlayingStrategy from the Parcel of data. * <p> * The order of reading in variables HAS TO MATCH the order in * writeToParcel(Parcel, int) * * @param in */ private ParcelableCommand(Parcel in) { // If there were fields we'd initialize them here from the // Parcel parameter. } /** * public Parcelable.Creator for ParcelableCommand, which is an * interface that must be implemented and provided as a public * CREATOR field that generates instances of your Parcelable class * from a Parcel. */ public static final Parcelable.Creator<ParcelableCommand> CREATOR = new Parcelable.Creator<ParcelableCommand>() { public ParcelableCommand createFromParcel(Parcel in) { return (ParcelableCommand) in.readSerializable(); } public ParcelableCommand[] newArray(int size) { return new ParcelableCommand[size]; } }; }