[android] Fixed the NPE exception in RoutingPlanController while retreiving the cached routing info

This commit is contained in:
alexzatsepin 2016-09-23 13:43:21 +03:00
parent 2143577410
commit 14663396e2
2 changed files with 17 additions and 5 deletions

View file

@ -92,6 +92,7 @@ public class RoutingController
private boolean mContainsCachedResult;
private int mLastResultCode;
private String[] mLastMissingMaps;
@Nullable
private RoutingInfo mCachedRoutingInfo;
@SuppressWarnings("FieldCanBeLocal")
@ -525,6 +526,7 @@ public class RoutingController
return mEndPoint;
}
@Nullable
RoutingInfo getCachedRoutingInfo()
{
return mCachedRoutingInfo;

View file

@ -177,12 +177,25 @@ public class RoutingPlanController extends ToolbarController
}
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);
@ -192,11 +205,8 @@ public class RoutingPlanController extends ToolbarController
String arrivalTime = RoutingController.formatArrivalTime(rinfo.totalTimeInSeconds);
numbersArrival.setText(arrivalTime);
}
UiUtils.show(mAltitudeChartFrame);
mAltitudeChartShown = true;
}
private void hideAltitudeChartAndRoutingDetails()
{
if (UiUtils.isHidden(mAltitudeChartFrame))