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

@ -9,7 +9,6 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.util.LruCache;
import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.stetho.Stetho; import com.facebook.stetho.Stetho;
@ -27,7 +26,6 @@ import javax.inject.Inject;
import dagger.android.AndroidInjector; import dagger.android.AndroidInjector;
import dagger.android.DaggerApplication; import dagger.android.DaggerApplication;
import fr.free.nrw.commons.auth.AccountUtil; import fr.free.nrw.commons.auth.AccountUtil;
import fr.free.nrw.commons.caching.CacheController;
import fr.free.nrw.commons.contributions.Contribution; import fr.free.nrw.commons.contributions.Contribution;
import fr.free.nrw.commons.data.Category; import fr.free.nrw.commons.data.Category;
import fr.free.nrw.commons.data.DBOpenHelper; import fr.free.nrw.commons.data.DBOpenHelper;
@ -35,9 +33,7 @@ import fr.free.nrw.commons.di.CommonsApplicationComponent;
import fr.free.nrw.commons.di.CommonsApplicationModule; import fr.free.nrw.commons.di.CommonsApplicationModule;
import fr.free.nrw.commons.di.DaggerCommonsApplicationComponent; import fr.free.nrw.commons.di.DaggerCommonsApplicationComponent;
import fr.free.nrw.commons.modifications.ModifierSequence; import fr.free.nrw.commons.modifications.ModifierSequence;
import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi;
import fr.free.nrw.commons.mwapi.MediaWikiApi; import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.nearby.NearbyPlaces;
import fr.free.nrw.commons.utils.FileUtils; import fr.free.nrw.commons.utils.FileUtils;
import timber.log.Timber; import timber.log.Timber;
@ -54,6 +50,7 @@ public class CommonsApplication extends DaggerApplication {
@Inject MediaWikiApi mediaWikiApi; @Inject MediaWikiApi mediaWikiApi;
@Inject AccountUtil accountUtil; @Inject AccountUtil accountUtil;
@Inject DBOpenHelper dbOpenHelper;
private Account currentAccount = null; // Unlike a savings account... private Account currentAccount = null; // Unlike a savings account...
public static final String API_URL = "https://commons.wikimedia.org/w/api.php"; public static final String API_URL = "https://commons.wikimedia.org/w/api.php";
@ -73,37 +70,8 @@ public class CommonsApplication extends DaggerApplication {
public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com"; public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com";
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback"; public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback";
private LruCache<String, String> thumbnailUrlCache = new LruCache<>(1024);
private CacheController cacheData = null;
private DBOpenHelper dbOpenHelper = null;
private NearbyPlaces nearbyPlaces = null;
private CommonsApplicationComponent component; private CommonsApplicationComponent component;
public CacheController getCacheData() {
if (cacheData == null) {
cacheData = new CacheController();
}
return cacheData;
}
public LruCache<String, String> getThumbnailUrlCache() {
return thumbnailUrlCache;
}
public synchronized DBOpenHelper getDBOpenHelper() {
if (dbOpenHelper == null) {
dbOpenHelper = new DBOpenHelper(this);
}
return dbOpenHelper;
}
public synchronized NearbyPlaces getNearbyPlaces() {
if (nearbyPlaces == null) {
nearbyPlaces = new NearbyPlaces();
}
return nearbyPlaces;
}
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -127,9 +95,6 @@ public class CommonsApplication extends DaggerApplication {
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0"); System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
Fresco.initialize(this); Fresco.initialize(this);
//For caching area -> categories
cacheData = new CacheController();
} }
@Override @Override
@ -150,10 +115,10 @@ public class CommonsApplication extends DaggerApplication {
* @return Account|null * @return Account|null
*/ */
public Account getCurrentAccount() { public Account getCurrentAccount() {
if(currentAccount == null) { if (currentAccount == null) {
AccountManager accountManager = AccountManager.get(this); AccountManager accountManager = AccountManager.get(this);
Account[] allAccounts = accountManager.getAccountsByType(accountUtil.accountType()); Account[] allAccounts = accountManager.getAccountsByType(accountUtil.accountType());
if(allAccounts.length != 0) { if (allAccounts.length != 0) {
currentAccount = allAccounts[0]; currentAccount = allAccounts[0];
} }
} }
@ -164,7 +129,7 @@ public class CommonsApplication extends DaggerApplication {
AccountManager accountManager = AccountManager.get(this); AccountManager accountManager = AccountManager.get(this);
Account curAccount = getCurrentAccount(); Account curAccount = getCurrentAccount();
if(curAccount == null) { if (curAccount == null) {
return false; // This should never happen return false; // This should never happen
} }
@ -218,7 +183,6 @@ public class CommonsApplication extends DaggerApplication {
* Deletes all tables and re-creates them. * Deletes all tables and re-creates them.
*/ */
public void updateAllDatabases() { public void updateAllDatabases() {
DBOpenHelper dbOpenHelper = getDBOpenHelper();
dbOpenHelper.getReadableDatabase().close(); dbOpenHelper.getReadableDatabase().close();
SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); SQLiteDatabase db = dbOpenHelper.getWritableDatabase();

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.graphics.drawable.VectorDrawableCompat; import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.util.LruCache;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.Toast; import android.widget.Toast;
@ -19,6 +20,8 @@ import timber.log.Timber;
public class MediaWikiImageView extends SimpleDraweeView { public class MediaWikiImageView extends SimpleDraweeView {
@Inject CommonsApplication application; @Inject CommonsApplication application;
@Inject MediaWikiApi mwApi; @Inject MediaWikiApi mwApi;
@Inject LruCache<String, String> thumbnailUrlCache;
private ThumbnailFetchTask currentThumbnailTask; private ThumbnailFetchTask currentThumbnailTask;
public MediaWikiImageView(Context context) { public MediaWikiImageView(Context context) {
@ -44,8 +47,8 @@ public class MediaWikiImageView extends SimpleDraweeView {
return; return;
} }
if (application.getThumbnailUrlCache().get(media.getFilename()) != null) { if (thumbnailUrlCache.get(media.getFilename()) != null) {
setImageUrl(application.getThumbnailUrlCache().get(media.getFilename())); setImageUrl(thumbnailUrlCache.get(media.getFilename()));
} else { } else {
setImageUrl(null); setImageUrl(null);
currentThumbnailTask = new ThumbnailFetchTask(media, mwApi); currentThumbnailTask = new ThumbnailFetchTask(media, mwApi);
@ -91,8 +94,7 @@ public class MediaWikiImageView extends SimpleDraweeView {
} else { } else {
// only cache meaningful thumbnails received from network. // only cache meaningful thumbnails received from network.
try { try {
CommonsApplication app = (CommonsApplication) getContext().getApplicationContext(); thumbnailUrlCache.put(media.getFilename(), result);
app.getThumbnailUrlCache().put(media.getFilename(), result);
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
Timber.e("error when adding pic to cache " + npe); Timber.e("error when adding pic to cache " + npe);

View file

@ -40,13 +40,11 @@ public class CategoryContentProvider extends ContentProvider {
} }
@Inject CommonsApplication application; @Inject CommonsApplication application;
@Inject DBOpenHelper dbOpenHelper;
private DBOpenHelper dbOpenHelper;
@Override @Override
public boolean onCreate() { public boolean onCreate() {
AndroidInjection.inject(this); AndroidInjection.inject(this);
dbOpenHelper = application.getDBOpenHelper();
return false; return false;
} }

View file

@ -14,6 +14,7 @@ import javax.inject.Inject;
import dagger.android.AndroidInjection; import dagger.android.AndroidInjection;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.data.DBOpenHelper;
import timber.log.Timber; import timber.log.Timber;
public class ContributionsContentProvider extends ContentProvider{ public class ContributionsContentProvider extends ContentProvider{
@ -37,6 +38,7 @@ public class ContributionsContentProvider extends ContentProvider{
} }
@Inject CommonsApplication application; @Inject CommonsApplication application;
@Inject DBOpenHelper dbOpenHelper;
@Override @Override
public boolean onCreate() { public boolean onCreate() {
@ -51,7 +53,7 @@ public class ContributionsContentProvider extends ContentProvider{
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase db = application.getDBOpenHelper().getReadableDatabase(); SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor; Cursor cursor;
switch(uriType) { switch(uriType) {
@ -85,7 +87,7 @@ public class ContributionsContentProvider extends ContentProvider{
@Override @Override
public Uri insert(@NonNull Uri uri, ContentValues contentValues) { public Uri insert(@NonNull Uri uri, ContentValues contentValues) {
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
long id = 0; long id = 0;
switch (uriType) { switch (uriType) {
case CONTRIBUTIONS: case CONTRIBUTIONS:
@ -103,7 +105,7 @@ public class ContributionsContentProvider extends ContentProvider{
int rows = 0; int rows = 0;
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase db = application.getDBOpenHelper().getReadableDatabase(); SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
switch(uriType) { switch(uriType) {
case CONTRIBUTIONS_ID: case CONTRIBUTIONS_ID:
@ -124,7 +126,7 @@ public class ContributionsContentProvider extends ContentProvider{
public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) { public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
Timber.d("Hello, bulk insert! (ContributionsContentProvider)"); Timber.d("Hello, bulk insert! (ContributionsContentProvider)");
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
sqlDB.beginTransaction(); sqlDB.beginTransaction();
switch (uriType) { switch (uriType) {
case CONTRIBUTIONS: 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. 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); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
int rowsUpdated = 0; int rowsUpdated = 0;
switch (uriType) { switch (uriType) {
case CONTRIBUTIONS: case CONTRIBUTIONS:

View file

@ -1,12 +1,17 @@
package fr.free.nrw.commons.di; package fr.free.nrw.commons.di;
import android.support.v4.util.LruCache;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.caching.CacheController;
import fr.free.nrw.commons.data.DBOpenHelper;
import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi; import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi;
import fr.free.nrw.commons.mwapi.MediaWikiApi; import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.nearby.NearbyPlaces;
@Module @Module
public class CommonsApplicationModule { public class CommonsApplicationModule {
@ -26,4 +31,28 @@ public class CommonsApplicationModule {
public MediaWikiApi provideMediaWikiApi() { public MediaWikiApi provideMediaWikiApi() {
return new ApacheHttpClientMediaWikiApi(CommonsApplication.API_URL); return new ApacheHttpClientMediaWikiApi(CommonsApplication.API_URL);
} }
@Provides
@Singleton
public CacheController provideCacheController() {
return new CacheController();
}
@Provides
@Singleton
public DBOpenHelper provideDBOpenHelper(CommonsApplication application) {
return new DBOpenHelper(application);
}
@Provides
@Singleton
public NearbyPlaces provideNearbyPlaces() {
return new NearbyPlaces();
}
@Provides
@Singleton
public LruCache<String, String> provideLruCache() {
return new LruCache<>(1024);
}
} }

View file

@ -14,6 +14,7 @@ import javax.inject.Inject;
import dagger.android.AndroidInjection; import dagger.android.AndroidInjection;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.data.DBOpenHelper;
import timber.log.Timber; import timber.log.Timber;
public class ModificationsContentProvider extends ContentProvider{ public class ModificationsContentProvider extends ContentProvider{
@ -37,6 +38,7 @@ public class ModificationsContentProvider extends ContentProvider{
} }
@Inject CommonsApplication application; @Inject CommonsApplication application;
@Inject DBOpenHelper dbOpenHelper;
@Override @Override
public boolean onCreate() { public boolean onCreate() {
@ -58,7 +60,7 @@ public class ModificationsContentProvider extends ContentProvider{
throw new IllegalArgumentException("Unknown URI" + uri); throw new IllegalArgumentException("Unknown URI" + uri);
} }
SQLiteDatabase db = application.getDBOpenHelper().getReadableDatabase(); SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder); Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri); cursor.setNotificationUri(getContext().getContentResolver(), uri);
@ -74,7 +76,7 @@ public class ModificationsContentProvider extends ContentProvider{
@Override @Override
public Uri insert(@NonNull Uri uri, ContentValues contentValues) { public Uri insert(@NonNull Uri uri, ContentValues contentValues) {
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
long id = 0; long id = 0;
switch (uriType) { switch (uriType) {
case MODIFICATIONS: case MODIFICATIONS:
@ -90,7 +92,7 @@ public class ModificationsContentProvider extends ContentProvider{
@Override @Override
public int delete(@NonNull Uri uri, String s, String[] strings) { public int delete(@NonNull Uri uri, String s, String[] strings) {
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
switch (uriType) { switch (uriType) {
case MODIFICATIONS_ID: case MODIFICATIONS_ID:
String id = uri.getLastPathSegment(); String id = uri.getLastPathSegment();
@ -108,7 +110,7 @@ public class ModificationsContentProvider extends ContentProvider{
public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) { public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
Timber.d("Hello, bulk insert! (ModificationsContentProvider)"); Timber.d("Hello, bulk insert! (ModificationsContentProvider)");
int uriType = uriMatcher.match(uri); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
sqlDB.beginTransaction(); sqlDB.beginTransaction();
switch (uriType) { switch (uriType) {
case MODIFICATIONS: case MODIFICATIONS:
@ -136,7 +138,7 @@ public class ModificationsContentProvider extends ContentProvider{
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise. 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); int uriType = uriMatcher.match(uri);
SQLiteDatabase sqlDB = application.getDBOpenHelper().getWritableDatabase(); SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
int rowsUpdated = 0; int rowsUpdated = 0;
switch (uriType) { switch (uriType) {
case MODIFICATIONS: case MODIFICATIONS:

View file

@ -31,7 +31,6 @@ import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng; import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager; import fr.free.nrw.commons.location.LocationServiceManager;
@ -43,7 +42,7 @@ public class NearbyActivity extends NavigationBaseActivity {
@BindView(R.id.progressBar) @BindView(R.id.progressBar)
ProgressBar progressBar; ProgressBar progressBar;
@Inject CommonsApplication application; @Inject NearbyPlaces nearbyPlaces;
private boolean isMapViewActive = false; private boolean isMapViewActive = false;
private static final int LOCATION_REQUEST = 1; private static final int LOCATION_REQUEST = 1;
@ -94,7 +93,7 @@ public class NearbyActivity extends NavigationBaseActivity {
locationManager = new LocationServiceManager(this); locationManager = new LocationServiceManager(this);
locationManager.registerLocationManager(); locationManager.registerLocationManager();
curLatLang = locationManager.getLatestLocation(); curLatLang = locationManager.getLatestLocation();
nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(application)); nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(nearbyPlaces));
nearbyAsyncTask.execute(); nearbyAsyncTask.execute();
} }
@ -233,7 +232,7 @@ public class NearbyActivity extends NavigationBaseActivity {
} }
private void refreshView() { private void refreshView() {
nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(application)); nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(nearbyPlaces));
nearbyAsyncTask.execute(); nearbyAsyncTask.execute();
} }
@ -262,7 +261,7 @@ public class NearbyActivity extends NavigationBaseActivity {
@Override @Override
protected List<Place> doInBackground(Void... params) { protected List<Place> doInBackground(Void... params) {
return nearbyController.loadAttractionsFromLocation(curLatLang, application); return nearbyController.loadAttractionsFromLocation(curLatLang, NearbyActivity.this);
} }
@Override @Override

View file

@ -15,7 +15,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng; import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UiUtils; import fr.free.nrw.commons.utils.UiUtils;
@ -27,11 +26,10 @@ import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
public class NearbyController { public class NearbyController {
private static final int MAX_RESULTS = 1000; private static final int MAX_RESULTS = 1000;
private final NearbyPlaces nearbyPlaces;
private final CommonsApplication application; public NearbyController(NearbyPlaces nearbyPlaces) {
this.nearbyPlaces = nearbyPlaces;
public NearbyController(CommonsApplication application) {
this.application = application;
} }
/** /**
@ -45,7 +43,6 @@ public class NearbyController {
if (curLatLng == null) { if (curLatLng == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
NearbyPlaces nearbyPlaces = application.getNearbyPlaces();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<Place> places = prefs.getBoolean("useWikidata", true) List<Place> places = prefs.getBoolean("useWikidata", true)
? nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage()) ? nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage())

View file

@ -37,6 +37,7 @@ import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils; import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.AuthenticatedActivity; import fr.free.nrw.commons.auth.AuthenticatedActivity;
import fr.free.nrw.commons.caching.CacheController;
import fr.free.nrw.commons.category.CategorizationFragment; import fr.free.nrw.commons.category.CategorizationFragment;
import fr.free.nrw.commons.category.OnCategoriesSaveHandler; import fr.free.nrw.commons.category.OnCategoriesSaveHandler;
import fr.free.nrw.commons.contributions.Contribution; import fr.free.nrw.commons.contributions.Contribution;
@ -68,6 +69,7 @@ public class ShareActivity
@Inject CommonsApplication application; @Inject CommonsApplication application;
@Inject MediaWikiApi mwApi; @Inject MediaWikiApi mwApi;
@Inject CacheController cacheController;
private String source; private String source;
private String mimeType; private String mimeType;
@ -137,7 +139,7 @@ public class ShareActivity
if (!cacheFound) { if (!cacheFound) {
//Has to be called after apiCall.request() //Has to be called after apiCall.request()
application.getCacheData().cacheCategory(); cacheController.cacheCategory();
Timber.d("Cache the categories found"); Timber.d("Cache the categories found");
} }
@ -482,12 +484,12 @@ public class ShareActivity
if (imageObj.imageCoordsExists) { if (imageObj.imageCoordsExists) {
double decLongitude = imageObj.getDecLongitude(); double decLongitude = imageObj.getDecLongitude();
double decLatitude = imageObj.getDecLatitude(); double decLatitude = imageObj.getDecLatitude();
application.getCacheData().setQtPoint(decLongitude, decLatitude); cacheController.setQtPoint(decLongitude, decLatitude);
} }
MwVolleyApi apiCall = new MwVolleyApi(application); MwVolleyApi apiCall = new MwVolleyApi(application);
List<String> displayCatList = application.getCacheData().findCategory(); List<String> displayCatList = cacheController.findCategory();
boolean catListEmpty = displayCatList.isEmpty(); boolean catListEmpty = displayCatList.isEmpty();
// If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories // If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories