Search in sources :

Example 1 with FinderLazyLoader

use of com.lidroid.xutils.db.sqlite.FinderLazyLoader in project xUtils by wyouflf.

the class Finder method setValue2Entity.

@Override
public void setValue2Entity(Object entity, Cursor cursor, int index) {
    Object value = null;
    Class<?> columnType = columnField.getType();
    Object finderValue = TableUtils.getColumnOrId(entity.getClass(), this.valueColumnName).getColumnValue(entity);
    if (columnType.equals(FinderLazyLoader.class)) {
        value = new FinderLazyLoader(this, finderValue);
    } else if (columnType.equals(List.class)) {
        try {
            value = new FinderLazyLoader(this, finderValue).getAllFromDb();
        } catch (DbException e) {
            LogUtils.e(e.getMessage(), e);
        }
    } else {
        try {
            value = new FinderLazyLoader(this, finderValue).getFirstFromDb();
        } catch (DbException e) {
            LogUtils.e(e.getMessage(), e);
        }
    }
    if (setMethod != null) {
        try {
            setMethod.invoke(entity, value);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
        }
    } else {
        try {
            this.columnField.setAccessible(true);
            this.columnField.set(entity, value);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
        }
    }
}
Also used : List(java.util.List) FinderLazyLoader(com.lidroid.xutils.db.sqlite.FinderLazyLoader) DbException(com.lidroid.xutils.exception.DbException)

Aggregations

FinderLazyLoader (com.lidroid.xutils.db.sqlite.FinderLazyLoader)1 DbException (com.lidroid.xutils.exception.DbException)1 List (java.util.List)1