Skip to content

Commit

Permalink
Merge pull request #1333 from ne0fhyk/bug_fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
m4gr3d committed Dec 17, 2014
2 parents b66675f + a804146 commit dd603df
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId 'org.droidplanner.android'
minSdkVersion 14
targetSdkVersion 21
versionCode 310
versionName "alpha v3.0.10"
versionCode 30010
versionName getGitVersion()
}

sourceSets {
Expand Down Expand Up @@ -96,7 +96,7 @@ android {
* @return The most recent git tag to be used as version name for the app.
*/
def getGitVersion(){
def cmd = "git describe --tag --dirty"
def cmd = "git describe --tag"
try {
def proc = cmd.execute()
return proc.text.trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,17 @@ public void onPathFinished(List<LatLong> path) {
List<LatLong> points = planningMapFragment.projectPathIntoMap(path);
switch (getTool()) {
case DRAW:
if (mIsSplineEnabled) {
missionProxy.addSplineWaypoints(points);
} else {
missionProxy.addWaypoints(points);
}
if(missionProxy != null) {
if (mIsSplineEnabled) {
missionProxy.addSplineWaypoints(points);
} else {
missionProxy.addWaypoints(points);
}
}
break;

case POLY:
if (path.size() > 2) {
if (missionProxy != null && path.size() > 2) {
missionProxy.addSurveyPolygon(points);
} else {
editorToolsFragment.setTool(EditorTools.POLY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.android.gms.maps.model.LatLng;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
import com.o3dr.services.android.lib.drone.property.Gps;

public class FlightMapFragment extends DroneMap implements DPMap.OnMapLongClickListener,
DPMap.OnMarkerClickListener, DPMap.OnMarkerDragListener, GuidedDialogListener {
Expand Down Expand Up @@ -115,7 +116,7 @@ public void onApiDisconnected(){

@Override
public void onMapLongClick(LatLong coord) {
if (drone.isConnected()) {
if (drone != null && drone.isConnected()) {
if (drone.getGuidedState().isInitialized()) {
drone.sendGuidedPoint(coord, false);
} else {
Expand Down Expand Up @@ -177,7 +178,8 @@ public void goToMyLocation() {
public void goToDroneLocation() {
super.goToDroneLocation();

if (!this.drone.getGps().isValid())
final Gps droneGps = this.drone.getGps();
if (droneGps == null || !droneGps.isValid())
return;

final int pressCount = mAppPrefs.prefs.getInt(PREF_DRONE_LOCATION_FIRST_PRESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ public void onReceive(Context context, Intent intent) {
if (!drone.isConnected())
return;

GoogleMap map = getMap();
Gps droneGps = drone.getGps();
if (map == null || droneGps == null)
final Gps droneGps = drone.getGps();
if (droneGps == null)
return;

if (mPanMode.get() == AutoPanMode.DRONE && droneGps.isValid()) {
final float currentZoomLevel = map.getCameraPosition().zoom;
final LatLong droneLocation = droneGps.getPosition();
updateCamera(droneLocation, currentZoomLevel);
updateCamera(droneLocation);
}
}
};
Expand Down Expand Up @@ -492,11 +490,29 @@ protected void doRun() {
}
}

private void updateCamera(final LatLong coord){
if(coord != null){
getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
final float zoomLevel = googleMap.getCameraPosition().zoom;
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(DroneHelper.CoordToLatLang(coord),
zoomLevel));
}
});
}
}

@Override
public void updateCamera(LatLong coord, float zoomLevel) {
public void updateCamera(final LatLong coord, final float zoomLevel) {
if (coord != null) {
getMap().animateCamera(CameraUpdateFactory.newLatLngZoom(
DroneHelper.CoordToLatLang(coord), zoomLevel));
getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
DroneHelper.CoordToLatLang(coord), zoomLevel));
}
});
}
}

Expand Down Expand Up @@ -635,7 +651,7 @@ public void zoomToFit(List<LatLong> coords) {
@Override
public void onMapReady(GoogleMap googleMap) {
CameraUpdate animation = CameraUpdateFactory.newLatLngBounds(bounds, 100);
getMap().animateCamera(animation);
googleMap.animateCamera(animation);
}
});
}
Expand Down Expand Up @@ -822,10 +838,6 @@ public double getMapRotation() {
}
}

private boolean isMapLayoutFinished() {
return getMap() != null && getView() != null && getView().getWidth() > 0;
}

@Override
public void onLocationChanged(Location location) {
Log.d(TAG, "User location changed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ private void checkIfValid(Survey survey) {
}

private void updateViews() {
if(isDetached())
return;

updateTextViews();
updateSeekBars();
}
Expand Down

0 comments on commit dd603df

Please sign in to comment.