|
|
@@ -8,6 +8,8 @@ import android.graphics.PointF;
|
|
|
import android.graphics.Rect;
|
|
|
import android.graphics.RectF;
|
|
|
import android.graphics.drawable.ColorDrawable;
|
|
|
+import android.os.Parcel;
|
|
|
+import android.os.Parcelable;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.text.Layout;
|
|
|
import android.text.StaticLayout;
|
|
|
@@ -45,7 +47,7 @@ public class PieChartView extends View {
|
|
|
void pieChartDidEndTouch();
|
|
|
}
|
|
|
|
|
|
- public static class ChartItem implements Serializable {
|
|
|
+ public static class ChartItem implements Serializable, Parcelable {
|
|
|
|
|
|
private static final long serialVersionUID = 1437379045091025768L;
|
|
|
|
|
|
@@ -65,7 +67,36 @@ public class PieChartView extends View {
|
|
|
private float percentage;
|
|
|
private Size titleSize;
|
|
|
|
|
|
+ public ChartItem() {
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ protected ChartItem(Parcel in) {
|
|
|
+ shortTitle = in.readString();
|
|
|
+ display = in.readByte() != 0;
|
|
|
+ color = in.readInt();
|
|
|
+ value = in.readFloat();
|
|
|
+ title = in.readString();
|
|
|
+ titleColor = in.readInt();
|
|
|
+ startAngle = in.readFloat();
|
|
|
+ angle = in.readFloat();
|
|
|
+ endAngle = in.readFloat();
|
|
|
+ select = in.readByte() != 0;
|
|
|
+ titlePosition = in.readParcelable(PointF.class.getClassLoader());
|
|
|
+ percentage = in.readFloat();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static final Creator<ChartItem> CREATOR = new Creator<ChartItem>() {
|
|
|
+ @Override
|
|
|
+ public ChartItem createFromParcel(Parcel in) {
|
|
|
+ return new ChartItem(in);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ChartItem[] newArray(int size) {
|
|
|
+ return new ChartItem[size];
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
private int getColor() {
|
|
|
if (color == -1) {
|
|
|
@@ -137,6 +168,27 @@ public class PieChartView extends View {
|
|
|
private String getMessage() {
|
|
|
return String.format("%.2f%%",percentage * 100);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int describeContents() {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void writeToParcel(Parcel dest, int flags) {
|
|
|
+ dest.writeString(shortTitle);
|
|
|
+ dest.writeByte((byte) (display ? 1 : 0));
|
|
|
+ dest.writeInt(color);
|
|
|
+ dest.writeFloat(value);
|
|
|
+ dest.writeString(title);
|
|
|
+ dest.writeInt(titleColor);
|
|
|
+ dest.writeFloat(startAngle);
|
|
|
+ dest.writeFloat(angle);
|
|
|
+ dest.writeFloat(endAngle);
|
|
|
+ dest.writeByte((byte) (select ? 1 : 0));
|
|
|
+ dest.writeParcelable(titlePosition, flags);
|
|
|
+ dest.writeFloat(percentage);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static class Size implements Serializable {
|