Skip to content

fix for #733,732 issue #768

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

Merged
merged 1 commit into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -10,7 +10,6 @@
import android.text.TextUtils;

import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.data.DBOpenHelper;
import timber.log.Timber;

public class ContributionsContentProvider extends ContentProvider{
Expand All @@ -33,10 +32,8 @@ public static Uri uriForId(int id) {
return Uri.parse(BASE_URI.toString() + "/" + id);
}

private DBOpenHelper dbOpenHelper;
@Override
public boolean onCreate() {
dbOpenHelper = CommonsApplication.getInstance().getDBOpenHelper();
return false;
}

Expand All @@ -47,7 +44,7 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] sel

int uriType = uriMatcher.match(uri);

SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
SQLiteDatabase db = CommonsApplication.getInstance().getDBOpenHelper().getReadableDatabase();
Cursor cursor;

switch(uriType) {
Expand Down Expand Up @@ -81,7 +78,7 @@ public String getType(Uri uri) {
@Override
public Uri insert(Uri uri, ContentValues contentValues) {
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
long id = 0;
switch (uriType) {
case CONTRIBUTIONS:
Expand All @@ -99,7 +96,7 @@ public int delete(Uri uri, String s, String[] strings) {
int rows = 0;
int uriType = uriMatcher.match(uri);

SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
SQLiteDatabase db = CommonsApplication.getInstance().getDBOpenHelper().getReadableDatabase();

switch(uriType) {
case CONTRIBUTIONS_ID:
Expand All @@ -120,7 +117,7 @@ public int delete(Uri uri, String s, String[] strings) {
public int bulkInsert(Uri uri, ContentValues[] values) {
Timber.d("Hello, bulk insert! (ContributionsContentProvider)");
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
sqlDB.beginTransaction();
switch (uriType) {
case CONTRIBUTIONS:
Expand Down Expand Up @@ -148,7 +145,7 @@ public int update(Uri uri, ContentValues contentValues, String selection, String
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 = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
int rowsUpdated = 0;
switch (uriType) {
case CONTRIBUTIONS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.text.TextUtils;

import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.data.DBOpenHelper;
import timber.log.Timber;

public class ModificationsContentProvider extends ContentProvider{
Expand All @@ -33,10 +32,9 @@ public static Uri uriForId(int id) {
return Uri.parse(BASE_URI.toString() + "/" + id);
}

private DBOpenHelper dbOpenHelper;

@Override
public boolean onCreate() {
dbOpenHelper = CommonsApplication.getInstance().getDBOpenHelper();
return false;
}

Expand All @@ -54,7 +52,7 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] sel
throw new IllegalArgumentException("Unknown URI" + uri);
}

SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
SQLiteDatabase db = CommonsApplication.getInstance().getDBOpenHelper().getReadableDatabase();

Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
Expand All @@ -70,7 +68,7 @@ public String getType(Uri uri) {
@Override
public Uri insert(Uri uri, ContentValues contentValues) {
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
long id = 0;
switch (uriType) {
case MODIFICATIONS:
Expand All @@ -86,7 +84,7 @@ public Uri insert(Uri uri, ContentValues contentValues) {
@Override
public int delete(Uri uri, String s, String[] strings) {
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
switch (uriType) {
case MODIFICATIONS_ID:
String id = uri.getLastPathSegment();
Expand All @@ -104,7 +102,7 @@ public int delete(Uri uri, String s, String[] strings) {
public int bulkInsert(Uri uri, ContentValues[] values) {
Timber.d("Hello, bulk insert! (ModificationsContentProvider)");
int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
sqlDB.beginTransaction();
switch (uriType) {
case MODIFICATIONS:
Expand Down Expand Up @@ -132,7 +130,7 @@ public int update(Uri uri, ContentValues contentValues, String selection, String
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 = dbOpenHelper.getWritableDatabase();
SQLiteDatabase sqlDB = CommonsApplication.getInstance().getDBOpenHelper().getWritableDatabase();
int rowsUpdated = 0;
switch (uriType) {
case MODIFICATIONS:
Expand Down