use of org.wikipedia.dataclient.mwapi.NearbyPage in project apps-android-wikipedia by wikimedia.
the class NearbyFragment method onStyleLoaded.
@Override
public void onStyleLoaded(@NonNull Style style) {
if (!isAdded() || mapboxMap == null) {
return;
}
symbolManager = new SymbolManager(mapView, mapboxMap, style);
symbolManager.setIconAllowOverlap(true);
symbolManager.setTextAllowOverlap(true);
symbolManager.addClickListener(symbol -> {
NearbyPage page = findNearbyPageFromSymbol(symbol);
if (page != null) {
onLoadPage(new HistoryEntry(page.getTitle(), HistoryEntry.SOURCE_NEARBY), page.getLocation());
}
});
enableUserLocationMarker();
if (lastCameraPos != null) {
mapboxMap.setCameraPosition(lastCameraPos);
} else {
goToUserLocationOrPromptPermissions();
}
showNearbyPages();
}
use of org.wikipedia.dataclient.mwapi.NearbyPage in project apps-android-wikipedia by wikimedia.
the class NearbyFragment method showNearbyPages.
private void showNearbyPages() {
if (mapboxMap == null || getActivity() == null) {
return;
}
getActivity().invalidateOptionsMenu();
symbolManager.delete(currentSymbols);
currentSymbols.clear();
List<SymbolOptions> optionsList = new ArrayList<>();
for (NearbyPage item : currentResults.getList()) {
if (item.getLocation() != null) {
optionsList.add(getSymbolOptions(item));
}
}
currentSymbols = symbolManager.create(optionsList);
}
use of org.wikipedia.dataclient.mwapi.NearbyPage in project apps-android-wikipedia by wikimedia.
the class NearbyUnitTest method constructNearbyPage.
private NearbyPage constructNearbyPage(@NonNull String title, double lat, double lon) {
Location location = new Location("");
location.setLatitude(lat);
location.setLongitude(lon);
return new NearbyPage(title, location);
}
use of org.wikipedia.dataclient.mwapi.NearbyPage in project apps-android-commons by commons-app.
the class NearbyUnitTest method constructNearbyPage.
private NearbyPage constructNearbyPage(@NonNull String title, double lat, double lon) {
Location location = new Location("");
location.setLatitude(lat);
location.setLongitude(lon);
return new NearbyPage(new PageTitle(title, TEST_WIKI_SITE), location);
}
use of org.wikipedia.dataclient.mwapi.NearbyPage in project apps-android-commons by commons-app.
the class NearbyUnitTest method testSortWithNullLocations.
@Test
public void testSortWithNullLocations() {
final Location location = null;
nearbyPages.add(new NearbyPage(new PageTitle("d", TEST_WIKI_SITE), location));
nearbyPages.add(new NearbyPage(new PageTitle("e", TEST_WIKI_SITE), location));
calcDistances(nearbyPages);
Collections.sort(nearbyPages, new NearbyDistanceComparator());
assertThat("a", is(nearbyPages.get(0).getTitle().getDisplayText()));
assertThat("b", is(nearbyPages.get(1).getTitle().getDisplayText()));
assertThat("c", is(nearbyPages.get(2).getTitle().getDisplayText()));
// the two null location values come last but in the same order as from the original list:
assertThat("d", is(nearbyPages.get(3).getTitle().getDisplayText()));
assertThat("e", is(nearbyPages.get(4).getTitle().getDisplayText()));
}
Aggregations