无限循环in.readTypedList方法android parcelable

无限循环in.readTypedList方法android parcelable,android,arraylist,out-of-memory,infinite-loop,parcelable,Android,Arraylist,Out Of Memory,Infinite Loop,Parcelable,我遇到2深度包裹的问题。我有3个类,包括它们自己作为这个模式: Serie List<Qcm> List<Proposition> Serie.java 如果你还需要别的东西,请告诉我。我已经在这上面呆了好几个小时了,我真的不明白。 谢谢 最后使用一个变通解决方案,我一直在使用我的JSON响应,将它与附加内容一起提供给下一个活动,并在下一个活动上构建我的对象 我认为这是一个奇怪的解决方案,但似乎叠瓦包裹的对象变得粗糙,深度太长 希望有帮助。如果您

我遇到2深度包裹的问题。我有3个类,包括它们自己作为这个模式:

Serie
    List<Qcm>
        List<Proposition>
Serie.java

如果你还需要别的东西,请告诉我。我已经在这上面呆了好几个小时了,我真的不明白。
谢谢

最后使用一个变通解决方案,我一直在使用我的JSON响应,将它与附加内容一起提供给下一个活动,并在下一个活动上构建我的对象

我认为这是一个奇怪的解决方案,但似乎叠瓦包裹的对象变得粗糙,深度太长


希望有帮助。

如果您有多深度的包裹,您应该尝试为其创建一个包含大量数据的单元测试,以查看它是否没有内存不足或加载时间过长。带有基元类型的简单列表不应该是个大问题,但是当对象变得更复杂时,它会占用大量内存和时间。我将在下一版本中尝试,谢谢您的建议。老实说,就我个人而言,我认为这不是复杂对象的问题,因为我的对象上使用最多的类型是原语。不过,我会试试你的建议。
04-18 15:19:19.565  14089-14089/com.examed.maprepaquotidienne D/MPQ.Qcm.createFromParcel﹕ qcm cree
04-18 15:19:19.570  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.570  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.570  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.570  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.575  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.575  14089-14089/com.examed.maprepaquotidienne D/MPQ.Qcm.createFromParcel﹕ qcm cree
04-18 15:19:19.575  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.575  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.580  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.580  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.580  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.580  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.580  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.585  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.585  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.585  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.585  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.590  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.590  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.590  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.590  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.590  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.600  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
04-18 15:19:19.600  14089-14089/com.examed.maprepaquotidienne D/MPQ.Proposition.createFromParcel﹕ proposition cree
package examed.lib.classes;

import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import examed.lib.DAO.FrequenceDAO;
import examed.lib.DAO.SerieDAO;
import examed.lib.DAO.UEDAO;
import examed.lib.workers.APIHelper;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Serie implements Parcelable
{

    private int id;
    private UE uniteEnseignement;
    private Frequence frq;
    private int type;
    private String authorFirstname, authorName, authorAvatar;
    private Date datePublication;
    private int anneeSerie, nbQcm, order;
    private String title, subtitle;
    private String beforeText;
    private String afterText;
    private List<Qcm> listeQcm = new ArrayList<Qcm>();
    private float chanceCoeff;
    private boolean enCreation;
    private boolean publiee;
    private Date dateValidationPubliee;
    private Date dateFinCreation;
    private int maxTime;
    private int statut;

    public Serie(Parcel in) throws ParseException, NullPointerException
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        this.id = in.readInt();
        this.uniteEnseignement = in.readParcelable(UE.class.getClassLoader());
        this.frq = in.readParcelable(Frequence.class.getClassLoader());
        this.type = in.readInt();
        this.authorFirstname = in.readString();
        this.authorName = in.readString();
        this.authorAvatar = in.readString();
        this.datePublication = dateFormat.parse(in.readString());
        this.anneeSerie = in.readInt();
        this.nbQcm = in.readInt();
        this.order = in.readInt();
        this.title = in.readString();
        this.subtitle = in.readString();
        this.beforeText = in.readString();
        this.afterText = in.readString();
        in.readTypedList(this.listeQcm, Qcm.CREATOR);
        this.chanceCoeff = in.readFloat();
        this.enCreation = (in.readInt() > 0);
        this.publiee = (in.readInt() > 0);
        this.dateValidationPubliee = dateFormat.parse(in.readString());
        this.dateFinCreation = dateFormat.parse(in.readString());
        this.maxTime = in.readInt();
        this.statut = in.readInt();
    }

    [...]

    // region [PARCELABLE]

    @Override
    public int describeContents()
    {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeInt(this.id);
        dest.writeParcelable(this.uniteEnseignement, flags);
        dest.writeParcelable(this.frq, flags);
        dest.writeInt(this.type);
        dest.writeString(this.authorFirstname);
        dest.writeString(this.authorName);
        dest.writeString(this.authorAvatar);
        dest.writeString(this.getDatePublication());
        dest.writeInt(this.anneeSerie);
        dest.writeInt(this.nbQcm);
        dest.writeInt(this.order);
        dest.writeString(this.title);
        dest.writeString(this.subtitle);
        dest.writeString(this.beforeText);
        dest.writeString(this.afterText);
        dest.writeTypedList(this.listeQcm);
        dest.writeDouble((double) this.chanceCoeff);
        dest.writeInt((this.enCreation) ? 1 : 0);
        dest.writeInt((this.publiee) ? 1 : 0);
        dest.writeString(this.getDateValidationPubliee());
        dest.writeString(this.getDateFinCreation());
        dest.writeInt(this.maxTime);
        dest.writeInt(this.statut);
    }

    public static final Parcelable.Creator<Serie> CREATOR = new Parcelable.Creator<Serie>()
    {
        @Override
        public Serie createFromParcel(Parcel source)
        {
            Serie serie = null;

            try {
                serie = new Serie(source);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            return serie;
        }

        @Override
        public Serie[] newArray(int size)
        {
            return new Serie[size];
        }
    };

    // endregion
}
package examed.lib.classes;

