mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
commit
a3a6417b45
6 changed files with 16 additions and 17 deletions
|
|
@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
|||
apply from: 'quality.gradle'
|
||||
|
||||
dependencies {
|
||||
compile ('com.github.nicolas-raoul:Quadtree:211b6fe59ac48f') {
|
||||
compile ('com.github.nicolas-raoul:Quadtree:349eb842356bae') {
|
||||
exclude module: 'junit'
|
||||
}
|
||||
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ public abstract class HandlerService<T> extends Service {
|
|||
threadHandler = new ServiceHandler(threadLooper);
|
||||
}
|
||||
|
||||
private void postMessage(int type, Object obj) {
|
||||
private void postMessage(int type, T t) {
|
||||
Message msg = threadHandler.obtainMessage(type);
|
||||
msg.obj = obj;
|
||||
msg.obj = t;
|
||||
threadHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ import fr.free.nrw.commons.upload.MwVolleyApi;
|
|||
public class CacheController {
|
||||
|
||||
private double x, y;
|
||||
private QuadTree quadTree;
|
||||
private Point[] pointsFound;
|
||||
private QuadTree<List<String>> quadTree;
|
||||
private Point<List<String>>[] pointsFound;
|
||||
private double xMinus, xPlus, yMinus, yPlus;
|
||||
|
||||
private static final String TAG = CacheController.class.getName();
|
||||
private static final int EARTH_RADIUS = 6378137;
|
||||
|
||||
public CacheController() {
|
||||
quadTree = new QuadTree(-180, -90, +180, +90);
|
||||
quadTree = new QuadTree<>(-180, -90, +180, +90);
|
||||
}
|
||||
|
||||
public void setQtPoint(double decLongitude, double decLatitude) {
|
||||
|
|
@ -43,7 +43,7 @@ public class CacheController {
|
|||
quadTree.set(x, y, pointCatList);
|
||||
}
|
||||
|
||||
public List findCategory() {
|
||||
public List<String> findCategory() {
|
||||
//Convert decLatitude and decLongitude to a coordinate offset range
|
||||
convertCoordRange();
|
||||
pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus);
|
||||
|
|
@ -53,9 +53,9 @@ public class CacheController {
|
|||
if (pointsFound.length != 0) {
|
||||
Log.d(TAG, "Entering for loop");
|
||||
|
||||
for (Point point : pointsFound) {
|
||||
for (Point<List<String>> point : pointsFound) {
|
||||
Log.d(TAG, "Nearby point: " + point.toString());
|
||||
displayCatList = (List<String>)point.getValue();
|
||||
displayCatList = point.getValue();
|
||||
Log.d(TAG, "Nearby cat: " + point.getValue());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import android.widget.Adapter;
|
|||
import android.widget.AdapterView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.HandlerService;
|
||||
|
|
@ -34,7 +35,7 @@ import fr.free.nrw.commons.upload.UploadService;
|
|||
|
||||
public class ContributionsActivity
|
||||
extends AuthenticatedActivity
|
||||
implements LoaderManager.LoaderCallbacks<Object>,
|
||||
implements LoaderManager.LoaderCallbacks<Cursor>,
|
||||
AdapterView.OnItemClickListener,
|
||||
MediaDetailPagerFragment.MediaDetailProvider,
|
||||
FragmentManager.OnBackStackChangedListener,
|
||||
|
|
@ -204,14 +205,12 @@ public class ContributionsActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public Loader onCreateLoader(int i, Bundle bundle) {
|
||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||
return new CursorLoader(this, ContributionsContentProvider.BASE_URI, Contribution.Table.ALL_FIELDS, CONTRIBUTION_SELECTION, null, CONTRIBUTION_SORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader cursorLoader, Object result) {
|
||||
|
||||
Cursor cursor = (Cursor) result;
|
||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||
if(contributionsList.getAdapter() == null) {
|
||||
contributionsList.setAdapter(new ContributionsListAdapter(this, cursor, 0));
|
||||
} else {
|
||||
|
|
@ -225,7 +224,7 @@ public class ContributionsActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader cursorLoader) {
|
||||
public void onLoaderReset(Loader<Cursor> cursorLoader) {
|
||||
((CursorAdapter) contributionsList.getAdapter()).swapCursor(null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class MwVolleyApi {
|
|||
return categoryList;
|
||||
}
|
||||
|
||||
public static void setGpsCat(List cachedList) {
|
||||
public static void setGpsCat(List<String> cachedList) {
|
||||
categoryList = new ArrayList<>();
|
||||
categoryList.addAll(cachedList);
|
||||
Log.d(TAG, "Setting GPS cats from cache: " + categoryList.toString());
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ public class ShareActivity
|
|||
|
||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||
|
||||
List displayCatList = app.cacheData.findCategory();
|
||||
List<String> displayCatList = app.cacheData.findCategory();
|
||||
boolean catListEmpty = displayCatList.isEmpty();
|
||||
|
||||
// If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue