Java 类android.arch.persistence.room.TypeConverter 实例源码

项目:PhotoExample    文件:SortPhotoConverter.java   
@TypeConverter
public SortPhotoEntity intToSortPhotoEntity(int value) {

   SortPhotoEntity result = null;

    if (value == SortPhotoEntity.LATEST.getCode()) {
        result = SortPhotoEntity.LATEST;
    }
    if (value == SortPhotoEntity.POPULAR.getCode()) {
        result = SortPhotoEntity.POPULAR;
    }
    if (value == SortPhotoEntity.OLDEST.getCode()) {
        result = SortPhotoEntity.OLDEST;
    }

    return result;
}
项目:SampleAppArch    文件:GithubTypeConverters.java   
@TypeConverter
public static List<Integer> stringToIntList(String data) {
  if (data == null) {
    return Collections.emptyList();
  }
  return StringUtil.splitToIntList(data);
}
项目:SampleAppArch    文件:TypeConvertor.java   
@TypeConverter
public static String stringToIntList(Date date) {
  if (date != null) {
    return new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH).format(date);
  }
  return new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH).format(new Date());
}
项目:SampleAppArch    文件:TypeConvertor.java   
@TypeConverter
public static Date intListToString(String date) {
  if (!date.equals("")) {
    try {
      return new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH).parse(date);
    } catch (ParseException e) {
      e.printStackTrace();
      return new Date();
    }
  }
  return new Date();
}
项目:elevator-room    文件:Person.java   
@TypeConverter
public static State toState(String state) {
    if (TextUtils.isEmpty(state)) {
        return State.LOBBY;
    }
    return State.valueOf(state);
}
项目:FitnessHabits    文件:CalendarDateConverter.java   
@TypeConverter
public CalendarDate fromString(String value) {

    if(value == null) {
        return null;
    }

    return CalendarDate.decodeFromString(value);
}
项目:FitnessHabits    文件:CalendarDateConverter.java   
@TypeConverter
public String toString(CalendarDate date) {
    if(date == null) {
        return null;
    }
    return date.encodeToString();
}
项目:FitnessHabits    文件:GenderConverter.java   
@TypeConverter
public Integer toInt(Gender value) {

    if(value == null) {
        return null;
    }

    return value.encodeToInt();
}
项目:igrow-android    文件:TypeConverters.java   
@TypeConverter
public Long dateToTimestamp(Date date) {
    if (date == null) {
        return null;
    } else {
        return date.getTime();
    }
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Date toDate(final Long value) {
    return value == null ? null : new Date(value);
}
项目:PADC-MyanmarAttractions-AC    文件:AttractionImagesTypeConverter.java   
@TypeConverter
public static String toString(String[] images) {
    StringBuilder stringBuilder = new StringBuilder();
    for (String image : images) {
        stringBuilder.append(image).append(",");
    }
    stringBuilder.deleteCharAt(stringBuilder.length() - 1);
    return stringBuilder.toString();
}
项目:elevator-room    文件:Person.java   
@TypeConverter
public static String toString(State state) {
    if (state == null) {
        return null;
    }
    return state.toString();
}
项目:LoriApp    文件:Converters.java   
@TypeConverter
public static String tagsToString(List<Tag> tags) {
    StringBuilder buffer = new StringBuilder();
    for (Tag tag : tags) {
        buffer.append(tag.getId()).append(":").append(tag.getName()).append(";");
    }
    return buffer.toString();
}
项目:SampleAppArch    文件:GithubTypeConverters.java   
@TypeConverter
public static String intListToString(List<Integer> ints) {
  return StringUtil.joinIntoString(ints);
}
项目:LoriApp    文件:Converters.java   
@TypeConverter
public static Project projectFromId(String id) {
    return id == null ? null : new Project(id);
}
项目:LoriApp    文件:Converters.java   
@TypeConverter
public static User userFromUserId(String id) {
    return id == null ? null : new User(id);
}
项目:labtablet    文件:Converters.java   
@TypeConverter
public static Date fromTimestamp(Long value) {
    return value == null ? null : new Date(value);
}
项目:labtablet    文件:Converters.java   
@TypeConverter
public static Long dateToTimestamp(Date date) {
    return date == null ? null : date.getTime();
}
项目:AndroidBlueprints    文件:EnumConverters.java   
@TypeConverter
public static String fromEnum(EnumUserStatus value) {
    // TODO: Handle null values
    return value.name();
}
项目:RoomDemo    文件:DateTypeConverter.java   
@TypeConverter
public static Long toLong(Date value) {
    return value == null ? null : value.getTime();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Long fromDate(final Date date) {
    return date == null ? null : date.getTime();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Date toDate(final Long value) {
    return value == null ? null : new Date(value);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static String fromFile(final File value) {
    return value == null ? null : value.getAbsolutePath();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static File toFile(final String path) {
    return path == null ? null : new File(path);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static String fromCategory(final Category value) {
    return value == null ? null : value.name();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Category toCategory(final String name) {
    return name == null ? null : Category.valueOf(name);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Attachment.Type toAttachmentType(final String name) {
    return name == null ? null : Attachment.Type.valueOf(name);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Long fromDate(final Date date) {
    return date == null ? null : date.getTime();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Date toDate(final Long value) {
    return value == null ? null : new Date(value);
}
项目:LoriApp    文件:Converters.java   
@TypeConverter
public static String taskToTaskId(Task task) {
    return task == null ? null : task.getId();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static File toFile(final String path) {
    return path == null ? null : new File(path);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static String fromCategory(final Category value) {
    return value == null ? null : value.name();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Category toCategory(final String name) {
    return name == null ? null : Category.valueOf(name);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static String fromAttachmentType(final Attachment.Type value) {
    return value == null ? null : value.name();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Attachment.Type toAttachmentType(final String name) {
    return name == null ? null : Attachment.Type.valueOf(name);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Long fromDate(final Date date) {
    return date == null ? null : date.getTime();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static String fromFile(final File value) {
    return value == null ? null : value.getAbsolutePath();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static File toFile(final String path) {
    return path == null ? null : new File(path);
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static String fromCategory(final Category value) {
    return value == null ? null : value.name();
}
项目:Hands-On-Android-UI-Development    文件:ClaimDatabase.java   
@TypeConverter
public static Category toCategory(final String name) {
    return name == null ? null : Category.valueOf(name);
}