protected <TYPE extends AbstractModel> SquidCursor<TYPE> fetchFirstItem(Class<TYPE> modelClass, Query query) { boolean immutableQuery = query.isImmutable(); Field<Integer> beforeLimit = query.getLimit(); SqlTable<?> beforeTable = query.getTable(); query = query.limit(1); // If argument was frozen, we may get a new object SquidCursor<TYPE> cursor = query(modelClass, query); if (!immutableQuery) { query.from(beforeTable).limit(beforeLimit); // Reset for user } cursor.moveToFirst(); return cursor; }
@Override public SquidCursor<T> loadInBackground() { SquidCursor<T> result = database.query(modelClass, query); if (result != null) { result.getCount(); // Make sure the window is filled Cursor androidResult = (Cursor) result.getCursor(); androidResult.registerContentObserver(observer); if (notificationUri != null) { androidResult.setNotificationUri(getContext().getContentResolver(), notificationUri); } } return result; }
@Override public SquidCursor<T> loadInBackground() { SquidCursor<T> result = database.query(modelClass, query); if (result != null) { result.getCount(); // Make sure the window is filled Cursor androidResult = (Cursor) result.getCursor(); androidResult.registerContentObserver(observer); if (notificationUri != null) { androidResult.setNotificationUri(getContext().getContentResolver(), notificationUri); } } return result; }
protected <TYPE extends AbstractModel> SquidCursor<TYPE> fetchFirstItem(Class<TYPE> modelClass, Query query) { boolean immutableQuery = query.isImmutable(); Field<Integer> beforeLimit = query.getLimit(); SqlTable<?> beforeTable = query.getTable(); query = query.limit(1); // If argument was frozen, we may get a new object SquidCursor<TYPE> cursor = query(modelClass, query); if (!immutableQuery) { query.from(beforeTable).limit(beforeLimit); // Reset for user } cursor.moveToFirst(); return cursor; }