Fix first screen no-wifi bug
This commit is contained in:
parent
d64d0bb0bf
commit
738c8e4cf6
1 changed files with 49 additions and 28 deletions
|
@ -130,7 +130,11 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (wizardType == WizardType.MAP_DOWNLOAD) {
|
if (wizardType == WizardType.MAP_DOWNLOAD) {
|
||||||
|
if (location != null) {
|
||||||
|
showOnMap(new LatLon(location.getLatitude(), location.getLongitude()), 13);
|
||||||
|
} else {
|
||||||
closeWizard();
|
closeWizard();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(getString(R.string.skip_map_downloading));
|
builder.setTitle(getString(R.string.skip_map_downloading));
|
||||||
|
@ -138,8 +142,12 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
builder.setNegativeButton(R.string.shared_string_skip, new DialogInterface.OnClickListener() {
|
builder.setNegativeButton(R.string.shared_string_skip, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (location != null) {
|
||||||
|
showOnMap(new LatLon(location.getLatitude(), location.getLongitude()), 13);
|
||||||
|
} else {
|
||||||
closeWizard();
|
closeWizard();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
builder.setNeutralButton(R.string.shared_string_cancel, null);
|
builder.setNeutralButton(R.string.shared_string_cancel, null);
|
||||||
builder.setPositiveButton(R.string.shared_string_select, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.shared_string_select, new DialogInterface.OnClickListener() {
|
||||||
|
@ -234,10 +242,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
redownloadButton.setOnClickListener(new View.OnClickListener() {
|
redownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (!downloadThread.isDownloading(item) && !item.isDownloaded() && firstMapDownloadCancelled) {
|
if (!downloadThread.isDownloading(item) && !item.isDownloaded()) {
|
||||||
progressPadding.setVisibility(View.GONE);
|
|
||||||
progressLayout.setVisibility(View.VISIBLE);
|
|
||||||
redownloadButton.setVisibility(View.GONE);
|
|
||||||
validationManager.startDownload(getActivity(), item);
|
validationManager.startDownload(getActivity(), item);
|
||||||
firstMapDownloadCancelled = false;
|
firstMapDownloadCancelled = false;
|
||||||
}
|
}
|
||||||
|
@ -246,19 +251,17 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
view.findViewById(R.id.map_download_progress_button).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.map_download_progress_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
downloadThread.cancelDownload(item);
|
|
||||||
firstMapDownloadCancelled = true;
|
firstMapDownloadCancelled = true;
|
||||||
|
downloadThread.cancelDownload(item);
|
||||||
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
|
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
|
||||||
progressPadding.setVisibility(View.VISIBLE);
|
progressPadding.setVisibility(View.VISIBLE);
|
||||||
progressLayout.setVisibility(View.GONE);
|
progressLayout.setVisibility(View.GONE);
|
||||||
redownloadButton.setVisibility(View.VISIBLE);
|
redownloadButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (item.isDownloaded() || firstMapDownloadCancelled) {
|
|
||||||
progressPadding.setVisibility(View.VISIBLE);
|
progressPadding.setVisibility(View.VISIBLE);
|
||||||
progressLayout.setVisibility(View.GONE);
|
progressLayout.setVisibility(View.GONE);
|
||||||
redownloadButton.setVisibility(firstMapDownloadCancelled ? View.VISIBLE : View.GONE);
|
redownloadButton.setVisibility(View.VISIBLE);
|
||||||
}
|
|
||||||
view.findViewById(R.id.map_downloading_layout).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.map_downloading_layout).setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
view.findViewById(R.id.map_downloading_layout).setVisibility(View.GONE);
|
view.findViewById(R.id.map_downloading_layout).setVisibility(View.GONE);
|
||||||
|
@ -277,10 +280,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
redownloadButton.setOnClickListener(new View.OnClickListener() {
|
redownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (!downloadThread.isDownloading(item) && !item.isDownloaded() && secondMapDownloadCancelled) {
|
if (!downloadThread.isDownloading(item) && !item.isDownloaded()) {
|
||||||
progressPadding.setVisibility(View.GONE);
|
|
||||||
progressLayout.setVisibility(View.VISIBLE);
|
|
||||||
redownloadButton.setVisibility(View.GONE);
|
|
||||||
validationManager.startDownload(getActivity(), item);
|
validationManager.startDownload(getActivity(), item);
|
||||||
secondMapDownloadCancelled = false;
|
secondMapDownloadCancelled = false;
|
||||||
}
|
}
|
||||||
|
@ -289,19 +289,17 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
view.findViewById(R.id.map2_download_progress_button).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.map2_download_progress_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
downloadThread.cancelDownload(item);
|
|
||||||
secondMapDownloadCancelled = true;
|
secondMapDownloadCancelled = true;
|
||||||
|
downloadThread.cancelDownload(item);
|
||||||
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
|
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
|
||||||
progressPadding.setVisibility(View.VISIBLE);
|
progressPadding.setVisibility(View.VISIBLE);
|
||||||
progressLayout.setVisibility(View.GONE);
|
progressLayout.setVisibility(View.GONE);
|
||||||
redownloadButton.setVisibility(View.VISIBLE);
|
redownloadButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (item.isDownloaded() || secondMapDownloadCancelled) {
|
|
||||||
progressPadding.setVisibility(View.VISIBLE);
|
progressPadding.setVisibility(View.VISIBLE);
|
||||||
progressLayout.setVisibility(View.GONE);
|
progressLayout.setVisibility(View.GONE);
|
||||||
redownloadButton.setVisibility(secondMapDownloadCancelled ? View.VISIBLE : View.GONE);
|
redownloadButton.setVisibility(View.VISIBLE);
|
||||||
}
|
|
||||||
view.findViewById(R.id.map2_downloading_layout).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.map2_downloading_layout).setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
view.findViewById(R.id.map_downloading_divider).setVisibility(View.GONE);
|
view.findViewById(R.id.map_downloading_divider).setVisibility(View.GONE);
|
||||||
|
@ -554,12 +552,14 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
|
|
||||||
private void updateDownloadedItems() {
|
private void updateDownloadedItems() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (IndexItem indexItem : indexItems) {
|
|
||||||
if (indexItem.isDownloaded()) {
|
|
||||||
final View firstRowLayout = view.findViewById(R.id.map_downloading_layout);
|
final View firstRowLayout = view.findViewById(R.id.map_downloading_layout);
|
||||||
final View secondRowLayout = view.findViewById(R.id.map2_downloading_layout);
|
final View secondRowLayout = view.findViewById(R.id.map2_downloading_layout);
|
||||||
final View progressLayout = view.findViewById(R.id.map_download_progress_layout);
|
final View progressLayout = view.findViewById(R.id.map_download_progress_layout);
|
||||||
final View progressLayout2 = view.findViewById(R.id.map2_download_progress_layout);
|
final View progressLayout2 = view.findViewById(R.id.map2_download_progress_layout);
|
||||||
|
final ImageButton redownloadButton = (ImageButton) view.findViewById(R.id.map_redownload_button);
|
||||||
|
final ImageButton redownloadButton2 = (ImageButton) view.findViewById(R.id.map2_redownload_button);
|
||||||
|
for (IndexItem indexItem : indexItems) {
|
||||||
|
if (indexItem.isDownloaded()) {
|
||||||
if (i == 0 && progressLayout.getVisibility() == View.VISIBLE) {
|
if (i == 0 && progressLayout.getVisibility() == View.VISIBLE) {
|
||||||
final TextView mapDescriptionTextView = (TextView) view.findViewById(R.id.map_downloading_desc);
|
final TextView mapDescriptionTextView = (TextView) view.findViewById(R.id.map_downloading_desc);
|
||||||
mapDescriptionTextView.setText(indexItem.getSizeDescription(getContext()));
|
mapDescriptionTextView.setText(indexItem.getSizeDescription(getContext()));
|
||||||
|
@ -589,6 +589,25 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (downloadThread.isDownloading(indexItem)) {
|
||||||
|
if (i == 0 && !firstMapDownloadCancelled) {
|
||||||
|
if (progressLayout.getVisibility() == View.GONE) {
|
||||||
|
progressLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
if (redownloadButton.getVisibility() == View.VISIBLE) {
|
||||||
|
redownloadButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 1 && !secondMapDownloadCancelled) {
|
||||||
|
if (progressLayout2.getVisibility() == View.GONE) {
|
||||||
|
progressLayout2.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
if (redownloadButton2.getVisibility() == View.VISIBLE) {
|
||||||
|
redownloadButton2.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -616,8 +635,10 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
||||||
|
|
||||||
private void showOnMap(LatLon mapCenter, int mapZoom) {
|
private void showOnMap(LatLon mapCenter, int mapZoom) {
|
||||||
MapActivity mapActivity = (MapActivity) getActivity();
|
MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
mapActivity.setMapLocation(mapCenter.getLatitude(), mapCenter.getLongitude());
|
mapActivity.setMapLocation(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||||
mapActivity.getMapView().setIntZoom(mapZoom);
|
mapActivity.getMapView().setIntZoom(mapZoom);
|
||||||
|
}
|
||||||
closeWizard();
|
closeWizard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue