Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loaders and cursors for DBFlow #1091

Open
wants to merge 56 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
91326fb
First pass at external foreign key references
hilljh82 Jan 31, 2016
50382fc
Added missing files
hilljh82 Jan 31, 2016
a1ff768
Merge from Raizlabs
hilljh82 Jan 31, 2016
35567d3
Foreign key on primary key failed if column was a model and not a mod…
hilljh82 Feb 3, 2016
a92a9d1
Removed debug code
hilljh82 Feb 3, 2016
de30375
Overrided getSupportedOptions() to handle processor warnings
hilljh82 Feb 3, 2016
bf4b415
Foreign key definition failed with model container
hilljh82 Feb 3, 2016
50e409b
Reverted change
hilljh82 Feb 3, 2016
6dfd5d6
Removed test files
hilljh82 Feb 23, 2016
f3935e1
Merge from raizlabs/develop
hilljh82 Feb 23, 2016
0947f8c
Added missing code for checkNeedsReferences()
hilljh82 Mar 10, 2016
118204a
Removed faulty line of code
hilljh82 Mar 10, 2016
2a450a2
Added missing check for external foreign key
hilljh82 Mar 10, 2016
36b7fa7
Overrided the newInstance() method
hilljh82 Mar 14, 2016
f98ebc2
Merge from Raizlabs/master
hilljh82 Jul 3, 2016
9431b13
Fixed error preventing Jitpack from working
hilljh82 Jul 3, 2016
e483520
Merge from master
hilljh82 Jul 3, 2016
1e05a47
Fixed build errors
hilljh82 Jul 4, 2016
ccdb83b
Fixed build error
hilljh82 Jul 4, 2016
49d3993
Fixed compilation errors
hilljh82 Jul 4, 2016
25403c8
Merge branch 'master' into develop
hilljh82 Jul 4, 2016
e3b8ecb
Switch to AsyncTaskLoader in Android support library
hilljh82 Jul 7, 2016
536a5bb
Added missing dependency
hilljh82 Jul 7, 2016
36b144d
Fixed build issues with API version
hilljh82 Jul 7, 2016
cff3e40
Merge from Raizlabs/develop
hilljh82 Jul 7, 2016
09f1be7
Merge from Raizlabs/master
hilljh82 Jul 7, 2016
956fc1b
Merge branch 'master' into develop
hilljh82 Jul 7, 2016
63fe220
Fixed issues in implementation
hilljh82 Jul 21, 2016
008dc04
Loaders for single model queries
hilljh82 Jul 21, 2016
a7105b4
Relocated file
hilljh82 Aug 4, 2016
1508e00
Added support for Travis CI
hilljh82 Aug 4, 2016
464ba50
Moved Travis-CI config to different branch
hilljh82 Aug 28, 2016
f5a5b13
Moved ExternalForeignKey annotation to its own branch
hilljh82 Aug 28, 2016
d983e5f
Added documentation; fixed spacing issues
hilljh82 Aug 28, 2016
9632cd8
Fixed format
hilljh82 Aug 28, 2016
7d79b78
Fixed format
hilljh82 Aug 28, 2016
aa85b79
Removed unused variables; fixed formatting
hilljh82 Aug 28, 2016
f0ab254
Fixed merge: Updated sdk version numbers to be compatible with depend…
hilljh82 Aug 28, 2016
344a9a5
Fixed build error
hilljh82 Nov 29, 2016
dea07b7
Merge from Raizlabs/develop
hilljh82 Nov 30, 2016
a1b9485
Fixed build errors related to updates to raizlabs/develop
hilljh82 Dec 1, 2016
56392ad
Fixed merge conflicts
hilljh82 Dec 1, 2016
34acd05
Fixed merge conflicts
hilljh82 Dec 1, 2016
0212982
Fixed merge conflicts
hilljh82 Dec 1, 2016
d1a52cb
Fixed merge conflicts
hilljh82 Dec 1, 2016
fd72253
Removed obsolete file
hilljh82 Dec 1, 2016
0554ec4
Fixed formatting issues
hilljh82 Dec 1, 2016
8d72965
For some reason, lintOptions was added to the build config
hilljh82 Dec 1, 2016
d019191
PropertyExtensions was changed during the merge; this file should not…
hilljh82 Dec 1, 2016
aff9722
Removed obsolete file
hilljh82 Dec 1, 2016
a613727
Fixed naming convention on class variables
hilljh82 Dec 1, 2016
d7d188e
Fixed naming convention on class variables
hilljh82 Dec 1, 2016
c97f1b3
Fixed refactoring error
hilljh82 Dec 1, 2016
83ac02d
Fixed refactoring error
hilljh82 Dec 1, 2016
4cd5e39
Fixed naming conventions errors
hilljh82 Dec 1, 2016
0067c1e
Fixed naming conventions errors
hilljh82 Dec 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.raizlabs.android.dbflow.kotlinextensions

