Skip to content

Instantly share code, notes, and snippets.

@null-dev
Last active February 12, 2016 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save null-dev/f0bf2daa32217dd105c0 to your computer and use it in GitHub Desktop.
Save null-dev/f0bf2daa32217dd105c0 to your computer and use it in GitHub Desktop.
Object that was involved in the crash. (https://github.com/Stuart-campbell/RushOrm/issues/99)
package xyz.nulldev.slickmangaapp.model.manga;
import android.os.Parcel;
import android.os.Parcelable;
import java.net.URL;
import java.util.ArrayList;
import java.util.UUID;
import co.uk.rushorm.core.RushObject;
import co.uk.rushorm.core.annotations.RushList;
import xyz.nulldev.slickmangaapp.model.bitmap.SlickBitmap;
import xyz.nulldev.slickmangaapp.model.migration.Migratable;
import xyz.nulldev.slickmangaapp.model.migration.MigrationStrategy;
import xyz.nulldev.slickmangaapp.model.orm.RushString;
import xyz.nulldev.slickmangaapp.utils.ORMUtils;
/**
* Project: SlickMangaApp
* Created: 25/01/16
* Author: hc
*/
public class Manga extends RushObject implements Parcelable, Migratable<Manga> {
//Version code of current structure for migrating
public static final double VERSION = 0.1;
public static final Creator<Manga> CREATOR = new Creator<Manga>() {
public Manga createFromParcel(Parcel source) {
return new Manga(source);
}
public Manga[] newArray(int size) {
return new Manga[size];
}
};
UUID uuid = null;
UUID sourceUUID = null;
String title = null;
Status status = null;
@RushList(classType = RushString.class)
ArrayList<RushString> genres = new ArrayList<>();
String author = null;
URL url = null;
SlickBitmap coverImage = null;
String synopsis = null;
@RushList(classType = Chapter.class)
ArrayList<Chapter> chapters = new ArrayList<>();
String serializedSource = null;
/**
* DO NOT USE, ONLY FOR USE BY RUSHORM
*/
@Deprecated
public Manga() {
}
public Manga(UUID sourceUUID, String title, Status status, String author, String synopsis, URL url, SlickBitmap coverImage) {
this.sourceUUID = sourceUUID;
this.title = title;
this.status = status;
this.author = author;
this.url = url;
this.coverImage = coverImage;
this.uuid = UUID.randomUUID();
}
public Manga(UUID sourceUUID, String title, Status status, ArrayList<String> genres, String author, String synopsis, URL url, SlickBitmap coverImage, ArrayList<Chapter> chapters) {
this(sourceUUID, title, status, author, synopsis, url, coverImage); // Call constructor to generate ID field
this.genres = ORMUtils.convert(genres, RushString.class);
this.chapters = chapters;
}
protected Manga(Parcel in) {
this.uuid = (UUID) in.readSerializable();
this.sourceUUID = (UUID) in.readSerializable();
this.title = in.readString();
int tmpStatus = in.readInt();
this.status = tmpStatus == -1 ? null : Status.values()[tmpStatus];
this.genres = in.createTypedArrayList(RushString.CREATOR);
this.author = in.readString();
this.url = (URL) in.readSerializable();
this.coverImage = in.readParcelable(SlickBitmap.class.getClassLoader());
this.synopsis = in.readString();
this.chapters = in.createTypedArrayList(Chapter.CREATOR);
this.serializedSource = in.readString();
}
public UUID getUuid() {
return uuid;
}
public UUID getSourceUUID() {
return sourceUUID;
}
public void setSourceUUID(UUID sourceUUID) {
this.sourceUUID = sourceUUID;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public ArrayList<String> getGenres() {
return ORMUtils.convert(genres, String.class);
}
public void setGenres(ArrayList<String> genres) {
this.genres = ORMUtils.convert(genres, RushString.class);
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getSynopsis() {
return synopsis;
}
public void setSynopsis(String synopsis) {
this.synopsis = synopsis;
}
public URL getUrl() {
return url;
}
public void setUrl(URL url) {
this.url = url;
}
public SlickBitmap getCoverImage() {
return coverImage;
}
public void setCoverImage(SlickBitmap coverImage) {
this.coverImage = coverImage;
}
public ArrayList<Chapter> getChapters() {
return chapters;
}
public void setChapters(ArrayList<Chapter> chapters) {
this.chapters = chapters;
}
public String getSerializedSource() {
return serializedSource;
}
public void setSerializedSource(String serializedSource) {
this.serializedSource = serializedSource;
}
/**
* ================= [PARCELABLE CODE] =================
**/
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeSerializable(this.uuid);
dest.writeSerializable(this.sourceUUID);
dest.writeString(this.title);
dest.writeInt(this.status == null ? -1 : this.status.ordinal());
dest.writeTypedList(genres);
dest.writeString(this.author);
dest.writeSerializable(this.url);
dest.writeParcelable(this.coverImage, 0);
dest.writeString(this.synopsis);
dest.writeTypedList(chapters);
dest.writeString(this.serializedSource);
}
/**
* ================= [MIGRATION CODE] =================
**/
@Override
public ArrayList<MigrationStrategy<Manga>> getMigrationStrategies() {
return null;
}
@Override
public double getRequiredVersion() {
return VERSION;
}
@Override
public int describeContents() {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment