Make nearby card click action work

This commit is contained in:
neslihanturan 2019-09-17 12:57:58 +03:00
parent 4304e3d018
commit c5d4d5533d
5 changed files with 39 additions and 5 deletions

View file

@ -13,6 +13,7 @@ import android.widget.TextView;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.MainActivity;
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
import fr.free.nrw.commons.utils.SwipableCardView;
import fr.free.nrw.commons.utils.ViewUtil;
import timber.log.Timber;
@ -90,7 +91,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);
// Center the map to the place
//((NearbyFragment) m.contributionsActivityPagerAdapter.getItem(NEARBY_TAB_POSITION)).centerMapToPlace(place);
((NearbyParentFragment) m.contributionsActivityPagerAdapter.getItem(NEARBY_TAB_POSITION)).centerMapToPlace(place);
});
}

View file

@ -34,5 +34,6 @@ public interface NearbyMapContract {
MapboxMap getMapboxMap();
void viewsAreAssignedToPresenter(NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback);
void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener);
void centerMapToPlace(Place place, boolean isPortraitMode);
}
}

View file

@ -444,6 +444,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
* Centers the map in nearby fragment to a given place
* @param place is new center of the map
*/
@Override
public void centerMapToPlace(Place place, boolean isPortraitMode) {
Log.d("denemeSon","isPortyrait:"+isPortraitMode);
double cameraShift;

View file

@ -402,10 +402,13 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
public void centerMapToPlace(Place place) {
Log.d("denemeson","place:"+place);
if (nearbyMapFragment != null) {
nearbyMapFragment.centerMapToPlace(
place,
nearbyParentFragmentPresenter.centerMapToPlace(place,
getActivity().getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT);
/*nearbyMapFragment.centerMapToPlace(
place,
getActivity().getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT);*/
}
}

View file

@ -11,6 +11,7 @@ import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.location.LocationUpdateListener;
import fr.free.nrw.commons.nearby.NearbyController;
import fr.free.nrw.commons.nearby.Place;
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
import fr.free.nrw.commons.utils.LocationUtils;
@ -43,6 +44,11 @@ public class NearbyParentFragmentPresenter
boolean nearbyOperationsInitialized;
boolean mapInitialized; // TODO reset this on fragment destroyed
Place placeToCenter;
boolean isPortraitMode;
boolean willMapBeCentered;
boolean placesLoadedOnce;
private LocationServiceManager locationServiceManager;
@ -282,7 +288,7 @@ public class NearbyParentFragmentPresenter
/**
* 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.
* @param nearbyPlacesInfo This variable has placeToCenter list information and distances.
*/
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, Marker selectedMarker) {
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
@ -291,12 +297,13 @@ public class NearbyParentFragmentPresenter
lockUnlockNearby(false); // So that new location updates wont come
nearbyParentFragmentView.setProgressBarVisibility(false);
nearbyListFragmentView.updateListFragment(nearbyPlacesInfo.placeList);
handleCenteringTaskIfAny();
}
/**
* 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.
* @param nearbyPlacesInfo This variable has placeToCenter list information and distances.
*/
public void updateMapMarkersForCustomLocation(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, Marker selectedMarker) {
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
@ -304,7 +311,14 @@ public class NearbyParentFragmentPresenter
lockUnlockNearby(false); // So that new location updates wont come
nearbyParentFragmentView.setProgressBarVisibility(false);
nearbyListFragmentView.updateListFragment(nearbyPlacesInfo.placeList);
handleCenteringTaskIfAny();
}
private void handleCenteringTaskIfAny() {
if (!placesLoadedOnce) {
placesLoadedOnce = true;
nearbyMapFragmentView.centerMapToPlace(placeToCenter, isPortraitMode);
}
}
@Override
@ -395,4 +409,18 @@ public class NearbyParentFragmentPresenter
return true;
}
}
/**
* Centers the map in nearby fragment to a given placeToCenter
* @param place is new center of the map
*/
public void centerMapToPlace(Place place, boolean isPortraitMode) {
if (placesLoadedOnce) {
nearbyMapFragmentView.centerMapToPlace(place, isPortraitMode);
} else {
willMapBeCentered = true;
this.isPortraitMode = isPortraitMode;
this.placeToCenter = place;
}
}
}