Search in sources :

Example 1 with TypeConverter

use of android.arch.persistence.room.TypeConverter in project IITB-App by wncc.

the class Converters method stringfromEvents.

@TypeConverter
public static String stringfromEvents(List<Event> list) {
    Gson gson = new Gson();
    String json = gson.toJson(list);
    return json;
}
Also used : Gson(com.google.gson.Gson) TypeConverter(android.arch.persistence.room.TypeConverter)

Example 2 with TypeConverter

use of android.arch.persistence.room.TypeConverter in project IITB-App by wncc.

the class Converters method stringfromVenues.

@TypeConverter
public static String stringfromVenues(List<Venue> list) {
    Gson gson = new Gson();
    String json = gson.toJson(list);
    return json;
}
Also used : Gson(com.google.gson.Gson) TypeConverter(android.arch.persistence.room.TypeConverter)

Example 3 with TypeConverter

use of android.arch.persistence.room.TypeConverter in project IITB-App by wncc.

the class Converters method stringfromUsers.

@TypeConverter
public static String stringfromUsers(List<User> list) {
    Gson gson = new Gson();
    String json = gson.toJson(list);
    return json;
}
Also used : Gson(com.google.gson.Gson) TypeConverter(android.arch.persistence.room.TypeConverter)

Example 4 with TypeConverter

use of android.arch.persistence.room.TypeConverter in project IITB-App by wncc.

the class Converters method stringfromTimestamp.

@TypeConverter
public static String stringfromTimestamp(Timestamp timestamp) {
    Gson gson = new Gson();
    String json = gson.toJson(timestamp);
    return json;
}
Also used : Gson(com.google.gson.Gson) TypeConverter(android.arch.persistence.room.TypeConverter)

Example 5 with TypeConverter

use of android.arch.persistence.room.TypeConverter in project bugzy by cpunq.

the class BugzyTypeConverters method caseEventListFromString.

@TypeConverter
public static List<CaseEvent> caseEventListFromString(String value) {
    Type listType = new TypeToken<List<CaseEvent>>() {
    }.getType();
    List<CaseEvent> events = sGson.fromJson(value, listType);
    if (events != null) {
        Collections.sort(events, ((caseEvent, t1) -> Long.compare(t1.getDate().getTime(), caseEvent.getDate().getTime())));
    }
    return events;
}
Also used : CaseEvent(com.bluestacks.bugzy.data.model.CaseEvent) FieldNamingPolicy(com.google.gson.FieldNamingPolicy) List(java.util.List) TypeToken(com.google.gson.reflect.TypeToken) Type(java.lang.reflect.Type) Gson(com.google.gson.Gson) Date(java.util.Date) TypeConverter(android.arch.persistence.room.TypeConverter) Collections(java.util.Collections) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Type(java.lang.reflect.Type) List(java.util.List) ArrayList(java.util.ArrayList) CaseEvent(com.bluestacks.bugzy.data.model.CaseEvent) TypeConverter(android.arch.persistence.room.TypeConverter)

Aggregations

TypeConverter (android.arch.persistence.room.TypeConverter)7 Gson (com.google.gson.Gson)7 FieldNamingPolicy (com.google.gson.FieldNamingPolicy)2 GsonBuilder (com.google.gson.GsonBuilder)2 TypeToken (com.google.gson.reflect.TypeToken)2 Type (java.lang.reflect.Type)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Date (java.util.Date)2 List (java.util.List)2 CaseEvent (com.bluestacks.bugzy.data.model.CaseEvent)1 CaseEvent (in.bugzy.data.model.CaseEvent)1