use of me.himanshusoni.quantumflux.model.util.ContentResolverValues in project QuantumFlux by himanshu-soni.
the class QuantumFlux method delete.
public static <T> void delete(Select<T> select) {
ContentResolverValues contentResolverValues = select.asContentResolverValue();
ContentResolver contentResolver = mApplicationContext.getContentResolver();
contentResolver.delete(contentResolverValues.getItemUri(), contentResolverValues.getWhere(), contentResolverValues.getWhereArgs());
}
use of me.himanshusoni.quantumflux.model.util.ContentResolverValues in project QuantumFlux by himanshu-soni.
the class Select method queryAsCursor.
/**
* Executes the query and returns the results as a cursor. The {@link QuantumFluxCursor} is a wrapper for the normal cursor,
* and in addition to providing the normal cursor functionality, it also has methods to manipulate model objects, such as inflating the current cursor
* values to a model object.
*
* @return The {@link QuantumFluxCursor} containing the results
*/
public QuantumFluxCursor<T> queryAsCursor() {
ContentResolverValues contentResolverValues = asContentResolverValue();
ContentResolver contentResolver = QuantumFlux.getApplicationContext().getContentResolver();
Cursor cursor = contentResolver.query(contentResolverValues.getItemUri(), contentResolverValues.getProjection(), contentResolverValues.getWhere(), contentResolverValues.getWhereArgs(), contentResolverValues.getSortOrder());
return new QuantumFluxCursor<>(contentResolverValues.getTableDetails(), cursor);
}
use of me.himanshusoni.quantumflux.model.util.ContentResolverValues in project QuantumFlux by himanshu-soni.
the class Select method asContentResolverValue.
/**
* Packages this select into a {@link ContentResolverValues} package, this will contain all of the required arguments to run this query on
* a content resolver, it is used internally by all of the as* methods.
*
* @return The {@link ContentResolverValues} containing the arguments needed by the content resolver query method
*/
public ContentResolverValues asContentResolverValue() {
TableDetails tableDetails = QuantumFlux.findTableDetails(mDataObjectClass);
QueryBuilder where = buildWhereClause(QuantumFlux.getColumnMappingFactory());
QueryBuilder sort = buildSort();
Uri.Builder itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails);
if (mOffset != null)
itemUri.appendQueryParameter(QuantumFluxContentProvider.PARAMETER_OFFSET, mOffset.toString());
if (mLimit != null)
itemUri.appendQueryParameter(QuantumFluxContentProvider.PARAMETER_LIMIT, mLimit.toString());
return new ContentResolverValues(tableDetails, itemUri.build(), getProjection(tableDetails), where.getQueryString(), where.getQueryArgsAsArray(), sort.getQueryString());
}
Aggregations