[downloader][android] fix: Sometimes "Download" button was not shown in routing error dialog.

This commit is contained in:
Alexander Marchuk 2016-05-11 14:04:28 +03:00 committed by Vladimir Byko-Ianko
parent 39bac02dc3
commit 718e265d9e
2 changed files with 15 additions and 12 deletions

View file

@ -16,15 +16,15 @@ class ResultCodesHelper
static final int NO_ERROR = 0;
static final int CANCELLED = 1;
static final int NO_POSITION = 2;
static final int INCONSISTENT_MWM_ROUTE = 3;
static final int ROUTING_FILE_NOT_EXIST = 4;
static final int START_POINT_NOT_FOUND = 5;
static final int END_POINT_NOT_FOUND = 6;
static final int DIFFERENT_MWM = 7;
static final int ROUTE_NOT_FOUND = 8;
static final int NEED_MORE_MAPS = 9;
static final int INTERNAL_ERROR = 10;
static final int FILE_TOO_OLD = 11;
private static final int INCONSISTENT_MWM_ROUTE = 3;
private static final int ROUTING_FILE_NOT_EXIST = 4;
private static final int START_POINT_NOT_FOUND = 5;
private static final int END_POINT_NOT_FOUND = 6;
private static final int DIFFERENT_MWM = 7;
private static final int ROUTE_NOT_FOUND = 8;
private static final int NEED_MORE_MAPS = 9;
private static final int INTERNAL_ERROR = 10;
private static final int FILE_TOO_OLD = 11;
static Pair<String, String> getDialogTitleSubtitle(int errorCode, int missingCount)
{
@ -104,8 +104,11 @@ class ResultCodesHelper
return new Pair<>(titleRes == 0 ? "" : resources.getString(titleRes), builder.toString());
}
static boolean isDownloadable(int resultCode)
static boolean isDownloadable(int resultCode, int missingCount)
{
return resultCode == INCONSISTENT_MWM_ROUTE || resultCode == ROUTING_FILE_NOT_EXIST;
return (resultCode == INCONSISTENT_MWM_ROUTE ||
resultCode == ROUTING_FILE_NOT_EXIST ||
resultCode == NEED_MORE_MAPS ||
(resultCode == ROUTE_NOT_FOUND && missingCount > 0));
}
}

View file

@ -32,7 +32,7 @@ public class RoutingErrorDialogFragment extends BaseRoutingErrorDialogFragment
builder.setTitle(titleMessage.first);
mMessage = titleMessage.second;
if (ResultCodesHelper.isDownloadable(mResultCode))
if (ResultCodesHelper.isDownloadable(mResultCode, mMissingMaps.size()))
builder.setPositiveButton(R.string.download, null);
}