Skip to content

Commit

Permalink
Merge pull request #4368 from alexzatsepin/release-64
Browse files Browse the repository at this point in the history
[android] Fixed the NPE exception in RoutingPlanController while retr…
  • Loading branch information
yunikkk authored Sep 28, 2016
2 parents c7b0247 + 01c2ea6 commit f3bac4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public interface Container
private boolean mContainsCachedResult;
private int mLastResultCode;
private String[] mLastMissingMaps;
@Nullable
private RoutingInfo mCachedRoutingInfo;

@SuppressWarnings("FieldCanBeLocal")
Expand Down Expand Up @@ -525,6 +526,7 @@ MapObject getEndPoint()
return mEndPoint;
}

@Nullable
RoutingInfo getCachedRoutingInfo()
{
return mCachedRoutingInfo;
Expand Down
20 changes: 15 additions & 5 deletions android/src/com/mapswithme/maps/routing/RoutingPlanController.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,25 @@ private void updateProgressLabels()
}

private void showAltitudeChartAndRoutingDetails()
{
UiUtils.show(mAltitudeChartFrame);
mAltitudeChartShown = true;
showRoutingDetails();
}

private void showRoutingDetails()
{
final View numbersFrame = mAltitudeChartFrame.findViewById(R.id.numbers);
final RoutingInfo rinfo = RoutingController.get().getCachedRoutingInfo();
if (rinfo == null)
{
UiUtils.hide(numbersFrame);
return;
}

TextView numbersTime = (TextView) numbersFrame.findViewById(R.id.time);
TextView numbersDistance = (TextView) numbersFrame.findViewById(R.id.distance);
TextView numbersArrival = (TextView) numbersFrame.findViewById(R.id.arrival);
RoutingInfo rinfo = RoutingController.get().getCachedRoutingInfo();
numbersTime.setText(RoutingController.formatRoutingTime(mFrame.getContext(), rinfo.totalTimeInSeconds,
R.dimen.text_size_routing_number));
numbersDistance.setText(rinfo.distToTarget + " " + rinfo.targetUnits);
Expand All @@ -192,11 +205,8 @@ private void showAltitudeChartAndRoutingDetails()
String arrivalTime = RoutingController.formatArrivalTime(rinfo.totalTimeInSeconds);
numbersArrival.setText(arrivalTime);
}

UiUtils.show(mAltitudeChartFrame);
mAltitudeChartShown = true;
}

private void hideAltitudeChartAndRoutingDetails()
{
if (UiUtils.isHidden(mAltitudeChartFrame))
Expand Down

0 comments on commit f3bac4d

Please sign in to comment.