commit
c136e84f5d
1 changed files with 44 additions and 24 deletions
|
@ -52,6 +52,7 @@ import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
|
||||||
|
@ -115,6 +116,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
String transparencyStr = (int) value + "%";
|
String transparencyStr = (int) value + "%";
|
||||||
transparencyValueTv.setText(transparencyStr);
|
transparencyValueTv.setText(transparencyStr);
|
||||||
srtmPlugin.setTerrainTransparency((int) Math.ceil(value * 2.55), srtmPlugin.getTerrainMode());
|
srtmPlugin.setTerrainTransparency((int) Math.ceil(value * 2.55), srtmPlugin.getTerrainMode());
|
||||||
|
refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -127,10 +129,20 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
minZoomTv.setText(String.valueOf(values.get(0).intValue()));
|
minZoomTv.setText(String.valueOf(values.get(0).intValue()));
|
||||||
maxZoomTv.setText(String.valueOf(values.get(1).intValue()));
|
maxZoomTv.setText(String.valueOf(values.get(1).intValue()));
|
||||||
srtmPlugin.setTerrainZoomValues(values.get(0).intValue(), values.get(1).intValue(), srtmPlugin.getTerrainMode());
|
srtmPlugin.setTerrainZoomValues(values.get(0).intValue(), values.get(1).intValue(), srtmPlugin.getTerrainMode());
|
||||||
|
refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private MapActivity getMapActivity() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity instanceof MapActivity && !activity.isFinishing()) {
|
||||||
|
return (MapActivity) activity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
app = requireMyApplication();
|
app = requireMyApplication();
|
||||||
|
@ -365,13 +377,17 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refreshMap() {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.getMapView().refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateLayers() {
|
private void updateLayers() {
|
||||||
Activity activity = getActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (activity instanceof MapActivity) {
|
if (mapActivity != null) {
|
||||||
srtmPlugin.updateLayers(
|
srtmPlugin.updateLayers(mapActivity.getMapView(), mapActivity);
|
||||||
((MapActivity) activity).getMapView(),
|
|
||||||
(MapActivity) activity
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,10 +397,11 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
adapter.setProfileDependent(true);
|
adapter.setProfileDependent(true);
|
||||||
adapter.setNightMode(nightMode);
|
adapter.setNightMode(nightMode);
|
||||||
|
|
||||||
final Activity mapActivity = getActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (!(mapActivity instanceof MapActivity)) {
|
if (mapActivity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
|
|
||||||
final DownloadIndexesThread downloadThread = app.getDownloadThread();
|
final DownloadIndexesThread downloadThread = app.getDownloadThread();
|
||||||
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
|
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
|
||||||
|
@ -425,6 +442,8 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
|
||||||
|
MapActivity mapActivity = mapActivityRef.get();
|
||||||
|
if (mapActivity != null && !mapActivity.isFinishing()) {
|
||||||
ContextMenuItem item = adapter.getItem(position);
|
ContextMenuItem item = adapter.getItem(position);
|
||||||
if (downloadThread.isDownloading(indexItem)) {
|
if (downloadThread.isDownloading(indexItem)) {
|
||||||
downloadThread.cancelDownload(indexItem);
|
downloadThread.cancelDownload(indexItem);
|
||||||
|
@ -435,7 +454,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new DownloadValidationManager(app).startDownload((MapActivity) mapActivity, indexItem);
|
new DownloadValidationManager(app).startDownload(mapActivity, indexItem);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setProgress(ContextMenuItem.INVALID_ID);
|
item.setProgress(ContextMenuItem.INVALID_ID);
|
||||||
item.setLoading(true);
|
item.setLoading(true);
|
||||||
|
@ -443,6 +462,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue