If you think the Android project epgreader-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.jeffpalm.android.tmz.model;
/*fromwww.java2s.com*/import android.os.Parcel;
import android.os.Parcelable;
import com.jeffpalm.android.epg.EPG;
/**
* A TMZ feed.
*/publicclass TMZ extends TMZFactoryHolder {
privatefinal TMZSection section;
privatefinal TMZIndex index;
privatestatic TMZSection getSection(TMZAdapter factory, EPG epg) {
if (epg.getSections().isEmpty()) {
thrownew RuntimeException("No main section.");
}
if (epg.getSections().size() > 1) {
thrownew RuntimeException("There should only be one section.");
}
return (TMZSection) factory.adapt(epg.getSections().get(0));
}
privatestatic TMZIndex getIndex(TMZAdapter factory, EPG epg) {
return (TMZIndex) factory.adapt(epg.getEgpIndex());
}
public TMZ(EPG epg) {
this(DefaultTMZAdapter.getInstance(), epg);
}
public TMZ(TMZAdapter factory, EPG epg) {
this(factory, getSection(factory, epg), getIndex(factory, epg));
}
public TMZ(TMZAdapter factory, TMZSection section, TMZIndex index) {
super(factory);
this.section = section;
this.index = index;
}
public TMZ(Parcel in) {
this(DefaultTMZAdapter.getInstance(), (TMZSection) in
.readParcelable(TMZ.class.getClassLoader()), (TMZIndex) in.readParcelable(TMZ.class
.getClassLoader()));
}
/** @return the main TMZ section */public TMZSection getSection() {
return section;
}
/** @return the TMZ index */public TMZIndex getIndex() {
return index;
}
@Override
publicint hashCode() {
return section.hashCode() + index.hashCode();
}
@Override
publicboolean equals(Object o) {
if (!(o instanceof TMZ)) {
return false;
}
TMZ that = (TMZ) o;
return this.section.equals(that.section) && this.index.equals(that.index);
}
@Override
protectedvoid writeToParcelAfterFactory(Parcel dest, int flags) {
dest.writeParcelable(section, flags);
dest.writeParcelable(index, flags);
}
@SuppressWarnings("rawtypes")
publicstaticfinal Parcelable.Creator CREATOR = new Parcelable.Creator() {
public TMZ createFromParcel(Parcel in) {
returnnew TMZ(in);
}
public TMZ[] newArray(int size) {
returnnew TMZ[size];
}
};
}