diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d8a54..7d98b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Android ContentProvider Generator Changelog =========================================== +v1.13.0 (2017-02-20) +------ +- `XyzSelection.getCursorLoader()` now returns loaders of wrapped cursors. +- New `XyzContentValues.notify(boolean)` method to enable/disable notifications. +- New `debugLogsFieldName` attribute to enable/disable debug logging in the generated code. + v1.12.0 (2017-02-06) ------ This is a somewhat big update in the way the tool is used, and there are also a few syntax differences. diff --git a/README.md b/README.md index 7e75321..c2890b6 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Add this to your app's `build.gradle`: ```groovy buildscript { dependencies { - classpath "org.jraf:acpg-gradle-plugin:1.12.0" + classpath "org.jraf:acpg-gradle-plugin:1.13.0" } } @@ -94,6 +94,10 @@ acpg { // Optional - default value: true generateBeans true + // Name of a boolean field in BuildConfig to enable/disable debug logging in the generated code + // Optional - default value: "DEBUG" + debugLogsFieldName LOG_DEBUG_PROVIDER + // Version of the tool syntax (must be 4) // The allows to break the build immediately if an incompatible version of the tool is used. Safety first! // Optional - default value: 4 @@ -122,7 +126,8 @@ Here is an example: "enableForeignKeys": true, "useAnnotations": true, "useSupportLibrary": true, - "generateBeans": true + "generateBeans": true, + "debugLogsFieldName": "LOG_DEBUG_PROVIDER" } ``` @@ -131,10 +136,10 @@ Not to be confused with the `applicationId` (see https://developer.android.com/s #### Get and run the tool -Download the `acpg-cli-1.12.0.jar` file here: +Download the `acpg-cli-1.13.0.jar` file here: https://github.com/BoD/android-contentprovider-generator/releases/latest -`java -jar acpg-cli-1.12.0.jar -i -o ` +`java -jar acpg-cli-1.13.0.jar -i -o ` - Input folder: where to find `_config.json` and your entity json files - Output folder: where the resulting files will be generated diff --git a/acpg-gradle-plugin/src/main/groovy/org/jraf/acpg/gradleplugin/AcpgPluginExtension.groovy b/acpg-gradle-plugin/src/main/groovy/org/jraf/acpg/gradleplugin/AcpgPluginExtension.groovy index 8233843..9c826f3 100644 --- a/acpg-gradle-plugin/src/main/groovy/org/jraf/acpg/gradleplugin/AcpgPluginExtension.groovy +++ b/acpg-gradle-plugin/src/main/groovy/org/jraf/acpg/gradleplugin/AcpgPluginExtension.groovy @@ -90,4 +90,8 @@ class AcpgPluginExtension { def generateBeans(boolean generateBeans) { config.generateBeans = generateBeans } + + def debugLogsFieldName(String debugLogsFieldName) { + config.debugLogsFieldName = debugLogsFieldName + } } diff --git a/acpg-lib/src/main/java/org/jraf/acpg/lib/config/Config.java b/acpg-lib/src/main/java/org/jraf/acpg/lib/config/Config.java index de6b1d6..7fdc704 100644 --- a/acpg-lib/src/main/java/org/jraf/acpg/lib/config/Config.java +++ b/acpg-lib/src/main/java/org/jraf/acpg/lib/config/Config.java @@ -40,6 +40,7 @@ public class Config implements Serializable, Cloneable { public Boolean useAnnotations; public Boolean useSupportLibrary; public Boolean generateBeans; + public String debugLogsFieldName; @Override public Object clone() throws CloneNotSupportedException { @@ -67,7 +68,8 @@ public boolean equals(Object o) { if (enableForeignKeys != null ? !enableForeignKeys.equals(config.enableForeignKeys) : config.enableForeignKeys != null) return false; if (useAnnotations != null ? !useAnnotations.equals(config.useAnnotations) : config.useAnnotations != null) return false; if (useSupportLibrary != null ? !useSupportLibrary.equals(config.useSupportLibrary) : config.useSupportLibrary != null) return false; - return generateBeans != null ? generateBeans.equals(config.generateBeans) : config.generateBeans == null; + if (generateBeans != null ? !generateBeans.equals(config.generateBeans) : config.generateBeans != null) return false; + return debugLogsFieldName != null ? debugLogsFieldName.equals(config.debugLogsFieldName) : config.debugLogsFieldName == null; } @Override @@ -85,6 +87,7 @@ public int hashCode() { result = 31 * result + (useAnnotations != null ? useAnnotations.hashCode() : 0); result = 31 * result + (useSupportLibrary != null ? useSupportLibrary.hashCode() : 0); result = 31 * result + (generateBeans != null ? generateBeans.hashCode() : 0); + result = 31 * result + (debugLogsFieldName != null ? debugLogsFieldName.hashCode() : 0); return result; } } diff --git a/acpg-lib/src/main/java/org/jraf/acpg/lib/config/ConfigParser.java b/acpg-lib/src/main/java/org/jraf/acpg/lib/config/ConfigParser.java index be803fd..993b1cd 100644 --- a/acpg-lib/src/main/java/org/jraf/acpg/lib/config/ConfigParser.java +++ b/acpg-lib/src/main/java/org/jraf/acpg/lib/config/ConfigParser.java @@ -93,6 +93,10 @@ public void validateConfig(Config config) throws GeneratorException { LOG.info("'generateBeans' not set in configuration: assuming true."); config.generateBeans = true; } + if (config.debugLogsFieldName == null) { + LOG.info("'debugLogsFieldName' not set in configuration: assuming 'DEBUG'."); + config.debugLogsFieldName = "DEBUG"; + } } private void ensureNotNull(Object value, String fieldName) throws GeneratorException { diff --git a/acpg-lib/src/main/resources/org/jraf/acpg/lib/basesqliteopenhelpercallbacks.ftl b/acpg-lib/src/main/resources/org/jraf/acpg/lib/basesqliteopenhelpercallbacks.ftl index 61fd608..cc70c3a 100644 --- a/acpg-lib/src/main/resources/org/jraf/acpg/lib/basesqliteopenhelpercallbacks.ftl +++ b/acpg-lib/src/main/resources/org/jraf/acpg/lib/basesqliteopenhelpercallbacks.ftl @@ -22,7 +22,7 @@ public class BaseSQLiteOpenHelperCallbacks { * @see android.database.sqlite.SQLiteOpenHelper#onOpen(SQLiteDatabase) onOpen */ public void onOpen(Context context, SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onOpen"); + if (BuildConfig.${config.debugLogsFieldName}) Log.d(TAG, "onOpen"); } /** @@ -30,7 +30,7 @@ public class BaseSQLiteOpenHelperCallbacks { * @see android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) onCreate */ public void onPreCreate(Context context, SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onPreCreate"); + if (BuildConfig.${config.debugLogsFieldName}) Log.d(TAG, "onPreCreate"); } /** @@ -38,7 +38,7 @@ public class BaseSQLiteOpenHelperCallbacks { * @see android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) onCreate */ public void onPostCreate(Context context, SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onPostCreate"); + if (BuildConfig.${config.debugLogsFieldName}) Log.d(TAG, "onPostCreate"); } /** @@ -46,6 +46,6 @@ public class BaseSQLiteOpenHelperCallbacks { * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(Context, SQLiteDatabase, int, int) onUpgrade */ public void onUpgrade(final Context context, final SQLiteDatabase db, final int oldVersion, final int newVersion) { - if (BuildConfig.DEBUG) Log.d(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); + if (BuildConfig.${config.debugLogsFieldName}) Log.d(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); } } diff --git a/acpg-lib/src/main/resources/org/jraf/acpg/lib/contentprovider.ftl b/acpg-lib/src/main/resources/org/jraf/acpg/lib/contentprovider.ftl index f3a2d1b..718b7c1 100644 --- a/acpg-lib/src/main/resources/org/jraf/acpg/lib/contentprovider.ftl +++ b/acpg-lib/src/main/resources/org/jraf/acpg/lib/contentprovider.ftl @@ -25,7 +25,7 @@ import ${config.providerJavaPackage}.${entity.packageName}.${entity.nameCamelCas public class ${config.providerClassName} extends BaseContentProvider { private static final String TAG = ${config.providerClassName}.class.getSimpleName(); - private static final boolean DEBUG = BuildConfig.DEBUG; + private static final boolean DEBUG = BuildConfig.${config.debugLogsFieldName}; private static final String TYPE_CURSOR_ITEM = "vnd.android.cursor.item/"; private static final String TYPE_CURSOR_DIR = "vnd.android.cursor.dir/"; diff --git a/acpg-lib/src/main/resources/org/jraf/acpg/lib/sqliteopenhelper.ftl b/acpg-lib/src/main/resources/org/jraf/acpg/lib/sqliteopenhelper.ftl index b179be7..c4102f1 100644 --- a/acpg-lib/src/main/resources/org/jraf/acpg/lib/sqliteopenhelper.ftl +++ b/acpg-lib/src/main/resources/org/jraf/acpg/lib/sqliteopenhelper.ftl @@ -120,7 +120,7 @@ public class ${config.sqliteOpenHelperClassName} extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onCreate"); + if (BuildConfig.${config.debugLogsFieldName}) Log.d(TAG, "onCreate"); mOpenHelperCallbacks.onPreCreate(mContext, db); <#list model.entities as entity> db.execSQL(SQL_CREATE_TABLE_${entity.nameUpperCase}); diff --git a/build.gradle b/build.gradle index 9ddc234..c2a1723 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ allprojects { apply plugin: 'maven' group = 'org.jraf' - version = '1.12.0' + version = '1.13.0' repositories { mavenLocal() diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleProvider.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleProvider.java index dc65dfb..9f86e88 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleProvider.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleProvider.java @@ -48,7 +48,7 @@ public class SampleProvider extends BaseContentProvider { private static final String TAG = SampleProvider.class.getSimpleName(); - private static final boolean DEBUG = BuildConfig.DEBUG; + private static final boolean DEBUG = BuildConfig.LOG_DEBUG_PROVIDER; private static final String TYPE_CURSOR_ITEM = "vnd.android.cursor.item/"; private static final String TYPE_CURSOR_DIR = "vnd.android.cursor.dir/"; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleSQLiteOpenHelper.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleSQLiteOpenHelper.java index 05f5317..f9aeffa 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleSQLiteOpenHelper.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/SampleSQLiteOpenHelper.java @@ -181,7 +181,7 @@ private SampleSQLiteOpenHelper(Context context, DatabaseErrorHandler errorHandle @Override public void onCreate(SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onCreate"); + if (BuildConfig.LOG_DEBUG_PROVIDER) Log.d(TAG, "onCreate"); mOpenHelperCallbacks.onPreCreate(mContext, db); db.execSQL(SQL_CREATE_TABLE_COMPANY); db.execSQL(SQL_CREATE_INDEX_COMPANY_NAME); diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractContentValues.java index 1bafdd1..f8df677 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractContentValues.java @@ -31,13 +31,29 @@ import android.net.Uri; @SuppressWarnings("unused") -public abstract class AbstractContentValues { +public abstract class AbstractContentValues> { protected final ContentValues mContentValues = new ContentValues(); + private Boolean mNotify; /** * Returns the {@code uri} argument to pass to the {@code ContentResolver} methods. */ - public abstract Uri uri(); + protected abstract Uri baseUri(); + + /** + * Returns the {@code uri} argument to pass to the {@code ContentResolver} methods. + */ + public Uri uri() { + Uri uri = baseUri(); + if (mNotify != null) uri = BaseContentProvider.notify(uri, mNotify); + return uri; + } + + @SuppressWarnings("unchecked") + public T notify(boolean notify) { + mNotify = notify; + return (T) this; + } /** * Returns the {@code ContentValues} wrapped by this object. diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractSelection.java index 575ca31..a3e3649 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/AbstractSelection.java @@ -421,9 +421,7 @@ public int count(Context context) { * @param projection The projection to use. * @return The CursorLoader. */ - public CursorLoader getCursorLoader(Context context, String[] projection) { - return new CursorLoader(context, uri(), projection, sel(), args(), order()); - } + public abstract CursorLoader getCursorLoader(Context context, String[] projection); /** * Returns a {@code CursorLoader} based on this selection, with a {@code null} (all columns) selection. diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/BaseSQLiteOpenHelperCallbacks.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/BaseSQLiteOpenHelperCallbacks.java index 4bb281e..55f4ffa 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/BaseSQLiteOpenHelperCallbacks.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/base/BaseSQLiteOpenHelperCallbacks.java @@ -43,7 +43,7 @@ public class BaseSQLiteOpenHelperCallbacks { * @see android.database.sqlite.SQLiteOpenHelper#onOpen(SQLiteDatabase) onOpen */ public void onOpen(Context context, SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onOpen"); + if (BuildConfig.LOG_DEBUG_PROVIDER) Log.d(TAG, "onOpen"); } /** @@ -51,7 +51,7 @@ public void onOpen(Context context, SQLiteDatabase db) { * @see android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) onCreate */ public void onPreCreate(Context context, SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onPreCreate"); + if (BuildConfig.LOG_DEBUG_PROVIDER) Log.d(TAG, "onPreCreate"); } /** @@ -59,7 +59,7 @@ public void onPreCreate(Context context, SQLiteDatabase db) { * @see android.database.sqlite.SQLiteOpenHelper#onCreate(SQLiteDatabase) onCreate */ public void onPostCreate(Context context, SQLiteDatabase db) { - if (BuildConfig.DEBUG) Log.d(TAG, "onPostCreate"); + if (BuildConfig.LOG_DEBUG_PROVIDER) Log.d(TAG, "onPostCreate"); } /** @@ -67,6 +67,6 @@ public void onPostCreate(Context context, SQLiteDatabase db) { * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(Context, SQLiteDatabase, int, int) onUpgrade */ public void onUpgrade(final Context context, final SQLiteDatabase db, final int oldVersion, final int newVersion) { - if (BuildConfig.DEBUG) Log.d(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); + if (BuildConfig.LOG_DEBUG_PROVIDER) Log.d(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); } } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanyContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanyContentValues.java index 22a1279..6fd66c9 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanyContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanyContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code company} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class CompanyContentValues extends AbstractContentValues { +public class CompanyContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return CompanyColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanySelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanySelection.java index a26e0c5..e67ff53 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanySelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/company/CompanySelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; import org.jraf.androidcontentprovidergenerator.sample.provider.serialnumber.*; @@ -86,6 +87,20 @@ public CompanyCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new CompanyCursor(super.loadInBackground()); + } + }; + } + + public CompanySelection id(long... value) { addEquals("company." + CompanyColumns._ID, toObjectArray(value)); return this; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualContentValues.java index 2bf8527..bd32a04 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code manual} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class ManualContentValues extends AbstractContentValues { +public class ManualContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return ManualColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualSelection.java index 212db11..d255b9f 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/manual/ManualSelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; @@ -85,6 +86,20 @@ public ManualCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new ManualCursor(super.loadInBackground()); + } + }; + } + + public ManualSelection id(long... value) { addEquals("manual." + ManualColumns._ID, toObjectArray(value)); return this; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonContentValues.java index bae5864..74ebdf7 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code person} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class PersonContentValues extends AbstractContentValues { +public class PersonContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return PersonColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonSelection.java index accb665..1dd411f 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/person/PersonSelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; @@ -85,6 +86,20 @@ public PersonCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new PersonCursor(super.loadInBackground()); + } + }; + } + + public PersonSelection id(long... value) { addEquals("person." + PersonColumns._ID, toObjectArray(value)); return this; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamContentValues.java index 095851f..74e1561 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code person_team} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class PersonTeamContentValues extends AbstractContentValues { +public class PersonTeamContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return PersonTeamColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamSelection.java index 8b29fbc..e071523 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/personteam/PersonTeamSelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; import org.jraf.androidcontentprovidergenerator.sample.provider.person.*; @@ -90,6 +91,20 @@ public PersonTeamCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new PersonTeamCursor(super.loadInBackground()); + } + }; + } + + public PersonTeamSelection id(long... value) { addEquals("person_team." + PersonTeamColumns._ID, toObjectArray(value)); return this; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductContentValues.java index 7dcc5b1..d8f60f7 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code product} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class ProductContentValues extends AbstractContentValues { +public class ProductContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return ProductColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductSelection.java index bee4315..6822a89 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/product/ProductSelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; import org.jraf.androidcontentprovidergenerator.sample.provider.manual.*; @@ -86,6 +87,20 @@ public ProductCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new ProductCursor(super.loadInBackground()); + } + }; + } + + public ProductSelection id(long... value) { addEquals("product." + ProductColumns._ID, toObjectArray(value)); return this; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberContentValues.java index a7de540..f845b69 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code serial_number} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class SerialNumberContentValues extends AbstractContentValues { +public class SerialNumberContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return SerialNumberColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberSelection.java index d614c1e..9e9836a 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/serialnumber/SerialNumberSelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; @@ -85,6 +86,20 @@ public SerialNumberCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new SerialNumberCursor(super.loadInBackground()); + } + }; + } + + public SerialNumberSelection id(long... value) { addEquals("serial_number." + SerialNumberColumns._ID, toObjectArray(value)); return this; diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamContentValues.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamContentValues.java index 71cbea6..0569d41 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamContentValues.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamContentValues.java @@ -39,9 +39,9 @@ * Content values wrapper for the {@code team} table. */ @SuppressWarnings({"ConstantConditions", "unused"}) -public class TeamContentValues extends AbstractContentValues { +public class TeamContentValues extends AbstractContentValues { @Override - public Uri uri() { + protected Uri baseUri() { return TeamColumns.CONTENT_URI; } diff --git a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamSelection.java b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamSelection.java index 793e6d6..cdc34ce 100644 --- a/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamSelection.java +++ b/etc/sample-generated-code/org/jraf/androidcontentprovidergenerator/sample/provider/team/TeamSelection.java @@ -31,6 +31,7 @@ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.v4.content.CursorLoader; import org.jraf.androidcontentprovidergenerator.sample.provider.base.AbstractSelection; import org.jraf.androidcontentprovidergenerator.sample.provider.company.*; @@ -88,6 +89,20 @@ public TeamCursor query(Context context) { } + /** + * {@inheritDoc} + */ + @Override + public CursorLoader getCursorLoader(Context context, String[] projection) { + return new CursorLoader(context, uri(), projection, sel(), args(), order()) { + @Override + public Cursor loadInBackground() { + return new TeamCursor(super.loadInBackground()); + } + }; + } + + public TeamSelection id(long... value) { addEquals("team." + TeamColumns._ID, toObjectArray(value)); return this; diff --git a/sample-app/build.gradle b/sample-app/build.gradle index e89aa2d..63d2deb 100644 --- a/sample-app/build.gradle +++ b/sample-app/build.gradle @@ -1,7 +1,7 @@ buildscript { repositories { - jcenter() mavenLocal() + jcenter() } dependencies { @@ -22,6 +22,8 @@ android { targetSdkVersion 25 versionCode 1 versionName '1.0' + + buildConfigField 'boolean', 'LOG_DEBUG_PROVIDER', "true" } } @@ -36,6 +38,7 @@ acpg { enableForeignKeys true useAnnotations true useSupportLibrary true + debugLogsFieldName 'LOG_DEBUG_PROVIDER' } dependencies { diff --git a/sample-app/etc/acpg/_config.json b/sample-app/etc/acpg/_config.json index 108bf13..88b4f0a 100644 --- a/sample-app/etc/acpg/_config.json +++ b/sample-app/etc/acpg/_config.json @@ -11,5 +11,6 @@ "enableForeignKeys": true, "useAnnotations": true, "useSupportLibrary": true, - "generateBeans": true + "generateBeans": true, + "debugLogsFieldName": "LOG_DEBUG_PROVIDER" }