|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectims.map.Map
public class Map
The main class which handles the map-fragment. It sets up the GoogleMap and
the main components.
Copyright © 2014 by Daniela Blum
This file is part of GPSChildFinder.
GPSChildFinder is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program. If not, see http://www.gnu.org/licenses.
Constructor Summary | |
---|---|
Map(android.content.Context context,
android.app.FragmentManager fragmentManager)
Constructor which sets the context and the fragmentManager of the context to show the map in a fragment of the mainActivity. |
Method Summary | |
---|---|
void |
addDeviceLocationMarker(com.google.android.gms.maps.model.MarkerOptions deviceLocationMarkerOptions)
Adds or rather updates the icon of the marker of the device's location |
void |
calculateNewBounds(android.view.View.OnClickListener listener)
Called from ims.map.DeviceButtonListener or
MyLocationListener when the new bounds of the screen
should be calculated so that both - device and my location - are shown on
the map. |
boolean |
checkLocationSettings()
Checks which location settings are set on the phone which are needed to show my location (phone's location) on the map. |
void |
connectMyLocationClient()
Connects the location client. |
void |
disconnectMyLocationClient()
Disconnects the location client and removes all the location updates. |
DeviceLocationButton |
getDeviceLocationButton()
|
android.os.Handler |
getDeviceLocationHandler()
|
MyLocationButton |
getMyLocationButton()
|
void |
initMap()
Called in the noCreate() method in the context class (here the MainActivity to initialize the GoogleMap
with the aid of the fragmentManager. |
void |
onConnected(android.os.Bundle arg0)
Called by Location Services when the request to connect the client finishes successfully. |
void |
onConnectionFailed(com.google.android.gms.common.ConnectionResult connectionResult)
Called by Location Services if the attempt to Location Services fails. |
void |
onDestroy()
Is called from MainActivity when the Activity gets
destroyed. |
void |
onDisconnected()
Called by Location Services if the connection to the location client drops because of an error. |
void |
removeDeviceLocationMarker()
Removes the marker of the device's location when the location can't be obtained. |
void |
removeMyLocationMarker()
Removes the marker of my location (phone's location) when the location can't be obtained. |
void |
requestMyLocationUpdate()
Called from MyLocationListener when a update of my
location (phones location) is requested from the
myLocationClient . |
void |
selectDeviceLocationButton(java.lang.Boolean selected)
If deviceLocationButton is selected or unselected the button
icon and status gets changed with
ImageView.setSelected(boolean) and
StatusImageButton.setButtonStatus(ButtonStatus) . |
void |
selectMyLocationButton(java.lang.Boolean selected)
If myLocationButton is selected or unselected the button icon
and status gets changed with
ImageView.setSelected(boolean) and
StatusImageButton.setButtonStatus(ButtonStatus) . |
void |
setDeviceHandler(android.os.Handler deviceHandler)
|
void |
setDeviceLocationButton(DeviceLocationButton deviceLocationButton)
|
void |
setMapType(int type)
Wrapper function. |
void |
setMyLocationButton(MyLocationButton myLocationButton)
|
void |
showDeviceLocation(android.view.View view)
Method places device's current location as point of interest in the center of the view by moving the map's camera. |
void |
showMyLocation()
Method places my/phone's current location as point of interest in the center of the view by moving the map's camera. |
void |
showToast(int message,
int duration)
Shows a toast on the screen. |
void |
updateCamera(float bearing)
Called from MySensorEventListener and moves the camera
into a new position after the view direction has changed. |
void |
updateDirectionArrow()
Called when the direction arrow should be updated to align in direction of the remote device. |
void |
updateDistance(boolean remove)
Is called when the distance should be updated. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Map(android.content.Context context, android.app.FragmentManager fragmentManager)
context
- context of the map. Normally the MainActivity
fragmentManager
- fragment manager of the context to show the map in a frame of
the context classMethod Detail |
---|
public void initMap()
MainActivity
to initialize the GoogleMap
with the aid of the fragmentManager. gestureDetector
with the supplied listener and calls the methods
to setup the main components of the GoogleMap:
initMyLocationComponents()
,
initDeviceLocationComponents()
,
initDirectionComponents()
startScreen()
method)
public void setMapType(int type)
GoogleMap.setMapType(int)
method and
forwards the map type to set the GoogleMap-type.
type
- GoogleMap-type. Can either be
GoogleMap.MAP_TYPE_SATELLITE
,
GoogleMap.MAP_TYPE_TERRAIN
or
GoogleMap.MAP_TYPE_NORMAL
public void requestMyLocationUpdate()
MyLocationListener
when a update of my
location (phones location) is requested from the
myLocationClient
.
public void selectMyLocationButton(java.lang.Boolean selected)
myLocationButton
is selected or unselected the button icon
and status gets changed with
ImageView.setSelected(boolean)
and
StatusImageButton.setButtonStatus(ButtonStatus)
. deviceLocationButton
methods are called for deselecting
and button icon changing that both selected aren't possible.
selected
- true if the myLocationButton is pressed/selected by the
user, false otherwisepublic void selectDeviceLocationButton(java.lang.Boolean selected)
deviceLocationButton
is selected or unselected the button
icon and status gets changed with
ImageView.setSelected(boolean)
and
StatusImageButton.setButtonStatus(ButtonStatus)
. myLocationButton
methods are called for deselecting and
button icon changing that both selected aren't possible.
selected
- true if the deviceLocationButton is pressed/selected by
the user, false otherwisepublic void showMyLocation()
myLocationButton
is pressed. getMyLocation()
method if no location can be
demanded.
public void showDeviceLocation(android.view.View view)
deviceLocationButton
is pressed. getDeviceLocation()
method if no location can be
demanded.
public void addDeviceLocationMarker(com.google.android.gms.maps.model.MarkerOptions deviceLocationMarkerOptions)
deviceLocationMarkerOptions
- the options to add the marker of the device's locationpublic void removeDeviceLocationMarker()
public void removeMyLocationMarker()
public void updateDistance(boolean remove)
Location.distanceBetween(double, double, double, double, float[])
is called to calculate the new distance in meters between the points.
remove
- true if distance textView should be removed,
false if distance should be updatedpublic void updateDirectionArrow()
Math.atan2(double, double)
method and the latitudes and
longitudes of the two points/locations. myLocationMarkerOptions
are updated and
addMyLocationMarker(MarkerOptions)
is called.
public void calculateNewBounds(android.view.View.OnClickListener listener)
ims.map.DeviceButtonListener
or
MyLocationListener
when the new bounds of the screen
should be calculated so that both - device and my location - are shown on
the map.BoundsCalculator.calculateNewBounds(GoogleMap, LatLng)
method.
listener
- the listener where the method was called frompublic void updateCamera(float bearing)
MySensorEventListener
and moves the camera
into a new position after the view direction has changed.
bearing
- direction of the compasspublic void showToast(int message, int duration)
message
- Current relevant message to show on the screen. The resource
id of the string resource to use. Can be formatted text.duration
- How long to display the message. Either
Toast.LENGTH_SHORT
or Toast#LENGTH_LONG
public void onDestroy() throws java.lang.NullPointerException
MainActivity
when the Activity gets
destroyed. deviceLocationHandler
.
Unregisters the sensorListener
from all sensors.
java.lang.NullPointerException
- when the deviceLocationHandler
or
updateDeviceLocationRunnable
isn't initialized at
the moment.public android.os.Handler getDeviceLocationHandler()
public void setDeviceHandler(android.os.Handler deviceHandler)
deviceHandler
- to setpublic MyLocationButton getMyLocationButton()
public void setMyLocationButton(MyLocationButton myLocationButton)
myLocationButton
- to setpublic DeviceLocationButton getDeviceLocationButton()
public void setDeviceLocationButton(DeviceLocationButton deviceLocationButton)
deviceLocationButton
- to setpublic void onConnected(android.os.Bundle arg0)
onConnected
in interface com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks
public void onConnectionFailed(com.google.android.gms.common.ConnectionResult connectionResult)
onConnectionFailed
in interface com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener
public void onDisconnected()
onDisconnected
in interface com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks
public void connectMyLocationClient()
public void disconnectMyLocationClient()
public boolean checkLocationSettings()
Settings.Secure#LOCATION_MODE_HIGH_ACCURACY
or
Settings.Secure#LOCATION_MODE_BATTERY_SAVING
,
false otherwise (location access off (
Settings.Secure#LOCATION_MODE_OFF
) or device only) Settings.Secure#LOCATION_PROVIDERS_ALLOWED
contains at
least one provider, false if its empty.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |