Merge pull request #1047 from psh/more-database-cleanup

More database related cleanup
This commit is contained in:
neslihanturan 2018-01-12 17:41:58 +03:00 committed by GitHub
commit 1224302ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 211 additions and 151 deletions

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons.di;
import android.content.ContentProviderClient;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.util.LruCache;
@ -22,10 +23,14 @@ import fr.free.nrw.commons.nearby.NearbyPlaces;
import fr.free.nrw.commons.upload.UploadController;
import static android.content.Context.MODE_PRIVATE;
import static fr.free.nrw.commons.contributions.ContributionsContentProvider.CONTRIBUTION_AUTHORITY;
import static fr.free.nrw.commons.modifications.ModificationsContentProvider.MODIFICATIONS_AUTHORITY;
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public class CommonsApplicationModule {
public static final String CATEGORY_AUTHORITY = "fr.free.nrw.commons.categories.contentprovider";
private CommonsApplication application;
public CommonsApplicationModule(CommonsApplication application) {
@ -37,6 +42,24 @@ public class CommonsApplicationModule {
return new AccountUtil(application);
}
@Provides
@Named("category")
public ContentProviderClient provideCategoryContentProviderClient() {
return application.getContentResolver().acquireContentProviderClient(CATEGORY_AUTHORITY);
}
@Provides
@Named("contribution")
public ContentProviderClient provideContributionContentProviderClient() {
return application.getContentResolver().acquireContentProviderClient(CONTRIBUTION_AUTHORITY);
}
@Provides
@Named("modification")
public ContentProviderClient provideModificationContentProviderClient() {
return application.getContentResolver().acquireContentProviderClient(MODIFICATIONS_AUTHORITY);
}
@Provides
@Named("application_preferences")
public SharedPreferences providesApplicationSharedPreferences() {