Search in sources :

Example 1 with ContentResolverValues

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());
}
Also used : ContentResolverValues(me.himanshusoni.quantumflux.model.util.ContentResolverValues) ContentResolver(android.content.ContentResolver)

Example 2 with ContentResolverValues

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);
}
Also used : ContentResolverValues(me.himanshusoni.quantumflux.model.util.ContentResolverValues) QuantumFluxCursor(me.himanshusoni.quantumflux.model.util.QuantumFluxCursor) QuantumFluxCursor(me.himanshusoni.quantumflux.model.util.QuantumFluxCursor) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Example 3 with ContentResolverValues

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());
}
Also used : TableDetails(me.himanshusoni.quantumflux.model.generate.TableDetails) ContentResolverValues(me.himanshusoni.quantumflux.model.util.ContentResolverValues) Uri(android.net.Uri)

Aggregations

ContentResolverValues (me.himanshusoni.quantumflux.model.util.ContentResolverValues)3 ContentResolver (android.content.ContentResolver)2 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 TableDetails (me.himanshusoni.quantumflux.model.generate.TableDetails)1 QuantumFluxCursor (me.himanshusoni.quantumflux.model.util.QuantumFluxCursor)1