Search in sources :

Example 31 with TableDetails

use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.

the class QuantumFluxSyncHelper method delete.

public static <T> void delete(Context context, ContentProviderClient provider, T dataModelObject) throws RemoteException {
    TableDetails tableDetails = QuantumFlux.findTableDetails(dataModelObject.getClass());
    Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
    Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails, String.valueOf(columnValue)).appendQueryParameter(QuantumFluxContentProvider.PARAMETER_SYNC, "false").build();
    provider.delete(itemUri, null, null);
}
Also used : TableDetails(me.himanshusoni.quantumflux.model.generate.TableDetails) Uri(android.net.Uri)

Example 32 with TableDetails

use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.

the class QuantumFluxContentProvider method notifyChanges.

private void notifyChanges(Uri uri, TableDetails tableDetails) {
    Boolean sync = uri.getBooleanQueryParameter(PARAMETER_SYNC, true);
    getContext().getContentResolver().notifyChange(uri, null, sync);
    List<Class<?>> changeListeners = tableDetails.getChangeListeners();
    if (!changeListeners.isEmpty()) {
        for (int i = 0; i < changeListeners.size(); i++) {
            Class<?> changeListener = changeListeners.get(i);
            TableDetails changeListenerDetails = mDatabase.getTableDetailsCache().findTableDetails(getContext(), changeListener);
            if (changeListenerDetails == null) {
                continue;
            }
            //Change listeners are registered on views, so the entire view needs to be updated if changes to its data occurs
            Uri changeUri = mUriMatcherHelper.generateItemUri(changeListenerDetails);
            getContext().getContentResolver().notifyChange(changeUri, null, sync);
        }
    }
}
Also used : TableDetails(me.himanshusoni.quantumflux.model.generate.TableDetails) Uri(android.net.Uri)

Aggregations

TableDetails (me.himanshusoni.quantumflux.model.generate.TableDetails)32 Uri (android.net.Uri)22 ContentValues (android.content.ContentValues)17 ContentResolver (android.content.ContentResolver)9 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5 Cursor (android.database.Cursor)2 UriMatcher (android.content.UriMatcher)1 ContentResolverValues (me.himanshusoni.quantumflux.model.util.ContentResolverValues)1 CursorIterator (me.himanshusoni.quantumflux.model.util.CursorIterator)1 QuantumFluxException (me.himanshusoni.quantumflux.model.util.QuantumFluxException)1