Moved other singletons over to being managed by Dagger

This commit is contained in:
Paul Hawke 2017-08-25 22:26:03 -05:00
parent 647cc166ef
commit cfe17cafa6
9 changed files with 69 additions and 74 deletions

View file

@ -14,6 +14,7 @@ import javax.inject.Inject;
import dagger.android.AndroidInjection;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.data.DBOpenHelper;
import timber.log.Timber;
public class ContributionsContentProvider extends ContentProvider{
@ -37,6 +38,7 @@ public class ContributionsContentProvider extends ContentProvider{
}
@Inject CommonsApplication application;
@Inject DBOpenHelper dbOpenHelper;
@Override
public boolean onCreate() {
@ -51,7 +53,7 @@ public class ContributionsContentProvider extends ContentProvider{
int uriType = uriMatcher.match(uri);
SQLiteDatabase db = application.getDBOpenHelper().getReadableDatabase();
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor;
switch(uriType) {
@ -85,7 +87,7 @@ public class ContributionsContentProvider extends ContentProvider{
@Override
public Uri insert(@NonNull Uri uri, ContentValues contentValues) {
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase();
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
long id = 0;
switch (uriType) {
case CONTRIBUTIONS:
@ -103,7 +105,7 @@ public class ContributionsContentProvider extends ContentProvider{
int rows = 0;
int uriType = uriMatcher.match(uri);
SQLiteDatabase db = application.getDBOpenHelper().getReadableDatabase();
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
switch(uriType) {
case CONTRIBUTIONS_ID:
@ -124,7 +126,7 @@ public class ContributionsContentProvider extends ContentProvider{
public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
Timber.d("Hello, bulk insert! (ContributionsContentProvider)");
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase();
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
sqlDB.beginTransaction();
switch (uriType) {
case CONTRIBUTIONS:
@ -152,7 +154,7 @@ public class ContributionsContentProvider extends ContentProvider{
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
*/
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase();
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
int rowsUpdated = 0;
switch (uriType) {
case CONTRIBUTIONS: