-
Notifications
You must be signed in to change notification settings - Fork 601
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
base: develop
Are you sure you want to change the base?
Changes from 48 commits
91326fb
50382fc
a1ff768
35567d3
a92a9d1
de30375
bf4b415
50e409b
6dfd5d6
f3935e1
0947f8c
118204a
2a450a2
36b7fa7
f98ebc2
9431b13
e483520
1e05a47
ccdb83b
49d3993
25403c8
e3b8ecb
536a5bb
36b144d
cff3e40
09f1be7
956fc1b
63fe220
008dc04
a7105b4
1508e00
464ba50
f5a5b13
d983e5f
9632cd8
7d79b78
aa85b79
f0ab254
344a9a5
dea07b7
a1b9485
56392ad
34acd05
0212982
d1a52cb
fd72253
0554ec4
8d72965
d019191
aff9722
a613727
d7d188e
c97f1b3
83ac02d
4cd5e39
0067c1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.raizlabs.android.dbflow.processor; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
---|---|---|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we might want to use a |
||
} | ||
} |
There was a problem hiding this comment.
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?