import com.raizlabs.android.dbflow.sql.language.property.*
import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable
import com.raizlabs.android.dbflow.structure.Model

/**
* Description: Provides some very nice Property class extensions.
Expand Down Expand Up @@ -35,6 +34,6 @@ val <T : Any> T.property: Property<T>
val <T : Any> ModelQueriable<T>.property: Property<T>
get() = PropertyFactory.from(this)

inline fun <reified T : Any> T.propertyString(stringRepresentation: String?): Property<T> {
return PropertyFactory.from(T::class.java, stringRepresentation)
inline fun <reified TModel : Any> TModel.propertyString(stringRepresentation: String?): Property<TModel> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#? not sure why this type parameter changed?

return PropertyFactory.from(TModel::class.java, stringRepresentation)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.raizlabs.android.dbflow.structure.Model
/**
* Description: Provides property methods in via infix functions.
*/

infix fun <T : Any> Property<T>.eq(value: T) = this.eq(value)

infix fun <T : Any> Property<T>.`is`(value: T) = this.`is`(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ fun <T : Any> update(modelClass: KClass<T>): Update<T> = SQLite.update(modelClas

infix fun <T : Any> Update<T>.set(sqlCondition: SQLCondition) = set(sqlCondition)


// delete

inline fun <reified T : Any> delete() = SQLite.delete(T::class.java)
Expand Down
1 change: 0 additions & 1 deletion dbflow-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testCompile 'junit:junit:4.12'

}

apply from: '../java-artifacts.gradle'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.raizlabs.android.dbflow.processor;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#req remove this file. It was added back, in develop its a kotlin file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agrosner I am will take care of that now. I am looking at the changed files to resolve other issues that are similar to this one.


import com.raizlabs.android.dbflow.annotation.ConflictAction;
import com.squareup.javapoet.ClassName;

/**
* Description: The static FQCN string file to assist in providing class names for imports and more in the Compiler
*/
public class ClassNames {


public static final String BASE_PACKAGE = "com.raizlabs.android.dbflow";
public static final String FLOW_MANAGER_PACKAGE = BASE_PACKAGE + ".config";
public static final String DATABASE_HOLDER_STATIC_CLASS_NAME = "GeneratedDatabaseHolder";
public static final String CONVERTER = BASE_PACKAGE + ".converter";
public static final String STRUCTURE = BASE_PACKAGE + ".structure";
public static final String DATABASE = STRUCTURE + ".database";
public static final String CONTAINER = STRUCTURE + ".container";
public static final String SQL = BASE_PACKAGE + ".sql";
public static final String LANGUAGE = SQL + ".language";
public static final String QUERIABLE = SQL + ".queriable";
public static final String PROPERTY_PACKAGE = LANGUAGE + ".property";
public static final String CONFIG = BASE_PACKAGE + ".config";
public static final String BUILDER = SQL + ".builder";
public static final String MIGRATION_PACKAGE = SQL + ".migration";
public static final String LISTENER = STRUCTURE + ".listener";
public static final String RUNTIME = BASE_PACKAGE + ".runtime";
public static final String TRANSACTION = RUNTIME + ".transaction";
public static final String DATABASE_TRANSACTION = DATABASE + ".transaction";
public static final String PROCESS = TRANSACTION + ".process";
public static final String SAVEABLE = SQL + ".saveable";

public static final ClassName DATABASE_HOLDER = ClassName.get(CONFIG, "DatabaseHolder");
public static final ClassName FLOW_MANAGER = ClassName.get(CONFIG, "FlowManager");
public static final ClassName BASE_DATABASE_DEFINITION_CLASSNAME = ClassName.get(CONFIG, "DatabaseDefinition");

public static final ClassName URI = ClassName.get("android.net", "Uri");
public static final ClassName URI_MATCHER = ClassName.get("android.content", "UriMatcher");
public static final ClassName CURSOR = ClassName.get("android.database", "Cursor");
public static final ClassName DATABASE_UTILS = ClassName.get("android.database", "DatabaseUtils");
public static final ClassName CONTENT_VALUES = ClassName.get("android.content", "ContentValues");
public static final ClassName CONTENT_URIS = ClassName.get("android.content", "ContentUris");

public static final ClassName MODEL_ADAPTER = ClassName.get(STRUCTURE, "ModelAdapter");
public static final ClassName QUERY_MODEL_ADAPTER = ClassName.get(STRUCTURE, "QueryModelAdapter");
public static final ClassName MODEL = ClassName.get(STRUCTURE, "Model");
public static final ClassName MODEL_VIEW_ADAPTER = ClassName.get(STRUCTURE, "ModelViewAdapter");
public static final ClassName MODEL_VIEW = ClassName.get(STRUCTURE, "BaseModelView");

public static final ClassName FLOW_SQLITE_OPEN_HELPER = ClassName.get(DATABASE, "FlowSQLiteOpenHelper");
public static final ClassName DATABASE_STATEMENT = ClassName.get(DATABASE, "DatabaseStatement");
public static final ClassName OPEN_HELPER = ClassName.get(DATABASE, "OpenHelper");

public static final ClassName CONDITION_QUERY_BUILDER = ClassName.get(BUILDER, "ConditionQueryBuilder");
public static final ClassName CONDITION = ClassName.get(BUILDER, "Condition");

public static final ClassName SQL_UTILS = ClassName.get(SQL, "SqlUtils");
public static final ClassName QUERY = ClassName.get(SQL, "Query");

public static final ClassName TYPE_CONVERTER = ClassName.get(CONVERTER, "TypeConverter");
public static final ClassName PROCESS_MODEL_INFO = ClassName.get(PROCESS, "ProcessModelInfo");

public static final ClassName FLOW_MANAGER_STATIC_INTERFACE = ClassName.get(FLOW_MANAGER_PACKAGE, "DatabaseHolder");

public static final ClassName MIGRATION = ClassName.get(MIGRATION_PACKAGE, "Migration");

public static final ClassName CONFLICT_ACTION = ClassName.get(ConflictAction.class);

public static final ClassName CONTENT_VALUES_LISTENER = ClassName.get(LISTENER, "ContentValuesListener");
public static final ClassName LOAD_FROM_CURSOR_LISTENER = ClassName.get(LISTENER, "LoadFromCursorListener");
public static final ClassName SQLITE_STATEMENT_LISTENER = ClassName.get(LISTENER, "SQLiteStatementListener");


public static final ClassName DELETE_MODEL_LIST_TRANSACTION = ClassName.get(PROCESS, "DeleteModelListTransaction");
public static final ClassName SAVE_MODEL_LIST_TRANSACTION = ClassName.get(PROCESS, "SaveModelTransaction");
public static final ClassName UPDATE_MODEL_LIST_TRANSACTION = ClassName.get(PROCESS, "UpdateModelListTransaction");
public static final ClassName INSERT_MODEL_LIST_TRANSACTION = ClassName.get(PROCESS, "InsertModelTransaction");

public static final ClassName PROPERTY = ClassName.get(PROPERTY_PACKAGE, "Property");
public static final ClassName IPROPERTY = ClassName.get(PROPERTY_PACKAGE, "IProperty");
public static final ClassName BASE_PROPERTY = ClassName.get(PROPERTY_PACKAGE, "BaseProperty");
public static final ClassName INDEX_PROPERTY = ClassName.get(PROPERTY_PACKAGE, "IndexProperty");
public static final ClassName CONDITION_GROUP = ClassName.get(LANGUAGE, "ConditionGroup");
public static final ClassName SELECT = ClassName.get(LANGUAGE, "Select");
public static final ClassName UPDATE = ClassName.get(LANGUAGE, "Update");
public static final ClassName DELETE = ClassName.get(LANGUAGE, "Delete");
public static final ClassName METHOD = ClassName.get(LANGUAGE, "Method");

public static final ClassName BASE_CONTENT_PROVIDER = ClassName.get(RUNTIME, "BaseContentProvider");
public static final ClassName PROPERTY_CONVERTER = ClassName.get(RUNTIME + ".BaseContentProvider", "PropertyConverter");

public static final ClassName MODEL_CONTAINER_UTILS = ClassName.get(CONTAINER, "ModelContainerUtils");
public static final ClassName MODEL_CONTAINER = ClassName.get(CONTAINER, "ModelContainer");
public static final ClassName MODEL_CONTAINER_ADAPTER = ClassName.get(CONTAINER, "ModelContainerAdapter");
public static final ClassName FOREIGN_KEY_CONTAINER = ClassName.get(CONTAINER, "ForeignKeyContainer");
public static final ClassName EXTERNAL_FOREIGN_KEY_CONTAINER = ClassName.get(CONTAINER, "ExternalForeignKeyContainer");
public static final ClassName BASE_MODEL = ClassName.get(STRUCTURE, "BaseModel");
public static final ClassName MODEL_CACHE = ClassName.get(STRUCTURE + ".cache", "ModelCache");
public static final ClassName MULTI_KEY_CACHE_CONVERTER = ClassName.get(STRUCTURE + ".cache", "IMultiKeyCacheConverter");

public static final ClassName CACHEABLE_MODEL_LOADER = ClassName.get(QUERIABLE, "CacheableModelLoader");
public static final ClassName SINGLE_MODEL_LOADER = ClassName.get(QUERIABLE, "SingleModelLoader");
public static final ClassName CACHEABLE_LIST_MODEL_LOADER = ClassName.get(QUERIABLE, "CacheableListModelLoader");
public static final ClassName LIST_MODEL_LOADER = ClassName.get(QUERIABLE, "ListModelLoader");

public static final ClassName DATABASE_WRAPPER = ClassName.get(DATABASE, "DatabaseWrapper");

public static final ClassName ORDER_BY = ClassName.get(LANGUAGE, "OrderBy");
public static final ClassName SQLITE = ClassName.get(LANGUAGE, "SQLite");

public static final ClassName UNSAFE_STRING_CONDITION = ClassName.get(LANGUAGE, "UnSafeStringCondition");

public static final ClassName CACHEABLE_LIST_MODEL_SAVER = ClassName.get(SAVEABLE, "CacheableListModelSaver");

public static final ClassName SINGLE_KEY_CACHEABLE_MODEL_LOADER = ClassName.get(QUERIABLE, "SingleKeyCacheableModelLoader");
public static final ClassName SINGLE_KEY_CACHEABLE_LIST_MODEL_LOADER = ClassName.get(QUERIABLE, "SingleKeyCacheableListModelLoader");
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public class DBFlowProcessor extends AbstractProcessor {

private ProcessorManager manager;

@Override
public Set<String> getSupportedOptions() {
Set <String> supportedOptions = new LinkedHashSet<>();
supportedOptions.add("targetModuleName");

return supportedOptions;
}

/**
* If the processor class is annotated with {@link
* javax.annotation.processing.SupportedAnnotationTypes}, return an unmodifiable set with the
Expand Down
2 changes: 0 additions & 2 deletions dbflow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ android {
dependencies {
compile project("${dbflow_project_prefix}dbflow-core")
compile "com.android.support:support-annotations:25.0.0"


}

apply from: '../android-artifacts.gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.raizlabs.android.dbflow.list;

import android.annotation.TargetApi;
import android.content.Context;
import android.database.Cursor;
import android.widget.CursorAdapter;

import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.structure.Model;
import com.raizlabs.android.dbflow.structure.ModelAdapter;

/**
* Specialization of CursorAdapter for DBFLow models. The getItem() method
* returns a model element instead of a Cursor object.
*
* @param <TModel>
*/
public abstract class FlowCursorAdapter <TModel extends Model> extends CursorAdapter {
private final ModelAdapter<TModel> mModelAdapter;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#req naming. no m-prefix names please.


public FlowCursorAdapter(Context context, Class<TModel> modelClass, Cursor c, boolean autoRequery) {
super(context, c, autoRequery);

this.mModelAdapter = FlowManager.getModelAdapter(modelClass);
}

@TargetApi(11)
public FlowCursorAdapter(Context context, Class<TModel> modelClass, Cursor c, int flags) {
super(context, c, flags);

this.mModelAdapter = FlowManager.getModelAdapter(modelClass);
}

@Override
public TModel getItem(int position) {
Cursor cursor = (Cursor) super.getItem(position);
return cursor != null ? this.mModelAdapter.loadFromCursor(cursor) : null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to use a FlowCursorList here so we can provide caching.

}
}
Loading