PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.64k stars 9.02k forks source link

Parcelable #2978

Open ghost opened 7 years ago

ghost commented 7 years ago
public class DataForBinding implements Parcelable {

    public ArrayList<BarEntry> barEntries;
    public ArrayList<CandleEntry> candleEntries;
    public ArrayList<Entry> lineEntries;

    public DataForBinding() {

    }

    protected DataForBinding(Parcel in) {

        candleEntries = in.readArrayList(CandleEntry.class.getClassLoader());
        barEntries = in.readArrayList(BarEntry.class.getClassLoader());
        lineEntries = in.readArrayList(Entry.class.getClassLoader());

    }

    public static final Creator<DataForBinding> CREATOR = new Creator<DataForBinding>() {
        @Override
        public DataForBinding createFromParcel(Parcel in) {
            return new DataForBinding(in);
        }

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

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeList(barEntries);
        dest.writeList(candleEntries);
        dest.writeList(lineEntries);
    }

    private void readFromParcel(Parcel in) {
    }
    public ArrayList<BarEntry> getBarEntries() {
        return barEntries;
    }

    public void setBarEntries(ArrayList<BarEntry> barEntries) {
        this.barEntries = barEntries;
    }

    public ArrayList<CandleEntry> getCandleEntries() {
        return candleEntries;
    }

    public void setCandleEntries(ArrayList<CandleEntry> candleEntries) {
        this.candleEntries = candleEntries;
    }

    public ArrayList<Entry> getLineEntries() {
        return lineEntries;
    }

    public void setLineEntries(ArrayList<Entry> lineEntries) {
        this.lineEntries = lineEntries;
    }

}

its wrong ,how to write correctly

drawers commented 7 years ago

Answered on StackOverflow:

http://stackoverflow.com/questions/43121992/parcelable-objct-with-another-types-mpandroidchart/43166651