Convert ExploreMapCalls and ExploreMapContract to kotlin

This commit is contained in:
Paul Hawke 2025-07-13 22:31:57 -05:00
parent 77ee6e4161
commit a0214d8ddc
4 changed files with 68 additions and 79 deletions

View file

@ -1,34 +0,0 @@
package fr.free.nrw.commons.explore.map;
import androidx.annotation.NonNull;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.media.MediaClient;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class ExploreMapCalls {
@Inject
MediaClient mediaClient;
@Inject
public ExploreMapCalls() {
}
/**
* Calls method to query Commons for uploads around a location
*
* @param currentLatLng coordinates of search location
* @return list of places obtained
*/
@NonNull
List<Media> callCommonsQuery(final LatLng currentLatLng) {
String coordinates = currentLatLng.getLatitude() + "|" + currentLatLng.getLongitude();
return mediaClient.getMediaListFromGeoSearch(coordinates).blockingGet();
}
}

View file

@ -0,0 +1,25 @@
package fr.free.nrw.commons.explore.map
import fr.free.nrw.commons.Media
import fr.free.nrw.commons.location.LatLng
import fr.free.nrw.commons.media.MediaClient
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class ExploreMapCalls @Inject constructor() {
@Inject
@JvmField
var mediaClient: MediaClient? = null
/**
* Calls method to query Commons for uploads around a location
*
* @param currentLatLng coordinates of search location
* @return list of places obtained
*/
fun callCommonsQuery(currentLatLng: LatLng): List<Media> {
val coordinates = currentLatLng.latitude.toString() + "|" + currentLatLng.longitude
return mediaClient!!.getMediaListFromGeoSearch(coordinates).blockingGet()
}
}

View file

@ -1,45 +0,0 @@
package fr.free.nrw.commons.explore.map;
import android.content.Context;
import fr.free.nrw.commons.BaseMarker;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager;
import java.util.List;
public class ExploreMapContract {
interface View {
boolean isNetworkConnectionEstablished();
void populatePlaces(LatLng curlatLng);
void askForLocationPermission();
void recenterMap(LatLng curLatLng);
void hideBottomDetailsSheet();
LatLng getMapCenter();
LatLng getMapFocus();
LatLng getLastMapFocus();
void addMarkersToMap(final List<BaseMarker> nearbyBaseMarkers);
void clearAllMarkers();
void addSearchThisAreaButtonAction();
void setSearchThisAreaButtonVisibility(boolean isVisible);
void setProgressBarVisibility(boolean isVisible);
boolean isDetailsBottomSheetVisible();
boolean isSearchThisAreaButtonVisible();
Context getContext();
LatLng getLastLocation();
void disableFABRecenter();
void enableFABRecenter();
void setFABRecenterAction(android.view.View.OnClickListener onClickListener);
boolean backButtonClicked();
}
interface UserActions {
void updateMap(LocationServiceManager.LocationChangeType locationChangeType);
void lockUnlockNearby(boolean isNearbyLocked);
void attachView(View view);
void detachView();
void setActionListeners(JsonKvStore applicationKvStore);
boolean backButtonClicked();
}
}

View file

@ -0,0 +1,43 @@
package fr.free.nrw.commons.explore.map
import android.content.Context
import android.view.View
import fr.free.nrw.commons.BaseMarker
import fr.free.nrw.commons.kvstore.JsonKvStore
import fr.free.nrw.commons.location.LatLng
import fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType
class ExploreMapContract {
interface View {
fun isNetworkConnectionEstablished(): Boolean
fun populatePlaces(curlatLng: LatLng?)
fun askForLocationPermission()
fun recenterMap(curLatLng: LatLng?)
fun hideBottomDetailsSheet()
fun getMapCenter(): LatLng?
fun getMapFocus(): LatLng?
fun getLastMapFocus(): LatLng?
fun addMarkersToMap(nearbyBaseMarkers: List<BaseMarker?>?)
fun clearAllMarkers()
fun addSearchThisAreaButtonAction()
fun setSearchThisAreaButtonVisibility(isVisible: Boolean)
fun setProgressBarVisibility(isVisible: Boolean)
fun isDetailsBottomSheetVisible(): Boolean
fun isSearchThisAreaButtonVisible(): Boolean
fun getContext(): Context?
fun getLastLocation(): LatLng?
fun disableFABRecenter()
fun enableFABRecenter()
fun setFABRecenterAction(onClickListener: android.view.View.OnClickListener?)
fun backButtonClicked(): Boolean
}
interface UserActions {
fun updateMap(locationChangeType: LocationChangeType?)
fun lockUnlockNearby(isNearbyLocked: Boolean)
fun attachView(view: View?)
fun detachView()
fun setActionListeners(applicationKvStore: JsonKvStore?)
fun backButtonClicked(): Boolean
}
}