mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Call update map and add required markers
This commit is contained in:
parent
b10804910c
commit
786212fc49
7 changed files with 156 additions and 15 deletions
|
|
@ -41,21 +41,21 @@ public class NearbyController {
|
||||||
* Prepares Place list to make their distance information update later.
|
* Prepares Place list to make their distance information update later.
|
||||||
*
|
*
|
||||||
* @param curLatLng current location for user
|
* @param curLatLng current location for user
|
||||||
* @param latLangToSearchAround the location user wants to search around
|
* @param searchLatLng the location user wants to search around
|
||||||
* @param returnClosestResult if this search is done to find closest result or all results
|
* @param returnClosestResult if this search is done to find closest result or all results
|
||||||
* @return NearbyPlacesInfo a variable holds Place list without distance information
|
* @return NearbyPlacesInfo a variable holds Place list without distance information
|
||||||
* and boundary coordinates of current Place List
|
* and boundary coordinates of current Place List
|
||||||
*/
|
*/
|
||||||
public NearbyPlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng latLangToSearchAround, boolean returnClosestResult, boolean checkingAroundCurrentLocation) throws IOException {
|
public NearbyPlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng searchLatLng, boolean returnClosestResult, boolean checkingAroundCurrentLocation) throws IOException {
|
||||||
|
|
||||||
Timber.d("Loading attractions near %s", latLangToSearchAround);
|
Timber.d("Loading attractions near %s", searchLatLng);
|
||||||
NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo();
|
NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo();
|
||||||
|
|
||||||
if (latLangToSearchAround == null) {
|
if (searchLatLng == null) {
|
||||||
Timber.d("Loading attractions nearby, but curLatLng is null");
|
Timber.d("Loading attractions nearby, but curLatLng is null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Place> places = nearbyPlaces.radiusExpander(latLangToSearchAround, Locale.getDefault().getLanguage(), returnClosestResult);
|
List<Place> places = nearbyPlaces.radiusExpander(searchLatLng, Locale.getDefault().getLanguage(), returnClosestResult);
|
||||||
|
|
||||||
if (null != places && places.size() > 0) {
|
if (null != places && places.size() > 0) {
|
||||||
LatLng[] boundaryCoordinates = {places.get(0).location, // south
|
LatLng[] boundaryCoordinates = {places.get(0).location, // south
|
||||||
|
|
@ -91,6 +91,8 @@ public class NearbyController {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
nearbyPlacesInfo.curLatLng = curLatLng;
|
||||||
|
nearbyPlacesInfo.searchLatLng = searchLatLng;
|
||||||
nearbyPlacesInfo.placeList = places;
|
nearbyPlacesInfo.placeList = places;
|
||||||
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates;
|
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates;
|
||||||
if (!returnClosestResult && checkingAroundCurrentLocation) {
|
if (!returnClosestResult && checkingAroundCurrentLocation) {
|
||||||
|
|
@ -212,5 +214,7 @@ public class NearbyController {
|
||||||
public class NearbyPlacesInfo {
|
public class NearbyPlacesInfo {
|
||||||
public List<Place> placeList; // List of nearby places
|
public List<Place> placeList; // List of nearby places
|
||||||
public LatLng[] boundaryCoordinates; // Corners of nearby area
|
public LatLng[] boundaryCoordinates; // Corners of nearby area
|
||||||
|
public LatLng curLatLng; // current location when this places are populated
|
||||||
|
public LatLng searchLatLng; //search location for finding this places
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,13 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
|
||||||
import com.mapbox.mapboxsdk.maps.MapView;
|
import com.mapbox.mapboxsdk.maps.MapView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
|
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
|
||||||
import fr.free.nrw.commons.nearby.Place;
|
import fr.free.nrw.commons.nearby.Place;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,14 +25,14 @@ public interface NearbyMapContract {
|
||||||
void showSearchThisAreaButton();
|
void showSearchThisAreaButton();
|
||||||
void showInformationBottomSheet();
|
void showInformationBottomSheet();
|
||||||
void initViews();
|
void initViews();
|
||||||
void updateMapMarkers();
|
void updateMapMarkers(LatLng latLng, List<Place> placeList);
|
||||||
void updateMapToTrackPosition();
|
void updateMapToTrackPosition();
|
||||||
void setListeners();
|
void setListeners();
|
||||||
MapView setupMapView(Bundle savedInstanceState);
|
MapView setupMapView(Bundle savedInstanceState);
|
||||||
void addCurrentLocationMarker();
|
void addCurrentLocationMarker();
|
||||||
void setSearchThisAreaButtonVisibility(boolean visible);
|
void setSearchThisAreaButtonVisibility(boolean visible);
|
||||||
boolean isCurrentLocationMarkerVisible();
|
boolean isCurrentLocationMarkerVisible();
|
||||||
void addNearbyMarkersToMapBoxMap();
|
void addNearbyMarkersToMapBoxMap(List<NearbyBaseMarker> baseMarkerOptions);
|
||||||
void prepareViewsForSheetPosition();
|
void prepareViewsForSheetPosition();
|
||||||
void hideFABs();
|
void hideFABs();
|
||||||
void showFABs();
|
void showFABs();
|
||||||
|
|
@ -47,7 +52,7 @@ public interface NearbyMapContract {
|
||||||
void searchThisArea();
|
void searchThisArea();
|
||||||
void storeSharedPrefs();
|
void storeSharedPrefs();
|
||||||
void recenterMap();
|
void recenterMap();
|
||||||
void updateMapMarkers();
|
void updateMapMarkers(LatLng latLng);
|
||||||
void updateMapToTrackPosition();
|
void updateMapToTrackPosition();
|
||||||
void getBundleContent();
|
void getBundleContent();
|
||||||
boolean addMapMovementListener();
|
boolean addMapMovementListener();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.free.nrw.commons.nearby.mvp.contract;
|
package fr.free.nrw.commons.nearby.mvp.contract;
|
||||||
|
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||||
|
|
||||||
public interface NearbyParentFragmentContract {
|
public interface NearbyParentFragmentContract {
|
||||||
|
|
@ -16,6 +17,7 @@ public interface NearbyParentFragmentContract {
|
||||||
boolean isNetworkConnectionEstablished();
|
boolean isNetworkConnectionEstablished();
|
||||||
void addNetworkBroadcastReceiver();
|
void addNetworkBroadcastReceiver();
|
||||||
void listOptionMenuItemClicked();
|
void listOptionMenuItemClicked();
|
||||||
|
void populatePlaces(LatLng curlatLng, LatLng searchLatLng);
|
||||||
boolean isBottomSheetExpanded();
|
boolean isBottomSheetExpanded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -14,28 +15,54 @@ import android.view.animation.AnimationUtils;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.mapbox.mapboxsdk.Mapbox;
|
import com.mapbox.mapboxsdk.Mapbox;
|
||||||
|
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
|
||||||
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
|
import com.mapbox.mapboxsdk.constants.Style;
|
||||||
import com.mapbox.mapboxsdk.maps.MapView;
|
import com.mapbox.mapboxsdk.maps.MapView;
|
||||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||||
|
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||||
|
import com.mapbox.mapboxsdk.plugins.localization.LocalizationPlugin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
|
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
|
||||||
|
import fr.free.nrw.commons.nearby.NearbyController;
|
||||||
import fr.free.nrw.commons.nearby.Place;
|
import fr.free.nrw.commons.nearby.Place;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class NearbyMapFragment extends CommonsDaggerSupportFragment implements NearbyMapContract.View {
|
public class NearbyMapFragment extends CommonsDaggerSupportFragment implements NearbyMapContract.View {
|
||||||
|
@Inject
|
||||||
|
@Named("default_preferences")
|
||||||
|
JsonKvStore applicationKvStore;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BookmarkLocationsDao bookmarkLocationDao;
|
||||||
|
|
||||||
@BindView(R.id.bottom_sheet)
|
@BindView(R.id.bottom_sheet)
|
||||||
View bottomSheetList;
|
View bottomSheetList;
|
||||||
|
|
||||||
@BindView(R.id.bottom_sheet_details)
|
@BindView(R.id.bottom_sheet_details)
|
||||||
View bottomSheetDetails;
|
View bottomSheetDetails;
|
||||||
|
|
||||||
MapView mapView;
|
public MapView mapView;
|
||||||
|
public MapboxMap mapboxMap;
|
||||||
public NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback;
|
public NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback;
|
||||||
|
|
||||||
private BottomSheetBehavior bottomSheetListBehavior;
|
private BottomSheetBehavior bottomSheetListBehavior;
|
||||||
|
|
@ -45,6 +72,11 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
||||||
private Animation fab_open;
|
private Animation fab_open;
|
||||||
private Animation rotate_forward;
|
private Animation rotate_forward;
|
||||||
|
|
||||||
|
private static final double ZOOM_LEVEL = 14f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
@ -113,6 +145,38 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapView setupMapView(Bundle savedInstanceState) {
|
public MapView setupMapView(Bundle savedInstanceState) {
|
||||||
|
Log.d("deneme1","setupMapView");
|
||||||
|
Timber.d("setupMapView called");
|
||||||
|
boolean isDarkTheme = applicationKvStore.getBoolean("theme", false);
|
||||||
|
MapboxMapOptions options = new MapboxMapOptions()
|
||||||
|
.compassGravity(Gravity.BOTTOM | Gravity.LEFT)
|
||||||
|
.compassMargins(new int[]{12, 0, 0, 24})
|
||||||
|
.styleUrl(isDarkTheme ? Style.DARK : Style.OUTDOORS)
|
||||||
|
.logoEnabled(false)
|
||||||
|
.attributionEnabled(false)
|
||||||
|
.camera(new CameraPosition.Builder()
|
||||||
|
.zoom(ZOOM_LEVEL)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
if (!getParentFragment().getActivity().isFinishing()) {
|
||||||
|
MapView mapView = new MapView(getParentFragment().getActivity(), options);
|
||||||
|
// create map
|
||||||
|
mapView.onCreate(savedInstanceState);
|
||||||
|
mapView.getMapAsync(mapboxMap -> {
|
||||||
|
LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap);
|
||||||
|
|
||||||
|
try {
|
||||||
|
localizationPlugin.matchMapLanguageWithDeviceDefault();
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
Timber.d(exception.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mapboxMap = mapboxMap;
|
||||||
|
//addMapMovementListeners();
|
||||||
|
//updateMapSignificantlyForCurrentLocation();
|
||||||
|
});
|
||||||
|
return mapView;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,12 +191,23 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMapMarkers() {
|
public void updateMapMarkers(LatLng curLatLng, List<Place> placeList) {
|
||||||
|
Log.d("deneme1","updateMapMarkers");
|
||||||
|
List<NearbyBaseMarker> customBaseMarkerOptions = NearbyController
|
||||||
|
.loadAttractionsFromLocationToBaseMarkerOptions(curLatLng, // Curlatlang will be used to calculate distances
|
||||||
|
placeList,
|
||||||
|
getActivity(),
|
||||||
|
bookmarkLocationDao.getAllBookmarksLocations());
|
||||||
|
mapboxMap.clear();
|
||||||
|
// We are trying to find nearby places around our custom searched area, thus custom parameter is nonnull
|
||||||
|
addNearbyMarkersToMapBoxMap(customBaseMarkerOptions);
|
||||||
|
// Re-enable mapbox gestures on custom location markers load
|
||||||
|
mapboxMap.getUiSettings().setAllGesturesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMapToTrackPosition() {
|
public void updateMapToTrackPosition() {
|
||||||
|
//addCurrentLocationMarker(mapboxMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,7 +232,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNearbyMarkersToMapBoxMap() {
|
public void addNearbyMarkersToMapBoxMap(List<NearbyBaseMarker> baseMarkerOptions) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,10 +296,15 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Means that views are set in presenter
|
||||||
|
* @param viewsAreReadyCallback
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void viewsAreSet(NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback) {
|
public void viewsAreSet(NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback) {
|
||||||
Log.d("deneme1","viewsAreSet");
|
Log.d("deneme1","viewsAreSet");
|
||||||
this.viewsAreReadyCallback = viewsAreReadyCallback;
|
this.viewsAreReadyCallback = viewsAreReadyCallback;
|
||||||
|
|
||||||
this.viewsAreReadyCallback.nearbyFragmentAndMapViewReady();
|
this.viewsAreReadyCallback.nearbyFragmentAndMapViewReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
||||||
import fr.free.nrw.commons.utils.FragmentUtils;
|
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||||
|
|
@ -142,6 +145,30 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
wikidataEditListener.setAuthenticationStateListener(null);
|
wikidataEditListener.setAuthenticationStateListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populatePlaces(LatLng curlatLng, LatLng searchLatLng){
|
||||||
|
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
||||||
|
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, true))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(this::updateMapMarkers,
|
||||||
|
throwable -> {
|
||||||
|
Timber.d(throwable);
|
||||||
|
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates places for custom location, should be used for finding nearby places around a
|
||||||
|
* location where you are not at.
|
||||||
|
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||||
|
*/
|
||||||
|
private void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||||
|
nearbyParentFragmentPresenter.updateMapMarkers(nearbyPlacesInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resume fragments if they exists
|
* Resume fragments if they exists
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package fr.free.nrw.commons.nearby.mvp.presenter;
|
package fr.free.nrw.commons.nearby.mvp.presenter;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
|
|
||||||
|
|
@ -26,6 +27,11 @@ public class NearbyMapPresenter implements NearbyMapContract.UserActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void updateMapMarkers(LatLng latLng) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateMapMarkers() {
|
public void updateMapMarkers() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
package fr.free.nrw.commons.nearby.mvp.presenter;
|
package fr.free.nrw.commons.nearby.mvp.presenter;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
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;
|
||||||
import fr.free.nrw.commons.location.LocationUpdateListener;
|
import fr.free.nrw.commons.location.LocationUpdateListener;
|
||||||
|
import fr.free.nrw.commons.nearby.NearbyController;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||||
|
|
@ -35,7 +41,7 @@ public class NearbyParentFragmentPresenter
|
||||||
LocationServiceManager locationServiceManager) {
|
LocationServiceManager locationServiceManager) {
|
||||||
this.nearbyParentFragmentView = nearbyParentFragmentView;
|
this.nearbyParentFragmentView = nearbyParentFragmentView;
|
||||||
this.nearbyMapFragmentView = nearbyMapFragmentView;
|
this.nearbyMapFragmentView = nearbyMapFragmentView;
|
||||||
nearbyMapFragmentView.setViewsAreReady(this);
|
nearbyMapFragmentView.viewsAreSet(this);
|
||||||
this.locationServiceManager = locationServiceManager;
|
this.locationServiceManager = locationServiceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,13 +151,24 @@ public class NearbyParentFragmentPresenter
|
||||||
*/
|
*/
|
||||||
if (locationChangeType.equals(LOCATION_SIGNIFICANTLY_CHANGED)
|
if (locationChangeType.equals(LOCATION_SIGNIFICANTLY_CHANGED)
|
||||||
|| locationChangeType.equals(MAP_UPDATED)) {
|
|| locationChangeType.equals(MAP_UPDATED)) {
|
||||||
nearbyMapFragmentView.updateMapMarkers();
|
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
||||||
nearbyMapFragmentView.updateMapToTrackPosition();
|
// TODO add a search location here
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nearbyMapFragmentView.updateMapToTrackPosition();
|
nearbyMapFragmentView.updateMapToTrackPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates places for custom location, should be used for finding nearby places around a
|
||||||
|
* location where you are not at.
|
||||||
|
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||||
|
*/
|
||||||
|
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||||
|
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList);
|
||||||
|
nearbyMapFragmentView.updateMapToTrackPosition();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWikidataEditSuccessful() {
|
public void onWikidataEditSuccessful() {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue