本文整理汇总了Java中android.arch.persistence.room.TypeConverter类的典型用法代码示例。如果您正苦于以下问题:Java TypeConverter类的具体用法?Java TypeConverter怎么用?Java TypeConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeConverter类属于android.arch.persistence.room包,在下文中一共展示了TypeConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intToSortPhotoEntity
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@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;
}
示例2: toString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@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();
}
示例3: toString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static String toString(State state) {
if (state == null) {
return null;
}
return state.toString();
}
示例4: tagsToString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@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();
}
示例5: stringToIntList
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static List<Integer> stringToIntList(String data) {
if (data == null) {
return Collections.emptyList();
}
return StringUtil.splitToIntList(data);
}
示例6: intListToString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static String intListToString(List<Integer> ints) {
return StringUtil.joinIntoString(ints);
}
示例7: stringToIntList
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@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());
}
示例8: intListToString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@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();
}
示例9: toState
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static State toState(String state) {
if (TextUtils.isEmpty(state)) {
return State.LOBBY;
}
return State.valueOf(state);
}
示例10: fromString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public CalendarDate fromString(String value) {
if(value == null) {
return null;
}
return CalendarDate.decodeFromString(value);
}
示例11: toString
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public String toString(CalendarDate date) {
if(date == null) {
return null;
}
return date.encodeToString();
}
示例12: userFromUserId
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static User userFromUserId(String id) {
return id == null ? null : new User(id);
}
示例13: toInt
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public Integer toInt(Gender value) {
if(value == null) {
return null;
}
return value.encodeToInt();
}
示例14: fromTimestamp
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static Date fromTimestamp(Long value) {
return value == null ? null : new Date(value);
}
示例15: dateToTimestamp
import android.arch.persistence.room.TypeConverter; //导入依赖的package包/类
@TypeConverter
public static Long dateToTimestamp(Date date) {
return date == null ? null : date.getTime();
}