import android.os.Parcel;
import android.os.Parcelable;
import examed.lib.workers.APIHelper;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Qcm implements Parcelable
{
    private int id;
    private String question;
    private int typeNotation;
    private List<Proposition> propositions = new ArrayList<Proposition>();
    private Date dateCreation;
    private Date dateUpdate;
    private int typeChapitre;
    private boolean validee;
    private int annee;
    private boolean origineAnnale;
    private float coeff;
    private int duree;

    public static String FIELD_QCM_ID = "QCMID";
    public static String FIELD_QCM_QUESTION = "Question";
    public static String FIELD_QCM_TYPE_NOTATION_ID = "TypeNotationID";
    public static String FIELD_QCM_DATE_CREATION = "DateCreation";
    public static String FIELD_QCM_DATE_MODIF = "DateUpdate";
    public static String FIELD_QCM_TYPE_CHAPITRE = "TypeChapitreID";
    public static String FIELD_QCM_VALIDEE = "Validee";
    public static String FIELD_QCM_ANNEE = "Annee";
    public static String FIELD_QCM_ORIGINE_ANNALE = "OrigineAnnale";
    public static String FIELD_QCM_COEFF = "coef";
    public static String FIELD_QCM_DUREE = "dureeQCM";


    public Qcm(Parcel in) throws ParseException
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        this.id = in.readInt();
        this.question = in.readString();
        this.typeNotation = in.readInt();
        in.readTypedList(this.propositions, Proposition.CREATOR);
        this.dateCreation = dateFormat.parse(in.readString());
        this.dateUpdate = dateFormat.parse(in.readString());
        this.typeChapitre = in.readInt();
        this.validee = (in.readInt() > 0);
        this.annee = in.readInt();
        this.origineAnnale = (in.readInt() > 0);
        this.coeff = in.readFloat();
        this.duree = in.readInt();
    }

    // region [PARCELABLE]

    @Override
    public int describeContents()
    {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags)
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        dest.writeInt(this.id);
        dest.writeString(this.question);
        dest.writeInt(this.typeNotation);
        dest.writeTypedList(this.propositions);
        dest.writeString(dateFormat.format(this.dateCreation));
        dest.writeString(dateFormat.format(this.dateUpdate));
        dest.writeInt(this.typeChapitre);
        dest.writeInt((this.validee) ? 1 : 0);
        dest.writeInt(this.annee);
        dest.writeInt((this.origineAnnale) ? 1 : 0);
        dest.writeDouble((double)this.coeff);
        dest.writeInt(this.duree);
    }

    public static final Parcelable.Creator<Qcm> CREATOR = new Parcelable.Creator<Qcm>()
    {
        @Override
        public Qcm createFromParcel(Parcel source)
        {
            Qcm qcm = null;
            APIHelper.log('d', "qcm cree");
            try {
                qcm = new Qcm(source);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            return qcm;
        }

        @Override
        public Qcm[] newArray(int size)
        {
            return new Qcm[size];
        }
    };

    // endregion

}
package examed.lib.classes;

import android.os.Parcel;
import android.os.Parcelable;
import examed.lib.workers.APIHelper;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Proposition implements Parcelable
{

    private String content;
    private boolean toCheck;
    private String correction;


    public Proposition(Parcel in) throws ParseException
    {
        this.content = in.readString();
        this.toCheck = (in.readInt() > 0);
        this.correction = in.readString();
    }

    // region [PARCELABLE]

    @Override
    public int describeContents()
    {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeString(this.content);
        dest.writeInt((this.toCheck) ? 1 : 0);
        dest.writeString(this.correction);
    }

    public static final Parcelable.Creator<Proposition> CREATOR = new Parcelable.Creator<Proposition>()
    {
        @Override
        public Proposition createFromParcel(Parcel source)
        {
            Proposition proposition = null;

            try {
                proposition = new Proposition(source);
                APIHelper.log('d', "proposition cree");
            } catch (ParseException e) {
                e.printStackTrace();
            }

            return proposition;
        }

        @Override
        public Proposition[] newArray(int size)
        {
            return new Proposition[size];
        }
    };

    // endregion

}
Intent intent = getIntent();

if(intent.getExtras() != null)
{
    APIHelper.log('d', intent.getExtras().getParcelable("SELECTED_SERIE"));
    this.serie = intent.getExtras().getParcelable("SELECTED_SERIE");
    APIHelper.log('d', this.serie);
}