commit
4e62896c0a
5 changed files with 72 additions and 56 deletions
|
@ -11,6 +11,7 @@ import net.osmand.binary.RouteDataBundle;
|
|||
import net.osmand.binary.StringBundle;
|
||||
import net.osmand.binary.StringBundleWriter;
|
||||
import net.osmand.binary.StringBundleXmlWriter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
|
@ -38,20 +39,22 @@ public class RouteExporter {
|
|||
RouteDataResources resources = new RouteDataResources(locations);
|
||||
final RouteDataBundle bundle = new RouteDataBundle(resources);
|
||||
|
||||
for (RouteSegmentResult sr : route) {
|
||||
sr.collectTypes(resources);
|
||||
}
|
||||
for (RouteSegmentResult sr : route) {
|
||||
sr.collectNames(resources);
|
||||
}
|
||||
if (!Algorithms.isEmpty(route)) {
|
||||
for (RouteSegmentResult sr : route) {
|
||||
sr.collectTypes(resources);
|
||||
}
|
||||
for (RouteSegmentResult sr : route) {
|
||||
sr.collectNames(resources);
|
||||
}
|
||||
|
||||
List<StringBundle> routeItems = new ArrayList<>();
|
||||
for (RouteSegmentResult sr : route) {
|
||||
RouteDataBundle itemBundle = new RouteDataBundle(resources);
|
||||
sr.writeToBundle(itemBundle);
|
||||
routeItems.add(itemBundle);
|
||||
List<StringBundle> routeItems = new ArrayList<>();
|
||||
for (RouteSegmentResult sr : route) {
|
||||
RouteDataBundle itemBundle = new RouteDataBundle(resources);
|
||||
sr.writeToBundle(itemBundle);
|
||||
routeItems.add(itemBundle);
|
||||
}
|
||||
bundle.putBundleList("route", "segment", routeItems);
|
||||
}
|
||||
bundle.putBundleList("route", "segment", routeItems);
|
||||
|
||||
List<StringBundle> typeList = new ArrayList<>();
|
||||
Map<RouteTypeRule, Integer> rules = resources.getRules();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
android:id="@+id/ZoomToDownload"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="fill_parent"
|
||||
android:stepSize="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
|
|
|
@ -51,11 +51,12 @@ public class DownloadTilesDialog {
|
|||
|
||||
public void openDialog(){
|
||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||
if(!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()){
|
||||
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
||||
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||
if(mapSource == null || !mapSource.couldBeDownloadedFromInternet()){
|
||||
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
||||
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
@ -66,29 +67,28 @@ public class DownloadTilesDialog {
|
|||
|
||||
// calculate pixel rectangle
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||
LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.download_tiles, null);
|
||||
|
||||
|
||||
|
||||
((TextView)view.findViewById(R.id.MinZoom)).setText(zoom+""); //$NON-NLS-1$
|
||||
((TextView)view.findViewById(R.id.MaxZoom)).setText(max+""); //$NON-NLS-1$
|
||||
|
||||
((TextView) view.findViewById(R.id.MinZoom)).setText(String.valueOf(zoom));
|
||||
((TextView) view.findViewById(R.id.MaxZoom)).setText(String.valueOf(max));
|
||||
|
||||
final Slider slider = (Slider) view.findViewById(R.id.ZoomToDownload);
|
||||
slider.setValueTo(max - zoom);
|
||||
int progress = (max - zoom) / 2;
|
||||
slider.setValue(progress);
|
||||
|
||||
final TextView downloadText = ((TextView) view.findViewById(R.id.DownloadDescription));
|
||||
final String template = ctx.getString(R.string.tiles_to_download_estimated_size);
|
||||
|
||||
|
||||
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) slider.getValue());
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) value);
|
||||
}
|
||||
});
|
||||
if (max > zoom) {
|
||||
slider.setValueTo(max - zoom);
|
||||
int progress = (max - zoom) / 2;
|
||||
slider.setValue(progress);
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
builder.setPositiveButton(R.string.shared_string_download, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.squareup.picasso.Picasso;
|
|||
|
||||
import net.osmand.PicassoUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -56,19 +57,24 @@ public class ImagesPagerAdapter extends PagerAdapter {
|
|||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
|
||||
final String imageUrl = imageUrls.get(position);
|
||||
Picasso.get().load(imageUrl).into(imageView, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
picassoUtils.setResultLoaded(imageUrl, true);
|
||||
}
|
||||
if (!Algorithms.isEmpty(imageUrl)) {
|
||||
Picasso.get().load(imageUrl).into(imageView, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
picassoUtils.setResultLoaded(imageUrl, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
picassoUtils.setResultLoaded(imageUrl, false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
picassoUtils.setResultLoaded(imageUrl, false);
|
||||
}
|
||||
});
|
||||
return imageView;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -167,8 +166,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
@Override
|
||||
public void setCategory(String name, int color) {
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
if (helper != null) {
|
||||
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
||||
Context ctx = getContext();
|
||||
if (helper != null && ctx != null) {
|
||||
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(ctx, name));
|
||||
this.group = group;
|
||||
super.setCategory(name, group != null ? group.getColor() : 0);
|
||||
}
|
||||
|
@ -176,10 +176,13 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
|
||||
@Override
|
||||
protected String getLastUsedGroup() {
|
||||
OsmandApplication app = requireMyApplication();
|
||||
String lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||
lastCategory = "";
|
||||
String lastCategory = "";
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||
lastCategory = "";
|
||||
}
|
||||
}
|
||||
return lastCategory;
|
||||
}
|
||||
|
@ -325,11 +328,14 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
private void doEditFavorite(FavouritePoint favorite, String name, String category, String description,
|
||||
@ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId,
|
||||
FavouritesDbHelper helper) {
|
||||
requireMyApplication().getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
}
|
||||
}
|
||||
|
||||
private void doAddFavorite(String name, String category, String description, @ColorInt int color,
|
||||
|
|
Loading…
Reference in a new issue