From 4a196102a11cb8b2e2f94a715bbf21c136a9e29c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 8 Mar 2017 14:40:12 +0000 Subject: [PATCH] Collection info: serialize url, but not to json. --- .../syncadapter/model/CollectionInfo.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java b/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java index 105c2065..2d7aa500 100644 --- a/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java +++ b/app/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java @@ -10,34 +10,44 @@ package com.etesync.syncadapter.model; import android.content.ContentValues; +import com.etesync.syncadapter.model.ServiceDB.Collections; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; + import java.io.Serializable; -import com.etesync.syncadapter.GsonHelper; -import com.etesync.syncadapter.model.ServiceDB.Collections; import lombok.ToString; @ToString public class CollectionInfo implements Serializable { - public transient long id; - public transient Long serviceID; + public long id; + public Long serviceID; public enum Type { ADDRESS_BOOK, CALENDAR } + @Expose public Type type; - public transient String url; // Essentially the uuid + public String url; // Essentially the uuid + @Expose public boolean readOnly; + @Expose public String displayName, description; + @Expose public Integer color; + @Expose public String timeZone; + @Expose public Boolean supportsVEVENT; + @Expose public Boolean supportsVTODO; + @Expose public boolean selected; public CollectionInfo() { @@ -104,11 +114,11 @@ public class CollectionInfo implements Serializable { } public static CollectionInfo fromJson(String json) { - return GsonHelper.gson.fromJson(json, CollectionInfo.class); + return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, CollectionInfo.class); } public String toJson() { - return GsonHelper.gson.toJson(this, CollectionInfo.class); + return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(this, CollectionInfo.class); } private static Boolean getAsBooleanOrNull(ContentValues values, String field) {