public class MapFragment
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
MapFragment.MapFiller
Manages the list of pins to draw on the map
|
class |
MapFragment.MarkerInfoWindowAdapter
Manages the data shown in the info window
|
Modifier and Type | Field and Description |
---|---|
private int |
curMapTypeIndex |
static MapFragment |
instance |
private int[] |
MAP_TYPES |
private android.support.design.widget.CoordinatorLayout |
mapCoordinatorLayout |
private com.google.android.gms.maps.SupportMapFragment |
mapFragment |
private Location |
mCurrentLocation |
private com.google.android.gms.common.api.GoogleApiClient |
mGoogleApiClient |
com.google.android.gms.maps.GoogleMap |
mGoogleMap |
private static long |
MIN_DISTANCE_CHANGE_FOR_UPDATES |
private static long |
MIN_TIME_BW_UPDATES |
private Square |
mLastSelectedSquare |
private java.lang.String |
mLastSelectedSquareId |
private com.google.android.gms.maps.model.LatLng |
mLastUpdateLocation |
private BroadcastReceiver |
mMessageReceiver
Broadcast receiver that manages in real time the creation, update and deletion of squares on the map
|
private com.arlib.floatingsearchview.FloatingSearchView |
mSearchView |
private com.google.android.gms.analytics.Tracker |
mTracker |
private static int |
PERMISSION_REQUEST_CODE |
private static float |
PIN_DOWNLOAD_RADIUS |
private static float |
PIN_DOWNLOAD_RADIUS_MAX |
static int |
REQUEST_SQUARE |
static int |
RESULT_SQUARE |
static int |
RESULT_SQUARE_FACEBOOK |
private java.util.List<Square> |
searchResult |
static java.lang.String |
SQUARE_TAG |
private java.util.HashMap<com.google.android.gms.maps.model.Marker,Square> |
squareHashMap |
private static java.lang.String |
TAG |
Constructor and Description |
---|
MapFragment() |
Modifier and Type | Method and Description |
---|---|
void |
checkActivityIntent(Intent intent)
Method that open the proper ChatActivity if the user clicked on a notification
|
private com.google.android.gms.maps.model.BitmapDescriptor |
correctMapPin(java.lang.String name,
int scaleSize)
Defines the size and color of a pin
|
private com.google.android.gms.maps.model.Marker |
createSquarePin(com.google.android.gms.maps.model.LatLng pos,
java.lang.String name,
int type)
Creates and adds a marker on the map
|
private void |
downloadAndInsertPins(double distance,
com.google.android.gms.maps.model.LatLng position)
Downloads and draws on the map the closest squares, based on the zoom distance and the actual center of the map
|
void |
favouriteSquare(int method,
Square square)
unused
|
private void |
getClosestSquares(java.lang.String distance,
double lat,
double lon)
Sends a request to the server to download the closest squares based on a position and a radius of research
|
private float |
getDistance(com.google.android.gms.maps.model.LatLng southwest,
com.google.android.gms.maps.model.LatLng frnd_latlong)
Calculates the distance between 2 locations
|
Location |
getmCurrentLocation() |
void |
handleSquareCreation(int resultCode,
Intent data)
Manages the kind of request that will be done to the server to create a new Square
|
private void |
initCamera()
Initializes the Google Maps map
|
private void |
initListeners()
Initializes all the necessary listeners for the MapFragment
|
private void |
moveToPosition(Location toLocation)
Moves the map to a given location
|
static MapFragment |
newInstance() |
void |
onActivityCreated(Bundle savedInstanceState) |
void |
onCameraChange(com.google.android.gms.maps.model.CameraPosition cameraPosition)
Triggers when the user scrolls the map and eventually downloads nearby squares
|
void |
onConnected(Bundle bundle) |
void |
onConnectionFailed(com.google.android.gms.common.ConnectionResult connectionResult) |
void |
onConnectionSuspended(int i) |
void |
onCreate(Bundle savedInstanceState) |
View |
onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) |
void |
onDetach() |
void |
onFavChanged() |
void |
onInfoWindowClick(com.google.android.gms.maps.model.Marker marker) |
void |
onMapClick(com.google.android.gms.maps.model.LatLng latLng) |
void |
onMapLongClick(com.google.android.gms.maps.model.LatLng latLng)
Listens to a longpress on the map and shows the CreateSquareActivity
|
void |
onMapReady(com.google.android.gms.maps.GoogleMap googleMap)
Triggered when the Google Map is ready.
|
boolean |
onMarkerClick(com.google.android.gms.maps.model.Marker marker)
Shows the info windows for a square when the user taps on its marker
|
void |
onOwnedChanged() |
void |
onPause() |
void |
onRecentChanged() |
void |
onRequestPermissionsResult(int requestCode,
java.lang.String[] permissions,
int[] grantResults)
When the user gives the location permissions to the app, it calls setupLocation
|
void |
onResume() |
void |
onStart() |
void |
onStop() |
void |
onViewCreated(View view,
Bundle savedInstanceState) |
void |
setMapInPosition(double lat,
double lon) |
private void |
setupLocation()
Sets on the map the marker in the actual position of the user
|
private void |
setupSearchView()
Manages the list of results from the search bar.
|
void |
startChatActivity(Square s)
Opens the ChatActivity relative to a given Square
|
private static final int PERMISSION_REQUEST_CODE
private java.util.List<Square> searchResult
public static MapFragment instance
private com.google.android.gms.maps.SupportMapFragment mapFragment
public static final int REQUEST_SQUARE
public static final int RESULT_SQUARE
public static final int RESULT_SQUARE_FACEBOOK
private static final java.lang.String TAG
private com.google.android.gms.common.api.GoogleApiClient mGoogleApiClient
private Location mCurrentLocation
private com.google.android.gms.maps.model.LatLng mLastUpdateLocation
private java.lang.String mLastSelectedSquareId
private Square mLastSelectedSquare
private static final float PIN_DOWNLOAD_RADIUS
private static final float PIN_DOWNLOAD_RADIUS_MAX
private final int[] MAP_TYPES
private int curMapTypeIndex
public com.google.android.gms.maps.GoogleMap mGoogleMap
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES
private static final long MIN_TIME_BW_UPDATES
private java.util.HashMap<com.google.android.gms.maps.model.Marker,Square> squareHashMap
private android.support.design.widget.CoordinatorLayout mapCoordinatorLayout
private com.arlib.floatingsearchview.FloatingSearchView mSearchView
private com.google.android.gms.analytics.Tracker mTracker
public static final java.lang.String SQUARE_TAG
private BroadcastReceiver mMessageReceiver
public static MapFragment newInstance()
public void onCreate(Bundle savedInstanceState)
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
public void onViewCreated(View view, Bundle savedInstanceState)
public void onStart()
public void onResume()
public void onPause()
public void onStop()
public void onDetach()
public void onConnected(Bundle bundle)
private void setupLocation()
public void onRequestPermissionsResult(int requestCode, java.lang.String[] permissions, int[] grantResults)
setupLocation()
private void setupSearchView()
private void moveToPosition(Location toLocation)
toLocation
- The location in which the map will be centeredprivate void initCamera()
public void checkActivityIntent(Intent intent)
public void onConnectionSuspended(int i)
public void onCameraChange(com.google.android.gms.maps.model.CameraPosition cameraPosition)
cameraPosition
- The new camera positionprivate void downloadAndInsertPins(double distance, com.google.android.gms.maps.model.LatLng position)
distance
- The zoom distanceposition
- The actual center of the mapgetClosestSquares(String, double, double)
private void getClosestSquares(java.lang.String distance, double lat, double lon)
distance
- lat
- Latitude of the actual center of the maplon
- Longitude of the actual center of the mapprivate float getDistance(com.google.android.gms.maps.model.LatLng southwest, com.google.android.gms.maps.model.LatLng frnd_latlong)
southwest
- location 1frnd_latlong
- location 2public void onConnectionFailed(com.google.android.gms.common.ConnectionResult connectionResult)
public void onInfoWindowClick(com.google.android.gms.maps.model.Marker marker)
public void startChatActivity(Square s)
s
- A squareChatActivity
private com.google.android.gms.maps.model.Marker createSquarePin(com.google.android.gms.maps.model.LatLng pos, java.lang.String name, int type)
pos
- location of the markername
- name to be showntype
- type of the squarecorrectMapPin(String, int)
private com.google.android.gms.maps.model.BitmapDescriptor correctMapPin(java.lang.String name, int scaleSize)
name
- name of the pinscaleSize
- scale sizepublic void onMapClick(com.google.android.gms.maps.model.LatLng latLng)
public void onActivityCreated(@Nullable Bundle savedInstanceState)
public void handleSquareCreation(int resultCode, Intent data)
resultCode
- The code of which kind of square is being createddata
- The package of data of the new Squarepublic void onMapLongClick(com.google.android.gms.maps.model.LatLng latLng)
latLng
- the position of the longpresspublic void onMapReady(com.google.android.gms.maps.GoogleMap googleMap)
downloadAndInsertPins(double, LatLng)
private void initListeners()
public boolean onMarkerClick(com.google.android.gms.maps.model.Marker marker)
marker
- the marker of the squarepublic void favouriteSquare(int method, Square square)
public void onOwnedChanged()
public void onFavChanged()
public void onRecentChanged()
public void setMapInPosition(double lat, double lon)
public Location getmCurrentLocation()