Search map for context menu in background
This commit is contained in:
parent
8e300271a2
commit
f2b037d3c2
3 changed files with 205 additions and 146 deletions
|
@ -305,6 +305,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
appModeChanged = false;
|
appModeChanged = false;
|
||||||
|
|
||||||
if (needAcquireMenuController) {
|
if (needAcquireMenuController) {
|
||||||
|
if (menuController != null) {
|
||||||
|
menuController.setMapContextMenu(null);
|
||||||
|
}
|
||||||
if (!acquireMenuController(restorePrevious)) {
|
if (!acquireMenuController(restorePrevious)) {
|
||||||
active = false;
|
active = false;
|
||||||
clearSelectedObject(object);
|
clearSelectedObject(object);
|
||||||
|
@ -380,6 +383,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rebuildMenu() {
|
||||||
|
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||||
|
if (fragmentRef != null) {
|
||||||
|
fragmentRef.get().rebuildMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void showOrUpdate(LatLon latLon, PointDescription pointDescription, Object object) {
|
public void showOrUpdate(LatLon latLon, PointDescription pointDescription, Object object) {
|
||||||
if (isVisible() && this.object != null && this.object.equals(object)) {
|
if (isVisible() && this.object != null && this.object.equals(object)) {
|
||||||
update(latLon, pointDescription, object);
|
update(latLon, pointDescription, object);
|
||||||
|
@ -526,6 +536,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
menuController = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.STANDARD);
|
menuController = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.STANDARD);
|
||||||
if (menuController.setActive(true)) {
|
if (menuController.setActive(true)) {
|
||||||
|
menuController.setMapContextMenu(this);
|
||||||
if (menuData != null && (object != menuData.getObject())
|
if (menuData != null && (object != menuData.getObject())
|
||||||
&& (menuController.hasBackAction() || menuData.hasBackAction())) {
|
&& (menuController.hasBackAction() || menuData.hasBackAction())) {
|
||||||
historyStack.add(menuData);
|
historyStack.add(menuData);
|
||||||
|
@ -599,16 +610,18 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
public void onSingleTapOnMap() {
|
public void onSingleTapOnMap() {
|
||||||
if (menuController == null || !menuController.handleSingleTapOnMap()) {
|
if (menuController == null || !menuController.handleSingleTapOnMap()) {
|
||||||
hide();
|
hide();
|
||||||
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn())
|
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) {
|
||||||
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
|
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchAddressDone() {
|
public void onSearchAddressDone() {
|
||||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||||
if (fragmentRef != null)
|
if (fragmentRef != null) {
|
||||||
fragmentRef.get().refreshTitle();
|
fragmentRef.get().refreshTitle();
|
||||||
|
}
|
||||||
|
|
||||||
if (searchDoneAction != null) {
|
if (searchDoneAction != null) {
|
||||||
if (searchDoneAction.dlg != null) {
|
if (searchDoneAction.dlg != null) {
|
||||||
|
|
|
@ -67,12 +67,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
ImageView fabView;
|
ImageView fabView;
|
||||||
|
|
||||||
private MapContextMenu menu;
|
private MapContextMenu menu;
|
||||||
private TitleButtonController leftTitleButtonController;
|
|
||||||
private TitleButtonController rightTitleButtonController;
|
|
||||||
private TitleButtonController topRightTitleButtonController;
|
|
||||||
private TitleButtonController leftDownloadButtonController;
|
|
||||||
private TitleButtonController rightDownloadButtonController;
|
|
||||||
private TitleProgressController titleProgressController;
|
|
||||||
|
|
||||||
private int menuTopViewHeight;
|
private int menuTopViewHeight;
|
||||||
private int menuTopShadowHeight;
|
private int menuTopShadowHeight;
|
||||||
|
@ -130,14 +124,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
nightMode = menu.isNightMode();
|
nightMode = menu.isNightMode();
|
||||||
mainView = view.findViewById(R.id.context_menu_main);
|
mainView = view.findViewById(R.id.context_menu_main);
|
||||||
|
|
||||||
leftTitleButtonController = menu.getLeftTitleButtonController();
|
|
||||||
rightTitleButtonController = menu.getRightTitleButtonController();
|
|
||||||
topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
|
||||||
|
|
||||||
leftDownloadButtonController = menu.getLeftDownloadButtonController();
|
|
||||||
rightDownloadButtonController = menu.getRightDownloadButtonController();
|
|
||||||
titleProgressController = menu.getTitleProgressController();
|
|
||||||
|
|
||||||
map = getMapActivity().getMapView();
|
map = getMapActivity().getMapView();
|
||||||
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
||||||
customMapCenter = menu.getMapCenter() != null;
|
customMapCenter = menu.getMapCenter() != null;
|
||||||
|
@ -162,71 +148,77 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
|
|
||||||
// Left title button
|
// Left title button
|
||||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||||
if (leftTitleButtonController != null) {
|
leftTitleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
leftTitleButton.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
|
||||||
|
if (leftTitleButtonController != null) {
|
||||||
leftTitleButtonController.buttonPressed();
|
leftTitleButtonController.buttonPressed();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Right title button
|
// Right title button
|
||||||
final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
|
final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
|
||||||
if (rightTitleButtonController != null) {
|
rightTitleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
rightTitleButton.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
|
||||||
|
if (rightTitleButtonController != null) {
|
||||||
rightTitleButtonController.buttonPressed();
|
rightTitleButtonController.buttonPressed();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Left download button
|
// Left download button
|
||||||
final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
|
final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
|
||||||
if (leftDownloadButtonController != null) {
|
leftDownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
leftDownloadButton.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
|
||||||
|
if (leftDownloadButtonController != null) {
|
||||||
leftDownloadButtonController.buttonPressed();
|
leftDownloadButtonController.buttonPressed();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Right download button
|
// Right download button
|
||||||
final Button rightDownloadButton = (Button) view.findViewById(R.id.download_button_right);
|
final Button rightDownloadButton = (Button) view.findViewById(R.id.download_button_right);
|
||||||
if (rightDownloadButtonController != null) {
|
rightDownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
rightDownloadButton.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
|
||||||
|
if (rightDownloadButtonController != null) {
|
||||||
rightDownloadButtonController.buttonPressed();
|
rightDownloadButtonController.buttonPressed();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Top Right title button
|
// Top Right title button
|
||||||
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
|
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
|
||||||
if (topRightTitleButtonController != null) {
|
topRightTitleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
topRightTitleButton.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
||||||
|
if (topRightTitleButtonController != null) {
|
||||||
topRightTitleButtonController.buttonPressed();
|
topRightTitleButtonController.buttonPressed();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Progress bar
|
// Progress bar
|
||||||
if (titleProgressController != null) {
|
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
|
||||||
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
|
progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark,
|
||||||
progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark,
|
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
progressButton.setOnClickListener(new View.OnClickListener() {
|
||||||
progressButton.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
TitleProgressController titleProgressController = menu.getTitleProgressController();
|
||||||
|
if (titleProgressController != null) {
|
||||||
titleProgressController.buttonPressed();
|
titleProgressController.buttonPressed();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
menu.updateData();
|
menu.updateData();
|
||||||
updateButtonsAndProgress();
|
updateButtonsAndProgress();
|
||||||
|
@ -583,6 +575,13 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
|
|
||||||
private void updateButtonsAndProgress() {
|
private void updateButtonsAndProgress() {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
|
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
|
||||||
|
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
|
||||||
|
TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
||||||
|
TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
|
||||||
|
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
|
||||||
|
TitleProgressController titleProgressController = menu.getTitleProgressController();
|
||||||
|
|
||||||
// Title buttons
|
// Title buttons
|
||||||
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
|
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
|
||||||
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
||||||
|
@ -848,12 +847,30 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
line2LineHeight = line2.getLineHeight();
|
line2LineHeight = line2.getLineHeight();
|
||||||
line2MeasuredHeight = line2.getMeasuredHeight();
|
line2MeasuredHeight = line2.getMeasuredHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dp16 = dpToPx(16f);
|
||||||
|
int titleButtonHeight = 0;
|
||||||
|
View titleButtonContainer = view.findViewById(R.id.title_button_container);
|
||||||
|
if (titleButtonContainer.getVisibility() == View.VISIBLE) {
|
||||||
|
titleButtonHeight = titleButtonContainer.getMeasuredHeight() - dp16;
|
||||||
|
}
|
||||||
|
int downloadButtonsHeight = 0;
|
||||||
|
View downloadButtonsContainer = view.findViewById(R.id.download_buttons_container);
|
||||||
|
if (downloadButtonsContainer.getVisibility() == View.VISIBLE) {
|
||||||
|
downloadButtonsHeight = downloadButtonsContainer.getMeasuredHeight() - dp16;
|
||||||
|
}
|
||||||
|
int titleProgressHeight = 0;
|
||||||
|
View titleProgressContainer = view.findViewById(R.id.title_progress_container);
|
||||||
|
if (titleProgressContainer.getVisibility() == View.VISIBLE) {
|
||||||
|
titleProgressHeight = titleProgressContainer.getMeasuredHeight() - dp16;
|
||||||
|
}
|
||||||
|
|
||||||
if (menuTopViewHeight != 0) {
|
if (menuTopViewHeight != 0) {
|
||||||
int titleHeight = line1.getLineCount() * line1.getLineHeight() + line2LineCount * line2LineHeight + menuTitleTopBottomPadding;
|
int titleHeight = line1.getLineCount() * line1.getLineHeight() + line2LineCount * line2LineHeight + menuTitleTopBottomPadding;
|
||||||
if (titleHeight < line1.getMeasuredHeight() + line2MeasuredHeight) {
|
if (titleHeight < line1.getMeasuredHeight() + line2MeasuredHeight) {
|
||||||
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
|
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
|
||||||
}
|
}
|
||||||
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight;
|
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight + titleButtonHeight + downloadButtonsHeight + titleProgressHeight;
|
||||||
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight - (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
|
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight - (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
|
||||||
} else {
|
} else {
|
||||||
menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight;
|
menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.mapcontextmenu;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -86,6 +87,7 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
MULTI_LINE
|
MULTI_LINE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected MapContextMenu mapContextMenu;
|
||||||
protected MenuBuilder builder;
|
protected MenuBuilder builder;
|
||||||
private int currentMenuState;
|
private int currentMenuState;
|
||||||
private MenuType menuType = MenuType.STANDARD;
|
private MenuType menuType = MenuType.STANDARD;
|
||||||
|
@ -117,6 +119,10 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
this.builder.setLight(isLight());
|
this.builder.setLight(isLight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMapContextMenu(MapContextMenu mapContextMenu) {
|
||||||
|
this.mapContextMenu = mapContextMenu;
|
||||||
|
}
|
||||||
|
|
||||||
public void build(View rootView) {
|
public void build(View rootView) {
|
||||||
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
|
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
|
||||||
if (plugin.isMenuControllerSupported(this.getClass())) {
|
if (plugin.isMenuControllerSupported(this.getClass())) {
|
||||||
|
@ -531,114 +537,137 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildMapDownloadButton(LatLon latLon) {
|
public void buildMapDownloadButton(final LatLon latLon) {
|
||||||
int point31x = MapUtils.get31TileNumberX(latLon.getLongitude());
|
new AsyncTask<Void, Void, BinaryMapDataObject>() {
|
||||||
int point31y = MapUtils.get31TileNumberY(latLon.getLatitude());
|
|
||||||
|
|
||||||
ResourceManager rm = getMapActivity().getMyApplication().getResourceManager();
|
ResourceManager rm;
|
||||||
OsmandRegions osmandRegions = rm.getOsmandRegions();
|
OsmandRegions osmandRegions;
|
||||||
|
|
||||||
List<BinaryMapDataObject> mapDataObjects = null;
|
|
||||||
try {
|
|
||||||
mapDataObjects = osmandRegions.queryBbox(point31x, point31x, point31y, point31y);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapDataObjects != null) {
|
|
||||||
Iterator<BinaryMapDataObject> it = mapDataObjects.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
BinaryMapDataObject o = it.next();
|
|
||||||
if (o.getTypes() != null) {
|
|
||||||
boolean isRegion = true;
|
|
||||||
for (int i = 0; i < o.getTypes().length; i++) {
|
|
||||||
TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
|
|
||||||
if ("boundary".equals(tp.value)) {
|
|
||||||
isRegion = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isRegion || !osmandRegions.contain(o, point31x, point31y)) {
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String selectedFullName = "";
|
String selectedFullName = "";
|
||||||
double smallestArea = -1;
|
|
||||||
downloadMapDataObject = null;
|
@Override
|
||||||
for (BinaryMapDataObject o : mapDataObjects) {
|
protected void onPreExecute() {
|
||||||
String downloadName = osmandRegions.getDownloadName(o);
|
rm = getMapActivity().getMyApplication().getResourceManager();
|
||||||
if (!Algorithms.isEmpty(downloadName)) {
|
osmandRegions = rm.getOsmandRegions();
|
||||||
boolean downloaded = checkIfObjectDownloaded(rm, downloadName);
|
}
|
||||||
if (downloaded) {
|
|
||||||
downloadMapDataObject = null;
|
@Override
|
||||||
break;
|
protected BinaryMapDataObject doInBackground(Void... voids) {
|
||||||
} else {
|
|
||||||
String fullName = osmandRegions.getFullName(o);
|
int point31x = MapUtils.get31TileNumberX(latLon.getLongitude());
|
||||||
WorldRegion region = osmandRegions.getRegionData(fullName);
|
int point31y = MapUtils.get31TileNumberY(latLon.getLatitude());
|
||||||
if (region != null && region.isRegionMapDownload()) {
|
|
||||||
double area = OsmandRegions.getArea(o);
|
List<BinaryMapDataObject> mapDataObjects = null;
|
||||||
if (smallestArea == -1) {
|
try {
|
||||||
smallestArea = area;
|
mapDataObjects = osmandRegions.queryBbox(point31x, point31x, point31y, point31y);
|
||||||
selectedFullName = fullName;
|
} catch (IOException e) {
|
||||||
downloadMapDataObject = o;
|
e.printStackTrace();
|
||||||
} else if (area < smallestArea) {
|
}
|
||||||
smallestArea = area;
|
|
||||||
selectedFullName = fullName;
|
BinaryMapDataObject binaryMapDataObject = null;
|
||||||
downloadMapDataObject = o;
|
if (mapDataObjects != null) {
|
||||||
|
Iterator<BinaryMapDataObject> it = mapDataObjects.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
BinaryMapDataObject o = it.next();
|
||||||
|
if (o.getTypes() != null) {
|
||||||
|
boolean isRegion = true;
|
||||||
|
for (int i = 0; i < o.getTypes().length; i++) {
|
||||||
|
TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
|
||||||
|
if ("boundary".equals(tp.value)) {
|
||||||
|
isRegion = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isRegion || !osmandRegions.contain(o, point31x, point31y)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double smallestArea = -1;
|
||||||
|
for (BinaryMapDataObject o : mapDataObjects) {
|
||||||
|
String downloadName = osmandRegions.getDownloadName(o);
|
||||||
|
if (!Algorithms.isEmpty(downloadName)) {
|
||||||
|
boolean downloaded = checkIfObjectDownloaded(rm, downloadName);
|
||||||
|
if (downloaded) {
|
||||||
|
binaryMapDataObject = null;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
String fullName = osmandRegions.getFullName(o);
|
||||||
|
WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
|
if (region != null && region.isRegionMapDownload()) {
|
||||||
|
double area = OsmandRegions.getArea(o);
|
||||||
|
if (smallestArea == -1) {
|
||||||
|
smallestArea = area;
|
||||||
|
selectedFullName = fullName;
|
||||||
|
binaryMapDataObject = o;
|
||||||
|
} else if (area < smallestArea) {
|
||||||
|
smallestArea = area;
|
||||||
|
selectedFullName = fullName;
|
||||||
|
binaryMapDataObject = o;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return binaryMapDataObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
downloaded = downloadMapDataObject == null;
|
@Override
|
||||||
if (!downloaded) {
|
protected void onPostExecute(BinaryMapDataObject binaryMapDataObject) {
|
||||||
downloadThread = getMapActivity().getMyApplication().getDownloadThread();
|
downloadMapDataObject = binaryMapDataObject;
|
||||||
downloadRegion = osmandRegions.getRegionData(selectedFullName);
|
downloaded = downloadMapDataObject == null;
|
||||||
if (downloadRegion != null && downloadRegion.isRegionMapDownload()) {
|
if (!downloaded) {
|
||||||
List<IndexItem> indexItems = downloadThread.getIndexes().getIndexItems(downloadRegion);
|
downloadThread = getMapActivity().getMyApplication().getDownloadThread();
|
||||||
for (IndexItem item : indexItems) {
|
downloadRegion = osmandRegions.getRegionData(selectedFullName);
|
||||||
if (item.getType() == DownloadActivityType.NORMAL_FILE
|
if (downloadRegion != null && downloadRegion.isRegionMapDownload()) {
|
||||||
&& (item.isDownloaded() || downloadThread.isDownloading(item))) {
|
List<IndexItem> indexItems = downloadThread.getIndexes().getIndexItems(downloadRegion);
|
||||||
indexItem = item;
|
for (IndexItem item : indexItems) {
|
||||||
}
|
if (item.getType() == DownloadActivityType.NORMAL_FILE
|
||||||
}
|
&& (item.isDownloaded() || downloadThread.isDownloading(item))) {
|
||||||
}
|
indexItem = item;
|
||||||
|
|
||||||
leftDownloadButtonController = new TitleButtonController() {
|
|
||||||
@Override
|
|
||||||
public void buttonPressed() {
|
|
||||||
if (indexItem != null) {
|
|
||||||
if (indexItem.getType() == DownloadActivityType.NORMAL_FILE) {
|
|
||||||
new DownloadValidationManager(getMapActivity().getMyApplication())
|
|
||||||
.startDownload(getMapActivity(), indexItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
leftDownloadButtonController.caption =
|
|
||||||
downloadRegion != null ? downloadRegion.getLocaleName() : getMapActivity().getString(R.string.shared_string_download);
|
|
||||||
leftDownloadButtonController.leftIconId = R.drawable.ic_action_import;
|
|
||||||
|
|
||||||
titleProgressController = new TitleProgressController() {
|
leftDownloadButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
if (indexItem != null) {
|
if (indexItem != null) {
|
||||||
downloadThread.cancelDownload(indexItem);
|
if (indexItem.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||||
|
new DownloadValidationManager(getMapActivity().getMyApplication())
|
||||||
|
.startDownload(getMapActivity(), indexItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
leftDownloadButtonController.caption =
|
||||||
|
downloadRegion != null ? downloadRegion.getLocaleName() : getMapActivity().getString(R.string.shared_string_download);
|
||||||
|
leftDownloadButtonController.leftIconId = R.drawable.ic_action_import;
|
||||||
|
|
||||||
|
titleProgressController = new TitleProgressController() {
|
||||||
|
@Override
|
||||||
|
public void buttonPressed() {
|
||||||
|
if (indexItem != null) {
|
||||||
|
downloadThread.cancelDownload(indexItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
|
||||||
|
if (getMapActivity().getMyApplication().getSettings().isInternetConnectionAvailable()) {
|
||||||
|
downloadThread.runReloadIndexFiles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
|
if (mapContextMenu != null) {
|
||||||
if (getMapActivity().getMyApplication().getSettings().isInternetConnectionAvailable()) {
|
mapContextMenu.updateMenuUI();
|
||||||
downloadThread.runReloadIndexFiles();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIfObjectDownloaded(ResourceManager rm, String downloadName) {
|
private boolean checkIfObjectDownloaded(ResourceManager rm, String downloadName) {
|
||||||
|
|
Loading…
Reference in a new issue