use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class UriMatcherHelper method init.
public void init(Context context, TableDetailsCache detailsCache) {
mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
int matcherInterval = MATCHER_CODE_INTERVALS;
for (Class<?> dataModelObject : ReflectionHelper.getDomainClasses(context, ReflectionHelper.TableType.TABLE)) {
TableDetails tableDetails = detailsCache.findTableDetails(context, dataModelObject);
mMatcherCodes.put(matcherInterval, tableDetails);
mUriMatcher.addURI(mAuthority, tableDetails.getTableName(), matcherInterval + MATCHER_ALL);
mUriMatcher.addURI(mAuthority, tableDetails.getTableName() + "/*", matcherInterval + MATCHER_SINGLE);
matcherInterval += MATCHER_CODE_INTERVALS;
}
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class UriMatcherHelper method getType.
public String getType(Uri uri) {
int matchCode = mUriMatcher.match(uri);
TableDetails tableDetails = findTableDetails(matchCode);
StringBuilder mimeType = new StringBuilder();
mimeType.append("android.cursor.");
if (isSingleItemRequested(matchCode))
mimeType.append(".item");
else
mimeType.append(".dir");
mimeType.append("/");
mimeType.append("vnd.");
mimeType.append(mAuthority);
if (mimeType.charAt(mimeType.length() - 1) != '.')
mimeType.append(".");
mimeType.append(tableDetails.getTableName());
return mimeType.toString();
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method insertAll.
public static <T> int insertAll(ContentProviderClient providerClient, List<T> dataModelObjects) throws RemoteException {
if (dataModelObjects == null || dataModelObjects.isEmpty())
return 0;
TableDetails tableDetails = findTableDetails(dataModelObjects.get(0).getClass());
Uri insertUri = UriMatcherHelper.generateItemUriBuilder(tableDetails).build();
ContentValues[] values = new ContentValues[dataModelObjects.size()];
for (int i = 0; i < dataModelObjects.size(); i++) {
values[i] = ModelInflater.deflate(tableDetails, dataModelObjects.get(i));
}
return providerClient.bulkInsert(insertUri, values);
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method delete.
public static <T> void delete(T dataModelObject) {
TableDetails tableDetails = findTableDetails(dataModelObject.getClass());
Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails, String.valueOf(columnValue)).build();
ContentResolver contentResolver = mApplicationContext.getContentResolver();
contentResolver.delete(itemUri, null, null);
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method deleteAll.
public static <T> void deleteAll(Class<T> dataModel) {
TableDetails tableDetails = findTableDetails(dataModel);
Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails).build();
ContentResolver contentResolver = getApplicationContext().getContentResolver();
contentResolver.delete(itemUri, null, null);
}
Aggregations